Skip to content

Commit 7735873

Browse files
committed
Bumps node modules
1 parent ee353c7 commit 7735873

16 files changed

Lines changed: 1345 additions & 102 deletions

File tree

.github/dependabot.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ updates:
4848
default-days: 7
4949
allow:
5050
- dependency-type: all
51+
ignore:
52+
- dependency-name: typescript
53+
versions: ~7.0.0
5154
rebase-strategy: auto
5255
assignees:
5356
- poad

agents/agent-langchain-nextjs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"media-chrome": "^4.19.2",
7070
"motion": "^12.42.2",
7171
"nanoid": "^5.1.16",
72-
"next": "^16.2.11",
72+
"next": "^16.2.12",
7373
"react": "19.2.3",
7474
"react-dom": "19.2.3",
7575
"shiki": "^3.23.0",
@@ -87,7 +87,7 @@
8787
"@types/react": "^19.2.17",
8888
"@types/react-dom": "^19.2.3",
8989
"eslint": "^10.8.0",
90-
"eslint-config-next": "^16.2.11",
90+
"eslint-config-next": "^16.2.12",
9191
"eslint-import-resolver-typescript": "^4.4.5",
9292
"eslint-plugin-import-x": "^4.17.1",
9393
"eslint-plugin-promise": "^7.3.0",

agents/agent-strands/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.agentcore-staging

