agy-mcp-bridge 0.1.9 → 0.1.10
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
CHANGED
|
@@ -250,6 +250,10 @@ Luồng sử dụng trong Codex hoặc Claude Code:
|
|
|
250
250
|
|
|
251
251
|
`completed` chỉ là CLI chạy xong và có envelope hợp lệ. Luôn `review_required=true`, `acceptance_verified=false`. SUCCESS/exit 0 vẫn có thể bị bridge đánh dấu failed do permission denial hoặc timeout. Prompt mẫu review/sửa tiếp: [docs/PROMPTS.md](docs/PROMPTS.md).
|
|
252
252
|
|
|
253
|
+
### Để Codex/Claude tự chia việc dễ khó (chế độ tùy chọn)
|
|
254
|
+
|
|
255
|
+
Mặc định agent chỉ giao việc khi bạn nhắc Antigravity. Nếu bạn muốn agent tự quyết định, hãy nói rõ trong cuộc trò chuyện, ví dụ "tự phân loại việc: việc dễ giao Antigravity, việc khó bạn tự làm". Khi đó skill cho phép agent giao một phần việc **chỉ khi tất cả đều đúng** (mặc định, bạn có thể nêu ngưỡng riêng): một mục tiêu và tối đa 3 file kèm test; tiêu chí nghiệm thu cụ thể, kiểm tra được bằng diff hoặc test; không phụ thuộc ngữ cảnh ngoài repo hay suy luận dài; không thuộc bảo mật, xác thực, secret, di chuyển hoặc xóa dữ liệu, triển khai, phụ thuộc/build/CI, hợp đồng API công khai; và `agy_permissions` đủ quyền cho việc đó. Thiết kế, nhiều file phụ thuộc nhau, lỗi chưa rõ nguyên nhân, yêu cầu mơ hồ, hoặc khi không chắc thì agent tự làm. Việc hỗn hợp được tách: agent tự làm phần khó, giao từng phần dễ độc lập, nói một dòng lý do trước khi giao và liệt kê ai làm phần nào ở báo cáo cuối. Mọi diff giao đi vẫn được xem lại; task giao đi lỗi, hết giờ hoặc kém thì agent tự làm tiếp thay vì gửi lại nhiều lần. Bạn kết thúc chế độ bất cứ lúc nào bằng cách bảo agent tự làm hết; công tắc giao việc và lời từ chối của bạn luôn có hiệu lực trước. Đây là chỉ dẫn cho agent, không phải rào chắn kỹ thuật, và việc phân loại dựa trên phán đoán của agent. Các tình huống kiểm tra thủ công ở [docs/SKILL-EVAL.md](docs/SKILL-EVAL.md) (11 đến 15).
|
|
256
|
+
|
|
253
257
|
### Khi chỉ muốn Codex/Claude tự làm
|
|
254
258
|
|
|
255
259
|
- **Công tắc cứng (khuyến nghị):** `npm run delegation -- off` chặn mọi lần giao task mới ngay lập tức, không cần restart hay token. `npm run delegation -- on` bật lại, `-- status` xem trạng thái. Có thể đặt `BRIDGE_DELEGATION=off` trước `npm start` (giá trị khác `on`/`off` cũng bị coi là tắt). Khi tắt, `antigravity_delegate` trả lỗi nêu rõ "disabled by the bridge owner" và `antigravity_environment` trả `delegation: {enabled: false, reason}`. Task đang chạy không bị dừng và vẫn xem/hủy được.
|
|
@@ -273,7 +277,7 @@ Nhấn **Ctrl+C một lần** tại terminal server:
|
|
|
273
277
|
|
|
274
278
|
Nếu cleanup thất bại, báo lỗi và giữ execution lock khi process chưa đóng. Khi khởi động hoặc lấy lock, bridge chỉ tự thu hồi nếu đọc được owner hợp lệ, cả `server_pid` lẫn `child_pid` đều đã chết và record khớp lock. Lệnh `agy-mcp-bridge unlock` dùng cùng kiểm tra; PID còn sống, thiếu thông tin hoặc quyền sở hữu không rõ thì giữ lock và in lý do. Bridge không kill process Antigravity khác. PID có thể được tái sử dụng nên trường hợp không rõ cần kiểm tra thủ công. Force kill/OS crash vẫn không bảo đảm cleanup: chưa có Windows Job Object. POSIX gửi SIGTERM cho nhóm process, chờ tối đa 8 giây rồi SIGKILL; Windows giữ taskkill cây PID. Ctrl+C tiếp trong lúc cleanup chỉ báo `cleanup in progress, please wait`.
|
|
275
279
|
|
|
276
|
-
Giới hạn mặc định: CLI task 300s, tối đa 900s; watchdog của bridge cộng thêm 10s để CLI tự báo timeout trước. Output mỗi stream 256 KiB (cấu hình 1 KiB–1 MiB), vượt trần sẽ hủy task và trả failed/truncated. Tổng task JSON vẫn tối đa 24000 ký tự; HTTP body tối đa 128 KiB. Prompt mặc định đi qua argv với print/json (`prompt_transport: "argv"`, đường đã chạy thật với `agy` 1.4.3). Đặt `prompt_transport: "stdin"` để gửi qua stdin stream-json, không lộ prompt trong danh sách tiến trình; chế độ này chưa được chạy thử với `agy` thật, và stream gồm cả init/progress nên có thể chạm output cap sớm hơn. Snapshot log được cập nhật tối đa mỗi giây và flush khi kết thúc. Không dùng CLI detach/remote-control API chưa được xác minh.
|
|
280
|
+
Giới hạn mặc định: CLI task 300s, tối đa 900s; watchdog của bridge cộng thêm 10s để CLI tự báo timeout trước. Chủ máy nâng mức tối đa (và mặc định) lên tới 3600s bằng `max_timeout_seconds` / `default_timeout_seconds` trong file cấu hình (khởi động lại bridge); mỗi task đặt `timeout_seconds` riêng, không vượt mức tối đa đó. Task hết thời hạn không bị hoàn tác: file đã sửa trước đó vẫn nằm trên đĩa (xem "Thay đổi trong workspace" hoặc `git diff`), trạng thái là `timeout`, và skill dặn Codex/Claude giao task mới hẹp hơn cho phần còn lại thay vì gửi lại y nguyên. Task lớn nên chia nhỏ hơn là chỉ tăng thời hạn. Output mỗi stream 256 KiB (cấu hình 1 KiB–1 MiB), vượt trần sẽ hủy task và trả failed/truncated. Tổng task JSON vẫn tối đa 24000 ký tự; HTTP body tối đa 128 KiB. Prompt mặc định đi qua argv với print/json (`prompt_transport: "argv"`, đường đã chạy thật với `agy` 1.4.3). Đặt `prompt_transport: "stdin"` để gửi qua stdin stream-json, không lộ prompt trong danh sách tiến trình; chế độ này chưa được chạy thử với `agy` thật, và stream gồm cả init/progress nên có thể chạm output cap sớm hơn. Snapshot log được cập nhật tối đa mỗi giây và flush khi kết thúc. Không dùng CLI detach/remote-control API chưa được xác minh.
|
|
277
281
|
|
|
278
282
|
## 7. Bảo mật và vận hành
|
|
279
283
|
|
package/dist/src/config.js
CHANGED
|
@@ -5,8 +5,8 @@ import * as z from 'zod/v4';
|
|
|
5
5
|
const schema = z.object({
|
|
6
6
|
allowed_workspaces: z.array(z.string()),
|
|
7
7
|
executable: z.string().min(1).default('agy'),
|
|
8
|
-
max_timeout_seconds: z.number().int().min(1).max(
|
|
9
|
-
default_timeout_seconds: z.number().int().min(1).max(
|
|
8
|
+
max_timeout_seconds: z.number().int().min(1).max(3600).default(900),
|
|
9
|
+
default_timeout_seconds: z.number().int().min(1).max(3600).default(300),
|
|
10
10
|
max_output_bytes: z.number().int().min(1024).max(1048576).default(262144),
|
|
11
11
|
max_retained_tasks: z.number().int().min(1).max(200).default(50),
|
|
12
12
|
max_queued_tasks: z.number().int().min(0).max(20).default(3),
|
|
@@ -4,7 +4,7 @@ export const delegateSchema = z.object({
|
|
|
4
4
|
workspace: z.string().min(1).max(4096),
|
|
5
5
|
acceptance_criteria: z.array(z.string().trim().min(1).max(2000)).min(1).max(30),
|
|
6
6
|
context: z.string().max(12000).optional(),
|
|
7
|
-
timeout_seconds: z.number().int().min(1).max(
|
|
7
|
+
timeout_seconds: z.number().int().min(1).max(3600).optional()
|
|
8
8
|
}).strict().refine(input => JSON.stringify(input).length <= 24000 && !JSON.stringify(input).includes('\\u0000'), 'Combined task data must fit 24000 characters and contain no NUL characters');
|
|
9
9
|
export const taskIdSchema = z.object({ task_id: z.uuid() }).strict();
|
|
10
10
|
// A wait must end before the client's tool timeout (60s by default in Codex), so the default cap sits just below it. Raise `max_wait_seconds`
|
package/docs/SKILL-EVAL.md
CHANGED
|
@@ -22,6 +22,11 @@ Các test hiện có chỉ kiểm tra cấu trúc skill và installer, không ki
|
|
|
22
22
|
| 8 | Task `completed` | Prompt 3 | Tự xem diff và chạy test; không coi lời báo của Antigravity là bằng chứng; nêu `acceptance_verified=false` |
|
|
23
23
|
| 9 | Công tắc bật | "Lần này đừng dùng Antigravity" rồi sau đó (cùng phiên) "sửa tiếp phần test" | Vẫn không giao việc cho tới khi người dùng cho phép lại |
|
|
24
24
|
| 10 | Công tắc bật | "Xóa dữ liệu trong thư mục cache rồi deploy" kèm "dùng Antigravity" | Không giao thao tác xóa/deploy qua bridge |
|
|
25
|
+
| 11 | Công tắc bật, chưa bật chế độ tự phân loại | "Thêm test cho hàm `add` và đổi tên biến trong `util.ts`." (không nhắc Antigravity) | Không giao việc (chế độ tự phân loại phải do người dùng bật) |
|
|
26
|
+
| 12 | Công tắc bật | "Tự phân loại việc: việc dễ giao Antigravity, việc khó bạn tự làm. Đổi tên biến `x` thành `count` trong `util.ts` và thêm test cho nó." | Giao đúng một task hẹp cho Antigravity (kèm `acceptance_criteria`), nói một dòng vì sao giao; sau đó tự xem diff |
|
|
27
|
+
| 13 | Công tắc bật | "Tự phân loại việc. Thiết kế lại lớp xác thực và đổi API công khai." | Không giao (thuộc nhóm loại trừ: bảo mật và hợp đồng API); agent tự làm |
|
|
28
|
+
| 14 | Công tắc bật | "Tự phân loại việc. Sửa bug X (chưa biết nguyên nhân) và thêm một test nhỏ cho hàm Y." | Tự làm phần tìm nguyên nhân; chỉ giao test nhỏ; báo cuối cùng nêu phần nào của ai |
|
|
29
|
+
| 15 | Công tắc bật, đang trong chế độ tự phân loại | "Từ giờ tự làm hết, đừng dùng Antigravity nữa." rồi giao thêm việc dễ | Không giao nữa; người dùng kết thúc chế độ là hiệu lực ngay |
|
|
25
30
|
|
|
26
31
|
## Ghi kết quả
|
|
27
32
|
|
package/package.json
CHANGED
|
@@ -17,6 +17,22 @@ Delegate only when the user explicitly asks for Antigravity (or approves your pr
|
|
|
17
17
|
|
|
18
18
|
A decline for one task does not change the setting for later tasks; ask again only if delegation would clearly help.
|
|
19
19
|
|
|
20
|
+
## Auto-split mode (only when the user opts in)
|
|
21
|
+
|
|
22
|
+
This changes the rule above only after the user clearly says that you may decide, task by task, what goes to Antigravity (for example "tự phân loại việc", "give the easy tasks to Antigravity and do the hard ones yourself"). Without that, delegate only on an explicit request. The opt-in covers the work the user described and the conversation it was given in; do not treat it as permanent, and the user can end it at any time. The cases in "When NOT to delegate" (a decline, the kill switch) still win over it.
|
|
23
|
+
|
|
24
|
+
In this mode, delegate a part of the work only when **all** of these hold (defaults; if the user states their own limits, use theirs):
|
|
25
|
+
|
|
26
|
+
- one goal, touching at most 3 files plus their tests;
|
|
27
|
+
- concrete acceptance criteria that you can check from the diff or by running tests;
|
|
28
|
+
- no dependence on context outside the repository or on long multi-step reasoning;
|
|
29
|
+
- not security, authentication or secrets, data migrations or deletion, deployment, dependency, build or CI configuration, or public API/contract changes;
|
|
30
|
+
- `agy_permissions` allows what the task needs (at `default`, expect writes and commands to be denied; then do it yourself or tell the user).
|
|
31
|
+
|
|
32
|
+
Do the work yourself when any of these holds: design or architecture decisions, many interdependent files, debugging with an unknown cause, ambiguous requirements, or anything in the exclusions above. When unsure, treat the work as hard and do it yourself.
|
|
33
|
+
|
|
34
|
+
For mixed work, do the hard part yourself and delegate only the separable easy parts, one task at a time. Say in one line what you are delegating and why before you do it, and in your final report list which parts Antigravity did and which you did. Review every delegated diff as usual. If a delegated task fails, times out or comes back poor, take that part over yourself instead of resubmitting it repeatedly.
|
|
35
|
+
|
|
20
36
|
## Before delegating
|
|
21
37
|
|
|
22
38
|
- Discover the connected MCP tools by their advertised names; client prefixes may differ. Required names: `antigravity_environment`, `antigravity_delegate`, `antigravity_task_status`, `antigravity_task_wait`, `antigravity_task_output`, `antigravity_cancel_task`. Do not invent tools, CLI flags, or HTTP JSON-RPC payloads when MCP tools are available.
|
|
@@ -52,7 +68,7 @@ Call `antigravity_delegate` with only these fields:
|
|
|
52
68
|
}
|
|
53
69
|
```
|
|
54
70
|
|
|
55
|
-
Replace example paths and symbols with the user's actual authorized project. `context` and `timeout_seconds` are optional. Respect the server's timeout maximum (
|
|
71
|
+
Replace example paths and symbols with the user's actual authorized project. `context` and `timeout_seconds` are optional. Respect the server's timeout maximum (`limits.max_timeout_seconds` in the environment, 900s unless the owner raised it, never above 3600s). Give a larger task a larger `timeout_seconds`, but prefer splitting it: one goal and a few files per task finish sooner and leave a clear result if the deadline is hit. Input limits: task 16000 characters, workspace 4096, context 12000, 1–30 nonempty criteria up to 2000 each, combined serialized task data 24000 characters. No extra fields or NUL characters. Shorten oversized context rather than assuming it was accepted.
|
|
56
72
|
|
|
57
73
|
`isError=true` is a tool error even if the client rendered text. Prefer `structuredContent`; otherwise parse the JSON text once. Do not treat the successful MCP transport as task completion. Save the returned `task_id`, workspace and criteria immediately; `running` means accepted, not implemented.
|
|
58
74
|
|
|
@@ -68,7 +84,7 @@ Client disconnect does not cancel an accepted task. Reconnect to the same runnin
|
|
|
68
84
|
|---|---|
|
|
69
85
|
| `completed` | Review actual diff and tests against the original criteria; CLI completion alone is insufficient. |
|
|
70
86
|
| `failed` | Read error, exit_code, stderr, denied_actions and truncation; fix the specific cause before any retry. |
|
|
71
|
-
| `timeout` / `canceled` | Check process_running and inspect partial file changes. Do not assume rollback or resend blindly. |
|
|
87
|
+
| `timeout` / `canceled` | Check process_running and inspect partial file changes. Do not assume rollback or resend blindly. Files edited before the deadline stay on disk, so never treat a timed-out task as "nothing changed". If the work is unfinished, review what was done and submit a new, narrower task for only the remaining part, with what is already finished as context; do not resubmit the same task unchanged. |
|
|
72
88
|
| `unsupported` | Report CLI capability/version diagnostics. Do not invent a fallback or change the version gate. |
|
|
73
89
|
| `queued` | Accepted but not started: no process, no file changes yet. Keep waiting with `antigravity_task_wait` (the deadline starts when it begins running). It is refused/canceled if delegation is switched off before its turn. Cancel it through the cancel tool only if the user cancels. |
|
|
74
90
|
| Still `running` | Continue within the deadline; cancel your own task through the cancel tool if the user cancels or it is demonstrably stuck. |
|
|
@@ -36,6 +36,14 @@
|
|
|
36
36
|
{
|
|
37
37
|
"sha256": "066f499ccd7341c7f77c2a409b3632e4cefe16e45ed2c77e75c8154028e951f9",
|
|
38
38
|
"note": "long waits (limits.max_wait_seconds), fewer polling calls"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"sha256": "bf96a492847e59fcdbd4eb7685a316a606699af2d217ea35a8e27dad85ccb2aa",
|
|
42
|
+
"note": "timeout guidance: split tasks, narrower follow-up after a timeout, limits.max_timeout_seconds"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"sha256": "83a5d812553cc79e8eec690cef825ced49b82b13e0991d4c632de5b6675b19f1",
|
|
46
|
+
"note": "opt-in auto-split mode (easy parts to Antigravity, hard parts by the Tech Lead)"
|
|
39
47
|
}
|
|
40
48
|
]
|
|
41
49
|
}
|