dsh-llm-verifier 0.6.7 → 0.6.8

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.
@@ -648,7 +648,7 @@ const VERIFIER_EVIDENCE_TOOLS = /* @__PURE__ */ new Set([
648
648
  "verifier_current_session"
649
649
  ]);
650
650
  /** Tools that return either a child's report (evidence) or a bare start acknowledgement (not evidence). */
651
- const SUBAGENT_TOOLS = /* @__PURE__ */ new Set(["subagent", "subagent_fork"]);
651
+ const SUBAGENT_TOOLS$1 = /* @__PURE__ */ new Set(["subagent", "subagent_fork"]);
652
652
  /**
653
653
  * Start acknowledgement of a background child.
654
654
  *
@@ -672,7 +672,7 @@ function isEvidenceOutput(name, text) {
672
672
  if (BOOKKEEPING_TOOLS.has(name) || VERIFIER_EVIDENCE_TOOLS.has(name)) return false;
673
673
  const body = text.trim();
674
674
  if (!body) return false;
675
- return !(SUBAGENT_TOOLS.has(name) && CHILD_START_ACKNOWLEDGEMENT.test(body));
675
+ return !(SUBAGENT_TOOLS$1.has(name) && CHILD_START_ACKNOWLEDGEMENT.test(body));
676
676
  }
677
677
  /** Signatures of an output that reports a PASSED verification result. */
678
678
  const VERIFICATION_PASS_SIGNATURES = [
@@ -1883,6 +1883,116 @@ function isSuccessfulCodeDispatch(data) {
1883
1883
  if (Array.isArray(data.content) && data.content.some((b) => b.isError === true)) return false;
1884
1884
  return true;
1885
1885
  }
1886
+ const SUBAGENT_TOOLS = /* @__PURE__ */ new Set(["subagent", "subagent_fork"]);
1887
+ const CONTINUABLE_SUBAGENT_START = /^\s*started subagent\s+([^\s`]+)/imu;
1888
+ const BACKGROUND_SUBAGENT_JOB_START = /^\s*started background subagent job\s+([^\s`]+)/imu;
1889
+ const GENERAL_SUBAGENT_START = /^\s*started (?:background )?subagent\b/imu;
1890
+ /**
1891
+ * Whether background subagents started during the current task remain in flight.
1892
+ *
1893
+ * A background subagent returns immediately with a start receipt (`started subagent <id>`
1894
+ * or `started background subagent job <id>`) and settles later via a runtime-injected notice
1895
+ * (`source.kind === 'subagent-settled'` or a job settlement notice). Performing session
1896
+ * acceptance while subagents are in flight will always fail and steer prematurely because the
1897
+ * delegated work has not reported back yet.
1898
+ * @param events - session events.
1899
+ * @param taskStartSeq - sequence number of the current direct user task statement.
1900
+ * @returns True when at least one background subagent remains unsettled.
1901
+ */
1902
+ function hasPendingSubagents(events, taskStartSeq) {
1903
+ const relevant = events.filter((event) => event.seq >= taskStartSeq);
1904
+ const pendingContinuable = /* @__PURE__ */ new Map();
1905
+ const pendingJobs = /* @__PURE__ */ new Map();
1906
+ let anonymousPendingCount = 0;
1907
+ const calls = /* @__PURE__ */ new Map();
1908
+ for (const event of relevant) if (event.type === "tool/call") calls.set(String(event.data.callId), event);
1909
+ for (const event of relevant) {
1910
+ if (event.type === "tool/result") {
1911
+ const call = calls.get(String(event.data.message.source.callId));
1912
+ if (call && SUBAGENT_TOOLS.has(call.data.name) && event.data.error === void 0) {
1913
+ if (event.data.message.content.every((b) => b.isError !== true)) {
1914
+ const text = blockText(event.data.message.content);
1915
+ const contMatch = text.match(CONTINUABLE_SUBAGENT_START);
1916
+ const jobMatch = text.match(BACKGROUND_SUBAGENT_JOB_START);
1917
+ if (contMatch) pendingContinuable.set(contMatch[1], event.seq);
1918
+ else if (jobMatch) pendingJobs.set(jobMatch[1], event.seq);
1919
+ else if (GENERAL_SUBAGENT_START.test(text)) anonymousPendingCount += 1;
1920
+ }
1921
+ }
1922
+ } else if (CODE_DISPATCH_TYPES.has(event.type)) {
1923
+ const data = event.data;
1924
+ if (data && SUBAGENT_TOOLS.has(data.name) && isSuccessfulCodeDispatch(data)) {
1925
+ const text = blockText(data.content);
1926
+ const contMatch = text.match(CONTINUABLE_SUBAGENT_START);
1927
+ const jobMatch = text.match(BACKGROUND_SUBAGENT_JOB_START);
1928
+ if (contMatch) pendingContinuable.set(contMatch[1], event.seq);
1929
+ else if (jobMatch) pendingJobs.set(jobMatch[1], event.seq);
1930
+ else if (GENERAL_SUBAGENT_START.test(text)) anonymousPendingCount += 1;
1931
+ }
1932
+ }
1933
+ if (event.type === "user/message") {
1934
+ const source = event.data?.source;
1935
+ const text = blockText(event.data?.content);
1936
+ if (source?.kind === "subagent-settled") {
1937
+ const senderId = typeof source.senderSessionId === "string" ? source.senderSessionId : void 0;
1938
+ if (senderId && pendingContinuable.has(senderId)) pendingContinuable.delete(senderId);
1939
+ else {
1940
+ let found = false;
1941
+ for (const [id] of pendingContinuable) if (text.includes(id)) {
1942
+ pendingContinuable.delete(id);
1943
+ found = true;
1944
+ break;
1945
+ }
1946
+ if (!found) {
1947
+ if (pendingContinuable.size > 0) {
1948
+ const oldest = pendingContinuable.keys().next().value;
1949
+ if (oldest !== void 0) pendingContinuable.delete(oldest);
1950
+ } else if (anonymousPendingCount > 0) anonymousPendingCount -= 1;
1951
+ }
1952
+ }
1953
+ } else if (source?.plugin === "tool-jobs" || /background job\b.*finished/iu.test(text)) {
1954
+ for (const [jobId] of pendingJobs) if (text.includes(jobId)) {
1955
+ pendingJobs.delete(jobId);
1956
+ break;
1957
+ }
1958
+ }
1959
+ }
1960
+ if (event.type === "tool/call") {
1961
+ const name = event.data.name;
1962
+ const argsText = event.data.arguments;
1963
+ let parsedArgs = {};
1964
+ if (typeof argsText === "string") try {
1965
+ parsedArgs = JSON.parse(argsText);
1966
+ } catch {}
1967
+ else if (typeof argsText === "object" && argsText !== null) parsedArgs = argsText;
1968
+ if (name === "interrupt_agent") {
1969
+ const target = String(parsedArgs.target ?? parsedArgs.agent_id ?? "");
1970
+ if (target && pendingContinuable.has(target)) pendingContinuable.delete(target);
1971
+ } else if (name === "job_kill") {
1972
+ const jobId = String(parsedArgs.job_id ?? "");
1973
+ if (jobId && pendingJobs.has(jobId)) pendingJobs.delete(jobId);
1974
+ }
1975
+ } else if (CODE_DISPATCH_TYPES.has(event.type)) {
1976
+ const data = event.data;
1977
+ if (data) {
1978
+ const name = data.name;
1979
+ let parsedArgs = {};
1980
+ if (typeof data.arguments === "string") try {
1981
+ parsedArgs = JSON.parse(data.arguments);
1982
+ } catch {}
1983
+ else if (typeof data.arguments === "object" && data.arguments !== null) parsedArgs = data.arguments;
1984
+ if (name === "interrupt_agent") {
1985
+ const target = String(parsedArgs.target ?? parsedArgs.agent_id ?? "");
1986
+ if (target && pendingContinuable.has(target)) pendingContinuable.delete(target);
1987
+ } else if (name === "job_kill") {
1988
+ const jobId = String(parsedArgs.job_id ?? "");
1989
+ if (jobId && pendingJobs.has(jobId)) pendingJobs.delete(jobId);
1990
+ }
1991
+ }
1992
+ }
1993
+ }
1994
+ return pendingContinuable.size > 0 || pendingJobs.size > 0 || anonymousPendingCount > 0;
1995
+ }
1886
1996
  function analyzeAutoTask(events, policy, sessionId) {
1887
1997
  const taskStartSeq = latestDirectUserSeq(events);
1888
1998
  if (taskStartSeq === void 0) return {
@@ -1892,6 +2002,7 @@ function analyzeAutoTask(events, policy, sessionId) {
1892
2002
  consequentialToolCalls: 0,
1893
2003
  hasManualSessionVerification: false,
1894
2004
  manualVerificationAccepted: false,
2005
+ pendingSubagents: false,
1895
2006
  eligible: false,
1896
2007
  reason: "no-direct-user-task"
1897
2008
  };
@@ -1949,6 +2060,7 @@ function analyzeAutoTask(events, policy, sessionId) {
1949
2060
  criteria: verdict.criteria
1950
2061
  }, policy.threshold) && !stale(verdict.toSeq);
1951
2062
  });
