@dougbots/avenor-opencode 0.3.1 → 0.3.3

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.
Files changed (2) hide show
  1. package/dist/index.js +61 -28
  2. package/package.json +2 -3
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { tool } from "@opencode-ai/plugin";
2
- import { z } from "zod";
3
2
  import * as crypto from "node:crypto";
4
3
  import { answerPermissionTool, eventsTool, followUpTool, shutdownTool, spawnTool, statusTool } from "@dougbots/avenor-core";
5
4
  //#region src/plugin.ts
@@ -88,6 +87,21 @@ const AvenorPlugin = async (ctx) => {
88
87
  }).catch(() => {});
89
88
  return;
90
89
  }
90
+ if (result.status === "waiting") {
91
+ const perm = result.pending_permission;
92
+ const lines = [`Sub-agent "${run.label}" is waiting for input.`];
93
+ if (perm) lines.push(`Permission request: ${perm.description}`, `To answer: call \`avenor_answer_permission\` with run_id "${run.runId}", option_id "allow_once" | "allow_always" | "deny"`);
94
+ else if (result.phase_label) lines.push(`Question: ${result.phase_label}`);
95
+ lines.push(`Use \`avenor_follow_up\` with run_id "${run.runId}" to respond, or \`avenor_status\` to re-check.`);
96
+ await ctx.client.session.promptAsync({
97
+ path: { id: run.orchestratorSessionId },
98
+ body: { parts: [{
99
+ type: "text",
100
+ text: lines.join("\n")
101
+ }] }
102
+ }).catch(() => {});
103
+ return;
104
+ }
91
105
  }
92
106
  }
