@dsh-cc/tui 0.5.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/LICENSE +201 -0
- package/README.md +144 -0
- package/lib/bash-history.d.ts +31 -0
- package/lib/bash-history.d.ts.map +1 -0
- package/lib/bash-history.js +94 -0
- package/lib/bash-history.js.map +1 -0
- package/lib/compact-fold.d.ts +35 -0
- package/lib/compact-fold.d.ts.map +1 -0
- package/lib/compact-fold.js +60 -0
- package/lib/compact-fold.js.map +1 -0
- package/lib/components/arg-completers.d.ts +22 -0
- package/lib/components/arg-completers.d.ts.map +1 -0
- package/lib/components/arg-completers.js +75 -0
- package/lib/components/arg-completers.js.map +1 -0
- package/lib/components/code-theme.d.ts +25 -0
- package/lib/components/code-theme.d.ts.map +1 -0
- package/lib/components/code-theme.js +137 -0
- package/lib/components/code-theme.js.map +1 -0
- package/lib/components/completion.d.ts +50 -0
- package/lib/components/completion.d.ts.map +1 -0
- package/lib/components/completion.js +279 -0
- package/lib/components/completion.js.map +1 -0
- package/lib/components/diff-card.d.ts +29 -0
- package/lib/components/diff-card.d.ts.map +1 -0
- package/lib/components/diff-card.js +175 -0
- package/lib/components/diff-card.js.map +1 -0
- package/lib/components/diff-hunks.d.ts +44 -0
- package/lib/components/diff-hunks.d.ts.map +1 -0
- package/lib/components/diff-hunks.js +188 -0
- package/lib/components/diff-hunks.js.map +1 -0
- package/lib/components/editor-history.d.ts +23 -0
- package/lib/components/editor-history.d.ts.map +1 -0
- package/lib/components/editor-history.js +29 -0
- package/lib/components/editor-history.js.map +1 -0
- package/lib/components/markdown-theme.d.ts +11 -0
- package/lib/components/markdown-theme.d.ts.map +1 -0
- package/lib/components/markdown-theme.js +29 -0
- package/lib/components/markdown-theme.js.map +1 -0
- package/lib/components/masked-input.d.ts +24 -0
- package/lib/components/masked-input.d.ts.map +1 -0
- package/lib/components/masked-input.js +168 -0
- package/lib/components/masked-input.js.map +1 -0
- package/lib/components/overlay-host.d.ts +31 -0
- package/lib/components/overlay-host.d.ts.map +1 -0
- package/lib/components/overlay-host.js +128 -0
- package/lib/components/overlay-host.js.map +1 -0
- package/lib/components/overlays.d.ts +94 -0
- package/lib/components/overlays.d.ts.map +1 -0
- package/lib/components/overlays.js +450 -0
- package/lib/components/overlays.js.map +1 -0
- package/lib/components/provider-box.d.ts +23 -0
- package/lib/components/provider-box.d.ts.map +1 -0
- package/lib/components/provider-box.js +164 -0
- package/lib/components/provider-box.js.map +1 -0
- package/lib/components/read-group.d.ts +51 -0
- package/lib/components/read-group.d.ts.map +1 -0
- package/lib/components/read-group.js +105 -0
- package/lib/components/read-group.js.map +1 -0
- package/lib/components/root-bash.d.ts +36 -0
- package/lib/components/root-bash.d.ts.map +1 -0
- package/lib/components/root-bash.js +112 -0
- package/lib/components/root-bash.js.map +1 -0
- package/lib/components/root-types.d.ts +42 -0
- package/lib/components/root-types.d.ts.map +1 -0
- package/lib/components/root-types.js +8 -0
- package/lib/components/root-types.js.map +1 -0
- package/lib/components/root-utils.d.ts +22 -0
- package/lib/components/root-utils.d.ts.map +1 -0
- package/lib/components/root-utils.js +45 -0
- package/lib/components/root-utils.js.map +1 -0
- package/lib/components/root.d.ts +25 -0
- package/lib/components/root.d.ts.map +1 -0
- package/lib/components/root.js +357 -0
- package/lib/components/root.js.map +1 -0
- package/lib/components/theme.d.ts +61 -0
- package/lib/components/theme.d.ts.map +1 -0
- package/lib/components/theme.js +99 -0
- package/lib/components/theme.js.map +1 -0
- package/lib/components/transcript.d.ts +43 -0
- package/lib/components/transcript.d.ts.map +1 -0
- package/lib/components/transcript.js +203 -0
- package/lib/components/transcript.js.map +1 -0
- package/lib/components/working-line.d.ts +35 -0
- package/lib/components/working-line.d.ts.map +1 -0
- package/lib/components/working-line.js +66 -0
- package/lib/components/working-line.js.map +1 -0
- package/lib/effort-catalog.d.ts +27 -0
- package/lib/effort-catalog.d.ts.map +1 -0
- package/lib/effort-catalog.js +36 -0
- package/lib/effort-catalog.js.map +1 -0
- package/lib/export-markdown.d.ts +18 -0
- package/lib/export-markdown.d.ts.map +1 -0
- package/lib/export-markdown.js +124 -0
- package/lib/export-markdown.js.map +1 -0
- package/lib/harness/approval-preview.d.ts +33 -0
- package/lib/harness/approval-preview.d.ts.map +1 -0
- package/lib/harness/approval-preview.js +179 -0
- package/lib/harness/approval-preview.js.map +1 -0
- package/lib/harness/boot-banner.d.ts +14 -0
- package/lib/harness/boot-banner.d.ts.map +1 -0
- package/lib/harness/boot-banner.js +89 -0
- package/lib/harness/boot-banner.js.map +1 -0
- package/lib/harness/driver-agent.d.ts +78 -0
- package/lib/harness/driver-agent.d.ts.map +1 -0
- package/lib/harness/driver-agent.js +314 -0
- package/lib/harness/driver-agent.js.map +1 -0
- package/lib/harness/driver-agents.d.ts +20 -0
- package/lib/harness/driver-agents.d.ts.map +1 -0
- package/lib/harness/driver-agents.js +123 -0
- package/lib/harness/driver-agents.js.map +1 -0
- package/lib/harness/driver-approvals.d.ts +38 -0
- package/lib/harness/driver-approvals.d.ts.map +1 -0
- package/lib/harness/driver-approvals.js +277 -0
- package/lib/harness/driver-approvals.js.map +1 -0
- package/lib/harness/driver-bash.d.ts +15 -0
- package/lib/harness/driver-bash.d.ts.map +1 -0
- package/lib/harness/driver-bash.js +73 -0
- package/lib/harness/driver-bash.js.map +1 -0
- package/lib/harness/driver-catalog.d.ts +84 -0
- package/lib/harness/driver-catalog.d.ts.map +1 -0
- package/lib/harness/driver-catalog.js +256 -0
- package/lib/harness/driver-catalog.js.map +1 -0
- package/lib/harness/driver-ctx.d.ts +462 -0
- package/lib/harness/driver-ctx.d.ts.map +1 -0
- package/lib/harness/driver-ctx.js +11 -0
- package/lib/harness/driver-ctx.js.map +1 -0
- package/lib/harness/driver-hud.d.ts +31 -0
- package/lib/harness/driver-hud.d.ts.map +1 -0
- package/lib/harness/driver-hud.js +204 -0
- package/lib/harness/driver-hud.js.map +1 -0
- package/lib/harness/driver-live.d.ts +36 -0
- package/lib/harness/driver-live.d.ts.map +1 -0
- package/lib/harness/driver-live.js +44 -0
- package/lib/harness/driver-live.js.map +1 -0
- package/lib/harness/driver-modal.d.ts +52 -0
- package/lib/harness/driver-modal.d.ts.map +1 -0
- package/lib/harness/driver-modal.js +78 -0
- package/lib/harness/driver-modal.js.map +1 -0
- package/lib/harness/driver-mode.d.ts +35 -0
- package/lib/harness/driver-mode.d.ts.map +1 -0
- package/lib/harness/driver-mode.js +84 -0
- package/lib/harness/driver-mode.js.map +1 -0
- package/lib/harness/driver-pickers.d.ts +48 -0
- package/lib/harness/driver-pickers.d.ts.map +1 -0
- package/lib/harness/driver-pickers.js +249 -0
- package/lib/harness/driver-pickers.js.map +1 -0
- package/lib/harness/driver-promote.d.ts +29 -0
- package/lib/harness/driver-promote.d.ts.map +1 -0
- package/lib/harness/driver-promote.js +36 -0
- package/lib/harness/driver-promote.js.map +1 -0
- package/lib/harness/driver-queue.d.ts +19 -0
- package/lib/harness/driver-queue.d.ts.map +1 -0
- package/lib/harness/driver-queue.js +281 -0
- package/lib/harness/driver-queue.js.map +1 -0
- package/lib/harness/driver-run-local.d.ts +32 -0
- package/lib/harness/driver-run-local.d.ts.map +1 -0
- package/lib/harness/driver-run-local.js +366 -0
- package/lib/harness/driver-run-local.js.map +1 -0
- package/lib/harness/driver-sessions.d.ts +28 -0
- package/lib/harness/driver-sessions.d.ts.map +1 -0
- package/lib/harness/driver-sessions.js +386 -0
- package/lib/harness/driver-sessions.js.map +1 -0
- package/lib/harness/driver.d.ts +22 -0
- package/lib/harness/driver.d.ts.map +1 -0
- package/lib/harness/driver.js +459 -0
- package/lib/harness/driver.js.map +1 -0
- package/lib/harness/preset.d.ts +32 -0
- package/lib/harness/preset.d.ts.map +1 -0
- package/lib/harness/preset.js +34 -0
- package/lib/harness/preset.js.map +1 -0
- package/lib/harness/session-list.d.ts +65 -0
- package/lib/harness/session-list.d.ts.map +1 -0
- package/lib/harness/session-list.js +91 -0
- package/lib/harness/session-list.js.map +1 -0
- package/lib/harness/shell-output.d.ts +44 -0
- package/lib/harness/shell-output.d.ts.map +1 -0
- package/lib/harness/shell-output.js +90 -0
- package/lib/harness/shell-output.js.map +1 -0
- package/lib/harness/statusline-cc-transcript.d.ts +51 -0
- package/lib/harness/statusline-cc-transcript.d.ts.map +1 -0
- package/lib/harness/statusline-cc-transcript.js +191 -0
- package/lib/harness/statusline-cc-transcript.js.map +1 -0
- package/lib/harness/statusline-command.d.ts +54 -0
- package/lib/harness/statusline-command.d.ts.map +1 -0
- package/lib/harness/statusline-command.js +161 -0
- package/lib/harness/statusline-command.js.map +1 -0
- package/lib/harness/statusline-payload.d.ts +79 -0
- package/lib/harness/statusline-payload.d.ts.map +1 -0
- package/lib/harness/statusline-payload.js +93 -0
- package/lib/harness/statusline-payload.js.map +1 -0
- package/lib/harness/statusline-settings.d.ts +47 -0
- package/lib/harness/statusline-settings.d.ts.map +1 -0
- package/lib/harness/statusline-settings.js +57 -0
- package/lib/harness/statusline-settings.js.map +1 -0
- package/lib/harness/statusline-wiring.d.ts +45 -0
- package/lib/harness/statusline-wiring.d.ts.map +1 -0
- package/lib/harness/statusline-wiring.js +247 -0
- package/lib/harness/statusline-wiring.js.map +1 -0
- package/lib/harness/usage-view.d.ts +84 -0
- package/lib/harness/usage-view.d.ts.map +1 -0
- package/lib/harness/usage-view.js +199 -0
- package/lib/harness/usage-view.js.map +1 -0
- package/lib/harness/worktree-exit.d.ts +105 -0
- package/lib/harness/worktree-exit.d.ts.map +1 -0
- package/lib/harness/worktree-exit.js +168 -0
- package/lib/harness/worktree-exit.js.map +1 -0
- package/lib/history.d.ts +50 -0
- package/lib/history.d.ts.map +1 -0
- package/lib/history.js +139 -0
- package/lib/history.js.map +1 -0
- package/lib/index.d.ts +63 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +54 -0
- package/lib/index.js.map +1 -0
- package/lib/input.d.ts +158 -0
- package/lib/input.d.ts.map +1 -0
- package/lib/input.js +400 -0
- package/lib/input.js.map +1 -0
- package/lib/invariant.d.ts +14 -0
- package/lib/invariant.d.ts.map +1 -0
- package/lib/invariant.js +20 -0
- package/lib/invariant.js.map +1 -0
- package/lib/mode-cycle.d.ts +22 -0
- package/lib/mode-cycle.d.ts.map +1 -0
- package/lib/mode-cycle.js +32 -0
- package/lib/mode-cycle.js.map +1 -0
- package/lib/model-catalog.d.ts +22 -0
- package/lib/model-catalog.d.ts.map +1 -0
- package/lib/model-catalog.js +45 -0
- package/lib/model-catalog.js.map +1 -0
- package/lib/packaged-preset.d.ts +32 -0
- package/lib/packaged-preset.d.ts.map +1 -0
- package/lib/packaged-preset.js +94 -0
- package/lib/packaged-preset.js.map +1 -0
- package/lib/plugin.d.ts +11 -0
- package/lib/plugin.d.ts.map +1 -0
- package/lib/plugin.js +88 -0
- package/lib/plugin.js.map +1 -0
- package/lib/profile.d.ts +4 -0
- package/lib/profile.d.ts.map +1 -0
- package/lib/profile.js +7 -0
- package/lib/profile.js.map +1 -0
- package/lib/project-sessions.d.ts +29 -0
- package/lib/project-sessions.d.ts.map +1 -0
- package/lib/project-sessions.js +60 -0
- package/lib/project-sessions.js.map +1 -0
- package/lib/project.d.ts +75 -0
- package/lib/project.d.ts.map +1 -0
- package/lib/project.js +196 -0
- package/lib/project.js.map +1 -0
- package/lib/provider-actions.d.ts +37 -0
- package/lib/provider-actions.d.ts.map +1 -0
- package/lib/provider-actions.js +417 -0
- package/lib/provider-actions.js.map +1 -0
- package/lib/provider-command.d.ts +109 -0
- package/lib/provider-command.d.ts.map +1 -0
- package/lib/provider-command.js +220 -0
- package/lib/provider-command.js.map +1 -0
- package/lib/provider-detail.d.ts +15 -0
- package/lib/provider-detail.d.ts.map +1 -0
- package/lib/provider-detail.js +201 -0
- package/lib/provider-detail.js.map +1 -0
- package/lib/provider-flow.d.ts +191 -0
- package/lib/provider-flow.d.ts.map +1 -0
- package/lib/provider-flow.js +192 -0
- package/lib/provider-flow.js.map +1 -0
- package/lib/provider-presets.d.ts +32 -0
- package/lib/provider-presets.d.ts.map +1 -0
- package/lib/provider-presets.js +105 -0
- package/lib/provider-presets.js.map +1 -0
- package/lib/provider-read.d.ts +63 -0
- package/lib/provider-read.d.ts.map +1 -0
- package/lib/provider-read.js +115 -0
- package/lib/provider-read.js.map +1 -0
- package/lib/provider-settings.d.ts +30 -0
- package/lib/provider-settings.d.ts.map +1 -0
- package/lib/provider-settings.js +65 -0
- package/lib/provider-settings.js.map +1 -0
- package/lib/resume-target.d.ts +59 -0
- package/lib/resume-target.d.ts.map +1 -0
- package/lib/resume-target.js +143 -0
- package/lib/resume-target.js.map +1 -0
- package/lib/slash.d.ts +44 -0
- package/lib/slash.d.ts.map +1 -0
- package/lib/slash.js +81 -0
- package/lib/slash.js.map +1 -0
- package/lib/state/driver-types.d.ts +505 -0
- package/lib/state/driver-types.d.ts.map +1 -0
- package/lib/state/driver-types.js +8 -0
- package/lib/state/driver-types.js.map +1 -0
- package/lib/state/driver-usage-types.d.ts +59 -0
- package/lib/state/driver-usage-types.d.ts.map +1 -0
- package/lib/state/driver-usage-types.js +8 -0
- package/lib/state/driver-usage-types.js.map +1 -0
- package/lib/statusline.d.ts +63 -0
- package/lib/statusline.d.ts.map +1 -0
- package/lib/statusline.js +97 -0
- package/lib/statusline.js.map +1 -0
- package/lib/store/pickers.d.ts +34 -0
- package/lib/store/pickers.d.ts.map +1 -0
- package/lib/store/pickers.js +111 -0
- package/lib/store/pickers.js.map +1 -0
- package/lib/store/provider-panel.d.ts +107 -0
- package/lib/store/provider-panel.d.ts.map +1 -0
- package/lib/store/provider-panel.js +151 -0
- package/lib/store/provider-panel.js.map +1 -0
- package/lib/store/question.d.ts +21 -0
- package/lib/store/question.d.ts.map +1 -0
- package/lib/store/question.js +59 -0
- package/lib/store/question.js.map +1 -0
- package/lib/store/queue.d.ts +27 -0
- package/lib/store/queue.d.ts.map +1 -0
- package/lib/store/queue.js +34 -0
- package/lib/store/queue.js.map +1 -0
- package/lib/store/session.d.ts +73 -0
- package/lib/store/session.d.ts.map +1 -0
- package/lib/store/session.js +172 -0
- package/lib/store/session.js.map +1 -0
- package/lib/store/subagents.d.ts +16 -0
- package/lib/store/subagents.d.ts.map +1 -0
- package/lib/store/subagents.js +44 -0
- package/lib/store/subagents.js.map +1 -0
- package/lib/store/todos.d.ts +35 -0
- package/lib/store/todos.d.ts.map +1 -0
- package/lib/store/todos.js +68 -0
- package/lib/store/todos.js.map +1 -0
- package/lib/store/usage.d.ts +15 -0
- package/lib/store/usage.d.ts.map +1 -0
- package/lib/store/usage.js +27 -0
- package/lib/store/usage.js.map +1 -0
- package/lib/store/views.d.ts +419 -0
- package/lib/store/views.d.ts.map +1 -0
- package/lib/store/views.js +3 -0
- package/lib/store/views.js.map +1 -0
- package/lib/store.d.ts +19 -0
- package/lib/store.d.ts.map +1 -0
- package/lib/store.js +10 -0
- package/lib/store.js.map +1 -0
- package/lib/terminal/lease.d.ts +33 -0
- package/lib/terminal/lease.d.ts.map +1 -0
- package/lib/terminal/lease.js +99 -0
- package/lib/terminal/lease.js.map +1 -0
- package/lib/tool-card.d.ts +75 -0
- package/lib/tool-card.d.ts.map +1 -0
- package/lib/tool-card.js +109 -0
- package/lib/tool-card.js.map +1 -0
- package/lib/tool-verbs.d.ts +12 -0
- package/lib/tool-verbs.d.ts.map +1 -0
- package/lib/tool-verbs.js +29 -0
- package/lib/tool-verbs.js.map +1 -0
- package/lib/transcript.d.ts +40 -0
- package/lib/transcript.d.ts.map +1 -0
- package/lib/transcript.js +413 -0
- package/lib/transcript.js.map +1 -0
- package/lib/working-line.d.ts +44 -0
- package/lib/working-line.d.ts.map +1 -0
- package/lib/working-line.js +56 -0
- package/lib/working-line.js.map +1 -0
- package/package.json +72 -0
- package/presets/cc/.dsh-cc-managed.json +5 -0
- package/presets/cc/agent.cordis.yml +524 -0
- package/presets/cc/preset.yml +3 -0
- package/scripts/stage-preset.mjs +26 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approval-prompt preview builders extracted from harness/driver.ts: argument
|
|
3
|
+
* restoration from the session log, structured payload previews, permission
|
|
4
|
+
* rule derivation, and settings-conflict detection. Pure functions over the
|
|
5
|
+
* approval request and store view types — no I/O and no harness state.
|
|
6
|
+
* @module @dsh-cc/tui/harness/approval-preview
|
|
7
|
+
*/
|
|
8
|
+
import { canonicalizeHostname, isWebFetchRuleTool, ruleString } from '@dsh-cc/permission-rules';
|
|
9
|
+
/**
|
|
10
|
+
* Character cap for the pretty-printed raw-arguments preview of an approval
|
|
11
|
+
* prompt (non-shell, non-file-edit tools).
|
|
12
|
+
*/
|
|
13
|
+
const ARGS_PREVIEW_MAX_CHARS = 500;
|
|
14
|
+
/**
|
|
15
|
+
* Restore the approved call's arguments by scanning the session log backwards
|
|
16
|
+
* for the `tool/call` event carrying the request's callId (`appendToolCall`
|
|
17
|
+
* lands before the pre-execute approval, so the event is always present).
|
|
18
|
+
* Returns undefined when the callId is missing, unpaired, or its arguments
|
|
19
|
+
* are not stored as a string.
|
|
20
|
+
*/
|
|
21
|
+
function argsOf(req) {
|
|
22
|
+
if (req.callId === undefined)
|
|
23
|
+
return undefined;
|
|
24
|
+
const events = req.agent.session.events;
|
|
25
|
+
for (let i = events.length - 1; i >= 0; i -= 1) {
|
|
26
|
+
const event = events[i];
|
|
27
|
+
if (event.type !== 'tool/call')
|
|
28
|
+
continue;
|
|
29
|
+
if (String(event.data.callId) !== String(req.callId))
|
|
30
|
+
continue;
|
|
31
|
+
const raw = event.data.arguments;
|
|
32
|
+
if (typeof raw !== 'string')
|
|
33
|
+
return undefined;
|
|
34
|
+
try {
|
|
35
|
+
const parsed = JSON.parse(raw);
|
|
36
|
+
if (parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
37
|
+
return { args: parsed };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Not JSON — fall through to the raw-text preview.
|
|
42
|
+
}
|
|
43
|
+
return { raw };
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Build the approval prompt's structured payload preview from the restored
|
|
49
|
+
* call arguments: shell-style `command` arguments map to the command kind;
|
|
50
|
+
* Edit/MultiEdit/Write arguments map to per-file diffs (rendered with the
|
|
51
|
+
* transcript's multi-hunk diff renderer); anything else pretty-prints the raw
|
|
52
|
+
* arguments, and a failed recovery degrades to tool name + reason only.
|
|
53
|
+
*/
|
|
54
|
+
export function payloadOf(req) {
|
|
55
|
+
const restored = argsOf(req);
|
|
56
|
+
if (restored === undefined)
|
|
57
|
+
return { kind: 'none' };
|
|
58
|
+
if ('raw' in restored) {
|
|
59
|
+
return { kind: 'args', json: restored.raw.slice(0, ARGS_PREVIEW_MAX_CHARS) };
|
|
60
|
+
}
|
|
61
|
+
const args = restored.args;
|
|
62
|
+
if (typeof args.command === 'string') {
|
|
63
|
+
return { kind: 'command', command: args.command };
|
|
64
|
+
}
|
|
65
|
+
const diffs = diffsOf(req.toolName.toLowerCase(), args);
|
|
66
|
+
if (diffs !== undefined)
|
|
67
|
+
return { kind: 'diff', diffs };
|
|
68
|
+
return { kind: 'args', json: JSON.stringify(args, null, 2).slice(0, ARGS_PREVIEW_MAX_CHARS) };
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Extract per-file diffs from file-edit tool arguments, or undefined when the
|
|
72
|
+
* arguments do not carry the expected shape (the preview then degrades to the
|
|
73
|
+
* raw-arguments kind).
|
|
74
|
+
*/
|
|
75
|
+
function diffsOf(name, args) {
|
|
76
|
+
const path = typeof args.file_path === 'string' ? args.file_path : undefined;
|
|
77
|
+
if (name === 'write') {
|
|
78
|
+
if (path === undefined || typeof args.content !== 'string')
|
|
79
|
+
return undefined;
|
|
80
|
+
return [{ path, oldText: null, newText: args.content }];
|
|
81
|
+
}
|
|
82
|
+
if (name === 'edit') {
|
|
83
|
+
if (path === undefined || typeof args.old_string !== 'string' || typeof args.new_string !== 'string')
|
|
84
|
+
return undefined;
|
|
85
|
+
return [{ path, oldText: args.old_string, newText: args.new_string }];
|
|
86
|
+
}
|
|
87
|
+
if (name === 'multiedit' || name === 'multi_edit') {
|
|
88
|
+
if (path === undefined || !Array.isArray(args.edits))
|
|
89
|
+
return undefined;
|
|
90
|
+
const diffs = [];
|
|
91
|
+
for (const edit of args.edits) {
|
|
92
|
+
if (edit === null || typeof edit !== 'object')
|
|
93
|
+
continue;
|
|
94
|
+
const { old_string: oldText, new_string: newText } = edit;
|
|
95
|
+
if (typeof oldText !== 'string' || typeof newText !== 'string')
|
|
96
|
+
continue;
|
|
97
|
+
diffs.push({ path, oldText, newText });
|
|
98
|
+
}
|
|
99
|
+
return diffs.length > 0 ? diffs : undefined;
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Derive the permission rule an "always" answer persists for the approved
|
|
105
|
+
* call. Shell commands get a trailing-space first-word prefix rule
|
|
106
|
+
* (`Bash(npm )` matches `npm install …` but not `npmx …` — the deliberate
|
|
107
|
+
* trailing space replaces the colon-carrying `:*` legacy form, which would
|
|
108
|
+
* otherwise embed the colon in the prefix and never match). Environment
|
|
109
|
+
* variable prefixes (e.g., `FOO=bar`) are stripped before extracting the
|
|
110
|
+
* first word, so `FOO=bar npm install` derives a rule for `npm`, not `FOO=bar`.
|
|
111
|
+
* A WebFetch call derives a `WebFetch(domain:<host>)` rule on the exact host
|
|
112
|
+
* from its `url` argument; every other tool gets a whole-tool rule. Undefined
|
|
113
|
+
* (stay once-only) when nothing usable remains, e.g. a blank command.
|
|
114
|
+
*/
|
|
115
|
+
export function allowRuleOf(toolName, preview) {
|
|
116
|
+
const name = toolName.trim();
|
|
117
|
+
if (name === '')
|
|
118
|
+
return undefined;
|
|
119
|
+
if (preview?.kind === 'command') {
|
|
120
|
+
const command = preview.command.trim();
|
|
121
|
+
if (command === '')
|
|
122
|
+
return undefined;
|
|
123
|
+
// Strip environment variable prefixes (FOO=bar, FOO=bar BAZ=qux, etc.)
|
|
124
|
+
// These are assignments that appear before the actual command.
|
|
125
|
+
let remaining = command;
|
|
126
|
+
while (true) {
|
|
127
|
+
const match = remaining.match(/^[A-Z_][A-Z0-9_]*=\S*\s+/);
|
|
128
|
+
if (!match)
|
|
129
|
+
break;
|
|
130
|
+
remaining = remaining.slice(match[0].length);
|
|
131
|
+
}
|
|
132
|
+
// Handle common command prefixes that should be stripped
|
|
133
|
+
// sudo: run as root, but rule should match the actual command
|
|
134
|
+
// npx/yarn: package runners, but rule should match the underlying tool
|
|
135
|
+
const prefixesToStrip = ['sudo ', 'npx ', 'yarn '];
|
|
136
|
+
for (const prefix of prefixesToStrip) {
|
|
137
|
+
if (remaining.startsWith(prefix)) {
|
|
138
|
+
remaining = remaining.slice(prefix.length);
|
|
139
|
+
break; // Only strip one prefix
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// For compound commands (&&, ||, ;), only consider the first segment
|
|
143
|
+
// This is a simplification - the rule will match any command starting
|
|
144
|
+
// with the first segment's command, which is the desired behavior.
|
|
145
|
+
const firstSegment = remaining.split(/&&|\|\||;/)[0]?.trim() ?? '';
|
|
146
|
+
const firstWord = firstSegment.split(/\s+/)[0] ?? '';
|
|
147
|
+
if (firstWord === '')
|
|
148
|
+
return undefined;
|
|
149
|
+
// ruleString escapes parens/backslashes so a subshell-opening first word
|
|
150
|
+
// round-trips through parseRuleString.
|
|
151
|
+
return ruleString(name, `${firstWord} `);
|
|
152
|
+
}
|
|
153
|
+
// WebFetch persists a domain rule on the exact host (not `*.host`): the
|
|
154
|
+
// args preview carries the URL, whose hostname is canonicalized here. An
|
|
155
|
+
// unparsable payload keeps today's whole-tool rule.
|
|
156
|
+
if (isWebFetchRuleTool(name) && preview?.kind === 'args') {
|
|
157
|
+
try {
|
|
158
|
+
const parsed = JSON.parse(preview.json);
|
|
159
|
+
const url = parsed.url;
|
|
160
|
+
if (typeof url === 'string') {
|
|
161
|
+
const hostname = canonicalizeHostname(url);
|
|
162
|
+
if (hostname !== undefined)
|
|
163
|
+
return ruleString('WebFetch', `domain:${hostname}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
// Malformed JSON or missing url — fall through to the whole-tool rule.
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return name;
|
|
171
|
+
}
|
|
172
|
+
/** Whether an error is the settings provider's revision-conflict rejection. */
|
|
173
|
+
export function isSettingsConflict(error) {
|
|
174
|
+
const candidate = error;
|
|
175
|
+
if (candidate === null || typeof candidate !== 'object')
|
|
176
|
+
return false;
|
|
177
|
+
return candidate.code === 'SETTINGS_CONFLICT' || candidate.name === 'SettingsConflictError';
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=approval-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval-preview.js","sourceRoot":"","sources":["../../src/harness/approval-preview.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAG/F;;;GAGG;AACH,MAAM,sBAAsB,GAAG,GAAG,CAAA;AAUlC;;;;;;GAMG;AACH,SAAS,MAAM,CAAC,GAAoB;IAClC,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAC9C,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAA;IACvC,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAE,CAAA;QACxB,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW;YAAE,SAAQ;QACxC,IAAI,MAAM,CAAE,KAAK,CAAC,IAA6B,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,GAAG,CAAC,M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AAE,CAAC,CAAA;YACjF,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,uEAAuE;QACzE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,MAAM,SAAS,GAAG,KAAkD,CAAA;IACpE,IAAI,SAAS,KAAK,IAAI,IAAI,OAAO,SAAS,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACrE,OAAO,SAAS,CAAC,IAAI,KAAK,mBAAmB,IAAI,SAAS,CAAC,IAAI,KAAK,uBAAuB,CAAA;AAC7F,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TranscriptRow } from '../store.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Build the 6-line half-block whale art: vertical row pairs compress to one
|
|
4
|
+
* line ('█' both, '▀' upper only, '▄' lower only). Lines are right-trimmed,
|
|
5
|
+
* then the common left indent is trimmed so alignment survives. Every line
|
|
6
|
+
* is wrapped in its fixed blue SGR foreground and closed with `\x1b[0m`
|
|
7
|
+
* (pi-tui's wrap engine carries active codes across lines).
|
|
8
|
+
*/
|
|
9
|
+
export declare function whaleBannerArt(): string;
|
|
10
|
+
/** Boot info line under the whale art (em dash + middle dots, as historically). */
|
|
11
|
+
export declare function bootBannerText(modelLabel: string, cwd: string): string;
|
|
12
|
+
/** The two transcript rows emitted at boot: whale art, then the info line. */
|
|
13
|
+
export declare function bootBannerRows(modelLabel: string, cwd: string): TranscriptRow[];
|
|
14
|
+
//# sourceMappingURL=boot-banner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boot-banner.d.ts","sourceRoot":"","sources":["../../src/harness/boot-banner.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAiDhD;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAmBvC;AAED,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa,EAAE,CAK/E"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boot banner art + info text for the CC transcript. Brand art is
|
|
3
|
+
* theme-independent: the whale renders through a fixed deep-to-light blue
|
|
4
|
+
* 256-color ramp regardless of the configured palette.
|
|
5
|
+
* @module @dsh-cc/tui/harness/boot-banner
|
|
6
|
+
*/
|
|
7
|
+
import { sgr } from "../components/theme.js";
|
|
8
|
+
/**
|
|
9
|
+
* DeepSeek whale source art, "half-block compressed" (半块压缩版): 11 rows of
|
|
10
|
+
* '█' (filled) / '.' (background), embedded verbatim — pristine. The eye is
|
|
11
|
+
* punched at build time (see {@link EYE}), so the source art above stays
|
|
12
|
+
* untouched and the eye intent is documented here rather than edited in.
|
|
13
|
+
*/
|
|
14
|
+
const WHALE_BITMAP = [
|
|
15
|
+
'..........................███......█.......',
|
|
16
|
+
'..........................█████..█████.....',
|
|
17
|
+
'..........█████████.......████████████.....',
|
|
18
|
+
'........███████████████.....█████████......',
|
|
19
|
+
'......███████████████████..██████..........',
|
|
20
|
+
'......████████████████████████.██..........',
|
|
21
|
+
'......███████████████████████████..........',
|
|
22
|
+
'......█████.......██████████████...........',
|
|
23
|
+
'.......██.............█████████............',
|
|
24
|
+
'.........███...........█████████...........',
|
|
25
|
+
'............███████████..███████...........',
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* Eye hole: bitmap rows 4 and 5, column 27 (0-based). Rows are paired
|
|
29
|
+
* vertically (0,1),(2,3),(4,5),… so punching both rows keeps the eye inside
|
|
30
|
+
* one half-block pair. Applied at build time over the verbatim bitmap.
|
|
31
|
+
*/
|
|
32
|
+
const EYE = [
|
|
33
|
+
[4, 27],
|
|
34
|
+
[5, 27],
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* Fixed deep→light 256-color SGR foreground ramp, one per output line. The
|
|
38
|
+
* mid rows anchor on 63 (#5f5fff), the nearest 256-color match to the
|
|
39
|
+
* DeepSeek brand blue #4D6BFE; the ramp stays on the blue axis (no cyan
|
|
40
|
+
* drift) and the belly tops out at 75 (#5fafff).
|
|
41
|
+
*/
|
|
42
|
+
const BLUE_RAMP = ['38;5;25', '38;5;26', '38;5;27', '38;5;63', '38;5;69', '38;5;75'];
|
|
43
|
+
/** Bitmap with the eye punched in (filled → background) at the EYE points. */
|
|
44
|
+
const PUNCHED = (() => {
|
|
45
|
+
const rows = WHALE_BITMAP.slice();
|
|
46
|
+
for (const [r, c] of EYE) {
|
|
47
|
+
rows[r] = rows[r].slice(0, c) + '.' + rows[r].slice(c + 1);
|
|
48
|
+
}
|
|
49
|
+
return rows;
|
|
50
|
+
})();
|
|
51
|
+
/**
|
|
52
|
+
* Build the 6-line half-block whale art: vertical row pairs compress to one
|
|
53
|
+
* line ('█' both, '▀' upper only, '▄' lower only). Lines are right-trimmed,
|
|
54
|
+
* then the common left indent is trimmed so alignment survives. Every line
|
|
55
|
+
* is wrapped in its fixed blue SGR foreground and closed with `\x1b[0m`
|
|
56
|
+
* (pi-tui's wrap engine carries active codes across lines).
|
|
57
|
+
*/
|
|
58
|
+
export function whaleBannerArt() {
|
|
59
|
+
const lines = [];
|
|
60
|
+
for (let pair = 0; pair * 2 < PUNCHED.length; pair++) {
|
|
61
|
+
const upper = PUNCHED[pair * 2];
|
|
62
|
+
const lower = PUNCHED[pair * 2 + 1] ?? '';
|
|
63
|
+
let line = '';
|
|
64
|
+
for (let col = 0; col < upper.length; col++) {
|
|
65
|
+
const up = upper[col] === '█';
|
|
66
|
+
const low = lower[col] === '█';
|
|
67
|
+
line += up && low ? '█' : up ? '▀' : low ? '▄' : ' ';
|
|
68
|
+
}
|
|
69
|
+
lines.push(line);
|
|
70
|
+
}
|
|
71
|
+
const trimmed = lines.map(line => line.replace(/\s+$/, ''));
|
|
72
|
+
const indent = Math.min(...trimmed.map(line => line.length - line.trimStart().length));
|
|
73
|
+
return trimmed
|
|
74
|
+
.map(line => line.slice(indent))
|
|
75
|
+
.map((line, i) => sgr(BLUE_RAMP[i % BLUE_RAMP.length])(line))
|
|
76
|
+
.join('\n');
|
|
77
|
+
}
|
|
78
|
+
/** Boot info line under the whale art (em dash + middle dots, as historically). */
|
|
79
|
+
export function bootBannerText(modelLabel, cwd) {
|
|
80
|
+
return `dsh cc-mode — ${modelLabel} · ${cwd} · /tui-help for keys`;
|
|
81
|
+
}
|
|
82
|
+
/** The two transcript rows emitted at boot: whale art, then the info line. */
|
|
83
|
+
export function bootBannerRows(modelLabel, cwd) {
|
|
84
|
+
return [
|
|
85
|
+
{ kind: 'banner', text: whaleBannerArt() },
|
|
86
|
+
{ kind: 'status', text: bootBannerText(modelLabel, cwd) },
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=boot-banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boot-banner.js","sourceRoot":"","sources":["../../src/harness/boot-banner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAA;AAG5C;;;;;GAKG;AACH,MAAM,YAAY,GAAG;IACnB,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;CAC9C,CAAA;AAED;;;;GAIG;AACH,MAAM,GAAG,GAAuD;IAC9D,CAAC,CAAC,EAAE,EAAE,CAAC;IACP,CAAC,CAAC,EAAE,EAAE,CAAC;CACR,CAAA;AAED;;;;;GAKG;AACH,MAAM,SAAS,GAAG,CAAC,SAAS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model + history cluster of the TUI driver factory.
|
|
3
|
+
*
|
|
4
|
+
* createDriver used to hold these locals inline: resolveEfforts / stalePair /
|
|
5
|
+
* seedDefaultModel, the resume marker + prompt/bash histories, the tool
|
|
6
|
+
* presenters, history folding, and the model-command catalog. They only read
|
|
7
|
+
* `ctx`/`current`/`selection`/`liveMode` off `rt` (DriverAgentCtx), so they
|
|
8
|
+
* migrate here as a free-function collaborator to keep the factory under the
|
|
9
|
+
* 500-line budget — the same pattern as the other harness/driver-*.ts leaves.
|
|
10
|
+
*
|
|
11
|
+
* Mutable state the other sections rebind (`markedContent`, `history`,
|
|
12
|
+
* `bashHistory`) is owned HERE and exposed through get/set/append handles so
|
|
13
|
+
* no other module captures a stale copy.
|
|
14
|
+
* @module @dsh-cc/tui/harness/driver-agent
|
|
15
|
+
*/
|
|
16
|
+
import { type TuiState } from '../store.ts';
|
|
17
|
+
import { type ToolPresenters } from '../transcript.ts';
|
|
18
|
+
import type { CatalogEntry } from '../model-catalog.ts';
|
|
19
|
+
import type { ShellExecutorLike } from '../state/driver-types.ts';
|
|
20
|
+
import type { DriverAgentCtx, DriverSessionEventsCtx } from './driver-ctx.ts';
|
|
21
|
+
/**
|
|
22
|
+
* The slice of createDriver's model/history cluster that the session/event
|
|
23
|
+
* listener needs: it folds events onto fresh state and presents tool cards for
|
|
24
|
+
* the live agent.
|
|
25
|
+
*/
|
|
26
|
+
export declare function attachSessionEvents(rt: DriverSessionEventsCtx): void;
|
|
27
|
+
/**
|
|
28
|
+
* The handle object returned by {@link createAgentSection}. createDriver
|
|
29
|
+
* destructures these into its locals and threads them into the other sections.
|
|
30
|
+
*/
|
|
31
|
+
export interface AgentSection {
|
|
32
|
+
resolveEfforts(provider: string, model: string): Promise<readonly {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
}[] | undefined>;
|
|
36
|
+
stalePair(captured: {
|
|
37
|
+
provider: string;
|
|
38
|
+
model: string;
|
|
39
|
+
}): boolean;
|
|
40
|
+
seedDefaultModel(reset?: boolean): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Await the boot default-model seed (kicked once, shared promise). Model-turn
|
|
43
|
+
* paths must await this before dispatch so a turn never runs with an
|
|
44
|
+
* unresolved selection. Resolves even when the seed failed.
|
|
45
|
+
*/
|
|
46
|
+
waitForModel(): Promise<void>;
|
|
47
|
+
/** Bounded boot-frame wait (never blocks on a slow seed). */
|
|
48
|
+
awaitBootFrame(): Promise<void>;
|
|
49
|
+
persistResumeTarget(): void;
|
|
50
|
+
getMarkedContent(): boolean;
|
|
51
|
+
setMarkedContent(value: boolean): void;
|
|
52
|
+
historyDir: string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Rebind prompt/bash history to a new data directory and reload both from
|
|
55
|
+
* disk. Used by /resume to re-scope history onto the switched session's
|
|
56
|
+
* project (a no-op caller-side when the project is unchanged).
|
|
57
|
+
*/
|
|
58
|
+
bindHistoryDir(dir: string | undefined): void;
|
|
59
|
+
getHistory(): string[];
|
|
60
|
+
setHistory(next: string[]): void;
|
|
61
|
+
getBashHistory(): string[];
|
|
62
|
+
appendBashHistory(command: string): void;
|
|
63
|
+
/** Tool presenters (absent when no tools service mounted). */
|
|
64
|
+
presenters: ToolPresenters | undefined;
|
|
65
|
+
/** Shell executor seam for `!` commands (used by the bash section). */
|
|
66
|
+
shell: ShellExecutorLike | undefined;
|
|
67
|
+
/** Fold the live session's event log onto the current view-model. */
|
|
68
|
+
foldHistory(): TuiState;
|
|
69
|
+
loadCatalog(): Promise<CatalogEntry[]>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Build the agent-model/history cluster. Returns handles createDriver threads
|
|
73
|
+
* into the picker/session/run-local/queue sections and the Driver API, and
|
|
74
|
+
* exposes the owned `markedContent`/`history`/`bashHistory` state through
|
|
75
|
+
* get/set seams so no other module captures a stale copy.
|
|
76
|
+
*/
|
|
77
|
+
export declare function createAgentSection(rt: DriverAgentCtx): AgentSection;
|
|
78
|
+
//#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