@agi-fans/dsh-tui 0.20.0 → 0.22.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/lib/CHANGELOG.md +249 -3
- package/lib/chrome/box.d.ts +47 -16
- package/lib/chrome/box.js +172 -130
- package/lib/chrome/box.js.map +1 -1
- package/lib/chrome/code-highlight.d.ts +15 -0
- package/lib/chrome/code-highlight.js +60 -4
- package/lib/chrome/code-highlight.js.map +1 -1
- package/lib/chrome/command-output.d.ts +29 -2
- package/lib/chrome/command-output.js +100 -4
- package/lib/chrome/command-output.js.map +1 -1
- package/lib/chrome/main-screen-renderer.d.ts +18 -0
- package/lib/chrome/main-screen-renderer.js +58 -5
- package/lib/chrome/main-screen-renderer.js.map +1 -1
- package/lib/chrome/markdown.js +30 -10
- package/lib/chrome/markdown.js.map +1 -1
- package/lib/chrome/relative-time.d.ts +17 -0
- package/lib/chrome/relative-time.js +36 -0
- package/lib/chrome/relative-time.js.map +1 -1
- package/lib/chrome/renderer.d.ts +9 -0
- package/lib/chrome/renderer.js +1 -1
- package/lib/chrome/renderer.js.map +1 -1
- package/lib/chrome/secret-mask.d.ts +35 -0
- package/lib/chrome/secret-mask.js +180 -0
- package/lib/chrome/secret-mask.js.map +1 -0
- package/lib/chrome/status-config.d.ts +161 -51
- package/lib/chrome/status-config.js +237 -126
- package/lib/chrome/status-config.js.map +1 -1
- package/lib/chrome/status-line.d.ts +3 -2
- package/lib/chrome/status-line.js +105 -63
- package/lib/chrome/status-line.js.map +1 -1
- package/lib/chrome/terminal-colors.d.ts +85 -0
- package/lib/chrome/terminal-colors.js +230 -0
- package/lib/chrome/terminal-colors.js.map +1 -0
- package/lib/chrome/terminal-images.d.ts +9 -1
- package/lib/chrome/terminal-images.js +27 -4
- package/lib/chrome/terminal-images.js.map +1 -1
- package/lib/chrome/theme.d.ts +32 -9
- package/lib/chrome/theme.js +616 -520
- package/lib/chrome/theme.js.map +1 -1
- package/lib/chrome/tool-args.d.ts +1 -1
- package/lib/chrome/tool-args.js +3 -1
- package/lib/chrome/tool-args.js.map +1 -1
- package/lib/chrome/tool-renderers.d.ts +2 -0
- package/lib/chrome/tool-renderers.js +69 -3
- package/lib/chrome/tool-renderers.js.map +1 -1
- package/lib/chrome/tools-list.d.ts +1 -4
- package/lib/chrome/tools-list.js +1 -41
- package/lib/chrome/tools-list.js.map +1 -1
- package/lib/chrome/welcome-tips.d.ts +20 -7
- package/lib/chrome/welcome-tips.js +22 -41
- package/lib/chrome/welcome-tips.js.map +1 -1
- package/lib/commands/auth-ids.d.ts +25 -0
- package/lib/commands/auth-ids.js +27 -0
- package/lib/commands/auth-ids.js.map +1 -0
- package/lib/commands/auth-input.d.ts +34 -0
- package/lib/commands/auth-input.js +96 -0
- package/lib/commands/auth-input.js.map +1 -0
- package/lib/commands/auth-providers.d.ts +39 -0
- package/lib/commands/auth-providers.js +125 -0
- package/lib/commands/auth-providers.js.map +1 -0
- package/lib/commands/auth.d.ts +16 -22
- package/lib/commands/auth.js +346 -299
- package/lib/commands/auth.js.map +1 -1
- package/lib/commands/btw.d.ts +27 -0
- package/lib/commands/btw.js +59 -0
- package/lib/commands/btw.js.map +1 -0
- package/lib/commands/diff.js +30 -5
- package/lib/commands/diff.js.map +1 -1
- package/lib/commands/export.d.ts +1 -1
- package/lib/commands/export.js +5 -3
- package/lib/commands/export.js.map +1 -1
- package/lib/commands/files.d.ts +17 -1
- package/lib/commands/files.js +69 -61
- package/lib/commands/files.js.map +1 -1
- package/lib/commands/integrations.js +18 -6
- package/lib/commands/integrations.js.map +1 -1
- package/lib/commands/jobs.d.ts +19 -4
- package/lib/commands/jobs.js +50 -7
- package/lib/commands/jobs.js.map +1 -1
- package/lib/commands/model.js +109 -76
- package/lib/commands/model.js.map +1 -1
- package/lib/commands/permission.js +46 -13
- package/lib/commands/permission.js.map +1 -1
- package/lib/commands/plugins.js +196 -42
- package/lib/commands/plugins.js.map +1 -1
- package/lib/commands/schedule.d.ts +29 -0
- package/lib/commands/schedule.js +228 -0
- package/lib/commands/schedule.js.map +1 -0
- package/lib/commands/session-configuration.d.ts +1 -1
- package/lib/commands/session-configuration.js +29 -28
- package/lib/commands/session-configuration.js.map +1 -1
- package/lib/commands/session.js +75 -80
- package/lib/commands/session.js.map +1 -1
- package/lib/commands/terminal.d.ts +24 -4
- package/lib/commands/terminal.js +38 -94
- package/lib/commands/terminal.js.map +1 -1
- package/lib/commands/trajectory.js +4 -1
- package/lib/commands/trajectory.js.map +1 -1
- package/lib/definition.d.ts +150 -11
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/input/actions.d.ts +51 -0
- package/lib/input/actions.js +120 -0
- package/lib/input/actions.js.map +1 -0
- package/lib/input/editor-discovery.js +2 -2
- package/lib/input/editor-discovery.js.map +1 -1
- package/lib/input/editor.d.ts +0 -10
- package/lib/input/editor.js +11 -9
- package/lib/input/editor.js.map +1 -1
- package/lib/input/image-paste.d.ts +19 -1
- package/lib/input/image-paste.js +82 -1
- package/lib/input/image-paste.js.map +1 -1
- package/lib/input/keybindings-config.d.ts +15 -4
- package/lib/input/keybindings-config.js +57 -35
- package/lib/input/keybindings-config.js.map +1 -1
- package/lib/input/keys.d.ts +18 -0
- package/lib/input/keys.js +48 -3
- package/lib/input/keys.js.map +1 -1
- package/lib/input/wheel-scroll.d.ts +46 -0
- package/lib/input/wheel-scroll.js +69 -0
- package/lib/input/wheel-scroll.js.map +1 -0
- package/lib/prompt-intents.d.ts +182 -0
- package/lib/prompt-intents.js +127 -0
- package/lib/prompt-intents.js.map +1 -0
- package/lib/runtime/agent-profile.d.ts +5 -0
- package/lib/runtime/agent-profile.js +12 -0
- package/lib/runtime/agent-profile.js.map +1 -1
- package/lib/runtime/approval-rules.d.ts +59 -0
- package/lib/runtime/approval-rules.js +179 -0
- package/lib/runtime/approval-rules.js.map +1 -0
- package/lib/runtime/btw-policy.d.ts +7 -0
- package/lib/runtime/btw-policy.js +18 -0
- package/lib/runtime/btw-policy.js.map +1 -0
- package/lib/runtime/btw.d.ts +47 -0
- package/lib/runtime/btw.js +200 -0
- package/lib/runtime/btw.js.map +1 -0
- package/lib/runtime/cancellable.d.ts +75 -0
- package/lib/runtime/cancellable.js +76 -0
- package/lib/runtime/cancellable.js.map +1 -0
- package/lib/runtime/composer-images.js +5 -4
- package/lib/runtime/composer-images.js.map +1 -1
- package/lib/runtime/composer-shell.d.ts +30 -0
- package/lib/runtime/composer-shell.js +150 -0
- package/lib/runtime/composer-shell.js.map +1 -0
- package/lib/runtime/file-recovery-local.d.ts +73 -0
- package/lib/runtime/file-recovery-local.js +351 -0
- package/lib/runtime/file-recovery-local.js.map +1 -0
- package/lib/runtime/file-recovery-recording.d.ts +23 -0
- package/lib/runtime/file-recovery-recording.js +131 -0
- package/lib/runtime/file-recovery-recording.js.map +1 -0
- package/lib/runtime/file-recovery-review.d.ts +3 -0
- package/lib/runtime/file-recovery-review.js +130 -0
- package/lib/runtime/file-recovery-review.js.map +1 -0
- package/lib/runtime/file-recovery-store.d.ts +83 -0
- package/lib/runtime/file-recovery-store.js +329 -0
- package/lib/runtime/file-recovery-store.js.map +1 -0
- package/lib/runtime/file-recovery-worker.d.ts +22 -0
- package/lib/runtime/file-recovery-worker.js +153 -0
- package/lib/runtime/file-recovery-worker.js.map +1 -0
- package/lib/runtime/file-review.d.ts +6 -3
- package/lib/runtime/file-review.js +44 -7
- package/lib/runtime/file-review.js.map +1 -1
- package/lib/runtime/herdr-agent.d.ts +4 -13
- package/lib/runtime/herdr-agent.js +19 -63
- package/lib/runtime/herdr-agent.js.map +1 -1
- package/lib/runtime/plain-tui.d.ts +2 -0
- package/lib/runtime/plain-tui.js +7 -1
- package/lib/runtime/plain-tui.js.map +1 -1
- package/lib/runtime/plugin-settings.d.ts +25 -2
- package/lib/runtime/plugin-settings.js +329 -31
- package/lib/runtime/plugin-settings.js.map +1 -1
- package/lib/runtime/provider-local.d.ts +81 -24
- package/lib/runtime/provider-local.js +1807 -608
- package/lib/runtime/provider-local.js.map +1 -1
- package/lib/runtime/runner.js +52 -12
- package/lib/runtime/runner.js.map +1 -1
- package/lib/runtime/session-archive.d.ts +6 -0
- package/lib/runtime/session-archive.js +129 -3
- package/lib/runtime/session-archive.js.map +1 -1
- package/lib/runtime/session-runtime.js +1 -1
- package/lib/runtime/session-runtime.js.map +1 -1
- package/lib/runtime/settings-preferences.d.ts +5 -0
- package/lib/runtime/settings-preferences.js +34 -0
- package/lib/runtime/settings-preferences.js.map +1 -0
- package/lib/runtime/startup-notices.js +2 -0
- package/lib/runtime/startup-notices.js.map +1 -1
- package/lib/runtime/terminal-modes.d.ts +47 -0
- package/lib/runtime/terminal-modes.js +86 -0
- package/lib/runtime/terminal-modes.js.map +1 -0
- package/lib/runtime/terminal-notifications.d.ts +3 -5
- package/lib/runtime/terminal-notifications.js +4 -8
- package/lib/runtime/terminal-notifications.js.map +1 -1
- package/lib/runtime/terminal-probe.d.ts +36 -0
- package/lib/runtime/terminal-probe.js +37 -0
- package/lib/runtime/terminal-probe.js.map +1 -0
- package/lib/runtime/terminal-session.d.ts +57 -0
- package/lib/runtime/terminal-session.js +164 -0
- package/lib/runtime/terminal-session.js.map +1 -0
- package/lib/runtime/terminal-state.d.ts +29 -0
- package/lib/runtime/terminal-state.js +62 -0
- package/lib/runtime/terminal-state.js.map +1 -0
- package/lib/runtime/tool-presentation.js +50 -14
- package/lib/runtime/tool-presentation.js.map +1 -1
- package/lib/session/external-agents.d.ts +5 -0
- package/lib/session/external-agents.js +27 -0
- package/lib/session/external-agents.js.map +1 -0
- package/lib/session/feature-toggles.d.ts +1 -1
- package/lib/session/feature-toggles.js +1 -1
- package/lib/session/interaction-adapter.d.ts +1 -6
- package/lib/session/interaction-adapter.js +95 -18
- package/lib/session/interaction-adapter.js.map +1 -1
- package/lib/session/message-queue.js +1 -1
- package/lib/session/message-queue.js.map +1 -1
- package/lib/session/model-readiness.d.ts +16 -0
- package/lib/session/model-readiness.js +43 -0
- package/lib/session/model-readiness.js.map +1 -0
- package/lib/session/package-metadata.d.ts +8 -0
- package/lib/session/package-metadata.js +8 -0
- package/lib/session/package-metadata.js.map +1 -1
- package/lib/session/project-context.d.ts +5 -0
- package/lib/session/project-context.js +36 -0
- package/lib/session/project-context.js.map +1 -1
- package/lib/session/session-controller.d.ts +10 -13
- package/lib/session/session-controller.js +183 -98
- package/lib/session/session-controller.js.map +1 -1
- package/lib/session/session-library.js +2 -0
- package/lib/session/session-library.js.map +1 -1
- package/lib/session/session-tree.d.ts +3 -0
- package/lib/session/session-tree.js +3 -1
- package/lib/session/session-tree.js.map +1 -1
- package/lib/session/subagent-roster.d.ts +2 -1
- package/lib/session/subagent-roster.js +24 -3
- package/lib/session/subagent-roster.js.map +1 -1
- package/lib/session/subagent-tracker.d.ts +6 -2
- package/lib/session/subagent-tracker.js +49 -2
- package/lib/session/subagent-tracker.js.map +1 -1
- package/lib/session/tui-settings.d.ts +47 -13
- package/lib/session/tui-settings.js +76 -34
- package/lib/session/tui-settings.js.map +1 -1
- package/lib/session/working-directory.d.ts +4 -0
- package/lib/session/working-directory.js +4 -0
- package/lib/session/working-directory.js.map +1 -0
- package/lib/session/worktrees.d.ts +13 -0
- package/lib/session/worktrees.js +49 -0
- package/lib/session/worktrees.js.map +1 -0
- package/lib/views/approval-rule.d.ts +3 -0
- package/lib/views/approval-rule.js +4 -0
- package/lib/views/approval-rule.js.map +1 -0
- package/lib/views/at-complete.d.ts +8 -0
- package/lib/views/at-complete.js +64 -2
- package/lib/views/at-complete.js.map +1 -1
- package/lib/views/autocomplete.d.ts +22 -2
- package/lib/views/autocomplete.js +70 -40
- package/lib/views/autocomplete.js.map +1 -1
- package/lib/views/copy-targets.d.ts +13 -14
- package/lib/views/copy-targets.js +42 -54
- package/lib/views/copy-targets.js.map +1 -1
- package/lib/views/document-reader.js +18 -5
- package/lib/views/document-reader.js.map +1 -1
- package/lib/views/event-views.d.ts +1 -1
- package/lib/views/event-views.js +60 -6
- package/lib/views/event-views.js.map +1 -1
- package/lib/views/file-actions.d.ts +12 -0
- package/lib/views/file-actions.js +72 -0
- package/lib/views/file-actions.js.map +1 -0
- package/lib/views/history-search.js +15 -21
- package/lib/views/history-search.js.map +1 -1
- package/lib/views/hotkeys.d.ts +8 -1
- package/lib/views/hotkeys.js +53 -26
- package/lib/views/hotkeys.js.map +1 -1
- package/lib/views/list-navigation.d.ts +62 -0
- package/lib/views/list-navigation.js +73 -0
- package/lib/views/list-navigation.js.map +1 -0
- package/lib/views/list-view.d.ts +99 -0
- package/lib/views/list-view.js +165 -0
- package/lib/views/list-view.js.map +1 -0
- package/lib/views/prompt-selector.d.ts +34 -4
- package/lib/views/prompt-selector.js +270 -134
- package/lib/views/prompt-selector.js.map +1 -1
- package/lib/views/session-files.d.ts +1 -2
- package/lib/views/session-files.js +1 -11
- package/lib/views/session-files.js.map +1 -1
- package/lib/views/settings-list.d.ts +51 -10
- package/lib/views/settings-list.js +267 -315
- package/lib/views/settings-list.js.map +1 -1
- package/lib/views/trajectory-timeline.d.ts +72 -0
- package/lib/views/trajectory-timeline.js +133 -0
- package/lib/views/trajectory-timeline.js.map +1 -0
- package/lib/views/trajectory.d.ts +15 -4
- package/lib/views/trajectory.js +557 -123
- package/lib/views/trajectory.js.map +1 -1
- package/lib/views/transcript-export.js +9 -0
- package/lib/views/transcript-export.js.map +1 -1
- package/lib/views/transcript-render.d.ts +97 -25
- package/lib/views/transcript-render.js +542 -170
- package/lib/views/transcript-render.js.map +1 -1
- package/lib/views/transcript-search.d.ts +39 -6
- package/lib/views/transcript-search.js +46 -11
- package/lib/views/transcript-search.js.map +1 -1
- package/lib/views/transcript-types.d.ts +63 -5
- package/lib/views/transcript-types.js +23 -11
- package/lib/views/transcript-types.js.map +1 -1
- package/package.json +95 -65
- package/lib/commands/loop.d.ts +0 -52
- package/lib/commands/loop.js +0 -307
- package/lib/commands/loop.js.map +0 -1
- package/lib/commands/steer.d.ts +0 -5
- package/lib/commands/steer.js +0 -24
- package/lib/commands/steer.js.map +0 -1
- package/lib/runtime/terminal-reader.d.ts +0 -11
- package/lib/runtime/terminal-reader.js +0 -87
- package/lib/runtime/terminal-reader.js.map +0 -1
- package/lib/views/agent-hub.d.ts +0 -32
- package/lib/views/agent-hub.js +0 -206
- package/lib/views/agent-hub.js.map +0 -1
- package/lib/views/copy-selector.d.ts +0 -51
- package/lib/views/copy-selector.js +0 -139
- package/lib/views/copy-selector.js.map +0 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The four intents a caller actually has when it asks the reader something.
|
|
3
|
+
*
|
|
4
|
+
* `TuiPrompt` grew to forty-six optional fields because every new surface added
|
|
5
|
+
* one: `presentation`, `filterable`, `approveValue`,
|
|
6
|
+
* `dismissLabel`, `skippable`, `wait`, `interrupt`, `onSuperseded`,
|
|
7
|
+
* `refreshDocument`, `refreshOptions` … A caller passing `{ title, question,
|
|
8
|
+
* allowCustom: true }` had to know that omitting `options` means "free text" and
|
|
9
|
+
* that `allowCustom: false` is what makes a list non-editable. Nothing in the
|
|
10
|
+
* type said which fields belong together, so each new caller assembled its own
|
|
11
|
+
* combination and the interface kept widening.
|
|
12
|
+
*
|
|
13
|
+
* These four intents are measured, not invented: across 196 call sites, 109 ask
|
|
14
|
+
* for free text, 45 offer a list, 14 read a document, and the rest are those
|
|
15
|
+
* shapes with one extra field. Each function below names the intent, defaults
|
|
16
|
+
* what the intent always wants, and leaves the escape hatch — {@link TuiService.prompt}
|
|
17
|
+
* with the full type — for the handful of surfaces that genuinely need it.
|
|
18
|
+
*
|
|
19
|
+
* @module @agi-fans/dsh-tui/prompt-intents
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Ask for free text.
|
|
23
|
+
*
|
|
24
|
+
* This is the shape 109 of 196 call sites wanted and had to spell as
|
|
25
|
+
* `{ allowCustom: true, notify: false }`. A bare input needs no `options` array
|
|
26
|
+
* and no `presentation`; both are supplied here so the caller states one thing.
|
|
27
|
+
*/
|
|
28
|
+
export function askPrompt(request) {
|
|
29
|
+
return {
|
|
30
|
+
title: request.title,
|
|
31
|
+
question: request.question,
|
|
32
|
+
...(request.detail === undefined ? {} : { detail: request.detail }),
|
|
33
|
+
...(request.initialInput === undefined ? {} : { initialInput: request.initialInput }),
|
|
34
|
+
...(request.preserveWhitespace === true ? { preserveWhitespace: true } : {}),
|
|
35
|
+
...(request.secret === true ? { secret: true } : {}),
|
|
36
|
+
...(request.onCancelDraft === undefined ? {} : { onCancelDraft: request.onCancelDraft }),
|
|
37
|
+
...(request.submitLabel === undefined ? {} : { submitLabel: request.submitLabel }),
|
|
38
|
+
...(request.signal === undefined ? {} : { signal: request.signal }),
|
|
39
|
+
allowCustom: true,
|
|
40
|
+
notify: request.notify ?? false,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Offer a list of choices.
|
|
45
|
+
*
|
|
46
|
+
* The list is not editable: a caller that wants both a list and free text wants
|
|
47
|
+
* {@link askPrompt} with `detail`, or the full {@link TuiPrompt} if it really
|
|
48
|
+
* needs both. Keeping the two apart is what lets this function state the shape
|
|
49
|
+
* without an `allowCustom` flag the caller has to reason about.
|
|
50
|
+
*/
|
|
51
|
+
export function choosePrompt(request) {
|
|
52
|
+
return {
|
|
53
|
+
title: request.title,
|
|
54
|
+
question: request.question,
|
|
55
|
+
...(request.detail === undefined ? {} : { detail: request.detail }),
|
|
56
|
+
options: request.options,
|
|
57
|
+
...(request.initialValue === undefined ? {} : { initialValue: request.initialValue }),
|
|
58
|
+
...(request.filterable === true ? { filterable: true } : {}),
|
|
59
|
+
...(request.emptyText === undefined ? {} : { emptyText: request.emptyText }),
|
|
60
|
+
...(request.actions === undefined ? {} : { actions: request.actions }),
|
|
61
|
+
...(request.multiSelect === true ? { multiSelect: true } : {}),
|
|
62
|
+
...(request.initialValues === undefined ? {} : { initialValues: request.initialValues }),
|
|
63
|
+
...(request.allowEmptySelection === true ? { allowEmptySelection: true } : {}),
|
|
64
|
+
...(request.submitLabel === undefined ? {} : { submitLabel: request.submitLabel }),
|
|
65
|
+
...(request.signal === undefined ? {} : { signal: request.signal }),
|
|
66
|
+
allowCustom: false,
|
|
67
|
+
notify: request.notify ?? false,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Ask one yes/no question.
|
|
72
|
+
*
|
|
73
|
+
* Returns a boolean rather than a string or null, because "dismissed" and "no"
|
|
74
|
+
* are the same answer: a reader who presses Escape has not agreed to anything.
|
|
75
|
+
* Callers that need to tell those apart use the full prompt.
|
|
76
|
+
*/
|
|
77
|
+
export async function confirmPrompt(prompt, request) {
|
|
78
|
+
const accept = request.acceptLabel ?? 'Continue';
|
|
79
|
+
const answer = await prompt({
|
|
80
|
+
title: request.title,
|
|
81
|
+
question: request.question,
|
|
82
|
+
...(request.detail === undefined ? {} : { detail: request.detail }),
|
|
83
|
+
options: request.cancelLabel === null
|
|
84
|
+
? [{ label: accept, value: 'accept', ...(request.acceptDescription === undefined ? {} : { description: request.acceptDescription }) }]
|
|
85
|
+
: [
|
|
86
|
+
{ label: accept, value: 'accept', ...(request.acceptDescription === undefined ? {} : { description: request.acceptDescription }) },
|
|
87
|
+
{ label: request.cancelLabel ?? 'Cancel', value: 'cancel', ...(request.cancelDescription === undefined ? {} : { description: request.cancelDescription }) },
|
|
88
|
+
],
|
|
89
|
+
// A one-way door preselects its only row; dismissal is still a no.
|
|
90
|
+
...(request.cancelLabel === null ? { initialValue: 'accept' } : { initialValue: 'cancel' }),
|
|
91
|
+
allowCustom: false,
|
|
92
|
+
notify: request.notify ?? false,
|
|
93
|
+
...(request.signal === undefined ? {} : { signal: request.signal }),
|
|
94
|
+
});
|
|
95
|
+
return answer === 'accept';
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Show a document the reader can scroll, search, and leave.
|
|
99
|
+
*
|
|
100
|
+
* The surface is dropped automatically when the work it describes ends, so the
|
|
101
|
+
* caller does not have to pair an open with a close.
|
|
102
|
+
*/
|
|
103
|
+
export function readPrompt(request) {
|
|
104
|
+
return {
|
|
105
|
+
title: request.title,
|
|
106
|
+
question: request.question,
|
|
107
|
+
...(request.detail === undefined ? {} : { detail: request.detail }),
|
|
108
|
+
// A plain string becomes a source so the reader gets line numbers and search
|
|
109
|
+
// rather than a wrapped prose page; an explicit source wins.
|
|
110
|
+
...(request.source !== undefined
|
|
111
|
+
? { documentSource: request.source }
|
|
112
|
+
: request.text === undefined ? {} : { documentSource: { text: request.text } }),
|
|
113
|
+
...(request.position === undefined ? {} : { documentPosition: request.position }),
|
|
114
|
+
...(request.tail === true ? { documentTail: true } : {}),
|
|
115
|
+
...(request.image === undefined ? {} : { documentImage: request.image }),
|
|
116
|
+
...(request.refresh === undefined ? {} : { refreshDocument: request.refresh }),
|
|
117
|
+
...(request.onPosition === undefined ? {} : { onDocumentPosition: request.onPosition }),
|
|
118
|
+
options: [{ label: request.cancelLabel ?? 'Cancel', value: 'cancel' }],
|
|
119
|
+
presentation: 'document',
|
|
120
|
+
allowCustom: false,
|
|
121
|
+
notify: false,
|
|
122
|
+
...(request.signal === undefined ? {} : { signal: request.signal }),
|
|
123
|
+
...(request.interrupt === undefined ? {} : { interrupt: request.interrupt }),
|
|
124
|
+
...(request.onSuperseded === undefined ? {} : { onSuperseded: request.onSuperseded }),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=prompt-intents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-intents.js","sourceRoot":"","sources":["../src/prompt-intents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAkDH;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,OAiBzB;IACC,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,C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2
|
import type { Context } from '@deepseek-ai/cordis';
|
|
3
3
|
import type { ToolRestriction } from '@deepseek-ai/dsh-tools';
|
|
4
|
+
import { type Agent, type ModelSelectionRef } from '@deepseek-ai/dsh-agent';
|
|
4
5
|
export declare const name = "omdsh-agent-profile";
|
|
5
6
|
export declare const inject: string[];
|
|
6
7
|
/**
|
|
@@ -10,6 +11,10 @@ export declare const inject: string[];
|
|
|
10
11
|
* tool registered.
|
|
11
12
|
*/
|
|
12
13
|
export declare const SHELL_TOOL_ALIAS = "shell";
|
|
14
|
+
/** Compose a model selection and the session's preset before Agent publication. */
|
|
15
|
+
export declare function configureAgentContext(ctx: Context, agent: Agent, selection: ModelSelectionRef): Promise<{
|
|
16
|
+
agentPreset: string;
|
|
17
|
+
}>;
|
|
13
18
|
export interface Config {
|
|
14
19
|
/** Restrict inherited tools while preserving tools registered by this preset. */
|
|
15
20
|
tools?: ToolRestriction;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** Agent-preset helpers owned by the omdsh product composition. */
|
|
2
|
+
import { installModelSelection } from '@deepseek-ai/dsh-agent';
|
|
2
3
|
export const name = 'omdsh-agent-profile';
|
|
3
4
|
export const inject = ['tools'];
|
|
4
5
|
/**
|
|
@@ -8,6 +9,17 @@ export const inject = ['tools'];
|
|
|
8
9
|
* tool registered.
|
|
9
10
|
*/
|
|
10
11
|
export const SHELL_TOOL_ALIAS = 'shell';
|
|
12
|
+
/** Compose a model selection and the session's preset before Agent publication. */
|
|
13
|
+
export async function configureAgentContext(ctx, agent, selection) {
|
|
14
|
+
installModelSelection(ctx, selection);
|
|
15
|
+
const presets = ctx.get('agentPresets');
|
|
16
|
+
const projections = ctx.get('sessionProjections');
|
|
17
|
+
if (presets === undefined || projections === undefined)
|
|
18
|
+
throw new Error('agent configuration services are unavailable');
|
|
19
|
+
const preset = projections.stateOf(agent.session, 'agentPreset') ?? presets.defaultId;
|
|
20
|
+
const mounted = await presets.mount(ctx, preset);
|
|
21
|
+
return { agentPreset: mounted.id };
|
|
22
|
+
}
|
|
11
23
|
/** Global shell tool name mounted for one platform. */
|
|
12
24
|
export function shellToolName(platform = process.platform) {
|
|
13
25
|
return platform === 'win32' ? 'pwsh' : 'bash';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-profile.js","sourceRoot":"","sources":["../../src/runtime/agent-profile.ts"],"names":[],"mappings":"AAAA,mEAAmE;
|
|
1
|
+
{"version":3,"file":"agent-profile.js","sourceRoot":"","sources":["../../src/runtime/agent-profile.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAInE,OAAO,EAAE,qBAAqB,EAAsC,MAAM,wBAAwB,CAAA;AAIlG,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAA;AACzC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,CAAA;AAE/B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAA;AAEvC,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,GAAY,EAAE,KAAY,EAAE,SAA4B;IAClG,qBAAqB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAA;IACrC,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IACvC,MAAM,WAAW,GAAG,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;IACjD,IAAI,OAAO,KAAK,SAAS,IAAI,WAAW,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;IACvH,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,IAAI,OAAO,CAAC,SAAS,CAAA;IACrF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAChD,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,EAAE,CAAA;AACpC,CAAC;AAOD,uDAAuD;AACvD,MAAM,UAAU,aAAa,CAAC,WAA4B,OAAO,CAAC,QAAQ;IACxE,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAA;AAC/C,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,iBAAiB,CAC/B,WAA4B,EAC5B,WAA4B,OAAO,CAAC,QAAQ;IAE5C,IAAI,WAAW,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,WAAW,CAAA;IACvD,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,gBAAgB,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IACvG,OAAO,EAAE,GAAG,WAAW,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAA;AACvD,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAY,EAAE,SAAiB,EAAE;IACrD,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;QAAE,OAAM;IACtC,MAAM,WAAW,GAAG,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACnD,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,qCAAqC,CAAC,CAAA;AAC1F,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Remembered decisions over the Harness approval waterfall, never a sandbox override. */
|
|
2
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
4
|
+
import type { ApprovalRequestEvent } from '@deepseek-ai/dsh-user-approval/types';
|
|
5
|
+
export interface ApprovalAction {
|
|
6
|
+
tool: string;
|
|
7
|
+
arguments: string;
|
|
8
|
+
cwd: string;
|
|
9
|
+
workspace: string;
|
|
10
|
+
sandbox: string;
|
|
11
|
+
reason: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ApprovalRule extends ApprovalAction {
|
|
14
|
+
version: 1;
|
|
15
|
+
id: string;
|
|
16
|
+
scope: 'session' | 'workspace';
|
|
17
|
+
sessionId: string;
|
|
18
|
+
decision: 'allow' | 'reject';
|
|
19
|
+
createdAt: number;
|
|
20
|
+
}
|
|
21
|
+
export interface Config {
|
|
22
|
+
stateDir: string;
|
|
23
|
+
}
|
|
24
|
+
declare module '@deepseek-ai/cordis' {
|
|
25
|
+
interface Context {
|
|
26
|
+
omdshApprovalRules: ApprovalRules;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
declare module '@deepseek-ai/dsh-session/types' {
|
|
30
|
+
interface PluginRecordMap {
|
|
31
|
+
'plugin:omdsh/approval-rule-matched': {
|
|
32
|
+
id: string;
|
|
33
|
+
scope: 'session' | 'workspace';
|
|
34
|
+
decision: 'allow' | 'reject';
|
|
35
|
+
};
|
|
36
|
+
'plugin:omdsh/approval-rule-error': {
|
|
37
|
+
message: string;
|
|
38
|
+
};
|
|
39
|
+
'plugin:omdsh/workspace-changes': {
|
|
40
|
+
turn: number;
|
|
41
|
+
summary: import('@deepseek-ai/dsh-workspace-changes').WorkspaceChangesSummary;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Stable exact JSON comparison; whitespace and object-key order are not permissions. */
|
|
46
|
+
export declare function exactArguments(value: unknown): string;
|
|
47
|
+
export declare class ApprovalRules extends Service {
|
|
48
|
+
static inject: string[];
|
|
49
|
+
private readonly ownerContext;
|
|
50
|
+
private readonly directory;
|
|
51
|
+
private readonly pending;
|
|
52
|
+
constructor(ctx: Context, config: Config);
|
|
53
|
+
private observe;
|
|
54
|
+
describe(request: ApprovalRequestEvent): ApprovalAction | undefined;
|
|
55
|
+
list(agent: Agent): ApprovalRule[];
|
|
56
|
+
remember(request: ApprovalRequestEvent, scope: ApprovalRule['scope'], decision: ApprovalRule['decision']): ApprovalRule;
|
|
57
|
+
revoke(agent: Agent, id: string): void;
|
|
58
|
+
}
|
|
59
|
+
export default ApprovalRules;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/** Remembered decisions over the Harness approval waterfall, never a sandbox override. */
|
|
2
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { join, resolve } from 'node:path';
|
|
6
|
+
import { appendPluginRecord } from '@deepseek-ai/dsh-session';
|
|
7
|
+
import { currentWorkingDirectory } from "../session/working-directory.js";
|
|
8
|
+
/** Stable exact JSON comparison; whitespace and object-key order are not permissions. */
|
|
9
|
+
export function exactArguments(value) {
|
|
10
|
+
const canonical = (item) => {
|
|
11
|
+
if (item === null || typeof item === 'string' || typeof item === 'boolean')
|
|
12
|
+
return item;
|
|
13
|
+
if (typeof item === 'number' && Number.isFinite(item))
|
|
14
|
+
return item;
|
|
15
|
+
if (Array.isArray(item))
|
|
16
|
+
return item.map(canonical);
|
|
17
|
+
if (typeof item === 'object' && item !== null)
|
|
18
|
+
return Object.fromEntries(Object.entries(item).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, child]) => [key, canonical(child)]));
|
|
19
|
+
throw new Error('Approval arguments must be lossless JSON.');
|
|
20
|
+
};
|
|
21
|
+
const text = JSON.stringify(canonical(value));
|
|
22
|
+
if (Buffer.byteLength(text) > 64 * 1024)
|
|
23
|
+
throw new Error('This action is too large to remember; approve it once.');
|
|
24
|
+
return text;
|
|
25
|
+
}
|
|
26
|
+
function sameAction(rule, action) {
|
|
27
|
+
return rule.tool === action.tool && rule.arguments === action.arguments && rule.cwd === action.cwd
|
|
28
|
+
&& rule.workspace === action.workspace && rule.sandbox === action.sandbox && rule.reason === action.reason;
|
|
29
|
+
}
|
|
30
|
+
export class ApprovalRules extends Service {
|
|
31
|
+
static inject = ['tools', 'approval', 'sandboxPolicy'];
|
|
32
|
+
ownerContext;
|
|
33
|
+
directory;
|
|
34
|
+
pending = new Map();
|
|
35
|
+
constructor(ctx, config) {
|
|
36
|
+
super(ctx, 'omdshApprovalRules');
|
|
37
|
+
if (typeof config?.stateDir !== 'string' || config.stateDir.trim() === '')
|
|
38
|
+
throw new Error('Approval rules require a private state directory.');
|
|
39
|
+
this.ownerContext = ctx;
|
|
40
|
+
this.directory = config.stateDir;
|
|
41
|
+
// Both hook asks before dispatch and capability-owned asks inside the body
|
|
42
|
+
// carry the registry's immutable execution, including native and PTC calls.
|
|
43
|
+
ctx.on('tools/pre-execute', (exec, next) => this.observe(exec, next), true);
|
|
44
|
+
ctx.on('tools/execute', (exec, next) => this.observe(exec, next), true);
|
|
45
|
+
ctx.on('approval/request', async (request, next) => {
|
|
46
|
+
if (request.signal?.aborted)
|
|
47
|
+
return 'cancelled';
|
|
48
|
+
try {
|
|
49
|
+
const action = this.describe(request);
|
|
50
|
+
if (action === undefined)
|
|
51
|
+
return next();
|
|
52
|
+
const matches = this.list(request.agent).filter(rule => sameAction(rule, action));
|
|
53
|
+
const rule = matches.find(rule => rule.decision === 'reject') ?? matches[0];
|
|
54
|
+
if (rule === undefined)
|
|
55
|
+
return next();
|
|
56
|
+
appendPluginRecord(request.agent.session, 'plugin:omdsh/approval-rule-matched', { id: rule.id, scope: rule.scope, decision: rule.decision });
|
|
57
|
+
return rule.decision === 'allow' ? 'allowed-once' : 'rejected';
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Corrupt/unreadable permission state must never grant the request.
|
|
61
|
+
appendPluginRecord(request.agent.session, 'plugin:omdsh/approval-rule-error', { message: 'Approval rule storage is invalid or unavailable. The request was rejected; inspect /permission → Approval rules.' });
|
|
62
|
+
return 'rejected';
|
|
63
|
+
}
|
|
64
|
+
}, true);
|
|
65
|
+
ctx.effect(() => () => { this.pending.clear(); });
|
|
66
|
+
}
|
|
67
|
+
async observe(exec, next) {
|
|
68
|
+
if (exec.agent === undefined)
|
|
69
|
+
return next();
|
|
70
|
+
let argumentsText;
|
|
71
|
+
try {
|
|
72
|
+
argumentsText = exactArguments(exec.arguments);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return next();
|
|
76
|
+
}
|
|
77
|
+
const policy = this.ownerContext.get('sandboxPolicy').resolve({ session: exec.agent.session });
|
|
78
|
+
const action = { tool: exec.name, arguments: argumentsText, cwd: resolve(currentWorkingDirectory(this.ownerContext, exec.agent.session)),
|
|
79
|
+
workspace: resolve(policy.workspaceRoot), sandbox: policy.mode };
|
|
80
|
+
let calls = this.pending.get(exec.agent);
|
|
81
|
+
if (calls === undefined) {
|
|
82
|
+
calls = new Map();
|
|
83
|
+
this.pending.set(exec.agent, calls);
|
|
84
|
+
}
|
|
85
|
+
if (calls.has(exec.callId))
|
|
86
|
+
throw new Error('Duplicate pending approval call identity.');
|
|
87
|
+
calls.set(exec.callId, action);
|
|
88
|
+
try {
|
|
89
|
+
return await next();
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
calls.delete(exec.callId);
|
|
93
|
+
if (calls.size === 0)
|
|
94
|
+
this.pending.delete(exec.agent);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
describe(request) {
|
|
98
|
+
const action = request.callId === undefined ? undefined : this.pending.get(request.agent)?.get(request.callId);
|
|
99
|
+
if (action === undefined || action.tool !== request.toolName || request.signal?.aborted)
|
|
100
|
+
return undefined;
|
|
101
|
+
const reason = request.reason ?? '';
|
|
102
|
+
if (Buffer.byteLength(reason) > 64 * 1024)
|
|
103
|
+
return undefined;
|
|
104
|
+
return { ...action, reason };
|
|
105
|
+
}
|
|
106
|
+
list(agent) {
|
|
107
|
+
const workspace = resolve(this.ownerContext.get('sandboxPolicy').resolve({ session: agent.session }).workspaceRoot);
|
|
108
|
+
let names;
|
|
109
|
+
try {
|
|
110
|
+
names = readdirSync(this.directory).filter(name => name.endsWith('.json'));
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
if (error.code === 'ENOENT')
|
|
114
|
+
return [];
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
if (names.length > 500)
|
|
118
|
+
throw new Error('Too many approval rules; revoke unused decisions.');
|
|
119
|
+
return names.sort().map(name => {
|
|
120
|
+
const path = join(this.directory, name), stat = lstatSync(path);
|
|
121
|
+
if (!stat.isFile() || stat.size > 160 * 1024)
|
|
122
|
+
throw new Error('Approval rule must be a bounded regular file.');
|
|
123
|
+
const text = readFileSync(path, 'utf8');
|
|
124
|
+
if (Buffer.byteLength(text) > 160 * 1024)
|
|
125
|
+
throw new Error('Approval rule exceeds the record limit.');
|
|
126
|
+
const rule = JSON.parse(text);
|
|
127
|
+
if (!validRule(rule) || name !== rule.id + '.json')
|
|
128
|
+
throw new Error('Invalid approval rule record.');
|
|
129
|
+
if (exactArguments(JSON.parse(rule.arguments)) !== rule.arguments)
|
|
130
|
+
throw new Error('Approval rule arguments are not canonical JSON.');
|
|
131
|
+
return rule;
|
|
132
|
+
}).filter(rule => rule.workspace === workspace && (rule.scope === 'workspace' || rule.sessionId === agent.id));
|
|
133
|
+
}
|
|
134
|
+
remember(request, scope, decision) {
|
|
135
|
+
request.signal?.throwIfAborted();
|
|
136
|
+
if (!['session', 'workspace'].includes(scope) || !['allow', 'reject'].includes(decision))
|
|
137
|
+
throw new Error('Invalid approval rule selection.');
|
|
138
|
+
const action = this.describe(request);
|
|
139
|
+
if (action === undefined)
|
|
140
|
+
throw new Error('The requested action is no longer pending; no rule was saved.');
|
|
141
|
+
// Read before mutation; do not overwrite corrupted permissions or duplicate
|
|
142
|
+
// an existing decision. Files are independent so other processes can revoke
|
|
143
|
+
// or add unrelated rules without a read-modify-write race on one document.
|
|
144
|
+
const rules = this.list(request.agent);
|
|
145
|
+
const existing = rules.find(rule => rule.scope === scope && rule.decision === decision && sameAction(rule, action));
|
|
146
|
+
if (existing !== undefined)
|
|
147
|
+
return existing;
|
|
148
|
+
const rule = { ...action, version: 1, id: randomUUID(), scope, decision, sessionId: request.agent.id, createdAt: Date.now() };
|
|
149
|
+
mkdirSync(this.directory, { recursive: true, mode: 0o700 });
|
|
150
|
+
if (readdirSync(this.directory).filter(name => name.endsWith('.json')).length >= 500)
|
|
151
|
+
throw new Error('Revoke an unused approval rule before adding another.');
|
|
152
|
+
const target = join(this.directory, rule.id + '.json'), temp = target + '.tmp';
|
|
153
|
+
try {
|
|
154
|
+
writeFileSync(temp, JSON.stringify(rule) + '\n', { mode: 0o600, flag: 'wx' });
|
|
155
|
+
renameSync(temp, target);
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
rmSync(temp, { force: true });
|
|
159
|
+
}
|
|
160
|
+
return rule;
|
|
161
|
+
}
|
|
162
|
+
revoke(agent, id) {
|
|
163
|
+
const rule = this.list(agent).find(rule => rule.id === id);
|
|
164
|
+
if (rule === undefined)
|
|
165
|
+
throw new Error('That approval rule does not belong to this session or workspace.');
|
|
166
|
+
rmSync(join(this.directory, rule.id + '.json'), { force: true });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function validRule(value) {
|
|
170
|
+
if (value === null || typeof value !== 'object')
|
|
171
|
+
return false;
|
|
172
|
+
const rule = value;
|
|
173
|
+
return rule.version === 1 && typeof rule.id === 'string' && /^[0-9a-f-]{36}$/u.test(rule.id)
|
|
174
|
+
&& ['tool', 'arguments', 'cwd', 'workspace', 'sandbox', 'reason', 'sessionId'].every(key => typeof rule[key] === 'string')
|
|
175
|
+
&& ['session', 'workspace'].includes(String(rule.scope)) && ['allow', 'reject'].includes(String(rule.decision))
|
|
176
|
+
&& Number.isSafeInteger(rule.createdAt);
|
|
177
|
+
}
|
|
178
|
+
export default ApprovalRules;
|
|
179
|
+
//# sourceMappingURL=approval-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;WAC5G,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AAC3C,CAAC;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Durable preset policy for tool-free side consultations. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
export declare const BTW_PRESET = "btw";
|
|
4
|
+
export declare const name = "omdsh-btw-policy";
|
|
5
|
+
export declare const inject: string[];
|
|
6
|
+
/** No scope-local tool or an earlier allow decision may bypass this guard. */
|
|
7
|
+
export declare function apply(ctx: Context): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Durable preset policy for tool-free side consultations. */
|
|
2
|
+
export const BTW_PRESET = 'btw';
|
|
3
|
+
export const name = 'omdsh-btw-policy';
|
|
4
|
+
export const inject = ['tools', 'systemPrompt'];
|
|
5
|
+
/** No scope-local tool or an earlier allow decision may bypass this guard. */
|
|
6
|
+
export function apply(ctx) {
|
|
7
|
+
ctx.effect(() => ctx.tools.presentAs('native'), 'side consultation tool presentation');
|
|
8
|
+
ctx.effect(() => ctx.tools.restrict({ allow: [] }), 'side consultation inherited tools');
|
|
9
|
+
ctx.effect(() => ctx.tools.guard(() => 'Side consultations cannot use tools.'), 'side consultation execution guard');
|
|
10
|
+
ctx.on('system-prompt/assemble', async (_assembly, _context, next) => ({ ...await next(), tools: [], contexts: [] }));
|
|
11
|
+
// New workspace observations belong to the primary run. Preserve rejection
|
|
12
|
+
// policies, but admit only explicit side questions after the copied prefix.
|
|
13
|
+
ctx.on('agent/pre-step', async ({ messages }, next) => {
|
|
14
|
+
const decision = await next();
|
|
15
|
+
return decision.kind === 'reject' ? decision : { ...decision, messages: messages.filter(message => message.source.kind === 'user') };
|
|
16
|
+
}, true);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=btw-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,EAAE,CAAA;IACtI,CAAC,EAAE,IAAI,CAAC,CAAA;AACV,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Durable side consultations over the public Harness Agent and fork seams. */
|
|
2
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { Agent, ModelSelection } from '@deepseek-ai/dsh-agent';
|
|
4
|
+
import { Session, SessionId, type SessionEvent } from '@deepseek-ai/dsh-session';
|
|
5
|
+
import { type TurnTokenUsage } from '@deepseek-ai/dsh-token-meter/client';
|
|
6
|
+
export interface BtwTopic {
|
|
7
|
+
version: 1;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
parentSessionId: string;
|
|
10
|
+
prefixEvents: number;
|
|
11
|
+
question: string;
|
|
12
|
+
createdAt: number;
|
|
13
|
+
updatedAt: number;
|
|
14
|
+
status: 'running' | 'completed' | 'cancelled' | 'failed';
|
|
15
|
+
}
|
|
16
|
+
export interface BtwReply {
|
|
17
|
+
topic: BtwTopic;
|
|
18
|
+
text: string;
|
|
19
|
+
usage?: TurnTokenUsage;
|
|
20
|
+
error?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface Config {
|
|
23
|
+
stateDir?: string;
|
|
24
|
+
}
|
|
25
|
+
declare module '@deepseek-ai/cordis' {
|
|
26
|
+
interface Context {
|
|
27
|
+
omdshBtw: BtwService;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Preserve the exact source prefix, then select the child's independent world. */
|
|
31
|
+
export declare function btwSeed(parent: Session, id: SessionId, cwd: string): readonly SessionEvent[];
|
|
32
|
+
export declare class BtwService extends Service {
|
|
33
|
+
static inject: string[];
|
|
34
|
+
private readonly ownerContext;
|
|
35
|
+
private readonly stateDir;
|
|
36
|
+
private readonly topics;
|
|
37
|
+
private readonly active;
|
|
38
|
+
private readonly tasks;
|
|
39
|
+
private readonly closing;
|
|
40
|
+
constructor(ctx: Context, config?: Config);
|
|
41
|
+
list(parent: Agent): BtwTopic[];
|
|
42
|
+
read(parent: Agent, id: string, signal: AbortSignal): Promise<string>;
|
|
43
|
+
consult(parent: Agent, question: string, selection: ModelSelection, signal: AbortSignal, update: (text: string) => void, topicId?: string): Promise<BtwReply>;
|
|
44
|
+
private runQuestion;
|
|
45
|
+
private saveTopic;
|
|
46
|
+
}
|
|
47
|
+
export default BtwService;
|