@aws/agentcore 1.0.0-preview.23 → 1.0.0-preview.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/agentcore",
3
- "version": "1.0.0-preview.23",
3
+ "version": "1.0.0-preview.24",
4
4
  "description": "CLI for Amazon Bedrock AgentCore",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -64,10 +64,13 @@
64
64
  "prepare": "husky",
65
65
  "test": "vitest run --project unit",
66
66
  "test:all": "vitest run",
67
+ "test:docs": "node --test scripts/*.test.mjs && python3 -m unittest scripts/test_render_adoc.py",
67
68
  "test:watch": "vitest --project unit",
68
69
  "test:integ": "npm run build && vitest run --project integ",
69
70
  "test:unit": "vitest run --project unit --coverage",
70
71
  "test:e2e": "vitest run --project e2e",
72
+ "test-artifacts:sanitize": "tsx scripts/sanitize-test-artifacts.ts --redact",
73
+ "test-artifacts:check": "tsx scripts/sanitize-test-artifacts.ts --check",
71
74
  "test:update-snapshots": "vitest run --project unit --update",
72
75
  "test:tui": "npm run build:harness && vitest run --project tui",
73
76
  "test:browser": "npx playwright test --config browser-tests/playwright.config.ts",
@@ -19,6 +19,7 @@
19
19
  import { execFileSync } from 'node:child_process';
20
20
  import { writeFileSync } from 'node:fs';
21
21
  import { argv } from 'node:process';
22
+ import { pathToFileURL } from 'node:url';
22
23
 
23
24
  // Command grouping (arranged properly, per the request). Mirrors the sections
24
25
  // in agentcore-cli/docs/commands.md. Any command discovered from the binary but
@@ -84,11 +85,30 @@ function help(args) {
84
85
  }
85
86
  }
86
87
 
88
+ const PARAMETER_DESCRIPTION_OVERRIDES = new Map([
89
+ ['bedrock, open_ai, or gemini', 'The model provider. Valid values: `bedrock`, `open_ai`, or `gemini`.'],
90
+ [
91
+ 'Override LiteLLM API base URL (harness only, lite_llm) [non-interactive]',
92
+ 'The LiteLLM API base URL override for harness invocations. ' +
93
+ 'Available only with `lite_llm` in non-interactive mode.',
94
+ ],
95
+ [
96
+ 'Override LiteLLM additional params as a JSON object (harness only, lite_llm) [non-interactive]',
97
+ 'The additional LiteLLM parameters, as a JSON object, for harness invocations. ' +
98
+ 'Available only with `lite_llm` in non-interactive mode.',
99
+ ],
100
+ ]);
101
+
102
+ export function normalizeParameterDescription(description) {
103
+ return PARAMETER_DESCRIPTION_OVERRIDES.get(description) || description;
104
+ }
105
+
87
106
  // Parse a Commander.js help blob into { summary, signature, params, options }.
