opencode-subagent-tools 0.2.0 → 0.2.1
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/CHANGELOG.md +14 -0
- package/README.md +2 -2
- package/SKILL.md +1 -1
- package/docs/limitations.md +10 -9
- package/docs/reference.md +6 -6
- package/package.json +2 -2
- package/src/background.ts +13 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@ All notable changes to this project are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## 0.2.1 - 2026-11-18
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Code Mode background jobs (`codemode`) are reported in `backgroundJob.kinds` and count as active work. OpenCode 2.3.1+ reports them through the `experimental.idle` hook; older versions never send this kind.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Tested against `@opencode/plugin` 2.3.2.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- A Code Mode idle item no longer falls into the unknown-kind path and marks its owner `stateUnknown`.
|
|
21
|
+
|
|
8
22
|
## 0.2.0 - 2026-11-17
|
|
9
23
|
|
|
10
24
|
### Added
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ descendants, steer or queue messages, and inject context.
|
|
|
6
6
|
|
|
7
7
|
> Plugin ID: `subagent-tools`. Default tool namespace: `subagent`.
|
|
8
8
|
|
|
9
|
-
Requires OpenCode 2.3.0
|
|
9
|
+
Requires OpenCode 2.3.0+; tested against 2.3.2.
|
|
10
10
|
|
|
11
11
|
## Quick start
|
|
12
12
|
|
|
@@ -84,7 +84,7 @@ to be asked or blocked. See [security model](docs/security-model.md).
|
|
|
84
84
|
## Pitfalls
|
|
85
85
|
|
|
86
86
|
- **`finished` is not task completion.** It means the last execution succeeded.
|
|
87
|
-
The child may still own a shell, image, or
|
|
87
|
+
The child may still own a shell, image, subagent, or Code Mode job. Use `active` and
|
|
88
88
|
`subtreeActive` to find work that is still in progress.
|
|
89
89
|
- **`cancel` is a soft interrupt.** It does not cascade. A long tool call may
|
|
90
90
|
finish first, and jobs owned by an idle session keep running. The result
|
package/SKILL.md
CHANGED
|
@@ -40,7 +40,7 @@ Tool names below omit the default `subagent_` prefix. With the default namespace
|
|
|
40
40
|
- `activeDescendants` — at least one discovered child is active in its subtree.
|
|
41
41
|
An idle parent with active descendants may wake.
|
|
42
42
|
- `backgroundJob` — the session's own observed background work. `kinds` can
|
|
43
|
-
contain `shell`, `image`, and `
|
|
43
|
+
contain `shell`, `image`, `subagent`, and `codemode`. `stateUnknown` means work may remain
|
|
44
44
|
but could not be verified.
|
|
45
45
|
- `usageMayLag` — usage may still grow because the session is active or unknown.
|
|
46
46
|
|
package/docs/limitations.md
CHANGED
|
@@ -20,16 +20,17 @@ and what to do about it.
|
|
|
20
20
|
record, and an `unknown` row may still be running. A resumed child can look
|
|
21
21
|
finished if the server omits its busy/idle timestamps.
|
|
22
22
|
- **`finished` is execution-only.** In OpenCode 2.3.0+ a child can be
|
|
23
|
-
idle while its own shell, image, or
|
|
24
|
-
last execution succeeded, not that the delegated task is
|
|
25
|
-
`active` and `subtreeActive` for work that is still in progress.
|
|
23
|
+
idle while its own shell, image, subagent, or Code Mode job is still running.
|
|
24
|
+
`finished` means the last execution succeeded, not that the delegated task is
|
|
25
|
+
complete. Use `active` and `subtreeActive` for work that is still in progress.
|
|
26
26
|
- **Background detection is live.** The plugin learns about background work from
|
|
27
27
|
the `experimental.idle` hook, shell events, and structured context probes. A job
|
|
28
28
|
that started before the plugin loaded may not be visible until a later event or
|
|
29
29
|
a `cancel` probe. The idle hook is experimental; if it is unavailable, shell
|
|
30
|
-
events still provide partial coverage, but image and
|
|
31
|
-
missed.
|
|
32
|
-
|
|
30
|
+
events still provide partial coverage, but image, subagent, and Code Mode jobs
|
|
31
|
+
may be missed. Code Mode jobs are visible only through the idle hook; a
|
|
32
|
+
`cancel` probe cannot see them. The hook has no timestamp, so the plugin stamps
|
|
33
|
+
it locally; large clock skew can delay or drop a snapshot.
|
|
33
34
|
- **`subtreeActive` follows discovered rows.** Incomplete discovery can make it
|
|
34
35
|
false when an active descendant is missing. `discoveryComplete` and the warning
|
|
35
36
|
still apply.
|
|
@@ -44,8 +45,8 @@ and what to do about it.
|
|
|
44
45
|
|
|
45
46
|
- **`cancel` is a soft interrupt.** It uses `session.interrupt({ resume: false })`.
|
|
46
47
|
A long tool call may finish first, and there is no hard abort.
|
|
47
|
-
- **Idle jobs keep running.** OpenCode can keep shell, subagent, or
|
|
48
|
-
alive while a session is idle; `session.interrupt` does nothing there. When the
|
|
48
|
+
- **Idle jobs keep running.** OpenCode can keep shell, subagent, image, or Code
|
|
49
|
+
Mode jobs alive while a session is idle; `session.interrupt` does nothing there. When the
|
|
49
50
|
session is running, an interrupt cancels its jobs as the session stops; for an
|
|
50
51
|
idle session, use the job's own controls. The plugin context exposes no job
|
|
51
52
|
list or job cancellation API, so the plugin probes the target's structured
|
|
@@ -147,7 +148,7 @@ and what to do about it.
|
|
|
147
148
|
`ctx.session`, `ctx.event`, `ctx.permission`, `ctx.model`, `ctx.skill`, and
|
|
148
149
|
`ctx.options`. The `experimental.idle` hook is experimental and may be
|
|
149
150
|
unavailable in a custom build; in that case shell events still provide partial
|
|
150
|
-
coverage, but image and
|
|
151
|
+
coverage, but image, subagent, and Code Mode jobs may be missed.
|
|
151
152
|
- **`steer` cannot move a blocking shell.** The UI calls `session.background`
|
|
152
153
|
after admitting a steer; `Plugin.Context` does not expose it. Delivery may wait
|
|
153
154
|
for a blocking shell to finish. This is a UI parity gap, not a plugin bug.
|
package/docs/reference.md
CHANGED
|
@@ -48,7 +48,7 @@ Text output is one row per session plus summary and warning lines. JSON output c
|
|
|
48
48
|
- `active` — true when the session itself is running, unknown, or owns a background job. Descendants are excluded.
|
|
49
49
|
- `subtreeActive` — true when the session or any discovered descendant is active.
|
|
50
50
|
- `activeDescendants?` — true only when at least one discovered child is active in its subtree.
|
|
51
|
-
- `backgroundJob?` — the session's own observed work: `kinds` (`shell`, `image`, `subagent`), and optional `stateUnknown` when work may remain but could not be verified.
|
|
51
|
+
- `backgroundJob?` — the session's own observed work: `kinds` (`shell`, `image`, `subagent`, `codemode`), and optional `stateUnknown` when work may remain but could not be verified.
|
|
52
52
|
- `ageSeconds?` (omitted when the launch time is unknown), `launchedAt`.
|
|
53
53
|
- `usageMayLag?` — true when the row is active or unknown.
|
|
54
54
|
- `usage?` — `costUSD?`, `tokens?`, and `tokensUsed?` when the server provides them.
|
|
@@ -134,7 +134,7 @@ Text output reports the interrupt result, the current state, and a lag note. JSO
|
|
|
134
134
|
- `accepted` — alias for `interrupt === "accepted"`.
|
|
135
135
|
- `status` — execution status after the interrupt and status check.
|
|
136
136
|
- `active` — true when the target is running, unknown, or owns observed background work after the call.
|
|
137
|
-
- `backgroundJob?` — the target's own observed work: `kinds` (`shell`, `image`, `subagent`), `mayRemain?` when work may still run after the call, and `stateUnknown?` when a probe failed.
|
|
137
|
+
- `backgroundJob?` — the target's own observed work: `kinds` (`shell`, `image`, `subagent`, `codemode`), `mayRemain?` when work may still run after the call, and `stateUnknown?` when a probe failed.
|
|
138
138
|
- `reason?` — the recorded reason.
|
|
139
139
|
- `readBackMayLag` — true when the interrupt was accepted and the status check after cancellation still reports `running` or `unknown`.
|
|
140
140
|
- `cancellationDoesNotCascade` — always `true`; cancellation is non-cascading, not a claim that the target has no children.
|
|
@@ -147,7 +147,7 @@ Text distinguishes an accepted interrupt with a remaining job ("may continue"),
|
|
|
147
147
|
- An unknown target, a self-target, a malformed ID, or a target outside `sessionControlPolicy` returns `Tool.Error`.
|
|
148
148
|
- Aborting before or during the interrupt returns `Tool.Error`. An abort after the interrupt may return a normal result.
|
|
149
149
|
- Cancelling a stopped, failed, or finished session is not an error.
|
|
150
|
-
- If the target is idle or terminal and no live background job is known, the tool probes `session.context(target)` for running shell messages and shell/image/subagent tool parts. A failed probe, or a probe without an authoritative idle snapshot for the target, sets `backgroundJob.stateUnknown`; it does not claim there is no job.
|
|
150
|
+
- If the target is idle or terminal and no live background job is known, the tool probes `session.context(target)` for running shell messages and shell/image/subagent tool parts. It cannot see a Code Mode job; that requires an idle snapshot. A failed probe, or a probe without an authoritative idle snapshot for the target, sets `backgroundJob.stateUnknown`; it does not claim there is no job.
|
|
151
151
|
- This is a soft interrupt: it does not cascade, a long tool call may finish first, and jobs owned by an idle session keep running. The tool reports those jobs but cannot stop them.
|
|
152
152
|
- OpenCode may wake the parent with a cancellation notice.
|
|
153
153
|
- If `interrupt` is `unknown`, `readBackMayLag` is true, or `status` is `running` or `unknown`, re-run `list`.
|
|
@@ -298,15 +298,15 @@ Text output reports the target and size. JSON output contains:
|
|
|
298
298
|
- `finished` — the last run succeeded. This does not mean the delegated task is complete.
|
|
299
299
|
- `unknown` — no reliable status is available; the session may still be running.
|
|
300
300
|
|
|
301
|
-
`status` is execution-oriented. In OpenCode 2.3.0+, shell, image, or
|
|
301
|
+
`status` is execution-oriented. In OpenCode 2.3.0+, shell, image, subagent, or Code Mode work can stay alive while a session is idle, so use the activity fields for "still working":
|
|
302
302
|
|
|
303
303
|
- `active` — the session itself is running, unknown, or owns a background job. Descendants are not included.
|
|
304
304
|
- `subtreeActive` — the session or any discovered descendant is active.
|
|
305
305
|
- `activeDescendants` — at least one discovered child is active. An idle parent with active descendants may wake.
|
|
306
|
-
- `backgroundJob` — the session's own observed work: `kinds` can contain `shell`, `image`, and `
|
|
306
|
+
- `backgroundJob` — the session's own observed work: `kinds` can contain `shell`, `image`, `subagent`, and `codemode`. `stateUnknown` means work may remain but could not be verified.
|
|
307
307
|
- `usageMayLag` — the session is active or unknown, so usage may still grow.
|
|
308
308
|
|
|
309
|
-
Status and activity are observed from live events, the idle hook, shell events, structured context probes, and the session record. They can lag, and an `unknown` row may still be running. See [limitations](limitations.md).
|
|
309
|
+
Status and activity are observed from live events, the idle hook, shell events, structured context probes, and the session record. Code Mode jobs are visible only through the idle hook. They can lag, and an `unknown` row may still be running. See [limitations](limitations.md).
|
|
310
310
|
|
|
311
311
|
`list` includes all five statuses by default. `statuses` filters executions only; use `active` and `subtreeActive` for work that is still in progress. `counts` always covers all five statuses and sums to `known`.
|
|
312
312
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-subagent-tools",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "OpenCode V2 plugin that gives the agent tools to list, inspect, cancel, steer, queue, and inject context into its subagent sessions.",
|
|
5
5
|
"author": "Maxim Matsiushonak",
|
|
6
6
|
"license": "MIT",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@opencode/plugin": "^2.3.
|
|
65
|
+
"@opencode/plugin": "^2.3.2",
|
|
66
66
|
"@types/bun": "^1.4.3",
|
|
67
67
|
"@types/node": "^26.6.5",
|
|
68
68
|
"oxlint": "1.60.0",
|
package/src/background.ts
CHANGED
|
@@ -6,6 +6,7 @@ export const BACKGROUND_JOB_KIND = {
|
|
|
6
6
|
shell: "shell",
|
|
7
7
|
image: "image",
|
|
8
8
|
subagent: "subagent",
|
|
9
|
+
codemode: "codemode",
|
|
9
10
|
} as const;
|
|
10
11
|
|
|
11
12
|
export type BackgroundJobKind =
|
|
@@ -75,6 +76,7 @@ interface BackgroundState {
|
|
|
75
76
|
shell: Map<string, number>;
|
|
76
77
|
image: Map<string, number>;
|
|
77
78
|
subagent: Map<string, number>;
|
|
79
|
+
codemode: Map<string, number>;
|
|
78
80
|
/** Last idle snapshot applied for this session, trusted or not. */
|
|
79
81
|
snapshotAt: number;
|
|
80
82
|
/** Whether an idle snapshot has ever been authoritative for this session. */
|
|
@@ -89,6 +91,7 @@ const createState = (): BackgroundState => ({
|
|
|
89
91
|
shell: new Map(),
|
|
90
92
|
image: new Map(),
|
|
91
93
|
subagent: new Map(),
|
|
94
|
+
codemode: new Map(),
|
|
92
95
|
snapshotAt: 0,
|
|
93
96
|
hasAuthoritativeSnapshot: false,
|
|
94
97
|
snapshotOwners: new Set(),
|
|
@@ -187,6 +190,12 @@ const parseIdleItem = (value: unknown): IdleItemParse => {
|
|
|
187
190
|
? { ok: true, item: { kind: item.kind, key, owner } }
|
|
188
191
|
: { ok: false, owner };
|
|
189
192
|
}
|
|
193
|
+
if (item.kind === BACKGROUND_JOB_KIND.codemode) {
|
|
194
|
+
const key = normalizeBackgroundKey(item.jobID);
|
|
195
|
+
return key
|
|
196
|
+
? { ok: true, item: { kind: item.kind, key, owner } }
|
|
197
|
+
: { ok: false, owner };
|
|
198
|
+
}
|
|
190
199
|
const key = normalizeSessionID(item.childSessionID);
|
|
191
200
|
return key ? { ok: true, item: { kind: item.kind, key, owner } } : { ok: false, owner };
|
|
192
201
|
};
|
|
@@ -331,7 +340,8 @@ export const createBackgroundJobStore = () => {
|
|
|
331
340
|
/**
|
|
332
341
|
* Apply an `experimental.idle` snapshot. The hook lists work owned by the
|
|
333
342
|
* idle session and its descendants; items are stored under their owner so a
|
|
334
|
-
* descendant's job never makes the idle parent active.
|
|
343
|
+
* descendant's job never makes the idle parent active. Code Mode scripts are
|
|
344
|
+
* reported only through this hook; shell events do not cover them.
|
|
335
345
|
*
|
|
336
346
|
* The snapshot is authoritative only when every item can be parsed. An item
|
|
337
347
|
* with a known owner preserves that owner's jobs and marks its state unknown;
|
|
@@ -488,7 +498,8 @@ export const createBackgroundJobStore = () => {
|
|
|
488
498
|
/**
|
|
489
499
|
* Structured fallback when the store has no authoritative snapshot for the
|
|
490
500
|
* target, such as after a restart. Running shell messages and running
|
|
491
|
-
* shell/image/subagent tool parts are proof of work
|
|
501
|
+
* shell/image/subagent tool parts are proof of work. Code Mode scripts are
|
|
502
|
+
* not visible here, so they rely on the idle hook. A missing snapshot, or a
|
|
492
503
|
* failed or malformed read, is unknown, never idle.
|
|
493
504
|
*/
|
|
494
505
|
const probe = async ({
|