@strands-agents/cli 0.1.2 → 0.1.4

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 (83) hide show
  1. package/README.md +11 -8
  2. package/dist/src/cli/arguments.js +40 -1
  3. package/dist/src/cli/arguments.js.map +1 -1
  4. package/dist/src/cli/run.js +7 -9
  5. package/dist/src/cli/run.js.map +1 -1
  6. package/dist/src/cli/update.js +67 -0
  7. package/dist/src/cli/update.js.map +1 -0
  8. package/dist/src/tui/agent-configuration.js +30 -38
  9. package/dist/src/tui/agent-configuration.js.map +1 -1
  10. package/dist/src/tui/builtin-tools.js +29 -0
  11. package/dist/src/tui/builtin-tools.js.map +1 -1
  12. package/dist/src/tui/chat/commands.js +2 -1
  13. package/dist/src/tui/chat/commands.js.map +1 -1
  14. package/dist/src/tui/chat/controller.js +81 -87
  15. package/dist/src/tui/chat/controller.js.map +1 -1
  16. package/dist/src/tui/chat/help.js +1 -0
  17. package/dist/src/tui/chat/help.js.map +1 -1
  18. package/dist/src/tui/chat/panels.js +21 -11
  19. package/dist/src/tui/chat/panels.js.map +1 -1
  20. package/dist/src/tui/chat/types.js.map +1 -1
  21. package/dist/src/tui/npm.js +32 -0
  22. package/dist/src/tui/npm.js.map +1 -0
  23. package/dist/src/tui/permissions/policy.js +1 -9
  24. package/dist/src/tui/permissions/policy.js.map +1 -1
  25. package/dist/src/tui/permissions/settings.js +9 -8
  26. package/dist/src/tui/permissions/settings.js.map +1 -1
  27. package/dist/src/tui/project/export.js +19 -2
  28. package/dist/src/tui/project/export.js.map +1 -1
  29. package/dist/src/tui/project/python.js +1 -1
  30. package/dist/src/tui/project/python.js.map +1 -1
  31. package/dist/src/tui/project/worker.py +56 -7
  32. package/dist/src/tui/provider/aws-client.js +3 -3
  33. package/dist/src/tui/provider/aws-client.js.map +1 -1
  34. package/dist/src/tui/run.js +5 -12
  35. package/dist/src/tui/run.js.map +1 -1
  36. package/dist/src/tui/runtime.js +8 -7
  37. package/dist/src/tui/runtime.js.map +1 -1
  38. package/dist/src/tui/session/context.js +23 -13
  39. package/dist/src/tui/session/context.js.map +1 -1
  40. package/dist/src/tui/session/conversations.js +21 -3
  41. package/dist/src/tui/session/conversations.js.map +1 -1
  42. package/dist/src/tui/strands-backend.js +46 -15
  43. package/dist/src/tui/strands-backend.js.map +1 -1
  44. package/dist/src/tui/update-check.js +37 -0
  45. package/dist/src/tui/update-check.js.map +1 -0
  46. package/dist/src/tui/view/app.js +33 -20
  47. package/dist/src/tui/view/app.js.map +1 -1
  48. package/dist/src/tui/view/chat-root.js +38 -29
  49. package/dist/src/tui/view/chat-root.js.map +1 -1
  50. package/dist/src/tui/view/chat-view.js +4 -39
  51. package/dist/src/tui/view/chat-view.js.map +1 -1
  52. package/dist/src/tui/view/frog-intro-renderer.js +14 -84
  53. package/dist/src/tui/view/frog-intro-renderer.js.map +1 -1
  54. package/dist/src/tui/view/help-footer.js +19 -13
  55. package/dist/src/tui/view/help-footer.js.map +1 -1
  56. package/dist/src/tui/view/interaction.js +1 -1
  57. package/dist/src/tui/view/interaction.js.map +1 -1
  58. package/dist/src/tui/view/mcp-trust-prompt.js +17 -0
  59. package/dist/src/tui/view/mcp-trust-prompt.js.map +1 -0
  60. package/dist/src/tui/view/panels.js +24 -14
  61. package/dist/src/tui/view/panels.js.map +1 -1
  62. package/dist/src/tui/view/rename-panel.js +11 -0
  63. package/dist/src/tui/view/rename-panel.js.map +1 -0
  64. package/dist/src/tui/view/setup-wizard/index.js +90 -123
  65. package/dist/src/tui/view/setup-wizard/index.js.map +1 -1
  66. package/dist/src/tui/view/setup-wizard/opening-menu.js +2 -2
  67. package/dist/src/tui/view/setup-wizard/opening-menu.js.map +1 -1
  68. package/dist/src/tui/view/setup-wizard/progress.js +1 -2
  69. package/dist/src/tui/view/setup-wizard/progress.js.map +1 -1
  70. package/dist/src/tui/view/setup-wizard/providers.js +2 -1
  71. package/dist/src/tui/view/setup-wizard/providers.js.map +1 -1
  72. package/dist/src/tui/view/setup-wizard/steps.js +60 -46
  73. package/dist/src/tui/view/setup-wizard/steps.js.map +1 -1
  74. package/dist/src/tui/view/startup-view.js +4 -2
  75. package/dist/src/tui/view/startup-view.js.map +1 -1
  76. package/dist/src/tui/view/transcript.js +1 -1
  77. package/package.json +4 -2
  78. package/dist/src/tui/agent-setup.js +0 -80
  79. package/dist/src/tui/agent-setup.js.map +0 -1
  80. package/dist/src/tui/setup/questions.js +0 -277
  81. package/dist/src/tui/setup/questions.js.map +0 -1
  82. package/dist/src/tui/view/setup-question.js +0 -90
  83. 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();
