@dougbots/avenor-opencode 0.3.2 → 0.3.4

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
@@ -132,7 +132,7 @@ Shut down the avenor supervisor process and clean up temp files. Call this when
132
132
  **Parallel / fire-and-forget (`wait=false`):**
133
133
  ```
134
134
  1. avenor_spawn × N → each returns run_id immediately
135
- 2. (session goes idle) → plugin starts monitoring all pending runs
135
+ 2. plugin starts monitoring each run immediately
136
136
  3. (sub-agent finishes) → plugin re-prompts this session automatically
137
137
  4. avenor_answer_permission → if a permission was routed here mid-run
138
138
  5. avenor_events → inspect output
package/dist/index.js CHANGED
@@ -87,6 +87,22 @@ const AvenorPlugin = async (ctx) => {
87
87
  }).catch(() => {});
88
88
  return;
89
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
+ run.monitoring = false;
104
+ return;
105
+ }
90
106
  }
91
107
  }
92
108
  async function pollChannelMessages(sessionId) {
@@ -234,10 +250,17 @@ const AvenorPlugin = async (ctx) => {
234
250
  monitoring: args.wait
235
251
  });
236
252
  if (result.runtime_id) runtimeIdToRunId.set(result.runtime_id, result.run_id);
237
- if (!args.wait) return {
238
- title: `${result.label} — dispatched`,
239
- output: `Dispatched "${result.label}" (run_id: ${result.run_id}). Call avenor_status with run_id to check progress, or wait for the completion notification.`
240
- };
253
+ if (!args.wait) {
254
+ const run = trackedRuns.get(result.run_id);
255
+ if (run) {
256
+ run.monitoring = true;
257
+ monitorRun(run).catch(console.error);
258
+ }
259
+ return {
260
+ title: `${result.label} — dispatched`,
261
+ output: `Dispatched "${result.label}" (run_id: ${result.run_id}). Call avenor_status with run_id to check progress, or wait for the completion notification.`
262
+ };
263
+ }
241
264
  context.metadata({ title: `Starting ${result.label}…` });
242
265
  let firstPoll = true;
243
266
  while (!context.abort.aborted) {
@@ -297,6 +320,25 @@ const AvenorPlugin = async (ctx) => {
297
320
  }
298
321
  };
299
322
  }
323
+ if (status.status === "waiting") {
324
+ const perm = status.pending_permission;
325
+ const lines = [`Sub-agent "${result.label}" is waiting for input.`];
326
+ 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"`);
327
+ else if (status.phase_label) lines.push(`Question: ${status.phase_label}`);
328
+ lines.push(`Use \`avenor_follow_up\` with run_id "${result.run_id}" to respond, or \`avenor_status\` to re-check.`);
329
+ const tracked = trackedRuns.get(result.run_id);
330
+ if (tracked) tracked.monitoring = false;
331
+ return {
332
+ title: `${result.label} — waiting`,
333
+ output: lines.join("\n"),
334
+ metadata: {
335
+ status: "waiting",
336
+ run_id: result.run_id,
337
+ session_id: status.session_id,
338
+ ...perm && { pending_permission: perm }
339
+ }
340
+ };
341
+ }
300
342
  }
301
343
  trackedRuns.delete(result.run_id);
302
344
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dougbots/avenor-opencode",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  "dev": "tsdown --watch"
28
28
  },
29
29
  "dependencies": {
30
- "@dougbots/avenor-core": "^0.3.2"
30
+ "@dougbots/avenor-core": "^0.3.4"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@opencode-ai/plugin": "1.15.3"