strands-darwin 0.0.45 → 0.0.48
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 +5 -3
- package/README.zh-CN.md +5 -3
- package/dist/src/agent/permission-rules.d.ts +11 -7
- package/dist/src/agent/permission-rules.js +64 -7
- package/dist/src/agent/permission-rules.js.map +1 -1
- package/dist/src/agent/permission.js +21 -3
- package/dist/src/agent/permission.js.map +1 -1
- package/dist/src/agent/runtime.d.ts +41 -1
- package/dist/src/agent/runtime.js +80 -4
- package/dist/src/agent/runtime.js.map +1 -1
- package/dist/src/agent/session-label-write.d.ts +1 -0
- package/dist/src/agent/session-label-write.js +50 -0
- package/dist/src/agent/session-label-write.js.map +1 -0
- package/dist/src/agent/session-label.d.ts +19 -0
- package/dist/src/agent/session-label.js +112 -0
- package/dist/src/agent/session-label.js.map +1 -0
- package/dist/src/agents/child-result-text.d.ts +26 -0
- package/dist/src/agents/child-result-text.js +29 -0
- package/dist/src/agents/child-result-text.js.map +1 -0
- package/dist/src/agents/subagent-tool.js +6 -5
- package/dist/src/agents/subagent-tool.js.map +1 -1
- package/dist/src/agents/workflow-tool.d.ts +15 -2
- package/dist/src/agents/workflow-tool.js +24 -5
- package/dist/src/agents/workflow-tool.js.map +1 -1
- package/dist/src/cli-completion.d.ts +13 -0
- package/dist/src/cli-completion.js +161 -0
- package/dist/src/cli-completion.js.map +1 -0
- package/dist/src/cli-main.js +4 -0
- package/dist/src/cli-main.js.map +1 -1
- package/dist/src/cli-sessions.d.ts +30 -2
- package/dist/src/cli-sessions.js +53 -13
- package/dist/src/cli-sessions.js.map +1 -1
- package/dist/src/cli-usage.d.ts +1 -1
- package/dist/src/cli-usage.js +1 -0
- package/dist/src/cli-usage.js.map +1 -1
- package/dist/src/cli.js +5 -1
- package/dist/src/cli.js.map +1 -1
- package/dist/src/collaboration/local.d.ts +11 -0
- package/dist/src/collaboration/local.js +23 -4
- package/dist/src/collaboration/local.js.map +1 -1
- package/dist/src/commands/custom-commands.d.ts +8 -1
- package/dist/src/commands/custom-commands.js +23 -1
- package/dist/src/commands/custom-commands.js.map +1 -1
- package/dist/src/dev-repl.js +4 -1
- package/dist/src/dev-repl.js.map +1 -1
- package/dist/src/headless-protocol.d.ts +1 -1
- package/dist/src/headless-protocol.js +5 -0
- package/dist/src/headless-protocol.js.map +1 -1
- package/dist/src/headless-runner.js +5 -0
- package/dist/src/headless-runner.js.map +1 -1
- package/dist/src/headless.js +5 -0
- package/dist/src/headless.js.map +1 -1
- package/dist/src/mcp/prompts.d.ts +179 -0
- package/dist/src/mcp/prompts.js +349 -0
- package/dist/src/mcp/prompts.js.map +1 -0
- package/dist/src/mcp/registry.d.ts +8 -1
- package/dist/src/mcp/registry.js +3 -1
- package/dist/src/mcp/registry.js.map +1 -1
- package/dist/src/tools/file-editor-serial.d.ts +5 -3
- package/dist/src/tools/file-editor-serial.js +5 -3
- package/dist/src/tools/file-editor-serial.js.map +1 -1
- package/dist/src/tui/App.js +227 -21
- package/dist/src/tui/App.js.map +1 -1
- package/dist/src/tui/InputBox.d.ts +10 -2
- package/dist/src/tui/InputBox.js +7 -5
- package/dist/src/tui/InputBox.js.map +1 -1
- package/dist/src/tui/external-editor.d.ts +143 -0
- package/dist/src/tui/external-editor.js +482 -0
- package/dist/src/tui/external-editor.js.map +1 -0
- package/dist/src/tui/help-format.d.ts +1 -1
- package/dist/src/tui/help-format.js +3 -3
- package/dist/src/tui/help-format.js.map +1 -1
- package/dist/src/tui/mcp-format.d.ts +2 -0
- package/dist/src/tui/mcp-format.js +23 -1
- package/dist/src/tui/mcp-format.js.map +1 -1
- package/dist/src/tui/prompt-editor.d.ts +21 -7
- package/dist/src/tui/prompt-editor.js +33 -39
- package/dist/src/tui/prompt-editor.js.map +1 -1
- package/dist/src/tui/sessions-format.d.ts +10 -0
- package/dist/src/tui/sessions-format.js +46 -0
- package/dist/src/tui/sessions-format.js.map +1 -0
- package/dist/src/tui/status-format.d.ts +2 -0
- package/dist/src/tui/status-format.js +2 -1
- package/dist/src/tui/status-format.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP server prompts as user-invoked slash commands (SER-114).
|
|
3
|
+
*
|
|
4
|
+
* A prompt-capable server's `prompts/list` is read once, after `agent.initialize()`
|
|
5
|
+
* has connected the clients, and each prompt is offered as `/mcp__<server>__<prompt>`
|
|
6
|
+
* at the lowest slash precedence. Only an explicit user submission calls
|
|
7
|
+
* `prompts/get`; its result becomes one ordinary user prompt. Nothing here is a tool,
|
|
8
|
+
* nothing is automatic, the model never sees the catalogue, and the system prompt is
|
|
9
|
+
* untouched.
|
|
10
|
+
*
|
|
11
|
+
* Everything goes through the public SDK surface: `McpClient.connectionState`,
|
|
12
|
+
* `serverCapabilities` and `client` (the MCP SDK `Client`, whose `listPrompts` /
|
|
13
|
+
* `getPrompt` take `RequestOptions` with a timeout and an `AbortSignal`). Never
|
|
14
|
+
* `listTools()` (it connects lazily) and never `connect(true)`: a server that is not
|
|
15
|
+
* already `connected` gets no prompt request at all, which is also why a server held
|
|
16
|
+
* back by workspace trust (it has no client) and a failed or prompt-less one stay
|
|
17
|
+
* silent.
|
|
18
|
+
*/
|
|
19
|
+
import type { McpClient } from '@strands-agents/sdk';
|
|
20
|
+
/** The fixed prefix of every MCP prompt command name. */
|
|
21
|
+
export declare const MCP_PROMPT_COMMAND_PREFIX = "mcp__";
|
|
22
|
+
/** Prompts kept per server; the rest are reported, never offered. */
|
|
23
|
+
export declare const MAX_MCP_PROMPTS_PER_SERVER = 64;
|
|
24
|
+
/** `prompts/list` pages followed per server before discovery stops and says so. */
|
|
25
|
+
export declare const MAX_MCP_PROMPT_LIST_PAGES = 8;
|
|
26
|
+
/** One deadline per server for the whole (paginated) listing. */
|
|
27
|
+
export declare const MCP_PROMPT_LIST_TIMEOUT_MS = 5000;
|
|
28
|
+
/** One `prompts/get` call; the turn's cancel aborts it sooner. */
|
|
29
|
+
export declare const MCP_PROMPT_GET_TIMEOUT_MS = 15000;
|
|
30
|
+
/** Declared arguments per prompt; a prompt declaring more is skipped and reported. */
|
|
31
|
+
export declare const MAX_MCP_PROMPT_ARGUMENTS = 16;
|
|
32
|
+
/** Prompt and argument names, in code points; a longer one is skipped and reported. */
|
|
33
|
+
export declare const MAX_MCP_PROMPT_NAME_CHARS = 128;
|
|
34
|
+
/** Prompt and argument descriptions, in code points (display metadata, cut with `…`). */
|
|
35
|
+
export declare const MAX_MCP_PROMPT_DESCRIPTION_CHARS = 160;
|
|
36
|
+
/** One problem or server-error sentence, in code points. */
|
|
37
|
+
export declare const MAX_MCP_PROMPT_PROBLEM_CHARS = 240;
|
|
38
|
+
/** Problems kept per session (the last one becomes `… N more`), so every surface is bounded. */
|
|
39
|
+
export declare const MAX_MCP_PROMPT_PROBLEMS = 16;
|
|
40
|
+
/**
|
|
41
|
+
* The largest expanded prompt accepted, in code points: the trajectory's own
|
|
42
|
+
* per-field cap (`MAX_FIELD_CHARS`), reused rather than a second number. A larger
|
|
43
|
+
* result is refused, never truncated.
|
|
44
|
+
*/
|
|
45
|
+
export declare const MAX_MCP_PROMPT_RESULT_CHARS = 8000;
|
|
46
|
+
export interface McpPromptArgument {
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly description?: string;
|
|
49
|
+
readonly required: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** One listed prompt, its metadata bounded, exactly as the server named it. */
|
|
52
|
+
export interface McpListedPrompt {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly description?: string;
|
|
55
|
+
readonly arguments: readonly McpPromptArgument[];
|
|
56
|
+
}
|
|
57
|
+
/** One prompt-capable, connected server's single discovery result. */
|
|
58
|
+
export interface McpPromptListing {
|
|
59
|
+
readonly server: string;
|
|
60
|
+
readonly client: McpClient;
|
|
61
|
+
readonly prompts: readonly McpListedPrompt[];
|
|
62
|
+
/** Why the listing failed (error or timeout), bounded; no prompts are offered then. */
|
|
63
|
+
readonly failure?: string;
|
|
64
|
+
/** Bounded sentences: the failure, a truncation, or a skipped prompt's metadata. */
|
|
65
|
+
readonly problems: readonly string[];
|
|
66
|
+
/** Listed prompts dropped here: over the per-server cap, or metadata over a bound. */
|
|
67
|
+
readonly skipped: number;
|
|
68
|
+
}
|
|
69
|
+
/** Every listing taken this process; inherited by `/clear` and `/rewind` successors. */
|
|
70
|
+
export interface McpPromptDiscovery {
|
|
71
|
+
readonly listings: readonly McpPromptListing[];
|
|
72
|
+
}
|
|
73
|
+
/** One offered slash command. */
|
|
74
|
+
export interface McpPromptCommand {
|
|
75
|
+
/** The command name without its slash: `mcp__<server>__<prompt>`, sanitized. */
|
|
76
|
+
readonly name: string;
|
|
77
|
+
readonly server: string;
|
|
78
|
+
/** The prompt's own name, sent back verbatim in `prompts/get`. */
|
|
79
|
+
readonly prompt: string;
|
|
80
|
+
readonly description?: string;
|
|
81
|
+
readonly arguments: readonly McpPromptArgument[];
|
|
82
|
+
readonly client: McpClient;
|
|
83
|
+
}
|
|
84
|
+
/** What `/mcp` states about one prompt-capable server: names and counts only. */
|
|
85
|
+
export interface McpPromptServerSummary {
|
|
86
|
+
/** Offered command names, in listing order. */
|
|
87
|
+
readonly commands: readonly string[];
|
|
88
|
+
/** Listed prompts not offered (collision or metadata over a bound). */
|
|
89
|
+
readonly skipped: number;
|
|
90
|
+
/** Why the listing produced nothing, when it failed. */
|
|
91
|
+
readonly failure?: string;
|
|
92
|
+
}
|
|
93
|
+
export interface McpPromptCatalogue {
|
|
94
|
+
readonly commands: readonly McpPromptCommand[];
|
|
95
|
+
/** Keyed by server name; only servers that were asked (connected, prompt-capable). */
|
|
96
|
+
readonly servers: ReadonlyMap<string, McpPromptServerSummary>;
|
|
97
|
+
/** Every discovery and naming problem, bounded, in server order. */
|
|
98
|
+
readonly problems: readonly string[];
|
|
99
|
+
}
|
|
100
|
+
export declare const EMPTY_MCP_PROMPT_CATALOGUE: McpPromptCatalogue;
|
|
101
|
+
/** Bounds a sentence to one line of at most `max` code points, controls replaced. */
|
|
102
|
+
export declare function boundedMcpText(value: string, max?: number): string;
|
|
103
|
+
/** Every character outside `[A-Za-z0-9_-]` becomes `_` (per code point). */
|
|
104
|
+
export declare function sanitizeMcpPromptPart(value: string): string;
|
|
105
|
+
/** The canonical command name for one server's prompt, without the slash. */
|
|
106
|
+
export declare function mcpPromptCommandName(server: string, prompt: string): string;
|
|
107
|
+
/**
|
|
108
|
+
* Lists the prompts of every client that is already `connected` and declares the
|
|
109
|
+
* `prompts` capability, all servers concurrently, each under its own deadline, so
|
|
110
|
+
* the whole step is bounded by one timeout. Never throws: a failure is that
|
|
111
|
+
* server's bounded problem and its prompts are absent.
|
|
112
|
+
*/
|
|
113
|
+
export declare function discoverMcpPrompts(clients: readonly McpClient[], options?: {
|
|
114
|
+
timeoutMs?: number;
|
|
115
|
+
}): Promise<McpPromptDiscovery>;
|
|
116
|
+
/**
|
|
117
|
+
* Names the listed prompts against the names already owned. `claimed` maps a
|
|
118
|
+
* lower-cased command name to its owner (built-ins, aliases, skills, custom
|
|
119
|
+
* commands — everything with higher precedence); a prompt landing on any of them,
|
|
120
|
+
* or on an earlier prompt, is skipped and reported, never shadowing.
|
|
121
|
+
*/
|
|
122
|
+
export declare function buildMcpPromptCatalogue(discovery: McpPromptDiscovery, claimed: ReadonlyMap<string, string>): McpPromptCatalogue;
|
|
123
|
+
/** An explicit submission naming an offered prompt, with its whitespace-split words. */
|
|
124
|
+
export interface McpPromptInvocation {
|
|
125
|
+
readonly command: McpPromptCommand;
|
|
126
|
+
readonly words: readonly string[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Matches `/mcp__s__p [args]` against the catalogue, case-insensitively like custom
|
|
130
|
+
* commands. Anything else — including an unknown `/mcp__…` name — is `null` and
|
|
131
|
+
* stays ordinary input. Pure: no server is contacted.
|
|
132
|
+
*/
|
|
133
|
+
export declare function matchMcpPromptCommand(catalogue: McpPromptCatalogue, input: string): McpPromptInvocation | null;
|
|
134
|
+
/** `<required> [optional]` in declaration order — the completion hint and the usage line. */
|
|
135
|
+
export declare function mcpPromptArgumentHint(command: McpPromptCommand): string;
|
|
136
|
+
/** The local usage notice: the command, its arguments, and what each one is. */
|
|
137
|
+
export declare function mcpPromptUsage(command: McpPromptCommand, problem: string): string;
|
|
138
|
+
/** A failure the drivers state as one bounded notice, with the draft returned unsent. */
|
|
139
|
+
export declare class McpPromptError extends Error {
|
|
140
|
+
constructor(message: string);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Maps the words positionally onto the declared arguments. More words than
|
|
144
|
+
* arguments, or a required argument with no word, is a usage error raised before
|
|
145
|
+
* any server call.
|
|
146
|
+
*/
|
|
147
|
+
export declare function mapMcpPromptArguments(invocation: McpPromptInvocation): Record<string, string>;
|
|
148
|
+
/** What a `prompts/get` result left out of the prompt, counted for one visible notice. */
|
|
149
|
+
export interface McpPromptOmissions {
|
|
150
|
+
readonly assistantMessages: number;
|
|
151
|
+
readonly nonTextBlocks: number;
|
|
152
|
+
}
|
|
153
|
+
export interface ExpandedMcpPrompt {
|
|
154
|
+
readonly command: McpPromptCommand;
|
|
155
|
+
readonly message: string;
|
|
156
|
+
readonly omitted: McpPromptOmissions;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Projects a `prompts/get` result onto one user prompt: user-role text blocks joined
|
|
160
|
+
* in order by a blank line. Assistant-role messages and non-text user content are
|
|
161
|
+
* not sent and are counted. No user text, or more than
|
|
162
|
+
* {@link MAX_MCP_PROMPT_RESULT_CHARS} code points, is refused — never truncated.
|
|
163
|
+
*/
|
|
164
|
+
export declare function composeMcpPromptResult(command: McpPromptCommand, result: {
|
|
165
|
+
messages?: unknown;
|
|
166
|
+
}): ExpandedMcpPrompt;
|
|
167
|
+
/** The one notice every driver prints for a loaded prompt, omissions counted in it. */
|
|
168
|
+
export declare function mcpPromptLoadedNotice(expanded: ExpandedMcpPrompt): string;
|
|
169
|
+
/** Whether the notice has to warn: something the server returned was not sent. */
|
|
170
|
+
export declare function mcpPromptOmittedAnything(omitted: McpPromptOmissions): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* The explicit invocation: argument mapping (usage errors make no request), then one
|
|
173
|
+
* `prompts/get` with a timeout and the caller's cancel signal, then the projection.
|
|
174
|
+
* Every failure is a bounded {@link McpPromptError}.
|
|
175
|
+
*/
|
|
176
|
+
export declare function expandMcpPrompt(invocation: McpPromptInvocation, options?: {
|
|
177
|
+
signal?: AbortSignal;
|
|
178
|
+
timeoutMs?: number;
|
|
179
|
+
}): Promise<ExpandedMcpPrompt>;
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { MAX_FIELD_CHARS } from '../trajectory/record.js';
|
|
2
|
+
/** The fixed prefix of every MCP prompt command name. */
|
|
3
|
+
export const MCP_PROMPT_COMMAND_PREFIX = 'mcp__';
|
|
4
|
+
/** Prompts kept per server; the rest are reported, never offered. */
|
|
5
|
+
export const MAX_MCP_PROMPTS_PER_SERVER = 64;
|
|
6
|
+
/** `prompts/list` pages followed per server before discovery stops and says so. */
|
|
7
|
+
export const MAX_MCP_PROMPT_LIST_PAGES = 8;
|
|
8
|
+
/** One deadline per server for the whole (paginated) listing. */
|
|
9
|
+
export const MCP_PROMPT_LIST_TIMEOUT_MS = 5_000;
|
|
10
|
+
/** One `prompts/get` call; the turn's cancel aborts it sooner. */
|
|
11
|
+
export const MCP_PROMPT_GET_TIMEOUT_MS = 15_000;
|
|
12
|
+
/** Declared arguments per prompt; a prompt declaring more is skipped and reported. */
|
|
13
|
+
export const MAX_MCP_PROMPT_ARGUMENTS = 16;
|
|
14
|
+
/** Prompt and argument names, in code points; a longer one is skipped and reported. */
|
|
15
|
+
export const MAX_MCP_PROMPT_NAME_CHARS = 128;
|
|
16
|
+
/** Prompt and argument descriptions, in code points (display metadata, cut with `…`). */
|
|
17
|
+
export const MAX_MCP_PROMPT_DESCRIPTION_CHARS = 160;
|
|
18
|
+
/** One problem or server-error sentence, in code points. */
|
|
19
|
+
export const MAX_MCP_PROMPT_PROBLEM_CHARS = 240;
|
|
20
|
+
/** Problems kept per session (the last one becomes `… N more`), so every surface is bounded. */
|
|
21
|
+
export const MAX_MCP_PROMPT_PROBLEMS = 16;
|
|
22
|
+
/**
|
|
23
|
+
* The largest expanded prompt accepted, in code points: the trajectory's own
|
|
24
|
+
* per-field cap (`MAX_FIELD_CHARS`), reused rather than a second number. A larger
|
|
25
|
+
* result is refused, never truncated.
|
|
26
|
+
*/
|
|
27
|
+
export const MAX_MCP_PROMPT_RESULT_CHARS = MAX_FIELD_CHARS;
|
|
28
|
+
export const EMPTY_MCP_PROMPT_CATALOGUE = { commands: [], servers: new Map(), problems: [] };
|
|
29
|
+
/** Bounds a sentence to one line of at most `max` code points, controls replaced. */
|
|
30
|
+
export function boundedMcpText(value, max = MAX_MCP_PROMPT_PROBLEM_CHARS) {
|
|
31
|
+
// eslint-disable-next-line no-control-regex
|
|
32
|
+
const flat = value.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]+/gu, ' ').replace(/\s+/gu, ' ').trim();
|
|
33
|
+
const points = [...flat];
|
|
34
|
+
return points.length <= max ? flat : `${points.slice(0, max - 1).join('')}…`;
|
|
35
|
+
}
|
|
36
|
+
/** Every character outside `[A-Za-z0-9_-]` becomes `_` (per code point). */
|
|
37
|
+
export function sanitizeMcpPromptPart(value) {
|
|
38
|
+
return Array.from(value, (character) => (/^[A-Za-z0-9_-]$/u.test(character) ? character : '_')).join('');
|
|
39
|
+
}
|
|
40
|
+
/** The canonical command name for one server's prompt, without the slash. */
|
|
41
|
+
export function mcpPromptCommandName(server, prompt) {
|
|
42
|
+
return `${MCP_PROMPT_COMMAND_PREFIX}${sanitizeMcpPromptPart(server)}__${sanitizeMcpPromptPart(prompt)}`;
|
|
43
|
+
}
|
|
44
|
+
function errorText(error) {
|
|
45
|
+
return error instanceof Error ? error.message : String(error);
|
|
46
|
+
}
|
|
47
|
+
function codePoints(value) {
|
|
48
|
+
return [...value].length;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Validates and bounds one listed prompt's metadata. Names are identifiers the
|
|
52
|
+
* server needs back verbatim, so a name over its bound is a skip, never a cut.
|
|
53
|
+
*/
|
|
54
|
+
function boundPrompt(raw) {
|
|
55
|
+
const record = typeof raw === 'object' && raw !== null ? raw : {};
|
|
56
|
+
const name = record['name'];
|
|
57
|
+
if (typeof name !== 'string' || name === '')
|
|
58
|
+
return 'a listed prompt has no name';
|
|
59
|
+
const label = boundedMcpText(name, 48);
|
|
60
|
+
if (codePoints(name) > MAX_MCP_PROMPT_NAME_CHARS) {
|
|
61
|
+
return `prompt "${label}" skipped: name longer than ${MAX_MCP_PROMPT_NAME_CHARS} characters`;
|
|
62
|
+
}
|
|
63
|
+
const declared = Array.isArray(record['arguments']) ? record['arguments'] : [];
|
|
64
|
+
if (declared.length > MAX_MCP_PROMPT_ARGUMENTS) {
|
|
65
|
+
return `prompt "${label}" skipped: declares ${declared.length} arguments (at most ${MAX_MCP_PROMPT_ARGUMENTS})`;
|
|
66
|
+
}
|
|
67
|
+
const args = [];
|
|
68
|
+
for (const entry of declared) {
|
|
69
|
+
const argument = typeof entry === 'object' && entry !== null ? entry : {};
|
|
70
|
+
const argName = argument['name'];
|
|
71
|
+
if (typeof argName !== 'string' || argName === '' || codePoints(argName) > MAX_MCP_PROMPT_NAME_CHARS) {
|
|
72
|
+
return `prompt "${label}" skipped: an argument name is missing or longer than ${MAX_MCP_PROMPT_NAME_CHARS} characters`;
|
|
73
|
+
}
|
|
74
|
+
const argDescription = argument['description'];
|
|
75
|
+
args.push({
|
|
76
|
+
name: argName,
|
|
77
|
+
required: argument['required'] === true,
|
|
78
|
+
...(typeof argDescription === 'string' && argDescription.trim() !== ''
|
|
79
|
+
? { description: boundedMcpText(argDescription, MAX_MCP_PROMPT_DESCRIPTION_CHARS) }
|
|
80
|
+
: {}),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const description = typeof record['description'] === 'string' ? record['description'] : typeof record['title'] === 'string' ? record['title'] : undefined;
|
|
84
|
+
return {
|
|
85
|
+
name,
|
|
86
|
+
arguments: args,
|
|
87
|
+
...(description !== undefined && description.trim() !== ''
|
|
88
|
+
? { description: boundedMcpText(description, MAX_MCP_PROMPT_DESCRIPTION_CHARS) }
|
|
89
|
+
: {}),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** One server's bounded, paginated `prompts/list` under a single deadline. */
|
|
93
|
+
async function listServerPrompts(client, timeoutMs) {
|
|
94
|
+
const server = client.clientName;
|
|
95
|
+
// The MCP SDK's `Protocol.request` adds an `abort` listener to the request signal and
|
|
96
|
+
// never removes it, so a signal that aborts after the answer sends a stray
|
|
97
|
+
// `notifications/cancelled` for a completed request. The deadline is therefore a
|
|
98
|
+
// controller whose timer is cleared once the listing settles: it can only ever abort
|
|
99
|
+
// a request that is still in flight.
|
|
100
|
+
const deadline = new AbortController();
|
|
101
|
+
const timer = setTimeout(() => deadline.abort(new Error(`prompts/list deadline of ${timeoutMs}ms passed`)), timeoutMs);
|
|
102
|
+
const raw = [];
|
|
103
|
+
const problems = [];
|
|
104
|
+
let cursor;
|
|
105
|
+
let pages = 0;
|
|
106
|
+
try {
|
|
107
|
+
let more = true;
|
|
108
|
+
while (more) {
|
|
109
|
+
const page = await client.client.listPrompts(cursor === undefined ? undefined : { cursor }, { signal: deadline.signal, timeout: timeoutMs });
|
|
110
|
+
pages += 1;
|
|
111
|
+
raw.push(...page.prompts);
|
|
112
|
+
cursor = typeof page.nextCursor === 'string' && page.nextCursor !== '' ? page.nextCursor : undefined;
|
|
113
|
+
more = cursor !== undefined && raw.length <= MAX_MCP_PROMPTS_PER_SERVER && pages < MAX_MCP_PROMPT_LIST_PAGES;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
const timedOut = deadline.signal.aborted || (typeof error === 'object' && error !== null && error.code === -32001);
|
|
118
|
+
const reason = timedOut
|
|
119
|
+
? `prompts/list timed out after ${timeoutMs / 1000}s`
|
|
120
|
+
: `prompts/list failed — ${errorText(error)}`;
|
|
121
|
+
const failure = boundedMcpText(reason);
|
|
122
|
+
return { server, client, prompts: [], failure, skipped: 0, problems: [boundedMcpText(`mcp server "${server}": ${failure}; its prompts are not offered`)] };
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
clearTimeout(timer);
|
|
126
|
+
}
|
|
127
|
+
if (raw.length > MAX_MCP_PROMPTS_PER_SERVER) {
|
|
128
|
+
problems.push(`mcp server "${server}": lists more than ${MAX_MCP_PROMPTS_PER_SERVER} prompts; only the first ${MAX_MCP_PROMPTS_PER_SERVER} are offered`);
|
|
129
|
+
}
|
|
130
|
+
else if (cursor !== undefined) {
|
|
131
|
+
problems.push(`mcp server "${server}": prompts/list stopped after ${MAX_MCP_PROMPT_LIST_PAGES} pages; later prompts are not offered`);
|
|
132
|
+
}
|
|
133
|
+
const prompts = [];
|
|
134
|
+
let skipped = Math.max(0, raw.length - MAX_MCP_PROMPTS_PER_SERVER);
|
|
135
|
+
for (const entry of raw.slice(0, MAX_MCP_PROMPTS_PER_SERVER)) {
|
|
136
|
+
const bounded = boundPrompt(entry);
|
|
137
|
+
if (typeof bounded === 'string') {
|
|
138
|
+
skipped += 1;
|
|
139
|
+
problems.push(boundedMcpText(`mcp server "${server}": ${bounded}`));
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
prompts.push(bounded);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return { server, client, prompts, problems, skipped };
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Lists the prompts of every client that is already `connected` and declares the
|
|
149
|
+
* `prompts` capability, all servers concurrently, each under its own deadline, so
|
|
150
|
+
* the whole step is bounded by one timeout. Never throws: a failure is that
|
|
151
|
+
* server's bounded problem and its prompts are absent.
|
|
152
|
+
*/
|
|
153
|
+
export async function discoverMcpPrompts(clients, options = {}) {
|
|
154
|
+
const timeoutMs = options.timeoutMs ?? MCP_PROMPT_LIST_TIMEOUT_MS;
|
|
155
|
+
const eligible = clients.filter((client) => client.connectionState === 'connected' && client.serverCapabilities?.prompts !== undefined);
|
|
156
|
+
const listings = await Promise.all(eligible.map((client) => listServerPrompts(client, timeoutMs)));
|
|
157
|
+
return { listings };
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Names the listed prompts against the names already owned. `claimed` maps a
|
|
161
|
+
* lower-cased command name to its owner (built-ins, aliases, skills, custom
|
|
162
|
+
* commands — everything with higher precedence); a prompt landing on any of them,
|
|
163
|
+
* or on an earlier prompt, is skipped and reported, never shadowing.
|
|
164
|
+
*/
|
|
165
|
+
export function buildMcpPromptCatalogue(discovery, claimed) {
|
|
166
|
+
const owners = new Map(claimed);
|
|
167
|
+
const commands = [];
|
|
168
|
+
const servers = new Map();
|
|
169
|
+
const problems = [];
|
|
170
|
+
for (const listing of discovery.listings) {
|
|
171
|
+
problems.push(...listing.problems);
|
|
172
|
+
const offered = [];
|
|
173
|
+
let skipped = listing.skipped;
|
|
174
|
+
for (const prompt of listing.prompts) {
|
|
175
|
+
const name = mcpPromptCommandName(listing.server, prompt.name);
|
|
176
|
+
const owner = owners.get(name.toLowerCase());
|
|
177
|
+
if (owner !== undefined) {
|
|
178
|
+
skipped += 1;
|
|
179
|
+
problems.push(boundedMcpText(`mcp prompt "${prompt.name}" from "${listing.server}" skipped: /${name} conflicts with ${owner}`));
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
owners.set(name.toLowerCase(), `mcp prompt "${prompt.name}" from "${listing.server}"`);
|
|
183
|
+
offered.push(name);
|
|
184
|
+
commands.push({
|
|
185
|
+
name,
|
|
186
|
+
server: listing.server,
|
|
187
|
+
prompt: prompt.name,
|
|
188
|
+
arguments: prompt.arguments,
|
|
189
|
+
client: listing.client,
|
|
190
|
+
...(prompt.description === undefined ? {} : { description: prompt.description }),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
servers.set(listing.server, {
|
|
194
|
+
commands: offered,
|
|
195
|
+
skipped,
|
|
196
|
+
...(listing.failure === undefined ? {} : { failure: listing.failure }),
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
if (problems.length > MAX_MCP_PROMPT_PROBLEMS) {
|
|
200
|
+
const hidden = problems.length - (MAX_MCP_PROMPT_PROBLEMS - 1);
|
|
201
|
+
problems.splice(MAX_MCP_PROMPT_PROBLEMS - 1, problems.length, `… ${hidden} more MCP prompt problems not listed`);
|
|
202
|
+
}
|
|
203
|
+
return { commands, servers, problems };
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Matches `/mcp__s__p [args]` against the catalogue, case-insensitively like custom
|
|
207
|
+
* commands. Anything else — including an unknown `/mcp__…` name — is `null` and
|
|
208
|
+
* stays ordinary input. Pure: no server is contacted.
|
|
209
|
+
*/
|
|
210
|
+
export function matchMcpPromptCommand(catalogue, input) {
|
|
211
|
+
const trimmed = input.trim();
|
|
212
|
+
if (!trimmed.toLowerCase().startsWith(`/${MCP_PROMPT_COMMAND_PREFIX}`))
|
|
213
|
+
return null;
|
|
214
|
+
const withoutSlash = trimmed.slice(1);
|
|
215
|
+
const separator = withoutSlash.search(/\s/u);
|
|
216
|
+
const name = (separator === -1 ? withoutSlash : withoutSlash.slice(0, separator)).toLowerCase();
|
|
217
|
+
const command = catalogue.commands.find((candidate) => candidate.name.toLowerCase() === name);
|
|
218
|
+
if (command === undefined)
|
|
219
|
+
return null;
|
|
220
|
+
const rest = separator === -1 ? '' : withoutSlash.slice(separator).trim();
|
|
221
|
+
return { command, words: rest === '' ? [] : rest.split(/\s+/u) };
|
|
222
|
+
}
|
|
223
|
+
/** `<required> [optional]` in declaration order — the completion hint and the usage line. */
|
|
224
|
+
export function mcpPromptArgumentHint(command) {
|
|
225
|
+
return command.arguments.map((argument) => (argument.required ? `<${argument.name}>` : `[${argument.name}]`)).join(' ');
|
|
226
|
+
}
|
|
227
|
+
/** The local usage notice: the command, its arguments, and what each one is. */
|
|
228
|
+
export function mcpPromptUsage(command, problem) {
|
|
229
|
+
const hint = mcpPromptArgumentHint(command);
|
|
230
|
+
const described = command.arguments.map((argument) => `${argument.name}${argument.required ? ' (required)' : ''}${argument.description === undefined ? '' : `: ${argument.description}`}`);
|
|
231
|
+
const detail = described.length === 0 ? 'it takes no arguments' : `arguments — ${described.join('; ')}`;
|
|
232
|
+
return boundedMcpText(`${problem}; usage: /${command.name}${hint === '' ? '' : ` ${hint}`} — ${detail} (words are whitespace-split, one per argument)`, 600);
|
|
233
|
+
}
|
|
234
|
+
/** A failure the drivers state as one bounded notice, with the draft returned unsent. */
|
|
235
|
+
export class McpPromptError extends Error {
|
|
236
|
+
constructor(message) {
|
|
237
|
+
super(boundedMcpText(message, 600));
|
|
238
|
+
this.name = 'McpPromptError';
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Maps the words positionally onto the declared arguments. More words than
|
|
243
|
+
* arguments, or a required argument with no word, is a usage error raised before
|
|
244
|
+
* any server call.
|
|
245
|
+
*/
|
|
246
|
+
export function mapMcpPromptArguments(invocation) {
|
|
247
|
+
const { command, words } = invocation;
|
|
248
|
+
if (words.length > command.arguments.length) {
|
|
249
|
+
throw new McpPromptError(mcpPromptUsage(command, `/${command.name} got ${words.length} word${words.length === 1 ? '' : 's'} for ${command.arguments.length} argument${command.arguments.length === 1 ? '' : 's'}`));
|
|
250
|
+
}
|
|
251
|
+
const missing = command.arguments.slice(words.length).filter((argument) => argument.required).map((argument) => argument.name);
|
|
252
|
+
if (missing.length > 0) {
|
|
253
|
+
throw new McpPromptError(mcpPromptUsage(command, `/${command.name} is missing required argument${missing.length === 1 ? '' : 's'} ${missing.join(', ')}`));
|
|
254
|
+
}
|
|
255
|
+
return Object.fromEntries(words.map((word, index) => [command.arguments[index].name, word]));
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Projects a `prompts/get` result onto one user prompt: user-role text blocks joined
|
|
259
|
+
* in order by a blank line. Assistant-role messages and non-text user content are
|
|
260
|
+
* not sent and are counted. No user text, or more than
|
|
261
|
+
* {@link MAX_MCP_PROMPT_RESULT_CHARS} code points, is refused — never truncated.
|
|
262
|
+
*/
|
|
263
|
+
export function composeMcpPromptResult(command, result) {
|
|
264
|
+
const messages = Array.isArray(result.messages) ? result.messages : [];
|
|
265
|
+
const texts = [];
|
|
266
|
+
let assistantMessages = 0;
|
|
267
|
+
let nonTextBlocks = 0;
|
|
268
|
+
for (const entry of messages) {
|
|
269
|
+
const message = typeof entry === 'object' && entry !== null ? entry : {};
|
|
270
|
+
if (message['role'] !== 'user') {
|
|
271
|
+
assistantMessages += 1;
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const content = message['content'];
|
|
275
|
+
const blocks = Array.isArray(content) ? content : [content];
|
|
276
|
+
for (const block of blocks) {
|
|
277
|
+
const record = typeof block === 'object' && block !== null ? block : {};
|
|
278
|
+
if (record['type'] === 'text' && typeof record['text'] === 'string')
|
|
279
|
+
texts.push(record['text']);
|
|
280
|
+
else
|
|
281
|
+
nonTextBlocks += 1;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const omitted = { assistantMessages, nonTextBlocks };
|
|
285
|
+
const message = texts.join('\n\n');
|
|
286
|
+
if (message.trim() === '') {
|
|
287
|
+
throw new McpPromptError(`/${command.name}: the server returned no user text to send${omissionClause(omitted)}; prompt not sent`);
|
|
288
|
+
}
|
|
289
|
+
const size = codePoints(message);
|
|
290
|
+
if (size > MAX_MCP_PROMPT_RESULT_CHARS) {
|
|
291
|
+
throw new McpPromptError(`/${command.name}: the server's prompt is ${size} characters, over the ${MAX_MCP_PROMPT_RESULT_CHARS}-character cap darwin records for a prompt; refused, not truncated`);
|
|
292
|
+
}
|
|
293
|
+
return { command, message, omitted };
|
|
294
|
+
}
|
|
295
|
+
function omissionClause(omitted) {
|
|
296
|
+
const parts = [
|
|
297
|
+
omitted.assistantMessages > 0 ? `${omitted.assistantMessages} assistant message${omitted.assistantMessages === 1 ? '' : 's'}` : '',
|
|
298
|
+
omitted.nonTextBlocks > 0 ? `${omitted.nonTextBlocks} non-text block${omitted.nonTextBlocks === 1 ? '' : 's'}` : '',
|
|
299
|
+
].filter((part) => part !== '');
|
|
300
|
+
return parts.length === 0 ? '' : ` (not sent: ${parts.join(', ')})`;
|
|
301
|
+
}
|
|
302
|
+
/** The one notice every driver prints for a loaded prompt, omissions counted in it. */
|
|
303
|
+
export function mcpPromptLoadedNotice(expanded) {
|
|
304
|
+
return `loaded MCP prompt "/${expanded.command.name}" from server "${expanded.command.server}"${omissionClause(expanded.omitted)}`;
|
|
305
|
+
}
|
|
306
|
+
/** Whether the notice has to warn: something the server returned was not sent. */
|
|
307
|
+
export function mcpPromptOmittedAnything(omitted) {
|
|
308
|
+
return omitted.assistantMessages > 0 || omitted.nonTextBlocks > 0;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* The explicit invocation: argument mapping (usage errors make no request), then one
|
|
312
|
+
* `prompts/get` with a timeout and the caller's cancel signal, then the projection.
|
|
313
|
+
* Every failure is a bounded {@link McpPromptError}.
|
|
314
|
+
*/
|
|
315
|
+
export async function expandMcpPrompt(invocation, options = {}) {
|
|
316
|
+
const args = mapMcpPromptArguments(invocation);
|
|
317
|
+
const { command } = invocation;
|
|
318
|
+
const timeoutMs = options.timeoutMs ?? MCP_PROMPT_GET_TIMEOUT_MS;
|
|
319
|
+
if (command.client.connectionState !== 'connected') {
|
|
320
|
+
throw new McpPromptError(`/${command.name}: mcp server "${command.server}" is no longer connected; restart darwin to reconnect`);
|
|
321
|
+
}
|
|
322
|
+
let result;
|
|
323
|
+
// The request gets its own signal, linked to the caller's only while the call is in
|
|
324
|
+
// flight: the MCP SDK never removes its `abort` listener, so a caller signal aborted
|
|
325
|
+
// after the answer would otherwise send a stray `notifications/cancelled`.
|
|
326
|
+
const inFlight = new AbortController();
|
|
327
|
+
const forward = () => inFlight.abort(options.signal?.reason);
|
|
328
|
+
if (options.signal?.aborted === true)
|
|
329
|
+
forward();
|
|
330
|
+
else
|
|
331
|
+
options.signal?.addEventListener('abort', forward, { once: true });
|
|
332
|
+
try {
|
|
333
|
+
result = await command.client.client.getPrompt({ name: command.prompt, ...(Object.keys(args).length === 0 ? {} : { arguments: args }) }, { timeout: timeoutMs, signal: inFlight.signal });
|
|
334
|
+
}
|
|
335
|
+
catch (error) {
|
|
336
|
+
if (options.signal?.aborted === true)
|
|
337
|
+
throw new McpPromptError(`/${command.name}: cancelled before mcp server "${command.server}" answered`);
|
|
338
|
+
const text = errorText(error);
|
|
339
|
+
// -32001 is the MCP SDK's own RequestTimeout code (`ErrorCode.RequestTimeout`).
|
|
340
|
+
const timedOut = typeof error === 'object' && error !== null && error.code === -32001;
|
|
341
|
+
const reason = timedOut ? `timed out after ${timeoutMs / 1000}s` : `failed — ${text}`;
|
|
342
|
+
throw new McpPromptError(`/${command.name}: prompts/get on mcp server "${command.server}" ${reason}`);
|
|
343
|
+
}
|
|
344
|
+
finally {
|
|
345
|
+
options.signal?.removeEventListener('abort', forward);
|
|
346
|
+
}
|
|
347
|
+
return composeMcpPromptResult(command, result);
|
|
348
|
+
}
|
|
349
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/mcp/prompts.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,yDAAyD;AACzD,MAAM,CAAC,MAAM,yBAAyB,GAAG,OAAO,CAAC;AACjD,qEAAqE;AACrE,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAC7C,mFAAmF;AACnF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAC3C,iEAAiE;AACjE,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAChD,kEAAkE;AAClE,MAAM,CAAC,MAAM,yBAAyB,GAA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;YAAE,MAAM,IAAI,cAAc,CAAC,IAAI,OAAO,CAAC,IAAI,kCAAkC,OAAO,CAAC,MAAM,YAAY,CAAC,CAAC;QAC7I,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;QAC9B,gFAAgF;QAChF,MAAM,QAAQ,GAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAA4B,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC;QAC9G,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,mBAAmB,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,CAAC;QACtF,MAAM,IAAI,cAAc,CAAC,IAAI,OAAO,CAAC,IAAI,gCAAgC,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC,CAAC;IACxG,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { McpClient } from '@strands-agents/sdk';
|
|
2
2
|
import type { McpConnectionState, McpServerConfig } from '@strands-agents/sdk';
|
|
3
|
+
import type { McpPromptServerSummary } from './prompts.js';
|
|
3
4
|
/** Preferred location, alongside the rest of darwin's project state. */
|
|
4
5
|
export declare const MCP_CONFIG_FILENAME = "mcp.json";
|
|
5
6
|
/**
|
|
@@ -43,6 +44,12 @@ export interface McpServerStatus {
|
|
|
43
44
|
* token, expiry or any other credential detail.
|
|
44
45
|
*/
|
|
45
46
|
auth?: 'logged-in' | 'login-required' | 'not-logged-in';
|
|
47
|
+
/**
|
|
48
|
+
* Only for a server that was asked for prompts (connected and prompt-capable,
|
|
49
|
+
* SER-114): the offered command names, how many listed prompts were skipped, and
|
|
50
|
+
* the listing failure — read from the one startup discovery, never fetched here.
|
|
51
|
+
*/
|
|
52
|
+
prompts?: McpPromptServerSummary;
|
|
46
53
|
}
|
|
47
54
|
/**
|
|
48
55
|
* A read-only projection of the live clients for the `/mcp` report.
|
|
@@ -55,7 +62,7 @@ export interface McpServerStatus {
|
|
|
55
62
|
* stops exposing it degrades to `toolNames: undefined` (stated as unavailable by
|
|
56
63
|
* the formatter), never to a crash — and never to a connection attempt.
|
|
57
64
|
*/
|
|
58
|
-
export declare function mcpServerStatuses(clients: readonly McpClient[]): McpServerStatus[];
|
|
65
|
+
export declare function mcpServerStatuses(clients: readonly McpClient[], prompts?: ReadonlyMap<string, McpPromptServerSummary>): McpServerStatus[];
|
|
59
66
|
/**
|
|
60
67
|
* Every file `loadMcpClients` considers, in read order: the global config, the
|
|
61
68
|
* preferred project config, and the project-root fallback. Exported so the `/mcp`
|
package/dist/src/mcp/registry.js
CHANGED
|
@@ -43,18 +43,20 @@ export const ROOT_MCP_CONFIG_FILENAME = '.mcp.json';
|
|
|
43
43
|
* stops exposing it degrades to `toolNames: undefined` (stated as unavailable by
|
|
44
44
|
* the formatter), never to a crash — and never to a connection attempt.
|
|
45
45
|
*/
|
|
46
|
-
export function mcpServerStatuses(clients) {
|
|
46
|
+
export function mcpServerStatuses(clients, prompts) {
|
|
47
47
|
return clients.map((client) => {
|
|
48
48
|
const registered = client._registeredToolNames;
|
|
49
49
|
const toolNames = registered instanceof Set && [...registered].every((name) => typeof name === 'string')
|
|
50
50
|
? [...registered].sort((a, b) => a.localeCompare(b))
|
|
51
51
|
: undefined;
|
|
52
52
|
const provider = oauthProviders.get(client);
|
|
53
|
+
const promptSummary = prompts?.get(client.clientName);
|
|
53
54
|
return {
|
|
54
55
|
name: client.clientName,
|
|
55
56
|
state: client.connectionState,
|
|
56
57
|
toolNames,
|
|
57
58
|
...(provider === undefined ? {} : { auth: provider.authStatus() }),
|
|
59
|
+
...(promptSummary === undefined ? {} : { prompts: promptSummary }),
|
|
58
60
|
};
|
|
59
61
|
});
|
|
60
62
|
}
|