agents/agent-strands/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Agent(Bedrock AgentCore Runtime 上で動作する AI エージェント)
2+
3+
[Strands Agents SDK](https://github.com/strands-agents/sdk)(TypeScript)を使って実装された、Amazon Bedrock AgentCore Runtime 上で動作する AI エージェントです。AWS のシステムアーキテクチャ設計を支援するアシスタントとして動作します。
4+
5+
## 概要
6+
7+
- **モデル**:Amazon Bedrock の基盤モデル(呼び出し時にモデル ID を指定、デフォルトは `us.amazon.nova-micro-v1:0`
8+
- **リージョン**`us-east-1`
9+
- **ツール**`aws-knowledge-mcp-server``https://knowledge-mcp.global.api.aws`)を MCP(Model Context Protocol)経由で利用し、AWS ドキュメントに基づいた回答・アーキテクチャ提案を行う
10+
- **システムプロンプト**:AWS 知識に基づいて回答し、情報がなければ「わからない」と明言する/出典を明示する/複数のアーキテクチャパターンを提示する/質問と同じ言語で応答する、という方針で構成
11+
- **実行環境**`bedrock-agentcore` パッケージの `BedrockAgentCoreApp` を使い、AgentCore Runtime の呼び出し(invocation)ハンドラとしてリクエストを受け付け、SSE(Server-Sent Events)でテキストデルタをストリーミング返却
12+
13+
## ディレクトリ構成
14+
15+
agent/
16+
├── src/
17+
│ ├── index.ts # AgentCore Runtime のエントリポイント(リクエスト受付・ストリーミング応答)
18+
│ ├── agent.ts # Strands Agent の生成・OTel トレーサーの初期化
19+
│ ├── logger.ts # AWS Lambda Powertools ベースのロガー
20+
│ ├── tools/
21+
│ │ └── aws-tool.ts # aws-knowledge-mcp-server への MCP クライアント/ツール一覧取得
22+
│ └── observability/
23+
│ ├── exporters.ts # OTel の Trace/Logs/Metrics エクスポーター初期化(Databricks 送信)
24+
│ └── access-token-manager.ts # Databricks OAuth M2M アクセストークンのメモリキャッシュ管理
25+
├── package.json
26+
├── tsconfig.json
27+
└── vite.config.ts
28+
29+
## リクエスト仕様
30+
31+
`POST` で送信されたペイロードは以下のスキーマで検証されます。
32+
33+
| フィールド || デフォルト | 説明 |
34+
| --- | --- | --- | --- |
35+
| `message` | string | `"こんにちは!"` | ユーザーからの入力メッセージ |
36+
| `model` | string | `"us.amazon.nova-micro-v1:0"` | 使用する Bedrock モデル ID |
37+
38+
応答は SSE イベント(`event: message``data: { text: string }`)としてストリーミングされます。
39+
40+
## Observability(可観測性)
41+
42+
`ENABLE_TRACING` / `ENABLE_LOGS` / `ENABLE_METRICS` の環境変数(`"true"` 文字列)により、OpenTelemetry の Trace・Logs・Metrics をそれぞれ有効化できます。有効化した場合、Databricks の OTLP/HTTP エンドポイント(Unity Catalog テーブル)へエクスポートされます。
43+
44+
必要な環境変数:
45+
46+
| 環境変数 | 説明 |
47+
| --- | --- |
48+
| `DATABRICKS_WORKSPACE_URL` | Databricks ワークスペースの URL |
49+
| `DATABRICKS_OAUTH_CLIENT_ID` | サービスプリンシパルのクライアント ID |
50+
| `DATABRICKS_OAUTH_CLIENT_SECRET` | サービスプリンシパルのシークレット |
51+
| `DATABRICKS_UC_SCHEMA_NAME` | Unity Catalog のスキーマ名 |
52+
| `DATABRICKS_UC_TABLE_PREFIX` | 送信先テーブル名のプレフィックス(例:`{prefix}_otel_spans`|
53+
54+
Databricks 側の設定が不足している場合は Observability 機能をスキップし、通常どおりエージェントは動作します。
55+
56+
## よく使うコマンド
57+
58+
```bash
59+
pnpm build # rimraf で dist/.agentcore-staging をクリーンアップ → vite build → 本番用依存関係を .agentcore-staging に展開
60+
pnpm watch # ファイル変更を監視してビルド
61+
pnpm test # vitest によるユニットテスト
62+
pnpm lint # ESLint
63+
pnpm lint-fix # ESLint(自動修正)
64+
```
65+
66+
`pnpm build` で生成される `agent/.agentcore-staging` は、`cdk/``AgentCoreStack``AgentRuntimeArtifact.fromCodeAsset()`)から直接参照され、AgentCore Runtime のデプロイアセットとして使われます(ECR は使用しません)。
67+
68+
## 関連
69+
70+
- インフラ定義:[../cdk/README.md](../cdk/README.md)
71+
- チャット UI:[../frontend/README.md](../frontend/README.md)
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import path from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
import { defineConfig, includeIgnoreFile } from 'eslint/config';
4+
import eslint from '@eslint/js';
5+
import stylistic from '@stylistic/eslint-plugin';
6+
import {configs, parser} from 'typescript-eslint';
7+
import { importX, createNodeResolver } from 'eslint-plugin-import-x';
8+
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
9+
10+
const __filename = fileURLToPath(import.meta.url);
11+
const __dirname = path.dirname(__filename);
12+
const gitignorePath = path.resolve(__dirname, './.gitignore');
13+
14+
export default defineConfig(
15+
includeIgnoreFile(gitignorePath),
16+
{
17+
ignores: [
18+
'**/*.d.ts',
19+
'*.{js,jsx}',
20+
'src/tsconfig.json',
21+
'src/stories',
22+
'**/*.css',
23+
'node_modules/**/*',
24+
'./.next/*',
25+
'out',
26+
'.storybook',
27+
'dist',
28+
'.vinxi',
29+
'.output',
30+
],
31+
},
32+
importX.flatConfigs.recommended,
33+
importX.flatConfigs.typescript,
34+
{
35+
files: [
36+
'bin/**/*.ts',
37+
'lib/**/*.ts',
38+
'lambda/**/*.ts',
39+
'eslint.config.ts',
40+
'vitest.config.ts',
41+
],
42+
languageOptions: {
43+
parser,
44+
ecmaVersion: 'latest',
45+
sourceType: 'module',
46+
parserOptions: {
47+
tsconfigRootDir: __dirname,
48+
projectService: {
49+
allowDefaultProject: ['eslint.config.ts', 'vitest.config.ts'],
50+
},
51+
},
52+
},
53+
plugins: {
54+
'@stylistic': stylistic,
55+
},
56+
settings: {
57+
'import-x/resolver-next': [
58+
createTypeScriptImportResolver({
59+
alwaysTryTypes: true,
60+
}),
61+
createNodeResolver(),
62+
],
63+
},
64+
extends: [
65+
eslint.configs.recommended,
66+
configs.strict,
67+
configs.stylistic,
68+
],
69+
rules: {
70+
'@stylistic/semi': ['error', 'always'],
71+
'@stylistic/indent': ['error', 2],
72+
'@stylistic/comma-dangle': ['error', 'always-multiline'],
73+
'@stylistic/quotes': ['error', 'single'],
74+
75+
'import-x/order': [
76+
'error',
77+
{
78+
'groups': [
79+
// Imports of builtins are first
80+
'builtin',
81+
// Then sibling and parent imports. They can be mingled together
82+
['sibling', 'parent'],
83+
// Then index file imports
84+
'index',
85+
// Then any arcane TypeScript imports
86+
'object',
87+
// Then the omitted imports: internal, external, type, unknown
88+
],
89+
},
90+
],
91+
},
92+
},
93+
);

agents/agent-strands/package.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "agent-strands",
3+
"description": "",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"scripts": {
7+
"build": "rimraf dist && vite build",
8+
"watch": "vite -w",
9+
"test": "vitest run --passWithNoTests",
10+
"lint": "eslint .",
11+
"lint-fix": "eslint . --fix",
12+
"dev": "tsx src/index.ts"
13+
},
14+
"keywords": [],
15+
"author": "",
16+
"license": "ISC",
17+
"devDependencies": {
18+
"@eslint/js": "^10.0.1",
19+
"@stylistic/eslint-plugin": "^5.10.0",
20+
"@types/node": "24.10.1",
21+
"eslint": "^10.8.0",
22+
"eslint-import-resolver-typescript": "^4.4.5",
23+
"eslint-plugin-awscdk": "^4.4.0",
24+
"eslint-plugin-import-x": "^4.17.1",
25+
"eslint-plugin-promise": "^7.3.0",
26+
"jiti": "^2.7.0",
27+
"rimraf": "^6.1.3",
28+
"tsx": "^4.23.1",
29+
"typescript": "^6.0.3",
30+
"typescript-eslint": "^8.65.0",
31+
"vite": "^8.1.5"
32+
},
33+
"dependencies": {
34+
"@aws-lambda-powertools/logger": "^2.34.0",
35+
"@aws-sdk/credential-providers": "^3.1095.0",
36+
"@modelcontextprotocol/client": "^2.0.0",
37+
"@opentelemetry/api": "^1.9.1",
38+
"@opentelemetry/exporter-logs-otlp-proto": "^0.220.0",
39+
"@opentelemetry/exporter-metrics-otlp-http": "^0.220.0",
40+
"@opentelemetry/exporter-metrics-otlp-proto": "^0.220.0",
41+
"@opentelemetry/exporter-trace-otlp-http": "^0.220.0",
42+
"@opentelemetry/exporter-trace-otlp-proto": "^0.220.0",
43+
"@opentelemetry/resources": "^2.10.0",
44+
"@opentelemetry/sdk-logs": "^0.220.0",
45+
"@opentelemetry/sdk-metrics": "^2.10.0",
46+
"@opentelemetry/sdk-node": "^0.220.0",
47+
"@opentelemetry/sdk-trace-base": "^2.10.0",
48+
"@opentelemetry/sdk-trace-node": "^2.10.0",
49+
"@strands-agents/sdk": "^1.11.1",
50+
"uuid": "^14.0.1",
51+
"ws": "^8.21.1",
52+
"zod": "^4.4.3"
53+
}
54+
}