@@ -684,13 +667,16 @@ export class ChatController {
684
667
  ? this._selectEffort(row.value.slice('effort:'.length))
685
668
  : this._selectModel(row.value);
686
669
  case 'skills':
687
- return this._openSkillDetail(row.value);
670
+ await this.submit(`$${row.value}`);
671
+ return true;
688
672
  case 'tasks':
689
673
  return row.value === BACKGROUND_TASK_WAIT_TOGGLE
690
674
  ? this._toggleBackgroundTaskWaitMode()
691
675
  : this._openTaskDetail(row.value);
692
676
  case 'permissions':
693
677
  return this._updatePermissions(row.value);
678
+ case 'tools':
679
+ return this._toggleBuiltinTool(row.value);
694
680
  case 'settings':
695
681
  return row.value.startsWith('settings:')
696
682
  ? this._openSettingsCategory(row.value)
@@ -706,8 +692,6 @@ export class ChatController {
706
692
  : false;
707
693
  case 'permission':
708
694
  return this._respondPermission(row.value);
709
- case 'question':
710
- return this._respondSetupQuestion(row.value);
711
695
  default:
712
696
  return false;
713
697
  }
@@ -805,8 +789,6 @@ export class ChatController {
805
789
  ...(this._panel ? { panel: clonePanel(this._panel) } : {}),
806
790
  runtime: cloneRuntime(this._runtime),
807
791
  settings: globalThis.structuredClone(this._settings),
808
- ...(this._setupQuestions ? { setupGuide: true } : {}),
809
- ...(this._setupGuideAnswer ? { setupGuideAnswer: this._setupGuideAnswer } : {}),
810
792
  ...(this._exitCode !== undefined ? { exitCode: this._exitCode } : {}),
811
793
  };
812
794
  }
