@strands-agents/cli 0.1.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/LICENSE +175 -0
- package/NOTICE +1 -0
- package/README.md +576 -0
- package/bin/strands.js +256 -0
- package/dist/src/cli/arguments.js +198 -0
- package/dist/src/cli/arguments.js.map +1 -0
- package/dist/src/cli/invocation.js +124 -0
- package/dist/src/cli/invocation.js.map +1 -0
- package/dist/src/cli/run.js +252 -0
- package/dist/src/cli/run.js.map +1 -0
- package/dist/src/console.js +235 -0
- package/dist/src/console.js.map +1 -0
- package/dist/src/logging.js +103 -0
- package/dist/src/logging.js.map +1 -0
- package/dist/src/main.js +7 -0
- package/dist/src/main.js.map +1 -0
- package/dist/src/tui/acp/projection.js +276 -0
- package/dist/src/tui/acp/projection.js.map +1 -0
- package/dist/src/tui/acp/server.js +263 -0
- package/dist/src/tui/acp/server.js.map +1 -0
- package/dist/src/tui/agent-configuration.js +335 -0
- package/dist/src/tui/agent-configuration.js.map +1 -0
- package/dist/src/tui/agent-setup.js +80 -0
- package/dist/src/tui/agent-setup.js.map +1 -0
- package/dist/src/tui/background/activity.js +273 -0
- package/dist/src/tui/background/activity.js.map +1 -0
- package/dist/src/tui/background/inbox.js +120 -0
- package/dist/src/tui/background/inbox.js.map +1 -0
- package/dist/src/tui/background/tasks.js +98 -0
- package/dist/src/tui/background/tasks.js.map +1 -0
- package/dist/src/tui/builtin-tools.js +65 -0
- package/dist/src/tui/builtin-tools.js.map +1 -0
- package/dist/src/tui/chat/commands.js +98 -0
- package/dist/src/tui/chat/commands.js.map +1 -0
- package/dist/src/tui/chat/controller-helpers.js +62 -0
- package/dist/src/tui/chat/controller-helpers.js.map +1 -0
- package/dist/src/tui/chat/controller.js +1913 -0
- package/dist/src/tui/chat/controller.js.map +1 -0
- package/dist/src/tui/chat/help.js +94 -0
- package/dist/src/tui/chat/help.js.map +1 -0
- package/dist/src/tui/chat/panels.js +418 -0
- package/dist/src/tui/chat/panels.js.map +1 -0
- package/dist/src/tui/chat/projector.js +443 -0
- package/dist/src/tui/chat/projector.js.map +1 -0
- package/dist/src/tui/chat/sdk-projector.js +194 -0
- package/dist/src/tui/chat/sdk-projector.js.map +1 -0
- package/dist/src/tui/chat/shell.js +263 -0
- package/dist/src/tui/chat/shell.js.map +1 -0
- package/dist/src/tui/chat/types.js +2 -0
- package/dist/src/tui/chat/types.js.map +1 -0
- package/dist/src/tui/config.js +497 -0
- package/dist/src/tui/config.js.map +1 -0
- package/dist/src/tui/configuration-instructions.js +14 -0
- package/dist/src/tui/configuration-instructions.js.map +1 -0
- package/dist/src/tui/mcp/config.js +370 -0
- package/dist/src/tui/mcp/config.js.map +1 -0
- package/dist/src/tui/mcp.js +98 -0
- package/dist/src/tui/mcp.js.map +1 -0
- package/dist/src/tui/memory-options.js +10 -0
- package/dist/src/tui/memory-options.js.map +1 -0
- package/dist/src/tui/messaging.js +193 -0
- package/dist/src/tui/messaging.js.map +1 -0
- package/dist/src/tui/model/context.js +13 -0
- package/dist/src/tui/model/context.js.map +1 -0
- package/dist/src/tui/model/display.js +59 -0
- package/dist/src/tui/model/display.js.map +1 -0
- package/dist/src/tui/model/runtime.js +365 -0
- package/dist/src/tui/model/runtime.js.map +1 -0
- package/dist/src/tui/model/selection.js +160 -0
- package/dist/src/tui/model/selection.js.map +1 -0
- package/dist/src/tui/package-version.js +47 -0
- package/dist/src/tui/package-version.js.map +1 -0
- package/dist/src/tui/permissions/file-change-preview.js +182 -0
- package/dist/src/tui/permissions/file-change-preview.js.map +1 -0
- package/dist/src/tui/permissions/policy.js +223 -0
- package/dist/src/tui/permissions/policy.js.map +1 -0
- package/dist/src/tui/permissions/settings.js +21 -0
- package/dist/src/tui/permissions/settings.js.map +1 -0
- package/dist/src/tui/project/acp.js +93 -0
- package/dist/src/tui/project/acp.js.map +1 -0
- package/dist/src/tui/project/archive.js +239 -0
- package/dist/src/tui/project/archive.js.map +1 -0
- package/dist/src/tui/project/configuration-secrets.js +107 -0
- package/dist/src/tui/project/configuration-secrets.js.map +1 -0
- package/dist/src/tui/project/configuration.js +201 -0
- package/dist/src/tui/project/configuration.js.map +1 -0
- package/dist/src/tui/project/export.js +560 -0
- package/dist/src/tui/project/export.js.map +1 -0
- package/dist/src/tui/project/import.js +75 -0
- package/dist/src/tui/project/import.js.map +1 -0
- package/dist/src/tui/project/module-loader.js +157 -0
- package/dist/src/tui/project/module-loader.js.map +1 -0
- package/dist/src/tui/project/packaging.js +53 -0
- package/dist/src/tui/project/packaging.js.map +1 -0
- package/dist/src/tui/project/portable-dependencies.js +34 -0
- package/dist/src/tui/project/portable-dependencies.js.map +1 -0
- package/dist/src/tui/project/portable-mcp.js +118 -0
- package/dist/src/tui/project/portable-mcp.js.map +1 -0
- package/dist/src/tui/project/python.js +414 -0
- package/dist/src/tui/project/python.js.map +1 -0
- package/dist/src/tui/project/run.js +118 -0
- package/dist/src/tui/project/run.js.map +1 -0
- package/dist/src/tui/project/source.js +307 -0
- package/dist/src/tui/project/source.js.map +1 -0
- package/dist/src/tui/project/typescript.js +135 -0
- package/dist/src/tui/project/typescript.js.map +1 -0
- package/dist/src/tui/project/worker.py +731 -0
- package/dist/src/tui/provider/aws-client.js +67 -0
- package/dist/src/tui/provider/aws-client.js.map +1 -0
- package/dist/src/tui/provider/aws-config.js +66 -0
- package/dist/src/tui/provider/aws-config.js.map +1 -0
- package/dist/src/tui/provider/bedrock-catalog.js +87 -0
- package/dist/src/tui/provider/bedrock-catalog.js.map +1 -0
- package/dist/src/tui/provider/discovery.js +323 -0
- package/dist/src/tui/provider/discovery.js.map +1 -0
- package/dist/src/tui/provider/environment.js +138 -0
- package/dist/src/tui/provider/environment.js.map +1 -0
- package/dist/src/tui/provider/packages.js +42 -0
- package/dist/src/tui/provider/packages.js.map +1 -0
- package/dist/src/tui/run.js +257 -0
- package/dist/src/tui/run.js.map +1 -0
- package/dist/src/tui/runtime.js +520 -0
- package/dist/src/tui/runtime.js.map +1 -0
- package/dist/src/tui/session/agent-definition.js +100 -0
- package/dist/src/tui/session/agent-definition.js.map +1 -0
- package/dist/src/tui/session/catalog.js +159 -0
- package/dist/src/tui/session/catalog.js.map +1 -0
- package/dist/src/tui/session/context.js +118 -0
- package/dist/src/tui/session/context.js.map +1 -0
- package/dist/src/tui/session/conversation-helpers.js +46 -0
- package/dist/src/tui/session/conversation-helpers.js.map +1 -0
- package/dist/src/tui/session/conversations.js +456 -0
- package/dist/src/tui/session/conversations.js.map +1 -0
- package/dist/src/tui/session/desktop-profile.js +80 -0
- package/dist/src/tui/session/desktop-profile.js.map +1 -0
- package/dist/src/tui/session/options.js +44 -0
- package/dist/src/tui/session/options.js.map +1 -0
- package/dist/src/tui/session/sessions.js +251 -0
- package/dist/src/tui/session/sessions.js.map +1 -0
- package/dist/src/tui/session/voice.js +353 -0
- package/dist/src/tui/session/voice.js.map +1 -0
- package/dist/src/tui/settings.js +362 -0
- package/dist/src/tui/settings.js.map +1 -0
- package/dist/src/tui/setup/questions.js +277 -0
- package/dist/src/tui/setup/questions.js.map +1 -0
- package/dist/src/tui/skills.js +135 -0
- package/dist/src/tui/skills.js.map +1 -0
- package/dist/src/tui/steering.js +67 -0
- package/dist/src/tui/steering.js.map +1 -0
- package/dist/src/tui/strands-backend.js +368 -0
- package/dist/src/tui/strands-backend.js.map +1 -0
- package/dist/src/tui/stream-presentation.js +138 -0
- package/dist/src/tui/stream-presentation.js.map +1 -0
- package/dist/src/tui/telemetry.js +46 -0
- package/dist/src/tui/telemetry.js.map +1 -0
- package/dist/src/tui/terminal/composer.js +237 -0
- package/dist/src/tui/terminal/composer.js.map +1 -0
- package/dist/src/tui/terminal/directory-picker.js +76 -0
- package/dist/src/tui/terminal/directory-picker.js.map +1 -0
- package/dist/src/tui/terminal/ink.js +94 -0
- package/dist/src/tui/terminal/ink.js.map +1 -0
- package/dist/src/tui/terminal/mouse-input.js +83 -0
- package/dist/src/tui/terminal/mouse-input.js.map +1 -0
- package/dist/src/tui/terminal/open-url.js +21 -0
- package/dist/src/tui/terminal/open-url.js.map +1 -0
- package/dist/src/tui/terminal/process-tree.js +132 -0
- package/dist/src/tui/terminal/process-tree.js.map +1 -0
- package/dist/src/tui/terminal/sanitize.js +71 -0
- package/dist/src/tui/terminal/sanitize.js.map +1 -0
- package/dist/src/tui/terminal/shell-output.js +43 -0
- package/dist/src/tui/terminal/shell-output.js.map +1 -0
- package/dist/src/tui/terminal/terminal.js +39 -0
- package/dist/src/tui/terminal/terminal.js.map +1 -0
- package/dist/src/tui/view/agents-panel.js +21 -0
- package/dist/src/tui/view/agents-panel.js.map +1 -0
- package/dist/src/tui/view/app.js +1068 -0
- package/dist/src/tui/view/app.js.map +1 -0
- package/dist/src/tui/view/chat-root.js +88 -0
- package/dist/src/tui/view/chat-root.js.map +1 -0
- package/dist/src/tui/view/chat-view.js +185 -0
- package/dist/src/tui/view/chat-view.js.map +1 -0
- package/dist/src/tui/view/command-palette.js +18 -0
- package/dist/src/tui/view/command-palette.js.map +1 -0
- package/dist/src/tui/view/custom-theme-editor.js +301 -0
- package/dist/src/tui/view/custom-theme-editor.js.map +1 -0
- package/dist/src/tui/view/export-panel.js +14 -0
- package/dist/src/tui/view/export-panel.js.map +1 -0
- package/dist/src/tui/view/fade-in.js +106 -0
- package/dist/src/tui/view/fade-in.js.map +1 -0
- package/dist/src/tui/view/frog-canvas.js +375 -0
- package/dist/src/tui/view/frog-canvas.js.map +1 -0
- package/dist/src/tui/view/frog-drawing.js +415 -0
- package/dist/src/tui/view/frog-drawing.js.map +1 -0
- package/dist/src/tui/view/frog-easter-egg.js +53 -0
- package/dist/src/tui/view/frog-easter-egg.js.map +1 -0
- package/dist/src/tui/view/frog-intro-renderer.js +634 -0
- package/dist/src/tui/view/frog-intro-renderer.js.map +1 -0
- package/dist/src/tui/view/help-footer.js +36 -0
- package/dist/src/tui/view/help-footer.js.map +1 -0
- package/dist/src/tui/view/interaction.js +349 -0
- package/dist/src/tui/view/interaction.js.map +1 -0
- package/dist/src/tui/view/intro.js +35 -0
- package/dist/src/tui/view/intro.js.map +1 -0
- package/dist/src/tui/view/markdown.js +99 -0
- package/dist/src/tui/view/markdown.js.map +1 -0
- package/dist/src/tui/view/media.js +70 -0
- package/dist/src/tui/view/media.js.map +1 -0
- package/dist/src/tui/view/model-panel.js +65 -0
- package/dist/src/tui/view/model-panel.js.map +1 -0
- package/dist/src/tui/view/panel-components.js +17 -0
- package/dist/src/tui/view/panel-components.js.map +1 -0
- package/dist/src/tui/view/panels.js +129 -0
- package/dist/src/tui/view/panels.js.map +1 -0
- package/dist/src/tui/view/presentation.js +382 -0
- package/dist/src/tui/view/presentation.js.map +1 -0
- package/dist/src/tui/view/prompt-editor.js +74 -0
- package/dist/src/tui/view/prompt-editor.js.map +1 -0
- package/dist/src/tui/view/provider-list.js +14 -0
- package/dist/src/tui/view/provider-list.js.map +1 -0
- package/dist/src/tui/view/sessions-panel.js +15 -0
- package/dist/src/tui/view/sessions-panel.js.map +1 -0
- package/dist/src/tui/view/settings-panel.js +146 -0
- package/dist/src/tui/view/settings-panel.js.map +1 -0
- package/dist/src/tui/view/setup-question.js +90 -0
- package/dist/src/tui/view/setup-question.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/brand.js +18 -0
- package/dist/src/tui/view/setup-wizard/brand.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/index.js +1557 -0
- package/dist/src/tui/view/setup-wizard/index.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/opening-menu.js +88 -0
- package/dist/src/tui/view/setup-wizard/opening-menu.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/path-completion.js +53 -0
- package/dist/src/tui/view/setup-wizard/path-completion.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/profile-fields.js +29 -0
- package/dist/src/tui/view/setup-wizard/profile-fields.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/progress.js +42 -0
- package/dist/src/tui/view/setup-wizard/progress.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/providers.js +344 -0
- package/dist/src/tui/view/setup-wizard/providers.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/settings-panel.js +74 -0
- package/dist/src/tui/view/setup-wizard/settings-panel.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/steps.js +544 -0
- package/dist/src/tui/view/setup-wizard/steps.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/types.js +2 -0
- package/dist/src/tui/view/setup-wizard/types.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/use-provider-discovery.js +145 -0
- package/dist/src/tui/view/setup-wizard/use-provider-discovery.js.map +1 -0
- package/dist/src/tui/view/startup-view.js +42 -0
- package/dist/src/tui/view/startup-view.js.map +1 -0
- package/dist/src/tui/view/text-input.js +33 -0
- package/dist/src/tui/view/text-input.js.map +1 -0
- package/dist/src/tui/view/theme-detection.js +45 -0
- package/dist/src/tui/view/theme-detection.js.map +1 -0
- package/dist/src/tui/view/theme.js +127 -0
- package/dist/src/tui/view/theme.js.map +1 -0
- package/dist/src/tui/view/transcript-layout.js +60 -0
- package/dist/src/tui/view/transcript-layout.js.map +1 -0
- package/dist/src/tui/view/transcript-turn.js +135 -0
- package/dist/src/tui/view/transcript-turn.js.map +1 -0
- package/dist/src/tui/view/transcript.js +138 -0
- package/dist/src/tui/view/transcript.js.map +1 -0
- package/dist/src/tui/view/use-party-frame.js +15 -0
- package/dist/src/tui/view/use-party-frame.js.map +1 -0
- package/dist/src/tui/view/use-spinner.js +14 -0
- package/dist/src/tui/view/use-spinner.js.map +1 -0
- package/dist/src/tui/voice/session.js +515 -0
- package/dist/src/tui/voice/session.js.map +1 -0
- package/dist/src/tui/workspace/sandbox.js +156 -0
- package/dist/src/tui/workspace/sandbox.js.map +1 -0
- package/dist/src/tui/workspace/trust.js +147 -0
- package/dist/src/tui/workspace/trust.js.map +1 -0
- package/dist/src/usage.js +187 -0
- package/dist/src/usage.js.map +1 -0
- package/package.json +97 -0
- package/src/tui/voice/sidecar.py +606 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { tool } from '@strands-agents/sdk';
|
|
2
|
+
const MAX_MESSAGE_CHARS = 20_000;
|
|
3
|
+
const PEER_MESSAGE_METADATA_KEY = 'strands.peerMessage';
|
|
4
|
+
export class AgentMessaging {
|
|
5
|
+
_endpoints = new Map();
|
|
6
|
+
_agentEndpoints = new WeakMap();
|
|
7
|
+
_listeners = new Set();
|
|
8
|
+
register(endpoint) {
|
|
9
|
+
if (this._endpoints.has(endpoint.id)) {
|
|
10
|
+
throw new Error(`Peer endpoint ${JSON.stringify(endpoint.id)} is already registered.`);
|
|
11
|
+
}
|
|
12
|
+
this._endpoints.set(endpoint.id, endpoint);
|
|
13
|
+
this._emit();
|
|
14
|
+
}
|
|
15
|
+
rename(id, name) {
|
|
16
|
+
const endpoint = this._endpoints.get(id);
|
|
17
|
+
if (endpoint) {
|
|
18
|
+
endpoint.name = name;
|
|
19
|
+
this._emit();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
unregister(id) {
|
|
23
|
+
if (this._endpoints.delete(id)) {
|
|
24
|
+
this._emit();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
list() {
|
|
28
|
+
return this._list();
|
|
29
|
+
}
|
|
30
|
+
subscribe(listener) {
|
|
31
|
+
this._listeners.add(listener);
|
|
32
|
+
listener();
|
|
33
|
+
return () => {
|
|
34
|
+
this._listeners.delete(listener);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
unbindAgent(agent) {
|
|
38
|
+
this._agentEndpoints.delete(agent);
|
|
39
|
+
}
|
|
40
|
+
createPlugin(endpointId) {
|
|
41
|
+
const messageAgent = tool({
|
|
42
|
+
name: 'message_agent',
|
|
43
|
+
description: 'List the other live agents or send one an asynchronous message.',
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: {
|
|
47
|
+
action: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
enum: ['list', 'send'],
|
|
50
|
+
description: 'List available agents or send a message.',
|
|
51
|
+
},
|
|
52
|
+
to: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'Target agent ID returned by the list action.',
|
|
55
|
+
},
|
|
56
|
+
message: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
description: 'Complete message to deliver to the target agent.',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
required: ['action'],
|
|
62
|
+
additionalProperties: false,
|
|
63
|
+
},
|
|
64
|
+
callback: (input, context) => {
|
|
65
|
+
if (!context)
|
|
66
|
+
throw new Error('Tool context is required for agent_message.');
|
|
67
|
+
const parsed = readAgentMessageInput(input);
|
|
68
|
+
if (parsed.action === 'list') {
|
|
69
|
+
return { agents: this._list(this._requireSenderId(context.agent)) };
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
status: 'queued',
|
|
73
|
+
recipient: this._send(context.agent, parsed.to, parsed.message),
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
name: 'strands:agent-messaging',
|
|
79
|
+
initAgent: (agent) => {
|
|
80
|
+
this._agentEndpoints.set(agent, endpointId);
|
|
81
|
+
},
|
|
82
|
+
getTools: () => [messageAgent],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
_list(senderId) {
|
|
86
|
+
const peers = [];
|
|
87
|
+
for (const endpoint of this._endpoints.values()) {
|
|
88
|
+
const status = endpoint.status();
|
|
89
|
+
if (endpoint.id !== senderId && status) {
|
|
90
|
+
peers.push({ id: endpoint.id, name: endpoint.name, status });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return peers.sort((left, right) => left.name.localeCompare(right.name) || left.id.localeCompare(right.id));
|
|
94
|
+
}
|
|
95
|
+
_emit() {
|
|
96
|
+
for (const listener of this._listeners) {
|
|
97
|
+
listener();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
_send(agent, to, body) {
|
|
101
|
+
const senderId = this._requireSenderId(agent);
|
|
102
|
+
if (senderId === to) {
|
|
103
|
+
throw new Error('An agent cannot send a peer message to itself.');
|
|
104
|
+
}
|
|
105
|
+
const sender = this._requireEndpoint(senderId);
|
|
106
|
+
const recipient = this._requireEndpoint(to);
|
|
107
|
+
if (!recipient.status()) {
|
|
108
|
+
throw new Error(`Agent ${JSON.stringify(to)} is not available for peer messages.`);
|
|
109
|
+
}
|
|
110
|
+
const cleanBody = body.trim();
|
|
111
|
+
if (!cleanBody) {
|
|
112
|
+
throw new Error('Peer message content must not be empty.');
|
|
113
|
+
}
|
|
114
|
+
if (cleanBody.length > MAX_MESSAGE_CHARS) {
|
|
115
|
+
throw new Error(`Peer messages are limited to ${MAX_MESSAGE_CHARS.toLocaleString()} characters.`);
|
|
116
|
+
}
|
|
117
|
+
const message = {
|
|
118
|
+
from: { id: sender.id, name: sender.name },
|
|
119
|
+
body: cleanBody,
|
|
120
|
+
};
|
|
121
|
+
if (!recipient.enqueue(message)) {
|
|
122
|
+
throw new Error(`Agent ${JSON.stringify(to)} could not accept the peer message.`);
|
|
123
|
+
}
|
|
124
|
+
return recipient.name;
|
|
125
|
+
}
|
|
126
|
+
_requireSenderId(agent) {
|
|
127
|
+
const id = this._agentEndpoints.get(agent);
|
|
128
|
+
if (!id || !this._endpoints.has(id)) {
|
|
129
|
+
throw new Error('This agent is not registered for peer messaging.');
|
|
130
|
+
}
|
|
131
|
+
return id;
|
|
132
|
+
}
|
|
133
|
+
_requireEndpoint(id) {
|
|
134
|
+
const endpoint = this._endpoints.get(id);
|
|
135
|
+
if (!endpoint) {
|
|
136
|
+
throw new Error(`Unknown peer agent ${JSON.stringify(id)}. Use the list action to discover live agents.`);
|
|
137
|
+
}
|
|
138
|
+
return endpoint;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export function peerMessagePrompt(message) {
|
|
142
|
+
return `Message from ${message.from.name} (${message.from.id}):\n\n${message.body}`;
|
|
143
|
+
}
|
|
144
|
+
export function peerMessageMetadata(message) {
|
|
145
|
+
return {
|
|
146
|
+
[PEER_MESSAGE_METADATA_KEY]: {
|
|
147
|
+
from: { id: message.from.id, name: message.from.name },
|
|
148
|
+
body: message.body,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
export function readPeerMessageMetadata(value) {
|
|
153
|
+
if (!isRecord(value)) {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
const candidate = value[PEER_MESSAGE_METADATA_KEY];
|
|
157
|
+
if (!isRecord(candidate) || !isParticipant(candidate.from) || typeof candidate.body !== 'string') {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
from: candidate.from,
|
|
162
|
+
body: candidate.body,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function readAgentMessageInput(input) {
|
|
166
|
+
if (!isRecord(input)) {
|
|
167
|
+
throw new Error('message_agent input must be an object.');
|
|
168
|
+
}
|
|
169
|
+
if (input.action === 'list') {
|
|
170
|
+
return { action: 'list' };
|
|
171
|
+
}
|
|
172
|
+
if (input.action !== 'send') {
|
|
173
|
+
throw new Error('message_agent action must be "list" or "send".');
|
|
174
|
+
}
|
|
175
|
+
if (typeof input.to !== 'string' || !input.to.trim()) {
|
|
176
|
+
throw new Error('message_agent requires a target agent ID for the send action.');
|
|
177
|
+
}
|
|
178
|
+
if (typeof input.message !== 'string') {
|
|
179
|
+
throw new Error('message_agent requires message content for the send action.');
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
action: 'send',
|
|
183
|
+
to: input.to.trim(),
|
|
184
|
+
message: input.message,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function isParticipant(value) {
|
|
188
|
+
return isRecord(value) && typeof value.id === 'string' && typeof value.name === 'string';
|
|
189
|
+
}
|
|
190
|
+
function isRecord(value) {
|
|
191
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=messaging.js.map
|
|
@@ -0,0 +1 @@
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IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function contextWindowLimit(model) {
|
|
2
|
+
const configured = model.getConfig().contextWindowLimit;
|
|
3
|
+
if (configured !== undefined && Number.isFinite(configured) && configured > 0) {
|
|
4
|
+
return configured;
|
|
5
|
+
}
|
|
6
|
+
const modelId = (model.modelId ?? '')
|
|
7
|
+
.split('/')
|
|
8
|
+
.at(-1)
|
|
9
|
+
?.replace(/^(?:global|apac|us-gov|us|eu|au|jp)\./, '');
|
|
10
|
+
// Bedrock's catalog omits this value: https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-openai-gpt-6-astra.html
|
|
11
|
+
return modelId === 'openai.gpt-6-astra' || modelId === 'gpt-6-astra' ? 1_050_000 : undefined;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/tui/model/context.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,KAAY;IAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC,kBAAkB,CAAA;IACvD,IAAI,UAAU,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QAC9E,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;SAClC,KAAK,CAAC,GAAG,CAAC;SACV,EAAE,CAAC,CAAC,CAAC,CAAC;QACP,EAAE,OAAO,CAAC,uCAAuC,EAAE,EAAE,CAAC,CAAA;IACxD,8HAA8H;IAC9H,OAAO,OAAO,KAAK,oBAAoB,IAAI,OAAO,KAAK,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAA;AAC9F,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const VERSIONED_MODELS = [
|
|
2
|
+
[/^gpt-(\d+o?)(?:[.-](\d+))?(?:-(.+))?$/, 'GPT-'],
|
|
3
|
+
[/^gemini-(\d+)(?:[.-](\d+))?(?:-(.+))?$/, 'Gemini '],
|
|
4
|
+
[/^llama-?(\d+)(?:[.-](\d+))?(?:-(.+))?$/, 'Llama '],
|
|
5
|
+
[/^grok-(\d+)(?:[.-](\d+))?(?:-(.+))?$/, 'Grok '],
|
|
6
|
+
];
|
|
7
|
+
export function modelDisplayName(model) {
|
|
8
|
+
const original = model.trim();
|
|
9
|
+
if (!original || /\s/u.test(original)) {
|
|
10
|
+
return original;
|
|
11
|
+
}
|
|
12
|
+
const identifier = original
|
|
13
|
+
.replace(/^bedrock\//, '')
|
|
14
|
+
.replace(/^(?:apac|au|eu|global|jp|us)\./, '')
|
|
15
|
+
.replace(/^(?:amazon|anthropic|google|meta|mistral|openai|xai)\./, '')
|
|
16
|
+
.replace(/-v\d+(?::\d+)?$/u, '')
|
|
17
|
+
.replace(/-\d{8}$/u, '')
|
|
18
|
+
.toLowerCase();
|
|
19
|
+
const claudeTierFirst = /^claude-(opus|sonnet|haiku|fable)-(\d+)(?:[.-](\d+))?/.exec(identifier);
|
|
20
|
+
if (claudeTierFirst) {
|
|
21
|
+
return `Claude ${titleWord(claudeTierFirst[1])} ${version(claudeTierFirst[2], claudeTierFirst[3])}`;
|
|
22
|
+
}
|
|
23
|
+
const claudeVersionFirst = /^claude-(\d+)(?:[.-](\d+))?-(opus|sonnet|haiku|fable)/.exec(identifier);
|
|
24
|
+
if (claudeVersionFirst) {
|
|
25
|
+
return `Claude ${titleWord(claudeVersionFirst[3])} ${version(claudeVersionFirst[1], claudeVersionFirst[2])}`;
|
|
26
|
+
}
|
|
27
|
+
for (const [pattern, prefix] of VERSIONED_MODELS) {
|
|
28
|
+
const match = pattern.exec(identifier);
|
|
29
|
+
if (match) {
|
|
30
|
+
return [`${prefix}${version(match[1], match[2])}`, displaySuffix(match[3])].filter(Boolean).join(' ');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const gptOss = /^gpt-oss-(.+)$/.exec(identifier);
|
|
34
|
+
if (gptOss) {
|
|
35
|
+
return `GPT OSS ${displaySuffix(gptOss[1])}`;
|
|
36
|
+
}
|
|
37
|
+
const nova = /^nova-(.+)$/.exec(identifier);
|
|
38
|
+
if (nova) {
|
|
39
|
+
return `Nova ${displaySuffix(nova[1])}`;
|
|
40
|
+
}
|
|
41
|
+
return original;
|
|
42
|
+
}
|
|
43
|
+
function version(major, minor) {
|
|
44
|
+
return minor ? `${major}.${minor}` : major;
|
|
45
|
+
}
|
|
46
|
+
function displaySuffix(value) {
|
|
47
|
+
if (!value) {
|
|
48
|
+
return '';
|
|
49
|
+
}
|
|
50
|
+
return value
|
|
51
|
+
.split(/[-_.]/u)
|
|
52
|
+
.filter(Boolean)
|
|
53
|
+
.map((word) => (/^\d+b$/u.test(word) ? word.toUpperCase() : titleWord(word)))
|
|
54
|
+
.join(' ');
|
|
55
|
+
}
|
|
56
|
+
function titleWord(value) {
|
|
57
|
+
return value[0].toUpperCase() + value.slice(1);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=display.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.js","sourceRoot":"","sources":["../../../../src/tui/model/display.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG;IACvB,CAAC,uCAAuC,EAAE,MAAM,CAAC;IACjD,CAAC,wCAAwC,EAAE,SAAS,CAAC;IACrD,CAAC,wCAAwC,EAAE,QAAQ,CAAC;IACpD,CAAC,sCAAsC,EAAE,OAAO,CAAC;CACzC,CAAA;AAEV,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,MAAM,QAAQ,GAAG,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AC,CAAA;AACjD,CAAC"}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { PROVIDER_IDS } from '../config.js';
|
|
2
|
+
import { defaultBedrockClient, listBedrockModels, } from '../provider/bedrock-catalog.js';
|
|
3
|
+
import { sanitizeTerminalText } from '../terminal/sanitize.js';
|
|
4
|
+
import { modelDisplayName } from './display.js';
|
|
5
|
+
import { contextWindowLimit } from './context.js';
|
|
6
|
+
import { effortOptions, profileEffort, resolveModelTarget, effortForModel, effortValue, validateEffortSelection, validateModelSelection, } from './selection.js';
|
|
7
|
+
function reasoningProvider(modelId) {
|
|
8
|
+
const resource = modelId.slice(modelId.lastIndexOf('/') + 1);
|
|
9
|
+
return resource.replace(/^(?:global|apac|us-gov|us|eu|au|jp)\./, '').split('.')[0] ?? resource;
|
|
10
|
+
}
|
|
11
|
+
export class AgentModelRuntime {
|
|
12
|
+
_agent;
|
|
13
|
+
_sessionId;
|
|
14
|
+
_sessionDirectory;
|
|
15
|
+
_target;
|
|
16
|
+
_thinking;
|
|
17
|
+
_appliedThinking;
|
|
18
|
+
_backgroundTasksWaitForCompletion;
|
|
19
|
+
_bedrockCatalogs = new Map();
|
|
20
|
+
_providerCatalogs = new Map();
|
|
21
|
+
_contextWindows = new Map();
|
|
22
|
+
_createBedrockClient;
|
|
23
|
+
_discoverProviderModels;
|
|
24
|
+
_discoverContextWindow;
|
|
25
|
+
_providers;
|
|
26
|
+
_providerEnvironment;
|
|
27
|
+
_restartAgent;
|
|
28
|
+
_newSessionId;
|
|
29
|
+
_onModelChange;
|
|
30
|
+
constructor(_agent, options = {}) {
|
|
31
|
+
this._agent = _agent;
|
|
32
|
+
this._sessionId = options.sessionId;
|
|
33
|
+
this._sessionDirectory = options.sessionDir ?? './.agent/sessions';
|
|
34
|
+
this._thinking = options.thinking === undefined ? 'auto' : options.thinking;
|
|
35
|
+
this._appliedThinking = this._thinking;
|
|
36
|
+
this._backgroundTasksWaitForCompletion = options.backgroundTasksWaitForCompletion;
|
|
37
|
+
this._createBedrockClient = options.createBedrockClient ?? defaultBedrockClient;
|
|
38
|
+
this._discoverProviderModels = options.discoverProviderModels;
|
|
39
|
+
this._discoverContextWindow = options.discoverContextWindow;
|
|
40
|
+
this._providers = options.providers ?? [];
|
|
41
|
+
this._providerEnvironment = options.providerEnvironment ?? {};
|
|
42
|
+
this._restartAgent = options.restartAgent;
|
|
43
|
+
this._newSessionId = options.newSessionId;
|
|
44
|
+
this._onModelChange = options.onModelChange;
|
|
45
|
+
if (options.initialModel) {
|
|
46
|
+
this._target = resolveModelTarget(options.initialModel);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
get provider() {
|
|
50
|
+
return this._target?.provider ?? modelProvider(this._agent.model);
|
|
51
|
+
}
|
|
52
|
+
get agent() {
|
|
53
|
+
return this._agent;
|
|
54
|
+
}
|
|
55
|
+
get sessionId() {
|
|
56
|
+
return this._sessionId;
|
|
57
|
+
}
|
|
58
|
+
get sessionDirectory() {
|
|
59
|
+
return this._sessionDirectory;
|
|
60
|
+
}
|
|
61
|
+
get current() {
|
|
62
|
+
return this._agent.model.modelId || this._agent.model.constructor.name;
|
|
63
|
+
}
|
|
64
|
+
get thinking() {
|
|
65
|
+
return this._thinking;
|
|
66
|
+
}
|
|
67
|
+
async contextWindow() {
|
|
68
|
+
const fallback = contextWindowLimit(this._agent.model);
|
|
69
|
+
if (!this._discoverContextWindow) {
|
|
70
|
+
return fallback;
|
|
71
|
+
}
|
|
72
|
+
const provider = this.provider;
|
|
73
|
+
const key = `${provider}/${this.current}`;
|
|
74
|
+
let pending = this._contextWindows.get(key);
|
|
75
|
+
if (!pending) {
|
|
76
|
+
pending = this._discoverContextWindow(provider, this.current, this._providerEnvironment).then((limit) => {
|
|
77
|
+
if (limit === undefined || provider === 'ollama') {
|
|
78
|
+
this._contextWindows.delete(key);
|
|
79
|
+
}
|
|
80
|
+
return limit;
|
|
81
|
+
});
|
|
82
|
+
this._contextWindows.set(key, pending);
|
|
83
|
+
}
|
|
84
|
+
return (await pending) ?? fallback;
|
|
85
|
+
}
|
|
86
|
+
get backgroundTasksWaitForCompletion() {
|
|
87
|
+
return this._backgroundTasksWaitForCompletion;
|
|
88
|
+
}
|
|
89
|
+
async *stream(...args) {
|
|
90
|
+
await this._applyPendingEffort();
|
|
91
|
+
return yield* this._agent.stream(...args);
|
|
92
|
+
}
|
|
93
|
+
cancel() {
|
|
94
|
+
this._agent.cancel();
|
|
95
|
+
}
|
|
96
|
+
async list() {
|
|
97
|
+
const configuredProviders = this._providers.length > 0
|
|
98
|
+
? this._providers
|
|
99
|
+
: PROVIDER_IDS.includes(this.provider)
|
|
100
|
+
? [this.provider]
|
|
101
|
+
: [];
|
|
102
|
+
const discovered = await Promise.all(configuredProviders.map((provider) => this._listProviderModels(provider).catch(() => [])));
|
|
103
|
+
const models = discovered.flat();
|
|
104
|
+
if (!models.some((model) => this._isActive(model.value ?? model.id))) {
|
|
105
|
+
models.push(currentModel(this.current, this._target?.specifier, this.provider));
|
|
106
|
+
}
|
|
107
|
+
return models
|
|
108
|
+
.map((model) => ({
|
|
109
|
+
...model,
|
|
110
|
+
...(model.active || this._isActive(model.value ?? model.id) ? { active: true } : {}),
|
|
111
|
+
}))
|
|
112
|
+
.sort((left, right) => {
|
|
113
|
+
if (left.active) {
|
|
114
|
+
return -1;
|
|
115
|
+
}
|
|
116
|
+
if (right.active) {
|
|
117
|
+
return 1;
|
|
118
|
+
}
|
|
119
|
+
return left.name.localeCompare(right.name) || left.id.localeCompare(right.id);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
listEfforts() {
|
|
123
|
+
return effortOptions(this._target?.specifier ?? this.current, this._thinking);
|
|
124
|
+
}
|
|
125
|
+
changeMode(modelId) {
|
|
126
|
+
const target = resolveModelTarget(modelId);
|
|
127
|
+
if (target.provider !== this.provider) {
|
|
128
|
+
return 'restart';
|
|
129
|
+
}
|
|
130
|
+
if (target.modelId === this.current) {
|
|
131
|
+
return 'live';
|
|
132
|
+
}
|
|
133
|
+
if (this.provider === 'bedrock' && bedrockLiveSwitchKey(target.modelId) === bedrockLiveSwitchKey(this.current)) {
|
|
134
|
+
return 'live';
|
|
135
|
+
}
|
|
136
|
+
return 'restart';
|
|
137
|
+
}
|
|
138
|
+
async switch(modelId) {
|
|
139
|
+
const target = resolveModelTarget(modelId);
|
|
140
|
+
if (this.changeMode(modelId) === 'restart') {
|
|
141
|
+
throw new Error(`Changing from ${this.current} to ${target.modelId} requires restarting the agent.`);
|
|
142
|
+
}
|
|
143
|
+
if (target.modelId !== this.current) {
|
|
144
|
+
await validateModelSelection(modelId, this._discoverProviderModels, this._providerEnvironment);
|
|
145
|
+
this._agent.model.updateConfig({ modelId: target.modelId });
|
|
146
|
+
}
|
|
147
|
+
this._target = target;
|
|
148
|
+
await this._notifyModelChange();
|
|
149
|
+
return this.current;
|
|
150
|
+
}
|
|
151
|
+
async restart(modelId) {
|
|
152
|
+
if (!this._restartAgent) {
|
|
153
|
+
throw new Error('This runtime cannot rebuild the agent.');
|
|
154
|
+
}
|
|
155
|
+
const target = resolveModelTarget(modelId);
|
|
156
|
+
if (!this._isActive(modelId)) {
|
|
157
|
+
await validateModelSelection(modelId, this._discoverProviderModels, this._providerEnvironment);
|
|
158
|
+
}
|
|
159
|
+
const thinking = effortForModel(target.specifier, this._thinking);
|
|
160
|
+
const currentModelId = this._target?.modelId ?? this.current;
|
|
161
|
+
this._agent = await this._restartAgent({
|
|
162
|
+
model: target.specifier,
|
|
163
|
+
thinking,
|
|
164
|
+
...(this._sessionId ? { sessionId: this._sessionId } : {}),
|
|
165
|
+
sessionDir: this._sessionDirectory,
|
|
166
|
+
preserveConversation: true,
|
|
167
|
+
preserveReasoning: reasoningProvider(currentModelId) === reasoningProvider(target.modelId),
|
|
168
|
+
preserveSnapshot: false,
|
|
169
|
+
backgroundTasksWaitForCompletion: this._backgroundTasksWaitForCompletion ?? false,
|
|
170
|
+
}, this._agent);
|
|
171
|
+
this._thinking = thinking;
|
|
172
|
+
this._appliedThinking = thinking;
|
|
173
|
+
this._target = target;
|
|
174
|
+
await this._notifyModelChange();
|
|
175
|
+
return this.current;
|
|
176
|
+
}
|
|
177
|
+
async setEffort(effort) {
|
|
178
|
+
validateEffortSelection(effort, this.listEfforts());
|
|
179
|
+
if (this._thinking === effort) {
|
|
180
|
+
return effort;
|
|
181
|
+
}
|
|
182
|
+
if (!this._restartAgent && effortValue(this._appliedThinking) !== effortValue(effort)) {
|
|
183
|
+
throw new Error('This runtime cannot rebuild the agent.');
|
|
184
|
+
}
|
|
185
|
+
this._thinking = effort;
|
|
186
|
+
await this._notifyModelChange();
|
|
187
|
+
return effort;
|
|
188
|
+
}
|
|
189
|
+
async clear() {
|
|
190
|
+
if (!this._restartAgent) {
|
|
191
|
+
throw new Error('This runtime cannot rebuild the agent.');
|
|
192
|
+
}
|
|
193
|
+
const target = resolveModelTarget(this._target?.specifier ?? this.current);
|
|
194
|
+
const sessionId = this._newSessionId?.();
|
|
195
|
+
this._agent = await this._restartAgent({
|
|
196
|
+
model: target.specifier,
|
|
197
|
+
thinking: this._thinking,
|
|
198
|
+
sessionId: sessionId ?? null,
|
|
199
|
+
sessionDir: this._sessionDirectory,
|
|
200
|
+
preserveConversation: false,
|
|
201
|
+
preserveSnapshot: false,
|
|
202
|
+
backgroundTasksWaitForCompletion: this._backgroundTasksWaitForCompletion ?? false,
|
|
203
|
+
}, this._agent);
|
|
204
|
+
this._appliedThinking = this._thinking;
|
|
205
|
+
this._sessionId = sessionId;
|
|
206
|
+
this._target = target;
|
|
207
|
+
}
|
|
208
|
+
async setBackgroundTasksWaitForCompletion(waitForCompletion) {
|
|
209
|
+
if (this._backgroundTasksWaitForCompletion === undefined) {
|
|
210
|
+
throw new Error('Background Tasks are disabled for this agent.');
|
|
211
|
+
}
|
|
212
|
+
if (!this._restartAgent) {
|
|
213
|
+
throw new Error('This runtime cannot rebuild the agent.');
|
|
214
|
+
}
|
|
215
|
+
if (this._backgroundTasksWaitForCompletion === waitForCompletion) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const target = resolveModelTarget(this._target?.specifier ?? this.current);
|
|
219
|
+
this._agent = await this._restartAgent({
|
|
220
|
+
model: target.specifier,
|
|
221
|
+
thinking: this._thinking,
|
|
222
|
+
...(this._sessionId ? { sessionId: this._sessionId } : {}),
|
|
223
|
+
sessionDir: this._sessionDirectory,
|
|
224
|
+
preserveConversation: false,
|
|
225
|
+
preserveSnapshot: true,
|
|
226
|
+
backgroundTasksWaitForCompletion: waitForCompletion,
|
|
227
|
+
}, this._agent);
|
|
228
|
+
this._appliedThinking = this._thinking;
|
|
229
|
+
this._backgroundTasksWaitForCompletion = waitForCompletion;
|
|
230
|
+
this._target = target;
|
|
231
|
+
}
|
|
232
|
+
forkConfiguration() {
|
|
233
|
+
const target = resolveModelTarget(this._target?.specifier ?? this.current);
|
|
234
|
+
return {
|
|
235
|
+
model: target.specifier,
|
|
236
|
+
thinking: this._thinking,
|
|
237
|
+
backgroundTasksWaitForCompletion: this._backgroundTasksWaitForCompletion ?? false,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
async _notifyModelChange() {
|
|
241
|
+
await this._onModelChange?.({
|
|
242
|
+
model: this._target?.specifier ?? this.current,
|
|
243
|
+
effort: profileEffort(this._thinking),
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
async _applyPendingEffort() {
|
|
247
|
+
if (effortValue(this._appliedThinking) === effortValue(this._thinking)) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (!this._restartAgent) {
|
|
251
|
+
throw new Error('This runtime cannot rebuild the agent.');
|
|
252
|
+
}
|
|
253
|
+
const target = resolveModelTarget(this._target?.specifier ?? this.current);
|
|
254
|
+
this._agent = await this._restartAgent({
|
|
255
|
+
model: target.specifier,
|
|
256
|
+
thinking: this._thinking,
|
|
257
|
+
...(this._sessionId ? { sessionId: this._sessionId } : {}),
|
|
258
|
+
sessionDir: this._sessionDirectory,
|
|
259
|
+
preserveConversation: true,
|
|
260
|
+
preserveSnapshot: false,
|
|
261
|
+
backgroundTasksWaitForCompletion: this._backgroundTasksWaitForCompletion ?? false,
|
|
262
|
+
}, this._agent);
|
|
263
|
+
this._appliedThinking = this._thinking;
|
|
264
|
+
this._target = target;
|
|
265
|
+
}
|
|
266
|
+
_listBedrockModels(region) {
|
|
267
|
+
const cached = this._bedrockCatalogs.get(region);
|
|
268
|
+
if (cached) {
|
|
269
|
+
return cached;
|
|
270
|
+
}
|
|
271
|
+
const pending = listBedrockModels(this._createBedrockClient(region)).then(({ models }) => models.map((model) => ({
|
|
272
|
+
...model,
|
|
273
|
+
value: `bedrock/${model.id}`,
|
|
274
|
+
catalog: 'bedrock',
|
|
275
|
+
})));
|
|
276
|
+
this._bedrockCatalogs.set(region, pending);
|
|
277
|
+
void pending.catch(() => {
|
|
278
|
+
if (this._bedrockCatalogs.get(region) === pending) {
|
|
279
|
+
this._bedrockCatalogs.delete(region);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
return pending;
|
|
283
|
+
}
|
|
284
|
+
_listProviderModels(provider) {
|
|
285
|
+
if (provider === 'bedrock') {
|
|
286
|
+
const config = this._agent.model.getConfig();
|
|
287
|
+
const configRegion = typeof config.region === 'string' ? config.region : undefined;
|
|
288
|
+
const region = configRegion ??
|
|
289
|
+
this._providerEnvironment.AWS_REGION?.value ??
|
|
290
|
+
this._providerEnvironment.AWS_DEFAULT_REGION?.value;
|
|
291
|
+
return this._listBedrockModels(region);
|
|
292
|
+
}
|
|
293
|
+
if (!this._discoverProviderModels) {
|
|
294
|
+
return Promise.resolve([]);
|
|
295
|
+
}
|
|
296
|
+
const cached = this._providerCatalogs.get(provider);
|
|
297
|
+
if (cached) {
|
|
298
|
+
return cached;
|
|
299
|
+
}
|
|
300
|
+
const pending = this._discoverProviderModels(provider, this._providerEnvironment).then((discovery) => {
|
|
301
|
+
if (!discovery.available) {
|
|
302
|
+
this._providerCatalogs.delete(provider);
|
|
303
|
+
return [];
|
|
304
|
+
}
|
|
305
|
+
return discovery.models.map((model) => ({
|
|
306
|
+
id: model.id,
|
|
307
|
+
name: model.name,
|
|
308
|
+
description: '',
|
|
309
|
+
value: `${provider}/${model.id}`,
|
|
310
|
+
catalog: provider,
|
|
311
|
+
}));
|
|
312
|
+
});
|
|
313
|
+
this._providerCatalogs.set(provider, pending);
|
|
314
|
+
void pending.catch(() => {
|
|
315
|
+
if (this._providerCatalogs.get(provider) === pending) {
|
|
316
|
+
this._providerCatalogs.delete(provider);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
return pending;
|
|
320
|
+
}
|
|
321
|
+
_isActive(specifier) {
|
|
322
|
+
const target = resolveModelTarget(specifier);
|
|
323
|
+
const provider = this.provider;
|
|
324
|
+
const modelId = this._target?.modelId ?? this.current;
|
|
325
|
+
return target.provider === provider && target.modelId === modelId;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function modelProvider(model) {
|
|
329
|
+
switch (model.constructor.name) {
|
|
330
|
+
case 'BedrockModel':
|
|
331
|
+
return 'bedrock';
|
|
332
|
+
case 'AnthropicModel':
|
|
333
|
+
return 'anthropic';
|
|
334
|
+
case 'OpenAIModel':
|
|
335
|
+
return 'openai';
|
|
336
|
+
case 'GoogleModel':
|
|
337
|
+
return 'google';
|
|
338
|
+
default:
|
|
339
|
+
return model.constructor.name;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function bedrockLiveSwitchKey(modelId) {
|
|
343
|
+
const resource = modelId.slice(modelId.lastIndexOf('/') + 1);
|
|
344
|
+
const withoutRegion = resource.replace(/^(?:global|apac|us-gov|us|eu|au|jp)\./, '');
|
|
345
|
+
const claude = withoutRegion.match(/^anthropic\.claude-(opus|sonnet|haiku|fable|mythos)-(\d+)(?:[-.](\d+))?/);
|
|
346
|
+
if (claude) {
|
|
347
|
+
return `anthropic.claude-${claude[1]}-${claude[2]}-${claude[3] ?? '0'}`;
|
|
348
|
+
}
|
|
349
|
+
return withoutRegion.replace(/(?:[-.]v?\d[\w.:-]*)$/, '');
|
|
350
|
+
}
|
|
351
|
+
function currentModel(id, value, provider) {
|
|
352
|
+
const catalog = PROVIDER_IDS.includes(provider)
|
|
353
|
+
? provider
|
|
354
|
+
: 'current';
|
|
355
|
+
const cleanId = sanitizeTerminalText(id);
|
|
356
|
+
return {
|
|
357
|
+
id: cleanId,
|
|
358
|
+
name: modelDisplayName(cleanId),
|
|
359
|
+
description: '',
|
|
360
|
+
catalog,
|
|
361
|
+
...(provider !== 'bedrock' ? { active: true } : {}),
|
|
362
|
+
...(value ? { value: sanitizeTerminalText(value) } : {}),
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
//# sourceMappingURL=runtime.js.map
|