@strands-agents/cli 0.1.1 → 0.1.3
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 +15 -8
- package/dist/src/cli/run.js +2 -9
- package/dist/src/cli/run.js.map +1 -1
- package/dist/src/tui/agent-configuration.js +30 -38
- package/dist/src/tui/agent-configuration.js.map +1 -1
- package/dist/src/tui/builtin-tools.js +29 -0
- package/dist/src/tui/builtin-tools.js.map +1 -1
- package/dist/src/tui/chat/commands.js +1 -0
- package/dist/src/tui/chat/commands.js.map +1 -1
- package/dist/src/tui/chat/controller.js +93 -136
- package/dist/src/tui/chat/controller.js.map +1 -1
- package/dist/src/tui/chat/help.js +2 -1
- package/dist/src/tui/chat/help.js.map +1 -1
- package/dist/src/tui/chat/panels.js +22 -20
- package/dist/src/tui/chat/panels.js.map +1 -1
- package/dist/src/tui/chat/types.js.map +1 -1
- package/dist/src/tui/config.js +4 -61
- package/dist/src/tui/config.js.map +1 -1
- package/dist/src/tui/model/context.js +10 -2
- package/dist/src/tui/model/context.js.map +1 -1
- package/dist/src/tui/permissions/policy.js +1 -9
- package/dist/src/tui/permissions/policy.js.map +1 -1
- package/dist/src/tui/permissions/settings.js +9 -8
- package/dist/src/tui/permissions/settings.js.map +1 -1
- package/dist/src/tui/project/export.js +19 -2
- package/dist/src/tui/project/export.js.map +1 -1
- package/dist/src/tui/project/run.js +0 -2
- package/dist/src/tui/project/run.js.map +1 -1
- package/dist/src/tui/project/worker.py +6 -0
- package/dist/src/tui/provider/aws-client.js +3 -3
- package/dist/src/tui/provider/aws-client.js.map +1 -1
- package/dist/src/tui/run.js +5 -12
- package/dist/src/tui/run.js.map +1 -1
- package/dist/src/tui/runtime.js +8 -9
- package/dist/src/tui/runtime.js.map +1 -1
- package/dist/src/tui/session/conversations.js +2 -5
- package/dist/src/tui/session/conversations.js.map +1 -1
- package/dist/src/tui/strands-backend.js +0 -6
- package/dist/src/tui/strands-backend.js.map +1 -1
- package/dist/src/tui/terminal/composer.js +1 -1
- package/dist/src/tui/terminal/composer.js.map +1 -1
- package/dist/src/tui/view/app.js +36 -65
- package/dist/src/tui/view/app.js.map +1 -1
- package/dist/src/tui/view/chat-root.js +38 -29
- package/dist/src/tui/view/chat-root.js.map +1 -1
- package/dist/src/tui/view/chat-view.js +4 -39
- package/dist/src/tui/view/chat-view.js.map +1 -1
- package/dist/src/tui/view/frog-intro-renderer.js +14 -84
- package/dist/src/tui/view/frog-intro-renderer.js.map +1 -1
- package/dist/src/tui/view/help-footer.js +16 -12
- package/dist/src/tui/view/help-footer.js.map +1 -1
- package/dist/src/tui/view/interaction.js +1 -1
- package/dist/src/tui/view/interaction.js.map +1 -1
- package/dist/src/tui/view/intro.js +25 -3
- package/dist/src/tui/view/intro.js.map +1 -1
- package/dist/src/tui/view/mcp-trust-prompt.js +17 -0
- package/dist/src/tui/view/mcp-trust-prompt.js.map +1 -0
- package/dist/src/tui/view/model-panel.js +5 -6
- package/dist/src/tui/view/model-panel.js.map +1 -1
- package/dist/src/tui/view/panel-components.js +3 -2
- package/dist/src/tui/view/panel-components.js.map +1 -1
- package/dist/src/tui/view/panels.js +19 -11
- package/dist/src/tui/view/panels.js.map +1 -1
- package/dist/src/tui/view/presentation.js +2 -1
- package/dist/src/tui/view/presentation.js.map +1 -1
- package/dist/src/tui/view/setup-wizard/index.js +248 -172
- package/dist/src/tui/view/setup-wizard/index.js.map +1 -1
- package/dist/src/tui/view/setup-wizard/progress.js +1 -2
- package/dist/src/tui/view/setup-wizard/progress.js.map +1 -1
- package/dist/src/tui/view/setup-wizard/providers.js +11 -3
- package/dist/src/tui/view/setup-wizard/providers.js.map +1 -1
- package/dist/src/tui/view/setup-wizard/steps.js +97 -54
- package/dist/src/tui/view/setup-wizard/steps.js.map +1 -1
- package/dist/src/tui/view/setup-wizard/use-provider-discovery.js +1 -3
- package/dist/src/tui/view/setup-wizard/use-provider-discovery.js.map +1 -1
- package/dist/src/tui/view/startup-view.js +4 -2
- package/dist/src/tui/view/startup-view.js.map +1 -1
- package/package.json +2 -2
- package/dist/src/tui/agent-setup.js +0 -80
- package/dist/src/tui/agent-setup.js.map +0 -1
- package/dist/src/tui/setup/questions.js +0 -277
- package/dist/src/tui/setup/questions.js.map +0 -1
- package/dist/src/tui/view/setup-question.js +0 -90
- package/dist/src/tui/view/setup-question.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { homedir } from 'node:os';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
-
import { clonePanel, effortSlider, permissionRequestRows, formatPermissionPanelBody, formatTaskActivity, modelFilters, taskDetailRows, taskDetailTitle, settingsCategoryFilters, settingsRows, taskRows, sanitizeRows, makePanel, modelRows, sessionRows,
|
|
3
|
+
import { clonePanel, effortSlider, permissionRequestRows, formatPermissionPanelBody, formatTaskActivity, modelFilters, taskDetailRows, taskDetailTitle, settingsCategoryFilters, settingsRows, taskRows, sanitizeRows, makePanel, modelRows, sessionRows, skillRows, skillDetailRows, permissionSettingsRows, builtinToolRows, mcpRows, mcpOptions, BACKGROUND_TASK_WAIT_TOGGLE, } from './panels.js';
|
|
4
4
|
import { LOCAL_COMMAND_NAMES, parseCommandInvocation } from './commands.js';
|
|
5
5
|
import { helpRows } from './help.js';
|
|
6
6
|
import { DEFAULT_CHAT_SETTINGS, DEFAULT_SETTINGS_CATEGORY, SETTINGS_CATEGORIES, parseSettingUpdate, } from '../settings.js';
|
|
@@ -38,14 +38,13 @@ export class ChatController {
|
|
|
38
38
|
_mcp;
|
|
39
39
|
_settings;
|
|
40
40
|
_streamPresentation;
|
|
41
|
-
_pinnedModels;
|
|
42
|
-
_setModelPinned;
|
|
43
41
|
_setSettings;
|
|
44
42
|
_requestSetup;
|
|
43
|
+
_builtinTools;
|
|
44
|
+
_builtinToolSelection = new Set();
|
|
45
45
|
_exportAgentProject;
|
|
46
46
|
_project;
|
|
47
47
|
_copyText;
|
|
48
|
-
_setupQuestions;
|
|
49
48
|
_exportedPath;
|
|
50
49
|
_backend;
|
|
51
50
|
_activeProjector;
|
|
@@ -55,7 +54,6 @@ export class ChatController {
|
|
|
55
54
|
_pendingSubmissionRun;
|
|
56
55
|
_stopWatchingTasks;
|
|
57
56
|
_stopWatchingPermissions;
|
|
58
|
-
_stopWatchingSetupQuestions;
|
|
59
57
|
_stopWatchingTaskActivity;
|
|
60
58
|
_usageSubscriptions = new Set();
|
|
61
59
|
_usageGeneration = 0;
|
|
@@ -74,7 +72,6 @@ export class ChatController {
|
|
|
74
72
|
_deferredModelNoticeId;
|
|
75
73
|
_resourceChanging = false;
|
|
76
74
|
_composerStatus;
|
|
77
|
-
_setupGuideAnswer;
|
|
78
75
|
_closed = false;
|
|
79
76
|
_exitCode;
|
|
80
77
|
_hardExitCode;
|
|
@@ -95,14 +92,12 @@ export class ChatController {
|
|
|
95
92
|
this._mcp = options.mcp;
|
|
96
93
|
this._settings = globalThis.structuredClone({ ...DEFAULT_CHAT_SETTINGS, ...options.settings });
|
|
97
94
|
this._streamPresentation = options.streamPresentation;
|
|
98
|
-
this._pinnedModels = new Set(options.pinnedModels ?? []);
|
|
99
|
-
this._setModelPinned = options.setModelPinned;
|
|
100
95
|
this._setSettings = options.setSettings;
|
|
101
96
|
this._requestSetup = options.requestSetup;
|
|
97
|
+
this._builtinTools = options.builtinTools;
|
|
102
98
|
this._exportAgentProject = options.exportAgentProject;
|
|
103
99
|
this._project = options.project;
|
|
104
100
|
this._copyText = options.copyText ?? copyTerminalText;
|
|
105
|
-
this._setupQuestions = options.setupQuestions;
|
|
106
101
|
const info = backend.info?.();
|
|
107
102
|
this._runtime = {
|
|
108
103
|
agent: backend.name,
|
|
@@ -146,14 +141,6 @@ export class ChatController {
|
|
|
146
141
|
this._closePermissionPanel();
|
|
147
142
|
}
|
|
148
143
|
});
|
|
149
|
-
this._stopWatchingSetupQuestions = this._setupQuestions?.subscribe((request) => {
|
|
150
|
-
if (request) {
|
|
151
|
-
this._openSetupQuestion(request);
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
this._closeSetupQuestion();
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
144
|
}
|
|
158
145
|
subscribe = (listener) => {
|
|
159
146
|
this._listeners.add(listener);
|
|
@@ -210,14 +197,14 @@ export class ChatController {
|
|
|
210
197
|
? invocation.token
|
|
211
198
|
: undefined;
|
|
212
199
|
}
|
|
213
|
-
async start(firstRequest
|
|
200
|
+
async start(firstRequest) {
|
|
214
201
|
if (firstRequest) {
|
|
215
202
|
const prompt = firstRequest.trim();
|
|
216
203
|
if (prompt.startsWith('!')) {
|
|
217
204
|
await this._executeSubmission(prompt);
|
|
218
205
|
}
|
|
219
206
|
else {
|
|
220
|
-
await this._runPrompt(prompt
|
|
207
|
+
await this._runPrompt(prompt);
|
|
221
208
|
}
|
|
222
209
|
}
|
|
223
210
|
}
|
|
@@ -230,9 +217,6 @@ export class ChatController {
|
|
|
230
217
|
this.close();
|
|
231
218
|
return undefined;
|
|
232
219
|
}
|
|
233
|
-
if (this._panel?.kind === 'question' && this._respondSetupQuestionText(prompt)) {
|
|
234
|
-
return undefined;
|
|
235
|
-
}
|
|
236
220
|
if (/^\/help(?:\s|$)/iu.test(prompt) && !this._resourceChanging && this._panel?.kind !== 'permission') {
|
|
237
221
|
return this._executeSubmission(prompt);
|
|
238
222
|
}
|
|
@@ -379,16 +363,13 @@ export class ChatController {
|
|
|
379
363
|
this._panelStack.length = 0;
|
|
380
364
|
return this._runStream(prompt, this._backend.streamShell(command));
|
|
381
365
|
}
|
|
382
|
-
async _runPrompt(prompt
|
|
366
|
+
async _runPrompt(prompt) {
|
|
383
367
|
if (this._closed || this._activeProjector || this._drainingProjector || this._resourceChanging) {
|
|
384
368
|
return undefined;
|
|
385
369
|
}
|
|
386
|
-
if (this._setupQuestions && displayPrompt) {
|
|
387
|
-
this._setupGuideAnswer = displayPrompt;
|
|
388
|
-
}
|
|
389
370
|
this._panel = undefined;
|
|
390
371
|
this._panelStack.length = 0;
|
|
391
|
-
return this._runStream(
|
|
372
|
+
return this._runStream(prompt, this._backend.stream(prompt));
|
|
392
373
|
}
|
|
393
374
|
async _runPeerMessage(message) {
|
|
394
375
|
if (this._closed ||
|
|
@@ -579,8 +560,6 @@ export class ChatController {
|
|
|
579
560
|
this._stopWatchingTasks = undefined;
|
|
580
561
|
this._stopWatchingPermissions?.();
|
|
581
562
|
this._stopWatchingPermissions = undefined;
|
|
582
|
-
this._stopWatchingSetupQuestions?.();
|
|
583
|
-
this._stopWatchingSetupQuestions = undefined;
|
|
584
563
|
this._stopTaskActivity();
|
|
585
564
|
this._listeners.clear();
|
|
586
565
|
await Promise.allSettled([Promise.resolve().then(() => this._backend.dispose?.()), this._mcp?.dispose()]);
|
|
@@ -653,12 +632,12 @@ export class ChatController {
|
|
|
653
632
|
}
|
|
654
633
|
}
|
|
655
634
|
dismissPanel() {
|
|
656
|
-
if (!this._panel ||
|
|
657
|
-
this._resourceChanging ||
|
|
658
|
-
this._panel.kind === 'permission' ||
|
|
659
|
-
this._panel.kind === 'question') {
|
|
635
|
+
if (!this._panel || this._resourceChanging || this._panel.kind === 'permission') {
|
|
660
636
|
return false;
|
|
661
637
|
}
|
|
638
|
+
if (this._panel.kind === 'tools' && !this._applyBuiltinTools()) {
|
|
639
|
+
return true;
|
|
640
|
+
}
|
|
662
641
|
this._stopTaskActivity();
|
|
663
642
|
this._panel = this._panelStack.pop();
|
|
664
643
|
this._emit();
|
|
@@ -682,6 +661,7 @@ export class ChatController {
|
|
|
682
661
|
}
|
|
683
662
|
return true;
|
|
684
663
|
}
|
|
664
|
+
case 'effort':
|
|
685
665
|
case 'models':
|
|
686
666
|
return row.value.startsWith('effort:')
|
|
687
667
|
? this._selectEffort(row.value.slice('effort:'.length))
|
|
@@ -694,6 +674,8 @@ export class ChatController {
|
|
|
694
674
|
: this._openTaskDetail(row.value);
|
|
695
675
|
case 'permissions':
|
|
696
676
|
return this._updatePermissions(row.value);
|
|
677
|
+
case 'tools':
|
|
678
|
+
return this._toggleBuiltinTool(row.value);
|
|
697
679
|
case 'settings':
|
|
698
680
|
return row.value.startsWith('settings:')
|
|
699
681
|
? this._openSettingsCategory(row.value)
|
|
@@ -709,8 +691,6 @@ export class ChatController {
|
|
|
709
691
|
: false;
|
|
710
692
|
case 'permission':
|
|
711
693
|
return this._respondPermission(row.value);
|
|
712
|
-
case 'question':
|
|
713
|
-
return this._respondSetupQuestion(row.value);
|
|
714
694
|
default:
|
|
715
695
|
return false;
|
|
716
696
|
}
|
|
@@ -718,50 +698,6 @@ export class ChatController {
|
|
|
718
698
|
openContextPanel() {
|
|
719
699
|
this._openPanel('context', 'Context usage', []);
|
|
720
700
|
}
|
|
721
|
-
async toggleModelPin(modelId) {
|
|
722
|
-
const normalized = sanitizeTerminalText(modelId).trim();
|
|
723
|
-
if (!normalized) {
|
|
724
|
-
return false;
|
|
725
|
-
}
|
|
726
|
-
const pinned = !this._pinnedModels.has(normalized);
|
|
727
|
-
try {
|
|
728
|
-
await this._setModelPinned?.(normalized, pinned);
|
|
729
|
-
if (pinned) {
|
|
730
|
-
this._pinnedModels.add(normalized);
|
|
731
|
-
}
|
|
732
|
-
else {
|
|
733
|
-
this._pinnedModels.delete(normalized);
|
|
734
|
-
}
|
|
735
|
-
if (this._panel?.kind === 'models') {
|
|
736
|
-
const rows = this._panel.rows
|
|
737
|
-
.map((row) => {
|
|
738
|
-
if (row.value !== normalized) {
|
|
739
|
-
return row;
|
|
740
|
-
}
|
|
741
|
-
const { pinned: _pinned, ...rest } = row;
|
|
742
|
-
return pinned ? { ...rest, pinned: true } : rest;
|
|
743
|
-
})
|
|
744
|
-
.sort((left, right) => {
|
|
745
|
-
const leftCurrent = left.badge?.text === 'current';
|
|
746
|
-
const rightCurrent = right.badge?.text === 'current';
|
|
747
|
-
if (leftCurrent !== rightCurrent) {
|
|
748
|
-
return leftCurrent ? -1 : 1;
|
|
749
|
-
}
|
|
750
|
-
if (Boolean(left.pinned) !== Boolean(right.pinned)) {
|
|
751
|
-
return left.pinned ? -1 : 1;
|
|
752
|
-
}
|
|
753
|
-
return left.label.localeCompare(right.label) || left.description.localeCompare(right.description);
|
|
754
|
-
});
|
|
755
|
-
this._panel = { ...this._panel, rows: sanitizeRows(rows) };
|
|
756
|
-
this._emit();
|
|
757
|
-
}
|
|
758
|
-
return true;
|
|
759
|
-
}
|
|
760
|
-
catch (error) {
|
|
761
|
-
this._openError('model pin failed', normalized, errorMessage(error));
|
|
762
|
-
return false;
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
701
|
sessionTarget(reference) {
|
|
766
702
|
return this._sessions && this._backend.protocol === 'strands'
|
|
767
703
|
? this._sessions.resolve(reference)
|
|
@@ -852,8 +788,6 @@ export class ChatController {
|
|
|
852
788
|
...(this._panel ? { panel: clonePanel(this._panel) } : {}),
|
|
853
789
|
runtime: cloneRuntime(this._runtime),
|
|
854
790
|
settings: globalThis.structuredClone(this._settings),
|
|
855
|
-
...(this._setupQuestions ? { setupGuide: true } : {}),
|
|
856
|
-
...(this._setupGuideAnswer ? { setupGuideAnswer: this._setupGuideAnswer } : {}),
|
|
857
791
|
...(this._exitCode !== undefined ? { exitCode: this._exitCode } : {}),
|
|
858
792
|
};
|
|
859
793
|
}
|
|
@@ -873,6 +807,7 @@ export class ChatController {
|
|
|
873
807
|
skills: this._skills !== undefined,
|
|
874
808
|
mcp: this._mcp !== undefined,
|
|
875
809
|
setup: this._requestSetup !== undefined,
|
|
810
|
+
tools: this._builtinTools !== undefined,
|
|
876
811
|
export: this._exportAgentProject !== undefined,
|
|
877
812
|
}), {
|
|
878
813
|
searchable: true,
|
|
@@ -900,7 +835,12 @@ export class ChatController {
|
|
|
900
835
|
await (argument ? this._selectModel(argument) : this.openModelPanel());
|
|
901
836
|
break;
|
|
902
837
|
case 'effort':
|
|
903
|
-
|
|
838
|
+
if (argument) {
|
|
839
|
+
await this._selectEffort(argument.toLowerCase());
|
|
840
|
+
}
|
|
841
|
+
else {
|
|
842
|
+
this._openEffortPanel();
|
|
843
|
+
}
|
|
904
844
|
break;
|
|
905
845
|
case 'sessions':
|
|
906
846
|
await (argument ? this._handleSessionsCommand(argument) : this._openSessionsPanel());
|
|
@@ -920,6 +860,9 @@ export class ChatController {
|
|
|
920
860
|
case 'setup':
|
|
921
861
|
this._requestSetup?.();
|
|
922
862
|
break;
|
|
863
|
+
case 'tools':
|
|
864
|
+
this._openBuiltinToolsPanel();
|
|
865
|
+
break;
|
|
923
866
|
case 'export':
|
|
924
867
|
await this._handleExportCommand(parseCommandInvocation(prompt)?.argument ?? '');
|
|
925
868
|
break;
|
|
@@ -935,6 +878,44 @@ export class ChatController {
|
|
|
935
878
|
}
|
|
936
879
|
}
|
|
937
880
|
}
|
|
881
|
+
_openBuiltinToolsPanel() {
|
|
882
|
+
if (!this._builtinTools) {
|
|
883
|
+
this._openError('tools unavailable', '/tools', this._project
|
|
884
|
+
? `This agent is defined in ${this._project.entrypoint}. Edit its tools there.`
|
|
885
|
+
: 'Tool selection is not available in this session.');
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
const choices = this._builtinTools.choices();
|
|
889
|
+
this._builtinToolSelection = new Set(choices.filter((choice) => choice.enabled).map((choice) => choice.name));
|
|
890
|
+
this._openPanel('tools', 'tools', builtinToolRows(choices, this._builtinToolSelection));
|
|
891
|
+
}
|
|
892
|
+
_toggleBuiltinTool(value) {
|
|
893
|
+
if (this._panel?.kind !== 'tools' || !this._builtinTools || !value.startsWith('tools:toggle:')) {
|
|
894
|
+
return false;
|
|
895
|
+
}
|
|
896
|
+
const name = decodeURIComponent(value.slice('tools:toggle:'.length));
|
|
897
|
+
if (!this._builtinToolSelection.delete(name)) {
|
|
898
|
+
this._builtinToolSelection.add(name);
|
|
899
|
+
}
|
|
900
|
+
// Keeping the panel id keeps the cursor on the toggled row.
|
|
901
|
+
const rows = builtinToolRows(this._builtinTools.choices(), this._builtinToolSelection);
|
|
902
|
+
this._panel = makePanel(this._panel.id, 'tools', 'tools', rows, {});
|
|
903
|
+
this._emit();
|
|
904
|
+
return true;
|
|
905
|
+
}
|
|
906
|
+
/** Closing `/tools` applies its selection; returns false when the change is blocked. */
|
|
907
|
+
_applyBuiltinTools() {
|
|
908
|
+
const choices = this._builtinTools?.choices() ?? [];
|
|
909
|
+
if (choices.every((choice) => choice.enabled === this._builtinToolSelection.has(choice.name))) {
|
|
910
|
+
return true;
|
|
911
|
+
}
|
|
912
|
+
if (this.busy || this._hasUnresolvedBackgroundTasks()) {
|
|
913
|
+
this._openError('tools not changed', '/tools', 'Finish or cancel running work, then change tools again.');
|
|
914
|
+
return false;
|
|
915
|
+
}
|
|
916
|
+
this._builtinTools?.apply([...this._builtinToolSelection]);
|
|
917
|
+
return true;
|
|
918
|
+
}
|
|
938
919
|
_openTasksPanel() {
|
|
939
920
|
this._openPanel('tasks', `tasks (${this._tasks.length})`, taskRows(this._tasks, this._backend.backgroundTasksWaitForCompletion?.()));
|
|
940
921
|
}
|
|
@@ -970,7 +951,18 @@ export class ChatController {
|
|
|
970
951
|
this._resourceChanging = false;
|
|
971
952
|
}
|
|
972
953
|
}
|
|
973
|
-
|
|
954
|
+
_openEffortPanel() {
|
|
955
|
+
const slider = effortSlider(this._backend.listEfforts?.() ?? []);
|
|
956
|
+
if (!slider || slider.disabled) {
|
|
957
|
+
this._openError('effort unavailable', this._runtime.model, 'This model does not support reasoning effort.');
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
this._openPanel('effort', 'effort', [], {
|
|
961
|
+
slider: { ...slider, focused: true },
|
|
962
|
+
body: `${modelDisplayName(this._runtime.model)}\n${this._runtime.model}`,
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
async openModelPanel() {
|
|
974
966
|
if (!this._backend.listModels) {
|
|
975
967
|
this._openError('models unavailable', this._runtime.model, 'This backend does not expose model selection.');
|
|
976
968
|
return;
|
|
@@ -983,10 +975,10 @@ export class ChatController {
|
|
|
983
975
|
}
|
|
984
976
|
const efforts = this._backend.listEfforts?.() ?? [];
|
|
985
977
|
const slider = effortSlider(efforts);
|
|
986
|
-
this._openPanel('models', `models (${models.length})`, modelRows(models, this.
|
|
978
|
+
this._openPanel('models', `models (${models.length})`, modelRows(models, this._runtime.model), {
|
|
987
979
|
searchable: true,
|
|
988
980
|
filters: modelFilters(models.map((model) => model.catalog).filter((catalog) => !!catalog), this._backend.protocol),
|
|
989
|
-
...(slider ? { slider
|
|
981
|
+
...(slider ? { slider } : {}),
|
|
990
982
|
body: `${modelDisplayName(this._runtime.model)}\n${this._runtime.model}`,
|
|
991
983
|
});
|
|
992
984
|
}
|
|
@@ -1050,7 +1042,7 @@ export class ChatController {
|
|
|
1050
1042
|
const selected = await this._backend.setEffort(effort);
|
|
1051
1043
|
this._context = {};
|
|
1052
1044
|
this._refreshRuntime();
|
|
1053
|
-
if (this._panel?.kind === 'models' && this._panel.slider) {
|
|
1045
|
+
if ((this._panel?.kind === 'models' || this._panel?.kind === 'effort') && this._panel.slider) {
|
|
1054
1046
|
this._panel = {
|
|
1055
1047
|
...this._panel,
|
|
1056
1048
|
slider: {
|
|
@@ -1333,7 +1325,7 @@ export class ChatController {
|
|
|
1333
1325
|
}
|
|
1334
1326
|
this._openError('unknown permission mode', argument, 'Use /permissions, /permissions default, or /permissions bypass.');
|
|
1335
1327
|
}
|
|
1336
|
-
_openPermissionsPanel() {
|
|
1328
|
+
_openPermissionsPanel(refresh = false) {
|
|
1337
1329
|
const status = this._backend.permissionStatus?.();
|
|
1338
1330
|
if (!status ||
|
|
1339
1331
|
!this._backend.setPermissionMode ||
|
|
@@ -1342,11 +1334,21 @@ export class ChatController {
|
|
|
1342
1334
|
this._openError('permissions unavailable', this._backend.name, 'Permission configuration is available only for the built-in Strands backend.');
|
|
1343
1335
|
return;
|
|
1344
1336
|
}
|
|
1345
|
-
|
|
1337
|
+
const options = {
|
|
1346
1338
|
...(status.mode === 'bypassPermissions'
|
|
1347
1339
|
? { body: 'WARNING: Permission checks are bypassed. Configured interventions and sandboxing still apply.' }
|
|
1348
1340
|
: {}),
|
|
1349
|
-
}
|
|
1341
|
+
};
|
|
1342
|
+
if (refresh && this._panel?.kind === 'permissions') {
|
|
1343
|
+
const currentId = this._panel.id;
|
|
1344
|
+
this._panel = {
|
|
1345
|
+
...this._makePanel('permissions', 'permissions', permissionSettingsRows(status, this._runtime.tools), options),
|
|
1346
|
+
id: currentId,
|
|
1347
|
+
};
|
|
1348
|
+
this._emit();
|
|
1349
|
+
return;
|
|
1350
|
+
}
|
|
1351
|
+
this._openPanel('permissions', 'permissions', permissionSettingsRows(status, this._runtime.tools), options);
|
|
1350
1352
|
}
|
|
1351
1353
|
async _updatePermissions(value) {
|
|
1352
1354
|
const [prefix, action, encodedValue] = value.split(':');
|
|
@@ -1371,7 +1373,7 @@ export class ChatController {
|
|
|
1371
1373
|
else {
|
|
1372
1374
|
await this._backend.allowPermission(toolName);
|
|
1373
1375
|
}
|
|
1374
|
-
this._openPermissionsPanel();
|
|
1376
|
+
this._openPermissionsPanel(true);
|
|
1375
1377
|
return true;
|
|
1376
1378
|
}
|
|
1377
1379
|
catch (error) {
|
|
@@ -1386,7 +1388,7 @@ export class ChatController {
|
|
|
1386
1388
|
}
|
|
1387
1389
|
try {
|
|
1388
1390
|
await this._backend.setPermissionMode(mode);
|
|
1389
|
-
this._openPermissionsPanel();
|
|
1391
|
+
this._openPermissionsPanel(true);
|
|
1390
1392
|
return true;
|
|
1391
1393
|
}
|
|
1392
1394
|
catch (error) {
|
|
@@ -1575,50 +1577,12 @@ export class ChatController {
|
|
|
1575
1577
|
this._closePermissionPanel();
|
|
1576
1578
|
return true;
|
|
1577
1579
|
}
|
|
1578
|
-
_respondSetupQuestion(value) {
|
|
1579
|
-
const [prefix, encodedRequestId, encodedChoiceId] = value.split(':');
|
|
1580
|
-
if (prefix !== 'question' || !encodedRequestId || !encodedChoiceId) {
|
|
1581
|
-
return false;
|
|
1582
|
-
}
|
|
1583
|
-
const previousAnswer = this._setupGuideAnswer;
|
|
1584
|
-
this._setupGuideAnswer = this._panel?.rows.find((row) => row.value === value)?.label;
|
|
1585
|
-
const responded = this._setupQuestions?.respond(decodeURIComponent(encodedRequestId), decodeURIComponent(encodedChoiceId)) ?? false;
|
|
1586
|
-
if (!responded) {
|
|
1587
|
-
this._setupGuideAnswer = previousAnswer;
|
|
1588
|
-
}
|
|
1589
|
-
return responded;
|
|
1590
|
-
}
|
|
1591
|
-
_respondSetupQuestionText(answer) {
|
|
1592
|
-
const value = this._panel?.rows.find((row) => row.value?.startsWith('question:'))?.value;
|
|
1593
|
-
const [, encodedRequestId] = value?.split(':') ?? [];
|
|
1594
|
-
if (!encodedRequestId) {
|
|
1595
|
-
return false;
|
|
1596
|
-
}
|
|
1597
|
-
const previousAnswer = this._setupGuideAnswer;
|
|
1598
|
-
const normalizedAnswer = sanitizeTerminalText(answer).trim();
|
|
1599
|
-
this._setupGuideAnswer = normalizedAnswer;
|
|
1600
|
-
try {
|
|
1601
|
-
const responded = this._setupQuestions?.respondText(decodeURIComponent(encodedRequestId), normalizedAnswer) ?? false;
|
|
1602
|
-
if (!responded) {
|
|
1603
|
-
this._setupGuideAnswer = previousAnswer;
|
|
1604
|
-
}
|
|
1605
|
-
return responded;
|
|
1606
|
-
}
|
|
1607
|
-
catch (error) {
|
|
1608
|
-
this._setupGuideAnswer = previousAnswer;
|
|
1609
|
-
throw error;
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
1580
|
_openPermissionPanel(request) {
|
|
1613
1581
|
this._pushPanel('permission', `Allow ${request.toolName}?`, permissionRequestRows(request), {
|
|
1614
1582
|
body: formatPermissionPanelBody(request),
|
|
1615
1583
|
...(request.diff ? { diff: request.diff } : {}),
|
|
1616
1584
|
});
|
|
1617
1585
|
}
|
|
1618
|
-
_openSetupQuestion(request) {
|
|
1619
|
-
this._setupGuideAnswer = undefined;
|
|
1620
|
-
this._pushPanel('question', 'Dr. Harness', setupQuestionRows(request), { body: request.question });
|
|
1621
|
-
}
|
|
1622
1586
|
_refreshRuntime(model) {
|
|
1623
1587
|
const info = this._backend.info?.();
|
|
1624
1588
|
const session = info?.sessionId && this._sessions?.current === info.sessionId && this._runtime.session !== info.sessionId
|
|
@@ -1648,13 +1612,6 @@ export class ChatController {
|
|
|
1648
1612
|
this._panel = this._panelStack.pop();
|
|
1649
1613
|
this._emit();
|
|
1650
1614
|
}
|
|
1651
|
-
_closeSetupQuestion() {
|
|
1652
|
-
if (this._panel?.kind !== 'question') {
|
|
1653
|
-
return;
|
|
1654
|
-
}
|
|
1655
|
-
this._panel = this._panelStack.pop();
|
|
1656
|
-
this._emit();
|
|
1657
|
-
}
|
|
1658
1615
|
_setTasks(tasks) {
|
|
1659
1616
|
const previous = new Map(this._tasks.map((task) => [task.id, task]));
|
|
1660
1617
|
this._tasks = tasks.map(cloneTask);
|