@@ -826,6 +808,7 @@ export class ChatController {
826
808
  skills: this._skills !== undefined,
827
809
  mcp: this._mcp !== undefined,
828
810
  setup: this._requestSetup !== undefined,
811
+ tools: this._builtinTools !== undefined,
829
812
  export: this._exportAgentProject !== undefined,
830
813
  }), {
831
814
  searchable: true,
@@ -878,6 +861,9 @@ export class ChatController {
878
861
  case 'setup':
879
862
  this._requestSetup?.();
880
863
  break;
864
+ case 'tools':
865
+ this._openBuiltinToolsPanel();
866
+ break;
881
867
  case 'export':
882
868
  await this._handleExportCommand(parseCommandInvocation(prompt)?.argument ?? '');
883
869
  break;
@@ -893,6 +879,44 @@ export class ChatController {
893
879
  }
894
880
  }
895
881
  }
882
+ _openBuiltinToolsPanel() {
883
+ if (!this._builtinTools) {
884
+ this._openError('tools unavailable', '/tools', this._project
885
+ ? `This agent is defined in ${this._project.entrypoint}. Edit its tools there.`
886
+ : 'Tool selection is not available in this session.');
887
+ return;
888
+ }
889
+ const choices = this._builtinTools.choices();
890
+ this._builtinToolSelection = new Set(choices.filter((choice) => choice.enabled).map((choice) => choice.name));
891
+ this._openPanel('tools', 'tools', builtinToolRows(choices, this._builtinToolSelection));
892
+ }
893
+ _toggleBuiltinTool(value) {
894
+ if (this._panel?.kind !== 'tools' || !this._builtinTools || !value.startsWith('tools:toggle:')) {
895
+ return false;
896
+ }
897
+ const name = decodeURIComponent(value.slice('tools:toggle:'.length));
898
+ if (!this._builtinToolSelection.delete(name)) {
899
+ this._builtinToolSelection.add(name);
900
+ }
901
+ // Keeping the panel id keeps the cursor on the toggled row.
902
+ const rows = builtinToolRows(this._builtinTools.choices(), this._builtinToolSelection);
903
+ this._panel = makePanel(this._panel.id, 'tools', 'tools', rows, {});
904
+ this._emit();
905
+ return true;
906
+ }
907
+ /** Closing `/tools` applies its selection; returns false when the change is blocked. */
908
+ _applyBuiltinTools() {
909
+ const choices = this._builtinTools?.choices() ?? [];
910
+ if (choices.every((choice) => choice.enabled === this._builtinToolSelection.has(choice.name))) {
911
+ return true;
912
+ }
913
+ if (this.busy || this._hasUnresolvedBackgroundTasks()) {
914
+ this._openError('tools not changed', '/tools', 'Finish or cancel running work, then change tools again.');
915
+ return false;
916
+ }
917
+ this._builtinTools?.apply([...this._builtinToolSelection]);
918
+ return true;
919
+ }
896
920
  _openTasksPanel() {
897
921
  this._openPanel('tasks', `tasks (${this._tasks.length})`, taskRows(this._tasks, this._backend.backgroundTasksWaitForCompletion?.()));
898
922
  }
@@ -1204,8 +1228,13 @@ export class ChatController {
1204
1228
  this._panelStack.length = 0;
1205
1229
  this._emit();
1206
1230
  try {
1207
- if (await this._backend.compact()) {
1208
- this._context = {};
1231
+ const context = await this._backend.compact();
1232
+ if (context) {
1233
+ this._context = { ...context };
1234
+ this._addNotice('success', 'Compacted older conversation context into a summary');
1235
+ }
1236
+ else {
1237
+ this._addNotice('delivered', 'Nothing to compact yet');
1209
1238
  }
1210
1239
  }
1211
1240
  catch (error) {
@@ -1259,7 +1288,7 @@ export class ChatController {
1259
1288
  this._resourceChanging = false;
1260
1289
  }
1261
1290
  }
1262
- _openSkillDetail(name) {
1291
+ openSkillDetail(name) {
1263
1292
  const skill = this._skillDetails.get(name);
1264
1293
  if (!skill) {
1265
1294
  return false;
@@ -1302,7 +1331,7 @@ export class ChatController {
1302
1331
  }
1303
1332
  this._openError('unknown permission mode', argument, 'Use /permissions, /permissions default, or /permissions bypass.');
1304
1333
  }
1305
- _openPermissionsPanel() {
1334
+ _openPermissionsPanel(refresh = false) {
1306
1335
  const status = this._backend.permissionStatus?.();
1307
1336
  if (!status ||
1308
1337
  !this._backend.setPermissionMode ||
@@ -1311,11 +1340,21 @@ export class ChatController {
1311
1340
  this._openError('permissions unavailable', this._backend.name, 'Permission configuration is available only for the built-in Strands backend.');
1312
1341
  return;
1313
1342
  }
1314
- this._openPanel('permissions', 'permissions', permissionSettingsRows(status, this._runtime.tools), {
1343
+ const options = {
1315
1344
  ...(status.mode === 'bypassPermissions'
1316
1345
  ? { body: 'WARNING: Permission checks are bypassed. Configured interventions and sandboxing still apply.' }
1317
1346
  : {}),
1318
- });
1347
+ };
1348
+ if (refresh && this._panel?.kind === 'permissions') {
1349
+ const currentId = this._panel.id;
1350
+ this._panel = {
1351
+ ...this._makePanel('permissions', 'permissions', permissionSettingsRows(status, this._runtime.tools), options),
1352
+ id: currentId,
1353
+ };
1354
+ this._emit();
1355
+ return;
1356
+ }
1357
+ this._openPanel('permissions', 'permissions', permissionSettingsRows(status, this._runtime.tools), options);
1319
1358
  }
1320
1359
  async _updatePermissions(value) {
1321
1360
  const [prefix, action, encodedValue] = value.split(':');
@@ -1340,7 +1379,7 @@ export class ChatController {
1340
1379
  else {
1341
1380
  await this._backend.allowPermission(toolName);
1342
1381
  }
1343
- this._openPermissionsPanel();
1382
+ this._openPermissionsPanel(true);
1344
1383
  return true;
1345
1384
  }
1346
1385
  catch (error) {
@@ -1355,7 +1394,7 @@ export class ChatController {
1355
1394
  }
1356
1395
  try {
1357
1396
  await this._backend.setPermissionMode(mode);
1358
- this._openPermissionsPanel();
1397
+ this._openPermissionsPanel(true);
1359
1398
  return true;
1360
1399
  }
1361
1400
  catch (error) {
@@ -1544,50 +1583,12 @@ export class ChatController {
1544
1583
  this._closePermissionPanel();
1545
1584
  return true;
1546
1585
  }
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
1586
  _openPermissionPanel(request) {
1582
1587
  this._pushPanel('permission', `Allow ${request.toolName}?`, permissionRequestRows(request), {
1583
1588
  body: formatPermissionPanelBody(request),
1584
1589
  ...(request.diff ? { diff: request.diff } : {}),
1585
1590
  });
1586
1591
  }
1587
- _openSetupQuestion(request) {
1588
- this._setupGuideAnswer = undefined;
1589
- this._pushPanel('question', 'Dr. Harness', setupQuestionRows(request), { body: request.question });
1590
- }
1591
1592
  _refreshRuntime(model) {
1592
1593
  const info = this._backend.info?.();
1593
1594
  const session = info?.sessionId && this._sessions?.current === info.sessionId && this._runtime.session !== info.sessionId
@@ -1617,13 +1618,6 @@ export class ChatController {
1617
1618
  this._panel = this._panelStack.pop();
1618
1619
  this._emit();
1619
1620
  }
1620
- _closeSetupQuestion() {
1621
- if (this._panel?.kind !== 'question') {
1622
- return;
1623
- }
1624
- this._panel = this._panelStack.pop();
1625
- this._emit();
1626
- }
1627
1621
  _setTasks(tasks) {
1628
1622
  const previous = new Map(this._tasks.map((task) => [task.id, task]));
1629
1623
  this._tasks = tasks.map(cloneTask);