@madarco/agentbox 0.7.0 → 0.8.0
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/dist/_cloud-attach-T727ZPRV.js +13 -0
- package/dist/{chunk-NW5NYTQM.js → chunk-67N47KUS.js} +359 -85
- package/dist/chunk-67N47KUS.js.map +1 -0
- package/dist/{chunk-NAVL4R34.js → chunk-6OZDFNBF.js} +1084 -516
- package/dist/chunk-6OZDFNBF.js.map +1 -0
- package/dist/chunk-BGK32PZE.js +455 -0
- package/dist/chunk-BGK32PZE.js.map +1 -0
- package/dist/{chunk-7KOEFGN2.js → chunk-FODMEHD3.js} +52 -14
- package/dist/chunk-FODMEHD3.js.map +1 -0
- package/dist/{chunk-UK72UQ5U.js → chunk-G3H2L3O2.js} +55 -4
- package/dist/chunk-G3H2L3O2.js.map +1 -0
- package/dist/{chunk-V5KZGB5V.js → chunk-LEV3KICD.js} +18 -2
- package/dist/chunk-LEV3KICD.js.map +1 -0
- package/dist/{cloud-poller-ZIWSADJB-JXFRJUEM.js → cloud-poller-SUNA6ZQC-2RG5WPRN.js} +2 -2
- package/dist/{dist-R67WMLCF.js → dist-L4LCG5SJ.js} +120 -10
- package/dist/dist-L4LCG5SJ.js.map +1 -0
- package/dist/{dist-ETCFRVPA.js → dist-LOZBWMBF.js} +44 -20
- package/dist/{dist-QZGJIBT5.js → dist-ZODPD2I6.js} +142 -74
- package/dist/dist-ZODPD2I6.js.map +1 -0
- package/dist/index.js +3563 -845
- package/dist/index.js.map +1 -1
- package/dist/prepared-state-CL4CWXQA-ME4HSKDE.js +18 -0
- package/dist/prepared-state-CL4CWXQA-ME4HSKDE.js.map +1 -0
- package/package.json +4 -4
- package/runtime/daytona/custom-system-CLAUDE.md +39 -0
- package/runtime/docker/Dockerfile.box +22 -0
- package/runtime/docker/apps/cli/share/agentbox-setup/SKILL.md +1 -1
- package/runtime/docker/packages/ctl/dist/bin.cjs +1118 -71
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json +66 -35
- package/runtime/docker/packages/sandbox-docker/scripts/claude-managed-settings.json +62 -1
- package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +15 -4
- package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +263 -0
- package/runtime/docker/packages/sandbox-docker/scripts/git-shim +131 -0
- package/runtime/docker/packages/sandbox-docker/scripts/opencode-agentbox-plugin.js +76 -0
- package/runtime/hetzner/agentbox-codex-hooks.json +66 -35
- package/runtime/hetzner/agentbox-setup-skill.md +1 -1
- package/runtime/hetzner/claude-managed-settings.json +62 -1
- package/runtime/hetzner/ctl.cjs +1118 -71
- package/runtime/hetzner/custom-system-CLAUDE.md +26 -14
- package/runtime/hetzner/gh-shim +263 -0
- package/runtime/hetzner/git-shim +131 -0
- package/runtime/hetzner/opencode-agentbox-plugin.js +76 -0
- package/runtime/hetzner/scripts/install-box.sh +11 -2
- package/runtime/relay/bin.cjs +927 -36
- package/share/agentbox-setup/SKILL.md +1 -1
- package/share/host-skills/agentbox/SKILL.md +29 -0
- package/share/host-skills/agentbox-info/SKILL.md +211 -0
- package/share/host-skills/codex/agentbox.md +35 -0
- package/share/host-skills/opencode/agentbox.md +26 -0
- package/dist/_cloud-attach-DMVH6GWO.js +0 -12
- package/dist/chunk-7KOEFGN2.js.map +0 -1
- package/dist/chunk-NAVL4R34.js.map +0 -1
- package/dist/chunk-NW5NYTQM.js.map +0 -1
- package/dist/chunk-UK72UQ5U.js.map +0 -1
- package/dist/chunk-V5KZGB5V.js.map +0 -1
- package/dist/dist-QZGJIBT5.js.map +0 -1
- package/dist/dist-R67WMLCF.js.map +0 -1
- /package/dist/{_cloud-attach-DMVH6GWO.js.map → _cloud-attach-T727ZPRV.js.map} +0 -0
- /package/dist/{cloud-poller-ZIWSADJB-JXFRJUEM.js.map → cloud-poller-SUNA6ZQC-2RG5WPRN.js.map} +0 -0
- /package/dist/{dist-ETCFRVPA.js.map → dist-LOZBWMBF.js.map} +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// AgentBox state-reporting plugin for OpenCode (sst/opencode).
|
|
2
|
+
//
|
|
3
|
+
// Subscribes to OpenCode's plugin event bus and reports each lifecycle
|
|
4
|
+
// transition to `agentbox-ctl opencode-state <state>`. The ctl daemon then
|
|
5
|
+
// publishes the state to the host relay's status.json, which is what
|
|
6
|
+
// `agentbox agent state` / `agent wait-for` consume on the host side.
|
|
7
|
+
//
|
|
8
|
+
// Fire-and-forget — a missing/late `agentbox-ctl` must never disturb the
|
|
9
|
+
// OpenCode session. The spawned process is detached + unrefed so a slow
|
|
10
|
+
// ctl response never blocks an event handler.
|
|
11
|
+
//
|
|
12
|
+
// Seeded by `seedOpencodePlugin` (packages/sandbox-docker/src/opencode.ts)
|
|
13
|
+
// from the image-baked copy at /usr/local/share/agentbox/opencode-plugin/
|
|
14
|
+
// into the box's `$OPENCODE_CONFIG_DIR/plugins/agentbox-state.js` on every
|
|
15
|
+
// create / start. Idempotent overwrite.
|
|
16
|
+
//
|
|
17
|
+
// Event coverage (mirrors the Claude / Codex state machine):
|
|
18
|
+
// working — agent is generating. Driven by `message.part.delta` (streamed
|
|
19
|
+
// tokens) — these fire only DURING active generation, never after
|
|
20
|
+
// the turn ends, so they don't fight the `session.idle` end
|
|
21
|
+
// signal. (Empirically `tool.execute.before` does NOT reach the
|
|
22
|
+
// plugin event bus in opencode 1.15, and `message.updated` fires
|
|
23
|
+
// once AFTER `session.idle` — so neither is safe to map to
|
|
24
|
+
// working.)
|
|
25
|
+
// idle — turn complete / ready for input (`session.idle`, plus
|
|
26
|
+
// `session.created` as a baseline at session start).
|
|
27
|
+
// waiting — user input required (`permission.asked`).
|
|
28
|
+
// error — `session.error`.
|
|
29
|
+
// compacting — opencode has no PreCompact event; `session.compacted` fires
|
|
30
|
+
// AFTER compaction completes, so it maps to `working` (the next
|
|
31
|
+
// event supersedes) rather than `compacting`.
|
|
32
|
+
//
|
|
33
|
+
// The plugin shape comes from https://opencode.ai/docs/plugins/ — `event` is
|
|
34
|
+
// a single handler that receives `{ event }` with a `type` field. Multiple
|
|
35
|
+
// exports = multiple plugin functions; we ship one.
|
|
36
|
+
|
|
37
|
+
import { spawn } from 'node:child_process';
|
|
38
|
+
|
|
39
|
+
const EVENT_TO_STATE = {
|
|
40
|
+
'session.created': 'idle',
|
|
41
|
+
'session.idle': 'idle',
|
|
42
|
+
'session.error': 'error',
|
|
43
|
+
'session.compacted': 'working',
|
|
44
|
+
'permission.asked': 'waiting',
|
|
45
|
+
'permission.replied': 'working',
|
|
46
|
+
'message.part.delta': 'working',
|
|
47
|
+
// tool.execute.before kept as a defensive mapping — harmless if a future
|
|
48
|
+
// opencode build starts surfacing it (it doesn't today).
|
|
49
|
+
'tool.execute.before': 'working',
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Dedupe: `message.part.delta` fires dozens of times per streamed turn. Only
|
|
53
|
+
// spawn agentbox-ctl when the mapped state actually changes, so a turn costs
|
|
54
|
+
// ~2 spawns (working on the first delta, idle on session.idle) instead of ~50.
|
|
55
|
+
let lastState = null;
|
|
56
|
+
|
|
57
|
+
function pushState(state) {
|
|
58
|
+
if (!state || state === lastState) return;
|
|
59
|
+
lastState = state;
|
|
60
|
+
try {
|
|
61
|
+
const p = spawn('agentbox-ctl', ['opencode-state', state], {
|
|
62
|
+
stdio: 'ignore',
|
|
63
|
+
detached: true,
|
|
64
|
+
});
|
|
65
|
+
p.unref();
|
|
66
|
+
} catch {
|
|
67
|
+
// Fire-and-forget. A missing agentbox-ctl bin (test env, older box image)
|
|
68
|
+
// must not throw out of this handler.
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const AgentboxStatePlugin = async () => ({
|
|
73
|
+
event: async ({ event }) => {
|
|
74
|
+
pushState(EVENT_TO_STATE[event?.type]);
|
|
75
|
+
},
|
|
76
|
+
});
|
|
@@ -1,37 +1,68 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
2
|
+
"$comment": "Codex 0.134.0 expects `~/.codex/hooks.json` to be `{ hooks: { Event: [...] } }` (matching the `HooksFile` Rust struct), NOT a top-level event map. The `hooks` feature flag must also be enabled (`codex --enable hooks`) and hook trust must be either persisted via the in-TUI dialog or bypassed at launch (`--dangerously-bypass-hook-trust`). startCodexSession() does both. In practice the hook firing on the JSON-config path is still unreliable in 0.134.0 (TUI mode skips them on at least some startup paths) — the real mechanism that lights up state in production is the tmux-pane scraper in packages/ctl/src/codex-scraper.ts. These hooks remain as a defense-in-depth seed so any future codex build that fixes the firing also lights up state without further work.",
|
|
3
|
+
"hooks": {
|
|
4
|
+
"SessionStart": [
|
|
5
|
+
{
|
|
6
|
+
"hooks": [
|
|
7
|
+
{ "type": "command", "command": "agentbox-ctl codex-state idle >/dev/null 2>&1 &", "timeout": 3 }
|
|
8
|
+
]
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
"UserPromptSubmit": [
|
|
12
|
+
{
|
|
13
|
+
"hooks": [
|
|
14
|
+
{ "type": "command", "command": "agentbox-ctl codex-state working >/dev/null 2>&1 &", "timeout": 3 }
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"PreToolUse": [
|
|
19
|
+
{
|
|
20
|
+
"hooks": [
|
|
21
|
+
{ "type": "command", "command": "agentbox-ctl codex-state working >/dev/null 2>&1 &", "timeout": 3 }
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"PermissionRequest": [
|
|
26
|
+
{
|
|
27
|
+
"hooks": [
|
|
28
|
+
{ "type": "command", "command": "agentbox-ctl codex-state waiting >/dev/null 2>&1 &", "timeout": 3 }
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"PreCompact": [
|
|
33
|
+
{
|
|
34
|
+
"hooks": [
|
|
35
|
+
{ "type": "command", "command": "agentbox-ctl codex-state compacting >/dev/null 2>&1 &", "timeout": 3 }
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"PostCompact": [
|
|
40
|
+
{
|
|
41
|
+
"hooks": [
|
|
42
|
+
{ "type": "command", "command": "agentbox-ctl codex-state working >/dev/null 2>&1 &", "timeout": 3 }
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"SubagentStart": [
|
|
47
|
+
{
|
|
48
|
+
"hooks": [
|
|
49
|
+
{ "type": "command", "command": "agentbox-ctl codex-state working >/dev/null 2>&1 &", "timeout": 3 }
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"SubagentStop": [
|
|
54
|
+
{
|
|
55
|
+
"hooks": [
|
|
56
|
+
{ "type": "command", "command": "agentbox-ctl codex-state working >/dev/null 2>&1 &", "timeout": 3 }
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"Stop": [
|
|
61
|
+
{
|
|
62
|
+
"hooks": [
|
|
63
|
+
{ "type": "command", "command": "agentbox-ctl codex-state idle >/dev/null 2>&1 &", "timeout": 3 }
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
37
68
|
}
|
|
@@ -14,7 +14,7 @@ Run `agentbox checkpoint --set-default` (similar to `docker commit`) to save any
|
|
|
14
14
|
|
|
15
15
|
Some special folders:
|
|
16
16
|
|
|
17
|
-
- **Host main repo's `.git/`** — If the box bind-mounted RW at its identical absolute host path. In-box commits land on the host's branch refs (visible to `git log` on the host immediately); the box itself carries no SSH/git creds, so `git push` goes through the host relay (`agentbox-ctl git push`). The host's **working tree is never written to** — only refs/objects under `.git/`.
|
|
17
|
+
- **Host main repo's `.git/`** — If the box bind-mounted RW at its identical absolute host path. In-box commits land on the host's branch refs (visible to `git log` on the host immediately); the box itself carries no SSH/git creds, so `git push` goes through the host relay (`agentbox-ctl git push`). The host's **working tree is never written to** — only refs/objects under `.git/`. GitHub PR ops (`agentbox-ctl git pr create|view|list|comment|review|merge|close|reopen|checkout`) flow the same way through host `gh`; write ops require host confirmation (deny → exit 10), `merge` and `checkout` have additional opt-in guards.
|
|
18
18
|
- **`~/.claude`** — and similar home folders for coding agents are seeded from the host's `~/.claude` on each create so auth, skills, and plugins persist without leaking the host's home dir.
|
|
19
19
|
- **`agentbox.yaml`** — read by `agentbox-ctl` from `/workspace`. Tasks and services declared here are what the supervisor will run.
|
|
20
20
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$comment": "AgentBox enterprise-managed Claude Code settings, baked into the box image at /etc/claude-code/managed-settings.json. Highest precedence and NOT synced from the host ~/.claude, so claude-hooks-filter.ts never touches it; per Claude Code, hook arrays MERGE across settings sources, so the user's own hooks still run. These hooks report Claude's activity to the box supervisor (agentbox-ctl claude-state -> ctl socket -> relay -> ~/.agentbox/boxes/<id>/status.json) so `agentbox status/list/inspect` can show it even when the box is paused. Each command is exit-0 fast and shell-backgrounded so a hook can never block or fail a Claude turn.",
|
|
2
|
+
"$comment": "AgentBox enterprise-managed Claude Code settings, baked into the box image at /etc/claude-code/managed-settings.json. Highest precedence and NOT synced from the host ~/.claude, so claude-hooks-filter.ts never touches it; per Claude Code, hook arrays MERGE across settings sources, so the user's own hooks still run. These hooks report Claude's activity to the box supervisor (agentbox-ctl claude-state -> ctl socket -> relay -> ~/.agentbox/boxes/<id>/status.json) so `agentbox status/list/inspect` can show it even when the box is paused. Each command is exit-0 fast and shell-backgrounded so a hook can never block or fail a Claude turn. The ExitPlanMode / AskUserQuestion entries run SYNCHRONOUSLY (no &) because they consume the hook's stdin payload; the catchall PreToolUse 'working' hook races with them, but the supervisor's sticky-state semantics swallow that race (a 'working' set while in end-plan/question is ignored unless --clear-pending is set, which only the matching PostToolUse hook passes).",
|
|
3
3
|
"hooks": {
|
|
4
4
|
"UserPromptSubmit": [
|
|
5
5
|
{
|
|
@@ -13,6 +13,32 @@
|
|
|
13
13
|
"hooks": [
|
|
14
14
|
{ "type": "command", "command": "agentbox-ctl claude-state working >/dev/null 2>&1 &", "timeout": 3 }
|
|
15
15
|
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"matcher": "ExitPlanMode",
|
|
19
|
+
"hooks": [
|
|
20
|
+
{ "type": "command", "command": "agentbox-ctl claude-state end-plan --payload-stdin >/dev/null 2>&1", "timeout": 3 }
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"matcher": "AskUserQuestion",
|
|
25
|
+
"hooks": [
|
|
26
|
+
{ "type": "command", "command": "agentbox-ctl claude-state question --payload-stdin >/dev/null 2>&1", "timeout": 3 }
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"PostToolUse": [
|
|
31
|
+
{
|
|
32
|
+
"matcher": "ExitPlanMode",
|
|
33
|
+
"hooks": [
|
|
34
|
+
{ "type": "command", "command": "agentbox-ctl claude-state working --clear-pending >/dev/null 2>&1 &", "timeout": 3 }
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"matcher": "AskUserQuestion",
|
|
39
|
+
"hooks": [
|
|
40
|
+
{ "type": "command", "command": "agentbox-ctl claude-state working --clear-pending >/dev/null 2>&1 &", "timeout": 3 }
|
|
41
|
+
]
|
|
16
42
|
}
|
|
17
43
|
],
|
|
18
44
|
"Stop": [
|
|
@@ -22,6 +48,41 @@
|
|
|
22
48
|
]
|
|
23
49
|
}
|
|
24
50
|
],
|
|
51
|
+
"StopFailure": [
|
|
52
|
+
{
|
|
53
|
+
"hooks": [
|
|
54
|
+
{ "type": "command", "command": "agentbox-ctl claude-state error >/dev/null 2>&1 &", "timeout": 3 }
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"PreCompact": [
|
|
59
|
+
{
|
|
60
|
+
"hooks": [
|
|
61
|
+
{ "type": "command", "command": "agentbox-ctl claude-state compacting >/dev/null 2>&1 &", "timeout": 3 }
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"PostCompact": [
|
|
66
|
+
{
|
|
67
|
+
"hooks": [
|
|
68
|
+
{ "type": "command", "command": "agentbox-ctl claude-state working --clear-pending >/dev/null 2>&1 &", "timeout": 3 }
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"SubagentStart": [
|
|
73
|
+
{
|
|
74
|
+
"hooks": [
|
|
75
|
+
{ "type": "command", "command": "agentbox-ctl claude-state working >/dev/null 2>&1 &", "timeout": 3 }
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"SubagentStop": [
|
|
80
|
+
{
|
|
81
|
+
"hooks": [
|
|
82
|
+
{ "type": "command", "command": "agentbox-ctl claude-state working >/dev/null 2>&1 &", "timeout": 3 }
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
],
|
|
25
86
|
"Notification": [
|
|
26
87
|
{
|
|
27
88
|
"matcher": "permission_prompt",
|