agents/agent-strands/src/agent.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { init } from './observability/exporters.js';
2+
import { tools } from './tools/aws-tool.js';
3+
import { Agent, BedrockModel } from '@strands-agents/sdk';
4+
import { setupTracer } from '@strands-agents/sdk/telemetry';
5+
import { NodeTracerProvider, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node';
6+
7+
const exporters = await init();
8+
if (exporters.trace) {
9+
const provider = new NodeTracerProvider({
10+
spanProcessors: [
11+
// Configure OTLP endpoint programmatically
12+
new SimpleSpanProcessor(
13+
exporters.trace,
14+
),
15+
],
16+
});
17+
setupTracer({
18+
provider,
19+
exporters: { otlp: true, console: false },
20+
});
21+
}
22+
23+
const createAgent = (
24+
{ model: modelId, session, user = 'anonymous' }:
25+
{ model: string, session: string, user?: string }
26+
) => {
27+
const model = new BedrockModel({
28+
region: 'us-east-1',
29+
modelId: modelId,
30+
maxTokens: 4096,
31+
});
32+
33+
return new Agent({
34+
model,
35+
id: 'general-agent',
36+
name: 'General Agent',
37+
systemPrompt: `
38+
MCP サーバーに、入力されたメッセージを渡して、返されたレスポンスを表示してください。
39+
`,
40+
traceAttributes: {
41+
'session.id': session,
42+
'user.id': user,
43+
},
44+
tools,
45+
printer: false,
46+
});
47+
};
48+
49+
const finalize = async () => {
50+
await exporters.flush();
51+
};
52+
53+
export { createAgent, finalize };

agents/agent-strands/src/index.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import readline from 'node:readline/promises';
2+
import { stdin as input, stdout as output } from "node:process";
3+
import { createAgent } from './agent.js';
4+
import { logger } from './logger.js';
5+
6+
const session = crypto.randomUUID();
7+
const rl = readline.createInterface({ input, output });
8+
9+
const agent = await createAgent({ model: 'global.amazon.nova-2-lite-v1:0', session });
10+
while (true) {
11+
const line = await rl.question("prompt or command: ");
12+
if (line.trim() === '/exit' || line.trim() === '/quit') {
13+
agent.cancel();
14+
console.log("Bye!");
15+
process.exit(0);
16+
}
17+
for await (const event of agent.stream(line)) {
18+
logger.trace('[Event]', event.type);
19+
if (event.type === 'modelStreamUpdateEvent') {
20+
if (event.event.type === 'modelContentBlockDeltaEvent' &&
21+
event.event.delta.type === 'textDelta') {
22+
if (event.event.delta.type === 'textDelta') {
23+
console.log({ event: 'message', data: { text: event.event.delta.text } });
24+
}
25+
}
26+
}
27+
}
28+
};

agents/agent-strands/src/logger.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { LogFormatter, LogItem, Logger } from '@aws-lambda-powertools/logger';
2+
import type {
3+
LogAttributes,
4+
UnformattedAttributes,
5+
} from '@aws-lambda-powertools/logger/types';
6+
7+
class LocalLogFormatter extends LogFormatter {
8+
public formatAttributes(
9+
attributes: UnformattedAttributes,
10+
additionalLogAttributes: LogAttributes,
11+
): LogItem {
12+
const baseAttributes = {
13+
logLevel: attributes.logLevel,
14+
timestamp: this.formatTimestamp(attributes.timestamp), // You can extend this function
15+
message: attributes.message,
16+
};
17+
const logItem = new LogItem({ attributes: baseAttributes });
18+
// add any attributes not explicitly defined
19+
logItem.addAttributes(additionalLogAttributes);
20+
return logItem;
21+
}
22+
}
23+
24+
export const logger = new Logger({
25+
logFormatter: new LocalLogFormatter(),
26+
});
27+
28+
export default logger;

0 commit comments

Comments
 (0)