@staff0rd/assist 0.748.0 → 0.748.2

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.748.0",
9
+ version: "0.748.2",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -42589,6 +42589,36 @@ function ensureProjectDirExists(dir, sessionId) {
42589
42589
  }
42590
42590
  }
42591
42591
 
42592
+ // src/commands/sessions/shared/hasPendingAskUserQuestion.ts
42593
+ var ASK_USER_QUESTION2 = "AskUserQuestion";
42594
+ function hasPendingAskUserQuestion(events, idx) {
42595
+ const ev = events[idx];
42596
+ if (ev?.kind !== "assistant") return false;
42597
+ const resolved = resolvedToolUseIds(events, idx);
42598
+ return ev.toolUses.some(
42599
+ (tool) => tool.name === ASK_USER_QUESTION2 && !resolved.has(tool.id)
42600
+ );
42601
+ }
42602
+ function resolvedToolUseIds(events, afterIdx) {
42603
+ const ids = /* @__PURE__ */ new Set();
42604
+ for (let i = afterIdx + 1; i < events.length; i++) {
42605
+ const event = events[i];
42606
+ if (event.kind === "toolResult") for (const id of event.ids) ids.add(id);
42607
+ }
42608
+ return ids;
42609
+ }
42610
+
42611
+ // src/commands/sessions/shared/lastDecisiveIndex.ts
42612
+ var NON_DECISIVE_KINDS = /* @__PURE__ */ new Set([
42613
+ "toolResult",
42614
+ "taskNotification"
42615
+ ]);
42616
+ function lastDecisiveIndex(events) {
42617
+ for (let i = events.length - 1; i >= 0; i--)
42618
+ if (!NON_DECISIVE_KINDS.has(events[i].kind)) return i;
42619
+ return -1;
42620
+ }
42621
+
42592
42622
  // src/commands/sessions/shared/normalizeUser.ts
42593
42623
  var INTERRUPT_PREFIX = "[Request interrupted";
42594
42624
  var TASK_NOTIFICATION = "<task-notification>";
@@ -42660,12 +42690,7 @@ function asRecord2(value) {
42660
42690
  }
42661
42691
 
42662
42692
  // src/commands/sessions/shared/deriveTranscriptStatus.ts
42663
- var ASK_USER_QUESTION2 = "AskUserQuestion";
42664
42693
  var TURN_END_STOP_REASONS = /* @__PURE__ */ new Set(["end_turn", "stop_sequence"]);