88
- function parseHelp(text, name) {
107
+ export function parseHelp(text) {
89
108
  const lines = text.split('\n');
90
109
  const out = { summary: '', signature: '', args: [], options: [] };
91
110
  let section = 'head';
111
+ let currentItem = null;
92
112
  const descLines = [];
93
113
 
94
114
  for (const raw of lines) {
@@ -96,18 +116,22 @@ function parseHelp(text, name) {
96
116
  if (/^Usage:/.test(line)) {
97
117
  out.signature = line.replace(/^Usage:\s*/, '').trim();
98
118
  section = 'desc';
119
+ currentItem = null;
99
120
  continue;
100
121
  }
101
122
  if (/^Arguments:/.test(line)) {
102
123
  section = 'args';
124
+ currentItem = null;
103
125
  continue;
104
126
  }
105
127
  if (/^Options:/.test(line)) {
106
128
  section = 'options';
129
+ currentItem = null;
107
130
  continue;
108
131
  }
109
132
  if (/^Commands:/.test(line)) {
110
133
  section = 'commands';
134
+ currentItem = null;
111
135
  continue;
112
136
  }
113
137
 
@@ -115,10 +139,22 @@ function parseHelp(text, name) {
115
139
  if (line.trim()) descLines.push(line.trim());
116
140
  } else if (section === 'args') {
117
141
  const m = line.match(/^\s+(\S+)\s{2,}(.*)$/);
118
- if (m) out.args.push({ name: m[1], type: null, required: true, description: m[2].trim() });
142
+ if (m) {
143
+ currentItem = { name: m[1], type: null, required: true, description: m[2].trim() };
144
+ out.args.push(currentItem);
145
+ } else if (currentItem && /^\s+\S/.test(line)) {
146
+ currentItem.description += ` ${line.trim()}`;
147
+ }
119
148
  } else if (section === 'options') {
120
149
  const m = line.match(/^\s+(-[^\s].*?)\s{2,}(.*)$/);
121
- if (m) out.options.push({ name: m[1].trim(), type: null, required: false, description: m[2].trim() });
150
+ if (m) {
151
+ currentItem = { name: m[1].trim(), type: null, required: false, description: m[2].trim() };
152
+ out.options.push(currentItem);
153
+ } else if (currentItem && /^\s+\S/.test(line)) {
154
+ currentItem.description += ` ${line.trim()}`;
155
+ } else if (line.trim()) {
156
+ currentItem = null;
157
+ }
122
158
  }
123
159
  }
124
160
  out.summary = descLines.join(' ');
@@ -138,7 +174,7 @@ function entryForCommand(name) {
138
174
  `not a real CLI command (phantom/renamed). Remove it from GROUPS or fix the name.`
139
175
  );
140
176
  }
141
- const parsed = parseHelp(raw, name);
177
+ const parsed = parseHelp(raw);
142
178
  // subcommands (e.g. `add agent`, `remove tool`) show under "Commands:"—
143
179
  // we surface the top-level command; nested ones can be expanded later.
144
180
  return {
@@ -150,7 +186,10 @@ function entryForCommand(name) {
150
186
  // reuse params for both positional args and flags, flagged by required.
151
187
  // The renderer already wraps param names in backticks, so don't add our
152
188
  // own (that produced double-backticks). Drop the ubiquitous help flag.
153
- params: [...parsed.args, ...parsed.options.filter(o => !/^-h,?\s|--help\b/.test(o.name))],
189
+ params: [...parsed.args, ...parsed.options.filter(o => !/^-h,?\s|--help\b/.test(o.name))].map(param => ({
190
+ ...param,
191
+ description: normalizeParameterDescription(param.description),
192
+ })),
154
193
  returns: null,
155
194
  raises: [],
156
195
  examples: [],
@@ -225,4 +264,6 @@ function main() {
225
264
  process.stderr.write(`Wrote doc-model: ${groups.length} groups, version ${version}\n`);
226
265
  }
227
266
 
228
- main();
267
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
268
+ main();
269
+ }
@@ -0,0 +1,43 @@
1
+ import { normalizeParameterDescription, parseHelp } from './extract-cli-model.mjs';
2
+ import assert from 'node:assert/strict';
3
+ import test from 'node:test';
4
+
5
+ test('parseHelp preserves wrapped argument and option descriptions', () => {
6
+ const parsed = parseHelp(`Usage: agentcore invoke [options] [prompt]
7
+
8
+ Invoke an agent.
9
+
10
+ Arguments:
11
+ prompt Prompt to send to the agent. Also accepts piped
12
+ stdin when no prompt is provided
13
+
14
+ Options:
15
+ --prompt-file <path> Read the prompt from a file (for long or
16
+ structured payloads that exceed shell limits)
17
+
18
+ Output
19
+ --json Output as JSON
20
+ `);
21
+
22
+ assert.equal(
23
+ parsed.args[0].description,
24
+ 'Prompt to send to the agent. Also accepts piped stdin when no prompt is provided'
25
+ );
26
+ assert.equal(
27
+ parsed.options[0].description,
28
+ 'Read the prompt from a file (for long or structured payloads that exceed shell limits)'
29
+ );
30
+ assert.equal(parsed.options[1].description, 'Output as JSON');
31
+ });
32
+
33
+ test('normalizeParameterDescription expands model provider and LiteLLM fragments', () => {
34
+ assert.equal(
35
+ normalizeParameterDescription('bedrock, open_ai, or gemini'),
36
+ 'The model provider. Valid values: `bedrock`, `open_ai`, or `gemini`.'
37
+ );
38
+ assert.equal(
39
+ normalizeParameterDescription('Override LiteLLM API base URL (harness only, lite_llm) [non-interactive]'),
40
+ 'The LiteLLM API base URL override for harness invocations. ' +
41
+ 'Available only with `lite_llm` in non-interactive mode.'
42
+ );
43
+ });
@@ -55,15 +55,91 @@ import textwrap
55
55
  SCHEMA_VERSION = 1
56
56
 
57
57
 
58
+ def normalize_style(text):
59
+ """Apply style-safe substitutions to generated prose."""
60
+ if not text:
61
+ return ""
62
+ text = re.sub(r"\be\.g\.(?:,)?", "for example,", text, flags=re.IGNORECASE)
63
+ text = re.sub(
64
+ r"\bAWS (?:Bedrock(?: AgentCore)? )?Code\s*Interpreter\b",
65
+ "Amazon Bedrock AgentCore Code Interpreter",
66
+ text,
67
+ flags=re.IGNORECASE,
68
+ )
69
+ text = re.sub(r"\bAWS Bedrock AgentCore\b", "Amazon Bedrock AgentCore", text)
70
+ text = re.sub(r"\bAWS Bedrock\b", "Amazon Bedrock", text)
71
+ text = re.sub(
72
+ r"(?<!Amazon )(?<!AWS )\bBedrock AgentCore\b",
73
+ "Amazon Bedrock AgentCore",
74
+ text,
75
+ )
76
+ text = re.sub(
77
+ r"(?<!Amazon Bedrock )\bAgentCore Code Interpreter\b",
78
+ "Amazon Bedrock AgentCore Code Interpreter",
79
+ text,
80
+ )
81
+ text = re.sub(
82
+ r"(?<!Amazon Bedrock )\bAgentCore runtime\b",
83
+ "Amazon Bedrock AgentCore runtime",
84
+ text,
85
+ )
86
+ text = re.sub(
87
+ r"(?<!Amazon Bedrock )\bAgentCore Identity\b",
88
+ "Amazon Bedrock AgentCore Identity",
89
+ text,
90
+ )
91
+ text = text.replace(", allowing applications to", " so applications can")
92
+ text = re.sub(r"\bAWS region\b", "AWS Region", text, flags=re.IGNORECASE)
93
+ text = re.sub(r"\bAgentCore Memory\b", "AgentCore memory", text)
94
+ text = re.sub(r"\bAgentCore Runtime\b", "AgentCore runtime", text)
95
+ text = text.replace(
96
+ "This feature is in preview and may change in future releases.",
97
+ "This feature is in preview and might change in future releases.",
98
+ )
99
+ text = text.replace("validation will ensure", "validation ensures")
100
+ return re.sub(r"\bAWS\b", "{aws}", text)
101
+
102
+
103
+ def normalize_param_description(text):
104
+ """Normalize recurring parameter-description style issues."""
105
+ text = normalize_style(text).strip()
106
+ exact_substitutions = {
107
+ "bedrock, open_ai, or gemini": (
108
+ "The model provider. Valid values: `bedrock`, `open_ai`, or `gemini`."
109
+ ),
110
+ "Override LiteLLM API base URL (harness only, lite_llm) [non-interactive]": (
111
+ "The LiteLLM API base URL override for harness invocations. "
112
+ "Available only with `lite_llm` in non-interactive mode."
113
+ ),
114
+ "Override LiteLLM additional params as a JSON object (harness only, lite_llm) "
115
+ "[non-interactive]": (
116
+ "The additional LiteLLM parameters, as a JSON object, for harness invocations. "
117
+ "Available only with `lite_llm` in non-interactive mode."
118
+ ),
119
+ }
120
+ if text in exact_substitutions:
121
+ return exact_substitutions[text]
122
+ substitutions = (
123
+ (r"^Optional\b", "The optional"),
124
+ (r"^(?:\{aws\}|AWS)\s+region\b", "The {aws} Region"),
125
+ (r"^id of\b", "The ID of"),
126
+ (r"^Behaviour\b", "The behavior"),
127
+ (r"^Behavior\b", "The behavior"),
128
+ (r"^Memory resource ID\b", "The memory resource ID"),
129
+ (r"^Strategy name\b", "The name of the memory strategy"),
130
+ (r"^Strategy ID\b", "The ID of the memory strategy"),
131
+ )
132
+ for pattern, replacement in substitutions:
133
+ text = re.sub(pattern, replacement, text, count=1, flags=re.IGNORECASE)
134
+ return text
58
135
  def esc(text):
59
136
  """Escape AsciiDoc-significant characters in inline text."""
60
137
  if not text:
61
138
  return ""
62
139
  # Guard the couple of chars that start AsciiDoc markup in running prose.
63
- return (
64
- text.replace("|", "\\|")
65
- .replace("{", "\\{")
66
- )
140
+ marker = "\0AWS_ENTITY\0"
141
+ text = normalize_style(text).replace("{aws}", marker)
142
+ return text.replace("|", "\\|").replace("{", "\\{").replace(marker, "{aws}")
67
143
 
68
144
 
69
145
  # Match markdown code fences that may be indented (reST/Google docstrings often
@@ -116,7 +192,7 @@ def render_params(params, out):
116
192
  req = "" if p.get("required") else " _(optional)_"
117
193
  typ = f"`{p['type']}`" if p.get("type") else ""
118
194
  out.append(f"`{p['name']}`{req} {typ}::")
119
- out.append(esc(p.get("description", "")) or "_No description._")
195
+ out.append(esc(normalize_param_description(p.get("description", ""))) or "_No description._")
120
196
  out.append("")
121
197
 
122
198
 
@@ -0,0 +1,7 @@
1
+ import { JUnitReporter } from 'vitest/node';
2
+
3
+ export default class SafeJUnitReporter extends JUnitReporter {
4
+ constructor() {
5
+ super({ includeConsoleOutput: false });
6
+ }
7
+ }
@@ -0,0 +1,65 @@
1
+ import { redactTestOutput, sensitiveEnvironmentValues } from '../src/test-utils/test-output-redaction';
2
+ import { lstat, readFile, readdir, writeFile } from 'node:fs/promises';
3
+ import { relative, resolve } from 'node:path';
4
+
5
+ type Mode = 'check' | 'redact';
6
+
7
+ async function collectFiles(inputPath: string): Promise<string[]> {
8
+ const absolutePath = resolve(inputPath);
9
+
10
+ try {
11
+ const fileStat = await lstat(absolutePath);
12
+ if (fileStat.isSymbolicLink()) {
13
+ throw new Error(`Symbolic links are not allowed in test artifacts: ${inputPath}`);
14
+ }
15
+ if (fileStat.isFile()) return [absolutePath];
16
+ if (!fileStat.isDirectory()) return [];
17
+ } catch (error) {
18
+ if ((error as NodeJS.ErrnoException).code === 'ENOENT') return [];
19
+ throw error;
20
+ }
21
+
22
+ const entries = await readdir(absolutePath, { withFileTypes: true });
23
+ const files = await Promise.all(entries.map(entry => collectFiles(resolve(absolutePath, entry.name))));
24
+ return files.flat();
25
+ }
26
+
27
+ async function main(): Promise<void> {
28
+ const [modeArgument, ...inputPaths] = process.argv.slice(2);
29
+ if ((modeArgument !== '--redact' && modeArgument !== '--check') || inputPaths.length === 0) {
30
+ throw new Error('Usage: tsx scripts/sanitize-test-artifacts.ts <--redact|--check> <path...>');
31
+ }
32
+
33
+ const mode = modeArgument.slice(2) as Mode;
34
+ const files = (await Promise.all(inputPaths.map(collectFiles))).flat();
35
+ const secretValues = sensitiveEnvironmentValues();
36
+ const affectedFiles: string[] = [];
37
+ let redactionCount = 0;
38
+
39
+ for (const file of files) {
40
+ const original = await readFile(file, 'utf8');
41
+ const result = redactTestOutput(original, secretValues);
42
+ if (result.redactions === 0) continue;
43
+
44
+ affectedFiles.push(relative(process.cwd(), file));
45
+ redactionCount += result.redactions;
46
+ if (mode === 'redact') await writeFile(file, result.text, 'utf8');
47
+ }
48
+
49
+ if (mode === 'check' && affectedFiles.length > 0) {
50
+ console.error(`Sensitive output detected in ${affectedFiles.length} artifact file(s): ${affectedFiles.join(', ')}`);
51
+ process.exitCode = 1;
52
+ return;
53
+ }
54
+
55
+ if (mode === 'redact') {
56
+ console.log(`Redacted ${redactionCount} sensitive value(s) from ${affectedFiles.length} artifact file(s).`);
57
+ } else {
58
+ console.log(`No sensitive output detected in ${files.length} artifact file(s).`);
59
+ }
60
+ }
61
+
62
+ void main().catch((error: unknown) => {
63
+ console.error(error instanceof Error ? error.message : String(error));
64
+ process.exitCode = 1;
65
+ });
@@ -0,0 +1,38 @@
1
+ import unittest
2
+
3
+ from scripts.render_adoc import normalize_param_description, normalize_style
4
+
5
+
6
+ class NormalizeParamDescriptionTest(unittest.TestCase):
7
+ def test_optional_descriptions_support_singular_plural_and_mass_nouns(self):
8
+ cases = {
9
+ "Optional session name.": "The optional session name.",
10
+ "Optional tags.": "The optional tags.",
11
+ "Optional additional task metadata.": "The optional additional task metadata.",
12
+ }
13
+
14
+ for description, expected in cases.items():
15
+ with self.subTest(description=description):
16
+ self.assertEqual(normalize_param_description(description), expected)
17
+
18
+ def test_service_names_are_fully_qualified(self):
19
+ self.assertEqual(
20
+ normalize_style("Client for AgentCore runtime."),
21
+ "Client for Amazon Bedrock AgentCore runtime.",
22
+ )
23
+ self.assertEqual(
24
+ normalize_style("Client for the AgentCore Code Interpreter sandbox service."),
25
+ "Client for the Amazon Bedrock AgentCore Code Interpreter sandbox service.",
26
+ )
27
+ self.assertEqual(
28
+ normalize_style("Retrieves an API key from AgentCore Identity."),
29
+ "Retrieves an API key from Amazon Bedrock AgentCore Identity.",
30
+ )
31
+ self.assertEqual(
32
+ normalize_style("Provides credentials, allowing applications to connect."),
33
+ "Provides credentials so applications can connect.",
34
+ )
35
+
36
+
37
+ if __name__ == "__main__":
38
+ unittest.main()