@staff0rd/assist 0.704.3 → 0.704.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.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.704.3",
9
+ version: "0.704.4",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -40912,11 +40912,13 @@ function ensureProjectDirExists(dir, sessionId) {
40912
40912
 
40913
40913
  // src/commands/sessions/shared/normalizeUser.ts
40914
40914
  var INTERRUPT_PREFIX = "[Request interrupted";
40915
+ var TASK_NOTIFICATION = "<task-notification>";
40915
40916
  function normalizeUser(entry) {
40916
40917
  const content = asRecord(entry.message)?.content;
40917
- if (typeof content === "string")
40918
- return isInterruptText(content) ? { kind: "interrupt" } : { kind: "user" };
40918
+ if (typeof content === "string") return normalizeUserText(content);
40919
40919
  if (!Array.isArray(content)) return { kind: "user" };
40920
+ if (content.length === 1 && asRecord(content[0])?.type === "text")
40921
+ return normalizeUserText(asRecord(content[0])?.text);
40920
40922
  const toolResultIds = [];
40921
40923
  let hasInterrupt = false;
40922
40924
  let hasNonToolResult = false;
@@ -40938,6 +40940,12 @@ function normalizeUser(entry) {
40938
40940
  function asRecord(value) {
40939
40941
  return value && typeof value === "object" ? value : null;
40940
40942
  }
40943
+ function normalizeUserText(text18) {
40944
+ if (isInterruptText(text18)) return { kind: "interrupt" };
40945
+ if (typeof text18 === "string" && text18.trimStart().startsWith(TASK_NOTIFICATION))
40946
+ return { kind: "taskNotification" };
40947
+ return { kind: "user" };
40948
+ }
40941
40949
  function isInterruptText(value) {
40942
40950
  return typeof value === "string" && value.startsWith(INTERRUPT_PREFIX);
40943
40951
  }
@@ -40975,6 +40983,10 @@ function asRecord2(value) {
40975
40983
  // src/commands/sessions/shared/deriveTranscriptStatus.ts
40976
40984
  var ASK_USER_QUESTION2 = "AskUserQuestion";
40977
40985
  var TURN_END_STOP_REASONS = /* @__PURE__ */ new Set(["end_turn", "stop_sequence"]);
40986
+ var NON_DECISIVE_KINDS = /* @__PURE__ */ new Set([
40987
+ "toolResult",
40988
+ "taskNotification"
40989
+ ]);
40978
40990
  function deriveTranscriptStatus(entries, opts = {}) {
40979
40991
  const events = normalizeTranscriptEvents(entries);
40980
40992
  const lastIdx = lastDecisiveIndex(events);
@@ -40982,7 +40994,7 @@ function deriveTranscriptStatus(entries, opts = {}) {
40982
40994
  const ev = events[lastIdx];
40983
40995
  if (ev.kind === "interrupt") return "waiting";
40984
40996
  if (ev.kind === "user") return "running";
40985
- if (ev.kind === "toolResult") return null;
40997
+ if (ev.kind === "toolResult" || ev.kind === "taskNotification") return null;
40986
40998
  if (ev.stopReason != null && TURN_END_STOP_REASONS.has(ev.stopReason))
40987
40999
  return "waiting";
40988
41000
  if (opts.permissionActive) return "waiting";
@@ -40994,7 +41006,7 @@ function deriveTranscriptStatus(entries, opts = {}) {
40994
41006
  }
40995
41007
  function lastDecisiveIndex(events) {
40996
41008
  for (let i = events.length - 1; i >= 0; i--)
40997
- if (events[i].kind !== "toolResult") return i;
41009
+ if (!NON_DECISIVE_KINDS.has(events[i].kind)) return i;
40998
41010
  return -1;
40999
41011
  }
41000
41012
  function resolvedToolUseIds(events, afterIdx) {
@@ -42139,13 +42151,20 @@ function daemonRestartPrompt(backgroundTaskIds) {
42139
42151
  }
42140
42152
 
42141
42153
  // src/commands/sessions/shared/unfinishedBackgroundTasks.ts
42142
- var TASK_ID = /<task-id>([^<]+)<\/task-id>/g;
42154
+ var NOTIFICATION = /<task-notification>([\s\S]*?)<\/task-notification>/g;
42155
+ var TASK_ID = /<task-id>([^<]+)<\/task-id>/;
42156
+ var STATUS = /<status>([^<]+)<\/status>/;
42157
+ var KILLED_STATUSES = /* @__PURE__ */ new Set(["killed", "stopped"]);
42158
+ var STOP_TOOLS = /* @__PURE__ */ new Set(["KillShell", "KillBash", "TaskStop"]);
42143
42159
  function unfinishedBackgroundTasks(entries) {
42144
42160
  const inFlight2 = /* @__PURE__ */ new Set();
42145
42161
  for (const entry of entries) {
42146
42162
  const started = startedTaskId(entry);
42147
42163
  if (started) inFlight2.add(started);
42148
- for (const notified of notifiedTaskIds(entry)) inFlight2.delete(notified);
42164
+ for (const finished2 of selfFinishedTaskIds(entry))
42165
+ inFlight2.delete(finished2);
42166
+ for (const stopped of deliberatelyStoppedTaskIds(entry))
42167
+ inFlight2.delete(stopped);
42149
42168
  }
42150
42169
  return [...inFlight2];
42151
42170
  }
@@ -42153,10 +42172,30 @@ function startedTaskId(entry) {
42153
42172
  const result = asRecord4(entry.toolUseResult);
42154
42173
  return typeof result?.backgroundTaskId === "string" ? result.backgroundTaskId : void 0;
42155
42174
  }
42156
- function notifiedTaskIds(entry) {
42175
+ function selfFinishedTaskIds(entry) {
42157
42176
  const text18 = taskNotificationText(entry);
42158
42177
  if (!text18) return [];
42159
- return [...text18.matchAll(TASK_ID)].map((match) => match[1]);
42178
+ const ids = [];
42179
+ for (const [, body] of text18.matchAll(NOTIFICATION)) {
42180
+ const id = body.match(TASK_ID)?.[1];
42181
+ const status3 = body.match(STATUS)?.[1]?.trim();
42182
+ if (id && !(status3 && KILLED_STATUSES.has(status3))) ids.push(id);
42183
+ }
42184
+ return ids;
42185
+ }
42186
+ function deliberatelyStoppedTaskIds(entry) {
42187
+ if (entry.type !== "assistant") return [];
42188
+ const content = asRecord4(entry.message)?.content;
42189
+ if (!Array.isArray(content)) return [];
42190
+ const ids = [];
42191
+ for (const block of content) {
42192
+ const b = asRecord4(block);
42193
+ if (b?.type !== "tool_use" || !STOP_TOOLS.has(String(b.name))) continue;
42194
+ const input = asRecord4(b.input);
42195
+ const id = input?.task_id ?? input?.shell_id ?? input?.bash_id;
42196
+ if (typeof id === "string") ids.push(id);
42197
+ }
42198
+ return ids;
42160
42199
  }
42161
42200
  function taskNotificationText(entry) {
42162
42201
  const content = asRecord4(entry.message)?.content ?? entry.content;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.704.3",
3
+ "version": "0.704.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {