@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.
- package/README.md +10 -8
- package/cli/adapters/dsh/index.mjs +2 -2
- package/guide/dsh-tui-guide/cli.en.md +1 -1
- package/guide/dsh-tui-guide/cli.md +1 -1
- package/guide/dsh-tui-guide/configuration.en.md +3 -2
- package/guide/dsh-tui-guide/configuration.md +3 -2
- package/guide/dsh-tui-guide/getting-started.en.md +6 -2
- package/guide/dsh-tui-guide/getting-started.md +4 -1
- package/guide/dsh-tui-guide/interaction.en.md +28 -7
- package/guide/dsh-tui-guide/interaction.md +17 -5
- package/guide/dsh-tui-guide/plugins.en.md +28 -7
- package/guide/dsh-tui-guide/plugins.md +18 -5
- package/guide/dsh-tui-guide/user-guide.en.md +29 -15
- package/guide/dsh-tui-guide/user-guide.md +20 -10
- package/lib/settings.json +3 -3
- package/lib/types/adapter/channel/ui-policy.d.ts +1 -0
- package/lib/types/adapter/channel/ui-policy.d.ts.map +1 -1
- package/lib/types/adapter/channel/ui-policy.js +1 -0
- package/lib/types/adapter/ports/channel-ui.d.ts +5 -0
- package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
- package/lib/types/adapter/ports/channel-view.d.ts +3 -0
- package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
- package/lib/types/adapter/standard/grants.d.ts +60 -0
- package/lib/types/adapter/standard/grants.d.ts.map +1 -1
- package/lib/types/adapter/standard/grants.js +74 -0
- package/lib/types/agent/events.d.ts +7 -1
- package/lib/types/agent/events.d.ts.map +1 -1
- package/lib/types/commands.js +1 -1
- package/lib/types/components/GoalTodoPanel.d.ts +71 -6
- package/lib/types/components/GoalTodoPanel.d.ts.map +1 -1
- package/lib/types/components/GoalTodoPanel.js +165 -17
- package/lib/types/components/MessageList.d.ts.map +1 -1
- package/lib/types/components/MessageList.js +3 -2
- package/lib/types/components/PluginGrantList.d.ts +45 -0
- package/lib/types/components/PluginGrantList.d.ts.map +1 -0
- package/lib/types/components/PluginGrantList.js +126 -0
- package/lib/types/components/PluginInstallPane.d.ts.map +1 -1
- package/lib/types/components/PluginInstallPane.js +35 -6
- package/lib/types/components/PluginManagePane.d.ts.map +1 -1
- package/lib/types/components/PluginManagePane.js +65 -8
- package/lib/types/components/PromptInput.js +2 -2
- package/lib/types/components/SubagentDashboard.d.ts.map +1 -1
- package/lib/types/components/SubagentDashboard.js +10 -0
- package/lib/types/components/SubagentDetailScene.d.ts.map +1 -1
- package/lib/types/components/SubagentDetailScene.js +12 -0
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts +2 -1
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantToolUseMessage.js +11 -5
- package/lib/types/components/onboardingModel.d.ts +2 -2
- package/lib/types/components/onboardingModel.js +3 -3
- package/lib/types/components/onboardingProviderPlan.d.ts +110 -0
- package/lib/types/components/onboardingProviderPlan.d.ts.map +1 -0
- package/lib/types/components/onboardingProviderPlan.js +78 -0
- package/lib/types/components/sidePanel/btw/BtwComposer.d.ts +7 -0
- package/lib/types/components/sidePanel/btw/BtwComposer.d.ts.map +1 -1
- package/lib/types/components/sidePanel/btw/BtwComposer.js +16 -0
- package/lib/types/components/sidePanel/btw/BtwPanelAdapter.d.ts.map +1 -1
- package/lib/types/components/sidePanel/btw/BtwPanelAdapter.js +8 -1
- package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts +7 -1
- package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts.map +1 -1
- package/lib/types/components/sidePanel/btw/BtwThreadScene.js +8 -1
- package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts +30 -0
- package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts.map +1 -0
- package/lib/types/components/sidePanel/btw/useBtwComposerPaste.js +94 -0
- package/lib/types/components/sidePanel/builtinPanels.d.ts.map +1 -1
- package/lib/types/components/sidePanel/builtinPanels.js +14 -2
- package/lib/types/components/sidePanel/types.d.ts +2 -0
- package/lib/types/components/sidePanel/types.d.ts.map +1 -1
- package/lib/types/components/sidePanel/useSidePanel.d.ts.map +1 -1
- package/lib/types/components/sidePanel/useSidePanel.js +15 -1
- package/lib/types/dsh-adapter/backend/session.d.ts +7 -1
- package/lib/types/dsh-adapter/backend/session.d.ts.map +1 -1
- package/lib/types/dsh-adapter/backend/session.js +62 -6
- package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
- package/lib/types/dsh-adapter/backend/translate.js +9 -5
- package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/agent-view-projection.js +3 -1
- package/lib/types/dsh-adapter/channel/composer-images.d.ts +2 -0
- package/lib/types/dsh-adapter/channel/composer-images.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/composer-images.js +10 -2
- package/lib/types/dsh-adapter/channel/composer-mentions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/composer-mentions.js +22 -7
- package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/context-bookkeeping.js +9 -5
- package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts +6 -0
- package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/core/binding-feed.js +35 -1
- package/lib/types/dsh-adapter/channel/core/compose.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/core/compose.js +5 -0
- package/lib/types/dsh-adapter/channel/input-actions.d.ts +2 -2
- package/lib/types/dsh-adapter/channel/input-actions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/input-actions.js +30 -0
- package/lib/types/dsh-adapter/channel/input-delivery.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/input-delivery.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/input-delivery.js +8 -4
- package/lib/types/dsh-adapter/channel/mentions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/mentions.js +21 -7
- package/lib/types/dsh-adapter/channel/paths.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/paths.js +11 -9
- package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-live-adoption.js +6 -1
- package/lib/types/dsh-adapter/channel/session-reset.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-reset.js +3 -1
- package/lib/types/dsh-adapter/channel/session-resume.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/session-resume.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-resume.js +10 -3
- package/lib/types/dsh-adapter/channel/session-rewind.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/session-rewind.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-rewind.js +3 -1
- package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-tree-actions.js +3 -1
- package/lib/types/dsh-adapter/contract.d.ts +4 -3
- package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
- package/lib/types/dsh-adapter/contract.js +6 -3
- package/lib/types/dsh-adapter/entry-slot.d.ts +6 -0
- package/lib/types/dsh-adapter/entry-slot.d.ts.map +1 -1
- package/lib/types/dsh-adapter/experimental-bundles.d.ts +3 -0
- package/lib/types/dsh-adapter/experimental-bundles.d.ts.map +1 -1
- package/lib/types/dsh-adapter/experimental-bundles.js +4 -0
- package/lib/types/dsh-adapter/grant-file.d.ts +70 -0
- package/lib/types/dsh-adapter/grant-file.d.ts.map +1 -0
- package/lib/types/dsh-adapter/grant-file.js +178 -0
- package/lib/types/dsh-adapter/host-access.d.ts +4 -0
- package/lib/types/dsh-adapter/host-access.d.ts.map +1 -1
- package/lib/types/dsh-adapter/host-access.js +54 -4
- package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
- package/lib/types/dsh-adapter/host-contract.js +2 -2
- package/lib/types/dsh-adapter/host-dsh.js +3 -3
- package/lib/types/dsh-adapter/index.d.ts.map +1 -1
- package/lib/types/dsh-adapter/index.js +8 -5
- package/lib/types/dsh-adapter/panels.d.ts +7 -1
- package/lib/types/dsh-adapter/panels.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin-declaration.d.ts +28 -0
- package/lib/types/dsh-adapter/plugin-declaration.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin-declaration.js +43 -1
- package/lib/types/dsh-adapter/plugin-install.d.ts +28 -1
- package/lib/types/dsh-adapter/plugin-install.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin-install.js +160 -13
- package/lib/types/dsh-adapter/plugin-manage.d.ts +53 -10
- package/lib/types/dsh-adapter/plugin-manage.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin-manage.js +240 -51
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin.js +64 -18
- package/lib/types/dsh-adapter/plugins-info.d.ts +6 -7
- package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugins-info.js +34 -21
- package/lib/types/dsh-adapter/presets.d.ts +6 -2
- package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
- package/lib/types/dsh-adapter/presets.js +23 -5
- package/lib/types/dsh-adapter/process-exit.d.ts +1 -1
- package/lib/types/dsh-adapter/process-exit.js +1 -1
- package/lib/types/dsh-adapter/providerWizard.d.ts +2 -0
- package/lib/types/dsh-adapter/providerWizard.d.ts.map +1 -1
- package/lib/types/dsh-adapter/providerWizard.js +11 -5
- package/lib/types/dsh-adapter/row-attachment.d.ts +30 -0
- package/lib/types/dsh-adapter/row-attachment.d.ts.map +1 -0
- package/lib/types/dsh-adapter/row-attachment.js +29 -0
- package/lib/types/dsh-adapter/worktree-tool.d.ts +27 -0
- package/lib/types/dsh-adapter/worktree-tool.d.ts.map +1 -0
- package/lib/types/dsh-adapter/worktree-tool.js +87 -0
- package/lib/types/heldInputs.d.ts +36 -0
- package/lib/types/heldInputs.d.ts.map +1 -0
- package/lib/types/heldInputs.js +173 -0
- package/lib/types/i18n.d.ts +352 -25
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +171 -18
- package/lib/types/onboardingDraft.d.ts +143 -0
- package/lib/types/onboardingDraft.d.ts.map +1 -0
- package/lib/types/onboardingDraft.js +71 -0
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +90 -30
- package/lib/types/screens/Onboarding.d.ts +22 -3
- package/lib/types/screens/Onboarding.d.ts.map +1 -1
- package/lib/types/screens/Onboarding.js +606 -36
- package/lib/types/settings/definitions.js +2 -2
- package/lib/types/utils/paths.d.ts +15 -0
- package/lib/types/utils/paths.d.ts.map +1 -1
- package/lib/types/utils/paths.js +25 -0
- package/package.json +111 -108
- package/tui-profile/feed/README.md +1 -1
- package/tui-profile/feed/first-party.json +1 -1
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { statSync } from 'node:fs';
|
|
2
2
|
import { isAbsolute } from 'node:path';
|
|
3
|
+
import { readGrantStore } from '../adapter/standard/grants.js';
|
|
4
|
+
import { adapterRuntimeFor } from '../adapter/kernel/runtime-context.js';
|
|
3
5
|
import { t } from '../i18n.js';
|
|
4
6
|
import { installedTuiVersion, resolveDshProfileName } from '../update.js';
|
|
5
|
-
import { COMPOSITION_PACKAGE } from './plugin-declaration.js';
|
|
7
|
+
import { COMPOSITION_PACKAGE, declaredGrantsAt, declaredGrantsIn, pluginDeclarationIn } from './plugin-declaration.js';
|
|
8
|
+
import { applyGrantMutation, grantFailureText, grantsFilePath, planGrants } from './grant-file.js';
|
|
9
|
+
import { getHostGrantStore } from './host-grants.js';
|
|
6
10
|
import { firstPartyVerdict, loadFirstPartyFeed } from './plugin-feed.js';
|
|
7
11
|
import { newInstallRequestId, pluginInstallEvents, pluginManagerOf } from './plugin-manager.js';
|
|
8
12
|
import { cell, declarationNoticeFor, parsePluginArgs } from './plugins-info.js';
|
|
@@ -85,6 +89,14 @@ export function createPluginInstallFlow(options) {
|
|
|
85
89
|
* screen close the pane over work that is still going on.
|
|
86
90
|
*/
|
|
87
91
|
let cancelling;
|
|
92
|
+
/** The declaration read before the install, when the target is a directory. */
|
|
93
|
+
let declared;
|
|
94
|
+
/** The plan the current step shows: the install's, or the post-install one. */
|
|
95
|
+
let grantPlan;
|
|
96
|
+
/** Whether a person answered a confirmation: a grant they did not see is reported apart. */
|
|
97
|
+
let confirmed = false;
|
|
98
|
+
/** Declared permission names this host does not know, already named in the transcript. */
|
|
99
|
+
const reportedUnknown = new Set();
|
|
88
100
|
const disposers = [];
|
|
89
101
|
/** Whether the session that asked is still bound; false drops every write. */
|
|
90
102
|
const live = () => options.binding() === bindingAtStart;
|
|
@@ -94,15 +106,77 @@ export function createPluginInstallFlow(options) {
|
|
|
94
106
|
options.onLines(lines);
|
|
95
107
|
};
|
|
96
108
|
const tailLines = () => logTail.map(line => ` ${line}`);
|
|
109
|
+
/**
|
|
110
|
+
* Name the declared permissions this host does not know, once per flow.
|
|
111
|
+
*
|
|
112
|
+
* Two answers can carry the same plan — the post-install step names them
|
|
113
|
+
* before it asks, then `ensureGrants` runs when the person answers — and a
|
|
114
|
+
* retry (`approve`/`acceptRisk`) re-runs the write. Reporting through here
|
|
115
|
+
* keeps one line per name without dropping the names a later plan adds.
|
|
116
|
+
*/
|
|
117
|
+
function reportUnknown(names) {
|
|
118
|
+
const fresh = names.filter(name => !reportedUnknown.has(name));
|
|
119
|
+
if (fresh.length === 0)
|
|
120
|
+
return;
|
|
121
|
+
for (const name of fresh)
|
|
122
|
+
reportedUnknown.add(name);
|
|
123
|
+
emit([t('plugins-grant-unknown-skipped', { names: cell(fresh.join(', ')) })]);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Write one plan's declared permissions, reporting whatever could not be
|
|
127
|
+
* written. Authorization is an enhancement here, never a precondition: a
|
|
128
|
+
* corrupt grants file gets one line and the install carries on.
|
|
129
|
+
*/
|
|
130
|
+
async function ensureGrants(plan) {
|
|
131
|
+
const grantStore = options.grants;
|
|
132
|
+
const write = await applyGrantMutation({ kind: 'ensure', id: plan.id, permissions: plan.entries }, {
|
|
133
|
+
dataDir: options.grantsDataDir,
|
|
134
|
+
knownPermissions: grantStore?.knownPermissions(),
|
|
135
|
+
});
|
|
136
|
+
if (!write.ok) {
|
|
137
|
+
emit([t('plugins-grant-write-refused', {
|
|
138
|
+
file: cell(grantsFilePath(options.grantsDataDir)),
|
|
139
|
+
reason: grantFailureText(write),
|
|
140
|
+
})]);
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
reportUnknown(plan.unknown);
|
|
144
|
+
if (write.changed) {
|
|
145
|
+
emit([t(confirmed ? 'plugins-install-granted' : 'plugins-install-granted-silent', {
|
|
146
|
+
count: String(plan.entries.length),
|
|
147
|
+
id: cell(plan.id),
|
|
148
|
+
})]);
|
|
149
|
+
}
|
|
150
|
+
// A written scope this host still refuses was not enforceable to begin
|
|
151
|
+
// with (an unsupported scope, or a deny that outranks it): say so once.
|
|
152
|
+
if (grantStore !== undefined) {
|
|
153
|
+
const unapplied = plan.entries.filter(entry => !grantStore.allows({ componentId: plan.id }, entry.name, entry.scope));
|
|
154
|
+
if (unapplied.length > 0) {
|
|
155
|
+
emit([t('plugins-grant-unapplied', {
|
|
156
|
+
scopes: cell(unapplied.map(entry => `${entry.name}@${entry.scope}`).join(', ')),
|
|
157
|
+
})]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return write;
|
|
161
|
+
}
|
|
162
|
+
/** A failure after the grant was written: put the file back, or say why not. */
|
|
163
|
+
async function rollbackGrant(write) {
|
|
164
|
+
if (write === undefined || !write.changed)
|
|
165
|
+
return;
|
|
166
|
+
const restored = await write.undo();
|
|
167
|
+
emit([t(restored ? 'plugins-grant-rolled-back' : 'plugins-grant-rollback-failed')]);
|
|
168
|
+
}
|
|
97
169
|
/**
|
|
98
170
|
* A turn is running: nothing is asked and no service is called. Checked at
|
|
99
|
-
*
|
|
100
|
-
* because a turn can start while the
|
|
171
|
+
* every end of the wait — before the inspection, before the install's grant,
|
|
172
|
+
* and again before the profile write — because a turn can start while the
|
|
173
|
+
* pane is waiting for an answer. The reason line is the caller's: the
|
|
174
|
+
* post-install grant step is not an install and must not say it is.
|
|
101
175
|
*/
|
|
102
|
-
function refuseWhileBusy() {
|
|
176
|
+
function refuseWhileBusy(reason = 'plugins-install-busy') {
|
|
103
177
|
if (!options.busy())
|
|
104
178
|
return undefined;
|
|
105
|
-
emit([t(
|
|
179
|
+
emit([t(reason)]);
|
|
106
180
|
return { kind: 'done' };
|
|
107
181
|
}
|
|
108
182
|
/**
|
|
@@ -225,17 +299,23 @@ export function createPluginInstallFlow(options) {
|
|
|
225
299
|
if (trust.kind === 'first-party') {
|
|
226
300
|
emit([t('plugins-install-trusted', { name: cell(trust.entry.name), version: cell(trust.entry.version) })]);
|
|
227
301
|
}
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
302
|
+
const directory = options.specDirectory?.(options.spec);
|
|
303
|
+
const notice = options.noticeOf({ name: read.name, directory });
|
|
304
|
+
// The permissions a confirmation can grant are read from the target itself,
|
|
305
|
+
// not from an already-installed package of the same name: a registry spec
|
|
306
|
+
// has no declaration on this machine yet (`notice.kind === 'unjudged'`), so
|
|
307
|
+
// its list arrives after the install as a `grant` step.
|
|
308
|
+
declared = directory === undefined ? undefined : options.declaredGrantsOf?.(directory);
|
|
309
|
+
grantPlan = declared === undefined || options.grants === undefined
|
|
310
|
+
? undefined
|
|
311
|
+
: planGrants(options.grants, declared);
|
|
232
312
|
// Gate 1 is a notice, never a veto: it is shown whenever it has something to
|
|
233
313
|
// say. A first-party package with a readable, accepted declaration is the one
|
|
234
314
|
// case with nothing to ask about — that is what skipping the trust
|
|
235
315
|
// confirmation means. It does not skip the ledger or the list.
|
|
236
316
|
if (trust.kind === 'first-party' && notice.kind === 'declared')
|
|
237
317
|
return { kind: 'done' };
|
|
238
|
-
return { kind: 'confirm', artifact: read, trust, notice };
|
|
318
|
+
return { kind: 'confirm', artifact: read, trust, notice, grants: grantPlan };
|
|
239
319
|
}
|
|
240
320
|
/**
|
|
241
321
|
* The profile's current exemptions. `listVersionExemptions()` is the one
|
|
@@ -264,6 +344,12 @@ export function createPluginInstallFlow(options) {
|
|
|
264
344
|
const refused = refuseWhileBusy();
|
|
265
345
|
if (refused !== undefined)
|
|
266
346
|
return refused;
|
|
347
|
+
// Grant first, install second: `installBundle` applies or reloads the
|
|
348
|
+
// plugin as part of the run, and a plugin that activates before its grants
|
|
349
|
+
// are on disk negotiates as `waiting_authorization` — registered, but kept
|
|
350
|
+
// out of the picker until a restart. Writing first closes that window.
|
|
351
|
+
const plan = grantPlan;
|
|
352
|
+
const grantWrite = plan === undefined ? undefined : await ensureGrants(plan);
|
|
267
353
|
const installSpec = installSpecOf(read, options.spec);
|
|
268
354
|
let result;
|
|
269
355
|
try {
|
|
@@ -277,6 +363,7 @@ export function createPluginInstallFlow(options) {
|
|
|
277
363
|
}
|
|
278
364
|
catch (error) {
|
|
279
365
|
emit([t('plugins-install-failed', { reason: cell(error instanceof Error ? error.message : String(error)) })]);
|
|
366
|
+
await rollbackGrant(grantWrite);
|
|
280
367
|
return { kind: 'done' };
|
|
281
368
|
}
|
|
282
369
|
finally {
|
|
@@ -294,17 +381,26 @@ export function createPluginInstallFlow(options) {
|
|
|
294
381
|
if (result.approvedBuilds !== undefined)
|
|
295
382
|
approvedBuilds = undefined;
|
|
296
383
|
// The cancel path reports itself; an install that ends `cancelled` after it
|
|
297
|
-
// must not report a second, contradictory ending.
|
|
298
|
-
|
|
384
|
+
// must not report a second, contradictory ending. Nothing landed, so the
|
|
385
|
+
// grant written before the run goes back too.
|
|
386
|
+
if (result.application === 'cancelled') {
|
|
387
|
+
await rollbackGrant(grantWrite);
|
|
299
388
|
return { kind: 'done' };
|
|
389
|
+
}
|
|
300
390
|
const builds = result.pendingBuilds ?? [];
|
|
301
391
|
if (builds.length > 0) {
|
|
392
|
+
// The retry (`approve`) runs `run()` again and grants again; keeping the
|
|
393
|
+
// grant across a run that never landed would leave it for a package that
|
|
394
|
+
// may never be installed.
|
|
395
|
+
await rollbackGrant(grantWrite);
|
|
302
396
|
emit([t('plugins-install-build-blocked', { count: String(builds.length) })]);
|
|
303
397
|
return { kind: 'build-blocked', builds };
|
|
304
398
|
}
|
|
305
399
|
if (result.application === 'failed') {
|
|
306
400
|
incompatible = result.error?.code === 'incompatible-version' ? result.error.incompatible ?? [] : [];
|
|
307
401
|
if (incompatible.length > 0) {
|
|
402
|
+
// `acceptRisk()` retries through `run()`, which grants again.
|
|
403
|
+
await rollbackGrant(grantWrite);
|
|
308
404
|
emit([t('plugins-install-incompatible', {
|
|
309
405
|
packages: incompatible.map(entry => `${cell(entry.name)}@${cell(entry.version)}`).join(', '),
|
|
310
406
|
runtime: cell(incompatible[0]?.runtimeVersion ?? ''),
|
|
@@ -321,6 +417,7 @@ export function createPluginInstallFlow(options) {
|
|
|
321
417
|
t('plugins-install-manual', { profile: cell(options.profileName ?? 'dsh-tui'), spec: cell(installSpec) }),
|
|
322
418
|
t('plugins-install-rescue'),
|
|
323
419
|
]);
|
|
420
|
+
await rollbackGrant(grantWrite);
|
|
324
421
|
return { kind: 'done' };
|
|
325
422
|
}
|
|
326
423
|
const bundle = result.bundle ?? read.name ?? options.spec;
|
|
@@ -332,6 +429,22 @@ export function createPluginInstallFlow(options) {
|
|
|
332
429
|
...result.application === 'restart-required' ? [t('plugins-install-restart-hint')] : [],
|
|
333
430
|
]);
|
|
334
431
|
await reportDrift();
|
|
432
|
+
// The declaration of a registry package was not readable before it landed.
|
|
433
|
+
// It is now: offer the list once, or finish when everything it asks for is
|
|
434
|
+
// already granted (a default-allow permission needs no rule).
|
|
435
|
+
if (plan === undefined) {
|
|
436
|
+
const installed = options.installedGrantsOf?.(bundle);
|
|
437
|
+
const post = installed === undefined || options.grants === undefined
|
|
438
|
+
? undefined
|
|
439
|
+
: planGrants(options.grants, installed);
|
|
440
|
+
if (post !== undefined) {
|
|
441
|
+
reportUnknown(post.unknown);
|
|
442
|
+
if (post.entries.some(entry => !entry.granted)) {
|
|
443
|
+
grantPlan = post;
|
|
444
|
+
return { kind: 'grant', plan: post };
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
335
448
|
return { kind: 'done' };
|
|
336
449
|
}
|
|
337
450
|
/**
|
|
@@ -424,7 +537,28 @@ export function createPluginInstallFlow(options) {
|
|
|
424
537
|
return step.kind === 'confirm' ? step : run();
|
|
425
538
|
},
|
|
426
539
|
async confirm() {
|
|
427
|
-
|
|
540
|
+
if (stopped)
|
|
541
|
+
return { kind: 'done' };
|
|
542
|
+
confirmed = true;
|
|
543
|
+
return run();
|
|
544
|
+
},
|
|
545
|
+
async grant() {
|
|
546
|
+
if (stopped)
|
|
547
|
+
return { kind: 'done' };
|
|
548
|
+
const plan = grantPlan;
|
|
549
|
+
if (plan === undefined)
|
|
550
|
+
return { kind: 'done' };
|
|
551
|
+
// The post-install step can be on screen when a turn starts. Granting is a
|
|
552
|
+
// write the running turn would immediately see (the decision guard reads
|
|
553
|
+
// the file per decision), so it waits for the same idle window as the
|
|
554
|
+
// pre-install grant and the profile write. The refusal answers with the
|
|
555
|
+
// same step, never `done`: `done` closes the pane (usePluginWriteFlow),
|
|
556
|
+
// and the person would have no way left to grant once the turn is over.
|
|
557
|
+
// `/plugin enable` stays the repair path if they close the pane instead.
|
|
558
|
+
if (refuseWhileBusy('plugins-install-grant-busy') !== undefined)
|
|
559
|
+
return { kind: 'grant', plan };
|
|
560
|
+
await ensureGrants(plan);
|
|
561
|
+
return { kind: 'done' };
|
|
428
562
|
},
|
|
429
563
|
async approve(builds) {
|
|
430
564
|
if (stopped)
|
|
@@ -500,6 +634,10 @@ export function createPluginInstallEntry(ctx, options = {}) {
|
|
|
500
634
|
const manager = pluginManagerOf(ctx);
|
|
501
635
|
if (manager === undefined)
|
|
502
636
|
return undefined;
|
|
637
|
+
// The live store the report and the plugin-host row share; a bare mount
|
|
638
|
+
// falls back to the same file-backed store with this composition's policy.
|
|
639
|
+
const grants = getHostGrantStore(ctx.get('tuiPluginHost'))
|
|
640
|
+
?? readGrantStore(undefined, undefined, adapterRuntimeFor(ctx));
|
|
503
641
|
return createPluginInstallFlow({
|
|
504
642
|
manager,
|
|
505
643
|
events: pluginInstallEvents(ctx),
|
|
@@ -518,6 +656,15 @@ export function createPluginInstallEntry(ctx, options = {}) {
|
|
|
518
656
|
onLines: sink.onLines,
|
|
519
657
|
ownVersion: options.ownVersion ?? installedTuiVersion(),
|
|
520
658
|
profileName: options.profileName ?? resolveDshProfileName(),
|
|
659
|
+
grants,
|
|
660
|
+
// A path spec's declaration is on disk before the install; a registry
|
|
661
|
+
// spec's only becomes readable after it. Two readers of one function
|
|
662
|
+
// (`declaredGrantsIn`/`declaredGrantsAt`), never a second parser here.
|
|
663
|
+
declaredGrantsOf: directory => {
|
|
664
|
+
const declaration = pluginDeclarationIn(directory);
|
|
665
|
+
return declaration === undefined ? undefined : declaredGrantsIn(declaration.source);
|
|
666
|
+
},
|
|
667
|
+
installedGrantsOf: name => declaredGrantsAt(ctx, name),
|
|
521
668
|
});
|
|
522
669
|
};
|
|
523
670
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import type { PluginEntryId } from '@deepseek-ai/dsh-plugin-manager/types';
|
|
3
|
+
import { type GrantStore } from '../adapter/standard/grants.js';
|
|
4
|
+
import { type GrantPlan } from './grant-file.js';
|
|
5
|
+
import { type DeclaredGrants } from './plugin-declaration.js';
|
|
3
6
|
import { type PluginGuardAction } from './plugin-guard.js';
|
|
4
7
|
import { type PluginManagerView } from './plugin-manager.js';
|
|
5
8
|
/** The three lifecycle actions. */
|
|
@@ -77,6 +80,13 @@ export type PluginManageStep = {
|
|
|
77
80
|
readonly kind: 'confirm';
|
|
78
81
|
readonly target: PluginManageTarget;
|
|
79
82
|
readonly question: PluginManageQuestion;
|
|
83
|
+
/**
|
|
84
|
+
* The bundle's declared permissions, when its declaration was readable
|
|
85
|
+
* before the write: what an enable grants, what a disable revokes, and the
|
|
86
|
+
* id a removal forgets. `undefined` for a row target and for a bundle with
|
|
87
|
+
* no readable declaration.
|
|
88
|
+
*/
|
|
89
|
+
readonly grants: GrantPlan | undefined;
|
|
80
90
|
} | {
|
|
81
91
|
readonly kind: 'done';
|
|
82
92
|
};
|
|
@@ -99,6 +109,22 @@ export interface PluginManageSink {
|
|
|
99
109
|
* not worth a line.
|
|
100
110
|
*/
|
|
101
111
|
export type PluginResidueWatch = () => readonly string[] | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* What one bundle's package-root declaration says, read **before** the write
|
|
114
|
+
* (for a removal, while the package is still installed).
|
|
115
|
+
*
|
|
116
|
+
* `undefined` means the package ships no declaration, so nothing claims a
|
|
117
|
+
* component id. `unreadable` means a declaration exists but this host cannot
|
|
118
|
+
* read it: that is reported rather than guessed at, because guessing an id
|
|
119
|
+
* would write a grant for some other package.
|
|
120
|
+
*/
|
|
121
|
+
export type PluginBundleDeclaration = {
|
|
122
|
+
readonly kind: 'declared';
|
|
123
|
+
readonly grants: DeclaredGrants | undefined;
|
|
124
|
+
readonly residue: PluginResidueWatch | undefined;
|
|
125
|
+
} | {
|
|
126
|
+
readonly kind: 'unreadable';
|
|
127
|
+
};
|
|
102
128
|
export interface PluginManageFlowOptions {
|
|
103
129
|
readonly manager: PluginManagerView;
|
|
104
130
|
readonly action: PluginManageAction;
|
|
@@ -117,12 +143,16 @@ export interface PluginManageFlowOptions {
|
|
|
117
143
|
/** The profile an action belongs to, for the manual commands. */
|
|
118
144
|
readonly profileName?: string | undefined;
|
|
119
145
|
/**
|
|
120
|
-
* The
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
146
|
+
* The bundle's declaration, read while it is still installed: its grants
|
|
147
|
+
* (what enable grants, disable revokes, removal forgets) and the residue
|
|
148
|
+
* watch a removal consults after the write. One read, so the two answers
|
|
149
|
+
* cannot come from different copies of the declaration.
|
|
124
150
|
*/
|
|
125
|
-
readonly
|
|
151
|
+
readonly declarationOf?: ((name: string) => PluginBundleDeclaration | undefined) | undefined;
|
|
152
|
+
/** The live grant store: what is granted now and which names this host knows. */
|
|
153
|
+
readonly grants?: GrantStore | undefined;
|
|
154
|
+
/** Test override for the grants file's directory. */
|
|
155
|
+
readonly grantsDataDir?: string | undefined;
|
|
126
156
|
/**
|
|
127
157
|
* Teammates of the bound session that are running or provisioning, and
|
|
128
158
|
* those that may be running. Read when `disable` resolves to the Agent
|
|
@@ -151,11 +181,11 @@ export declare function createPluginManageFlow(options: PluginManageFlowOptions)
|
|
|
151
181
|
* through (the screen then runs the read-only report, which is where the CLI
|
|
152
182
|
* route is printed).
|
|
153
183
|
*
|
|
154
|
-
* This is the one place that knows how a
|
|
155
|
-
* composition, and the only place that touches the person's own data.
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
184
|
+
* This is the one place that knows how a lifecycle action is wired to the
|
|
185
|
+
* running composition, and the only place that touches the person's own data.
|
|
186
|
+
* The bundle's declaration is read here, **while it is still installed**: its
|
|
187
|
+
* grants and the residue watch both come from a file inside the package, so
|
|
188
|
+
* both are unreadable once the bundle has left.
|
|
159
189
|
*/
|
|
160
190
|
export declare function createPluginManageEntry(ctx: Context, options?: {
|
|
161
191
|
readonly profileName?: string | undefined;
|
|
@@ -175,4 +205,17 @@ export declare function createPluginManageEntry(ctx: Context, options?: {
|
|
|
175
205
|
* is not evidence of a clean removal, only of an unanswerable question.
|
|
176
206
|
*/
|
|
177
207
|
export declare function residueWatchOf(ctx: Context, name: string, dataRoot?: string): PluginResidueWatch | undefined;
|
|
208
|
+
/**
|
|
209
|
+
* Read one installed bundle's declaration once, before any lifecycle write.
|
|
210
|
+
*
|
|
211
|
+
* The declaration is the package's own file, so it has to be read while the
|
|
212
|
+
* package is still there: after a removal it is gone, and after an enable or
|
|
213
|
+
* disable the grants half still has to name the component id. The raw parse
|
|
214
|
+
* feeds both answers — the residue watch (which trusts the declaration's own
|
|
215
|
+
* `id`/Backend ids, as before) and the grants reader (which applies the same
|
|
216
|
+
* parse/projection gates every other consumer does). A file that exists but
|
|
217
|
+
* cannot be read is `unreadable`, never "no declaration": the two lead to
|
|
218
|
+
* different reports.
|
|
219
|
+
*/
|
|
220
|
+
export declare function bundleDeclarationOf(ctx: Context, name: string, dataRoot?: string): PluginBundleDeclaration | undefined;
|
|
178
221
|
//# sourceMappingURL=plugin-manage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-manage.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/plugin-manage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-manage.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/plugin-manage.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAA4B,aAAa,EAAc,MAAM,uCAAuC,CAAA;AAChH,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAK/E,OAAO,EAAoE,KAAK,SAAS,EAA0B,MAAM,iBAAiB,CAAA;AAC1I,OAAO,EAAkF,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAG7I,OAAO,EAEL,KAAK,iBAAiB,EAIvB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAK7E,mCAA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