2063
+ const pendingSubagents = hasPendingSubagents(events, taskStartSeq);
1952
2064
  if (policy.mode === "manual") return {
1953
2065
  taskStartSeq,
1954
2066
  toolCalls,
@@ -1956,6 +2068,7 @@ function analyzeAutoTask(events, policy, sessionId) {
1956
2068
  consequentialToolCalls,
1957
2069
  hasManualSessionVerification,
1958
2070
  manualVerificationAccepted,
2071
+ pendingSubagents,
1959
2072
  eligible: false,
1960
2073
  reason: "manual-mode"
1961
2074
  };
@@ -1966,9 +2079,21 @@ function analyzeAutoTask(events, policy, sessionId) {
1966
2079
  consequentialToolCalls,
1967
2080
  hasManualSessionVerification,
1968
2081
  manualVerificationAccepted,
2082
+ pendingSubagents,
1969
2083
  eligible: false,
1970
2084
  reason: "already-verified"
1971
2085
  };
2086
+ if (pendingSubagents) return {
2087
+ taskStartSeq,
2088
+ toolCalls,
2089
+ completedToolResults,
2090
+ consequentialToolCalls,
2091
+ hasManualSessionVerification,
2092
+ manualVerificationAccepted,
2093
+ pendingSubagents: true,
2094
+ eligible: false,
2095
+ reason: "pending-subagents"
2096
+ };
1972
2097
  if (consequentialToolCalls === 0) return {
1973
2098
  taskStartSeq,
1974
2099
  toolCalls,
@@ -1976,6 +2101,7 @@ function analyzeAutoTask(events, policy, sessionId) {
1976
2101
  consequentialToolCalls,
1977
2102
  hasManualSessionVerification,
1978
2103
  manualVerificationAccepted,
2104
+ pendingSubagents,
1979
2105
  eligible: false,
1980
2106
  reason: "no-consequential-work"
1981
2107
  };
@@ -1986,6 +2112,7 @@ function analyzeAutoTask(events, policy, sessionId) {
1986
2112
  consequentialToolCalls,
1987
2113
  hasManualSessionVerification,
1988
2114
  manualVerificationAccepted,
2115
+ pendingSubagents,
1989
2116
  eligible: false,
1990
2117
  reason: "no-completed-evidence"
1991
2118
  };
@@ -1996,6 +2123,7 @@ function analyzeAutoTask(events, policy, sessionId) {
1996
2123
  consequentialToolCalls,
1997
2124
  hasManualSessionVerification,
1998
2125
  manualVerificationAccepted,
2126
+ pendingSubagents,
1999
2127
  eligible: false,
2000
2128
  reason: "insufficient-tool-evidence"
2001
2129
  };
@@ -2006,6 +2134,7 @@ function analyzeAutoTask(events, policy, sessionId) {
2006
2134
  consequentialToolCalls,
2007
2135
  hasManualSessionVerification,
2008
2136
  manualVerificationAccepted,
2137
+ pendingSubagents,
2009
2138
  eligible: true,
2010
2139
  reason: policy.mode + "-eligible"
2011
2140
  };
@@ -2173,6 +2302,6 @@ function selectRouteFeedbackDetail(candidates, result, maxChars = MAX_ROUTE_FEED
2173
2302
  ].join("\n"));
2174
2303
  }
2175
2304
  //#endregion
2176
- export { verificationFailed as A, latestDirectUserSeq as C, semanticDecision as D, routedRepeats as E, ScoreCache as F, SingleFlight as I, resolveCacheFile as L, extractSession as M, sanitizeVerifierText as N, semanticReferencesVisible as O, sessionEvents as P, stableHash as R, itemBudget as S, parseSemanticRoute as T, buildSemanticRoutePrompt as _, compareRouteFeedbackDetail as a, inspectDeliveryPhase as b, selectRouteFeedbackDetail as c, AutoVerifierRouter as d, MAX_ROUTED_CHECKPOINTS as f, buildEvidenceIndex as g, boundDecision as h, automaticFeedback as i, verificationVerdict as j, semanticRouteHint as k, sessionAccepted as l, analyzeStructuredRoute as m, PROPOSAL_FEEDBACK_NOTE as n, failedAcceptanceCriteria as o, RECOVERY_FAILURE_CONTEXT_CHARS as p, analyzeAutoTask as r, isSubagentSession as s, MAX_ROUTE_FEEDBACK_CHARS as t, topScoreIndices as u, buildSemanticRouteView as v, nextDiagnosticCycleId as w, inspectRecoverySignal as x, estimateRoutedCalls as y };
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 };
2177
2306
 
2178
- //# sourceMappingURL=auto-DkUMv8FV.js.map
2307
+ //# sourceMappingURL=auto-DmyrNZXK.js.map