@alisio/plugin-subagents 0.1.0-alpha.7 → 0.1.0-alpha.9

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
@@ -1,20 +1,77 @@
1
1
  # @alisio/plugin-subagents
2
2
 
3
- Subagents for [Alisio](https://github.com/GustavoGutierrez/alisio), shipped as a built-in plugin of the
4
- `alisio` CLI (disable with `--disable-plugin subagents`). The parent agent delegates work with the
5
- `task` tool to specialized agents that run in separate child sessions: fresh context, narrowed
6
- permissions, their own model and limits. It depends only on `@alisio/sdk` (generic
7
- `api.sessions`, `api.ui.panel`, `api.ui.select`) plus `zod` and `yaml`.
8
-
9
- - Agent definitions: Markdown + YAML frontmatter (`name`, `description`, `tools`, `model`,
10
- `permission`, `maxTurns`, …) from `--agents`, `.alisio/agents`, `.agents/agents`, `.claude/agents`,
11
- `.opencode/agent(s)`, user directories and plugins; built-ins `general`, `explore`, `plan`.
12
- - Tools: `task`, `task_status`, `task_wait`, `send_message`; parallel and background tasks, bounded
13
- waits, `<task …>` results, `<task-notification>` on background completion.
14
- - Limits: depth, concurrency per parent and total, bounded queue, turns, timeout and token budget.
15
- - Parallel writes in git: worktree per subagent (merge/discard with `/agents`), serial or shared.
16
- - A live agent tree in the TUI with keyboard navigation and read-only child views.
17
-
18
- Docs: [Subagents](https://gustavogutierrez.github.io/alisio/subagents).
19
-
20
- Maintainer: Gustavo Gutiérrez · License: MIT
3
+ **Subagents for [Alisio](https://github.com/GustavoGutierrez/alisio).** The parent agent delegates
4
+ work with the `task` tool to specialized agents that run in separate child sessions: fresh context,
5
+ narrowed permissions, their own model and limits.
6
+
7
+ ## What it is
8
+
9
+ Shipped as a built-in plugin of the `alisio` CLI (disable with `--disable-plugin subagents` or
10
+ `builtinPlugins.subagents.enabled: false`). It is built on the generic `api.sessions` service,
11
+ `api.ui.panel` and `api.ui.select`, so it depends only on `@alisio/sdk` plus `zod` and `yaml`.
12
+
13
+ ## Installation
14
+
15
+ Preinstalled in the `alisio` CLI. For an embedded host, register it through `createApplication`'s
16
+ `builtins` list.
17
+
18
+ ## Tools
19
+
20
+ | Tool | Input | Behavior |
21
+ | --- | --- | --- |
22
+ | `task` | `description`, `prompt`, `subagent_type`, optional `model`, `task_id`, `background` | Start an agent (or continue `task_id` with full history) and return its final report; several calls in one turn run in parallel |
23
+ | `task_status` | `task_id` | Status, agent, background flag and tokens; does not wait |
24
+ | `task_wait` | `task_id`, optional `timeout_ms` | Wait for a result, bounded by `waitMaxMs` |
25
+ | `send_message` | `task_id`, `text` | One-way message: queued for a running child's next turn, or resumes a finished child |
26
+
27
+ Results are wrapped in `<task …>` elements; background tasks deliver a `<task-notification>` when
28
+ they finish. Failures are structured tool errors that keep the `task_id`, so a task can be resumed.
29
+
30
+ ## Agent definitions
31
+
32
+ Markdown + YAML frontmatter (`name`, `description`, `tools`, `model`, `permission`, `maxTurns`, …)
33
+ discovered from `--agents` (JSON), `.alisio/agents`, `.agents/agents`, `.claude/agents`,
34
+ `.opencode/agent(s)`, user directories and plugin resources. Built-ins: `general` (multi-step
35
+ tasks), `explore` (read-only exploration) and `plan` (read-only implementation plans).
36
+
37
+ ## Parallel writes in git
38
+
39
+ With `parallelWrites: "worktree"`, each write-capable child works in its own git worktree
40
+ (`worktreeDir`, default `<state home>/worktrees`); the TUI `/agents` command offers
41
+ `open|cancel|kill|resume` and `merge|discard <id>` for worktrees. `ask`, `serial` and `shared` are
42
+ the other modes.
43
+
44
+ ## Configuration
45
+
46
+ Under `builtinPlugins.subagents`:
47
+
48
+ | Field | Default | Description |
49
+ | --- | --- | --- |
50
+ | `maxDepth` | `3` | Maximum nesting (1–8) |
51
+ | `maxConcurrentPerParent` | `4` | Running children per parent (1–32) |
52
+ | `maxConcurrentTotal` | `8` | Running children in total (1–64) |
53
+ | `maxQueued` | `16` | Waiting tasks beyond the concurrency limits (0–256) |
54
+ | `maxTurns` | `50` | Default turn limit per child |
55
+ | `timeoutMs` | `600000` | Timeout per child run |
56
+ | `maxTokensPerChild` | core budget | Per-child cumulative token budget |
57
+ | `maxOutputTokensPerChild` | `16384` | Per-child per-call output token budget |
58
+ | `parallelWrites` | `ask` | `ask`, `worktree`, `serial` or `shared` |
59
+ | `resultMaxBytes` | `50000` | Result size cap |
60
+ | `worktreeDir` | `<state home>/worktrees` | Where worktrees are created |
61
+
62
+ Children never exceed their parent: a read-only parent (or `--read-only`) makes every descendant
63
+ read-only, and approvals bubble up to the TUI labeled with the agent path.
64
+
65
+ ## Docs
66
+
67
+ [Subagents](https://gustavogutierrez.github.io/alisio/subagents) ·
68
+ [Configuration](https://gustavogutierrez.github.io/alisio/configuration).
69
+
70
+ ## Requirements
71
+
72
+ Node.js **>= 22.16** or Bun **>= 1.4.2**.
73
+
74
+ ## License
75
+
76
+ MIT. Maintained by Gustavo Gutiérrez Mercado. Source: <https://github.com/GustavoGutierrez/alisio> ·
77
+ npm: <https://www.npmjs.com/settings/alisio/packages>.
package/dist/config.d.ts CHANGED
@@ -23,6 +23,11 @@ export declare const subagentsConfigSchema: z.ZodObject<{
23
23
  prompt: z.ZodDefault<z.ZodString>;
24
24
  tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
25
  model: z.ZodOptional<z.ZodString>;
26
+ mode: z.ZodOptional<z.ZodEnum<{
27
+ all: "all";
28
+ primary: "primary";
29
+ subagent: "subagent";
30
+ }>>;
26
31
  }, z.core.$strip>>>;
27
32
  worktreeDir: z.ZodOptional<z.ZodString>;
28
33
  }, z.core.$strict>;
package/dist/config.js CHANGED
@@ -4,6 +4,8 @@ const cliAgent = z.object({
4
4
  prompt: z.string().default(""),
5
5
  tools: z.array(z.string()).optional(),
6
6
  model: z.string().optional(),
7
+ /** `primary`/`all` makes the definition available as an ACTIVE (main-session) agent in `/agents`. */
8
+ mode: z.enum(["subagent", "primary", "all"]).optional(),
7
9
  });
8
10
  /** Options under `builtinPlugins.subagents`. */
9
11
  export const subagentsConfigSchema = z
@@ -37,6 +37,7 @@ export interface CliAgent {
37
37
  prompt: string;
38
38
  tools?: string[];
39
39
  model?: string;
40
+ mode?: "subagent" | "primary" | "all";
40
41
  }
41
42
  /**
42
43
  * Discovery, first match wins by name: CLI `--agents` > project `.alisio/agents` >
@@ -224,7 +224,13 @@ export async function discoverAgents(options) {
224
224
  agents.set(definition.name, definition);
225
225
  };
226
226
  for (const [name, spec] of Object.entries(options.cli ?? {})) {
227
- const { definition, warnings: w } = parseAgentDefinition(`---\n${JSON.stringify({ name, description: spec.description, ...(spec.tools ? { tools: spec.tools } : {}), ...(spec.model ? { model: spec.model } : {}) })}\n---\n${spec.prompt ?? ""}`, { source: "cli" });
227
+ const { definition, warnings: w } = parseAgentDefinition(`---\n${JSON.stringify({
228
+ name,
229
+ description: spec.description,
230
+ ...(spec.tools ? { tools: spec.tools } : {}),
231
+ ...(spec.model ? { model: spec.model } : {}),
232
+ ...(spec.mode ? { mode: spec.mode } : {}),
233
+ })}\n---\n${spec.prompt ?? ""}`, { source: "cli" });
228
234
  warnings.push(...w);
229
235
  if (definition)
230
236
  add(definition);
package/dist/index.d.ts CHANGED
@@ -2,6 +2,8 @@ import { type Plugin } from "@alisio/sdk";
2
2
  export type { AgentDefinition } from "./definitions.ts";
3
3
  export { BUILTIN_AGENTS, discoverAgents, parseAgentDefinition } from "./definitions.ts";
4
4
  export { SubagentManager } from "./manager.ts";
5
+ /** Plugin-state key under which the plugin publishes main-session-capable (mode primary/all) agents. */
6
+ export declare const MAIN_AGENTS_STATE_KEY = "mainAgents";
5
7
  export interface SubagentsPluginContext {
6
8
  workspace: string;
7
9
  stateHome: string;
package/dist/index.js CHANGED
@@ -11,6 +11,8 @@ import { SubagentManager } from "./manager.js";
11
11
  import { loadVersion } from "./version.js";
12
12
  export { BUILTIN_AGENTS, discoverAgents, parseAgentDefinition } from "./definitions.js";
13
13
  export { SubagentManager } from "./manager.js";
14
+ /** Plugin-state key under which the plugin publishes main-session-capable (mode primary/all) agents. */
15
+ export const MAIN_AGENTS_STATE_KEY = "mainAgents";
14
16
  const schema = (properties, required) => ({
15
17
  type: "object",
16
18
  properties,
@@ -46,6 +48,20 @@ export function createSubagentsPlugin(rawOptions, context) {
46
48
  plugins: api.resources.list("agents"),
47
49
  });
48
50
  warnings = found.warnings;
51
+ // Publish the main-session-capable definitions (mode `primary`/`all`) for the TUI's `/agents`
52
+ // picker. The host reads them through `pluginState`, so the TUI never imports this package.
53
+ // Only the fields the ACTIVE agent needs are persisted; prompts stay bounded.
54
+ api.state.set(MAIN_AGENTS_STATE_KEY, [...found.agents.values()]
55
+ .filter((a) => a.mode !== "subagent" && !a.hidden)
56
+ .map((a) => ({
57
+ name: a.name,
58
+ description: a.description,
59
+ prompt: a.prompt.slice(0, 24_000),
60
+ ...(a.model ? { model: a.model } : {}),
61
+ ...(a.readOnly ? { readOnly: true } : {}),
62
+ source: a.source,
63
+ ...(a.path ? { path: a.path } : {}),
64
+ })));
49
65
  const m = new SubagentManager(api, config, context, found.agents);
50
66
  manager = m;
51
67
  const status = () => {
package/dist/manager.js CHANGED
@@ -342,6 +342,8 @@ export class SubagentManager {
342
342
  task.tokens = Math.max(task.tokens, result.usage.input + result.usage.output);
343
343
  if (task.worktree && result.status === "completed")
344
344
  await this.summarizeWorktree(task);
345
+ if (result.status === "completed" && result.turnsExceeded)
346
+ task.notes.push("This subagent reached its turn limit; the report above may be incomplete. Ask it to continue or raise its maxTurns in the agent definition.");
345
347
  task.result =
346
348
  result.status === "completed"
347
349
  ? this.wrap(task, "completed", result.text || "(no final message)")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alisio/plugin-subagents",
3
- "version": "0.1.0-alpha.7",
3
+ "version": "0.1.0-alpha.9",
4
4
  "description": "Subagents for Alisio: delegate tasks to specialized agents in separate child sessions with narrowed permissions, parallel execution, git worktree isolation and a live agent tree. Built-in, disableable plugin.",
5
5
  "author": "Gustavo Gutiérrez",
6
6
  "license": "MIT",
@@ -46,10 +46,10 @@
46
46
  "zod": "4.6.5"
47
47
  },
48
48
  "peerDependencies": {
49
- "@alisio/sdk": "^0.1.0-alpha.6"
49
+ "@alisio/sdk": "^0.1.0-alpha.8"
50
50
  },
51
51
  "devDependencies": {
52
- "@alisio/sdk": "0.1.0-alpha.6"
52
+ "@alisio/sdk": "0.1.0-alpha.8"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public",