merge(dev): resolve usage cap conflicts

This commit is contained in:
Goon committed 2026-05-24 13:49:40 +07:00
commit 7fee3073df
111 files changed
+3956 -248

No files matched your search

+1 -1
View File
@@ -69,7 +69,7 @@ The consumer routes system messages based on sender ID prefixes:
### Inbound Debounce
Normal channel messages pass through the shared inbound debouncer before agent execution. `gateway.inbound_debounce_ms` merges rapid text messages from the same `channel:chatID:senderID`; `0` uses the 1000ms default and `-1` disables debounce. Media messages bypass the wait window after flushing pending text, and command/control messages such as stop/reset and system escalations bypass debounce.
Normal channel messages pass through the shared inbound debouncer before agent execution. `gateway.inbound_debounce_ms` merges rapid text messages from the same `channel:chatID:senderID:agentID`; `0` means no debounce and positive values set the wait window. Agents can override the global value with `other_config.inbound_debounce_ms`; unset inherits the global config. Media messages bypass the wait window after flushing pending text, and command/control messages such as stop/reset and system escalations bypass debounce.
---
+1 -1
View File
@@ -108,7 +108,7 @@ Agent `budget_monthly_cents` values are bridged into `usage_cap_policies` with `
Migration versions:
- PostgreSQL: `000069_usage_caps_pricing`, `000070_usage_cap_policies`, `000071_agent_budget_usage_cap_bridge`.
- PostgreSQL: `000070_usage_caps_pricing`, `000071_usage_cap_policies`, `000072_agent_budget_usage_cap_bridge`.
- SQLite: no schema change; feature is not active in Lite.
---
+6 -4
View File
@@ -135,7 +135,7 @@ To install additional packages: pip3 install <pkg> or npm install -g <pkg>
- Run Python/Node scripts via exec tool
- Install packages via `pip3 install` / `npm install -g`
- Access files in `/app/workspace/` including `.media/` subdirectory
- Access files in `/app/workspace/`, including `.uploads/` for current user uploads and `.media/` for legacy media refs
- Read skill files from `.goclaw/skills-store/`
### What Agents CANNOT Do
@@ -152,16 +152,18 @@ To install additional packages: pip3 install <pkg> or npm install -g <pkg>
Uploaded files (from web chat, Telegram, Discord, etc.) are persisted to:
```
/app/workspace/.media/{sessionHash}/{uuid}.{ext}
/app/workspace/.uploads/{safe-original-name}-{8hex}.{ext}
```
Uploads without a usable original filename fall back to `{uuid}.{ext}`. Legacy media refs may still resolve from `.media/{sessionHash}/{uuid}.{ext}`.
The `enrichDocumentPaths()` function injects the full path into `<media:document>` tags:
```
<media:document name="report.pdf" path="/app/workspace/.media/abc123/uuid.pdf">
<media:document name="report.pdf" path="/app/workspace/.uploads/report-a1b2c3d4.pdf">
```
Agents can read these files directly via exec — no copy to `/tmp` needed.
Agents can read these files directly via exec — no copy to `/tmp` needed. For archive uploads such as `.zip`, inspect or extract with commands like `unzip -l "<path>"` or `unzip -q "<path>" -d <output-dir>`.
---
+33
View File
@@ -38,6 +38,39 @@ API keys are hashed with SHA-256 before lookup — the raw key is never stored.
---
## Browser Cookie Sync
Selected-cookie sync stores user-approved browser cookies for server-side browser automation. Endpoints require operator auth and `X-GoClaw-User-Id`; the request body cannot set `tenant_id` or `user_id`.
| Method | Path | Description |
|--------|------|-------------|
| `POST` | `/v1/browser/cookies/sync` | Store selected cookies for one `agent_id` |
| `GET` | `/v1/browser/cookies?agent_id=...` | List synced cookie metadata; values are redacted |
| `DELETE` | `/v1/browser/cookies?agent_id=...&domain=...&name=...` | Delete scoped synced cookies |
Example sync request:
```json
{
"agent_id": "default",
"source": "chrome-selected-cookie-sync",
"cookies": [{
"domain": ".example.com",
"name": "session",
"path": "/",
"value": "cookie-value",
"secure": true,
"httpOnly": true,
"sameSite": "lax",
"expirationDate": 1770000000
}]
}
```
See [Browser Cookie Sync Threat Model](browser-cookie-sync-threat-model.md) for isolation and encryption details.
---
## 2. Chat Completions
OpenAI-compatible chat API for programmatic access to agents.
+1 -1
View File
@@ -106,7 +106,7 @@ Send a message to an agent and trigger execution.
When `stream: true`, intermediate events are emitted: `chunk`, `tool.call`, `tool.result`, `run.started`, `run.completed`.
Rapid text-only `chat.send` requests for the same user and session are debounced by `gateway.inbound_debounce_ms`: `0` uses the 1000ms default and `-1` disables debounce. The merged message keeps request params from the latest send and joins text with newlines. Cancel keywords bypass debounce and abort the active run immediately. Media sends bypass the wait window and drain any pending text into the same dispatch.
Rapid text-only `chat.send` requests for the same user and session are debounced by `gateway.inbound_debounce_ms`: `0` means no debounce and positive values set the wait window. Agents can override the global value with `other_config.inbound_debounce_ms`; unset inherits the global config. The merged message keeps request params from the latest send and joins text with newlines. Cancel keywords bypass debounce and abort the active run immediately. Media sends bypass the wait window and drain any pending text into the same dispatch.
### `chat.history`
+43
View File
@@ -0,0 +1,43 @@
# Browser Cookie Sync Threat Model
Selected cookie sync lets a user copy specific Chrome cookies into a GoClaw server-side browser session for one agent.
## Assets
- Browser cookies and session tokens.
- Tenant, user, and agent isolation boundaries.
- Server-side browser incognito contexts.
- Audit logs showing sync and delete events.
## Trust Boundaries
- Chrome extension runs on the user's machine and only sends cookies after explicit selection.
- HTTP API derives tenant and user from gateway auth, API key auth, or paired-browser auth.
- Client payload may choose `agent_id`, but cannot choose `tenant_id` or `user_id`.
- Cookie values are encrypted before database persistence.
## Controls
- `POST /v1/browser/cookies/sync`, `GET /v1/browser/cookies`, and `DELETE /v1/browser/cookies` require operator auth.
- Sync fails when the request context has no user or no agent.
- Store unique key is `(tenant_id, user_id, agent_id, domain, path, name)`.
- Cookie values are encrypted at rest and never returned by list responses.
- Browser runtime applies cookies only to matching domain/path for the same tenant, user, and agent scope.
- Extension asks for active-site host permission and sends only checked cookies.
## Main Risks
| Risk | Mitigation |
|------|------------|
| Cross-user cookie leak | Store and browser scope include `tenant_id`, `user_id`, and `agent_id`. |
| Client spoofs user | API ignores user fields in JSON body; user comes from auth context. |
| Plaintext persistence | Cookie store fails closed when encryption key is missing. |
| Oversized cookie payload | API caps body size, cookie count, and per-cookie value size. |
| Overbroad extension access | Extension requests host permission for the current origin before reading cookies. |
| Accidental value exposure | List endpoint returns metadata only. Logs never include cookie values. |
## Operational Notes
- Set `GOCLAW_ENCRYPTION_KEY` before enabling cookie sync.
- Revoke synced cookies with `DELETE /v1/browser/cookies?agent_id=<agent>&domain=<domain>`.
- Restart the gateway after changing browser launch settings that affect manager startup.
+23
View File
@@ -4,6 +4,27 @@ Significant changes, features, and fixes in reverse chronological order.
---
## 2026-05-24
### Browser cookie sync and config UI
**Features**
- Added scoped browser cookie sync API, encrypted cookie store, browser runtime cookie application, dashboard browser settings, and a selected-cookie Chrome extension prototype.
### Cron SecureCLI credential context
**Fixes**
- Fixed cron-triggered agent turns so credentialed CLI lookups preserve the explicit tenant user credential identity captured when the cron job is created.
- Kept cron `user_id` ownership unchanged for group-scoped list/remove behavior while storing credential lookup identity separately in cron payload metadata.
**Tests**
- Added regression coverage for cron payload credential metadata, legacy payload compatibility, cron scheduler context injection, and SQLite cron persistence parity.
---
## 2026-05-22
### Usage Cap budget controls
@@ -30,11 +51,13 @@ Significant changes, features, and fixes in reverse chronological order.
**Features**
- Added per-agent inbound debounce override via `other_config.inbound_debounce_ms`; unset inherits the global gateway setting.
- Added Web Chat debounce for rapid text-only `chat.send` calls using `gateway.inbound_debounce_ms`.
- Clarified shared inbound debounce behavior in docs and Web UI config help text.
**Fixes**
- Fixed inbound debounce semantics so `gateway.inbound_debounce_ms=0` means no debounce and positive values set the wait window.
- Fixed Slack `debounce_delay: 0` so it disables per-thread batching instead of falling back to the default.
**Tests**