agent.libx.js 0.94.2 → 0.94.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/dist/index.d.ts CHANGED
@@ -880,6 +880,8 @@ declare class DuplexAgent {
880
880
  private ackIfSilent;
881
881
  /** One user turn: the voice agent streams the reply (and may Act/Think). Serialized with re-voice turns. */
882
882
  send(content: MessageContent): Promise<RunResult>;
883
+ /** Cancel a running background task — shared by the CancelTask tool and the CLI /tasks picker. */
884
+ cancelTask(id: string): string;
883
885
  /** Resolve when all queued voice turns AND all in-flight worker tasks have settled (tests, graceful shutdown). */
884
886
  idle(): Promise<void>;
885
887
  /** Promise-chain mutex: turns run strictly one at a time; a failed turn doesn't poison the chain. */
package/dist/index.js CHANGED
@@ -4292,6 +4292,15 @@ Today's date: ${(/* @__PURE__ */ new Date()).toDateString()}.`;
4292
4292
  return res;
4293
4293
  });
4294
4294
  }
4295
+ /** Cancel a running background task — shared by the CancelTask tool and the CLI /tasks picker. */
4296
+ cancelTask(id) {
4297
+ const rec = this.tasks.get(id);
4298
+ if (!rec) return `No task '${id}'.`;
4299
+ if (rec.status !== "running") return `Task ${rec.id} is already ${rec.status}.`;
4300
+ rec.status = "cancelled";
4301
+ rec.controller.abort();
4302
+ return `Task ${rec.id} (${rec.label}) cancelled.`;
4303
+ }
4295
4304
  /** Resolve when all queued voice turns AND all in-flight worker tasks have settled (tests, graceful shutdown). */
4296
4305
  async idle() {
4297
4306
  while (true) {
@@ -4708,14 +4717,7 @@ Another agent just implemented the above. Independently check the CURRENT state
4708
4717
  name: "CancelTask",
4709
4718
  description: "Cancel a running background task by id.",
4710
4719
  parameters: { type: "object", required: ["id"], properties: { id: { type: "string" } } },
4711
- run: async ({ id }) => {
4712
- const rec = this.tasks.get(String(id));
4713
- if (!rec) return `No task '${id}'.`;
4714
- if (rec.status !== "running") return `Task ${rec.id} is already ${rec.status}.`;
4715
- rec.status = "cancelled";
4716
- rec.controller.abort();
4717
- return `Task ${rec.id} (${rec.label}) cancelled.`;
4718
- }
4720
+ run: async ({ id }) => this.cancelTask(String(id))
4719
4721
  };
4720
4722
  }
4721
4723
  };