@aws/nx-plugin 1.2.0 → 1.3.1
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/LICENSE-THIRD-PARTY +107 -259
- package/README.md +1 -0
- package/generators.json +8 -0
- package/migrations.json +53 -10
- package/package.json +14 -14
- package/src/agentcore-gateway/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/greengrass/component/python/__snapshots__/generator.spec.ts.snap +8 -8
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/internal/test-matrix/generator.js +6 -1
- package/src/internal/test-matrix/generator.js.map +1 -1
- package/src/migrations/latest/biome-markdown-yaml-formatter-off/metadata.json +3 -0
- package/src/migrations/latest/biome-markdown-yaml-formatter-off/migration.d.ts +6 -0
- package/src/migrations/latest/biome-markdown-yaml-formatter-off/migration.js +113 -0
- package/src/migrations/latest/biome-markdown-yaml-formatter-off/migration.js.map +1 -0
- package/src/migrations/v1.0.15/0001-py-agent-pillow-override/migration.js.map +1 -0
- package/src/migrations/v1.1.1/0001-ts-agent-guardrails-synth-input/migration.js.map +1 -0
- package/src/migrations/v1.3.0/0001-ts-agent-guardrails-terraform-version-retention/metadata.json +3 -0
- package/src/migrations/v1.3.0/0001-ts-agent-guardrails-terraform-version-retention/migration.d.ts +6 -0
- package/src/migrations/v1.3.0/0001-ts-agent-guardrails-terraform-version-retention/migration.js +118 -0
- package/src/migrations/v1.3.0/0001-ts-agent-guardrails-terraform-version-retention/migration.js.map +1 -0
- package/src/preset/__snapshots__/generator.spec.ts.snap +17 -5
- package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +7 -7
- package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +7 -7
- package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +4 -4
- package/src/py/agent/guardrails/__snapshots__/generator.spec.ts.snap +3813 -0
- package/src/py/agent/guardrails/files/langchain/guardrail.py.template +135 -0
- package/src/py/agent/guardrails/files/strands/guardrail.py.template +93 -0
- package/src/py/agent/guardrails/generator.d.ts +10 -0
- package/src/py/agent/guardrails/generator.js +175 -0
- package/src/py/agent/guardrails/generator.js.map +1 -0
- package/src/py/agent/guardrails/runtime-check/run_checks.py +250 -0
- package/src/py/agent/guardrails/schema.d.js +6 -0
- package/src/py/agent/guardrails/schema.d.js.map +1 -0
- package/src/py/agent/guardrails/schema.d.ts +9 -0
- package/src/py/agent/guardrails/schema.json +25 -0
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +12 -12
- package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/py/rdb/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/sdk/py.d.ts +2 -0
- package/src/sdk/py.js +1 -0
- package/src/sdk/py.js.map +1 -1
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +8 -8
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +12 -12
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/ts/agent/guardrails/__snapshots__/generator.spec.ts.snap +57 -6
- package/src/ts/agent/guardrails/generator.js +2 -1
- package/src/ts/agent/guardrails/generator.js.map +1 -1
- package/src/ts/dcr-proxy/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +53 -33
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +2 -2
- package/src/utils/format.d.ts +10 -0
- package/src/utils/format.js +11 -0
- package/src/utils/format.js.map +1 -1
- package/src/utils/guardrail-constructs/files/terraform/app/guardrails/__nameKebabCase__/__nameKebabCase__-guardrail.tf.template +18 -1
- package/src/utils/guardrail-constructs/guardrail-constructs.d.ts +5 -0
- package/src/utils/guardrail-constructs/guardrail-constructs.js +8 -0
- package/src/utils/guardrail-constructs/guardrail-constructs.js.map +1 -1
- package/src/utils/guardrail-constructs/guardrail-wiring.d.ts +7 -0
- package/src/utils/guardrail-constructs/guardrail-wiring.js +6 -5
- package/src/utils/guardrail-constructs/guardrail-wiring.js.map +1 -1
- package/src/utils/test/fake-aws/fake_aws.py +205 -0
- package/src/utils/test/python-dependencies.d.ts +6 -0
- package/src/utils/test/python-dependencies.js +19 -0
- package/src/utils/test/python-dependencies.js.map +1 -1
- package/src/utils/test/warm-python-cache.js +5 -1
- package/src/utils/test/warm-python-cache.js.map +1 -1
- package/src/utils/version-upgrade-migration/sync-vended-versions.d.ts +8 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.js +11 -2
- package/src/utils/version-upgrade-migration/sync-vended-versions.js.map +1 -1
- package/src/utils/versions.d.ts +71 -71
- package/src/utils/versions.js +68 -68
- package/src/utils/versions.js.map +1 -1
- package/src/migrations/latest/py-agent-pillow-override/migration.js.map +0 -1
- package/src/migrations/latest/ts-agent-guardrails-synth-input/migration.js.map +0 -1
- /package/src/migrations/{latest/py-agent-pillow-override → v1.0.15/0001-py-agent-pillow-override}/metadata.json +0 -0
- /package/src/migrations/{latest/py-agent-pillow-override → v1.0.15/0001-py-agent-pillow-override}/migration.d.ts +0 -0
- /package/src/migrations/{latest/py-agent-pillow-override → v1.0.15/0001-py-agent-pillow-override}/migration.js +0 -0
- /package/src/migrations/{latest/ts-agent-guardrails-synth-input → v1.1.1/0001-ts-agent-guardrails-synth-input}/metadata.json +0 -0
- /package/src/migrations/{latest/ts-agent-guardrails-synth-input → v1.1.1/0001-ts-agent-guardrails-synth-input}/migration.d.ts +0 -0
- /package/src/migrations/{latest/ts-agent-guardrails-synth-input → v1.1.1/0001-ts-agent-guardrails-synth-input}/migration.js +0 -0
- /package/src/{ts/agent/guardrails/files/agent → utils/guardrail-constructs/files/policy}/guardrail.json.template +0 -0
package/src/migrations/v1.3.0/0001-ts-agent-guardrails-terraform-version-retention/migration.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { getProjects, joinPathFragments } from "@nx/devkit";
|
|
5
|
+
import { TS_AGENT_GENERATOR_INFO } from "../../../ts/agent/generator.js";
|
|
6
|
+
import { TS_AGENT_GUARDRAILS_GENERATOR_INFO } from "../../../ts/agent/guardrails/generator.js";
|
|
7
|
+
import { applyGritQL, GRIT_INSERT_PLACEHOLDER, insertViaGritQL, matchGritQL } from "../../../utils/ast.js";
|
|
8
|
+
import { formatFilesInSubtree } from "../../../utils/format.js";
|
|
9
|
+
import { kebabCase, toClassName } from "../../../utils/names.js";
|
|
10
|
+
import { PACKAGES_DIR, SHARED_TERRAFORM_DIR } from "../../../utils/shared-constructs-constants.js";
|
|
11
|
+
import { TERRAFORM_VERSIONS } from "../../../utils/versions.js";
|
|
12
|
+
/**
|
|
13
|
+
* Keep a replaced guardrail version for 15 seconds after the runtime-config
|
|
14
|
+
* deployment in each Terraform guardrail module of a `ts#agent#guardrails`
|
|
15
|
+
* agent.
|
|
16
|
+
*
|
|
17
|
+
* When `guardrail.json` changes, `aws_bedrock_guardrail_version.this` is
|
|
18
|
+
* replaced with `create_before_destroy`, and Terraform destroyed the old
|
|
19
|
+
* version as soon as the runtime-config deployment completed. Agents cache
|
|
20
|
+
* their runtime-config entry for 5 seconds, so a request in that window used
|
|
21
|
+
* the deleted version and failed. The module now has a `time_sleep` whose
|
|
22
|
+
* `triggers` hold the guardrail ID and version, and the runtime-config entry
|
|
23
|
+
* reads both from those triggers. On a version change the sleep is replaced
|
|
24
|
+
* too: the deposed sleep is destroyed after everything that depends on the new
|
|
25
|
+
* one (the entry and, through the root module's `depends_on`, the
|
|
26
|
+
* runtime-config deployment), waits its 15-second `destroy_duration`, and only
|
|
27
|
+
* then is the deposed version, which it depends on, destroyed.
|
|
28
|
+
*
|
|
29
|
+
* Guarded agents are found from the `ts#agent#guardrails` components in project
|
|
30
|
+
* metadata, each paired with the `ts#agent` component of the same name whose
|
|
31
|
+
* IaC is Terraform. The module is written with `KeepExisting`, so an upgraded
|
|
32
|
+
* workspace keeps the older module until this runs. A module that no longer
|
|
33
|
+
* has the generated shape is left untouched and reported via `nextSteps` with
|
|
34
|
+
* the lines to add.
|
|
35
|
+
*/ const TERRAFORM_GUARDRAILS_DIR = `${PACKAGES_DIR}/${SHARED_TERRAFORM_DIR}/src/app/guardrails`;
|
|
36
|
+
const hcl = (pattern)=>`language hcl\n${pattern}`;
|
|
37
|
+
const TIME_SLEEP = '`resource "time_sleep" "version_retention" { $_ }`';
|
|
38
|
+
/** Indented as `terraform fmt` writes it, since `.tf` files are not reformatted. */ const TIME_PROVIDER_TEXT = ` time = {
|
|
39
|
+
source = "hashicorp/time"
|
|
40
|
+
version = "${TERRAFORM_VERSIONS.time}"
|
|
41
|
+
}`;
|
|
42
|
+
const TIME_SLEEP_TEXT = `resource "time_sleep" "version_retention" {
|
|
43
|
+
destroy_duration = "15s"
|
|
44
|
+
|
|
45
|
+
triggers = {
|
|
46
|
+
guardrail_id = aws_bedrock_guardrail.this.guardrail_id
|
|
47
|
+
guardrail_version = aws_bedrock_guardrail_version.this.version
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
lifecycle {
|
|
51
|
+
create_before_destroy = true
|
|
52
|
+
}
|
|
53
|
+
}`;
|
|
54
|
+
const ENTRY_ID = 'guardrailId = aws_bedrock_guardrail.this.guardrail_id';
|
|
55
|
+
const ENTRY_VERSION = 'guardrailVersion = aws_bedrock_guardrail_version.this.version';
|
|
56
|
+
/** Every shape the migration rewrites, so a module missing one is reported rather than half-migrated. */ const REQUIRED_SHAPES = [
|
|
57
|
+
'`required_providers { $_ }`',
|
|
58
|
+
'`resource "aws_bedrock_guardrail_version" "this" { $_ }`',
|
|
59
|
+
`\`module "add_guardrail_to_runtime_config" { $body }\` where { $body <: and { contains \`${ENTRY_ID}\`, contains \`${ENTRY_VERSION}\` } }`
|
|
60
|
+
];
|
|
61
|
+
const divergedMessage = (filePath)=>`${filePath}: has diverged from the generated shape - left untouched. To keep a replaced guardrail version until agents have read the new one, add the time provider to required_providers:
|
|
62
|
+
|
|
63
|
+
${TIME_PROVIDER_TEXT}
|
|
64
|
+
|
|
65
|
+
add this resource:
|
|
66
|
+
|
|
67
|
+
${TIME_SLEEP_TEXT}
|
|
68
|
+
|
|
69
|
+
and make the runtime-config entry read guardrailId = time_sleep.version_retention.triggers.guardrail_id and guardrailVersion = time_sleep.version_retention.triggers.guardrail_version.`;
|
|
70
|
+
/** The Terraform guardrail module of each Terraform-deployed `ts#agent#guardrails` agent. */ const guardedTerraformModules = (tree)=>{
|
|
71
|
+
const files = new Set();
|
|
72
|
+
for (const project of getProjects(tree).values()){
|
|
73
|
+
const components = project.metadata?.components ?? [];
|
|
74
|
+
for (const guardrail of components.filter((c)=>c.generator === TS_AGENT_GUARDRAILS_GENERATOR_INFO.id)){
|
|
75
|
+
const agent = components.find((c)=>c.generator === TS_AGENT_GENERATOR_INFO.id && (c.name ?? 'agent') === guardrail.name);
|
|
76
|
+
if (agent?.iac !== 'terraform') {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const nameKebabCase = kebabCase(agent.rc ?? toClassName(agent.name ?? 'agent'));
|
|
80
|
+
files.add(joinPathFragments(TERRAFORM_GUARDRAILS_DIR, nameKebabCase, `${nameKebabCase}-guardrail.tf`));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return [
|
|
84
|
+
...files
|
|
85
|
+
];
|
|
86
|
+
};
|
|
87
|
+
const migrateModule = async (tree, filePath, nextSteps)=>{
|
|
88
|
+
if (await matchGritQL(tree, filePath, hcl(TIME_SLEEP))) {
|
|
89
|
+
return; // Already migrated.
|
|
90
|
+
}
|
|
91
|
+
const shapeChecks = await Promise.all(REQUIRED_SHAPES.map((shape)=>matchGritQL(tree, filePath, hcl(shape))));
|
|
92
|
+
if (shapeChecks.includes(false)) {
|
|
93
|
+
nextSteps.push(divergedMessage(filePath));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// Appended after the existing providers, so an entry the user changed is kept.
|
|
97
|
+
await insertViaGritQL(tree, filePath, hcl(`\`required_providers { $body }\` => \`required_providers {\n $body\n ${GRIT_INSERT_PLACEHOLDER}\n }\`` + ' where { $body <: not contains `time = { $_ }` }'), // The placeholder already sits at the entry's indentation.
|
|
98
|
+
TIME_PROVIDER_TEXT.replace(/^ {4}/, ''));
|
|
99
|
+
// After the version it keeps, where the generator writes it.
|
|
100
|
+
await insertViaGritQL(tree, filePath, hcl(`\`resource "aws_bedrock_guardrail_version" "this" { $body }\` => \`resource "aws_bedrock_guardrail_version" "this" {\n $body\n}\n\n${GRIT_INSERT_PLACEHOLDER}\``), TIME_SLEEP_TEXT);
|
|
101
|
+
// Only the entry reads through the sleep; the module's outputs are unchanged.
|
|
102
|
+
await applyGritQL(tree, filePath, hcl(`\`module "add_guardrail_to_runtime_config" { $body }\` where { $body <: contains bubble \`${ENTRY_ID}\` => \`guardrailId = time_sleep.version_retention.triggers.guardrail_id\`, $body <: contains bubble \`${ENTRY_VERSION}\` => \`guardrailVersion = time_sleep.version_retention.triggers.guardrail_version\` }`));
|
|
103
|
+
};
|
|
104
|
+
export default async function migration(tree) {
|
|
105
|
+
const nextSteps = [];
|
|
106
|
+
for (const filePath of guardedTerraformModules(tree)){
|
|
107
|
+
if (!tree.exists(filePath)) {
|
|
108
|
+
continue; // The guardrail module was removed or never added.
|
|
109
|
+
}
|
|
110
|
+
await migrateModule(tree, filePath, nextSteps);
|
|
111
|
+
}
|
|
112
|
+
await formatFilesInSubtree(tree);
|
|
113
|
+
return {
|
|
114
|
+
nextSteps
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=migration.js.map
|
package/src/migrations/v1.3.0/0001-ts-agent-guardrails-terraform-version-retention/migration.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.3.0/0001-ts-agent-guardrails-terraform-version-retention/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n getProjects,\n joinPathFragments,\n type MigrationReturnObject,\n type Tree,\n} from '@nx/devkit';\nimport { TS_AGENT_GENERATOR_INFO } from '../../../ts/agent/generator.js';\nimport { TS_AGENT_GUARDRAILS_GENERATOR_INFO } from '../../../ts/agent/guardrails/generator.js';\nimport {\n applyGritQL,\n GRIT_INSERT_PLACEHOLDER,\n insertViaGritQL,\n matchGritQL,\n} from '../../../utils/ast.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { kebabCase, toClassName } from '../../../utils/names.js';\nimport type { ComponentMetadata } from '../../../utils/nx.js';\nimport {\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n} from '../../../utils/shared-constructs-constants.js';\nimport { TERRAFORM_VERSIONS } from '../../../utils/versions.js';\n\n/**\n * Keep a replaced guardrail version for 15 seconds after the runtime-config\n * deployment in each Terraform guardrail module of a `ts#agent#guardrails`\n * agent.\n *\n * When `guardrail.json` changes, `aws_bedrock_guardrail_version.this` is\n * replaced with `create_before_destroy`, and Terraform destroyed the old\n * version as soon as the runtime-config deployment completed. Agents cache\n * their runtime-config entry for 5 seconds, so a request in that window used\n * the deleted version and failed. The module now has a `time_sleep` whose\n * `triggers` hold the guardrail ID and version, and the runtime-config entry\n * reads both from those triggers. On a version change the sleep is replaced\n * too: the deposed sleep is destroyed after everything that depends on the new\n * one (the entry and, through the root module's `depends_on`, the\n * runtime-config deployment), waits its 15-second `destroy_duration`, and only\n * then is the deposed version, which it depends on, destroyed.\n *\n * Guarded agents are found from the `ts#agent#guardrails` components in project\n * metadata, each paired with the `ts#agent` component of the same name whose\n * IaC is Terraform. The module is written with `KeepExisting`, so an upgraded\n * workspace keeps the older module until this runs. A module that no longer\n * has the generated shape is left untouched and reported via `nextSteps` with\n * the lines to add.\n */\n\nconst TERRAFORM_GUARDRAILS_DIR = `${PACKAGES_DIR}/${SHARED_TERRAFORM_DIR}/src/app/guardrails`;\n\nconst hcl = (pattern: string) => `language hcl\\n${pattern}`;\n\nconst TIME_SLEEP = '`resource \"time_sleep\" \"version_retention\" { $_ }`';\n\n/** Indented as `terraform fmt` writes it, since `.tf` files are not reformatted. */\nconst TIME_PROVIDER_TEXT = ` time = {\n source = \"hashicorp/time\"\n version = \"${TERRAFORM_VERSIONS.time}\"\n }`;\n\nconst TIME_SLEEP_TEXT = `resource \"time_sleep\" \"version_retention\" {\n destroy_duration = \"15s\"\n\n triggers = {\n guardrail_id = aws_bedrock_guardrail.this.guardrail_id\n guardrail_version = aws_bedrock_guardrail_version.this.version\n }\n\n lifecycle {\n create_before_destroy = true\n }\n}`;\n\nconst ENTRY_ID = 'guardrailId = aws_bedrock_guardrail.this.guardrail_id';\nconst ENTRY_VERSION =\n 'guardrailVersion = aws_bedrock_guardrail_version.this.version';\n\n/** Every shape the migration rewrites, so a module missing one is reported rather than half-migrated. */\nconst REQUIRED_SHAPES = [\n '`required_providers { $_ }`',\n '`resource \"aws_bedrock_guardrail_version\" \"this\" { $_ }`',\n `\\`module \"add_guardrail_to_runtime_config\" { $body }\\` where { $body <: and { contains \\`${ENTRY_ID}\\`, contains \\`${ENTRY_VERSION}\\` } }`,\n];\n\nconst divergedMessage = (filePath: string) =>\n `${filePath}: has diverged from the generated shape - left untouched. To keep a replaced guardrail version until agents have read the new one, add the time provider to required_providers:\n\n${TIME_PROVIDER_TEXT}\n\nadd this resource:\n\n${TIME_SLEEP_TEXT}\n\nand make the runtime-config entry read guardrailId = time_sleep.version_retention.triggers.guardrail_id and guardrailVersion = time_sleep.version_retention.triggers.guardrail_version.`;\n\n/** The Terraform guardrail module of each Terraform-deployed `ts#agent#guardrails` agent. */\nconst guardedTerraformModules = (tree: Tree): string[] => {\n const files = new Set<string>();\n for (const project of getProjects(tree).values()) {\n const components: ComponentMetadata[] =\n (project.metadata as { components?: ComponentMetadata[] } | undefined)\n ?.components ?? [];\n for (const guardrail of components.filter(\n (c) => c.generator === TS_AGENT_GUARDRAILS_GENERATOR_INFO.id,\n )) {\n const agent = components.find(\n (c) =>\n c.generator === TS_AGENT_GENERATOR_INFO.id &&\n (c.name ?? 'agent') === guardrail.name,\n );\n if (agent?.iac !== 'terraform') {\n continue;\n }\n const nameKebabCase = kebabCase(\n agent.rc ?? toClassName(agent.name ?? 'agent'),\n );\n files.add(\n joinPathFragments(\n TERRAFORM_GUARDRAILS_DIR,\n nameKebabCase,\n `${nameKebabCase}-guardrail.tf`,\n ),\n );\n }\n }\n return [...files];\n};\n\nconst migrateModule = async (\n tree: Tree,\n filePath: string,\n nextSteps: string[],\n): Promise<void> => {\n if (await matchGritQL(tree, filePath, hcl(TIME_SLEEP))) {\n return; // Already migrated.\n }\n\n const shapeChecks = await Promise.all(\n REQUIRED_SHAPES.map((shape) => matchGritQL(tree, filePath, hcl(shape))),\n );\n if (shapeChecks.includes(false)) {\n nextSteps.push(divergedMessage(filePath));\n return;\n }\n\n // Appended after the existing providers, so an entry the user changed is kept.\n await insertViaGritQL(\n tree,\n filePath,\n hcl(\n `\\`required_providers { $body }\\` => \\`required_providers {\\n $body\\n ${GRIT_INSERT_PLACEHOLDER}\\n }\\`` +\n ' where { $body <: not contains `time = { $_ }` }',\n ),\n // The placeholder already sits at the entry's indentation.\n TIME_PROVIDER_TEXT.replace(/^ {4}/, ''),\n );\n\n // After the version it keeps, where the generator writes it.\n await insertViaGritQL(\n tree,\n filePath,\n hcl(\n `\\`resource \"aws_bedrock_guardrail_version\" \"this\" { $body }\\` => \\`resource \"aws_bedrock_guardrail_version\" \"this\" {\\n $body\\n}\\n\\n${GRIT_INSERT_PLACEHOLDER}\\``,\n ),\n TIME_SLEEP_TEXT,\n );\n\n // Only the entry reads through the sleep; the module's outputs are unchanged.\n await applyGritQL(\n tree,\n filePath,\n hcl(\n `\\`module \"add_guardrail_to_runtime_config\" { $body }\\` where { $body <: contains bubble \\`${ENTRY_ID}\\` => \\`guardrailId = time_sleep.version_retention.triggers.guardrail_id\\`, $body <: contains bubble \\`${ENTRY_VERSION}\\` => \\`guardrailVersion = time_sleep.version_retention.triggers.guardrail_version\\` }`,\n ),\n );\n};\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n for (const filePath of guardedTerraformModules(tree)) {\n if (!tree.exists(filePath)) {\n continue; // The guardrail module was removed or never added.\n }\n await migrateModule(tree, filePath, nextSteps);\n }\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["getProjects","joinPathFragments","TS_AGENT_GENERATOR_INFO","TS_AGENT_GUARDRAILS_GENERATOR_INFO","applyGritQL","GRIT_INSERT_PLACEHOLDER","insertViaGritQL","matchGritQL","formatFilesInSubtree","kebabCase","toClassName","PACKAGES_DIR","SHARED_TERRAFORM_DIR","TERRAFORM_VERSIONS","TERRAFORM_GUARDRAILS_DIR","hcl","pattern","TIME_SLEEP","TIME_PROVIDER_TEXT","time","TIME_SLEEP_TEXT","ENTRY_ID","ENTRY_VERSION","REQUIRED_SHAPES","divergedMessage","filePath","guardedTerraformModules","tree","files","Set","project","values","components","metadata","guardrail","filter","c","generator","id","agent","find","name","iac","nameKebabCase","rc","add","migrateModule","nextSteps","shapeChecks","Promise","all","map","shape","includes","push","replace","migration","exists"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EACXC,iBAAiB,QAGZ,aAAa;AACpB,SAASC,uBAAuB,QAAQ,iCAAiC;AACzE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,mDAAmD;QAC/D;QACA,MAAMqB,cAAcnB,MAAMF,UAAUsB;IACtC;IAEA,MAAMvC,qBAAqBmB;IAE3B,OAAO;QAAEoB;IAAU;AACrB"}
|
|
@@ -113,6 +113,8 @@ The following list of generators are what is currently available in the \`@aws/n
|
|
|
113
113
|
|
|
114
114
|
- **py#agent**: Add an AI Agent to a Python project
|
|
115
115
|
|
|
116
|
+
- **py#agent#guardrails**: Add an Amazon Bedrock Guardrail to a Python Agent (experimental)
|
|
117
|
+
|
|
116
118
|
- **smithy#project**: Generate a Smithy model project, either defining a service or a library of reusable shapes
|
|
117
119
|
|
|
118
120
|
- **terraform#project**: Generates a Terraform project
|
|
@@ -257,7 +259,7 @@ export default {
|
|
|
257
259
|
|
|
258
260
|
exports[`preset generator > should run successfully > biome.json 1`] = `
|
|
259
261
|
"{
|
|
260
|
-
"$schema": "https://biomejs.dev/schemas/2.
|
|
262
|
+
"$schema": "https://biomejs.dev/schemas/2.6.3/schema.json",
|
|
261
263
|
"root": true,
|
|
262
264
|
"formatter": {
|
|
263
265
|
"enabled": true,
|
|
@@ -282,6 +284,16 @@ exports[`preset generator > should run successfully > biome.json 1`] = `
|
|
|
282
284
|
"enabled": false
|
|
283
285
|
}
|
|
284
286
|
},
|
|
287
|
+
"markdown": {
|
|
288
|
+
"formatter": {
|
|
289
|
+
"enabled": false
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
"yaml": {
|
|
293
|
+
"formatter": {
|
|
294
|
+
"enabled": false
|
|
295
|
+
}
|
|
296
|
+
},
|
|
285
297
|
"linter": {
|
|
286
298
|
"enabled": true,
|
|
287
299
|
"rules": {
|
|
@@ -422,11 +434,11 @@ onlyBuiltDependencies:
|
|
|
422
434
|
- sharp
|
|
423
435
|
catalogMode: strict
|
|
424
436
|
catalog:
|
|
425
|
-
nx: 23.3.
|
|
426
|
-
'@nx/js': 23.3.
|
|
427
|
-
'@nx/workspace': 23.3.
|
|
437
|
+
nx: 23.3.1
|
|
438
|
+
'@nx/js': 23.3.1
|
|
439
|
+
'@nx/workspace': 23.3.1
|
|
428
440
|
typescript: ~6.0.3
|
|
429
|
-
'@biomejs/biome': 2.
|
|
441
|
+
'@biomejs/biome': 2.6.3
|
|
430
442
|
'@aws/nx-plugin': ^0.0.0
|
|
431
443
|
'@aws/nx-plugin-mcp': ^0.0.0
|
|
432
444
|
"
|
|
@@ -763,19 +763,19 @@ name = "proj.test_project"
|
|
|
763
763
|
version = "0.1.0"
|
|
764
764
|
dependencies = [
|
|
765
765
|
"proj-agent-connection",
|
|
766
|
-
"aws-lambda-powertools==3.
|
|
766
|
+
"aws-lambda-powertools==3.37.0",
|
|
767
767
|
"aws-opentelemetry-distro==0.21.0",
|
|
768
|
-
"bedrock-agentcore==1.
|
|
769
|
-
"boto3==1.43.
|
|
770
|
-
"fastapi==0.
|
|
768
|
+
"bedrock-agentcore==1.25.0",
|
|
769
|
+
"boto3==1.43.118",
|
|
770
|
+
"fastapi==0.162.0",
|
|
771
771
|
"mcp==1.28.1",
|
|
772
|
-
"strands-agents==1.
|
|
773
|
-
"strands-agents-tools==0.8.
|
|
772
|
+
"strands-agents==1.62.0",
|
|
773
|
+
"strands-agents-tools==0.8.10",
|
|
774
774
|
"uvicorn==0.54.0"
|
|
775
775
|
]
|
|
776
776
|
|
|
777
777
|
[dependency-groups]
|
|
778
|
-
dev = [ "fastapi[standard]==0.
|
|
778
|
+
dev = [ "fastapi[standard]==0.162.0" ]
|
|
779
779
|
|
|
780
780
|
[tool.uv]
|
|
781
781
|
dev-dependencies = [ ]
|
|
@@ -701,15 +701,15 @@ name = "proj.test_project"
|
|
|
701
701
|
version = "0.1.0"
|
|
702
702
|
dependencies = [
|
|
703
703
|
"proj-agent-connection",
|
|
704
|
-
"aws-lambda-powertools==3.
|
|
704
|
+
"aws-lambda-powertools==3.37.0",
|
|
705
705
|
"aws-opentelemetry-distro==0.21.0",
|
|
706
|
-
"bedrock-agentcore==1.
|
|
707
|
-
"boto3==1.43.
|
|
708
|
-
"fastapi==0.
|
|
706
|
+
"bedrock-agentcore==1.25.0",
|
|
707
|
+
"boto3==1.43.118",
|
|
708
|
+
"fastapi==0.162.0",
|
|
709
709
|
"mcp==1.28.1",
|
|
710
|
-
"langchain==1.4.
|
|
710
|
+
"langchain==1.4.7",
|
|
711
711
|
"langchain-aws==1.9.0",
|
|
712
|
-
"langgraph==1.2.
|
|
712
|
+
"langgraph==1.2.17",
|
|
713
713
|
"langgraph-checkpoint-sqlite==3.1.2",
|
|
714
714
|
"aiosqlite==0.22.1",
|
|
715
715
|
"ag-ui-protocol==0.1.22",
|
|
@@ -718,7 +718,7 @@ dependencies = [
|
|
|
718
718
|
]
|
|
719
719
|
|
|
720
720
|
[dependency-groups]
|
|
721
|
-
dev = [ "fastapi[standard]==0.
|
|
721
|
+
dev = [ "fastapi[standard]==0.162.0" ]
|
|
722
722
|
|
|
723
723
|
[tool.uv]
|
|
724
724
|
dev-dependencies = [ ]
|
|
@@ -5,7 +5,7 @@ exports[`py#agent generator > should create DynamoDB checkpoint table and S3 off
|
|
|
5
5
|
required_providers {
|
|
6
6
|
aws = {
|
|
7
7
|
source = "hashicorp/aws"
|
|
8
|
-
version = "6.
|
|
8
|
+
version = "6.70.0"
|
|
9
9
|
}
|
|
10
10
|
random = {
|
|
11
11
|
source = "hashicorp/random"
|
|
@@ -381,7 +381,7 @@ exports[`py#agent generator > should match snapshot for Terraform generated file
|
|
|
381
381
|
required_providers {
|
|
382
382
|
aws = {
|
|
383
383
|
source = "hashicorp/aws"
|
|
384
|
-
version = "6.
|
|
384
|
+
version = "6.70.0"
|
|
385
385
|
}
|
|
386
386
|
random = {
|
|
387
387
|
source = "hashicorp/random"
|
|
@@ -704,7 +704,7 @@ exports[`py#agent generator > should match snapshot for Terraform generated file
|
|
|
704
704
|
required_providers {
|
|
705
705
|
aws = {
|
|
706
706
|
source = "hashicorp/aws"
|
|
707
|
-
version = "6.
|
|
707
|
+
version = "6.70.0"
|
|
708
708
|
}
|
|
709
709
|
null = {
|
|
710
710
|
source = "hashicorp/null"
|
|
@@ -1063,7 +1063,7 @@ resource "null_resource" "runtime_ready" {
|
|
|
1063
1063
|
|
|
1064
1064
|
provisioner "local-exec" {
|
|
1065
1065
|
command = <<-EOT
|
|
1066
|
-
uv run --with boto3==1.43.
|
|
1066
|
+
uv run --with boto3==1.43.118 python -c "
|
|
1067
1067
|
import boto3
|
|
1068
1068
|
import json
|
|
1069
1069
|
import os
|