42665
- var NON_DECISIVE_KINDS = /* @__PURE__ */ new Set([
42666
- "toolResult",
42667
- "taskNotification"
42668
- ]);
42669
42694
  function deriveTranscriptStatus(entries, opts = {}) {
42670
42695
  const events = normalizeTranscriptEvents(entries);
42671
42696
  const lastIdx = lastDecisiveIndex(events);
@@ -42677,25 +42702,9 @@ function deriveTranscriptStatus(entries, opts = {}) {
42677
42702
  if (ev.stopReason != null && TURN_END_STOP_REASONS.has(ev.stopReason))
42678
42703
  return "waiting";
42679
42704
  if (opts.permissionActive) return "waiting";
42680
- const resolved = resolvedToolUseIds(events, lastIdx);
42681
- const pending = ev.toolUses.filter((tool) => !resolved.has(tool.id));
42682
- if (pending.some((tool) => tool.name === ASK_USER_QUESTION2))
42683
- return "waiting";
42705
+ if (hasPendingAskUserQuestion(events, lastIdx)) return "waiting";
42684
42706
  return "running";
42685
42707
  }
42686
- function lastDecisiveIndex(events) {
42687
- for (let i = events.length - 1; i >= 0; i--)
42688
- if (!NON_DECISIVE_KINDS.has(events[i].kind)) return i;
42689
- return -1;
42690
- }
42691
- function resolvedToolUseIds(events, afterIdx) {
42692
- const ids = /* @__PURE__ */ new Set();
42693
- for (let i = afterIdx + 1; i < events.length; i++) {
42694
- const event = events[i];
42695
- if (event.kind === "toolResult") for (const id of event.ids) ids.add(id);
42696
- }
42697
- return ids;
42698
- }
42699
42708
 
42700
42709
  // src/commands/sessions/shared/renderPrompt.ts
42701
42710
  function renderPrompt(raw) {
@@ -43818,6 +43827,12 @@ function errorSession(id, persisted, error) {
43818
43827
  };
43819
43828
  }
43820
43829
 
43830
+ // src/commands/sessions/shared/awaitsQuestionAnswer.ts
43831
+ function awaitsQuestionAnswer(entries) {
43832
+ const events = normalizeTranscriptEvents(entries);
43833
+ return hasPendingAskUserQuestion(events, lastDecisiveIndex(events));
43834
+ }
43835
+
43821
43836
  // src/commands/sessions/daemon/deriveRestoreStatus.ts
43822
43837
  function deriveRestoreStatus(persisted) {
43823
43838
  if (!persisted.claudeSessionId) return "waiting";
@@ -43827,7 +43842,8 @@ function deriveRestoreStatus(persisted) {
43827
43842
  );
43828
43843
  if (!filePath) return "waiting";
43829
43844
  const entries = readTranscriptTailSync(filePath);
43830
- return deriveTranscriptStatus(entries) === "running" ? "running" : "waiting";
43845
+ if (deriveTranscriptStatus(entries) === "running") return "running";
43846
+ return awaitsQuestionAnswer(entries) ? "asking" : "waiting";
43831
43847
  }
43832
43848
 
43833
43849
  // src/commands/sessions/daemon/hasTranscriptOnDisk.ts
@@ -43935,11 +43951,19 @@ function killedByDaemonRestart(interrupted) {
43935
43951
  return interrupted?.reason === DAEMON_RESTART;
43936
43952
  }
43937
43953
 
43954
+ // src/commands/sessions/daemon/pendingQuestionPrompt.ts
43955
+ function pendingQuestionPrompt() {
43956
+ return "A restart interrupted this conversation while your AskUserQuestion was waiting for an answer. The user never saw it and it is no longer on screen. Ask the same question again with AskUserQuestion.";
43957
+ }
43958
+
43938
43959
  // src/commands/sessions/daemon/restoreResumePlan.ts
43939
- function restoreResumePlan(persisted, idle) {
43960
+ function restoreResumePlan(persisted, status3) {
43940
43961
  const tasks = interruptedBackgroundTasks(persisted);
43941
43962
  if (tasks.length > 0)
43942
43963
  return { prompt: daemonRestartPrompt(tasks), idle: false };
43964
+ if (status3 === "asking")
43965
+ return { prompt: pendingQuestionPrompt(), idle: false };
43966
+ const idle = status3 === "waiting";
43943
43967
  if (!killedByDaemonRestart(persisted.interrupted) || idle) return { idle };
43944
43968
  return { prompt: daemonRestartPrompt(tasks), idle: false };
43945
43969
  }
@@ -43978,9 +44002,9 @@ function restoredSession(base, persisted, pty2, status3) {
43978
44002
  }
43979
44003
 
43980
44004
  // src/commands/sessions/daemon/restoreCodexSession.ts
43981
- function restoreCodexSession(id, persisted, base, idle) {
44005
+ function restoreCodexSession(id, persisted, base, status3) {
43982
44006
  if (!persisted.harnessSessionId) return null;
43983
- const plan2 = restoreResumePlan(persisted, idle);
44007
+ const plan2 = restoreResumePlan(persisted, status3);
43984
44008
  const pty2 = spawnCodex2({
43985
44009
  resumeSessionId: persisted.harnessSessionId,
43986
44010
  prompt: resumePrompt(plan2),
@@ -43998,9 +44022,9 @@ function unresumableReason(harness) {
43998
44022
  }
43999
44023
 
44000
44024
  // src/commands/sessions/daemon/resumeViaClaude.ts
44001
- function resumeViaClaude(id, persisted, base, idle) {
44025
+ function resumeViaClaude(id, persisted, base, status3) {
44002
44026
  const mode = { design: persisted.design, auto: persisted.auto };
44003
- const plan2 = restoreResumePlan(persisted, idle);
44027
+ const plan2 = restoreResumePlan(persisted, status3);
44004
44028
  const pty2 = spawnClaude2(
44005
44029
  hasTranscriptOnDisk(persisted) ? {
44006
44030
  resumeSessionId: persisted.claudeSessionId,
@@ -44022,12 +44046,12 @@ function resumeViaClaude(id, persisted, base, idle) {
44022
44046
  function isCodex(harness) {
44023
44047
  return resolveHarness(harness) === "codex";
44024
44048
  }
44025
- function restoreInteractiveSession(id, persisted, base, idle) {
44049
+ function restoreInteractiveSession(id, persisted, base, status3) {
44026
44050
  if (persisted.commandType !== "run" && persisted.claudeSessionId && resolveHarness(persisted.harness) === "claude") {
44027
- return resumeViaClaude(id, persisted, base, idle);
44051
+ return resumeViaClaude(id, persisted, base, status3);
44028
44052
  }
44029
44053
  if (persisted.commandType !== "run" && isCodex(persisted.harness)) {
44030
- const resumed = restoreCodexSession(id, persisted, base, idle);
44054
+ const resumed = restoreCodexSession(id, persisted, base, status3);
44031
44055
  if (resumed) return resumed;
44032
44056
  }
44033
44057
  if (persisted.commandType === "claude") {
@@ -44095,11 +44119,13 @@ function restoreSession(id, persisted) {
44095
44119
  const base = restoreBase(id, persisted);
44096
44120
  if (persisted.status === "stopped") return stoppedSession(base, persisted);
44097
44121
  if (isUpdate(persisted)) return updatedSession(id, persisted);
44098
- const idle = deriveRestoreStatus(persisted) !== "running";
44122
+ const status3 = deriveRestoreStatus(persisted);
44099
44123
  if (needsWrapperRelaunch(persisted)) {
44100
44124
  const resumesWrittenConversation = hasTranscriptOnDisk(persisted);
44101
- const reattachesIdleConversation = idle && resumesWrittenConversation;
44102
- const plan2 = restoreResumePlan(persisted, reattachesIdleConversation);
44125
+ const plan2 = restoreResumePlan(
44126
+ persisted,
44127
+ resumesWrittenConversation ? status3 : "running"
44128
+ );
44103
44129
  const pty2 = spawnPty(
44104
44130
  resumesWrittenConversation ? assistResumeArgs(persisted) : assistResumeArgs({ assistArgs: persisted.assistArgs }),
44105
44131
  persisted.cwd,
@@ -44108,7 +44134,7 @@ function restoreSession(id, persisted) {
44108
44134
  );
44109
44135
  return plan2.idle ? waitingSession(base, persisted, pty2) : runningSession(base, persisted, pty2);
44110
44136
  }
44111
- return restoreInteractiveSession(id, persisted, base, idle);
44137
+ return restoreInteractiveSession(id, persisted, base, status3);
44112
44138
  }
44113
44139
 
44114
44140
  // src/commands/sessions/daemon/restoreOne.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.748.0",
3
+ "version": "0.748.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {