coze_lab 0.1.44 → 0.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -58
- package/index.js +95 -405
- package/package.json +1 -2
- package/scripts/claude-code/cozeloop_hook.py +6 -244
- package/scripts/codex/cozeloop_hook.py +7 -371
- package/scripts/openclaw/dist/cozeloop-exporter.js +11 -183
- package/scripts/openclaw/dist/index.js +1 -1
- package/scripts/openclaw/openclaw.plugin.json +2 -2
- package/scripts/openclaw/package.json +1 -1
- package/scripts/shared/cozeloop_refresh.py +0 -57
package/README.md
CHANGED
|
@@ -5,56 +5,52 @@ Configure local AI agents (Claude Code, Codex, OpenClaw) to report traces to Coz
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
#
|
|
9
|
-
npx coze_lab --agent=<type>
|
|
10
|
-
|
|
11
|
-
# Per-agent setup. Cloud/local is inferred from coze-bridge config or CLOUD_ENV=1.
|
|
8
|
+
# Per-agent setup. Local/cloud is inferred from ~/.coze/agents/<agentId>/config.json.
|
|
12
9
|
npx coze_lab --agent-id=<agentId>
|
|
13
10
|
|
|
14
|
-
#
|
|
15
|
-
npx coze_lab --
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
npx coze_lab --
|
|
11
|
+
# Cloud compatibility mode when the caller already knows the framework.
|
|
12
|
+
npx coze_lab --cloud --agent=<claude-code|codex|openclaw>
|
|
13
|
+
|
|
14
|
+
# Send a one-off trace selfcheck. Uses --agent-id patToken locally, or env token in cloud.
|
|
15
|
+
npx coze_lab --verify --agent-id=<agentId> --pair-code=<pairCode>
|
|
19
16
|
```
|
|
20
17
|
|
|
21
18
|
### Parameters
|
|
22
19
|
|
|
23
20
|
| Parameter | Required | Values / Effect |
|
|
24
21
|
|-----------|----------|-----------------|
|
|
25
|
-
| `--agent` |
|
|
26
|
-
| `--agent
|
|
27
|
-
| `--cloud` |
|
|
28
|
-
| `--codex-home` |
|
|
29
|
-
| `--
|
|
30
|
-
| `--
|
|
31
|
-
| `--
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
> **Note — traces are collected into a shared CozeLoop workspace.**
|
|
22
|
+
| `--agent-id` | Local setup | Resolve `~/.coze/agents/<agentId>/config.json`, infer framework/workspace, and read `patToken` for local trace upload |
|
|
23
|
+
| `--agent` | Cloud compatibility only | `claude-code`, `codex`, `openclaw` when no agent config is available |
|
|
24
|
+
| `--cloud` | Optional | Forces cloud mode; token must come from `COZELOOP_API_TOKEN` or `COZE_API_TOKEN` |
|
|
25
|
+
| `--codex-home` | Optional | Override Codex config home for custom cloud runs |
|
|
26
|
+
| `--force` | Optional | Force OpenClaw plugin rewrite/reinstall and gateway restart |
|
|
27
|
+
| `--verify` | Optional | Send a test trace; local requires `--agent-id` with `patToken`, cloud requires env token |
|
|
28
|
+
| `--pair-code` | Optional | Add a trace lookup code to selfcheck metadata |
|
|
29
|
+
|
|
30
|
+
> **Note - traces are collected into a shared CozeLoop workspace.**
|
|
35
31
|
> All traces from this tool are uploaded to a single fixed workspace
|
|
36
|
-
> (`COZELOOP_WORKSPACE_ID`) maintained by the CozeLoop team
|
|
37
|
-
>
|
|
38
|
-
> your identity for trace ingestion; it does not select a workspace.
|
|
32
|
+
> (`COZELOOP_WORKSPACE_ID`) maintained by the CozeLoop team; they are not sent
|
|
33
|
+
> to each user's personal workspace.
|
|
39
34
|
|
|
35
|
+
## What It Does
|
|
40
36
|
|
|
41
|
-
|
|
37
|
+
1. **Token resolution** - Local mode reads `patToken` from `~/.coze/agents/<agentId>/config.json`. Cloud mode reads `COZELOOP_API_TOKEN` or `COZE_API_TOKEN` from the environment.
|
|
38
|
+
2. **Agent detection** - Verifies the specified agent binary is installed locally.
|
|
39
|
+
3. **Environment checks** - Python >= 3.8 + `cozeloop` SDK for Claude Code and Codex; SDK is auto-installed via pip if missing. Agent version whitelist warnings are non-fatal.
|
|
40
|
+
4. **Hook configuration** - Writes hook scripts and config files for the selected agent.
|
|
41
|
+
5. **Selfcheck** - Sends a test trace with the resolved token.
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
- No token / refresh failed → launches Device Code OAuth flow: opens browser, displays verification URL, polls until user approves.
|
|
47
|
-
2. **Agent detection** — Verifies the specified agent binary is installed locally.
|
|
48
|
-
3. **Environment checks** — Python ≥ 3.8 + `cozeloop` SDK (Claude Code & Codex only; SDK auto-installed via pip if missing), agent version whitelist check.
|
|
49
|
-
4. **Hook configuration** — Writes hook scripts and config files for the selected agent.
|
|
43
|
+
There is no Device Code login, OAuth cache, or refresh-token fallback. Legacy
|
|
44
|
+
`--login`, `--status`, `--refresh`, `--logout`, and local `--agent=<type>`
|
|
45
|
+
commands fail with a migration message.
|
|
50
46
|
|
|
51
|
-
## Per-
|
|
47
|
+
## Per-Agent Hook Files
|
|
52
48
|
|
|
53
|
-
| Agent | Hook script | Config file |
|
|
54
|
-
|
|
55
|
-
| `claude-code` | `~/.claude/hooks/cozeloop_hook.py` | `~/.claude/settings.json` | `.claude/settings.local.json`
|
|
56
|
-
| `codex` |
|
|
57
|
-
| `openclaw` |
|
|
49
|
+
| Agent | Hook script | Config file | Token environment |
|
|
50
|
+
|-------|-------------|-------------|-------------------|
|
|
51
|
+
| `claude-code` | `~/.claude/hooks/cozeloop_hook.py` | `~/.claude/settings.json` or agent workspace `.claude/settings.json` | `.claude/settings.local.json` |
|
|
52
|
+
| `codex` | `<CODEX_HOME>/hooks/cozeloop_hook.py` | `<CODEX_HOME>/hooks.json` | `<CODEX_HOME>/hooks/cozeloop.env` |
|
|
53
|
+
| `openclaw` | Node.js plugin | `~/.openclaw/openclaw.json` | inline `authorization` |
|
|
58
54
|
|
|
59
55
|
For cloud Codex with `--agent-id=<agentId>`, Codex hooks are written to
|
|
60
56
|
`~/.coze/agents/<agentId>/codex-home` by default. The directory is created if it
|
|
@@ -66,32 +62,26 @@ Codex home. For cloud Codex, check
|
|
|
66
62
|
`~/.coze/agents/<agentId>/codex-home/hooks/cozeloop.log`. If that file is not
|
|
67
63
|
created after a new Codex turn, Codex did not load or execute the hook.
|
|
68
64
|
|
|
69
|
-
## Token
|
|
65
|
+
## Token Lifecycle
|
|
70
66
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
PAT directly and skips the OAuth device-code flow.
|
|
67
|
+
Local setup requires `~/.coze/agents/<agentId>/config.json` to contain
|
|
68
|
+
`patToken`. Onboarding writes that PAT into the selected agent's hook
|
|
69
|
+
configuration and marks the source as `agent_config.patToken`.
|
|
75
70
|
|
|
76
|
-
|
|
77
|
-
`
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
For Python SDK uploads, `OTEL_ENDPOINT` is not used as the SDK base URL; set
|
|
81
|
-
`COZELOOP_API_BASE_URL` only when the SDK ingest endpoint should be overridden.
|
|
71
|
+
Cloud setup and verification prefer `COZELOOP_API_TOKEN` and fall back to
|
|
72
|
+
`COZE_API_TOKEN`. The selfcheck result is authoritative: if the token does not
|
|
73
|
+
have trace ingest permission, cloud onboard still writes hook configuration but
|
|
74
|
+
reports `verify=fail` with `token_source`.
|
|
82
75
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
3. Updates `credentials.json` with the new token
|
|
88
|
-
4. Passes the fresh token to the CozeLoop SDK before uploading traces
|
|
76
|
+
At hook execution time, Claude Code, Codex, and OpenClaw use only the token
|
|
77
|
+
written by onboarding or injected by cloud env. They do not read
|
|
78
|
+
`~/.cozeloop/credentials.json` and do not refresh tokens locally. If a token is
|
|
79
|
+
revoked or rotated, rerun `npx coze_lab --agent-id=<agentId>`.
|
|
89
80
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
**For OpenClaw**, the token is read from `openclaw.json` at startup. Re-run `npx coze_lab --agent=openclaw` to refresh it if OpenClaw reports auth errors.
|
|
81
|
+
For Python SDK uploads, `OTEL_ENDPOINT` is not used as the SDK base URL; set
|
|
82
|
+
`COZELOOP_API_BASE_URL` only when the SDK ingest endpoint should be overridden.
|
|
93
83
|
|
|
94
|
-
## Supported
|
|
84
|
+
## Supported Versions
|
|
95
85
|
|
|
96
86
|
| Agent | Supported versions |
|
|
97
87
|
|-------|--------------------|
|
|
@@ -99,4 +89,4 @@ This means traces continue to upload without interruption even across token expi
|
|
|
99
89
|
| `codex` | 0.134.x, 1.0.x, 1.1.x |
|
|
100
90
|
| `openclaw` | 2026.3.x, 2026.4.x, 2026.5.x |
|
|
101
91
|
|
|
102
|
-
Versions outside this list
|
|
92
|
+
Versions outside this list show a warning but onboarding continues.
|