@strands-agents/cli 0.4.0 → 0.6.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/README.md +374 -5
- package/dist/src/agent/backend.js +2 -2
- package/dist/src/agent/backend.js.map +1 -1
- package/dist/src/agent/background.js +9 -1
- package/dist/src/agent/background.js.map +1 -1
- package/dist/src/agent/configuration.js.map +1 -1
- package/dist/src/agent/context.js +5 -1
- package/dist/src/agent/context.js.map +1 -1
- package/dist/src/agent/events.js +2 -0
- package/dist/src/agent/events.js.map +1 -1
- package/dist/src/agent/extension.js +46 -0
- package/dist/src/agent/extension.js.map +1 -0
- package/dist/src/agent/mcp.js +1 -2
- package/dist/src/agent/mcp.js.map +1 -1
- package/dist/src/agent/runtime.js +28 -5
- package/dist/src/agent/runtime.js.map +1 -1
- package/dist/src/cli/acp-events.js +15 -0
- package/dist/src/cli/acp-events.js.map +1 -1
- package/dist/src/cli/acp-python.js +2 -2
- package/dist/src/cli/acp-python.js.map +1 -1
- package/dist/src/cli/acp.js +2 -17
- package/dist/src/cli/acp.js.map +1 -1
- package/dist/src/cli/arguments.js +91 -11
- package/dist/src/cli/arguments.js.map +1 -1
- package/dist/src/cli/console.js +2 -0
- package/dist/src/cli/console.js.map +1 -1
- package/dist/src/cli/invocation.js +10 -2
- package/dist/src/cli/invocation.js.map +1 -1
- package/dist/src/cli/run.js +154 -15
- package/dist/src/cli/run.js.map +1 -1
- package/dist/src/cli/telemetry.js.map +1 -1
- package/dist/src/config/settings.js +67 -2
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/config/store.js +171 -21
- package/dist/src/config/store.js.map +1 -1
- package/dist/src/config/watch.js +24 -0
- package/dist/src/config/watch.js.map +1 -0
- package/dist/src/dev/agent-choices.js +281 -0
- package/dist/src/dev/agent-choices.js.map +1 -0
- package/dist/src/dev/agent-options.js +467 -0
- package/dist/src/dev/agent-options.js.map +1 -0
- package/dist/src/dev/base-cli.js +201 -0
- package/dist/src/dev/base-cli.js.map +1 -0
- package/dist/src/dev/chat-extension.js +42 -0
- package/dist/src/dev/chat-extension.js.map +1 -0
- package/dist/src/dev/create.js +443 -0
- package/dist/src/dev/create.js.map +1 -0
- package/dist/src/dev/errors.js +89 -0
- package/dist/src/dev/errors.js.map +1 -0
- package/dist/src/dev/evals/chat/agent-tools.js +941 -0
- package/dist/src/dev/evals/chat/agent-tools.js.map +1 -0
- package/dist/src/dev/evals/chat/background-flags.js +231 -0
- package/dist/src/dev/evals/chat/background-flags.js.map +1 -0
- package/dist/src/dev/evals/chat/command.js +140 -0
- package/dist/src/dev/evals/chat/command.js.map +1 -0
- package/dist/src/dev/evals/chat/ui-tools.js +252 -0
- package/dist/src/dev/evals/chat/ui-tools.js.map +1 -0
- package/dist/src/dev/evals/chat/workflow-skills.js +48 -0
- package/dist/src/dev/evals/chat/workflow-skills.js.map +1 -0
- package/dist/src/dev/evals/host.js +22 -0
- package/dist/src/dev/evals/host.js.map +1 -0
- package/dist/src/dev/evals/jobs.js +151 -0
- package/dist/src/dev/evals/jobs.js.map +1 -0
- package/dist/src/dev/evals/layout.js +223 -0
- package/dist/src/dev/evals/layout.js.map +1 -0
- package/dist/src/dev/evals/model.js +4 -0
- package/dist/src/dev/evals/model.js.map +1 -0
- package/dist/src/dev/evals/package.js +14 -0
- package/dist/src/dev/evals/package.js.map +1 -0
- package/dist/src/dev/evals/python/entry-files.js +70 -0
- package/dist/src/dev/evals/python/entry-files.js.map +1 -0
- package/dist/src/dev/evals/python/strands_dev_evals/__init__.py +0 -0
- package/dist/src/dev/evals/python/strands_dev_evals/errors.py +2 -0
- package/dist/src/dev/evals/python/strands_dev_evals/harness.py +265 -0
- package/dist/src/dev/evals/python/strands_dev_evals/imports.py +61 -0
- package/dist/src/dev/evals/python/strands_dev_evals/model_effort.py +120 -0
- package/dist/src/dev/evals/python/strands_dev_evals/optimize.py +152 -0
- package/dist/src/dev/evals/python/strands_dev_evals/run.py +55 -0
- package/dist/src/dev/evals/python/strands_dev_evals/space.py +212 -0
- package/dist/src/dev/evals/python/strands_dev_evals/temporary_typescript.py +313 -0
- package/dist/src/dev/evals/runs/background-runs.js +182 -0
- package/dist/src/dev/evals/runs/background-runs.js.map +1 -0
- package/dist/src/dev/evals/runs/environment.js +258 -0
- package/dist/src/dev/evals/runs/environment.js.map +1 -0
- package/dist/src/dev/evals/runs/evals-process.js +157 -0
- package/dist/src/dev/evals/runs/evals-process.js.map +1 -0
- package/dist/src/dev/evals/runs/evaluate.js +288 -0
- package/dist/src/dev/evals/runs/evaluate.js.map +1 -0
- package/dist/src/dev/evals/runs/experiment.js +319 -0
- package/dist/src/dev/evals/runs/experiment.js.map +1 -0
- package/dist/src/dev/evals/runs/layout-migration.js +302 -0
- package/dist/src/dev/evals/runs/layout-migration.js.map +1 -0
- package/dist/src/dev/evals/runs/optimize.js +249 -0
- package/dist/src/dev/evals/runs/optimize.js.map +1 -0
- package/dist/src/dev/evals/runs/typescript-runner-main.js +40 -0
- package/dist/src/dev/evals/runs/typescript-runner-main.js.map +1 -0
- package/dist/src/dev/evals/runs/typescript-runner.js +192 -0
- package/dist/src/dev/evals/runs/typescript-runner.js.map +1 -0
- package/dist/src/dev/evals/sessions/auto-optimize.js +259 -0
- package/dist/src/dev/evals/sessions/auto-optimize.js.map +1 -0
- package/dist/src/dev/evals/sessions/evals-ui.js +232 -0
- package/dist/src/dev/evals/sessions/evals-ui.js.map +1 -0
- package/dist/src/dev/evals/sessions/evaluate-session.js +252 -0
- package/dist/src/dev/evals/sessions/evaluate-session.js.map +1 -0
- package/dist/src/dev/evals/sessions/experiments-session.js +305 -0
- package/dist/src/dev/evals/sessions/experiments-session.js.map +1 -0
- package/dist/src/dev/evals/sessions/optimize-session.js +942 -0
- package/dist/src/dev/evals/sessions/optimize-session.js.map +1 -0
- package/dist/src/dev/evals/sessions/review-run.js +245 -0
- package/dist/src/dev/evals/sessions/review-run.js.map +1 -0
- package/dist/src/dev/evals/sessions/session-converter.js +110 -0
- package/dist/src/dev/evals/sessions/session-converter.js.map +1 -0
- package/dist/src/dev/evals/sessions/sessions.js +81 -0
- package/dist/src/dev/evals/sessions/sessions.js.map +1 -0
- package/dist/src/dev/evals/shell/arguments.js +26 -0
- package/dist/src/dev/evals/shell/arguments.js.map +1 -0
- package/dist/src/dev/evals/shell/cli.js +77 -0
- package/dist/src/dev/evals/shell/cli.js.map +1 -0
- package/dist/src/dev/evals/tuning/apply.js +535 -0
- package/dist/src/dev/evals/tuning/apply.js.map +1 -0
- package/dist/src/dev/evals/tuning/knobs.js +293 -0
- package/dist/src/dev/evals/tuning/knobs.js.map +1 -0
- package/dist/src/dev/evals/tuning/objective.js +273 -0
- package/dist/src/dev/evals/tuning/objective.js.map +1 -0
- package/dist/src/dev/evals/tuning/plan.js +156 -0
- package/dist/src/dev/evals/tuning/plan.js.map +1 -0
- package/dist/src/dev/evals/tuning/study.js +392 -0
- package/dist/src/dev/evals/tuning/study.js.map +1 -0
- package/dist/src/dev/failed-turns.js +31 -0
- package/dist/src/dev/failed-turns.js.map +1 -0
- package/dist/src/dev/file-edits.js +67 -0
- package/dist/src/dev/file-edits.js.map +1 -0
- package/dist/src/dev/fix-in-new-tab.js +151 -0
- package/dist/src/dev/fix-in-new-tab.js.map +1 -0
- package/dist/src/dev/picker.js +498 -0
- package/dist/src/dev/picker.js.map +1 -0
- package/dist/src/dev/prepare.js +526 -0
- package/dist/src/dev/prepare.js.map +1 -0
- package/dist/src/dev/project-setup.js +209 -0
- package/dist/src/dev/project-setup.js.map +1 -0
- package/dist/src/dev/runtime.js +55 -0
- package/dist/src/dev/runtime.js.map +1 -0
- package/dist/src/dev/search.js +466 -0
- package/dist/src/dev/search.js.map +1 -0
- package/dist/src/dev/telemetry.js +30 -0
- package/dist/src/dev/telemetry.js.map +1 -0
- package/dist/src/dev/workspace.js +547 -0
- package/dist/src/dev/workspace.js.map +1 -0
- package/dist/src/model/credential-failure.js +5 -0
- package/dist/src/model/credential-failure.js.map +1 -0
- package/dist/src/model/effort-fields.js +76 -0
- package/dist/src/model/effort-fields.js.map +1 -0
- package/dist/src/model/packages.js +2 -0
- package/dist/src/model/packages.js.map +1 -1
- package/dist/src/model/runtime.js +12 -4
- package/dist/src/model/runtime.js.map +1 -1
- package/dist/src/paths.js +9 -1
- package/dist/src/paths.js.map +1 -1
- package/dist/src/process-lock.js +89 -0
- package/dist/src/process-lock.js.map +1 -0
- package/dist/src/project/archive.js +11 -1
- package/dist/src/project/archive.js.map +1 -1
- package/dist/src/project/export.js +40 -14
- package/dist/src/project/export.js.map +1 -1
- package/dist/src/project/install.js +33 -0
- package/dist/src/project/install.js.map +1 -0
- package/dist/src/project/module-loader.js +36 -0
- package/dist/src/project/module-loader.js.map +1 -1
- package/dist/src/project/portability.js +2 -1
- package/dist/src/project/portability.js.map +1 -1
- package/dist/src/project/preparation-plan.js +182 -0
- package/dist/src/project/preparation-plan.js.map +1 -0
- package/dist/src/project/preparation.js +515 -0
- package/dist/src/project/preparation.js.map +1 -0
- package/dist/src/project/python-runtime.js +234 -0
- package/dist/src/project/python-runtime.js.map +1 -0
- package/dist/src/project/python.js +44 -11
- package/dist/src/project/python.js.map +1 -1
- package/dist/src/project/source.js +12 -7
- package/dist/src/project/source.js.map +1 -1
- package/dist/src/project/state-folder.js +15 -0
- package/dist/src/project/state-folder.js.map +1 -0
- package/dist/src/project/typescript-backend.js +18 -8
- package/dist/src/project/typescript-backend.js.map +1 -1
- package/dist/src/project/typescript-worker.js +14 -0
- package/dist/src/project/typescript-worker.js.map +1 -1
- package/dist/src/project/typescript.js +14 -1
- package/dist/src/project/typescript.js.map +1 -1
- package/dist/src/project/watch.js +37 -6
- package/dist/src/project/watch.js.map +1 -1
- package/dist/src/project/worker.py +168 -14
- package/dist/src/session/desktop-profile.js +4 -0
- package/dist/src/session/desktop-profile.js.map +1 -1
- package/dist/src/session/sessions.js +18 -2
- package/dist/src/session/sessions.js.map +1 -1
- package/dist/src/terminal/npm.js +1 -1
- package/dist/src/terminal/npm.js.map +1 -1
- package/dist/src/terminal/terminal.js +16 -2
- package/dist/src/terminal/terminal.js.map +1 -1
- package/dist/src/terminal/text.js +23 -0
- package/dist/src/terminal/text.js.map +1 -1
- package/dist/src/ui/app.js +17 -6
- package/dist/src/ui/app.js.map +1 -1
- package/dist/src/ui/chat/commands.js +3 -5
- package/dist/src/ui/chat/commands.js.map +1 -1
- package/dist/src/ui/chat/controller.js +405 -38
- package/dist/src/ui/chat/controller.js.map +1 -1
- package/dist/src/ui/chat/conversations.js +88 -10
- package/dist/src/ui/chat/conversations.js.map +1 -1
- package/dist/src/ui/chat/help.js +8 -0
- package/dist/src/ui/chat/help.js.map +1 -1
- package/dist/src/ui/chat/panel-state.js +36 -14
- package/dist/src/ui/chat/panel-state.js.map +1 -1
- package/dist/src/ui/chat/projector.js +10 -0
- package/dist/src/ui/chat/projector.js.map +1 -1
- package/dist/src/ui/chat/runtime.js +106 -9
- package/dist/src/ui/chat/runtime.js.map +1 -1
- package/dist/src/ui/chat/screen.js +215 -55
- package/dist/src/ui/chat/screen.js.map +1 -1
- package/dist/src/ui/chat/state.js +28 -0
- package/dist/src/ui/chat/state.js.map +1 -1
- package/dist/src/ui/chat/transcript-turn.js +15 -3
- package/dist/src/ui/chat/transcript-turn.js.map +1 -1
- package/dist/src/ui/chat/transcript.js +7 -5
- package/dist/src/ui/chat/transcript.js.map +1 -1
- package/dist/src/ui/chat/types.js.map +1 -1
- package/dist/src/ui/chat/view.js +84 -27
- package/dist/src/ui/chat/view.js.map +1 -1
- package/dist/src/ui/clipboard.js +41 -0
- package/dist/src/ui/clipboard.js.map +1 -0
- package/dist/src/ui/footer.js +19 -0
- package/dist/src/ui/footer.js.map +1 -1
- package/dist/src/ui/input.js +18 -0
- package/dist/src/ui/input.js.map +1 -0
- package/dist/src/ui/interaction.js +30 -8
- package/dist/src/ui/interaction.js.map +1 -1
- package/dist/src/ui/panels/dev.js +60 -0
- package/dist/src/ui/panels/dev.js.map +1 -0
- package/dist/src/ui/panels/settings.js +15 -1
- package/dist/src/ui/panels/settings.js.map +1 -1
- package/dist/src/ui/panels/wizard-request-panel.js +356 -0
- package/dist/src/ui/panels/wizard-request-panel.js.map +1 -0
- package/dist/src/ui/panels/wizard-request.js +251 -0
- package/dist/src/ui/panels/wizard-request.js.map +1 -0
- package/dist/src/ui/presentation.js +23 -7
- package/dist/src/ui/presentation.js.map +1 -1
- package/dist/src/ui/run.js +188 -11
- package/dist/src/ui/run.js.map +1 -1
- package/dist/src/ui/setup/providers.js +17 -1
- package/dist/src/ui/setup/providers.js.map +1 -1
- package/dist/src/ui/setup/steps.js +18 -6
- package/dist/src/ui/setup/steps.js.map +1 -1
- package/dist/src/ui/setup/wizard.js +12 -9
- package/dist/src/ui/setup/wizard.js.map +1 -1
- package/dist/src/ui/startup.js +32 -8
- package/dist/src/ui/startup.js.map +1 -1
- package/dist/src/ui/update.js +3 -2
- package/dist/src/ui/update.js.map +1 -1
- package/package.json +4 -4
|
@@ -10,8 +10,10 @@ import { sessionResumeCommand, } from '../../session/sessions.js';
|
|
|
10
10
|
import { mcpFailure } from '../mcp-diagnostics.js';
|
|
11
11
|
import { peerMessagePrompt } from '../../agent/messaging.js';
|
|
12
12
|
import { modelDisplayName } from '../../model/metadata.js';
|
|
13
|
-
import { modelControlErrorMessage } from '../../model/selection.js';
|
|
13
|
+
import { modelControlErrorMessage, profileEffort } from '../../model/selection.js';
|
|
14
|
+
import { isExpiredModelCredential, isModelCredentialFailure } from '../../model/credential-failure.js';
|
|
14
15
|
import { presentChatStream } from './stream-presentation.js';
|
|
16
|
+
import { SCREEN_CONTEXT_CLOSE, SCREEN_CONTEXT_OPEN } from '../../session/desktop-profile.js';
|
|
15
17
|
import { errorMessage, sanitizeTerminalText } from '../../terminal/text.js';
|
|
16
18
|
import { canUseNativePicker, chooseDirectory } from '../../terminal/directory-picker.js';
|
|
17
19
|
import { copyTerminalText } from '../../terminal/terminal.js';
|
|
@@ -19,7 +21,7 @@ import { expandHome, strandsUserPath } from '../../paths.js';
|
|
|
19
21
|
import { attachmentContent } from './attachments.js';
|
|
20
22
|
import { configurationDiffs, sanitizeConfigurationSource } from '../../config/source.js';
|
|
21
23
|
import { cloneRuntime, cloneTask, isConfigurationTool, isUnresolvedBackgroundTask, readTaskValue, readyBackgroundGeneration, } from './state.js';
|
|
22
|
-
import { TurnProjector, projectMessages } from './projector.js';
|
|
24
|
+
import { TurnProjector, projectFailedTurns, projectMessages } from './projector.js';
|
|
23
25
|
import {} from '../../agent/types.js';
|
|
24
26
|
import {} from './types.js';
|
|
25
27
|
export * from './types.js';
|
|
@@ -33,10 +35,18 @@ const EXPORT_TYPESCRIPT = 'export:typescript';
|
|
|
33
35
|
const EXPORT_NAME_PREFIX = 'export:name:';
|
|
34
36
|
const EXPORT_SAVE_DEFAULT_PREFIX = 'export:save-default:';
|
|
35
37
|
const EXPORT_SAVE_CUSTOM_PREFIX = 'export:save-custom:';
|
|
38
|
+
const TURN_FAILURE_GUIDANCE = {
|
|
39
|
+
expiredCredentials: 'Refresh your credentials, then restart Strands so that it loads them.',
|
|
40
|
+
modelSetup: 'Press s to choose a model provider, then resend your message.',
|
|
41
|
+
credentials: 'Refresh your credentials, then resend your message.',
|
|
42
|
+
other: 'Check your connection and provider, then resend your message.',
|
|
43
|
+
};
|
|
36
44
|
export class ChatController {
|
|
37
45
|
peerEndpointId;
|
|
38
46
|
_listeners = new Set();
|
|
39
47
|
_completedTurns = [];
|
|
48
|
+
_failedTurns;
|
|
49
|
+
_failedTurnRecord;
|
|
40
50
|
_panelStack = [];
|
|
41
51
|
_skillDetails = new Map();
|
|
42
52
|
_sessions;
|
|
@@ -48,6 +58,7 @@ export class ChatController {
|
|
|
48
58
|
_skills;
|
|
49
59
|
_skillRefresh;
|
|
50
60
|
_skillNames = new Set();
|
|
61
|
+
_skillsWithoutCommands;
|
|
51
62
|
_mcp;
|
|
52
63
|
_mcpDetails = new Map();
|
|
53
64
|
_mcpStartup;
|
|
@@ -56,11 +67,16 @@ export class ChatController {
|
|
|
56
67
|
_streamPresentation;
|
|
57
68
|
_setSettings;
|
|
58
69
|
_requestSetup;
|
|
70
|
+
_workspaceAction;
|
|
71
|
+
_devCommands;
|
|
72
|
+
_fileOpener;
|
|
73
|
+
_stopWatchingDevJobs = [];
|
|
59
74
|
_awsProfile;
|
|
60
75
|
_builtinTools;
|
|
61
76
|
_builtinToolSelection = new Set();
|
|
62
77
|
_exportAgentProject;
|
|
63
78
|
_useExportedProject;
|
|
79
|
+
_saveAgentOptions;
|
|
64
80
|
_configurationSource;
|
|
65
81
|
_project;
|
|
66
82
|
_copyText;
|
|
@@ -115,16 +131,20 @@ export class ChatController {
|
|
|
115
131
|
for (const name of options.skillNames ?? []) {
|
|
116
132
|
this._skillNames.add(name.toLowerCase());
|
|
117
133
|
}
|
|
134
|
+
this._skillsWithoutCommands = new Set(options.skillsWithoutCommands?.map((name) => name.toLowerCase()));
|
|
118
135
|
this._mcp = options.mcp;
|
|
119
136
|
this._watchMcpStartup();
|
|
120
137
|
this._settings = globalThis.structuredClone({ ...DEFAULT_CHAT_SETTINGS, ...options.settings });
|
|
121
138
|
this._streamPresentation = options.streamPresentation;
|
|
122
139
|
this._setSettings = options.setSettings;
|
|
123
140
|
this._requestSetup = options.requestSetup;
|
|
141
|
+
this._workspaceAction = options.workspaceAction;
|
|
142
|
+
this._devCommands = options.devCommands ?? [];
|
|
124
143
|
this._awsProfile = options.awsProfile;
|
|
125
144
|
this._builtinTools = options.builtinTools;
|
|
126
145
|
this._exportAgentProject = options.exportAgentProject;
|
|
127
146
|
this._useExportedProject = options.useExportedProject;
|
|
147
|
+
this._saveAgentOptions = options.saveAgentOptions;
|
|
128
148
|
this._configurationSource = options.configurationSource;
|
|
129
149
|
this._project = options.project;
|
|
130
150
|
this._copyText = options.copyText ?? copyTerminalText;
|
|
@@ -144,11 +164,13 @@ export class ChatController {
|
|
|
144
164
|
tools: info?.tools ?? [],
|
|
145
165
|
...options.runtime,
|
|
146
166
|
};
|
|
167
|
+
this._failedTurnRecord = options.failedTurns;
|
|
168
|
+
this._failedTurns = options.failedTurns?.saved ?? [];
|
|
147
169
|
if (options.initialTurns) {
|
|
148
170
|
this._completedTurns = [...options.initialTurns];
|
|
149
171
|
}
|
|
150
|
-
else if (options.initialMessages) {
|
|
151
|
-
this._completedTurns.push(...projectMessages(options.initialMessages, this.name));
|
|
172
|
+
else if (options.initialMessages || this._failedTurns.length > 0) {
|
|
173
|
+
this._completedTurns.push(...projectMessages(options.initialMessages ?? [], this.name), ...projectFailedTurns(this._failedTurns, this.name));
|
|
152
174
|
}
|
|
153
175
|
this._nextTurn = this._completedTurns.length + 1;
|
|
154
176
|
this._context = { ...(backend.contextUsage?.() ?? {}) };
|
|
@@ -157,7 +179,27 @@ export class ChatController {
|
|
|
157
179
|
this._configurationBaseline = options.initialConfigurationBaseline;
|
|
158
180
|
this._configurationDiffs = configurationDiffs(options.initialConfigurationBaseline.source, this._configuration);
|
|
159
181
|
}
|
|
182
|
+
if (this._runtime.devWorkspace) {
|
|
183
|
+
const { root, entrypoint, origin } = this._runtime.devWorkspace;
|
|
184
|
+
this._notices.push({
|
|
185
|
+
id: 'dev-workspace',
|
|
186
|
+
status: 'success',
|
|
187
|
+
text: `strands dev · ${backend.name}\nWorkspace: ${root}\nHarness: ${entrypoint} (${origin})\nModel, tools, and instructions come from this workspace.`,
|
|
188
|
+
});
|
|
189
|
+
if (options.devStateNotice)
|
|
190
|
+
this._notices.push({ id: 'dev-state', status: 'error', text: options.devStateNotice });
|
|
191
|
+
}
|
|
160
192
|
this._snapshot = this._createSnapshot();
|
|
193
|
+
for (const command of this._devCommands)
|
|
194
|
+
command.attach?.(this._devCommandContext());
|
|
195
|
+
this._stopWatchingDevJobs = this._devCommands.flatMap(({ jobs }) => jobs
|
|
196
|
+
? [
|
|
197
|
+
jobs.subscribe(() => {
|
|
198
|
+
if (!this._closed)
|
|
199
|
+
this._emit();
|
|
200
|
+
}),
|
|
201
|
+
]
|
|
202
|
+
: []);
|
|
161
203
|
this._stopWatchingTasks = this._backend.watchTasks?.((tasks) => {
|
|
162
204
|
if (this._closed) {
|
|
163
205
|
return;
|
|
@@ -234,8 +276,33 @@ export class ChatController {
|
|
|
234
276
|
...(sourceSelection ? { sourceSelection } : {}),
|
|
235
277
|
};
|
|
236
278
|
}
|
|
237
|
-
|
|
238
|
-
this.
|
|
279
|
+
clearReloadStatus() {
|
|
280
|
+
if (this._runtime.reloadStatus === undefined)
|
|
281
|
+
return;
|
|
282
|
+
delete this._runtime.reloadStatus;
|
|
283
|
+
this._emit();
|
|
284
|
+
}
|
|
285
|
+
attachFileOpener(open) {
|
|
286
|
+
this._fileOpener = open;
|
|
287
|
+
return () => {
|
|
288
|
+
if (this._fileOpener === open)
|
|
289
|
+
this._fileOpener = undefined;
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
markReloaded(paths) {
|
|
293
|
+
const changed = [...new Set(paths)];
|
|
294
|
+
const label = changed.length > 1 ? `${changed.length} files` : changed[0]?.split(/[\\/]/u).at(-1) || 'agent source';
|
|
295
|
+
const status = `↻ ${sanitizeTerminalText(label)} reloaded · session kept`;
|
|
296
|
+
this._runtime.reloadStatus = status;
|
|
297
|
+
this._addNotice('success', status);
|
|
298
|
+
this._emit();
|
|
299
|
+
}
|
|
300
|
+
showError(title, message, options = {}) {
|
|
301
|
+
this._openError(title, '', message, options.fixDirectory);
|
|
302
|
+
}
|
|
303
|
+
notify(status, text) {
|
|
304
|
+
this._addNotice(status, text);
|
|
305
|
+
this._emit();
|
|
239
306
|
}
|
|
240
307
|
get backend() {
|
|
241
308
|
return this._backend;
|
|
@@ -256,11 +323,14 @@ export class ChatController {
|
|
|
256
323
|
const session = this._sessions?.currentTarget ?? this._backend.sessionIdentity;
|
|
257
324
|
if (!session?.sessionId)
|
|
258
325
|
return undefined;
|
|
326
|
+
const dev = this._runtime.devWorkspace;
|
|
327
|
+
const ranBoundAgent = dev !== undefined && dev.entrypoint === dev.boundEntrypoint;
|
|
259
328
|
return {
|
|
260
329
|
sessionId: session.sessionId,
|
|
261
330
|
sessionDirectory: session.sessionDirectory,
|
|
262
331
|
workspace: session.workspace,
|
|
263
|
-
...(
|
|
332
|
+
...(dev ? { devWorkspace: dev.root } : {}),
|
|
333
|
+
...(this._project && !ranBoundAgent ? { agentProject: this._project.entrypoint } : {}),
|
|
264
334
|
};
|
|
265
335
|
}
|
|
266
336
|
actionableCommandToken(input) {
|
|
@@ -271,10 +341,13 @@ export class ChatController {
|
|
|
271
341
|
if (!invocation) {
|
|
272
342
|
return undefined;
|
|
273
343
|
}
|
|
274
|
-
if (invocation.prefix === '/' &&
|
|
344
|
+
if (invocation.prefix === '/' &&
|
|
345
|
+
(LOCAL_COMMAND_NAMES.has(invocation.name.toLowerCase()) || this._typedDevCommand(invocation.name))) {
|
|
275
346
|
return invocation.token;
|
|
276
347
|
}
|
|
277
|
-
return this._backend.protocol === 'strands' &&
|
|
348
|
+
return this._backend.protocol === 'strands' &&
|
|
349
|
+
this._skillNames.has(invocation.name.toLowerCase()) &&
|
|
350
|
+
(invocation.prefix === '$' || this._isSkillCommand(invocation.name))
|
|
278
351
|
? invocation.token
|
|
279
352
|
: undefined;
|
|
280
353
|
}
|
|
@@ -283,7 +356,7 @@ export class ChatController {
|
|
|
283
356
|
if (!input.startsWith('/')) {
|
|
284
357
|
return undefined;
|
|
285
358
|
}
|
|
286
|
-
return resolveCommandAssistance(input, this.actionableCommandToken(input), this._skillCommands());
|
|
359
|
+
return resolveCommandAssistance(input, this.actionableCommandToken(input), this._skillCommands(), this._devCommands.filter(({ hidden }) => !hidden).map((command) => command.spec));
|
|
287
360
|
}
|
|
288
361
|
async start(firstRequest) {
|
|
289
362
|
setImmediate(() => void this._discoverSkillNames());
|
|
@@ -334,12 +407,17 @@ export class ChatController {
|
|
|
334
407
|
}
|
|
335
408
|
}
|
|
336
409
|
_skillCommands() {
|
|
337
|
-
return [...this._skillDetails.values()]
|
|
410
|
+
return [...this._skillDetails.values()]
|
|
411
|
+
.filter(({ name }) => this._isSkillCommand(name))
|
|
412
|
+
.map((skill) => ({
|
|
338
413
|
name: skill.name,
|
|
339
414
|
usage: `/${sanitizeTerminalText(skill.name)} [request]`,
|
|
340
415
|
description: skill.description,
|
|
341
416
|
}));
|
|
342
417
|
}
|
|
418
|
+
_isSkillCommand(name) {
|
|
419
|
+
return !this._skillsWithoutCommands.has(name.toLowerCase());
|
|
420
|
+
}
|
|
343
421
|
async submit(input) {
|
|
344
422
|
const submission = normalizeChatInput(input);
|
|
345
423
|
const { text: prompt, attachments } = submission;
|
|
@@ -355,7 +433,7 @@ export class ChatController {
|
|
|
355
433
|
return undefined;
|
|
356
434
|
}
|
|
357
435
|
if (attachments.length === 0 &&
|
|
358
|
-
isLiveLocalCommand(prompt) &&
|
|
436
|
+
(isLiveLocalCommand(prompt) || this._isDevCommandPrompt(prompt)) &&
|
|
359
437
|
!this._resourceChanging &&
|
|
360
438
|
(this._panel?.kind !== 'permission' ||
|
|
361
439
|
['settings', 'permissions'].includes(parseCommandInvocation(prompt)?.name.toLowerCase() ?? ''))) {
|
|
@@ -507,8 +585,7 @@ export class ChatController {
|
|
|
507
585
|
this._openError('shell unavailable', `!${command}`, 'The active backend does not expose a sandbox. Switch to the built-in Strands connection.');
|
|
508
586
|
return undefined;
|
|
509
587
|
}
|
|
510
|
-
this.
|
|
511
|
-
this._panelStack.length = 0;
|
|
588
|
+
this._closePanelsForTurn();
|
|
512
589
|
return this._runStream(prompt, this._backend.streamShell(command), 'shell');
|
|
513
590
|
}
|
|
514
591
|
async _runPrompt(input, displayPrompt) {
|
|
@@ -516,17 +593,22 @@ export class ChatController {
|
|
|
516
593
|
return undefined;
|
|
517
594
|
}
|
|
518
595
|
const submission = normalizeChatInput(input);
|
|
519
|
-
this.
|
|
520
|
-
|
|
521
|
-
const
|
|
596
|
+
this._closePanelsForTurn();
|
|
597
|
+
// A message typed beside an open panel may be about what the panel shows. A command or a skill brings its own request.
|
|
598
|
+
const text = displayPrompt === undefined ? withScreenContext(submission.text, this._screenContext()) : submission.text;
|
|
599
|
+
const prompt = submission.attachments.length === 0 ? text : attachmentContent(text, submission.attachments);
|
|
522
600
|
return this._runStream(displayPrompt ?? submission.text, this._backend.stream(prompt), 'model', undefined, undefined, submission.attachments);
|
|
523
601
|
}
|
|
602
|
+
/** What the open dev panel shows, for the agent to read with the message that was typed beside it. */
|
|
603
|
+
_screenContext() {
|
|
604
|
+
const panel = this._panel;
|
|
605
|
+
return panel?.kind === 'dev' ? this._devCommand(panel.command)?.screenContext?.() : undefined;
|
|
606
|
+
}
|
|
524
607
|
async _runPeerMessage(message) {
|
|
525
608
|
if (this._closed || this._execution || this._resourceChanging || !this._backend.streamPeer) {
|
|
526
609
|
return undefined;
|
|
527
610
|
}
|
|
528
|
-
this.
|
|
529
|
-
this._panelStack.length = 0;
|
|
611
|
+
this._closePanelsForTurn();
|
|
530
612
|
return this._runStream(message.body, this._backend.streamPeer(message), 'model', 'peer', message.from);
|
|
531
613
|
}
|
|
532
614
|
async _runBackgroundContinuation() {
|
|
@@ -608,6 +690,8 @@ export class ChatController {
|
|
|
608
690
|
this._context = contextBeforeTurn;
|
|
609
691
|
const recovery = mode === 'shell' ? undefined : this._failureRecoveryHint(error);
|
|
610
692
|
projector.fail(error, recovery);
|
|
693
|
+
if (mode === 'model')
|
|
694
|
+
this._offerDevFix(projector.snapshot());
|
|
611
695
|
}
|
|
612
696
|
finally {
|
|
613
697
|
clearTimeout(toolOutputEmitTimer);
|
|
@@ -616,8 +700,9 @@ export class ChatController {
|
|
|
616
700
|
if (steeringDrain) {
|
|
617
701
|
await steeringDrain;
|
|
618
702
|
}
|
|
619
|
-
|
|
620
|
-
|
|
703
|
+
const finished = execution.phase === 'running' ? projector.snapshot() : undefined;
|
|
704
|
+
if (finished) {
|
|
705
|
+
this._completedTurns.push(finished);
|
|
621
706
|
}
|
|
622
707
|
if (this._execution === execution) {
|
|
623
708
|
this._execution = undefined;
|
|
@@ -625,20 +710,68 @@ export class ChatController {
|
|
|
625
710
|
this._steeringDrain = undefined;
|
|
626
711
|
this._clearDeliveredBackgroundTaskNotices();
|
|
627
712
|
this._emit();
|
|
713
|
+
if (finished && mode === 'model')
|
|
714
|
+
await this._updateFailedTurns(finished);
|
|
628
715
|
if (!this._closed) {
|
|
629
716
|
await this._applyDeferredModelRestart();
|
|
630
717
|
this._startBackgroundContinuation();
|
|
631
718
|
this._startPendingSubmissions();
|
|
719
|
+
if (finished && mode === 'model')
|
|
720
|
+
this._tellDevCommandsOfTurn(finished);
|
|
632
721
|
}
|
|
633
722
|
}
|
|
634
723
|
return projector.snapshot();
|
|
635
724
|
}
|
|
725
|
+
_offerDevFix(turn) {
|
|
726
|
+
if (turn.status !== 'error' || !this._runtime.devWorkspace)
|
|
727
|
+
return;
|
|
728
|
+
const message = turn.error ?? '';
|
|
729
|
+
const failure = this._turnFailure(message);
|
|
730
|
+
if (failure === 'expiredCredentials')
|
|
731
|
+
return;
|
|
732
|
+
if (failure === 'modelSetup') {
|
|
733
|
+
this._openPanel({
|
|
734
|
+
kind: 'error',
|
|
735
|
+
title: 'Model provider needs setup',
|
|
736
|
+
rows: [{ label: '', description: message, tone: 'danger' }],
|
|
737
|
+
modelSetup: true,
|
|
738
|
+
copyable: true,
|
|
739
|
+
});
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
this._openError('Agent turn failed', '', message, this._runtime.cwd);
|
|
743
|
+
}
|
|
744
|
+
_turnFailure(message) {
|
|
745
|
+
if (!isModelCredentialFailure(message))
|
|
746
|
+
return 'other';
|
|
747
|
+
if (isExpiredModelCredential(message))
|
|
748
|
+
return 'expiredCredentials';
|
|
749
|
+
return this._runtime.devWorkspace && this._requestSetup ? 'modelSetup' : 'credentials';
|
|
750
|
+
}
|
|
751
|
+
async _updateFailedTurns(turn) {
|
|
752
|
+
if (!this._failedTurnRecord)
|
|
753
|
+
return;
|
|
754
|
+
if (turn.status === 'error' && turn.source)
|
|
755
|
+
return;
|
|
756
|
+
if (turn.status !== 'error' && this._failedTurns.length === 0)
|
|
757
|
+
return;
|
|
758
|
+
this._failedTurns =
|
|
759
|
+
turn.status === 'error' ? [...this._failedTurns, { prompt: turn.prompt, error: turn.error ?? '' }] : [];
|
|
760
|
+
try {
|
|
761
|
+
await this._failedTurnRecord.save(this._failedTurns);
|
|
762
|
+
}
|
|
763
|
+
catch (error) {
|
|
764
|
+
this._addNotice('error', `The failed message could not be saved for a resume: ${errorMessage(error)}`);
|
|
765
|
+
this._emit();
|
|
766
|
+
}
|
|
767
|
+
}
|
|
636
768
|
_failureRecoveryHint(error) {
|
|
637
769
|
const message = errorMessage(error);
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
770
|
+
const guidance = this._runtime.devWorkspace
|
|
771
|
+
? TURN_FAILURE_GUIDANCE[this._turnFailure(message)]
|
|
772
|
+
: /credentials?|expiredtoken|security token|sso.*expired/i.test(message)
|
|
773
|
+
? 'Refresh your credentials, then resend your message.'
|
|
774
|
+
: 'Check your connection and provider, then resend your message.';
|
|
642
775
|
const session = this.resumeSession;
|
|
643
776
|
return session ? `${guidance}\nTo resume after restarting: ${sessionResumeCommand(session)}` : guidance;
|
|
644
777
|
}
|
|
@@ -702,6 +835,9 @@ export class ChatController {
|
|
|
702
835
|
}
|
|
703
836
|
execution.presentationAbort.abort();
|
|
704
837
|
this._backend.cancel();
|
|
838
|
+
// A tool of the cancelled turn may wait on screen; the worker cannot cancel it across the process boundary.
|
|
839
|
+
for (const command of this._devCommands)
|
|
840
|
+
command.abandon?.(this._devCommandContext());
|
|
705
841
|
if (running)
|
|
706
842
|
this._emit();
|
|
707
843
|
return true;
|
|
@@ -712,6 +848,7 @@ export class ChatController {
|
|
|
712
848
|
}
|
|
713
849
|
this._closed = true;
|
|
714
850
|
this._sessionNaming?.abort();
|
|
851
|
+
this._stopDevJobs();
|
|
715
852
|
this._stopWatchingUsage();
|
|
716
853
|
this._backgroundContinuationPending = false;
|
|
717
854
|
const interrupted = this._execution !== undefined;
|
|
@@ -730,6 +867,7 @@ export class ChatController {
|
|
|
730
867
|
async dispose() {
|
|
731
868
|
this._closed = true;
|
|
732
869
|
this._sessionNaming?.abort();
|
|
870
|
+
this._stopDevJobs();
|
|
733
871
|
this._stopWatchingUsage();
|
|
734
872
|
if (this._execution) {
|
|
735
873
|
this._execution.presentationAbort.abort();
|
|
@@ -885,8 +1023,7 @@ export class ChatController {
|
|
|
885
1023
|
if (!pending) {
|
|
886
1024
|
return;
|
|
887
1025
|
}
|
|
888
|
-
this.
|
|
889
|
-
this._panelStack.length = 0;
|
|
1026
|
+
this._closePanelsForTurn();
|
|
890
1027
|
if (pending.kind === 'peer') {
|
|
891
1028
|
await this._runPeerMessage(pending.message);
|
|
892
1029
|
}
|
|
@@ -904,12 +1041,18 @@ export class ChatController {
|
|
|
904
1041
|
}
|
|
905
1042
|
}
|
|
906
1043
|
dismissPanel() {
|
|
1044
|
+
return this._dismissPanel(true);
|
|
1045
|
+
}
|
|
1046
|
+
_dismissPanel(abandon) {
|
|
907
1047
|
if (!this._panel || this._resourceChanging || this._panel.kind === 'permission') {
|
|
908
1048
|
return false;
|
|
909
1049
|
}
|
|
910
1050
|
if (this._panel.kind === 'tools' && !this._applyBuiltinTools()) {
|
|
911
1051
|
return true;
|
|
912
1052
|
}
|
|
1053
|
+
// A dev panel that the developer leaves, rather than one that closes itself, gives up what it waits on.
|
|
1054
|
+
if (abandon && this._panel.kind === 'dev')
|
|
1055
|
+
this._devCommand(this._panel.command)?.abandon?.(this._devCommandContext());
|
|
913
1056
|
this._stopTaskActivity();
|
|
914
1057
|
this._panel = this._panelStack.pop();
|
|
915
1058
|
this._emit();
|
|
@@ -918,6 +1061,19 @@ export class ChatController {
|
|
|
918
1061
|
async setSettings(settings) {
|
|
919
1062
|
return this._applySettings(settings, 'settings');
|
|
920
1063
|
}
|
|
1064
|
+
/** Settings already saved outside this chat, applied without writing them back. */
|
|
1065
|
+
applyExternalSettings(settings) {
|
|
1066
|
+
if (this._closed)
|
|
1067
|
+
return;
|
|
1068
|
+
this._settings = globalThis.structuredClone(settings);
|
|
1069
|
+
if (this._panel?.kind === 'settings') {
|
|
1070
|
+
this._panel = {
|
|
1071
|
+
...this._panel,
|
|
1072
|
+
rows: sanitizeRows(this._settingsCategoryRows(this._panel.settingsCategory ?? DEFAULT_SETTINGS_CATEGORY)),
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
this._emit();
|
|
1076
|
+
}
|
|
921
1077
|
async activatePanelRow(row) {
|
|
922
1078
|
if (!this._panel || !row.value || this._resourceChanging) {
|
|
923
1079
|
return false;
|
|
@@ -953,6 +1109,17 @@ export class ChatController {
|
|
|
953
1109
|
case 'mcp':
|
|
954
1110
|
return row.value.startsWith('mcp:toggle:') ? this._toggleMcpServer(row.value) : false;
|
|
955
1111
|
case 'settings':
|
|
1112
|
+
if (row.value.startsWith('workspace:')) {
|
|
1113
|
+
const action = row.value.slice('workspace:'.length);
|
|
1114
|
+
if (!this._workspaceAction || !this._runtime.devWorkspace || action !== 'edit')
|
|
1115
|
+
return false;
|
|
1116
|
+
if (this.busy || this._hasUnresolvedBackgroundTasks()) {
|
|
1117
|
+
this._openError('Workspace busy', '', 'Finish or cancel running work before changing this workspace.');
|
|
1118
|
+
return false;
|
|
1119
|
+
}
|
|
1120
|
+
this._workspaceAction(action);
|
|
1121
|
+
return true;
|
|
1122
|
+
}
|
|
956
1123
|
if (row.value === SETTINGS_SETUP_ACTION) {
|
|
957
1124
|
if (!this._requestSetup) {
|
|
958
1125
|
return false;
|
|
@@ -1056,6 +1223,7 @@ export class ChatController {
|
|
|
1056
1223
|
this._updateOpenModelPanel(modelId);
|
|
1057
1224
|
this._openEffortPanelIfAvailable();
|
|
1058
1225
|
this._emit();
|
|
1226
|
+
await this._saveToAgent('model', { model: modelId });
|
|
1059
1227
|
return true;
|
|
1060
1228
|
}
|
|
1061
1229
|
catch (error) {
|
|
@@ -1066,6 +1234,16 @@ export class ChatController {
|
|
|
1066
1234
|
this._finishResourceChange();
|
|
1067
1235
|
}
|
|
1068
1236
|
}
|
|
1237
|
+
async _saveToAgent(option, change) {
|
|
1238
|
+
if (!this._saveAgentOptions)
|
|
1239
|
+
return;
|
|
1240
|
+
try {
|
|
1241
|
+
await this._saveAgentOptions(change);
|
|
1242
|
+
}
|
|
1243
|
+
catch (error) {
|
|
1244
|
+
this._openError(`${option} kept for this session only`, change[option] ?? option, errorMessage(error));
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1069
1247
|
_handleEvent(projector, event, turnContext) {
|
|
1070
1248
|
if (event.type === 'tasks') {
|
|
1071
1249
|
this._setTasks(event.tasks);
|
|
@@ -1120,6 +1298,7 @@ export class ChatController {
|
|
|
1120
1298
|
}
|
|
1121
1299
|
_createSnapshot() {
|
|
1122
1300
|
const activeTurn = this._activeProjector?.snapshot();
|
|
1301
|
+
const devJobs = this._devJobs();
|
|
1123
1302
|
return {
|
|
1124
1303
|
completedTurns: [...this._completedTurns],
|
|
1125
1304
|
...(activeTurn ? { activeTurn } : {}),
|
|
@@ -1156,6 +1335,7 @@ export class ChatController {
|
|
|
1156
1335
|
...(this._permissionMode ? { permissionMode: this._permissionMode } : {}),
|
|
1157
1336
|
...(this._permissionPreset ? { permissionPreset: this._permissionPreset } : {}),
|
|
1158
1337
|
settings: globalThis.structuredClone(this._settings),
|
|
1338
|
+
...(devJobs.length > 0 ? { devJobs } : {}),
|
|
1159
1339
|
...(this._exitCode !== undefined ? { exitCode: this._exitCode } : {}),
|
|
1160
1340
|
};
|
|
1161
1341
|
}
|
|
@@ -1181,6 +1361,7 @@ export class ChatController {
|
|
|
1181
1361
|
tools: this._builtinTools !== undefined,
|
|
1182
1362
|
export: this._exportAgentProject !== undefined,
|
|
1183
1363
|
config: this._configurationSource !== undefined,
|
|
1364
|
+
devCommands: this._devCommands.filter(({ hidden }) => !hidden).map((command) => command.spec),
|
|
1184
1365
|
}),
|
|
1185
1366
|
searchable: true,
|
|
1186
1367
|
filters: [
|
|
@@ -1253,7 +1434,20 @@ export class ChatController {
|
|
|
1253
1434
|
this.close();
|
|
1254
1435
|
break;
|
|
1255
1436
|
default: {
|
|
1256
|
-
const
|
|
1437
|
+
const devCommand = this._typedDevCommand(command);
|
|
1438
|
+
if (devCommand?.skill) {
|
|
1439
|
+
const { skill, workflow, unavailable } = devCommand.skill;
|
|
1440
|
+
const request = skillCommandRequest(devCommand.spec.name, workflow, prompt);
|
|
1441
|
+
if ((await this._activateSkillAndRun(skill, prompt, request)) === null) {
|
|
1442
|
+
this._openError('skill unavailable', `/${devCommand.spec.name}`, unavailable);
|
|
1443
|
+
}
|
|
1444
|
+
break;
|
|
1445
|
+
}
|
|
1446
|
+
if (devCommand) {
|
|
1447
|
+
this._openDevPanel(devCommand);
|
|
1448
|
+
break;
|
|
1449
|
+
}
|
|
1450
|
+
const turn = this._isSkillCommand(command) ? await this._activateSkillAndRun(command, prompt) : null;
|
|
1257
1451
|
if (turn === null) {
|
|
1258
1452
|
this._openError('unknown command', `/${command}`, 'Type / to browse commands or use /skills to list skills.');
|
|
1259
1453
|
}
|
|
@@ -1440,6 +1634,7 @@ export class ChatController {
|
|
|
1440
1634
|
this._updateOpenModelPanel(modelId);
|
|
1441
1635
|
this._openEffortPanelIfAvailable();
|
|
1442
1636
|
this._emit();
|
|
1637
|
+
await this._saveToAgent('model', { model: modelId });
|
|
1443
1638
|
return true;
|
|
1444
1639
|
}
|
|
1445
1640
|
catch (error) {
|
|
@@ -1477,6 +1672,8 @@ export class ChatController {
|
|
|
1477
1672
|
};
|
|
1478
1673
|
}
|
|
1479
1674
|
this._emit();
|
|
1675
|
+
if (selected !== undefined)
|
|
1676
|
+
await this._saveToAgent('effort', { effort: profileEffort(effort) });
|
|
1480
1677
|
return selected !== undefined;
|
|
1481
1678
|
}
|
|
1482
1679
|
catch (error) {
|
|
@@ -1684,7 +1881,7 @@ export class ChatController {
|
|
|
1684
1881
|
}
|
|
1685
1882
|
}
|
|
1686
1883
|
}
|
|
1687
|
-
async _activateSkillAndRun(name, displayPrompt) {
|
|
1884
|
+
async _activateSkillAndRun(name, displayPrompt, request = displayPrompt) {
|
|
1688
1885
|
if (!this._skills || this._backend.protocol !== 'strands') {
|
|
1689
1886
|
return null;
|
|
1690
1887
|
}
|
|
@@ -1699,7 +1896,7 @@ export class ChatController {
|
|
|
1699
1896
|
this._skillDetails.set(skill.name, skill);
|
|
1700
1897
|
// Start this submission before releasing queued work.
|
|
1701
1898
|
this._resourceChanging = false;
|
|
1702
|
-
return this._runPrompt(skillInvocationPrompt(activation,
|
|
1899
|
+
return this._runPrompt(skillInvocationPrompt(activation, request), displayPrompt);
|
|
1703
1900
|
}
|
|
1704
1901
|
catch (error) {
|
|
1705
1902
|
this._openError('skill activation failed', name, errorMessage(error));
|
|
@@ -1760,6 +1957,7 @@ export class ChatController {
|
|
|
1760
1957
|
await this._backend.clear();
|
|
1761
1958
|
this._stopWatchingUsage();
|
|
1762
1959
|
this._completedTurns = [];
|
|
1960
|
+
this._failedTurns = [];
|
|
1763
1961
|
this._notices = [];
|
|
1764
1962
|
this._tasks = [];
|
|
1765
1963
|
this._context = {};
|
|
@@ -2250,7 +2448,7 @@ export class ChatController {
|
|
|
2250
2448
|
if (this._panel?.kind === 'settings') {
|
|
2251
2449
|
this._panel = {
|
|
2252
2450
|
...this._panel,
|
|
2253
|
-
rows: sanitizeRows(
|
|
2451
|
+
rows: sanitizeRows(this._settingsCategoryRows(this._panel.settingsCategory ?? DEFAULT_SETTINGS_CATEGORY)),
|
|
2254
2452
|
};
|
|
2255
2453
|
}
|
|
2256
2454
|
return true;
|
|
@@ -2263,17 +2461,33 @@ export class ChatController {
|
|
|
2263
2461
|
this._finishResourceChange();
|
|
2264
2462
|
}
|
|
2265
2463
|
}
|
|
2464
|
+
_settingsCategoryRows(category) {
|
|
2465
|
+
const rows = settingsRows(this._settings, category, this._requestSetup !== undefined);
|
|
2466
|
+
if (category !== 'Workspace')
|
|
2467
|
+
return rows;
|
|
2468
|
+
return [
|
|
2469
|
+
{ label: 'Workspace folder', description: this._runtime.devWorkspace.root },
|
|
2470
|
+
{ label: 'Current agent', description: this._runtime.devWorkspace.entrypoint },
|
|
2471
|
+
{
|
|
2472
|
+
label: 'Edit workspace configuration',
|
|
2473
|
+
description: 'Open .config; changes apply on next launch',
|
|
2474
|
+
value: 'workspace:edit',
|
|
2475
|
+
},
|
|
2476
|
+
...rows,
|
|
2477
|
+
];
|
|
2478
|
+
}
|
|
2266
2479
|
_openSettingsCategory(value, replace = false) {
|
|
2267
|
-
const category =
|
|
2480
|
+
const category = value === 'settings:Workspace' && this._workspaceAction && this._runtime.devWorkspace
|
|
2481
|
+
? { id: 'Workspace', label: 'Strands dev workspace' }
|
|
2482
|
+
: SETTINGS_CATEGORIES.find(({ id }) => value === `settings:${id}`);
|
|
2268
2483
|
if (!category) {
|
|
2269
2484
|
return false;
|
|
2270
2485
|
}
|
|
2271
|
-
const rows = settingsRows(this._settings, category.id, this._requestSetup !== undefined);
|
|
2272
2486
|
const panel = {
|
|
2273
2487
|
kind: 'settings',
|
|
2274
2488
|
title: category.label,
|
|
2275
|
-
rows,
|
|
2276
|
-
filters: settingsCategoryFilters(),
|
|
2489
|
+
rows: this._settingsCategoryRows(category.id),
|
|
2490
|
+
filters: settingsCategoryFilters(Boolean(this._workspaceAction && this._runtime.devWorkspace)),
|
|
2277
2491
|
settingsCategory: category.id,
|
|
2278
2492
|
};
|
|
2279
2493
|
if (replace) {
|
|
@@ -2563,6 +2777,143 @@ export class ChatController {
|
|
|
2563
2777
|
this._notices = this._notices.filter((notice) => notice.status !== 'success' || !notice.taskId || !this._deliveredBackgroundTaskIds.has(notice.taskId));
|
|
2564
2778
|
this._deliveredBackgroundTaskIds.clear();
|
|
2565
2779
|
}
|
|
2780
|
+
_closePanelsForTurn() {
|
|
2781
|
+
if (this._panel?.kind === 'dev')
|
|
2782
|
+
return;
|
|
2783
|
+
this._panel = undefined;
|
|
2784
|
+
this._panelStack.length = 0;
|
|
2785
|
+
}
|
|
2786
|
+
_stopDevJobs() {
|
|
2787
|
+
for (const stop of this._stopWatchingDevJobs)
|
|
2788
|
+
stop();
|
|
2789
|
+
this._stopWatchingDevJobs = [];
|
|
2790
|
+
}
|
|
2791
|
+
openDevCommand(name, opening) {
|
|
2792
|
+
const devCommand = this._devCommand(name);
|
|
2793
|
+
if (!devCommand || this._closed || this._panel?.kind === 'permission')
|
|
2794
|
+
return false;
|
|
2795
|
+
if (opening?.job !== undefined && devCommand.openJob?.(this._devCommandContext(), opening.job))
|
|
2796
|
+
return true;
|
|
2797
|
+
if (devCommand.skill) {
|
|
2798
|
+
// A skill command has no panel to restore; a job click asks the chat about that job.
|
|
2799
|
+
if (opening?.restore)
|
|
2800
|
+
return false;
|
|
2801
|
+
const request = opening?.job ? devCommand.skill.job?.(opening.job) : undefined;
|
|
2802
|
+
void this.submit(`/${devCommand.spec.name}${request ? ` ${request}` : ''}`);
|
|
2803
|
+
return true;
|
|
2804
|
+
}
|
|
2805
|
+
this._openDevPanel(devCommand);
|
|
2806
|
+
return true;
|
|
2807
|
+
}
|
|
2808
|
+
/** A tool's panel waits under a pending permission prompt and shows once that prompt is answered. */
|
|
2809
|
+
_openToolPanel(name) {
|
|
2810
|
+
const devCommand = this._devCommand(name);
|
|
2811
|
+
if (!devCommand?.open || this._closed)
|
|
2812
|
+
return false;
|
|
2813
|
+
const waiting = this._panelStack.at(-1);
|
|
2814
|
+
if (this._panel?.kind !== 'permission')
|
|
2815
|
+
this._openDevPanel(devCommand);
|
|
2816
|
+
else if (waiting?.kind !== 'dev' || waiting.command !== devCommand.spec.name)
|
|
2817
|
+
this._openDevPanel(devCommand, true);
|
|
2818
|
+
return true;
|
|
2819
|
+
}
|
|
2820
|
+
_openDevPanel(devCommand, underPermission = false) {
|
|
2821
|
+
if (!devCommand.open)
|
|
2822
|
+
return;
|
|
2823
|
+
if (this._panel?.kind === 'dev' && this._panel.command === devCommand.spec.name)
|
|
2824
|
+
return;
|
|
2825
|
+
const panel = {
|
|
2826
|
+
kind: 'dev',
|
|
2827
|
+
command: devCommand.spec.name,
|
|
2828
|
+
title: `/${devCommand.spec.name}`,
|
|
2829
|
+
rows: [],
|
|
2830
|
+
view: devCommand.open(this._devCommandContext()),
|
|
2831
|
+
close: () => {
|
|
2832
|
+
if (this._panel?.id === opened.id)
|
|
2833
|
+
this._dismissPanel(false);
|
|
2834
|
+
},
|
|
2835
|
+
...(devCommand.sticky ? { sticky: true } : {}),
|
|
2836
|
+
...(devCommand.dock ? { dock: () => devCommand.dock() } : {}),
|
|
2837
|
+
...(devCommand.dropPending ? { dropPending: () => devCommand.dropPending() } : {}),
|
|
2838
|
+
...(devCommand.contentRows
|
|
2839
|
+
? { contentRows: (width) => devCommand.contentRows(width) }
|
|
2840
|
+
: {}),
|
|
2841
|
+
};
|
|
2842
|
+
const opened = underPermission ? this._makePanel(panel) : this._openPanel(panel);
|
|
2843
|
+
if (underPermission)
|
|
2844
|
+
this._panelStack.push(opened);
|
|
2845
|
+
}
|
|
2846
|
+
_devJobs() {
|
|
2847
|
+
return this._devCommands.flatMap(({ spec, jobs, backgroundTools = [] }) => {
|
|
2848
|
+
const listed = jobs?.snapshot() ?? [];
|
|
2849
|
+
if (listed.length === 0)
|
|
2850
|
+
return [];
|
|
2851
|
+
// Only a job that is running stands for its tool: one that waits on the developer says nothing of a new run.
|
|
2852
|
+
const working = listed.some(({ waiting }) => !waiting);
|
|
2853
|
+
return [
|
|
2854
|
+
{
|
|
2855
|
+
command: spec.name,
|
|
2856
|
+
jobs: listed.map((job) => ({ ...job, label: sanitizeTerminalText(job.label).replace(/\s+/gu, ' ').trim() })),
|
|
2857
|
+
...(working && backgroundTools.length > 0 ? { covers: backgroundTools } : {}),
|
|
2858
|
+
},
|
|
2859
|
+
];
|
|
2860
|
+
});
|
|
2861
|
+
}
|
|
2862
|
+
_isDevCommandPrompt(prompt) {
|
|
2863
|
+
const invocation = parseCommandInvocation(prompt);
|
|
2864
|
+
// Panels open during a turn; a skill command is a turn of its own, so it queues.
|
|
2865
|
+
const devCommand = invocation?.prefix === '/' ? this._typedDevCommand(invocation.name) : undefined;
|
|
2866
|
+
return devCommand !== undefined && devCommand.skill === undefined;
|
|
2867
|
+
}
|
|
2868
|
+
_typedDevCommand(name) {
|
|
2869
|
+
const devCommand = this._devCommand(name);
|
|
2870
|
+
return devCommand?.hidden ? undefined : devCommand;
|
|
2871
|
+
}
|
|
2872
|
+
_devCommand(name) {
|
|
2873
|
+
const requested = name.toLowerCase();
|
|
2874
|
+
return this._devCommands.find((command) => command.spec.name.toLowerCase() === requested);
|
|
2875
|
+
}
|
|
2876
|
+
_devCommandContext() {
|
|
2877
|
+
return {
|
|
2878
|
+
report: (status, text) => {
|
|
2879
|
+
let notice = this._addNotice(status, text);
|
|
2880
|
+
this._emit();
|
|
2881
|
+
return {
|
|
2882
|
+
update: (nextStatus, nextText) => {
|
|
2883
|
+
if (this._closed)
|
|
2884
|
+
return;
|
|
2885
|
+
this._notices = this._notices.filter((candidate) => candidate !== notice);
|
|
2886
|
+
notice = this._addNotice(nextStatus, nextText);
|
|
2887
|
+
this._emit();
|
|
2888
|
+
},
|
|
2889
|
+
};
|
|
2890
|
+
},
|
|
2891
|
+
openPanel: (name) => this._openToolPanel(name),
|
|
2892
|
+
openFile: async (path) => {
|
|
2893
|
+
if (!this._fileOpener)
|
|
2894
|
+
throw new Error('This terminal cannot open an editor.');
|
|
2895
|
+
await this._fileOpener(path);
|
|
2896
|
+
},
|
|
2897
|
+
setSettings: (update) => this.setSettings(update),
|
|
2898
|
+
};
|
|
2899
|
+
}
|
|
2900
|
+
/** Tells the dev commands that a turn of the developer's ended, after everything that follows a turn has started. */
|
|
2901
|
+
_tellDevCommandsOfTurn(turn) {
|
|
2902
|
+
if (turn.status !== 'complete' || turn.source)
|
|
2903
|
+
return;
|
|
2904
|
+
const listening = this._devCommands.filter((command) => command.turnEnded);
|
|
2905
|
+
if (listening.length === 0)
|
|
2906
|
+
return;
|
|
2907
|
+
const context = this._devCommandContext();
|
|
2908
|
+
for (const command of listening) {
|
|
2909
|
+
try {
|
|
2910
|
+
command.turnEnded(context, { prompt: turn.prompt });
|
|
2911
|
+
}
|
|
2912
|
+
catch {
|
|
2913
|
+
// A command that fails here must not take the chat with it.
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2566
2917
|
_addNotice(status, text, taskId) {
|
|
2567
2918
|
const afterTurnId = this._activeProjector?.snapshot().id ?? this._completedTurns.at(-1)?.id;
|
|
2568
2919
|
const notice = {
|
|
@@ -2606,6 +2957,7 @@ export class ChatController {
|
|
|
2606
2957
|
notice.text = `Model changed to ${modelDisplayName(modelId)}`;
|
|
2607
2958
|
}
|
|
2608
2959
|
this._openEffortPanelIfAvailable();
|
|
2960
|
+
await this._saveToAgent('model', { model: modelId });
|
|
2609
2961
|
}
|
|
2610
2962
|
catch (error) {
|
|
2611
2963
|
if (notice) {
|
|
@@ -2669,10 +3021,19 @@ export class ChatController {
|
|
|
2669
3021
|
return panel;
|
|
2670
3022
|
}
|
|
2671
3023
|
_makePanel(input) {
|
|
2672
|
-
|
|
3024
|
+
const shown = (input.kind === 'detail' || input.kind === 'help-detail') && this._runtime.devWorkspace
|
|
3025
|
+
? { ...input, wrapWords: true }
|
|
3026
|
+
: input;
|
|
3027
|
+
return makePanel(`panel-${this._nextPanel++}`, shown);
|
|
2673
3028
|
}
|
|
2674
|
-
_openError(title, label, description) {
|
|
2675
|
-
this._openPanel({
|
|
3029
|
+
_openError(title, label, description, fixDirectory) {
|
|
3030
|
+
this._openPanel({
|
|
3031
|
+
kind: 'error',
|
|
3032
|
+
title,
|
|
3033
|
+
rows: [{ label, description, tone: 'danger' }],
|
|
3034
|
+
...(fixDirectory ? { fixDirectory } : {}),
|
|
3035
|
+
...(this._runtime.devWorkspace ? { copyable: true } : {}),
|
|
3036
|
+
});
|
|
2676
3037
|
}
|
|
2677
3038
|
}
|
|
2678
3039
|
function skillInvocationPrompt(activation, displayPrompt) {
|
|
@@ -2689,6 +3050,12 @@ function skillInvocationPrompt(activation, displayPrompt) {
|
|
|
2689
3050
|
displayPrompt,
|
|
2690
3051
|
].join('\n');
|
|
2691
3052
|
}
|
|
3053
|
+
function withScreenContext(prompt, context) {
|
|
3054
|
+
return context ? [SCREEN_CONTEXT_OPEN, context, SCREEN_CONTEXT_CLOSE, '', prompt].join('\n') : prompt;
|
|
3055
|
+
}
|
|
3056
|
+
function skillCommandRequest(command, workflow, prompt) {
|
|
3057
|
+
return [`<strands_dev_command name="${command}">`, workflow, '</strands_dev_command>', '', prompt].join('\n');
|
|
3058
|
+
}
|
|
2692
3059
|
function isLiveLocalCommand(prompt) {
|
|
2693
3060
|
const invocation = parseCommandInvocation(prompt);
|
|
2694
3061
|
return invocation?.prefix === '/' && LIVE_LOCAL_COMMAND_NAMES.has(invocation.name.toLowerCase());
|