@deepseek-harness-tui/dsh-tui 0.17.0 → 0.18.0

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.
Files changed (186) hide show
  1. package/README.md +10 -8
  2. package/cli/adapters/dsh/index.mjs +2 -2
  3. package/guide/dsh-tui-guide/cli.en.md +1 -1
  4. package/guide/dsh-tui-guide/cli.md +1 -1
  5. package/guide/dsh-tui-guide/configuration.en.md +3 -2
  6. package/guide/dsh-tui-guide/configuration.md +3 -2
  7. package/guide/dsh-tui-guide/getting-started.en.md +6 -2
  8. package/guide/dsh-tui-guide/getting-started.md +4 -1
  9. package/guide/dsh-tui-guide/interaction.en.md +28 -7
  10. package/guide/dsh-tui-guide/interaction.md +17 -5
  11. package/guide/dsh-tui-guide/plugins.en.md +28 -7
  12. package/guide/dsh-tui-guide/plugins.md +18 -5
  13. package/guide/dsh-tui-guide/user-guide.en.md +29 -15
  14. package/guide/dsh-tui-guide/user-guide.md +20 -10
  15. package/lib/settings.json +3 -3
  16. package/lib/types/adapter/channel/ui-policy.d.ts +1 -0
  17. package/lib/types/adapter/channel/ui-policy.d.ts.map +1 -1
  18. package/lib/types/adapter/channel/ui-policy.js +1 -0
  19. package/lib/types/adapter/ports/channel-ui.d.ts +5 -0
  20. package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
  21. package/lib/types/adapter/ports/channel-view.d.ts +3 -0
  22. package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
  23. package/lib/types/adapter/standard/grants.d.ts +60 -0
  24. package/lib/types/adapter/standard/grants.d.ts.map +1 -1
  25. package/lib/types/adapter/standard/grants.js +74 -0
  26. package/lib/types/agent/events.d.ts +7 -1
  27. package/lib/types/agent/events.d.ts.map +1 -1
  28. package/lib/types/commands.js +1 -1
  29. package/lib/types/components/GoalTodoPanel.d.ts +71 -6
  30. package/lib/types/components/GoalTodoPanel.d.ts.map +1 -1
  31. package/lib/types/components/GoalTodoPanel.js +165 -17
  32. package/lib/types/components/MessageList.d.ts.map +1 -1
  33. package/lib/types/components/MessageList.js +3 -2
  34. package/lib/types/components/PluginGrantList.d.ts +45 -0
  35. package/lib/types/components/PluginGrantList.d.ts.map +1 -0
  36. package/lib/types/components/PluginGrantList.js +126 -0
  37. package/lib/types/components/PluginInstallPane.d.ts.map +1 -1
  38. package/lib/types/components/PluginInstallPane.js +35 -6
  39. package/lib/types/components/PluginManagePane.d.ts.map +1 -1
  40. package/lib/types/components/PluginManagePane.js +65 -8
  41. package/lib/types/components/PromptInput.js +2 -2
  42. package/lib/types/components/SubagentDashboard.d.ts.map +1 -1
  43. package/lib/types/components/SubagentDashboard.js +10 -0
  44. package/lib/types/components/SubagentDetailScene.d.ts.map +1 -1
  45. package/lib/types/components/SubagentDetailScene.js +12 -0
  46. package/lib/types/components/messages/AssistantToolUseMessage.d.ts +2 -1
  47. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  48. package/lib/types/components/messages/AssistantToolUseMessage.js +11 -5
  49. package/lib/types/components/onboardingModel.d.ts +2 -2
  50. package/lib/types/components/onboardingModel.js +3 -3
  51. package/lib/types/components/onboardingProviderPlan.d.ts +110 -0
  52. package/lib/types/components/onboardingProviderPlan.d.ts.map +1 -0
  53. package/lib/types/components/onboardingProviderPlan.js +78 -0
  54. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts +7 -0
  55. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts.map +1 -1
  56. package/lib/types/components/sidePanel/btw/BtwComposer.js +16 -0
  57. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.d.ts.map +1 -1
  58. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.js +8 -1
  59. package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts +7 -1
  60. package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts.map +1 -1
  61. package/lib/types/components/sidePanel/btw/BtwThreadScene.js +8 -1
  62. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts +30 -0
  63. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts.map +1 -0
  64. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.js +94 -0
  65. package/lib/types/components/sidePanel/builtinPanels.d.ts.map +1 -1
  66. package/lib/types/components/sidePanel/builtinPanels.js +14 -2
  67. package/lib/types/components/sidePanel/types.d.ts +2 -0
  68. package/lib/types/components/sidePanel/types.d.ts.map +1 -1
  69. package/lib/types/components/sidePanel/useSidePanel.d.ts.map +1 -1
  70. package/lib/types/components/sidePanel/useSidePanel.js +15 -1
  71. package/lib/types/dsh-adapter/backend/session.d.ts +7 -1
  72. package/lib/types/dsh-adapter/backend/session.d.ts.map +1 -1
  73. package/lib/types/dsh-adapter/backend/session.js +62 -6
  74. package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
  75. package/lib/types/dsh-adapter/backend/translate.js +9 -5
  76. package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts +1 -1
  77. package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts.map +1 -1
  78. package/lib/types/dsh-adapter/channel/agent-view-projection.js +3 -1
  79. package/lib/types/dsh-adapter/channel/composer-images.d.ts +2 -0
  80. package/lib/types/dsh-adapter/channel/composer-images.d.ts.map +1 -1
  81. package/lib/types/dsh-adapter/channel/composer-images.js +10 -2
  82. package/lib/types/dsh-adapter/channel/composer-mentions.d.ts.map +1 -1
  83. package/lib/types/dsh-adapter/channel/composer-mentions.js +22 -7
  84. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts +1 -1
  85. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts.map +1 -1
  86. package/lib/types/dsh-adapter/channel/context-bookkeeping.js +9 -5
  87. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts +6 -0
  88. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts.map +1 -1
  89. package/lib/types/dsh-adapter/channel/core/binding-feed.js +35 -1
  90. package/lib/types/dsh-adapter/channel/core/compose.d.ts +1 -1
  91. package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
  92. package/lib/types/dsh-adapter/channel/core/compose.js +5 -0
  93. package/lib/types/dsh-adapter/channel/input-actions.d.ts +2 -2
  94. package/lib/types/dsh-adapter/channel/input-actions.d.ts.map +1 -1
  95. package/lib/types/dsh-adapter/channel/input-actions.js +30 -0
  96. package/lib/types/dsh-adapter/channel/input-delivery.d.ts +1 -1
  97. package/lib/types/dsh-adapter/channel/input-delivery.d.ts.map +1 -1
  98. package/lib/types/dsh-adapter/channel/input-delivery.js +8 -4
  99. package/lib/types/dsh-adapter/channel/mentions.d.ts.map +1 -1
  100. package/lib/types/dsh-adapter/channel/mentions.js +21 -7
  101. package/lib/types/dsh-adapter/channel/paths.d.ts.map +1 -1
  102. package/lib/types/dsh-adapter/channel/paths.js +11 -9
  103. package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts +1 -1
  104. package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts.map +1 -1
  105. package/lib/types/dsh-adapter/channel/session-live-adoption.js +6 -1
  106. package/lib/types/dsh-adapter/channel/session-reset.d.ts.map +1 -1
  107. package/lib/types/dsh-adapter/channel/session-reset.js +3 -1
  108. package/lib/types/dsh-adapter/channel/session-resume.d.ts +1 -1
  109. package/lib/types/dsh-adapter/channel/session-resume.d.ts.map +1 -1
  110. package/lib/types/dsh-adapter/channel/session-resume.js +10 -3
  111. package/lib/types/dsh-adapter/channel/session-rewind.d.ts +1 -1
  112. package/lib/types/dsh-adapter/channel/session-rewind.d.ts.map +1 -1
  113. package/lib/types/dsh-adapter/channel/session-rewind.js +3 -1
  114. package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts +1 -1
  115. package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts.map +1 -1
  116. package/lib/types/dsh-adapter/channel/session-tree-actions.js +3 -1
  117. package/lib/types/dsh-adapter/contract.d.ts +4 -3
  118. package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
  119. package/lib/types/dsh-adapter/contract.js +6 -3
  120. package/lib/types/dsh-adapter/entry-slot.d.ts +6 -0
  121. package/lib/types/dsh-adapter/entry-slot.d.ts.map +1 -1
  122. package/lib/types/dsh-adapter/experimental-bundles.d.ts +3 -0
  123. package/lib/types/dsh-adapter/experimental-bundles.d.ts.map +1 -1
  124. package/lib/types/dsh-adapter/experimental-bundles.js +4 -0
  125. package/lib/types/dsh-adapter/grant-file.d.ts +70 -0
  126. package/lib/types/dsh-adapter/grant-file.d.ts.map +1 -0
  127. package/lib/types/dsh-adapter/grant-file.js +178 -0
  128. package/lib/types/dsh-adapter/host-access.d.ts +4 -0
  129. package/lib/types/dsh-adapter/host-access.d.ts.map +1 -1
  130. package/lib/types/dsh-adapter/host-access.js +54 -4
  131. package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
  132. package/lib/types/dsh-adapter/host-contract.js +2 -2
  133. package/lib/types/dsh-adapter/host-dsh.js +3 -3
  134. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  135. package/lib/types/dsh-adapter/index.js +8 -5
  136. package/lib/types/dsh-adapter/panels.d.ts +7 -1
  137. package/lib/types/dsh-adapter/panels.d.ts.map +1 -1
  138. package/lib/types/dsh-adapter/plugin-declaration.d.ts +28 -0
  139. package/lib/types/dsh-adapter/plugin-declaration.d.ts.map +1 -1
  140. package/lib/types/dsh-adapter/plugin-declaration.js +43 -1
  141. package/lib/types/dsh-adapter/plugin-install.d.ts +28 -1
  142. package/lib/types/dsh-adapter/plugin-install.d.ts.map +1 -1
  143. package/lib/types/dsh-adapter/plugin-install.js +160 -13
  144. package/lib/types/dsh-adapter/plugin-manage.d.ts +53 -10
  145. package/lib/types/dsh-adapter/plugin-manage.d.ts.map +1 -1
  146. package/lib/types/dsh-adapter/plugin-manage.js +240 -51
  147. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  148. package/lib/types/dsh-adapter/plugin.js +64 -18
  149. package/lib/types/dsh-adapter/plugins-info.d.ts +6 -7
  150. package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -1
  151. package/lib/types/dsh-adapter/plugins-info.js +34 -21
  152. package/lib/types/dsh-adapter/presets.d.ts +6 -2
  153. package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
  154. package/lib/types/dsh-adapter/presets.js +23 -5
  155. package/lib/types/dsh-adapter/process-exit.d.ts +1 -1
  156. package/lib/types/dsh-adapter/process-exit.js +1 -1
  157. package/lib/types/dsh-adapter/providerWizard.d.ts +2 -0
  158. package/lib/types/dsh-adapter/providerWizard.d.ts.map +1 -1
  159. package/lib/types/dsh-adapter/providerWizard.js +11 -5
  160. package/lib/types/dsh-adapter/row-attachment.d.ts +30 -0
  161. package/lib/types/dsh-adapter/row-attachment.d.ts.map +1 -0
  162. package/lib/types/dsh-adapter/row-attachment.js +29 -0
  163. package/lib/types/dsh-adapter/worktree-tool.d.ts +27 -0
  164. package/lib/types/dsh-adapter/worktree-tool.d.ts.map +1 -0
  165. package/lib/types/dsh-adapter/worktree-tool.js +87 -0
  166. package/lib/types/heldInputs.d.ts +36 -0
  167. package/lib/types/heldInputs.d.ts.map +1 -0
  168. package/lib/types/heldInputs.js +173 -0
  169. package/lib/types/i18n.d.ts +352 -25
  170. package/lib/types/i18n.d.ts.map +1 -1
  171. package/lib/types/i18n.js +171 -18
  172. package/lib/types/onboardingDraft.d.ts +143 -0
  173. package/lib/types/onboardingDraft.d.ts.map +1 -0
  174. package/lib/types/onboardingDraft.js +71 -0
  175. package/lib/types/screens/Chat.d.ts.map +1 -1
  176. package/lib/types/screens/Chat.js +90 -30
  177. package/lib/types/screens/Onboarding.d.ts +22 -3
  178. package/lib/types/screens/Onboarding.d.ts.map +1 -1
  179. package/lib/types/screens/Onboarding.js +606 -36
  180. package/lib/types/settings/definitions.js +2 -2
  181. package/lib/types/utils/paths.d.ts +15 -0
  182. package/lib/types/utils/paths.d.ts.map +1 -1
  183. package/lib/types/utils/paths.js +25 -0
  184. package/package.json +111 -108
  185. package/tui-profile/feed/README.md +1 -1
  186. package/tui-profile/feed/first-party.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/paths.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAEvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,8CAA8C;AAC9C,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED;4EAC4E;AAC5E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,GAAG,MAAM,CAG3E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,eAAe,GAAE,OAAsC,GACtD,OAAO,CAwBT;AAED,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CA+BlK;AAED,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,gBAAgB,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAmD5I"}
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/paths.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAEvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,8CAA8C;AAC9C,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED;4EAC4E;AAC5E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,GAAG,MAAM,CAG3E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,eAAe,GAAE,OAAsC,GACtD,OAAO,CAwBT;AAED,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAiClK;AAED,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,gBAAgB,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAmD5I"}
@@ -1,6 +1,6 @@
1
- import { join } from 'node:path';
1
+ import { isAbsolute, join } from 'node:path';
2
2
  import { rankFileCandidates } from '../../utils/fileSuggestions.js';
3
- import { homeDir } from '../../utils/paths.js';
3
+ import { expandHomePrefix, homeDir } from '../../utils/paths.js';
4
4
  /** Trailing path segment (`C:/a/b` → `b`). */
5
5
  export function basename(path) {
6
6
  const parts = path.split(/[\\/]/);
@@ -69,13 +69,15 @@ export async function listPathCandidates(fs, cwd, query, signal, topK) {
69
69
  const displayDirectoryPart = rawSlash < 0 ? (bareDir ? `${query}/` : '') : query.slice(0, rawSlash + 1);
70
70
  const displaySeparator = displayDirectoryPart.endsWith('\\') ? '\\' : '/';
71
71
  const nameQuery = slash < 0 || bareDir ? '' : normalized.slice(slash + 1);
72
- // `~/` expands against the host home (matches the cwd resolution rules);
73
- // drive-letter and POSIX-absolute prefixes pass through untouched.
74
- const expanded = directoryPart === '~/'
75
- ? `${homeDir()}/`
76
- : directoryPart.startsWith('/') || /^[A-Za-z]:\//.test(directoryPart)
77
- ? directoryPart
78
- : join(cwd, directoryPart || '.');
72
+ // A leading literal `~/` (or `~\`) expands against the host home at ANY
73
+ // depth — issue #1706: after picking `~/Downloads/` the next level used to be
74
+ // joined onto the workspace and the menu silently vanished. Drive-letter and
75
+ // POSIX-absolute prefixes still pass through untouched; `isAbsolute` also
76
+ // keeps a UNC home (`\\server\share\user`) off the workspace join.
77
+ const homeExpanded = expandHomePrefix(directoryPart);
78
+ const expanded = isAbsolute(homeExpanded) || /^[A-Za-z]:[\\/]/.test(homeExpanded)
79
+ ? homeExpanded
80
+ : join(cwd, homeExpanded || '.');
79
81
  try {
80
82
  if (signal?.aborted)
81
83
  return [];
@@ -7,7 +7,7 @@ type Binding = DshChannelBinding;
7
7
  type LiveAdoptionState = Pick<ChannelState, 'status' | 'agentId' | 'sessionId' | 'cwd' | 'displayCwd' | 'agentPreset' | 'provider' | 'model' | 'loadedContext' | 'contextWindow' | 'effortLevels' | 'reasoningEffort' | 'tps' | 'tpsSamples' | 'lastUsage' | 'turnUsage' | 'working' | 'emit'> & Parameters<typeof resetSessionProjection>[0];
8
8
  /** Adopt an already-live agent, preserving a meaningful previous handle in the background ledger. */
9
9
  export declare function createLiveAgentAdoption(state: LiveAdoptionState, deps: {
10
- binding: Pick<Binding, 'switchTo'>;
10
+ binding: Pick<Binding, 'switchTo' | 'handle'>;
11
11
  /** Wrap the target (and the parked handle this channel owns for it, if
12
12
  * any) as the session handed to the binding. */
13
13
  openSession(agent: Agent, handle: AgentHandle | undefined): AgentSession;
@@ -1 +1 @@
1
- {"version":3,"file":"session-live-adoption.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/session-live-adoption.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAM1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC3D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AM,CAAA;KAAE,CAAA;IACxD,gBAAgB,IAAI,IAAI,CAAA;IACxB,SAAS,IAAI,IAAI,CAAA;IACjB,eAAe,IAAI,IAAI,CAAA;IACvB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,iBAAiB,IAAI,IAAI,CAAA;IACzB;6CACyC;IACzC,iBAAiB,IAAI,IAAI,CAAA;IACzB,qBAAqB,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7F,eAAe,IAAI,IAAI,CAAA;CACxB,IAEa,QAAQ,KAAK,KAAG,OAAO,CAAC,YAAY,CAAC,CA8DpD"}
1
+ {"version":3,"file":"session-live-adoption.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/session-live-adoption.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAM1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE5D,KAAK,OAAO,GAAG,iBAAiB,CAAA;AAChC,KAAK,iBAAiB,GAAG,IAAI,CAC3B,YAAY,EACV,QAAQ,GACR,SAAS,GACT,WAAW,GACX,KAAK,GACL,YAAY,GACZ,aAAa,GACb,UAAU,GACV,OAAO,GACP,eAAe,GACf,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,KAAK,GACL,YAAY,GACZ,WAAW,GACX,WAAW,GACX,SAAS,GACT,MAAM,CACT,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAA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IAEa,QAAQ,KAAK,KAAG,OAAO,CAAC,YAAY,CAAC,CAkEpD"}
@@ -6,7 +6,12 @@ import { runningPresetOf } from '../presets.js';
6
6
  import { resetSessionProjection } from './session-reset.js';
7
7
  /** Adopt an already-live agent, preserving a meaningful previous handle in the background ledger. */
8
8
  export function createLiveAgentAdoption(state, deps) {
9
- return async (target) => deps.binding.switchTo(deps.openSession(target, deps.backgroundHandles.get(String(target.id))), (committed, disposePrevious) => {
9
+ return async (target) => deps.binding.switchTo(
10
+ // The screen's own agent, live under a session that ended with its
11
+ // listeners (#1651), is rebound with the handle the screen holds: a
12
+ // session without it would leave that handle to the default disposal.
13
+ deps.openSession(target, deps.backgroundHandles.get(String(target.id))
14
+ ?? (deps.binding.handle?.agent === target ? deps.binding.handle : undefined)), (committed, disposePrevious) => {
10
15
  const previousHandle = committed.handle;
11
16
  const previousSessionId = String(committed.agent.session.id);
12
17
  const keepPrevious = previousHandle !== undefined
@@ -1 +1 @@
1
- {"version":3,"file":"session-reset.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/session-reset.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,YAAY,EACV,MAAM,GACN,OAAO,GACP,SAAS,GACT,MAAM,GACN,cAAc,GACd,cAAc,GACd,kBAAkB,GAClB,QAAQ,GACR,UAAU,GACV,cAAc,GACd,eAAe,GACf,iBAAiB,GACjB,cAAc,GACd,SAAS,GACT,YAAY,GACZ,eAAe,GACf,aAAa,GACb,KAAK,GACL,YAAY,GACZ,WAAW,GACX,WAAW,GACX,aAAa,GACb,iBAAiB,GACjB,YAAY;AACd;;qEAEqE;GACnE,kBAAkB,CACrB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EACzB,cAAc,EAAE,MAAM,IAAI,EAC1B,cAAc,EAAE,MAAM,IAAI,EAC1B,SAAS,EAAE,MAAM,IAAI,GACpB,IAAI,CAoDN"}
1
+ {"version":3,"file":"session-reset.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/session-reset.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,YAAY,EACV,MAAM,GACN,OAAO,GACP,SAAS,GACT,MAAM,GACN,cAAc,GACd,cAAc,GACd,kBAAkB,GAClB,QAAQ,GACR,UAAU,GACV,cAAc,GACd,eAAe,GACf,iBAAiB,GACjB,cAAc,GACd,SAAS,GACT,YAAY,GACZ,eAAe,GACf,aAAa,GACb,KAAK,GACL,YAAY,GACZ,WAAW,GACX,WAAW,GACX,aAAa,GACb,iBAAiB,GACjB,YAAY;AACd;;qEAEqE;GACnE,kBAAkB,CACrB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EACzB,cAAc,EAAE,MAAM,IAAI,EAC1B,cAAc,EAAE,MAAM,IAAI,EAC1B,SAAS,EAAE,MAAM,IAAI,GACpB,IAAI,CAsDN"}
@@ -12,7 +12,9 @@ export function resetSessionProjection(state, rowIds, resetProjector, resetSubag
12
12
  resetSubagents();
13
13
  resetJobs();
14
14
  state.todos = [];
15
- state.pending = [];
15
+ // Orphaned rows belong to no backend (their session ended or dropped
16
+ // them): they wait in the dock for the user, whichever session is next.
17
+ state.pending = state.pending.filter(item => item.orphaned === true);
16
18
  state.goal = undefined;
17
19
  state.sessionTitle = '';
18
20
  state.sessionColor = '';
@@ -19,7 +19,7 @@ export declare function createSessionResumeActions(ctx: Context, state: ResumeSt
19
19
  model: string;
20
20
  }, deps: {
21
21
  owner: Pick<ChannelOwner, 'current'>;
22
- binding: Pick<Binding, 'agent' | 'capture' | 'isCurrent' | 'prepare' | 'abandon' | 'adopt' | 'waitForDisposal'>;
22
+ binding: Pick<Binding, 'agent' | 'session' | 'capture' | 'isCurrent' | 'prepare' | 'abandon' | 'adopt' | 'waitForDisposal'>;
23
23
  /**
24
24
  * Adopt an agent this process already has live. `/resume` uses it so a
25
25
  * target that is already running here is re-attached in place (parking the
@@ -1 +1 @@
1
- {"version":3,"file":"session-resume.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/session-resume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAsB,MAAM,wBAAwB,CAAA;AAEpF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAsBvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAgC,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AAC1G,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,0BAA0B,CAAA;AAEhF,KAAK,OAAO,GAAG,iBAAiB,CAAA;AAChC,KAAK,WAAW,GAAG,IAAI,CACrB,YAAY,EACV,SAAS,GACT,QAAQ,GACR,SAAS,GACT,WAAW,GACX,KAAK,GACL,YAAY,GACZ,aAAa,GACb,UAAU,GACV,OAAO,GACP,eAAe,GACf,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,SAAS,GACT,MAAM,CACT,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAA;AAEhD,YAAY,EAAE,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AAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IACjC,SAAS,IAAI,IAAI,CAAA;IACjB,MAAM,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,IAAI,CAAA;IAC7C,YAAY,IAAI,IAAI,CAAA;IACpB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACxD,gBAAgB,IAAI,IAAI,CAAA;IACxB,SAAS,IAAI,IAAI,CAAA;IACjB,eAAe,IAAI,IAAI,CAAA;IACvB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,iBAAiB,IAAI,IAAI,CAAA;IACzB;6CACyC;IACzC,iBAAiB,IAAI,IAAI,CAAA;IACzB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACjC,mBAAmB,CAAC,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,YAAY,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACtG,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAA;IAC9B,qBAAqB,CAAC,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;IAChH,OAAO,EAAE,qBAAqB,CAAA;CAC/B;4BA+MoC,MAAM,QAAQ,QAAQ,GAAG,YAAY,eAAe,OAAO,KAAG,OAAO,CAAC,YAAY,CAAC;0BAiDrF,MAAM,KAAG,OAAO,CAAC,YAAY,CAAC;;EAmKlE"}
@@ -126,7 +126,12 @@ export function createSessionResumeActions(ctx, state, options, deps) {
126
126
  // normal return is a commit, which is what the outer finally keys on.
127
127
  const result = deps.binding.adopt(candidate, adoption, (committedBinding, disposePrevious) => {
128
128
  const previousSessionId = String(committedBinding.agent.session.id);
129
- const keepPrevious = keepCurrent && committedBinding.handle !== undefined
129
+ // Reopening the screen's own ended session (#1651) is not a switch:
130
+ // the handle it replaces is the disposed one, and parking it would put
131
+ // a dead entry in the background ledger under the id this adoption now
132
+ // owns — the live-adoption lookup prefers that entry over the screen's
133
+ // current handle. Dispose it instead (idempotent).
134
+ const keepPrevious = keepCurrent && previousSessionId !== sessionId && committedBinding.handle !== undefined
130
135
  && (committedBinding.handle.agent.status === 'running' || agentViewHasTurns(snapshotLiveSessionEvents(committedBinding.handle.agent.session)));
131
136
  if (keepCurrent && (committedBinding.handle === undefined || keepPrevious))
132
137
  deps.parkSubagents(committedBinding.agent);
@@ -275,8 +280,10 @@ export function createSessionResumeActions(ctx, state, options, deps) {
275
280
  // default disposition disposes the handle that IS running, so a second
276
281
  // Enter on the `current` row stopped the live turn while reporting success.
277
282
  // `attachToAgent()` has always short-circuited here; this is the same rule
278
- // for the unified screen's `/resume` path.
279
- if (String(sessionId) === String(entrySession.id))
283
+ // for the unified screen's `/resume` path. A disposed foreground (its
284
+ // agent unloaded under the screen, #1651) has nothing running: resuming
285
+ // its own id reopens the log like any other disk resume.
286
+ if (String(sessionId) === String(entrySession.id) && deps.binding.session.status !== 'disposed')
280
287
  return { ok: true };
281
288
  // Switching away starts disposal without blocking the synchronous commit.
282
289
  // Do not adopt that closing Agent (or reopen its still-held JSONL writer).
@@ -9,7 +9,7 @@ type RewindState = Pick<ChannelState, 'working' | 'cwd' | 'provider' | 'model'>;
9
9
  /** Rewind a selected transcript row into a prepared, binding-owned fork. */
10
10
  export declare function createRewindToAction(ctx: Context, state: RewindState, deps: {
11
11
  owner: Pick<ChannelOwner, 'current'>;
12
- binding: Pick<Binding, 'agent' | 'capture' | 'prepare' | 'isCurrent' | 'abandon'>;
12
+ binding: Pick<Binding, 'agent' | 'session' | 'capture' | 'prepare' | 'isCurrent' | 'abandon'>;
13
13
  settleCompaction(): Promise<void>;
14
14
  notify: ChannelState['notify'];
15
15
  adoptForkedAgent(candidate: AgentSession, capture: ReturnType<Binding['capture']>, seed: readonly SessionEvent[], agentPreset: string | undefined, childId: SessionId): string;
@@ -1 +1 @@
1
- {"version":3,"file":"session-rewind.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/session-rewind.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAYvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEvD,KAAK,OAAO,GAAG,iBAAiB,CAAA;AAChC,KAAK,WAAW,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,OAAO,CAAC,CAAA;AAgB/E,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE;IACJ,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;IACpC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC,CAAA;IACjF,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACjC,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAA;IAC9B,gBAAgB,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,YAAY,EAAE,EAAE,WAAW,EAAE,MAAM,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AC,QAAQ,CAAC,CAAA;IAC9B,gBAAgB,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,YAAY,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,MAAM,CAAA;IAC9K,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1F,IAEa,KAAK,OAAO,EAAE,OAAM,MAAM,GAAG,IAAW,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmHhF"}
@@ -33,8 +33,10 @@ export function createRewindToAction(ctx, state, deps) {
33
33
  }
34
34
  const wasWorking = state.working;
35
35
  const cancelSeq = liveSessionOffset(deps.binding.agent.session);
36
+ // Through the session: the queue it drops is this client's own discard,
37
+ // not inputs the backend lost (those the channel would keep for the user).
36
38
  if (wasWorking)
37
- deps.binding.agent.cancel({ kind: 'user' });
39
+ void deps.binding.session.cancel('switch');
38
40
  if (wasWorking && !await waitForTurnEnd(deps.binding.agent.session, cancelSeq, 30000)) {
39
41
  deps.notify(t('rewind-settling'), { color: 'error' });
40
42
  return null;
@@ -9,7 +9,7 @@ type TreeRewindState = Pick<ChannelState, 'working' | 'cwd' | 'provider' | 'mode
9
9
  /** Rewind or fork a selected tree node; loading foreign family logs stays in this persistence adapter seam. */
10
10
  export declare function createTreeRewindAction(ctx: Context, state: TreeRewindState, deps: {
11
11
  owner: Pick<ChannelOwner, 'current'>;
12
- binding: Pick<Binding, 'agent' | 'capture' | 'isCurrent' | 'prepare' | 'abandon'>;
12
+ binding: Pick<Binding, 'agent' | 'session' | 'capture' | 'isCurrent' | 'prepare' | 'abandon'>;
13
13
  settleCompaction(): Promise<void>;
14
14
  notify: ChannelState['notify'];
15
15
  adoptForkedAgent(candidate: AgentSession, capture: ReturnType<Binding['capture']>, seed: readonly SessionEvent[], agentPreset: string | undefined, childId: SessionId): string;
@@ -1 +1 @@
1
- {"version":3,"file":"session-tree-actions.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/session-tree-actions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAY1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,KAAK,OAAO,GAAG,iBAAiB,CAAA;AAChC,KAAK,eAAe,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,OAAO,CAAC,CAAA;AAYnF,+GAA+G;AAC/G,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE;IACJ,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;IACpC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC,CAAA;IACjF,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACjC,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAA;IAC9B,gBAAgB,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,YAAY,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,SAAS,GA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,CAAA;IAC9B,gBAAgB,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,YAAY,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,MAAM,CAAA;IAC9K,qBAAqB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;CACnG,IAEa,WAAW,MAAM,EAAE,KAAK,MAAM,EAAE,OAAM,QAAQ,GAAG,MAAiB,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAsI1G"}
@@ -77,8 +77,10 @@ export function createTreeRewindAction(ctx, state, deps) {
77
77
  }
78
78
  const wasWorking = state.working;
79
79
  const cancelSeq = liveSessionOffset(deps.binding.agent.session);
80
+ // Through the session: the queue it drops is this client's own discard,
81
+ // not inputs the backend lost (those the channel would keep for the user).
80
82
  if (wasWorking)
81
- deps.binding.agent.cancel({ kind: 'user' });
83
+ void deps.binding.session.cancel('switch');
82
84
  if (wasWorking && !await waitForTurnEnd(deps.binding.agent.session, cancelSeq, 30000)) {
83
85
  deps.notify(t('rewind-settling'), { color: 'error' });
84
86
  return null;
@@ -1,9 +1,10 @@
1
1
  /** Primary validated upstream line (newest). */
2
- export declare const UPSTREAM_VALIDATED_VERSION = "0.2.1-rc.3";
2
+ export declare const UPSTREAM_VALIDATED_VERSION = "0.2.1-rc.5";
3
3
  /**
4
4
  * Explicitly supported upstream prerelease lines, oldest first.
5
5
  *
6
- * 0.2.1-rc.3 = primary continuous-CI line; 0.2.1-rc.2 and
6
+ * 0.2.1-rc.5 = primary continuous-CI line; 0.2.1-rc.4/rc.3/rc.2 = earlier
7
+ * prereleases of the same family (published code compared with the primary);
7
8
  * 0.2.0-rc.2/rc.1 = previous family (mapped compatibility);
8
9
  * 0.1.7-rc.2/rc.1 = previous family (mapped compatibility);
9
10
  * 0.1.5-rc.1/alpha.2/alpha.1 = mapped
@@ -18,7 +19,7 @@ export declare const UPSTREAM_VALIDATED_VERSION = "0.2.1-rc.3";
18
19
  * The peer range in package.json is deliberately wider than this list: an
19
20
  * install on an older or newer line is allowed but reports drift at boot.
20
21
  */
21
- export declare const UPSTREAM_VALIDATED_VERSIONS: readonly ["0.1.0-rc.6", "0.1.0-rc.7", "0.1.0-rc.8", "0.1.1-rc.1", "0.1.1-rc.2", "0.1.2-alpha.3", "0.1.2-alpha.4", "0.1.2-alpha.5", "0.1.2-rc.1", "0.1.3-alpha.2", "0.1.5-alpha.1", "0.1.5-alpha.2", "0.1.5-rc.1", "0.1.7-rc.1", "0.1.7-rc.2", "0.2.0-rc.1", "0.2.0-rc.2", "0.2.1-rc.2", "0.2.1-rc.3"];
22
+ export declare const UPSTREAM_VALIDATED_VERSIONS: readonly ["0.1.0-rc.6", "0.1.0-rc.7", "0.1.0-rc.8", "0.1.1-rc.1", "0.1.1-rc.2", "0.1.2-alpha.3", "0.1.2-alpha.4", "0.1.2-alpha.5", "0.1.2-rc.1", "0.1.3-alpha.2", "0.1.5-alpha.1", "0.1.5-alpha.2", "0.1.5-rc.1", "0.1.7-rc.1", "0.1.7-rc.2", "0.2.0-rc.1", "0.2.0-rc.2", "0.2.1-rc.2", "0.2.1-rc.3", "0.2.1-rc.4", "0.2.1-rc.5"];
22
23
  /**
23
24
  * Framework packages version on their own lines; the contract validates
24
25
  * their MAJOR (breaking surface), not the harness prerelease number.
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/contract.ts"],"names":[],"mappings":"AAmBA,gDAAgD;AAChD,eAAO,MAAM,0BAA0B,eAAe,CAAA;AAEtD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,2BAA2B,uSAoB9B,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM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ClC,iBAAiB,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAA+B,GAC5F,oBAAoB,GAAG,SAAS,CA0BlC"}
@@ -2,7 +2,7 @@
2
2
  * Upstream compatibility contract.
3
3
  *
4
4
  * The TUI is validated against a set of upstream prerelease lines — the
5
- * current primary (0.2.1-rc.3) plus older lines kept in backward
5
+ * current primary (0.2.1-rc.5) plus older lines kept in backward
6
6
  * compatibility across the 0.2.0, 0.1.7, 0.1.5, 0.1.3, 0.1.2, 0.1.1 and 0.1.0
7
7
  * release families.
8
8
  * Every official package this adapter touches is blessed here; anything
@@ -17,11 +17,12 @@ import { readFileSync } from 'node:fs';
17
17
  import { fileURLToPath } from 'node:url';
18
18
  import { ADAPTER_TYPE_PACKAGES, HOST_TYPE_PACKAGES } from './host-contract.js';
19
19
  /** Primary validated upstream line (newest). */
20
- export const UPSTREAM_VALIDATED_VERSION = '0.2.1-rc.3';
20
+ export const UPSTREAM_VALIDATED_VERSION = '0.2.1-rc.5';
21
21
  /**
22
22
  * Explicitly supported upstream prerelease lines, oldest first.
23
23
  *
24
- * 0.2.1-rc.3 = primary continuous-CI line; 0.2.1-rc.2 and
24
+ * 0.2.1-rc.5 = primary continuous-CI line; 0.2.1-rc.4/rc.3/rc.2 = earlier
25
+ * prereleases of the same family (published code compared with the primary);
25
26
  * 0.2.0-rc.2/rc.1 = previous family (mapped compatibility);
26
27
  * 0.1.7-rc.2/rc.1 = previous family (mapped compatibility);
27
28
  * 0.1.5-rc.1/alpha.2/alpha.1 = mapped
@@ -56,6 +57,8 @@ export const UPSTREAM_VALIDATED_VERSIONS = [
56
57
  '0.2.0-rc.2',
57
58
  '0.2.1-rc.2',
58
59
  '0.2.1-rc.3',
60
+ '0.2.1-rc.4',
61
+ '0.2.1-rc.5',
59
62
  ];
60
63
  /**
61
64
  * Framework packages version on their own lines; the contract validates
@@ -18,6 +18,12 @@ export interface EntrySlot {
18
18
  /** The DSH side. The row calls it once, after the Loader settled; it never
19
19
  * throws (a failure lands in the mounted screen). */
20
20
  attachDsh?: (ctx: unknown, runtimeConfig: unknown, configOwner: unknown) => Promise<void>;
21
+ /** A row applied again after `attachDsh` was taken (its services came
22
+ * back after unloading under the screen, #1651): the hook that remounts
23
+ * the DSH seams on the new row and reopens the screen's session if it
24
+ * ended with the previous row, called like `attachDsh`. Undefined while
25
+ * the previous row is still mounted, and the new row stays idle. */
26
+ reattachDsh?: () => EntrySlot['attachDsh'];
21
27
  /** DSH: the composition failed or had no `dsh-tui` row, the startup session
22
28
  * will never come. `logPath` is the saved startup report, if any. */
23
29
  composeFailed?: (error: unknown, logPath?: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"entry-slot.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/entry-slot.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,+CAA+C;AAC/C,MAAM,WAAW,SAAS;IACxB,kEAAkE;IAClE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;IACrB,2FAA2F;IAC3F,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;IAC/B;6DACyD;IACzD,OAAO,EAAE,OAAO,CAAA;IAChB;0DACsD;IACtD,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACzF;0EACsE;IACtE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1D;;4DAEwD;IACxD,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAA;IAC7B;wDACoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACxC;AAMD,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAI/E;AAED,sEAAsE;AACtE,wBAAgB,aAAa,IAAI,SAAS,GAAG,SAAS,CAErD;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,IAAI,SAAS,CAAC,WAAW,CAAC,CAKxD"}
1
+ {"version":3,"file":"entry-slot.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/entry-slot.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,+CAA+C;AAC/C,MAAM,WAAW,SAAS;IACxB,kEAAkE;IAClE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;IACrB,2FAA2F;IAC3F,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;IAC/B;6DACyD;IACzD,OAAO,EAAE,OAAO,CAAA;IAChB;0DACsD;IACtD,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACzF;;;;yEAIqE;IACrE,WAAW,CAAC,EAAE,MAAM,SAAS,CAAC,WAAW,CAAC,CAAA;IAC1C;0EACsE;IACtE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1D;;4DAEwD;IACxD,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAA;IAC7B;wDACoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACxC;AAMD,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAI/E;AAED,sEAAsE;AACtE,wBAAgB,aAAa,IAAI,SAAS,GAAG,SAAS,CAErD;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,IAAI,SAAS,CAAC,WAAW,CAAC,CAKxD"}
@@ -15,6 +15,9 @@ import type { I18nKey } from '../i18n.js';
15
15
  export declare const AUTO_REVIEW_BUNDLE = "@deepseek-ai/dsh-experimental-auto-review";
16
16
  /** The bundle that mounts the five read-only session-search tools. */
17
17
  export declare const SESSION_SEARCH_BUNDLE = "@deepseek-ai/dsh-experimental-session-search";
18
+ /** The bundle that mounts `create_worktree` (a new Git branch and worktree the
19
+ * session then moves into; the TUI follows the move like any other cd). */
20
+ export declare const WORKTREE_BUNDLE = "@deepseek-ai/dsh-experimental-tool-worktree";
18
21
  /** One experimental feature the TUI knows how to switch on and use. */
19
22
  export interface TuiExperimentalBundle {
20
23
  readonly name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"experimental-bundles.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/experimental-bundles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAGzC,2DAA2D;AAC3D,eAAO,MAAM,kBAAkB,8CAA8C,CAAA;AAE7E,sEAAsE;AACtE,eAAO,MAAM,qBAAqB,iDAAiD,CAAA;AAEnF,uEAAuE;AACvE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CACvB;AAED,gEAAgE;AAChE,eAAO,MAAM,wBAAwB,EAAE,SAAS,qBAAqB,EAIpE,CAAA"}
1
+ {"version":3,"file":"experimental-bundles.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/experimental-bundles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAGzC,2DAA2D;AAC3D,eAAO,MAAM,kBAAkB,8CAA8C,CAAA;AAE7E,sEAAsE;AACtE,eAAO,MAAM,qBAAqB,iDAAiD,CAAA;AAEnF;4EAC4E;AAC5E,eAAO,MAAM,eAAe,gDAAgD,CAAA;AAE5E,uEAAuE;AACvE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CACvB;AAED,gEAAgE;AAChE,eAAO,MAAM,wBAAwB,EAAE,SAAS,qBAAqB,EAKpE,CAAA"}
@@ -3,9 +3,13 @@ import { TEAM_BUNDLE } from './team-roster.js';
3
3
  export const AUTO_REVIEW_BUNDLE = '@deepseek-ai/dsh-experimental-auto-review';
4
4
  /** The bundle that mounts the five read-only session-search tools. */
5
5
  export const SESSION_SEARCH_BUNDLE = '@deepseek-ai/dsh-experimental-session-search';
6
+ /** The bundle that mounts `create_worktree` (a new Git branch and worktree the
7
+ * session then moves into; the TUI follows the move like any other cd). */
8
+ export const WORKTREE_BUNDLE = '@deepseek-ai/dsh-experimental-tool-worktree';
6
9
  /** The features `/plugin list` advertises, in product order. */
7
10
  export const TUI_EXPERIMENTAL_BUNDLES = [
8
11
  { name: TEAM_BUNDLE, hint: 'plugins-experimental-team-hint' },
9
12
  { name: AUTO_REVIEW_BUNDLE, hint: 'plugins-experimental-auto-review-hint' },
10
13
  { name: SESSION_SEARCH_BUNDLE, hint: 'plugins-experimental-session-search-hint' },
14
+ { name: WORKTREE_BUNDLE, hint: 'plugins-experimental-worktree-hint' },
11
15
  ];
@@ -0,0 +1,70 @@
1
+ import { type GrantMutation, type GrantStore } from '../adapter/standard/grants.js';
2
+ import type { DeclaredGrants } from './plugin-declaration.js';
3
+ /** The grants-file operations the lifecycle flows ask for. */
4
+ export type { GrantMutation, GrantPermissionWrite } from '../adapter/standard/grants.js';
5
+ export interface GrantWriteResult {
6
+ readonly ok: true;
7
+ /** False when the document already had every requested rule (no write happened). */
8
+ readonly changed: boolean;
9
+ /**
10
+ * Restore the bytes this write replaced; only while the file still contains
11
+ * exactly what was written. Returns false when it was edited since, when the
12
+ * previous state cannot be restored, or when the lock cannot be taken.
13
+ */
14
+ readonly undo: () => Promise<boolean>;
15
+ }
16
+ export type GrantWriteFailure = {
17
+ readonly ok: false;
18
+ readonly reason: 'corrupt' | 'unreadable' | 'write-failed';
19
+ readonly detail?: string;
20
+ };
21
+ /** The grants file a lifecycle action writes (`~/.dsh-tui/extension-grants.json`). */
22
+ export declare function grantsFilePath(dataDir?: string): string;
23
+ /** Why one write failed, localized, with the filesystem's own words bounded and sanitized. */
24
+ export declare function grantFailureText(failure: GrantWriteFailure): string;
25
+ /** Test overrides; production resolves the packaged paths. */
26
+ export interface GrantWriteOptions {
27
+ readonly dataDir?: string | undefined;
28
+ /** The registry's known permission names; defaults to the packaged spec data. */
29
+ readonly knownPermissions?: readonly string[] | undefined;
30
+ }
31
+ /** One permission a plan lists: what the package declares, and what is true now. */
32
+ export interface GrantPlanEntry {
33
+ readonly name: string;
34
+ readonly scope: string;
35
+ readonly default: 'allow' | 'deny';
36
+ /** Whether the live store already allows this exact operation scope. */
37
+ readonly granted: boolean;
38
+ }
39
+ /**
40
+ * What the confirmation pane shows before a lifecycle action. `unknown` names
41
+ * the declarations this host's registry does not know: they are never written
42
+ * (the store would ignore them) and are reported instead of dropped.
43
+ */
44
+ export interface GrantPlan {
45
+ /** The component id the rules are keyed by — never the bundle name. */
46
+ readonly id: string;
47
+ readonly entries: readonly GrantPlanEntry[];
48
+ readonly unknown: readonly string[];
49
+ }
50
+ /**
51
+ * The plan for one package declaration, evaluated with the same
52
+ * activation-less principal `/plugin check` uses. Activation-scoped rules in
53
+ * the file therefore fail closed here, while the write is a global rule — the
54
+ * same split the report has always had.
55
+ *
56
+ * Unknown permission names never enter `entries`: writing one would produce a
57
+ * rule the store ignores, and this host cannot say what it authorizes.
58
+ */
59
+ export declare function planGrants(grants: GrantStore, declared: DeclaredGrants): GrantPlan;
60
+ /**
61
+ * Apply one mutation to the grants file.
62
+ *
63
+ * A missing file is the empty document (`{}`), exactly as `readGrantStore`
64
+ * reads it; an existing zero-byte file is corruption and is refused, also
65
+ * exactly as the store reads it. The read-modify-write runs under
66
+ * `extension-grants.json.lock`; the reader stays lock-free because the
67
+ * same-directory rename makes it see either the old or the new complete bytes.
68
+ */
69
+ export declare function applyGrantMutation(mutation: GrantMutation, options?: GrantWriteOptions): Promise<GrantWriteResult | GrantWriteFailure>;
70
+ //# sourceMappingURL=grant-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grant-file.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/grant-file.ts"],"names":[],"mappings":"AA+BA,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,UAAU,EAChB,MAAM,+BAA+B,CAAA;AAGtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAG7D,8DAA8D;AAC9D,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAExF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAA;IACjB,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;CACtC;AAED,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,YAAY,GAAG,cAAc,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhH,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,OAAO,GAAE,MAAiB,GAAG,MAAM,CAEjE;AAED,8FAA8F;AAC9F,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAMnE;AAED,8DAA8D;AAC9D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,iFAAiF;IACjF,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CAC1D;AAED,oFAAoF;AACpF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAA;IAClC,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAA;IAC3C,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CACpC;AAWD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,GAAG,SAAS,CAiBlF;AAwBD;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,aAAa,EACvB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,CA0D/C"}
@@ -0,0 +1,178 @@
1
+ /**
2
+ * The write half of the plugin grant file (`~/.dsh-tui/extension-grants.json`).
3
+ *
4
+ * `../adapter/standard/grants.ts` answers "may this operation run"; it has
5
+ * always been read-only, and the only writer used to be the person editing the
6
+ * file. The lifecycle flows (`./plugin-install.ts`, `./plugin-manage.ts`) need
7
+ * to grant a package's declared permissions on install/enable, revoke them on
8
+ * disable and forget them on removal, so this module owns the file I/O and
9
+ * nothing else: the document's shape and what a valid rewrite looks like stay
10
+ * in the reader's own module.
11
+ *
12
+ * Three rules decide the shape of this file:
13
+ *
14
+ * - **Never repair the person's file.** A corrupt document (bad JSON, an
15
+ * unknown root key, a malformed rule, zero bytes) is refused with a reason;
16
+ * the caller reports it and carries on with the install/enable, because an
17
+ * authorization is an enhancement, not a precondition.
18
+ * - **Never write a document the reader would call corrupt.** The rewritten
19
+ * text is parsed again before it reaches the disk.
20
+ * - **Atomic, undoable, and serialized across processes.** Same-directory
21
+ * temporary file + rename, like `usageStats.ts`, under the same sibling file
22
+ * lock (`extension-grants.json.lock`) the profile's atomic writes use, so a
23
+ * second TUI instance cannot lose an ensure/revoke/forget between our read
24
+ * and our rename. `undo()` restores the previous bytes only while the file
25
+ * still holds what this writer put there, so a hand edit in between is
26
+ * reported rather than overwritten.
27
+ */
28
+ import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
29
+ import { join } from 'node:path';
30
+ import { withFileLock } from '@deepseek-ai/dsh-atomic-write';
31
+ import { loadSpecData } from '../adapter/standard/registry.js';
32
+ import { EXTENSION_GRANTS_FILE, parseGrantStore, rewriteGrantDocument, } from '../adapter/standard/grants.js';
33
+ import { t } from '../i18n.js';
34
+ import { DATA_DIR } from '../utils/paths.js';
35
+ import { cleanScalarText } from './sanitize.js';
36
+ /** The grants file a lifecycle action writes (`~/.dsh-tui/extension-grants.json`). */
37
+ export function grantsFilePath(dataDir = DATA_DIR) {
38
+ return join(dataDir, EXTENSION_GRANTS_FILE);
39
+ }
40
+ /** Why one write failed, localized, with the filesystem's own words bounded and sanitized. */
41
+ export function grantFailureText(failure) {
42
+ const key = failure.reason === 'corrupt'
43
+ ? 'plugins-grant-reason-corrupt'
44
+ : failure.reason === 'unreadable' ? 'plugins-grant-reason-unreadable' : 'plugins-grant-reason-write-failed';
45
+ const detail = failure.detail === undefined ? '' : ` (${cleanScalarText(failure.detail, 200)})`;
46
+ return `${t(key)}${detail}`;
47
+ }
48
+ /** The registry's known permission names, or none when the spec data is unusable. */
49
+ function knownPermissionNames() {
50
+ try {
51
+ return (loadSpecData()?.permissions.permissions ?? []).map(permission => permission.name);
52
+ }
53
+ catch {
54
+ return [];
55
+ }
56
+ }
57
+ /**
58
+ * The plan for one package declaration, evaluated with the same
59
+ * activation-less principal `/plugin check` uses. Activation-scoped rules in
60
+ * the file therefore fail closed here, while the write is a global rule — the
61
+ * same split the report has always had.
62
+ *
63
+ * Unknown permission names never enter `entries`: writing one would produce a
64
+ * rule the store ignores, and this host cannot say what it authorizes.
65
+ */
66
+ export function planGrants(grants, declared) {
67
+ const known = new Set(grants.knownPermissions());
68
+ const entries = [];
69
+ const unknown = new Set();
70
+ for (const permission of declared.permissions) {
71
+ if (!known.has(permission.name)) {
72
+ unknown.add(permission.name);
73
+ continue;
74
+ }
75
+ entries.push({
76
+ name: permission.name,
77
+ scope: permission.scope,
78
+ default: grants.defaultOf(permission.name),
79
+ granted: grants.allows({ componentId: declared.id }, permission.name, permission.scope),
80
+ });
81
+ }
82
+ return { id: declared.id, entries, unknown: [...unknown] };
83
+ }
84
+ /** Atomically replace `file` with `text`, leaving no temporary behind on failure. */
85
+ function writeAtomically(file, text) {
86
+ const temp = `${file}.tmp`;
87
+ try {
88
+ writeFileSync(temp, text);
89
+ renameSync(temp, file);
90
+ }
91
+ catch (error) {
92
+ try {
93
+ rmSync(temp, { force: true });
94
+ }
95
+ catch {
96
+ // The rename is the real failure; a leftover temporary is the temp dir's.
97
+ }
98
+ throw error;
99
+ }
100
+ }
101
+ /**
102
+ * Apply one mutation to the grants file.
103
+ *
104
+ * A missing file is the empty document (`{}`), exactly as `readGrantStore`
105
+ * reads it; an existing zero-byte file is corruption and is refused, also
106
+ * exactly as the store reads it. The read-modify-write runs under
107
+ * `extension-grants.json.lock`; the reader stays lock-free because the
108
+ * same-directory rename makes it see either the old or the new complete bytes.
109
+ */
110
+ export async function applyGrantMutation(mutation, options = {}) {
111
+ if (mutation.id === '')
112
+ return { ok: false, reason: 'write-failed', detail: 'empty component id' };
113
+ const dir = options.dataDir ?? DATA_DIR;
114
+ const file = join(dir, EXTENSION_GRANTS_FILE);
115
+ try {
116
+ mkdirSync(dir, { recursive: true });
117
+ return await withFileLock(file, async () => {
118
+ let previous;
119
+ try {
120
+ previous = { text: readFileSync(file, 'utf8'), existed: true };
121
+ }
122
+ catch (error) {
123
+ if (error.code !== 'ENOENT') {
124
+ return { ok: false, reason: 'unreadable', detail: error instanceof Error ? error.message : String(error) };
125
+ }
126
+ previous = { text: '{}', existed: false };
127
+ }
128
+ // The document this mutation targets, with declared permission names this
129
+ // host does not know removed: a rule the store ignores must not be written.
130
+ const applied = mutation.kind === 'ensure'
131
+ ? {
132
+ ...mutation,
133
+ permissions: mutation.permissions.filter(permission => (options.knownPermissions ?? knownPermissionNames()).includes(permission.name)),
134
+ }
135
+ : mutation;
136
+ const rewritten = rewriteGrantDocument(previous.text, applied);
137
+ if ('error' in rewritten)
138
+ return { ok: false, reason: 'corrupt' };
139
+ if (!rewritten.changed)
140
+ return { ok: true, changed: false, undo: async () => true };
141
+ if (parseGrantStore(rewritten.text).corrupt)
142
+ return { ok: false, reason: 'write-failed', detail: 'the rewrite did not round-trip' };
143
+ writeAtomically(file, rewritten.text);
144
+ return {
145
+ ok: true,
146
+ changed: true,
147
+ undo: async () => {
148
+ try {
149
+ return await withFileLock(file, async () => {
150
+ let current;
151
+ try {
152
+ current = readFileSync(file, 'utf8');
153
+ }
154
+ catch {
155
+ return false;
156
+ }
157
+ // Someone edited the file after this write: restoring the old
158
+ // bytes would silently throw their change away.
159
+ if (current !== rewritten.text)
160
+ return false;
161
+ if (previous.existed)
162
+ writeAtomically(file, previous.text);
163
+ else
164
+ rmSync(file, { force: true });
165
+ return true;
166
+ });
167
+ }
168
+ catch {
169
+ return false;
170
+ }
171
+ },
172
+ };
173
+ });
174
+ }
175
+ catch (error) {
176
+ return { ok: false, reason: 'write-failed', detail: error instanceof Error ? error.message : String(error) };
177
+ }
178
+ }
@@ -17,6 +17,10 @@ export declare function armRootCapabilityGuard(root: Context): void;
17
17
  * the composition root while running from a host plugin callback. This module
18
18
  * is internal and is not part of the public plugin package surface. */
19
19
  export declare function withHostRootCapability<T>(callback: () => T): T;
20
+ /** Run host code outside the plugin activation that triggered it: an action
21
+ * the entry owns, which a row only sets off (the screen reopening its session
22
+ * when the dsh-tui row applies again), acts as the entry, not as that row. */
23
+ export declare function outsideActivation<T>(callback: () => T): T;
20
24
  export declare function concreteService<T extends object>(service: T): T;
21
25
  /** Bind a host-side disposer to the caller's authenticated Cordis activation.
22
26
  * A failed registration immediately rolls back the owned contribution. */