feat(templates): add strands-ts TypeScript runtime template - #7
feat(templates): add strands-ts TypeScript runtime template#7Hweinstock wants to merge 7 commits into
Conversation
| @@ -0,0 +1,29 @@ | |||
| { | |||
There was a problem hiding this comment.
these templates are copied as is from https://github.com/aws/agentcore-cli/tree/main/src/assets/typescript/http/strands. I think it'd be great to simplify here.
| memory: MEMORY_SHORTCUTS[flags.memory ?? "longAndShortTerm"](runtimeName), | ||
| entrypoint: "main.py", | ||
| runtimeVersion: flags.build === "CodeZip" ? "PYTHON_3_14" : undefined, | ||
| entrypoint: flags.language === "TypeScript" ? "main.js" : "main.py", |
There was a problem hiding this comment.
since this is constant depending on the language, lets remove it from this interface and resolve it when we template the files.
There was a problem hiding this comment.
Done in 4b8e295 — removed entrypoint from ScaffoldRuntimeInput (and the shortcuts); it is now derived from the language in buildRuntimeSpec via entrypointForLanguage.
| }); | ||
| } | ||
| }) | ||
| .superRefine(({ language, framework }, ctx) => { |
There was a problem hiding this comment.
this should be rejected already later on when we try to resolve the template. i.e. in src/core/project/templates/runtime the key should not exist, and it should fail to find a resolver.
There was a problem hiding this comment.
Done in af204ac — removed the superRefine. none/TypeScript has no resolver key, so getRuntimeTemplateResolver returns nothing and the caller throws an InputValidationError (both create and add-runtime paths). Kept a test asserting the rejection.
| const [entrypoint] = input.runtime.entrypoint.split(":"); | ||
| const entrypointPath = resolve(directory, entrypoint!); | ||
| // TypeScript runtimes deploy a compiled main.js but are developed from the |
There was a problem hiding this comment.
lets update this comment be clearer, something like:
// the spec stores `.js` to be compatible with deploy, but dev uses `tsx watch` on the source code. // therefore we take the `.ts` version of the entrypoint if it exists for dev, and fallback to the `.js` in case a project has a pure js entrypoint. There was a problem hiding this comment.
Done in 8e2de34 — updated the comment to your wording.
4b8e295 to
18d284cCompareHweinstock
commented
Aug 28, 2026
Rebased onto the latest
Re-verified end-to-end on the new base with the compiled binary: create → dev (curl) → deploy → |
18d284c to
8a39389Compare3042954 to
bd35521Compare
Summary
Adds first-class TypeScript support to the CLI via a new
strands-tsproject template, ported from the upstreamsrc/assets/typescript/http/strandsassets and reformatted to match the Python template layout. Containers are intentionally out of scope for this PR (pending other work).Stacked on top of aws#2116 (memory-in-templates) — base is
memory-in-templates.Spec
What changed
src/assets/templates/strands-http-typescript/— new template (main.ts,model/load.ts,mcp_client/client.ts,memory/memory.ts,package.json,tsconfig.json,gitignore.template,README.md). Handlebars-templated; memory variables rewired to this repo's render context (memoryEnvVarName/memoryStrategies/hasMemory), mirroring the Pythonstrands-http-pythontemplate.runtime.ts— newstrands/TypeScriptresolver (+toNpmPackageName), mirroring the Python strands resolver (same memory-dir filter and spec shape).shortcuts.ts— newstrands-tsshortcut (CodeZip,NODE_22,longAndShortTermmemory).types.ts/create/add runtime—"TypeScript"added to the language enum. Unsupported language/framework combos (e.g. TypeScript without strands) are rejected by the template resolver — there's nostrands/none×TypeScriptresolver key, sogetRuntimeTemplateResolverreturns nothing and the caller raises anInputValidationError.runtimeVersionis derived per language in the handlers.runtime.ts— the runtime specentrypointis derived from the language inbuildRuntimeSpec(entrypointForLanguage: TypeScript →main.js, Python →main.py), rather than carried on the scaffold input.manager.tsx—installRuntimeDependenciesgained apackage.json→npm installbranch.codezip.ts—project devmaps a compiled.jsentrypoint back to its.tssource fortsx watch.Entrypoint note
The AgentCore
NODE_22runtime requires a.jsentrypoint; the deploy packager (@aws/agentcore-cdk) compilesmain.ts→main.jsvia esbuild at synth. So the runtime spec entrypoint ismain.jswhile the scaffolded source ismain.ts;project devruns the.tssource directly.package.json version pinning
Template dependencies are pinned with
~(patch-only) to avoid pulling breaking minor bumps into customer projects.Verification
Built the binary with
bun run compile:linux-x64and exercised the compiled CLI end to end against a dev AWS account (us-east-1).Automated checks
project dev+ curl (headless)project deploy+ aws cli invoke(Test stack deleted after verification.)
Validation — TypeScript without strands is rejected
Memory works both ways:
--memory noneomits thememory/dir and the memory import frommain.ts; the default (longAndShortTerm) wiresmemory/memory.tswithMEMORY_<NAME>_IDand all four strategy namespaces.How to test