@aws/nx-plugin-mcp 1.0.0-rc.55 → 1.0.0-rc.57
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.
|
@@ -75,7 +75,7 @@ export default async function migration(
|
|
|
75
75
|
}
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
- **`nextSteps`** —
|
|
78
|
+
- **`nextSteps`** — the follow-up actions Nx prints for the user after `nx migrate` runs. Every entry should be something they need to do by hand: reconcile a file you skipped (see the guardrails below), or finish something beyond the migration's reach, like an install to refresh a lock file. They aren't a log of what you changed — when a transform applies cleanly, add nothing, otherwise the entries that do need action get buried.
|
|
79
79
|
- **`agentContext`** (hybrid only) — a summary of what the codemod changed, passed to the paired `prompt` when it runs under Nx's agentic flow so the agent can focus on the user-owned parts.
|
|
80
80
|
|
|
81
81
|
For some example operations you can perform in your migration (generating files, modifying existing files using GritQL, reading and updating JSON), refer to the <Link path="/guides/nx-generator">Nx Generator guide</Link>.
|
|
@@ -86,6 +86,7 @@ Migrations run against workspaces you don't control, so it is recommended to adh
|
|
|
86
86
|
|
|
87
87
|
- **Transform source code with GritQL.** Use the <Link path="/guides/nx-generator">GritQL helpers</Link> (`applyGritQL`, `matchGritQL`) to edit source rather than regexes or string replacements. GritQL matches the AST, so one pattern holds across the formatting, whitespace and quoting a user's copy may have drifted into, where text matching quietly misses equivalent code or corrupts the file. Use `updateJson` for JSON and the matching parser for other structured config.
|
|
88
88
|
- **Pattern-match before writing.** If a target file has diverged from the shape your generators produce, skip it and report it via `nextSteps`, or consider a hybrid migration, rather than clobbering the user's changes. `matchGritQL` is a convenient way to make that check.
|
|
89
|
+
- **Report only what's left to do.** `nextSteps` is for work the user has to pick up, not a record of the edits you made — those are already in their `git diff`.
|
|
89
90
|
- **Idempotent.** Re-running the migration must be a no-op. Guard GritQL rewrites that inject code with a `where { ... <: not contains ... }` clause so a second run doesn't append a duplicate.
|
|
90
91
|
- **Format what you write.** Finish with `formatFilesInSubtree(tree)` so the files your migration wrote are formatted correctly.
|
|
91
92
|
|
package/docs/guides/ts-agent.mdx
CHANGED
|
@@ -60,6 +60,7 @@ The generator will add the following files to your existing TypeScript project.
|
|
|
60
60
|
- init.ts tRPC initialization
|
|
61
61
|
- router.ts tRPC router with agent procedures
|
|
62
62
|
- agent.ts Main agent definition with sample tools
|
|
63
|
+
- session.ts Resolves the SessionManager used to persist conversation state
|
|
63
64
|
- client.ts Vended client for invoking your agent
|
|
64
65
|
- agent-core-trpc-client.ts Client factory for connecting to agents on AgentCore Runtime
|
|
65
66
|
- Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
|
|
@@ -79,6 +80,7 @@ The entry point uses the [Strands A2A Express Server](https://strandsagents.com/
|
|
|
79
80
|
- agent/ (or custom name if specified)
|
|
80
81
|
- index.ts A2A Express server entry point
|
|
81
82
|
- agent.ts Main agent definition with sample tools
|
|
83
|
+
- session.ts Resolves the SessionManager used to persist conversation state
|
|
82
84
|
- Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
|
|
83
85
|
- package.json Updated with Strands and Express dependencies
|
|
84
86
|
- project.json Updated with agent serve targets
|
|
@@ -96,6 +98,7 @@ The entry point uses [`@ag-ui/aws-strands`](https://www.npmjs.com/package/@ag-ui
|
|
|
96
98
|
- agent/ (or custom name if specified)
|
|
97
99
|
- index.ts AG-UI server entry point (Express + SSE)
|
|
98
100
|
- agent.ts Main agent definition with sample tools
|
|
101
|
+
- session.ts Resolves the SessionManager used to persist conversation state
|
|
99
102
|
- Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
|
|
100
103
|
- package.json Updated with Strands and AG-UI dependencies
|
|
101
104
|
- project.json Updated with agent serve targets
|
|
@@ -185,7 +188,7 @@ const letterCounter = tool({
|
|
|
185
188
|
});
|
|
186
189
|
|
|
187
190
|
// Add tools to your agent
|
|
188
|
-
export const getAgent = async (
|
|
191
|
+
export const getAgent = async () => {
|
|
189
192
|
return new Agent({
|
|
190
193
|
systemPrompt: 'You are a helpful assistant with access to various tools.',
|
|
191
194
|
tools: [letterCounter],
|
|
@@ -347,6 +350,29 @@ Your agent is automatically configured with observability using the [AWS Distro
|
|
|
347
350
|
You can find traces in the CloudWatch AWS Console, by selecting "GenAI Observability" in the menu. Note that for traces to be populated you will need to enable [Transaction Search](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Transaction-Search.html).
|
|
348
351
|
|
|
349
352
|
For more details, refer to the [AgentCore documentation on observability](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability-configure.html).
|
|
353
|
+
|
|
354
|
+
### Session Management
|
|
355
|
+
|
|
356
|
+
The `session` option controls how your agent persists conversation state (message history, tool state, etc.) across invocations, using the Strands SDK's [SessionManager](https://strandsagents.com/docs/user-guide/concepts/agents/session-management/):
|
|
357
|
+
|
|
358
|
+
- **`s3`** (default): The CDK/Terraform infrastructure provisions a dedicated S3 bucket for session data, encrypted with a dedicated KMS key and with all public access blocked; server access logs are delivered to a CloudWatch Logs log group via the same key. The agent's IAM role is granted read/write/list/delete access to the bucket and decrypt/generate-data-key access to the key, and the bucket name is registered alongside the agent's ARN in AppConfig runtime configuration.
|
|
359
|
+
- **`in-memory`**: No bucket is provisioned. Conversation state is kept in memory only for the lifetime of the running process and does not survive restarts or scale-in.
|
|
360
|
+
|
|
361
|
+
This is implemented in the generated `session.ts`, which exports a `getSessionManager()` function resolving a `SessionManager` for the current session.
|
|
362
|
+
|
|
363
|
+
<OptionFilter when={{ protocol: 'ag-ui' }} description="AG-UI session wiring">
|
|
364
|
+
Since AG-UI clones a template agent per conversation thread, `getSessionManager` is wired in as a `sessionManagerProvider` on the `StrandsAgent` config in `index.ts`, so a fresh `SessionManager` is resolved for each thread rather than baked into the shared template agent.
|
|
365
|
+
</OptionFilter>
|
|
366
|
+
|
|
367
|
+
<OptionFilter when={{ protocol: ['http', 'a2a'] }} description="HTTP/A2A session wiring">
|
|
368
|
+
Since `withSessionId` already caches one `Agent` instance per session, `getSessionManager` is called directly inside `getAgent`'s `new Agent({ sessionManager: await getSessionManager() })` call in `agent.ts`.
|
|
369
|
+
</OptionFilter>
|
|
370
|
+
|
|
371
|
+
The session ID itself comes from the AgentCore Runtime session (propagated via the `x-amzn-bedrock-agentcore-runtime-session-id` header for A2A/AG-UI, or the WebSocket connection context for HTTP/tRPC) and is bound to an [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage)-based context so `getCurrentSessionId()` can resolve it anywhere in the request — including in any downstream MCP or A2A clients wired up via the <Link path="/guides/connection">`connection` generator</Link>, so the whole call chain shares a consistent session.
|
|
372
|
+
|
|
373
|
+
:::note[Local Development]
|
|
374
|
+
When running locally (`LOCAL_DEV=true`, set automatically by the `-dev` target), session data is always stored on disk under `tmp/agents/strands/<agent-name>` at the workspace root, regardless of the configured `session` option, for convenience.
|
|
375
|
+
:::
|
|
350
376
|
</OptionFilter>
|
|
351
377
|
|
|
352
378
|
## Invoking your Agent
|
package/package.json
CHANGED
package/src/py/agent/schema.json
CHANGED
|
@@ -60,6 +60,14 @@
|
|
|
60
60
|
"default": "agentcore",
|
|
61
61
|
"x-priority": "important"
|
|
62
62
|
},
|
|
63
|
+
"session": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"description": "The storage used to persist session for your Agent. Only 'in-memory' is currently supported for Python agents.",
|
|
66
|
+
"x-prompt": "How would you like to persist session for your Agent?",
|
|
67
|
+
"enum": ["in-memory"],
|
|
68
|
+
"default": "in-memory",
|
|
69
|
+
"x-priority": "important"
|
|
70
|
+
},
|
|
63
71
|
"preferInstallDependencies": {
|
|
64
72
|
"type": "boolean",
|
|
65
73
|
"description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
|
package/src/ts/agent/schema.json
CHANGED
|
@@ -60,6 +60,14 @@
|
|
|
60
60
|
"default": "agentcore",
|
|
61
61
|
"x-priority": "important"
|
|
62
62
|
},
|
|
63
|
+
"session": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"description": "The storage used to persist session for your Agent.",
|
|
66
|
+
"x-prompt": "How would you like to persist session for your Agent?",
|
|
67
|
+
"enum": ["s3", "in-memory"],
|
|
68
|
+
"default": "s3",
|
|
69
|
+
"x-priority": "important"
|
|
70
|
+
},
|
|
63
71
|
"preferInstallDependencies": {
|
|
64
72
|
"type": "boolean",
|
|
65
73
|
"description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
|