dsh-llm-verifier 0.6.8 → 0.6.9

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.
@@ -361,7 +361,7 @@ function blockText$1(blocks) {
361
361
  * @param blocks - content blocks of an `assistant/message` event.
362
362
  * @returns The joined text, trimmed.
363
363
  */
364
- function narrativeText(blocks) {
364
+ function narrativeText$1(blocks) {
365
365
  const parts = [];
366
366
  const visit = (items) => {
367
367
  for (const block of items) if (block.type === "text") parts.push(block.text);
@@ -433,7 +433,7 @@ function buildEvidenceIndex(events) {
433
433
  }
434
434
  } else if (event.type === "assistant/message") {
435
435
  const blocks = event.data?.message?.content ?? event.data?.content;
436
- const text = narrativeText(Array.isArray(blocks) ? blocks : []);
436
+ const text = narrativeText$1(Array.isArray(blocks) ? blocks : []);
437
437
  if (text) narration = {
438
438
  seq: event.seq,
439
439
  text
@@ -1776,7 +1776,8 @@ const PASSIVE_TOOLS = /* @__PURE__ */ new Set([
1776
1776
  "list_agents",
1777
1777
  "get_goal",
1778
1778
  "skill",
1779
- "mcp__codegraph__codegraph_explore"
1779
+ "mcp__codegraph__codegraph_explore",
1780
+ "ask_user_question"
1780
1781
  ]);
1781
1782
  const VERIFIER_TOOLS = /* @__PURE__ */ new Set([
1782
1783
  "verifier_compare",
@@ -1993,6 +1994,126 @@ function hasPendingSubagents(events, taskStartSeq) {
1993
1994
  }
1994
1995
  return pendingContinuable.size > 0 || pendingJobs.size > 0 || anonymousPendingCount > 0;
1995
1996
  }
1997
+ function parseArgumentsObject(value) {
1998
+ if (typeof value === "string") try {
1999
+ const parsed = JSON.parse(value);
2000
+ return typeof parsed === "object" && parsed !== null ? parsed : {};
2001
+ } catch {
2002
+ return {};
2003
+ }
2004
+ return typeof value === "object" && value !== null ? value : {};
2005
+ }
2006
+ const USER_QUESTION_PATTERNS = [
2007
+ /[??]\s*["'))』」]*\s*$/u,
2008
+ /(?:请|麻烦您?)(?:告知|确认|指示|选择|提供|决定|回复)/u,
2009
+ /(?:等待|静待|等)(?:您的|你的|您|你|用户)?(?:确认|指示|回复|决定|指令|反馈|选择|输入)/u,
2010
+ /(?:如果您?|如|若)(?:希望|需要|想)(?:继续|执行).*(?:请|告诉我|告知)/u,
2011
+ /(?:是否|要不要|可否)(?:需要我?|继续|同意|允许|采用).*[??]?/u,
2012
+ /(?:暂时|先|已)?暂停(?:工作|执行|后续).*(?:等|指示|确认|决定|用户)/u,
2013
+ /\b(?:please\s+(?:confirm|let\s+me\s+know|advise|choose|select|provide|indicate|tell\s+me|reply))\b/iu,
2014
+ /\b(?:waiting\s+for|awaiting)\s+(?:your\s+|user\s+)?(?:input|instructions?|reply|response|confirmation|decision|guidance|feedback)\b/iu,
2015
+ /\b(?:would\s+you\s+like|should\s+i|do\s+you\s+want\s+me\s+to|how\s+would\s+you\s+like|which\s+(?:option|approach|strategy)\s+do\s+you\s+prefer)\b/iu,
2016
+ /\b(?:let\s+me\s+know\s+(?:how|what|if|whether|when))\b/iu,
2017
+ /\b(?:paused?\s+(?:work|execution|here|for\s+now)|stopping\s+here)\b/iu
2018
+ ];
2019
+ function isAwaitingUserText(text) {
2020
+ const trimmed = text.trim();
2021
+ if (!trimmed) return false;
2022
+ const lastLine = trimmed.split("\n").filter((l) => l.trim()).at(-1) ?? "";
2023
+ return USER_QUESTION_PATTERNS.some((p) => p.test(lastLine) || p.test(trimmed));
2024
+ }
2025
+ function narrativeText(blocks) {
2026
+ if (typeof blocks === "string") return blocks.trim();
2027
+ if (!Array.isArray(blocks)) return "";
2028
+ const parts = [];
2029
+ for (const block of blocks) if (block?.type === "text" && typeof block.text === "string") parts.push(block.text);
2030
+ else if (block?.type === "tool-result") parts.push(blockText(block.content));
2031
+ return parts.join("\n").trim();
2032
+ }
2033
+ /**
2034
+ * Whether the agent has paused to ask the user a question, obtain confirmation, or await user instructions.
2035
+ *
2036
+ * During task execution, an agent may legitimately pause to ask the operator a question
2037
+ * (e.g. calling `ask_user_question`, pausing/blocking a goal, or concluding a turn with prose
2038
+ * awaiting user guidance). Gating or steering in this state forces the model to keep executing,
2039
+ * overriding the user interaction boundary and locking the user out of providing guidance.
2040
+ *
2041
+ * Returns undefined when the work has already reached its delivery phase (all todos completed
2042
+ * with verification evidence), because in that state the agent is delivering the task rather than
2043
+ * pausing for input.
2044
+ */
2045
+ function inspectUserInteractionPause(events, taskStartSeq, currentTurn) {
2046
+ const delivery = inspectDeliveryPhase(events);
2047
+ if (delivery?.todosComplete && delivery.verification !== void 0) return;
2048
+ let turnEvents = events;
2049
+ if (currentTurn !== void 0) {
2050
+ const turnStartIndex = events.findLastIndex((e) => e.type === "turn/start" && e.data.turn === currentTurn);
2051
+ if (turnStartIndex >= 0) turnEvents = events.slice(turnStartIndex);
2052
+ else {
2053
+ const byTurn = events.filter((e) => e.data?.turn === currentTurn);
2054
+ if (byTurn.length > 0) turnEvents = byTurn;
2055
+ }
2056
+ } else {
2057
+ const lastTurnStart = events.findLastIndex((e) => e.type === "turn/start");
2058
+ if (lastTurnStart >= 0) turnEvents = events.slice(lastTurnStart);
2059
+ }
2060
+ let lastAskUserSeq = -1;
2061
+ for (const event of turnEvents) if (event.type === "tool/call") {
2062
+ if (event.data.name === "ask_user_question") lastAskUserSeq = Math.max(lastAskUserSeq, event.seq);
2063
+ } else if (CODE_DISPATCH_TYPES.has(event.type)) {
2064
+ if (event.data?.name === "ask_user_question") lastAskUserSeq = Math.max(lastAskUserSeq, event.seq);
2065
+ }
2066
+ if (lastAskUserSeq >= 0) {
2067
+ if (!turnEvents.some((event) => {
2068
+ if (event.seq <= lastAskUserSeq) return false;
2069
+ if (event.type === "tool/call") return isConsequential(event.data.name);
2070
+ if (CODE_DISPATCH_TYPES.has(event.type)) {
2071
+ const data = event.data;
2072
+ return data ? isConsequential(data.name) : false;
2073
+ }
2074
+ return false;
2075
+ })) return {
2076
+ paused: true,
2077
+ reason: "ask_user_question in current turn"
2078
+ };
2079
+ }
2080
+ const taskEvents = events.filter((e) => e.seq >= taskStartSeq);
2081
+ let goalPhase;
2082
+ for (const event of taskEvents) if (event.type === "tool/call") {
2083
+ const call = event;
2084
+ if (call.data.name === "update_goal") {
2085
+ const args = parseArgumentsObject(call.data.arguments);
2086
+ if (args.action === "pause") goalPhase = "paused";
2087
+ else if (args.action === "blocked") goalPhase = "blocked";
2088
+ else if (args.action === "resume") goalPhase = "active";
2089
+ else if (args.action === "complete") goalPhase = "complete";
2090
+ }
2091
+ } else if (CODE_DISPATCH_TYPES.has(event.type)) {
2092
+ const data = event.data;
2093
+ if (data?.name === "update_goal") {
2094
+ const args = parseArgumentsObject(data.arguments);
2095
+ if (args.action === "pause") goalPhase = "paused";
2096
+ else if (args.action === "blocked") goalPhase = "blocked";
2097
+ else if (args.action === "resume") goalPhase = "active";
2098
+ else if (args.action === "complete") goalPhase = "complete";
2099
+ }
2100
+ }
2101
+ if (goalPhase === "paused" || goalPhase === "blocked") return {
2102
+ paused: true,
2103
+ reason: "goal is " + goalPhase
2104
+ };
2105
+ const lastAssistant = turnEvents.filter((e) => e.type === "assistant/message").at(-1);
2106
+ if (lastAssistant && lastAssistant.type === "assistant/message") {
2107
+ const content = lastAssistant.data.message?.content ?? [];
2108
+ if (!content.some((b) => b.type === "tool-call")) {
2109
+ const text = narrativeText(content);
2110
+ if (text && isAwaitingUserText(text)) return {
2111
+ paused: true,
2112
+ reason: "assistant awaiting user instructions"
2113
+ };
2114
+ }
2115
+ }
2116
+ }
1996
2117
  function analyzeAutoTask(events, policy, sessionId) {
1997
2118
  const taskStartSeq = latestDirectUserSeq(events);
1998
2119
  if (taskStartSeq === void 0) return {
@@ -2003,6 +2124,7 @@ function analyzeAutoTask(events, policy, sessionId) {
2003
2124
  hasManualSessionVerification: false,
2004
2125
  manualVerificationAccepted: false,
2005
2126
  pendingSubagents: false,
2127
+ pendingUserInteraction: false,
2006
2128
  eligible: false,
2007
2129
  reason: "no-direct-user-task"
2008
2130
  };
@@ -2061,6 +2183,7 @@ function analyzeAutoTask(events, policy, sessionId) {
2061
2183
  }, policy.threshold) && !stale(verdict.toSeq);
2062
2184
  });
2063
2185
  const pendingSubagents = hasPendingSubagents(events, taskStartSeq);
2186
+ const pendingUserInteraction = inspectUserInteractionPause(events, taskStartSeq) !== void 0;
2064
2187
  if (policy.mode === "manual") return {
2065
2188
  taskStartSeq,
2066
2189
  toolCalls,
@@ -2069,6 +2192,7 @@ function analyzeAutoTask(events, policy, sessionId) {
2069
2192
  hasManualSessionVerification,
2070
2193
  manualVerificationAccepted,
2071
2194
  pendingSubagents,
2195
+ pendingUserInteraction,
2072
2196
  eligible: false,
2073
2197
  reason: "manual-mode"
2074
2198
  };
@@ -2080,6 +2204,7 @@ function analyzeAutoTask(events, policy, sessionId) {
2080
2204
  hasManualSessionVerification,
2081
2205
  manualVerificationAccepted,
2082
2206
  pendingSubagents,
2207
+ pendingUserInteraction,
2083
2208
  eligible: false,
2084
2209
  reason: "already-verified"
2085
2210
  };
@@ -2091,9 +2216,22 @@ function analyzeAutoTask(events, policy, sessionId) {
2091
2216
  hasManualSessionVerification,
2092
2217
  manualVerificationAccepted,
2093
2218
  pendingSubagents: true,
2219
+ pendingUserInteraction,
2094
2220
  eligible: false,
2095
2221
  reason: "pending-subagents"
2096
2222
  };
2223
+ if (pendingUserInteraction) return {
2224
+ taskStartSeq,
2225
+ toolCalls,
2226
+ completedToolResults,
2227
+ consequentialToolCalls,
2228
+ hasManualSessionVerification,
2229
+ manualVerificationAccepted,
2230
+ pendingSubagents,
2231
+ pendingUserInteraction: true,
2232
+ eligible: false,
2233
+ reason: "user-interaction-paused"
2234
+ };
2097
2235
  if (consequentialToolCalls === 0) return {
2098
2236
  taskStartSeq,
2099
2237
  toolCalls,
@@ -2102,6 +2240,7 @@ function analyzeAutoTask(events, policy, sessionId) {
2102
2240
  hasManualSessionVerification,
2103
2241
  manualVerificationAccepted,
2104
2242
  pendingSubagents,
2243
+ pendingUserInteraction,
2105
2244
  eligible: false,
2106
2245
  reason: "no-consequential-work"
2107
2246
  };
@@ -2113,6 +2252,7 @@ function analyzeAutoTask(events, policy, sessionId) {
2113
2252
  hasManualSessionVerification,
2114
2253
  manualVerificationAccepted,
2115
2254
  pendingSubagents,
2255
+ pendingUserInteraction,
2116
2256
  eligible: false,
2117
2257
  reason: "no-completed-evidence"
2118
2258
  };
@@ -2124,6 +2264,7 @@ function analyzeAutoTask(events, policy, sessionId) {
2124
2264
  hasManualSessionVerification,
2125
2265
  manualVerificationAccepted,
2126
2266
  pendingSubagents,
2267
+ pendingUserInteraction,
2127
2268
  eligible: false,
2128
2269
  reason: "insufficient-tool-evidence"
2129
2270
  };
@@ -2135,6 +2276,7 @@ function analyzeAutoTask(events, policy, sessionId) {
2135
2276
  hasManualSessionVerification,
2136
2277
  manualVerificationAccepted,
2137
2278
  pendingSubagents,
2279
+ pendingUserInteraction,
2138
2280
  eligible: true,
2139
2281
  reason: policy.mode + "-eligible"
2140
2282
  };
@@ -2302,6 +2444,6 @@ function selectRouteFeedbackDetail(candidates, result, maxChars = MAX_ROUTE_FEED
2302
2444
  ].join("\n"));
2303
2445
  }
2304
2446
  //#endregion
2305
- export { semanticRouteHint as A, itemBudget as C, routedRepeats as D, parseSemanticRoute as E, sessionEvents as F, ScoreCache as I, SingleFlight as L, verificationVerdict as M, extractSession as N, semanticDecision as O, sanitizeVerifierText as P, resolveCacheFile as R, inspectRecoverySignal as S, nextDiagnosticCycleId as T, buildEvidenceIndex as _, compareRouteFeedbackDetail as a, estimateRoutedCalls as b, isSubagentSession as c, topScoreIndices as d, AutoVerifierRouter as f, boundDecision as g, analyzeStructuredRoute as h, automaticFeedback as i, verificationFailed as j, semanticReferencesVisible as k, selectRouteFeedbackDetail as l, RECOVERY_FAILURE_CONTEXT_CHARS as m, PROPOSAL_FEEDBACK_NOTE as n, failedAcceptanceCriteria as o, MAX_ROUTED_CHECKPOINTS as p, analyzeAutoTask as r, hasPendingSubagents as s, MAX_ROUTE_FEEDBACK_CHARS as t, sessionAccepted as u, buildSemanticRoutePrompt as v, latestDirectUserSeq as w, inspectDeliveryPhase as x, buildSemanticRouteView as y, stableHash as z };
2447
+ export { semanticDecision as A, resolveCacheFile as B, inspectDeliveryPhase as C, nextDiagnosticCycleId as D, latestDirectUserSeq as E, extractSession as F, sanitizeVerifierText as I, sessionEvents as L, semanticRouteHint as M, verificationFailed as N, parseSemanticRoute as O, verificationVerdict as P, ScoreCache as R, estimateRoutedCalls as S, itemBudget as T, stableHash as V, analyzeStructuredRoute as _, compareRouteFeedbackDetail as a, buildSemanticRoutePrompt as b, inspectUserInteractionPause as c, selectRouteFeedbackDetail as d, sessionAccepted as f, RECOVERY_FAILURE_CONTEXT_CHARS as g, MAX_ROUTED_CHECKPOINTS as h, automaticFeedback as i, semanticReferencesVisible as j, routedRepeats as k, isAwaitingUserText as l, AutoVerifierRouter as m, PROPOSAL_FEEDBACK_NOTE as n, failedAcceptanceCriteria as o, topScoreIndices as p, analyzeAutoTask as r, hasPendingSubagents as s, MAX_ROUTE_FEEDBACK_CHARS as t, isSubagentSession as u, boundDecision as v, inspectRecoverySignal as w, buildSemanticRouteView as x, buildEvidenceIndex as y, SingleFlight as z };
2306
2448
 
2307
- //# sourceMappingURL=auto-DmyrNZXK.js.map
2449
+ //# sourceMappingURL=auto-C9YG0E22.js.map