@demicodes/agent 0.19.0 → 0.19.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/dist/index.d.mts CHANGED
@@ -271,6 +271,14 @@ interface AgentServerOptions {
271
271
  providers: Provider[];
272
272
  shell?: Omit<BashEnvironmentOptions, 'host' | 'commands'>;
273
273
  session?: AgentServerSessionOptions;
274
+ subagents?: {
275
+ /**
276
+ * When false, a child closing never wakes an idle parent with an automatic
277
+ * user send; the host app observes the `subagent closed` frame and drives
278
+ * the parent itself. Defaults to true.
279
+ */
280
+ notifyParentOnIdle?: boolean;
281
+ };
274
282
  /**
275
283
  * Optional host-side shell prep (env, PATH, etc.). Implementation-agnostic —
276
284
  * command bridge wiring lives in `@demicodes/host-local`, not here.
@@ -314,6 +322,7 @@ declare class AgentServer {
314
322
  private readonly shellOptions;
315
323
  private readonly sessionOptions;
316
324
  private readonly prepareShell;
325
+ private readonly notifyParentOnIdle;
317
326
  private readonly bindings;
318
327
  private readonly sessionOwnership;
319
328
  constructor(options: AgentServerOptions);
@@ -342,6 +351,8 @@ interface ChildSupervisorOptions<State> {
342
351
  shellOptions: Omit<BashEnvironmentOptions, 'host' | 'commands'>;
343
352
  prepareShell: PrepareShell | null;
344
353
  sessionOptions: AgentServerSessionOptions;
354
+ /** When false, a child closing never wakes an idle parent; the host app orchestrates the wakeup from the `subagent closed` frame. */
355
+ notifyParentOnIdle: boolean;
345
356
  emit(frame: ServerFrame): void;
346
357
  }
347
358
  /**
package/dist/index.mjs CHANGED
@@ -3049,7 +3049,7 @@ var ChildSupervisor = class {
3049
3049
  }
3050
3050
  /** Wakes an idle parent with a user send; a parent blocked in the spawn gets the tool result instead. */
3051
3051
  notifyIdleParent(job, close) {
3052
- if (this.isDisposed) return;
3052
+ if (this.isDisposed || !this.options.notifyParentOnIdle) return;
3053
3053
  const parent = this.parentSession;
3054
3054
  if (!parent || parent.phase() !== "idle") return;
3055
3055
  const label = `subagent ${job.id}${job.description ? ` — ${job.description}` : ""}`;
@@ -3057,7 +3057,7 @@ var ChildSupervisor = class {
3057
3057
  parent.send([{
3058
3058
  type: "text",
3059
3059
  text: body
3060
- }]).catch(noop);
3060
+ }], job.metadata ? { metadata: job.metadata } : {}).catch(noop);
3061
3061
  }
3062
3062
  createChildAgentNode(childId, description) {
3063
3063
  return {
@@ -3090,13 +3090,15 @@ var ChildSupervisor = class {
3090
3090
  type: "text",
3091
3091
  text: `[subagent ${childId}${description ? ` — ${description}` : ""}] ${message}`
3092
3092
  }];
3093
+ const metadata = this.jobs.get(childId)?.metadata ?? null;
3094
+ const sendOptions = metadata ? { metadata } : {};
3093
3095
  if (parent.phase() !== "idle") {
3094
3096
  parent.steer(content).catch(() => {
3095
- parent.send(content).catch(noop);
3097
+ parent.send(content, sendOptions).catch(noop);
3096
3098
  });
3097
3099
  return;
3098
3100
  }
3099
- parent.send(content).catch(noop);
3101
+ parent.send(content, sendOptions).catch(noop);
3100
3102
  }
3101
3103
  async childEnvironment(job, ctx) {
3102
3104
  const resolved = await this.options.agent.host({
@@ -3445,6 +3447,7 @@ var AgentServer = class {
3445
3447
  shellOptions;
3446
3448
  sessionOptions;
3447
3449
  prepareShell;
3450
+ notifyParentOnIdle;
3448
3451
  bindings = /* @__PURE__ */ new Set();
3449
3452
  sessionOwnership = new SessionOwnershipRegistry();
3450
3453
  constructor(options) {
@@ -3453,6 +3456,7 @@ var AgentServer = class {
3453
3456
  this.shellOptions = options.shell ?? {};
3454
3457
  this.sessionOptions = options.session ?? {};
3455
3458
  this.prepareShell = options.prepareShell ?? null;
3459
+ this.notifyParentOnIdle = options.subagents?.notifyParentOnIdle ?? true;
3456
3460
  }
3457
3461
  client() {
3458
3462
  const transports = createInProcessTransportPair();
@@ -3467,6 +3471,7 @@ var AgentServer = class {
3467
3471
  shell: this.shellOptions,
3468
3472
  session: this.sessionOptions,
3469
3473
  prepareShell: this.prepareShell,
3474
+ notifyParentOnIdle: this.notifyParentOnIdle,
3470
3475
  sessions: this.sessionOwnership
3471
3476
  });
3472
3477
  this.bindings.add(binding);
@@ -3516,6 +3521,7 @@ var AgentTransportBindingImpl = class {
3516
3521
  shellOptions;
3517
3522
  sessionOptions;
3518
3523
  prepareShell;
3524
+ notifyParentOnIdle;
3519
3525
  sessions;
3520
3526
  session = null;
3521
3527
  currentAgent = null;
@@ -3537,6 +3543,7 @@ var AgentTransportBindingImpl = class {
3537
3543
  this.shellOptions = options.shell ?? {};
3538
3544
  this.sessionOptions = options.session ?? {};
3539
3545
  this.prepareShell = options.prepareShell;
3546
+ this.notifyParentOnIdle = options.notifyParentOnIdle;
3540
3547
  this.sessions = options.sessions;
3541
3548
  this.unsubscribeTransport = this.transport.onFrame((frame) => {
3542
3549
  this.handleFrame(frame);
@@ -3752,6 +3759,7 @@ var AgentTransportBindingImpl = class {
3752
3759
  shellOptions: this.shellOptions,
3753
3760
  prepareShell: this.prepareShell,
3754
3761
  sessionOptions: this.sessionOptions,
3762
+ notifyParentOnIdle: this.notifyParentOnIdle,
3755
3763
  emit: (subagentFrame) => this.send(subagentFrame)
3756
3764
  });
3757
3765
  const commands = injectSubagentCommand(harnessCommands, supervisor.rootCommandNode());
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@demicodes/agent",
3
3
  "description": "Session runtime and transport-neutral client and server protocol for Demi.",
4
- "version": "0.19.0",
4
+ "version": "0.19.1",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "exports": {
@@ -19,10 +19,10 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@demicodes/core": "^0.19.0",
23
- "@demicodes/provider": "^0.19.0",
24
- "@demicodes/shell": "^0.19.0",
25
- "@demicodes/utils": "^0.19.0",
22
+ "@demicodes/core": "^0.19.1",
23
+ "@demicodes/provider": "^0.19.1",
24
+ "@demicodes/shell": "^0.19.1",
25
+ "@demicodes/utils": "^0.19.1",
26
26
  "zod": "^4.0.0"
27
27
  },
28
28
  "license": "Apache-2.0",