@strands-agents/cli 0.1.2 → 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.
Files changed (65) hide show
  1. package/README.md +5 -8
  2. package/dist/src/cli/run.js +2 -9
  3. package/dist/src/cli/run.js.map +1 -1
  4. package/dist/src/tui/agent-configuration.js +30 -38
  5. package/dist/src/tui/agent-configuration.js.map +1 -1
  6. package/dist/src/tui/builtin-tools.js +29 -0
  7. package/dist/src/tui/builtin-tools.js.map +1 -1
  8. package/dist/src/tui/chat/commands.js +1 -0
  9. package/dist/src/tui/chat/commands.js.map +1 -1
  10. package/dist/src/tui/chat/controller.js +71 -83
  11. package/dist/src/tui/chat/controller.js.map +1 -1
  12. package/dist/src/tui/chat/help.js +1 -0
  13. package/dist/src/tui/chat/help.js.map +1 -1
  14. package/dist/src/tui/chat/panels.js +21 -11
  15. package/dist/src/tui/chat/panels.js.map +1 -1
  16. package/dist/src/tui/chat/types.js.map +1 -1
  17. package/dist/src/tui/permissions/policy.js +1 -9
  18. package/dist/src/tui/permissions/policy.js.map +1 -1
  19. package/dist/src/tui/permissions/settings.js +9 -8
  20. package/dist/src/tui/permissions/settings.js.map +1 -1
  21. package/dist/src/tui/project/export.js +19 -2
  22. package/dist/src/tui/project/export.js.map +1 -1
  23. package/dist/src/tui/provider/aws-client.js +3 -3
  24. package/dist/src/tui/provider/aws-client.js.map +1 -1
  25. package/dist/src/tui/run.js +5 -12
  26. package/dist/src/tui/run.js.map +1 -1
  27. package/dist/src/tui/runtime.js +8 -7
  28. package/dist/src/tui/runtime.js.map +1 -1
  29. package/dist/src/tui/session/conversations.js +2 -2
  30. package/dist/src/tui/session/conversations.js.map +1 -1
  31. package/dist/src/tui/strands-backend.js +0 -6
  32. package/dist/src/tui/strands-backend.js.map +1 -1
  33. package/dist/src/tui/view/app.js +2 -20
  34. package/dist/src/tui/view/app.js.map +1 -1
  35. package/dist/src/tui/view/chat-root.js +38 -29
  36. package/dist/src/tui/view/chat-root.js.map +1 -1
  37. package/dist/src/tui/view/chat-view.js +3 -38
  38. package/dist/src/tui/view/chat-view.js.map +1 -1
  39. package/dist/src/tui/view/frog-intro-renderer.js +14 -84
  40. package/dist/src/tui/view/frog-intro-renderer.js.map +1 -1
  41. package/dist/src/tui/view/help-footer.js +5 -3
  42. package/dist/src/tui/view/help-footer.js.map +1 -1
  43. package/dist/src/tui/view/interaction.js +1 -1
  44. package/dist/src/tui/view/interaction.js.map +1 -1
  45. package/dist/src/tui/view/mcp-trust-prompt.js +17 -0
  46. package/dist/src/tui/view/mcp-trust-prompt.js.map +1 -0
  47. package/dist/src/tui/view/panels.js +10 -6
  48. package/dist/src/tui/view/panels.js.map +1 -1
  49. package/dist/src/tui/view/setup-wizard/index.js +130 -131
  50. package/dist/src/tui/view/setup-wizard/index.js.map +1 -1
  51. package/dist/src/tui/view/setup-wizard/progress.js +1 -2
  52. package/dist/src/tui/view/setup-wizard/progress.js.map +1 -1
  53. package/dist/src/tui/view/setup-wizard/providers.js +2 -1
  54. package/dist/src/tui/view/setup-wizard/providers.js.map +1 -1
  55. package/dist/src/tui/view/setup-wizard/steps.js +89 -47
  56. package/dist/src/tui/view/setup-wizard/steps.js.map +1 -1
  57. package/dist/src/tui/view/startup-view.js +4 -2
  58. package/dist/src/tui/view/startup-view.js.map +1 -1
  59. package/package.json +2 -2
  60. package/dist/src/tui/agent-setup.js +0 -80
  61. package/dist/src/tui/agent-setup.js.map +0 -1
  62. package/dist/src/tui/setup/questions.js +0 -277
  63. package/dist/src/tui/setup/questions.js.map +0 -1
  64. package/dist/src/tui/view/setup-question.js +0 -90
  65. 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, setupQuestionRows, skillRows, skillDetailRows, permissionSettingsRows, mcpRows, mcpOptions, BACKGROUND_TASK_WAIT_TOGGLE, } from './panels.js';
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';
@@ -40,10 +40,11 @@ export class ChatController {
40
40
  _streamPresentation;
41
41
  _setSettings;
42
42
  _requestSetup;
43
+ _builtinTools;
44
+ _builtinToolSelection = new Set();
43
45
  _exportAgentProject;
44
46
  _project;
45
47
  _copyText;
46
- _setupQuestions;
47
48
  _exportedPath;
48
49
  _backend;
49
50
  _activeProjector;
@@ -53,7 +54,6 @@ export class ChatController {
53
54
  _pendingSubmissionRun;
54
55
  _stopWatchingTasks;
55
56
  _stopWatchingPermissions;
56
- _stopWatchingSetupQuestions;
57
57
  _stopWatchingTaskActivity;
58
58
  _usageSubscriptions = new Set();
59
59
  _usageGeneration = 0;
@@ -72,7 +72,6 @@ export class ChatController {
72
72
  _deferredModelNoticeId;
73
73
  _resourceChanging = false;
74
74
  _composerStatus;
75
- _setupGuideAnswer;
76
75
  _closed = false;
77
76
  _exitCode;
78
77
  _hardExitCode;
@@ -95,10 +94,10 @@ export class ChatController {
95
94
  this._streamPresentation = options.streamPresentation;
96
95
  this._setSettings = options.setSettings;
97
96
  this._requestSetup = options.requestSetup;
97
+ this._builtinTools = options.builtinTools;
98
98
  this._exportAgentProject = options.exportAgentProject;
99
99
  this._project = options.project;
100
100
  this._copyText = options.copyText ?? copyTerminalText;
101
- this._setupQuestions = options.setupQuestions;
102
101
  const info = backend.info?.();
103
102
  this._runtime = {
104
103
  agent: backend.name,
@@ -142,14 +141,6 @@ export class ChatController {
142
141
  this._closePermissionPanel();
143
142
  }
144
143
  });
145
- this._stopWatchingSetupQuestions = this._setupQuestions?.subscribe((request) => {
146
- if (request) {
147
- this._openSetupQuestion(request);
148
- }
149
- else {
150
- this._closeSetupQuestion();
151
- }
152
- });
153
144
  }
154
145
  subscribe = (listener) => {
155
146
  this._listeners.add(listener);
@@ -206,14 +197,14 @@ export class ChatController {
206
197
  ? invocation.token
207
198
  : undefined;
208
199
  }
209
- async start(firstRequest, options) {
200
+ async start(firstRequest) {
210
201
  if (firstRequest) {
211
202
  const prompt = firstRequest.trim();
212
203
  if (prompt.startsWith('!')) {
213
204
  await this._executeSubmission(prompt);
214
205
  }
215
206
  else {
216
- await this._runPrompt(prompt, options?.hidePrompt ? '' : prompt);
207
+ await this._runPrompt(prompt);
217
208
  }
218
209
  }
219
210
  }
@@ -226,9 +217,6 @@ export class ChatController {
226
217
  this.close();
227
218
  return undefined;
228
219
  }
229
- if (this._panel?.kind === 'question' && this._respondSetupQuestionText(prompt)) {
230
- return undefined;
231
- }
232
220
  if (/^\/help(?:\s|$)/iu.test(prompt) && !this._resourceChanging && this._panel?.kind !== 'permission') {
233
221
  return this._executeSubmission(prompt);
234
222
  }
@@ -375,16 +363,13 @@ export class ChatController {
375
363
  this._panelStack.length = 0;
376
364
  return this._runStream(prompt, this._backend.streamShell(command));
377
365
  }
378
- async _runPrompt(prompt, displayPrompt = prompt) {
366
+ async _runPrompt(prompt) {
379
367
  if (this._closed || this._activeProjector || this._drainingProjector || this._resourceChanging) {
380
368
  return undefined;
381
369
  }
382
- if (this._setupQuestions && displayPrompt) {
383
- this._setupGuideAnswer = displayPrompt;
384
- }
385
370
  this._panel = undefined;
386
371
  this._panelStack.length = 0;
387
- return this._runStream(displayPrompt, this._backend.stream(prompt));
372
+ return this._runStream(prompt, this._backend.stream(prompt));
388
373
  }
389
374
  async _runPeerMessage(message) {
390
375
  if (this._closed ||
@@ -575,8 +560,6 @@ export class ChatController {
575
560
  this._stopWatchingTasks = undefined;
576
561
  this._stopWatchingPermissions?.();
577
562
  this._stopWatchingPermissions = undefined;
578
- this._stopWatchingSetupQuestions?.();
579
- this._stopWatchingSetupQuestions = undefined;
580
563
  this._stopTaskActivity();
581
564
  this._listeners.clear();
582
565
  await Promise.allSettled([Promise.resolve().then(() => this._backend.dispose?.()), this._mcp?.dispose()]);
@@ -649,12 +632,12 @@ export class ChatController {
649
632
  }
650
633
  }
651
634
  dismissPanel() {
652
- if (!this._panel ||
653
- this._resourceChanging ||
654
- this._panel.kind === 'permission' ||
655
- this._panel.kind === 'question') {
635
+ if (!this._panel || this._resourceChanging || this._panel.kind === 'permission') {
656
636
  return false;
657
637
  }
638
+ if (this._panel.kind === 'tools' && !this._applyBuiltinTools()) {
639
+ return true;
640
+ }
658
641
  this._stopTaskActivity();
659
642
  this._panel = this._panelStack.pop();
660
643
  this._emit();
@@ -691,6 +674,8 @@ export class ChatController {
691
674
  : this._openTaskDetail(row.value);
692
675
  case 'permissions':
693
676
  return this._updatePermissions(row.value);
677
+ case 'tools':
678
+ return this._toggleBuiltinTool(row.value);
694
679
  case 'settings':
695
680
  return row.value.startsWith('settings:')
696
681
  ? this._openSettingsCategory(row.value)
@@ -706,8 +691,6 @@ export class ChatController {
706
691
  : false;
707
692
  case 'permission':
708
693
  return this._respondPermission(row.value);
709
- case 'question':
710
- return this._respondSetupQuestion(row.value);
711
694
  default:
712
695
  return false;
713
696
  }
@@ -805,8 +788,6 @@ export class ChatController {
805
788
  ...(this._panel ? { panel: clonePanel(this._panel) } : {}),
806
789
  runtime: cloneRuntime(this._runtime),
807
790
  settings: globalThis.structuredClone(this._settings),
808
- ...(this._setupQuestions ? { setupGuide: true } : {}),
809
- ...(this._setupGuideAnswer ? { setupGuideAnswer: this._setupGuideAnswer } : {}),
810
791
  ...(this._exitCode !== undefined ? { exitCode: this._exitCode } : {}),
811
792
  };
812
793
  }
@@ -826,6 +807,7 @@ export class ChatController {
826
807
  skills: this._skills !== undefined,
827
808
  mcp: this._mcp !== undefined,
828
809
  setup: this._requestSetup !== undefined,
810
+ tools: this._builtinTools !== undefined,
829
811
  export: this._exportAgentProject !== undefined,
830
812
  }), {
831
813
  searchable: true,
@@ -878,6 +860,9 @@ export class ChatController {
878
860
  case 'setup':
879
861
  this._requestSetup?.();
880
862
  break;
863
+ case 'tools':
864
+ this._openBuiltinToolsPanel();
865
+ break;
881
866
  case 'export':
882
867
  await this._handleExportCommand(parseCommandInvocation(prompt)?.argument ?? '');
883
868
  break;
@@ -893,6 +878,44 @@ export class ChatController {
893
878
  }
894
879
  }
895
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
+ }
896
919
  _openTasksPanel() {
897
920
  this._openPanel('tasks', `tasks (${this._tasks.length})`, taskRows(this._tasks, this._backend.backgroundTasksWaitForCompletion?.()));
898
921
  }
@@ -1302,7 +1325,7 @@ export class ChatController {
1302
1325
  }
1303
1326
  this._openError('unknown permission mode', argument, 'Use /permissions, /permissions default, or /permissions bypass.');
1304
1327
  }
1305
- _openPermissionsPanel() {
1328
+ _openPermissionsPanel(refresh = false) {
1306
1329
  const status = this._backend.permissionStatus?.();
1307
1330
  if (!status ||
1308
1331
  !this._backend.setPermissionMode ||
@@ -1311,11 +1334,21 @@ export class ChatController {
1311
1334
  this._openError('permissions unavailable', this._backend.name, 'Permission configuration is available only for the built-in Strands backend.');
1312
1335
  return;
1313
1336
  }
1314
- this._openPanel('permissions', 'permissions', permissionSettingsRows(status, this._runtime.tools), {
1337
+ const options = {
1315
1338
  ...(status.mode === 'bypassPermissions'
1316
1339
  ? { body: 'WARNING: Permission checks are bypassed. Configured interventions and sandboxing still apply.' }
1317
1340
  : {}),
1318
- });
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);
1319
1352
  }
1320
1353
  async _updatePermissions(value) {
1321
1354
  const [prefix, action, encodedValue] = value.split(':');
@@ -1340,7 +1373,7 @@ export class ChatController {
1340
1373
  else {
1341
1374
  await this._backend.allowPermission(toolName);
1342
1375
  }
1343
- this._openPermissionsPanel();
1376
+ this._openPermissionsPanel(true);
1344
1377
  return true;
1345
1378
  }
1346
1379
  catch (error) {
@@ -1355,7 +1388,7 @@ export class ChatController {
1355
1388
  }
1356
1389
  try {
1357
1390
  await this._backend.setPermissionMode(mode);
1358
- this._openPermissionsPanel();
1391
+ this._openPermissionsPanel(true);
1359
1392
  return true;
1360
1393
  }
1361
1394
  catch (error) {
@@ -1544,50 +1577,12 @@ export class ChatController {
1544
1577
  this._closePermissionPanel();
1545
1578
  return true;
1546
1579
  }
1547
- _respondSetupQuestion(value) {
1548
- const [prefix, encodedRequestId, encodedChoiceId] = value.split(':');
1549
- if (prefix !== 'question' || !encodedRequestId || !encodedChoiceId) {
1550
- return false;
1551
- }
1552
- const previousAnswer = this._setupGuideAnswer;
1553
- this._setupGuideAnswer = this._panel?.rows.find((row) => row.value === value)?.label;
1554
- const responded = this._setupQuestions?.respond(decodeURIComponent(encodedRequestId), decodeURIComponent(encodedChoiceId)) ?? false;
1555
- if (!responded) {
1556
- this._setupGuideAnswer = previousAnswer;
1557
- }
1558
- return responded;
1559
- }
1560
- _respondSetupQuestionText(answer) {
1561
- const value = this._panel?.rows.find((row) => row.value?.startsWith('question:'))?.value;
1562
- const [, encodedRequestId] = value?.split(':') ?? [];
1563
- if (!encodedRequestId) {
1564
- return false;
1565
- }
1566
- const previousAnswer = this._setupGuideAnswer;
1567
- const normalizedAnswer = sanitizeTerminalText(answer).trim();
1568
- this._setupGuideAnswer = normalizedAnswer;
1569
- try {
1570
- const responded = this._setupQuestions?.respondText(decodeURIComponent(encodedRequestId), normalizedAnswer) ?? false;
1571
- if (!responded) {
1572
- this._setupGuideAnswer = previousAnswer;
1573
- }
1574
- return responded;
1575
- }
1576
- catch (error) {
1577
- this._setupGuideAnswer = previousAnswer;
1578
- throw error;
1579
- }
1580
- }
1581
1580
  _openPermissionPanel(request) {
1582
1581
  this._pushPanel('permission', `Allow ${request.toolName}?`, permissionRequestRows(request), {
1583
1582
  body: formatPermissionPanelBody(request),
1584
1583
  ...(request.diff ? { diff: request.diff } : {}),
1585
1584
  });
1586
1585
  }
1587
- _openSetupQuestion(request) {
1588
- this._setupGuideAnswer = undefined;
1589
- this._pushPanel('question', 'Dr. Harness', setupQuestionRows(request), { body: request.question });
1590
- }
1591
1586
  _refreshRuntime(model) {
1592
1587
  const info = this._backend.info?.();
1593
1588
  const session = info?.sessionId && this._sessions?.current === info.sessionId && this._runtime.session !== info.sessionId
@@ -1617,13 +1612,6 @@ export class ChatController {
1617
1612
  this._panel = this._panelStack.pop();
1618
1613
  this._emit();
1619
1614
  }
1620
- _closeSetupQuestion() {
1621
- if (this._panel?.kind !== 'question') {
1622
- return;
1623
- }
1624
- this._panel = this._panelStack.pop();
1625
- this._emit();
1626
- }
1627
1615
  _setTasks(tasks) {
1628
1616
  const previous = new Map(this._tasks.map((task) => [task.id, task]));
1629
1617
  this._tasks = tasks.map(cloneTask);