agent.libx.js 0.94.5 → 0.94.6

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
@@ -775,6 +775,10 @@ interface TaskRecord {
775
775
  controller: AbortController;
776
776
  /** Settles when the worker finished AND its completion was processed. Never rejects. */
777
777
  promise: Promise<void>;
778
+ /** Rolling activity tail (tool calls + last-result previews, capped) — feeds task inspection UIs. */
779
+ tail: string[];
780
+ /** Final report text (or error message) once the task settled. */
781
+ result?: string;
778
782
  }
779
783
  type WorkerTier = 'act' | 'think';
780
784
  declare class DuplexAgentOptions {
package/dist/index.js CHANGED
@@ -4357,22 +4357,30 @@ ${recent}` : brief) + verify;
4357
4357
  const controller = new AbortController();
4358
4358
  const base = tierOpts?.hooks ?? o.actOptions?.hooks;
4359
4359
  const report = o.progressUpdates ? this.progressReporter(id) : void 0;
4360
- const hooks = report ? {
4360
+ const tail = [];
4361
+ const pushTail = (line) => {
4362
+ tail.push(line.slice(0, 200));
4363
+ if (tail.length > 120) tail.splice(0, tail.length - 120);
4364
+ };
4365
+ const hooks = {
4361
4366
  ...base,
4362
4367
  preToolUse: async (call, meta) => {
4363
4368
  const d = await base?.preToolUse?.(call, meta);
4364
- report.pre(call);
4369
+ pushTail(`\u2699 ${describeCall(call)}`);
4370
+ report?.pre(call);
4365
4371
  return d;
4366
4372
  },
4367
4373
  postToolUse: async (call, result, meta) => {
4368
4374
  await base?.postToolUse?.(call, result, meta);
4369
- report.post(call);
4375
+ const last = result?.trim().split("\n").filter(Boolean).pop();
4376
+ if (last) pushTail(` \u21B3 ${last}`);
4377
+ report?.post(call);
4370
4378
  },
4371
4379
  onToolOutput: (call, chunk, meta) => {
4372
4380
  base?.onToolOutput?.(call, chunk, meta);
4373
- report.output(chunk);
4381
+ report?.output(chunk);
4374
4382
  }
4375
- } : base;
4383
+ };
4376
4384
  const relayAsk = async (q) => {
4377
4385
  const opts = q.options?.length ? ` Options: ${q.options.map((x) => x.label).join(", ")}.` : "";
4378
4386
  const a = await this.parkQuestion(id, `${q.question}${opts}`);
@@ -4394,7 +4402,7 @@ ${recent}` : brief) + verify;
4394
4402
  // shared with the checker so a cancel tears down both
4395
4403
  };
4396
4404
  const promise = new Agent(agentOpts).run(briefText).then((res) => this.maybeVerify(id, briefText, res, tier, agentOpts)).then((res) => this.onWorkerSettled(id, res)).catch((err) => this.onWorkerFailed(id, err));
4397
- this.tasks.set(id, { id, label, status: "running", controller, promise });
4405
+ this.tasks.set(id, { id, label, status: "running", controller, promise, tail });
4398
4406
  }
4399
4407
  /** Fresh-context check of a successful Act task: a NEW agent (same model/fs/tools, but NO shared
4400
4408
  * conversation context) re-reads the file state against the brief and fixes any gap. The fix lands
@@ -4513,6 +4521,7 @@ Another agent just implemented the above. Independently check the CURRENT state
4513
4521
  return this.failTask(rec, msg);
4514
4522
  }
4515
4523
  rec.status = "done";
4524
+ rec.result = res.text;
4516
4525
  log8.verbose(`task ${id} done (${res.steps} steps)`);
4517
4526
  this.notify("task_done", `task ${id} (${rec.label}) completed`, {
4518
4527
  id,
@@ -4530,6 +4539,7 @@ Another agent just implemented the above. Independently check the CURRENT state
4530
4539
  failTask(rec, msg) {
4531
4540
  this.dropAsk(rec.id);
4532
4541
  rec.status = "error";
4542
+ rec.result = msg;
4533
4543
  log8.warn(`task ${rec.id} failed: ${msg}`);
4534
4544
  this.notify("task_error", `task ${rec.id} (${rec.label}) failed: ${msg}`);
4535
4545
  this.queueRevoice(`[task ${rec.id} failed] ${msg}`);