93
107
  async function pollChannelMessages(sessionId) {
@@ -196,17 +210,17 @@ const AvenorPlugin = async (ctx) => {
196
210
  avenor_spawn: tool({
197
211
  description: "Dispatch an agent run via avenor. Blocks by default, showing live progress as an updating tool call. Set wait=false for fire-and-forget — you will be re-prompted automatically on completion.",
198
212
  args: {
199
- agent: z.string().describe("Agent name (required, no default)"),
200
- prompt: z.string().optional().describe("Prompt text"),
201
- prompt_file: z.string().optional().describe("Path to prompt file"),
202
- dir: z.string().optional().describe("Working directory for the run (defaults to the session project directory)"),
203
- label: z.string().optional().describe("Human-readable label for the run"),
204
- timeout: z.string().optional().describe("Timeout duration (e.g. 3600s)"),
205
- model: z.string().optional().describe("Model override"),
206
- backend: z.string().optional().describe("Backend override"),
207
- server_url: z.string().optional().describe("Backend server URL"),
208
- supervisor_id: z.string().optional().describe("Reuse an existing supervisor by socket path"),
209
- wait: z.boolean().default(true).describe("Block until complete with live status updates. False = fire-and-forget.")
213
+ agent: tool.schema.string().describe("Agent name (required, no default)"),
214
+ prompt: tool.schema.string().optional().describe("Prompt text"),
215
+ prompt_file: tool.schema.string().optional().describe("Path to prompt file"),
216
+ dir: tool.schema.string().optional().describe("Working directory for the run (defaults to the session project directory)"),
217
+ label: tool.schema.string().optional().describe("Human-readable label for the run"),
218
+ timeout: tool.schema.string().optional().describe("Timeout duration (e.g. 3600s)"),
219
+ model: tool.schema.string().optional().describe("Model override"),
220
+ backend: tool.schema.string().optional().describe("Backend override"),
221
+ server_url: tool.schema.string().optional().describe("Backend server URL"),
222
+ supervisor_id: tool.schema.string().optional().describe("Reuse an existing supervisor by socket path"),
223
+ wait: tool.schema.boolean().default(true).describe("Block until complete with live status updates. False = fire-and-forget.")
210
224
  },
211
225
  async execute(args, context) {
212
226
  const parentRunId = ensureParentRunId();
@@ -298,6 +312,25 @@ const AvenorPlugin = async (ctx) => {
298
312
  }
299
313
  };
300
314
  }
315
+ if (status.status === "waiting") {
316
+ const perm = status.pending_permission;
317
+ const lines = [`Sub-agent "${result.label}" is waiting for input.`];
318
+ if (perm) lines.push(`Permission request: ${perm.description}`, `To answer: call \`avenor_answer_permission\` with run_id "${result.run_id}", option_id "allow_once" | "allow_always" | "deny"`);
319
+ else if (status.phase_label) lines.push(`Question: ${status.phase_label}`);
320
+ lines.push(`Use \`avenor_follow_up\` with run_id "${result.run_id}" to respond, or \`avenor_status\` to re-check.`);
321
+ const tracked = trackedRuns.get(result.run_id);
322
+ if (tracked) tracked.monitoring = false;
323
+ return {
324
+ title: `${result.label} — waiting`,
325
+ output: lines.join("\n"),
326
+ metadata: {
327
+ status: "waiting",
328
+ run_id: result.run_id,
329
+ session_id: status.session_id,
330
+ ...perm && { pending_permission: perm }
331
+ }
332
+ };
333
+ }
301
334
  }
302
335
  trackedRuns.delete(result.run_id);
303
336
  return {
@@ -310,8 +343,8 @@ const AvenorPlugin = async (ctx) => {
310
343
  avenor_status: tool({
311
344
  description: "Get status of a run or all runs. Surfaces pending permission requests.",
312
345
  args: {
313
- run_id: z.string().optional().describe("Specific run ID to query"),
314
- supervisor_id: z.string().optional().describe("Reuse an existing supervisor by socket path")
346
+ run_id: tool.schema.string().optional().describe("Specific run ID to query"),
347
+ supervisor_id: tool.schema.string().optional().describe("Reuse an existing supervisor by socket path")
315
348
  },
316
349
  async execute(args, _context) {
317
350
  const result = await statusTool({
@@ -324,10 +357,10 @@ const AvenorPlugin = async (ctx) => {
324
357
  avenor_answer_permission: tool({
325
358
  description: "Answer a pending permission request for a sub-agent. Pass option_id from avenor_status pending_permission.options, or use \"allow_once\", \"allow_always\", \"deny\".",
326
359
  args: {
327
- run_id: z.string().describe("Run ID with the pending permission"),
328
- option_id: z.string().describe("allow_once | allow_always | deny, or option_id from pending_permission.options"),
329
- request_id: z.string().optional().describe("Permission request ID (auto-discovered if omitted)"),
330
- supervisor_id: z.string().optional().describe("Reuse an existing supervisor by socket path")
360
+ run_id: tool.schema.string().describe("Run ID with the pending permission"),
361
+ option_id: tool.schema.string().describe("allow_once | allow_always | deny, or option_id from pending_permission.options"),
362
+ request_id: tool.schema.string().optional().describe("Permission request ID (auto-discovered if omitted)"),
363
+ supervisor_id: tool.schema.string().optional().describe("Reuse an existing supervisor by socket path")
331
364
  },
332
365
  async execute(args, _context) {
333
366
  const result = await answerPermissionTool({
@@ -342,10 +375,10 @@ const AvenorPlugin = async (ctx) => {
342
375
  avenor_follow_up: tool({
343
376
  description: "Resume a completed run with a follow-up message.",
344
377
  args: {
345
- run_id: z.string().describe("Completed run ID to resume"),
346
- message: z.string().describe("Follow-up message text"),
347
- label: z.string().optional().describe("Override label (defaults to <original>-followup)"),
348
- supervisor_id: z.string().optional().describe("Reuse an existing supervisor by socket path")
378
+ run_id: tool.schema.string().describe("Completed run ID to resume"),
379
+ message: tool.schema.string().describe("Follow-up message text"),
380
+ label: tool.schema.string().optional().describe("Override label (defaults to <original>-followup)"),
381
+ supervisor_id: tool.schema.string().optional().describe("Reuse an existing supervisor by socket path")
349
382
  },
350
383
  async execute(args, _context) {
351
384
  const result = await followUpTool({
@@ -360,10 +393,10 @@ const AvenorPlugin = async (ctx) => {
360
393
  avenor_events: tool({
361
394
  description: "Read events from a run. Filter by type. Returns last N events.",
362
395
  args: {
363
- run_id: z.string().describe("Run ID to read events from"),
364
- types: z.array(z.string()).optional().describe("Filter by event types"),
365
- limit: z.number().optional().describe("Max events to return (default 50)"),
366
- supervisor_id: z.string().optional().describe("Reuse an existing supervisor by socket path")
396
+ run_id: tool.schema.string().describe("Run ID to read events from"),
397
+ types: tool.schema.array(tool.schema.string()).optional().describe("Filter by event types"),
398
+ limit: tool.schema.number().optional().describe("Max events to return (default 50)"),
399
+ supervisor_id: tool.schema.string().optional().describe("Reuse an existing supervisor by socket path")
367
400
  },
368
401
  async execute(args, _context) {
369
402
  const result = await eventsTool({
@@ -378,8 +411,8 @@ const AvenorPlugin = async (ctx) => {
378
411
  avenor_shutdown: tool({
379
412
  description: "Shut down the avenor supervisor and clean up temp files.",
380
413
  args: {
381
- supervisor_id: z.string().optional().describe("Supervisor to shut down (defaults to singleton)"),
382
- force: z.boolean().optional().describe("Force shutdown instead of graceful")
414
+ supervisor_id: tool.schema.string().optional().describe("Supervisor to shut down (defaults to singleton)"),
415
+ force: tool.schema.boolean().optional().describe("Force shutdown instead of graceful")
383
416
  },
384
417
  async execute(args, _context) {
385
418
  const result = await shutdownTool({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dougbots/avenor-opencode",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,8 +27,7 @@
27
27
  "dev": "tsdown --watch"
28
28
  },
29
29
  "dependencies": {
30
- "@dougbots/avenor-core": "^0.3.0",
31
- "zod": "^4.4.3"
30
+ "@dougbots/avenor-core": "^0.3.3"
32
31
  },
33
32
  "peerDependencies": {
34
33
  "@opencode-ai/plugin": "1.15.3"