@rallycry/conveyor-agent 11.0.32 → 11.0.33

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.
@@ -2112,11 +2112,19 @@ function userRecordText(record) {
2112
2112
  if (content.some((b) => isRecord3(b) && b.type === "tool_result")) return void 0;
2113
2113
  return content.filter((b) => isRecord3(b) && b.type === "text").map((b) => typeof b.text === "string" ? b.text : "").filter((t) => t.length > 0).join("\n");
2114
2114
  }
2115
- function isBackgroundTaskNotificationRecord(raw) {
2116
- if (!isRecord3(raw) || raw.type !== "user") return false;
2117
- if (raw.isSidechain === true || raw.isMeta === true) return false;
2118
- const text = userRecordText(raw);
2119
- return text !== void 0 && text.trimStart().startsWith(TASK_NOTIFICATION_PREFIX);
2115
+ function backgroundTaskCompletion(raw) {
2116
+ if (!isRecord3(raw) || raw.isSidechain === true || raw.isMeta === true) return null;
2117
+ const text = notificationText(raw);
2118
+ if (text === void 0 || !text.trimStart().startsWith(TASK_NOTIFICATION_PREFIX)) return null;
2119
+ const taskId = /<task-id>([^<]+)<\/task-id>/.exec(text)?.[1]?.trim();
2120
+ return { taskId: taskId || null };
2121
+ }
2122
+ function notificationText(record) {
2123
+ if (record.type === "user") return userRecordText(record);
2124
+ if (record.type !== "attachment") return void 0;
2125
+ const attachment = record.attachment;
2126
+ if (!isRecord3(attachment) || attachment.commandMode !== "task-notification") return void 0;
2127
+ return typeof attachment.prompt === "string" ? attachment.prompt : void 0;
2120
2128
  }
2121
2129
  function mapSystem2(record) {
2122
2130
  if (record.subtype === "init") {
@@ -3666,7 +3674,8 @@ var PtySession = class {
3666
3674
  * backgrounded gate/subagent just finished) and the chat-proxy projection.
3667
3675
  */
3668
3676
  handleRawRecord(raw) {
3669
- if (isBackgroundTaskNotificationRecord(raw)) this.bridge?.notifyBackgroundTaskDone?.();
3677
+ const completion = backgroundTaskCompletion(raw);
3678
+ if (completion) this.bridge?.notifyBackgroundTaskDone?.(completion.taskId);
3670
3679
  if (typeof this.bridge?.sendChatEvent === "function") this.relayChatRecord(raw);
3671
3680
  }
3672
3681
  /**
@@ -13916,7 +13925,7 @@ var QueryBridge = class {
13916
13925
  let bridge;
13917
13926
  if (harnessKind === "pty") {
13918
13927
  this.directStream = wrapBridgeWithDirectStream(
13919
- buildPtyBridge(connection, () => this.onBackgroundTaskDone?.()),
13928
+ buildPtyBridge(connection, (taskId) => this.onBackgroundTaskDone?.(taskId)),
13920
13929
  connection
13921
13930
  );
13922
13931
  bridge = this.directStream.bridge;
@@ -14641,6 +14650,8 @@ function isBackgroundLaunch(tool2, input) {
14641
14650
  var BackgroundWorkTracker = class {
14642
14651
  /** Absolute expiry (epoch ms) of each outstanding launch, oldest first. */
14643
14652
  deadlines = [];
14653
+ /** CLI task ids already counted as complete. */
14654
+ completedTaskIds = /* @__PURE__ */ new Set();
14644
14655
  maxMs;
14645
14656
  onChange;
14646
14657
  log;
@@ -14669,7 +14680,11 @@ var BackgroundWorkTracker = class {
14669
14680
  * runner never saw, a re-injected record) must be a no-op, never a negative
14670
14681
  * balance that would keep the pod awake after the real work finished.
14671
14682
  */
14672
- noteCompletion(now = Date.now()) {
14683
+ noteCompletion(now = Date.now(), taskId = null) {
14684
+ if (taskId !== null) {
14685
+ if (this.completedTaskIds.has(taskId)) return;
14686
+ this.completedTaskIds.add(taskId);
14687
+ }
14673
14688
  this.prune(now);
14674
14689
  if (this.deadlines.length === 0) return;
14675
14690
  this.deadlines.shift();
@@ -14689,6 +14704,7 @@ var BackgroundWorkTracker = class {
14689
14704
  }
14690
14705
  /** Drop everything (shutdown / session teardown). */
14691
14706
  clear() {
14707
+ this.completedTaskIds.clear();
14692
14708
  if (this.deadlines.length === 0) return;
14693
14709
  this.deadlines.length = 0;
14694
14710
  this.onChange?.();
@@ -16057,7 +16073,7 @@ var SessionRunner = class _SessionRunner {
16057
16073
  onUserQuestion: (signal) => this.handleUserQuestionSignal(signal)
16058
16074
  });
16059
16075
  bridge.isParentTask = this.fullContext?.isParentTask ?? false;
16060
- bridge.onBackgroundTaskDone = () => this.backgroundWork.noteCompletion();
16076
+ bridge.onBackgroundTaskDone = (taskId) => this.backgroundWork.noteCompletion(Date.now(), taskId ?? null);
16061
16077
  bridge.onSoftStop = () => {
16062
16078
  process.stderr.write("[conveyor-agent] Soft stop requested (discovery ExitPlanMode)\n");
16063
16079
  this.softStop();
package/dist/cli.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  runUsageProbe,
28
28
  sampleKeyUsage,
29
29
  usesNativeUsageReporting
30
- } from "./chunk-Q2E2TM3J.js";
30
+ } from "./chunk-A73WZJ4Y.js";
31
31
  import "./chunk-37J5MMQT.js";
32
32
  import {
33
33
  inheritedEnv,
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SessionRunner,
3
3
  unshallowRepo
4
- } from "./chunk-Q2E2TM3J.js";
4
+ } from "./chunk-A73WZJ4Y.js";
5
5
  import "./chunk-37J5MMQT.js";
6
6
  import "./chunk-EKTPDG3G.js";
7
7
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rallycry/conveyor-agent",
3
- "version": "11.0.32",
3
+ "version": "11.0.33",
4
4
  "description": "Conveyor Agent Runner v10 - PTY harness for the task chat (SDK harness for audit/project-chat). Agent-as-User architecture with BaseService patterns. Works locally too.",
5
5
  "keywords": [
6
6
  "agent",