Skip to content

feat(templates): add strands-ts TypeScript runtime template - #7

Draft
Hweinstock wants to merge 5 commits into
memory-in-templatesfrom
feat/strands-ts-template
Draft

feat(templates): add strands-ts TypeScript runtime template#7
Hweinstock wants to merge 5 commits into
memory-in-templatesfrom
feat/strands-ts-template

Conversation

@Hweinstock

Copy link
Copy Markdown
Owner

Summary

Adds first-class TypeScript support to the CLI via a new strands-ts project template, ported from the upstream src/assets/typescript/http/strands assets 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

Problem

There is no support for TS. We want to first support strands TS templates from the original CLI (src/assets/typescript/http/strands). Containers are out of scope for the initial PR.

Definition of Done

  • agentcore project create --template strands-ts yields a working TypeScript agent, usable in agentcore project dev (curl in another terminal) and agentcore project deploy (invoke via aws cli).
  • Validation errors if you select typescript but not with strands (or other options).
  • Memory can be added and comes with the default option wired in; validation works with memory or no memory.

Details

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 Python strands-http-python template.
  • runtime.ts — new strands/TypeScript resolver (+ toNpmPackageName), mirroring the Python strands resolver (same memory-dir filter and spec shape).
  • shortcuts.ts — new strands-ts shortcut (CodeZip, NODE_22, longAndShortTerm memory).
  • types.ts / create / add runtime"TypeScript" added to the language enum; a superRefine requires framework === "strands" for TypeScript; entrypoint/runtimeVersion derived per language.
  • manager.tsxinstallRuntimeDependencies gained a package.jsonnpm install branch.
  • codezip.tsproject dev maps a compiled .js entrypoint back to its .ts source for tsx watch.

Entrypoint note

The AgentCore NODE_22 runtime requires a .js entrypoint; the deploy packager (@aws/agentcore-cdk) compiles main.tsmain.js via esbuild at synth. So the runtime spec entrypoint is main.js while the scaffolded source is main.ts; project dev runs the .ts source 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-x64 and exercised the compiled CLI end to end against a dev AWS account (us-east-1).

Automated checks

bun run typecheck   # clean
bun run lint:check  # clean
bun run format:check # clean
bun test            # 2217 pass, 0 fail (3 snapshots)

project dev + curl (headless)

$ agentcore project dev --mode headless --agent strands_agent --port 8081 --no-traces
... Server listening on port 8081
$ curl -sN -X POST http://127.0.0.1:8081/invocations \
    -H 'Content-Type: application/json' -H 'Accept: text/event-stream' \
    -H 'x-amzn-bedrock-agentcore-runtime-session-id: strands-ts-e2e-session-000000000002' \
    -d '{"prompt":"Reply with exactly: STRANDS_TS_DEV_OK"}'
data: "STRANDS_TS_DEV"
data: "_OK"

project deploy + aws cli invoke

$ agentcore project deploy --target default
... Deploying AgentCore-TsE2E-default
ApplicationAgentStrandsAgentRuntimeArnOutput...: arn:aws:bedrock-agentcore:us-east-1:<account>:runtime/TsE2E_strands_agent-<id>
# CloudFormation: Runtime + Memory CREATE_COMPLETE

$ aws bedrock-agentcore invoke-agent-runtime --region us-east-1 \
    --agent-runtime-arn arn:aws:bedrock-agentcore:us-east-1:<account>:runtime/TsE2E_strands_agent-<id> \
    --runtime-session-id strands-ts-deploy-session-000000000000001 \
    --payload fileb://payload.json --content-type application/json \
    --accept text/event-stream out.txt
{ "runtimeSessionId": "...", "contentType": "text/event-stream", "statusCode": 200 }
$ cat out.txt
data: "STRANDS_TS_DEPLOY"
data: "_OK"

(Test stack deleted after verification.)

Validation — TypeScript without strands is rejected

$ agentcore project create --name Bad --language TypeScript --framework none \
    --build CodeZip --model-provider Bedrock
Error: ✖ TypeScript runtimes are only supported with the strands framework
  → at framework

Memory works both ways: --memory none omits the memory/ dir and the memory import from main.ts; the default (longAndShortTerm) wires memory/memory.ts with MEMORY_<NAME>_ID and all four strategy namespaces.

How to test

git fetch fork feat/strands-ts-template && git checkout feat/strands-ts-template
bun install
bun test
bun run compile:linux-x64
BIN=./dist/bin/agentcore-linux-x64

# 1. Create + dev
mkdir /tmp/tsdemo && cd /tmp/tsdemo
$BIN project create --name TsDemo --template strands-ts --skip-git
cd TsDemo
$BIN project dev --mode headless --agent strands_agent --port 8081 --no-traces &
curl -sN -X POST http://127.0.0.1:8081/invocations \
  -H 'Content-Type: application/json' -H 'Accept: text/event-stream' \
  -H 'x-amzn-bedrock-agentcore-runtime-session-id: strands-ts-demo-session-000000000001' \
  -d '{"prompt":"hello"}'

# 2. Validation error
$BIN project create --name Bad --language TypeScript --framework none \
  --build CodeZip --model-provider Bedrock   # -> validation error

# 3. Deploy (add a default target to agentcore/aws-targets.json, then)
$BIN project deploy --target default

@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant