feat(project): scaffold add runtime handler - #2035
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## refactor #2035 +/- ##
============================================
+ Coverage 97.11% 97.15% +0.04%
============================================
Files 384 386 +2
Lines 22711 22984 +273
============================================
+ Hits 22055 22330 +275
+ Misses 656 654 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4423362 to
473c989
Compare
| flag("entrypoint", "entrypoint file, e.g. main.py:handler (BYO only)", z.string().optional()), | ||
| flag("protocol", "server protocol: HTTP, MCP, A2A, AGUI", ProtocolModeSchema.optional()), | ||
| flag( | ||
| "api-key", |
There was a problem hiding this comment.
We should mark this as sensitive
| `--${templateOnlyFlags[0]} is only available on the template path (--template)`, | ||
| ); | ||
|
|
||
| const inputEnvironmentVariables = parseJsonFlag<Record<string, string>>( |
There was a problem hiding this comment.
Might be worth changing this to parseJsonFlagWithSchema, and passing in z.record(EnvVarNameSchema, z.string()). That way we aren't accepting null, 0, etc. into env vars
There was a problem hiding this comment.
I believe this should get validated on line 209 below, since we borrow the env var shape from the existing schema.
| ]); | ||
| export type RuntimeMemoryConfig = z.input<typeof runtimeMemoryConfigSchema>; | ||
|
|
||
| const RuntimeInfraConfigSchema = z.object({ |
There was a problem hiding this comment.
qq: I see ProjectRuntimeSchema has a bunch of superRefines validating/invalidating flags that need to be used in combination (etc. ensures VPC always has a network config). Is that something we'll account for in the implementation PR or do we need those here?
There was a problem hiding this comment.
we should still surface these errors to the customer since we validate the schema before write, but this made me realize a small bug where this wouldn't rollback the scaffolded files. Fixing that here.
There was a problem hiding this comment.
Nice catch on the rollback. With that fix I have no concerns about the validation happening later in the chain
| RuntimeResourceConfigSchema, | ||
| } from "./types"; | ||
|
|
||
| export const createAddRuntimeHandler = (config: AddProjectResourceConfig) => |
There was a problem hiding this comment.
this is interesting!
| tags: parseTags(flags["tags"]), | ||
| }; | ||
|
|
||
| const runtimeInput = isTemplate |
There was a problem hiding this comment.
it looks like --build is accepted for templates but never added to runtimeInput, and the template schema strips it as well.
This means --build Container is silently ignored. Could we include build in the template config?
There was a problem hiding this comment.
yeah good catch. I was initially thinking build would go in here, but the existing asset templates don't actually leverage it and instead have separate templates for build.
I'm working on the template doc now, so this behavior will likely change. I'm making a note to come back to this when we implement the handler to make sure its consistent.
jariy17
left a comment
There was a problem hiding this comment.
Its good, the nits could be a follow up pr.
| RuntimeResourceConfigSchema, | ||
| } from "./types"; | ||
|
|
||
| export const createAddRuntimeHandler = (config: AddProjectResourceConfig) => |
| const entrypoint = flags.entrypoint ?? "main.py"; | ||
|
|
||
| const source = new SourceResolver({ stdin: config.io.stdin }); | ||
| const apiKey = await source.resolveText("api-key", flags["api-key"]); |
There was a problem hiding this comment.
After looking at Tejas's PR, we shouldn't allow inline secrets. I asked Tejas to shift this helper functino into SourceResolver.
There was a problem hiding this comment.
It looks like there is some inconsistency here since runtime does allow this:
.I'm going to merge to avoid conflicts, and make a follow-up task to align on consistent behavior here.

Problem
add runtimeis missing.Solution
project add runtimemostly mirroring the schema shapes.templateandbyo(import OOS here). We then use this input schema to scaffold the project, and resolve the config that goes into agentcore.json (to be implemented).templateflag describes templates likestrands-python, which can be adjusted with flags (ex.--build Container, or--protocol mcp, with defaults for each template. This will keep us flexible to support more templates in the future.Testing