@aws-blocks/bb-agent 0.1.2 → 0.1.3

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/DESIGN.md ADDED
@@ -0,0 +1,66 @@
1
+ # Agent — Design
2
+
3
+ Design document for the Agent Building Block. For usage, see [README.md](./README.md).
4
+
5
+ **Package:** `@aws-blocks/bb-agent`
6
+ **Type:** Composite (uses DistributedTable, Realtime, AsyncJob, FileBucket internally)
7
+ **AWS Services:** Bedrock, DynamoDB, S3, SQS, AppSync Events
8
+ **Agent Framework:** [Strands Agents SDK](https://strandsagents.com/)
9
+
10
+ ## Architecture
11
+
12
+ The Agent BB is a composite Building Block — it creates and manages 4 internal BBs:
13
+
14
+ | Internal BB | Purpose | Created when |
15
+ |-------------|---------|-------------|
16
+ | **FileBucket** | Session persistence (Strands SessionManager) | Always |
17
+ | **DistributedTable** | Frontend message history | `inferenceOnly: false` |
18
+ | **Realtime** | Streaming chunks to caller | Always |
19
+ | **AsyncJob** | Async agent execution (avoids 29s API Gateway timeout) | Always |
20
+
21
+ ```
22
+ stream() → AsyncJob.submit() → returns { channelId } immediately
23
+
24
+ AsyncJob consumer
25
+
26
+ runAgent() → Strands agent loop → publishes chunks to Realtime
27
+ → persists messages to DistributedTable
28
+ → SessionManager saves state to FileBucket
29
+ ```
30
+
31
+ ## Session Persistence
32
+
33
+ Two storage backends, same FileBucket BB:
34
+ - **AWS:** Strands' native `S3Storage` → FileBucket-provisioned S3 bucket
35
+ - **Local:** Custom `FileBucketSnapshotStorage` → FileBucket mock (mirrors S3Storage key layout exactly)
36
+
37
+ ## Infrastructure (CDK)
38
+
39
+ The CDK class mirrors the runtime's BB creation:
40
+ - **Bedrock IAM:** `InvokeModel` + `InvokeModelWithResponseStream` on all foundation models and inference profiles
41
+ - **FileBucket:** `${id}-sessions` — session snapshot storage
42
+ - **DistributedTable:** `${id}-messages` — conversation history (only when `inferenceOnly: false`)
43
+ - **Realtime:** `${id}-rt` — streaming namespace `chunks`
44
+ - **AsyncJob:** `${id}-job` — job payload: `{ message, conversationId?, channelId }`
45
+
46
+ > **Note:** Internal Building Blocks are created on the parent scope (not `this`) to ensure correct nested-scope resolution on AWS.
47
+
48
+ ## Model Providers
49
+
50
+ All providers are Strands model implementations, mapped from Blocks's `ModelConfig` via `model-factory.ts`:
51
+
52
+ | Provider | Strands Class | Use Case |
53
+ |----------|--------------|----------|
54
+ | `canned` | `CannedProvider` (custom) | Local dev — keyword-based responses with tool call support |
55
+ | `bedrock` | `BedrockModel` | AWS — Amazon Bedrock models |
56
+ | `openai-api` | `OpenAIModel` | Any OpenAI-compatible endpoint (OpenAI, Ollama, vLLM) |
57
+
58
+ ## CannedProvider
59
+
60
+ Custom Strands model provider for local development. No network, no API keys, no costs.
61
+
62
+ - Returns instant keyword-based responses (e.g., prompt contains "weather" → weather response, otherwise a default canned response)
63
+ - Streams word by word, matching the same `ModelStreamEvent` protocol as Bedrock/OpenAI
64
+ - Triggers tool calls when the prompt mentions a tool name — splits camelCase names into words (e.g., "weather" matches `getWeather`) and emits Strands `toolUse` events
65
+ - After Strands executes the tool and sends the result back, returns a fixed acknowledgment (`"I called the tool and got a result."`)
66
+ - Token usage reports zeros (no real model call)
package/README.md CHANGED
@@ -6,6 +6,8 @@ AI agent with streaming, tool calling, and conversation persistence. Powered by
6
6
 
7
7
  **Requires:** `zod` ^4.0.0 as a peer dependency. Tool parameters use Zod schemas for validation. If you see `ZodType missing properties` errors, check your zod version.
8
8
 
9
+ > Design & mock parity details: [DESIGN.md](./DESIGN.md)
10
+
9
11
  ## Quick Start
10
12
 
11
13
  ```typescript
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export declare const BB_NAME = "Agent";
2
- export declare const BB_VERSION = "0.1.2";
2
+ export declare const BB_VERSION = "0.1.3";
3
3
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // Auto-generated by scripts/generate-version.mjs — do not edit manually
2
2
  export const BB_NAME = 'Agent';
3
- export const BB_VERSION = '0.1.2';
3
+ export const BB_VERSION = '0.1.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-blocks/bb-agent",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "author": "Amazon Web Services",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -8,6 +8,7 @@
8
8
  "dist",
9
9
  "MODELS.md",
10
10
  "README.md",
11
+ "DESIGN.md",
11
12
  "src",
12
13
  "LICENSE"
13
14
  ],
@@ -33,11 +34,11 @@
33
34
  "test": "node --test dist/index.test.js"
34
35
  },
35
36
  "dependencies": {
36
- "@aws-blocks/bb-async-job": "^0.1.1",
37
- "@aws-blocks/bb-distributed-table": "^0.1.1",
38
- "@aws-blocks/bb-file-bucket": "^0.1.1",
39
- "@aws-blocks/bb-logger": "^0.1.1",
40
- "@aws-blocks/bb-realtime": "^0.1.1",
37
+ "@aws-blocks/bb-async-job": "^0.1.2",
38
+ "@aws-blocks/bb-distributed-table": "^0.1.3",
39
+ "@aws-blocks/bb-file-bucket": "^0.1.2",
40
+ "@aws-blocks/bb-logger": "^0.1.2",
41
+ "@aws-blocks/bb-realtime": "^0.1.2",
41
42
  "@aws-blocks/core": "^0.1.1",
42
43
  "@aws-sdk/client-bedrock": "^3.700.0",
43
44
  "@strands-agents/sdk": "~1.3.0",
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // Auto-generated by scripts/generate-version.mjs — do not edit manually
2
2
  export const BB_NAME = 'Agent';
3
- export const BB_VERSION = '0.1.2';
3
+ export const BB_VERSION = '0.1.3';