@narumitw/pi-plan-mode 0.55.0 → 0.55.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.ts CHANGED
@@ -19,7 +19,6 @@ import {
19
19
  configuredThinkingLevel,
20
20
  createImplementationRetentionCoordinator,
21
21
  exportStoredPlan,
22
- filterAvailableSelectedToolNames,
23
22
  findBlockedCommandSegment,
24
23
  findBlockedPowerShellCommandSegment,
25
24
  implementationRetentionPreview,
@@ -40,9 +39,8 @@ import {
40
39
  renderPlanModeCompletion,
41
40
  snapshotPlanModeSelectedNames,
42
41
  toolPolicyLabel,
43
- unique,
44
42
  updatePlanModeSettings
45
- } from "./chunks/chunk-KSGLZ4S2.js";
43
+ } from "./chunks/chunk-AS76FCC5.js";
46
44
 
47
45
  // src/plan-mode.ts
48
46
  import { randomUUID as randomUUID2 } from "node:crypto";
@@ -664,18 +662,6 @@ function assertPlanModeHelperToolsAvailable(toolNames) {
664
662
  "plan_mode_question and plan_mode_complete are unavailable; include them in the active tool allowlist or leave the restrictive tool mode before starting Plan mode"
665
663
  );
666
664
  }
667
- function withRequiredPlanModeTools(toolNames) {
668
- return unique([
669
- ...withoutRequiredPlanModeTools(toolNames),
670
- PLAN_MODE_QUESTION_TOOL_NAME,
671
- PLAN_MODE_COMPLETE_TOOL_NAME
672
- ]);
673
- }
674
- function withoutRequiredPlanModeTools(toolNames) {
675
- return toolNames.filter(
676
- (toolName) => toolName !== PLAN_MODE_QUESTION_TOOL_NAME && toolName !== PLAN_MODE_COMPLETE_TOOL_NAME
677
- );
678
- }
679
665
 
680
666
  // src/saved-plan-preflight.ts
681
667
  function savedPlanBlocksNewWorkflow(ctx, hasSavedPlan) {
@@ -740,11 +726,30 @@ function restorePlanModeState(entries, stateEntryType) {
740
726
  activeImplementation,
741
727
  selectedToolNames: stringArray(entry.data.selectedToolNames),
742
728
  selectedToolKeys: stringArray(entry.data.selectedToolKeys),
729
+ workflowToolPolicy: enabled ? normalizeWorkflowToolPolicy(entry.data.workflowToolPolicy) : void 0,
743
730
  previousThinkingLevel: enabled ? fixedThinkingLevel(entry.data.previousThinkingLevel) : void 0,
744
731
  appliedThinkingLevel: enabled ? fixedThinkingLevel(entry.data.appliedThinkingLevel) : void 0,
745
732
  manualThinkingLevel: enabled ? fixedThinkingLevel(entry.data.manualThinkingLevel) : void 0
746
733
  };
747
734
  }
735
+ function normalizeWorkflowToolPolicy(value) {
736
+ if (value === void 0) return void 0;
737
+ const denied = {
738
+ kind: "automatic",
739
+ allowedNames: [],
740
+ resolved: true
741
+ };
742
+ if (!isRecord(value)) return denied;
743
+ const kind = value.kind === "automatic" || value.kind === "explicit" ? value.kind : void 0;
744
+ const allowedNames = stringArray(value.allowedNames);
745
+ if (!kind || !allowedNames || typeof value.resolved !== "boolean") return denied;
746
+ if (kind === "automatic") {
747
+ return { kind, allowedNames, resolved: value.resolved };
748
+ }
749
+ const desiredNames = stringArray(value.desiredNames);
750
+ if (!desiredNames) return denied;
751
+ return { kind, desiredNames, allowedNames, resolved: value.resolved };
752
+ }
748
753
  function normalizeSavedPlan(value) {
749
754
  if (!isRecord(value)) return void 0;
750
755
  const source = planCompletionSource(value.source);
@@ -869,7 +874,7 @@ function planMode(pi, dependencies = {}) {
869
874
  const loadInteractiveUi = () => {
870
875
  if (dependencies.loadInteractiveUi) return dependencies.loadInteractiveUi();
871
876
  if (!interactiveUiPromise) {
872
- interactiveUiPromise = import("./chunks/interactive-ui-PSDKEVVG.js").catch((error) => {
877
+ interactiveUiPromise = import("./chunks/interactive-ui-UCL5UIJN.js").catch((error) => {
873
878
  interactiveUiPromise = void 0;
874
879
  throw error;
875
880
  });
@@ -882,8 +887,8 @@ function planMode(pi, dependencies = {}) {
882
887
  let toggleShortcut;
883
888
  const clearPlanModeShortcutHandler = () => {
884
889
  };
885
- let activeToolBaseline = [];
886
890
  let workflowAllowedToolNames;
891
+ let pendingWorkflowToolPolicy;
887
892
  let publishedContractMode;
888
893
  let modeContractsRelevant = false;
889
894
  let readyPresentationIntent;
@@ -1156,13 +1161,13 @@ function planMode(pi, dependencies = {}) {
1156
1161
  currentSessionContext = ctx;
1157
1162
  workflowOwner = void 0;
1158
1163
  workflowMutex.bindSession(ctx.sessionManager);
1159
- captureToolBaseline();
1160
1164
  refreshStateBeforeFirstAgentStart = event.reason === "new";
1161
1165
  menuController.abort(new DOMException("Plan-mode session replaced", "AbortError"));
1162
1166
  menuController = new AbortController();
1163
1167
  readyPresentationIntent = void 0;
1164
1168
  latestCommandContext = void 0;
1165
1169
  workflowAllowedToolNames = void 0;
1170
+ pendingWorkflowToolPolicy = void 0;
1166
1171
  implementationRetention.reset();
1167
1172
  settings = { thinkingLevel: "inherit" };
1168
1173
  const branch = ctx.sessionManager.getBranch();
@@ -1225,6 +1230,8 @@ function planMode(pi, dependencies = {}) {
1225
1230
  readyPresentationIntent = void 0;
1226
1231
  latestCommandContext = void 0;
1227
1232
  refreshStateBeforeFirstAgentStart = false;
1233
+ workflowAllowedToolNames = void 0;
1234
+ pendingWorkflowToolPolicy = void 0;
1228
1235
  implementationRetention.reset();
1229
1236
  await awaitPlanModeSettingsWrites(dependencies.settingsPath);
1230
1237
  if (currentSession !== void 0 && currentSession !== shutdownSession) {
@@ -1309,6 +1316,7 @@ Blocked command: ${blocked}`
1309
1316
  }
1310
1317
  });
1311
1318
  pi.on("context", async (event, ctx) => {
1319
+ resolvePendingWorkflowToolPolicy(ctx);
1312
1320
  const result = implementationRetention.transformContext(event.messages, state);
1313
1321
  if (result.clearActiveImplementationId) {
1314
1322
  clearActiveImplementation(result.clearActiveImplementationId, ctx);
@@ -1428,7 +1436,7 @@ ${intent.plan}`,
1428
1436
  selectedToolNames: candidate.selectedToolNames,
1429
1437
  selectedToolKeys: candidate.selectedToolKeys
1430
1438
  };
1431
- workflowAllowedToolNames = computePlanModePolicyToolNames();
1439
+ beginWorkflowToolPolicy();
1432
1440
  applyPlanThinkingLevel();
1433
1441
  persistState();
1434
1442
  updateUi(ctx);
@@ -1467,6 +1475,7 @@ ${intent.plan}`,
1467
1475
  awaitingAction: false,
1468
1476
  savedPlan: void 0,
1469
1477
  activeImplementation: void 0,
1478
+ workflowToolPolicy: void 0,
1470
1479
  manualThinkingLevel: void 0
1471
1480
  };
1472
1481
  if (wasEnabled) {
@@ -1585,6 +1594,7 @@ ${intent.plan}`,
1585
1594
  awaitingAction: false,
1586
1595
  savedPlan: { plan, source },
1587
1596
  activeImplementation: void 0,
1597
+ workflowToolPolicy: void 0,
1588
1598
  manualThinkingLevel: void 0
1589
1599
  };
1590
1600
  restoreThinkingLevel();
@@ -1643,6 +1653,7 @@ ${intent.plan}`,
1643
1653
  startedAt: Date.now(),
1644
1654
  retention
1645
1655
  },
1656
+ workflowToolPolicy: void 0,
1646
1657
  manualThinkingLevel: void 0
1647
1658
  };
1648
1659
  if (wasEnabled) {
@@ -1657,8 +1668,8 @@ ${intent.plan}`,
1657
1668
  state = previousState;
1658
1669
  readyPresentationIntent = previousIntent;
1659
1670
  if (wasEnabled) {
1671
+ restoreWorkflowToolPolicy(state.workflowToolPolicy);
1660
1672
  publishModeContract("plan", ctx);
1661
- workflowAllowedToolNames = computePlanModePolicyToolNames();
1662
1673
  applyPlanThinkingLevel();
1663
1674
  }
1664
1675
  persistState();
@@ -1690,29 +1701,57 @@ ${intent.plan}`,
1690
1701
  const ui = await loadInteractiveUi();
1691
1702
  if (!lifecycle.isCurrent() || lifecycle.signal.aborted) return;
1692
1703
  const tools = selectableTools();
1704
+ const activeToolNames = new Set(safeGetActiveTools());
1705
+ const initialSelectedNames = snapshotPlanModeSelectedNames(tools, toolSelectionSnapshot());
1706
+ const retainsInactiveSelection = state.selectedToolNames !== void 0 || state.selectedToolKeys !== void 0 || settings.defaultPlanTools !== void 0;
1707
+ const retainedInactiveNames = retainsInactiveSelection ? initialSelectedNames : /* @__PURE__ */ new Set();
1708
+ const registeredNames = new Set(tools.map((tool) => tool.name));
1709
+ const pendingNames = Array.from(retainedInactiveNames).filter(
1710
+ (name) => !registeredNames.has(name)
1711
+ );
1693
1712
  await ui.showPlanLaunchMenu(ctx, {
1694
1713
  statusText: planModeHelperToolsAvailable(safeGetActiveTools()) ? "Status: Off \u2014 visible Plan helpers stay inactive until /plan starts." : "Status: Off \u2014 required Plan helpers are unavailable under the active tool policy.",
1695
1714
  initialScreen,
1696
1715
  getSelectedNames: () => snapshotPlanModeSelectedNames(tools, toolSelectionSnapshot()),
1697
1716
  toolSummary: (selectedNames) => {
1698
1717
  const allowed = tools.filter(
1699
- (tool) => toolIsActive(tool.name) && selectedNames.has(tool.name) && canSelectToolInPlanMode(tool)
1718
+ (tool) => activeToolNames.has(tool.name) && selectedNames.has(tool.name) && canSelectToolInPlanMode(tool)
1700
1719
  ).map((tool) => tool.name);
1701
- return `Plan policy will allow: ${allowed.length > 0 ? allowed.join(", ") : "none"}.`;
1720
+ const pending = pendingNames.filter((name) => selectedNames.has(name)).map(terminalToolName);
1721
+ const visiblePending = pending.slice(0, 3);
1722
+ const pendingSuffix = pending.length > visiblePending.length ? `, +${pending.length - visiblePending.length} more` : "";
1723
+ return [
1724
+ `Plan policy will allow: ${allowed.length > 0 ? allowed.join(", ") : "none"}.`,
1725
+ ...pending.length > 0 ? [`Pending registration: ${visiblePending.join(", ")}${pendingSuffix}.`] : []
1726
+ ].join(" ");
1702
1727
  },
1703
- tools: tools.map((tool) => {
1704
- const selectable = canSelectToolInPlanMode(tool);
1705
- const active = toolIsActive(tool.name);
1706
- const policy = active ? toolPolicyLabel(tool) : "not active in this Pi session";
1707
- const description = tool.description ?? "No description available";
1708
- return {
1709
- name: tool.name,
1710
- description: `${policy} \xB7 ${description}`,
1711
- searchText: [policy, description].join(" "),
1712
- disabled: !selectable || !active,
1713
- disabledReason: !active ? "Not active in Pi; Plan mode will not activate it" : selectable ? void 0 : "Blocked by Plan-mode policy"
1714
- };
1715
- }),
1728
+ tools: [
1729
+ ...tools.map((tool) => {
1730
+ const selectable = canSelectToolInPlanMode(tool);
1731
+ const active = activeToolNames.has(tool.name);
1732
+ const retained = retainedInactiveNames.has(tool.name);
1733
+ const policy = active ? toolPolicyLabel(tool) : retained ? "not active yet; retained for first-request resolution" : "not active in this Pi session";
1734
+ const description = tool.description ?? "No description available";
1735
+ return {
1736
+ name: tool.name,
1737
+ description: `${policy} \xB7 ${description}`,
1738
+ searchText: [policy, description].join(" "),
1739
+ disabled: !selectable || !active,
1740
+ disabledReason: !active ? retained ? "Not active yet; retained and resolved before the first request" : "Not active in Pi; Plan mode will not activate it" : selectable ? void 0 : "Blocked by Plan-mode policy"
1741
+ };
1742
+ }),
1743
+ ...pendingNames.map((name) => {
1744
+ const label = terminalToolName(name);
1745
+ return {
1746
+ name,
1747
+ label,
1748
+ description: "pending registration \xB7 Retained and resolved before the first Plan request",
1749
+ searchText: `${label} pending registration retained first Plan request`,
1750
+ disabled: true,
1751
+ disabledReason: "Not registered yet; Plan mode will not activate it and will resolve it before the first request"
1752
+ };
1753
+ })
1754
+ ],
1716
1755
  ...lifecycle,
1717
1756
  start: (signal) => {
1718
1757
  if (signal.aborted || !lifecycle.isCurrent()) return;
@@ -1725,7 +1764,11 @@ ${intent.plan}`,
1725
1764
  },
1726
1765
  startWithTools: (names, signal) => {
1727
1766
  if (signal.aborted || !lifecycle.isCurrent()) return;
1728
- const selectedToolNames = filterAvailableSelectedToolNames(names, activePlanPolicyTools());
1767
+ const selectedToolNames = Array.from(
1768
+ new Set(
1769
+ names.filter((name) => activeToolNames.has(name) || retainedInactiveNames.has(name))
1770
+ )
1771
+ );
1729
1772
  if (enterPlanMode(ctx, { selectedToolNames, selectedToolKeys: void 0 })) {
1730
1773
  ctx.ui.notify("Plan mode enabled with the selected tools.", "info");
1731
1774
  }
@@ -1769,7 +1812,7 @@ ${intent.plan}`,
1769
1812
  if (!isCurrent() || signal.aborted) return false;
1770
1813
  const result = await ui.showPlanModeSettings(ctx, {
1771
1814
  tools: selectableTools(),
1772
- activeToolNames: activeToolBaseline,
1815
+ activeToolNames: safeGetActiveTools(),
1773
1816
  signal,
1774
1817
  isCurrent,
1775
1818
  settingsPath: dependencies.settingsPath,
@@ -1792,6 +1835,7 @@ ${intent.plan}`,
1792
1835
  }
1793
1836
  function advanceWorkflowGeneration() {
1794
1837
  workflowGeneration += 1;
1838
+ pendingWorkflowToolPolicy = void 0;
1795
1839
  finalizationRequest.reset();
1796
1840
  }
1797
1841
  function finalizationRunOutcome(messages) {
@@ -1810,16 +1854,108 @@ ${intent.plan}`,
1810
1854
  isCurrent: () => sessionGeneration === menuGeneration && planWorkflowGeneration === workflowGeneration && !controller.signal.aborted && (!state.enabled || workflowMutex.isOwner(owner))
1811
1855
  };
1812
1856
  }
1813
- function captureToolBaseline() {
1814
- activeToolBaseline = withRequiredPlanModeTools(safeGetActiveTools());
1815
- }
1816
1857
  function planModePolicyToolNames() {
1817
- return workflowAllowedToolNames ?? computePlanModePolicyToolNames();
1858
+ if (state.enabled) return workflowAllowedToolNames ?? [];
1859
+ return computePlanModePolicyToolNames();
1860
+ }
1861
+ function beginWorkflowToolPolicy() {
1862
+ const kind = toolPolicySelectionIsExplicit() ? "explicit" : "automatic";
1863
+ const desiredNames = desiredPlanModeToolNames();
1864
+ const allowedNames = resolvePlanModePolicyToolNames(desiredNames);
1865
+ const policy = {
1866
+ kind,
1867
+ ...kind === "explicit" ? { desiredNames } : {},
1868
+ allowedNames,
1869
+ resolved: false
1870
+ };
1871
+ state = { ...state, workflowToolPolicy: policy };
1872
+ pendingWorkflowToolPolicy = { generation: workflowGeneration, mode: "resolve" };
1873
+ workflowAllowedToolNames = allowedNames;
1874
+ }
1875
+ function resolvePendingWorkflowToolPolicy(ctx) {
1876
+ const pending = pendingWorkflowToolPolicy;
1877
+ if (!pending) return;
1878
+ if (pending.generation !== workflowGeneration || !state.enabled || !workflowMutex.isOwner(workflowOwner)) {
1879
+ pendingWorkflowToolPolicy = void 0;
1880
+ return;
1881
+ }
1882
+ const policy = state.workflowToolPolicy;
1883
+ const expectedResolved = pending.mode === "revalidate";
1884
+ if (!policy || policy.resolved !== expectedResolved) {
1885
+ pendingWorkflowToolPolicy = void 0;
1886
+ return;
1887
+ }
1888
+ const allowedNames = pending.mode === "resolve" ? resolveWorkflowToolPolicy(policy) : revalidateFrozenWorkflowToolPolicy(policy);
1889
+ const policyChanged = !policy.resolved || !arrayEquals(policy.allowedNames, allowedNames);
1890
+ workflowAllowedToolNames = allowedNames;
1891
+ state = {
1892
+ ...state,
1893
+ workflowToolPolicy: { ...policy, allowedNames, resolved: true }
1894
+ };
1895
+ pendingWorkflowToolPolicy = void 0;
1896
+ if (policyChanged) persistState();
1897
+ updateUi(ctx);
1818
1898
  }
1819
- function computePlanModePolicyToolNames() {
1899
+ function toolPolicySelectionIsExplicit() {
1900
+ return state.selectedToolNames !== void 0 || state.selectedToolKeys !== void 0 || settings.defaultPlanTools !== void 0;
1901
+ }
1902
+ function desiredPlanModeToolNames() {
1820
1903
  const tools = activePlanPolicyTools();
1821
- const selectedNames = snapshotPlanModeSelectedNames(tools, toolSelectionSnapshot());
1822
- return tools.filter((tool) => selectedNames.has(tool.name) && canSelectToolInPlanMode(tool)).map((tool) => tool.name);
1904
+ return Array.from(snapshotPlanModeSelectedNames(tools, toolSelectionSnapshot()));
1905
+ }
1906
+ function automaticPlanModeToolNames() {
1907
+ return Array.from(snapshotPlanModeSelectedNames(activePlanPolicyTools(), {}));
1908
+ }
1909
+ function resolveWorkflowToolPolicy(policy) {
1910
+ return resolvePlanModePolicyToolNames(
1911
+ policy.kind === "automatic" ? automaticPlanModeToolNames() : policy.desiredNames ?? []
1912
+ );
1913
+ }
1914
+ function revalidateFrozenWorkflowToolPolicy(policy) {
1915
+ const currentlyAllowed = new Set(
1916
+ policy.kind === "automatic" ? resolvePlanModePolicyToolNames(automaticPlanModeToolNames()) : resolvePlanModePolicyToolNames(policy.allowedNames)
1917
+ );
1918
+ return policy.allowedNames.filter((name) => currentlyAllowed.has(name));
1919
+ }
1920
+ function restoreWorkflowToolPolicy(policy) {
1921
+ let nextPolicy;
1922
+ if (!policy) {
1923
+ const kind = toolPolicySelectionIsExplicit() ? "explicit" : "automatic";
1924
+ const desiredNames = desiredPlanModeToolNames();
1925
+ nextPolicy = {
1926
+ kind,
1927
+ ...kind === "explicit" ? { desiredNames } : {},
1928
+ allowedNames: resolvePlanModePolicyToolNames(desiredNames),
1929
+ resolved: true
1930
+ };
1931
+ } else if (policy.resolved) {
1932
+ nextPolicy = policy;
1933
+ } else {
1934
+ nextPolicy = {
1935
+ ...policy,
1936
+ allowedNames: resolveWorkflowToolPolicy(policy)
1937
+ };
1938
+ }
1939
+ state = { ...state, workflowToolPolicy: nextPolicy };
1940
+ workflowAllowedToolNames = nextPolicy.resolved ? revalidateFrozenWorkflowToolPolicy(nextPolicy) : nextPolicy.allowedNames;
1941
+ pendingWorkflowToolPolicy = {
1942
+ generation: workflowGeneration,
1943
+ mode: nextPolicy.resolved ? "revalidate" : "resolve"
1944
+ };
1945
+ return !workflowToolPoliciesEqual(policy, nextPolicy);
1946
+ }
1947
+ function workflowToolPoliciesEqual(left, right) {
1948
+ return left?.kind === right.kind && left.resolved === right.resolved && arrayEquals(left.allowedNames, right.allowedNames) && arrayEquals(left.desiredNames ?? [], right.desiredNames ?? []);
1949
+ }
1950
+ function arrayEquals(left, right) {
1951
+ return left.length === right.length && left.every((value, index) => value === right[index]);
1952
+ }
1953
+ function computePlanModePolicyToolNames() {
1954
+ return resolvePlanModePolicyToolNames(desiredPlanModeToolNames());
1955
+ }
1956
+ function resolvePlanModePolicyToolNames(desiredNames) {
1957
+ const selectedNames = new Set(desiredNames);
1958
+ return activePlanPolicyTools().filter((tool) => selectedNames.has(tool.name) && canSelectToolInPlanMode(tool)).map((tool) => tool.name);
1823
1959
  }
1824
1960
  function toolSelectionSnapshot() {
1825
1961
  return {
@@ -1834,12 +1970,9 @@ ${intent.plan}`,
1834
1970
  ).sort(compareTools);
1835
1971
  }
1836
1972
  function activePlanPolicyTools() {
1837
- const activeNames = new Set(activeToolBaseline);
1973
+ const activeNames = new Set(safeGetActiveTools());
1838
1974
  return selectableTools().filter((tool) => activeNames.has(tool.name));
1839
1975
  }
1840
- function toolIsActive(toolName) {
1841
- return activeToolBaseline.includes(toolName);
1842
- }
1843
1976
  function safeGetAllTools() {
1844
1977
  try {
1845
1978
  return pi.getAllTools();
@@ -1897,6 +2030,7 @@ ${intent.plan}`,
1897
2030
  function installRestoredState(candidate, ctx) {
1898
2031
  const previousState = state;
1899
2032
  const previousWorkflowAllowedToolNames = workflowAllowedToolNames;
2033
+ const previousPendingWorkflowToolPolicy = pendingWorkflowToolPolicy;
1900
2034
  const previousOwner = workflowOwner;
1901
2035
  const wasEnabled = state.enabled;
1902
2036
  if (candidate.enabled && !workflowMutex.isOwner(workflowOwner)) {
@@ -1904,6 +2038,7 @@ ${intent.plan}`,
1904
2038
  if (!owner) {
1905
2039
  state = { enabled: false, awaitingAction: false };
1906
2040
  workflowAllowedToolNames = void 0;
2041
+ pendingWorkflowToolPolicy = void 0;
1907
2042
  reportRestoredWorkflowBusy(ctx);
1908
2043
  return false;
1909
2044
  }
@@ -1916,6 +2051,7 @@ ${intent.plan}`,
1916
2051
  } catch {
1917
2052
  state = { enabled: false, awaitingAction: false };
1918
2053
  workflowAllowedToolNames = void 0;
2054
+ pendingWorkflowToolPolicy = void 0;
1919
2055
  if (workflowOwner !== previousOwner) {
1920
2056
  workflowMutex.release(workflowOwner);
1921
2057
  workflowOwner = previousOwner;
@@ -1929,7 +2065,12 @@ ${intent.plan}`,
1929
2065
  restoreThinkingLevel();
1930
2066
  }
1931
2067
  state = candidate;
1932
- workflowAllowedToolNames = state.enabled ? computePlanModePolicyToolNames() : void 0;
2068
+ const policyChanged = state.enabled ? restoreWorkflowToolPolicy(state.workflowToolPolicy) : false;
2069
+ if (!state.enabled) {
2070
+ workflowAllowedToolNames = void 0;
2071
+ pendingWorkflowToolPolicy = void 0;
2072
+ }
2073
+ if (policyChanged) persistState();
1933
2074
  if (state.enabled) applyPlanThinkingLevel();
1934
2075
  else if (wasEnabled) releaseWorkflowOwner();
1935
2076
  return true;
@@ -1939,6 +2080,7 @@ ${intent.plan}`,
1939
2080
  } finally {
1940
2081
  state = previousState;
1941
2082
  workflowAllowedToolNames = previousWorkflowAllowedToolNames;
2083
+ pendingWorkflowToolPolicy = previousPendingWorkflowToolPolicy;
1942
2084
  if (workflowOwner !== previousOwner) {
1943
2085
  workflowMutex.release(workflowOwner);
1944
2086
  workflowOwner = previousOwner;
@@ -1958,6 +2100,7 @@ ${intent.plan}`,
1958
2100
  } finally {
1959
2101
  state = previousState;
1960
2102
  workflowAllowedToolNames = void 0;
2103
+ pendingWorkflowToolPolicy = void 0;
1961
2104
  try {
1962
2105
  persistState();
1963
2106
  updateUi(ctx);
@@ -2026,6 +2169,10 @@ ${intent.plan}`,
2026
2169
  function toolByName(toolName) {
2027
2170
  return safeGetAllTools().find((candidate) => candidate.name === toolName);
2028
2171
  }
2172
+ function terminalToolName(value) {
2173
+ const safe = safeTerminalText(value) || "(unnamed tool)";
2174
+ return safe.length > 120 ? `${safe.slice(0, 119)}\u2026` : safe;
2175
+ }
2029
2176
  function safeTerminalText(value) {
2030
2177
  return [...value].map((character) => {
2031
2178
  const codePoint = character.codePointAt(0) ?? 0;