Skip to content

Commit cf2f5d5

Browse files
committed
Merge branch 'refactor' into feat/memory-read-only-cli
2 parents 082e68c + 034ad39 commit cf2f5d5

27 files changed

Lines changed: 3115 additions & 224 deletions

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ agentcore # interactive TUI
5858
├── runtime # inspect deployed AgentCore Runtimes
5959
│ ├── get # fetch a Runtime by id
6060
│ ├── list # list Runtimes (server-side paginated)
61+
│ ├── invoke # invoke a Runtime
6162
│ ├── version
6263
│ │ ├── get # get a specific Runtime version
6364
│ │ └── list # list a Runtime's versions
@@ -162,6 +163,85 @@ Source-aware values: any field flag documented as such accepts the value inline,
162163
`file://` convention). A command reads stdin from at most one flag. For example,
163164
`--instructions file://order-quality.txt` or `--instructions -`.
164165

166+
### Invoke a Runtime
167+
168+
Runtime invocation accepts inline, file, or stdin payload bytes:
169+
170+
```bash
171+
# Inline
172+
agentcore runtime invoke \
173+
--id <runtimeId> \
174+
--payload '{"action":"status"}' \
175+
--content-type application/json \
176+
--accept text/event-stream
177+
178+
# File
179+
agentcore runtime invoke --id <runtimeId> --payload file://request.json
180+
181+
# stdin
182+
cat request.json | agentcore runtime invoke --id <runtimeId> --payload -
183+
```
184+
185+
CUSTOM_JWT Runtimes require `--bearer-token`. The token accepts the same inline,
186+
`file://`, or stdin sources as the payload; payload and token cannot both read
187+
stdin.
188+
189+
```bash
190+
agentcore runtime invoke \
191+
--id <runtimeId> \
192+
--payload file://request.json \
193+
--bearer-token file://$HOME/.config/agentcore/runtime-token
194+
```
195+
196+
For MCP Runtimes, initialize first, then pass the returned Runtime and MCP
197+
session IDs to later methods. MCP requests accept both JSON and SSE responses.
198+
199+
```bash
200+
agentcore runtime invoke \
201+
--id <runtimeId> \
202+
--payload '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"agentcore-cli","version":"1"}}}' \
203+
--accept 'application/json, text/event-stream' \
204+
--mcp-protocol-version 2025-03-26 \
205+
--mcp-method initialize
206+
207+
agentcore runtime invoke \
208+
--id <runtimeId> \
209+
--payload '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' \
210+
--accept 'application/json, text/event-stream' \
211+
--session-id <returnedRuntimeSessionId> \
212+
--mcp-session-id <returnedMcpSessionId> \
213+
--mcp-protocol-version 2025-03-26 \
214+
--mcp-method tools/list
215+
```
216+
217+
Raw stdout always streams exact response bytes as they arrive, regardless of
218+
content type. `--output-file` streams the same bytes directly to disk. Binary or
219+
unknown responses require `--output-file` or `--json` when stdout is a terminal.
220+
Response metadata is written to stderr.
221+
222+
`--json` buffers the complete response, including streaming representations, and
223+
emits one metadata envelope without interpreting the customer body. If a raw or
224+
file response fails, bytes already written remain available and the stderr
225+
summary reports `complete=false`. A failed JSON response emits no partial
226+
envelope.
227+
228+
```bash
229+
agentcore runtime invoke \
230+
--id <runtimeId> \
231+
--payload file://request.bin \
232+
--content-type application/octet-stream \
233+
--accept application/octet-stream \
234+
--output-file response.bin
235+
236+
agentcore runtime invoke --id <runtimeId> --payload '{"action":"status"}' --json
237+
# {"statusCode":200,"contentType":"application/json","bodyEncoding":"utf8","body":"{\"ok\":true}","complete":true}
238+
```
239+
240+
Runtime Invoke accepts Runtime IDs from the current account only. It does not
241+
accept ARNs, `--version`, `--interactive`, cross-account targets, or custom
242+
request paths. All requests use the Runtime `/invocations` route, including MCP
243+
Runtimes.
244+
165245
Bare Runtime branches and leaves require a TTY on stdin and stdout. Supplying
166246
operation flags runs the command headlessly, and `--json` always suppresses TUI
167247
rendering.

bun.lock

Lines changed: 125 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"typescript": "^5"
5050
},
5151
"dependencies": {
52-
"@aws-sdk/client-bedrock-agentcore": "^3.1079.0",
52+
"@aws-sdk/client-bedrock-agentcore": "^3.1092.0",
5353
"@aws-sdk/client-bedrock-agentcore-control": "^3.1079.0",
5454
"@aws-sdk/client-iam": "^3.1080.0",
5555
"@inkui-cli/data-table": "^0.2.0",

src/core/abortable.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Relays `source` while making an in-flight read reject as soon as `signal` aborts.
3+
*
4+
* Aborts use `signal.reason` or an `AbortError` fallback. The rejection remains
5+
* observed when no read is pending, and source cleanup is fire-and-forget because
6+
* a stalled stream may also stall `iterator.return()`.
7+
*/
8+
export async function* abortable<T>(
9+
source: AsyncIterable<T>,
10+
signal: AbortSignal,
11+
): AsyncGenerator<T> {
12+
let abort = () => {};
13+
const aborted = new Promise<never>((_, reject) => {
14+
abort = () =>
15+
reject(signal.reason ?? new DOMException("The operation was aborted", "AbortError"));
16+
if (signal.aborted) abort();
17+
else signal.addEventListener("abort", abort, { once: true });
18+
});
19+
aborted.catch(() => {});
20+
21+
const iterator = source[Symbol.asyncIterator]();
22+
try {
23+
for (;;) {
24+
const result = await Promise.race([iterator.next(), aborted]);
25+
if (result.done) return;
26+
yield result.value;
27+
}
28+
} finally {
29+
signal.removeEventListener("abort", abort);
30+
void iterator.return?.()?.catch(() => {});
31+
}
32+
}

0 commit comments

Comments
 (0)