Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ updates:
- '/common/backend/'
- '/agents/agent-mastra/'
- '/agents/agent-voltagent/'
- '/agents/agent-sdk/'
- '/basic/cdk/'
- '/basic/app/'
- '/mcp/clients/langgraph-mcp-client/'
Expand Down
8 changes: 8 additions & 0 deletions agents/agent-sdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
output.txt
node_modules
dist
.mastra
.env.development
.env*
*.db
output.ts
63 changes: 63 additions & 0 deletions agents/agent-sdk/eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { defineConfig } from 'eslint/config';
import eslint from '@eslint/js';
import stylistic from '@stylistic/eslint-plugin';
import tseslint from 'typescript-eslint';
import eslintImport from 'eslint-plugin-import';

import { includeIgnoreFile } from '@eslint/compat';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, './.gitignore');

export default defineConfig(
includeIgnoreFile(gitignorePath),
{
ignores: [
'**/*.d.ts',
'*.{js,jsx}',
'src/tsconfig.json',
'src/stories',
'**/*.css',
'node_modules/**/*',
'./.next/*',
'out',
'.storybook',
'dist',
'.vinxi',
'.output',
],
},
eslint.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
{
files: ['src/**/*.{ts,tsx}'],
languageOptions: {
parser: tseslint.parser,
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
projectService: true,
tsconfigRootDir: __dirname,
project: [
'./tsconfig.json',
'./tsconfig-eslint.json',
],
},
},
plugins: {
'@stylistic': stylistic,
},
extends: [eslintImport.flatConfigs.recommended, eslintImport.flatConfigs.typescript],
rules: {
'@stylistic/semi': ['error', 'always'],
'@stylistic/indent': ['error', 2],
'@stylistic/comma-dangle': ['error', 'always-multiline'],
'@stylistic/quotes': ['error', 'single'],
'import/no-unresolved': 'off',
},
}
);
43 changes: 43 additions & 0 deletions agents/agent-sdk/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "agent-sdk",
"version": "1.0.0",
"description": "Claude Agent SDK sample implementation for TypeScript",
"main": "dist/index.js",
"type": "module",
"scripts": {
"build": "tsc --build --clean && tsc",
"clean": "tsc --build --clean",
"watch": "tsc -w",
"test": "vitest run --passWithNoTests",
"dev": "tsx src/index.ts",
"lint": "eslint .",
"lint-fix": "eslint . --fix"
},
"devDependencies": {
"@eslint/compat": "^1.4.1",
"@eslint/js": "^9.39.1",
"@stylistic/eslint-plugin": "^5.5.0",
"@types/node": "^22.19.0",
"@types/uuid": "^10.0.0",
"@vitest/eslint-plugin": "^1.4.1",
"dotenv": "^16.6.1",
"esbuild": "^0.25.12",
"eslint": "^9.39.1",
"eslint-import-resolver-typescript": "^4.4.4",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-promise": "^7.2.1",
"jiti": "^2.6.1",
"tsx": "^4.20.6",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.3",
"vite": "^7.2.2",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^4.0.8"
},
"dependencies": {
"@anthropic-ai/claude-agent-sdk": "^0.1.30",
"source-map-support": "^0.5.21",
"uuid": "^13.0.0",
"zod": "^4.1.12"
}
}
20 changes: 20 additions & 0 deletions agents/agent-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { query } from '@anthropic-ai/claude-agent-sdk';

(async () => {
const stream = query({
prompt:
'Node.js のプログラムでフィボナッチ数列を出力するプログラムを TypeScript 書いて、現在の作業ディレクトリに output.ts という名前で保存してください。ファイルパスは相対パスで ./output.ts としてください。',
options: {
// systemPrompt: '',
allowedTools: ['Write'],
cwd: process.cwd(),
},
Comment thread
poad marked this conversation as resolved.
});

for await (const message of stream) {
// 実行途中の出力をログ表示
console.log(message);
}

console.log('\n処理を完了しました。');
})();
10 changes: 10 additions & 0 deletions agents/agent-sdk/tsconfig-eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": ["./tsconfig.json"],
"compilerOptions": {
"noEmit": true
},
"exclude": [
"node_modules",
"cdk.out"
]
}
44 changes: 44 additions & 0 deletions agents/agent-sdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"compilerOptions": {
"target": "esnext",
"module": "nodenext",
"lib": [
"esnext",
"dom"
],
"moduleResolution": "nodenext",
"moduleDetection": "force",
"resolveJsonModule": true,
"allowJs": true,
"esModuleInterop": true,
"isolatedModules": true,
"declaration": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": false,
"inlineSourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"skipLibCheck": true,
"outDir": "./dist",
"typeRoots": [
"./node_modules",
"./node_modules/@types"
],
"types": [
"node"
]
},
"exclude": [
"node_modules",
"cdk.out",
"*.config.*"
]
}
40 changes: 40 additions & 0 deletions agents/agent-sdk/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/// <reference types="vitest" />
/// <reference types="vite/client" />

import { defineConfig } from 'vitest/config';
import * as dotenv from 'dotenv';
import { resolve } from 'path';

export default defineConfig({
// モノレポ用の共通設定
resolve: {
alias: {
// パッケージ間の直接参照
'@llm-ts-example/common-core': resolve(__dirname, '../../common/core/src'),
'@llm-ts-example/common-backend': resolve(__dirname, '../../common/backend/src')
}
},
server: {
fs: {
// モノレポ内のファイルアクセスを許可
allow: ['..']
}
},
build: {
target: 'esnext',
rollupOptions: {
// ESModuleとして出力
output: {
format: 'es'
}
}
},
root: '.',
test: {
environment: 'node',
globals: true,
isolate: true,
env: dotenv.config({ path: '.env.test' }).parsed,
testTimeout: 30000,
},
});
Loading