@aws/agentcore 1.0.0-preview.20 → 1.0.0-preview.21
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/dist/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +1 -1
- package/dist/assets/python/http/strands/base/model/load.py +1 -1
- package/dist/cli/index.mjs +545 -519
- package/dist/lib/constants.d.ts +8 -4
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +13 -7
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/packaging/build-args.d.ts +6 -0
- package/dist/lib/packaging/build-args.d.ts.map +1 -1
- package/dist/lib/packaging/build-args.js +9 -0
- package/dist/lib/packaging/build-args.js.map +1 -1
- package/dist/lib/packaging/build-context-dockerignore.d.ts +23 -0
- package/dist/lib/packaging/build-context-dockerignore.d.ts.map +1 -0
- package/dist/lib/packaging/build-context-dockerignore.js +63 -0
- package/dist/lib/packaging/build-context-dockerignore.js.map +1 -0
- package/dist/lib/packaging/build-context.d.ts +21 -0
- package/dist/lib/packaging/build-context.d.ts.map +1 -0
- package/dist/lib/packaging/build-context.js +21 -0
- package/dist/lib/packaging/build-context.js.map +1 -0
- package/dist/lib/packaging/container.d.ts.map +1 -1
- package/dist/lib/packaging/container.js +15 -4
- package/dist/lib/packaging/container.js.map +1 -1
- package/dist/lib/packaging/index.d.ts +2 -0
- package/dist/lib/packaging/index.d.ts.map +1 -1
- package/dist/lib/packaging/index.js +5 -1
- package/dist/lib/packaging/index.js.map +1 -1
- package/dist/schema/schemas/agent-env.d.ts +22 -0
- package/dist/schema/schemas/agent-env.d.ts.map +1 -1
- package/dist/schema/schemas/agent-env.js +117 -15
- package/dist/schema/schemas/agent-env.js.map +1 -1
- package/dist/schema/schemas/agentcore-project.d.ts +4 -0
- package/dist/schema/schemas/agentcore-project.d.ts.map +1 -1
- package/dist/schema/schemas/aws-targets.d.ts +12 -0
- package/dist/schema/schemas/aws-targets.d.ts.map +1 -1
- package/dist/schema/schemas/aws-targets.js +4 -0
- package/dist/schema/schemas/aws-targets.js.map +1 -1
- package/dist/schema/schemas/mcp.d.ts +2 -0
- package/dist/schema/schemas/mcp.d.ts.map +1 -1
- package/dist/schema/schemas/mcp.js +1 -0
- package/dist/schema/schemas/mcp.js.map +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/scripts/extract-cli-model.mjs +228 -0
- package/scripts/render_adoc.py +274 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# render_adoc.py — shared doc-model -> AsciiDoc renderer
|
|
4
|
+
# =============================================================================
|
|
5
|
+
# Renders a normalized "doc-model" JSON (produced by any of the three
|
|
6
|
+
# extractors) into .adoc files for the documentation repository.
|
|
7
|
+
#
|
|
8
|
+
# It is deliberately source-agnostic: the Python extractor, the TypeScript
|
|
9
|
+
# TypeDoc extractor, and the CLI --help extractor all emit the SAME doc-model
|
|
10
|
+
# schema, so this one renderer produces consistent output for all three.
|
|
11
|
+
#
|
|
12
|
+
# NOTE: if these workflows are later consolidated into a single shared reusable
|
|
13
|
+
# workflow, this file is vendored there ONCE and every source repo's caller
|
|
14
|
+
# invokes it. Keep it dependency-free (stdlib only) so it drops cleanly into any
|
|
15
|
+
# runner.
|
|
16
|
+
#
|
|
17
|
+
# -----------------------------------------------------------------------------
|
|
18
|
+
# doc-model schema (v1) — the contract every extractor must emit:
|
|
19
|
+
# {
|
|
20
|
+
# "source": "python-sdk" | "ts-sdk" | "cli",
|
|
21
|
+
# "package": "bedrock-agentcore",
|
|
22
|
+
# "version": "1.16.0",
|
|
23
|
+
# "language": "python" | "typescript" | "cli",
|
|
24
|
+
# "groups": [ # a group -> one .adoc file
|
|
25
|
+
# {
|
|
26
|
+
# "id": "runtime", # -> <prefix>-runtime.adoc, and anchor id
|
|
27
|
+
# "title": "Runtime",
|
|
28
|
+
# "summary": "Runtime management and application context.",
|
|
29
|
+
# "entries": [ # classes / functions / commands
|
|
30
|
+
# {
|
|
31
|
+
# "kind": "class" | "function" | "command",
|
|
32
|
+
# "name": "BedrockAgentCoreApp",
|
|
33
|
+
# "signature": "BedrockAgentCoreApp(params)",
|
|
34
|
+
# "summary": "one-line summary",
|
|
35
|
+
# "description": "longer prose (optional)",
|
|
36
|
+
# "params": [ {"name","type","required","description"} ],
|
|
37
|
+
# "returns": {"type","description"} | null,
|
|
38
|
+
# "raises": [ {"type","description"} ],
|
|
39
|
+
# "examples": [ {"lang","code"} ],
|
|
40
|
+
# "members": [ <entry>, ... ] # methods on a class (recursive)
|
|
41
|
+
# }
|
|
42
|
+
# ]
|
|
43
|
+
# }
|
|
44
|
+
# ]
|
|
45
|
+
# }
|
|
46
|
+
# -----------------------------------------------------------------------------
|
|
47
|
+
|
|
48
|
+
import argparse
|
|
49
|
+
import json
|
|
50
|
+
import os
|
|
51
|
+
import re
|
|
52
|
+
import sys
|
|
53
|
+
import textwrap
|
|
54
|
+
|
|
55
|
+
SCHEMA_VERSION = 1
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def esc(text):
|
|
59
|
+
"""Escape AsciiDoc-significant characters in inline text."""
|
|
60
|
+
if not text:
|
|
61
|
+
return ""
|
|
62
|
+
# Guard the couple of chars that start AsciiDoc markup in running prose.
|
|
63
|
+
return (
|
|
64
|
+
text.replace("|", "\\|")
|
|
65
|
+
.replace("{", "\\{")
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# Match markdown code fences that may be indented (reST/Google docstrings often
|
|
70
|
+
# indent example blocks). `re.MULTILINE` lets ^ match each line start; the
|
|
71
|
+
# leading-whitespace groups are stripped from the captured code.
|
|
72
|
+
_FENCE_RE = re.compile(r"^[ \t]*```(\w*)[ \t]*\n(.*?)\n[ \t]*```[ \t]*$", re.DOTALL | re.MULTILINE)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def render_prose(text):
|
|
76
|
+
"""Render description prose that may contain markdown ``` code fences.
|
|
77
|
+
|
|
78
|
+
Docstrings/TSDoc frequently embed fenced code blocks in the description
|
|
79
|
+
(not just in @example). Left alone they leak literal backticks into the
|
|
80
|
+
AsciiDoc. Split the prose on fences: escape the prose spans, and convert
|
|
81
|
+
each fenced block into an AsciiDoc [source] block (verbatim, not escaped).
|
|
82
|
+
"""
|
|
83
|
+
if not text:
|
|
84
|
+
return []
|
|
85
|
+
out = []
|
|
86
|
+
pos = 0
|
|
87
|
+
for m in _FENCE_RE.finditer(text):
|
|
88
|
+
before = text[pos:m.start()].strip()
|
|
89
|
+
if before:
|
|
90
|
+
out.append(esc(before))
|
|
91
|
+
out.append("")
|
|
92
|
+
lang = m.group(1) or ""
|
|
93
|
+
out.append(f"[source,{lang}]" if lang else "[source]")
|
|
94
|
+
out.append("----")
|
|
95
|
+
# Dedent the captured code (fences are often indented in docstrings).
|
|
96
|
+
out.append(textwrap.dedent(m.group(2)).rstrip())
|
|
97
|
+
out.append("----")
|
|
98
|
+
out.append("")
|
|
99
|
+
pos = m.end()
|
|
100
|
+
tail = text[pos:].strip()
|
|
101
|
+
if tail:
|
|
102
|
+
out.append(esc(tail))
|
|
103
|
+
return out
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def block(lines):
|
|
107
|
+
return "\n".join(lines)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def render_params(params, out):
|
|
111
|
+
if not params:
|
|
112
|
+
return
|
|
113
|
+
out.append("*Parameters*")
|
|
114
|
+
out.append("")
|
|
115
|
+
for p in params:
|
|
116
|
+
req = "" if p.get("required") else " _(optional)_"
|
|
117
|
+
typ = f"`{p['type']}`" if p.get("type") else ""
|
|
118
|
+
out.append(f"`{p['name']}`{req} {typ}::")
|
|
119
|
+
out.append(esc(p.get("description", "")) or "_No description._")
|
|
120
|
+
out.append("")
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def render_returns(returns, out):
|
|
124
|
+
if not returns:
|
|
125
|
+
return
|
|
126
|
+
typ = f"`{returns['type']}` — " if returns.get("type") else ""
|
|
127
|
+
out.append("*Returns*")
|
|
128
|
+
out.append("")
|
|
129
|
+
out.append(f"{typ}{esc(returns.get('description', ''))}".strip())
|
|
130
|
+
out.append("")
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def render_raises(raises, out):
|
|
134
|
+
if not raises:
|
|
135
|
+
return
|
|
136
|
+
out.append("*Raises*")
|
|
137
|
+
out.append("")
|
|
138
|
+
for r in raises:
|
|
139
|
+
out.append(f"`{r.get('type', 'Error')}`:: {esc(r.get('description', ''))}")
|
|
140
|
+
out.append("")
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def clean_example_code(code):
|
|
144
|
+
"""Strip stray markdown fence lines from example code.
|
|
145
|
+
|
|
146
|
+
Extractors try to remove ``` fences, but real docstrings put them mid-buffer
|
|
147
|
+
(e.g. a fence followed by extra "Notes:"/"Thread Safety:" prose swept into
|
|
148
|
+
the example). Since this text is already going inside an AsciiDoc [source]
|
|
149
|
+
block, any line that is just a fence is spurious — drop it, and drop trailing
|
|
150
|
+
non-code prose that follows a closing fence.
|
|
151
|
+
"""
|
|
152
|
+
lines = code.split("\n")
|
|
153
|
+
kept = []
|
|
154
|
+
closed = False
|
|
155
|
+
for line in lines:
|
|
156
|
+
if re.match(r"^[ \t]*```", line):
|
|
157
|
+
# A closing fence marks the end of the real code; ignore the fence
|
|
158
|
+
# line itself and stop taking subsequent prose.
|
|
159
|
+
if kept:
|
|
160
|
+
closed = True
|
|
161
|
+
continue
|
|
162
|
+
if closed and line.strip() == "":
|
|
163
|
+
continue
|
|
164
|
+
if closed and line.strip():
|
|
165
|
+
break # prose after the closing fence — not part of the example
|
|
166
|
+
kept.append(line)
|
|
167
|
+
return textwrap.dedent("\n".join(kept)).strip()
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def render_examples(examples, out):
|
|
171
|
+
for ex in examples or []:
|
|
172
|
+
lang = ex.get("lang", "text")
|
|
173
|
+
code = clean_example_code(ex.get("code", ""))
|
|
174
|
+
if not code:
|
|
175
|
+
continue
|
|
176
|
+
out.append(f"[source,{lang}]")
|
|
177
|
+
out.append("----")
|
|
178
|
+
out.append(code)
|
|
179
|
+
out.append("----")
|
|
180
|
+
out.append("")
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def render_entry(entry, level, out):
|
|
184
|
+
"""Render a single class/function/command as an AsciiDoc section."""
|
|
185
|
+
heading = "=" * level
|
|
186
|
+
name = entry.get("name", "")
|
|
187
|
+
out.append(f"{heading} {name}")
|
|
188
|
+
out.append("")
|
|
189
|
+
|
|
190
|
+
sig = entry.get("signature")
|
|
191
|
+
if sig:
|
|
192
|
+
out.append("[source]")
|
|
193
|
+
out.append("----")
|
|
194
|
+
out.append(sig)
|
|
195
|
+
out.append("----")
|
|
196
|
+
out.append("")
|
|
197
|
+
|
|
198
|
+
if entry.get("summary"):
|
|
199
|
+
out.extend(render_prose(entry["summary"]))
|
|
200
|
+
out.append("")
|
|
201
|
+
if entry.get("description"):
|
|
202
|
+
out.extend(render_prose(entry["description"]))
|
|
203
|
+
out.append("")
|
|
204
|
+
|
|
205
|
+
render_params(entry.get("params"), out)
|
|
206
|
+
render_returns(entry.get("returns"), out)
|
|
207
|
+
render_raises(entry.get("raises"), out)
|
|
208
|
+
render_examples(entry.get("examples"), out)
|
|
209
|
+
|
|
210
|
+
# methods / subcommands nest one heading level deeper
|
|
211
|
+
for member in entry.get("members", []):
|
|
212
|
+
render_entry(member, level + 1, out)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def render_group(group, model, prefix):
|
|
216
|
+
"""Render one group -> one .adoc file body (string)."""
|
|
217
|
+
out = []
|
|
218
|
+
gid = group["id"]
|
|
219
|
+
# AsciiDoc anchor so the TOC / other pages can xref into it.
|
|
220
|
+
out.append(f"[[{prefix}-{gid}]]")
|
|
221
|
+
out.append(f"= {group['title']}")
|
|
222
|
+
out.append("")
|
|
223
|
+
out.append(
|
|
224
|
+
f"_Auto-generated from `{model['package']}` "
|
|
225
|
+
f"v{model['version']} — do not edit by hand._"
|
|
226
|
+
)
|
|
227
|
+
out.append("")
|
|
228
|
+
if group.get("summary"):
|
|
229
|
+
out.extend(render_prose(group["summary"]))
|
|
230
|
+
out.append("")
|
|
231
|
+
|
|
232
|
+
for entry in group.get("entries", []):
|
|
233
|
+
render_entry(entry, level=2, out=out)
|
|
234
|
+
|
|
235
|
+
return block(out).rstrip() + "\n"
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def main():
|
|
239
|
+
ap = argparse.ArgumentParser(description="Render doc-model JSON to .adoc")
|
|
240
|
+
ap.add_argument("--model", required=True, help="path to doc-model JSON")
|
|
241
|
+
ap.add_argument("--out-dir", required=True, help="output dir for .adoc files")
|
|
242
|
+
ap.add_argument(
|
|
243
|
+
"--prefix",
|
|
244
|
+
required=True,
|
|
245
|
+
help="filename + anchor prefix, e.g. 'python-sdk', 'ts-sdk', 'cli'",
|
|
246
|
+
)
|
|
247
|
+
args = ap.parse_args()
|
|
248
|
+
|
|
249
|
+
with open(args.model) as f:
|
|
250
|
+
model = json.load(f)
|
|
251
|
+
|
|
252
|
+
os.makedirs(args.out_dir, exist_ok=True)
|
|
253
|
+
written = []
|
|
254
|
+
for group in model.get("groups", []):
|
|
255
|
+
body = render_group(group, model, args.prefix)
|
|
256
|
+
fname = f"{args.prefix}-{group['id']}.adoc"
|
|
257
|
+
path = os.path.join(args.out_dir, fname)
|
|
258
|
+
with open(path, "w") as f:
|
|
259
|
+
f.write(body)
|
|
260
|
+
written.append(fname)
|
|
261
|
+
|
|
262
|
+
# Emit the list of includes the caller can splice into the docs TOC file.
|
|
263
|
+
manifest = os.path.join(args.out_dir, f"{args.prefix}-includes.txt")
|
|
264
|
+
with open(manifest, "w") as f:
|
|
265
|
+
for fname in written:
|
|
266
|
+
f.write(f"include::{args.prefix}/{fname}[leveloffset=+1]\n")
|
|
267
|
+
|
|
268
|
+
print(f"Rendered {len(written)} .adoc files to {args.out_dir}", file=sys.stderr)
|
|
269
|
+
for fname in written:
|
|
270
|
+
print(f" - {fname}", file=sys.stderr)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
if __name__ == "__main__":
|
|
274
|
+
main()
|