-
Notifications
You must be signed in to change notification settings - Fork 0
Add the Claude Agent SDK Sample #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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', | ||
| }, | ||
| } | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(), | ||
| }, | ||
| }); | ||
|
|
||
| for await (const message of stream) { | ||
| // 実行途中の出力をログ表示 | ||
| console.log(message); | ||
| } | ||
|
|
||
| console.log('\n処理を完了しました。'); | ||
| })(); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.*" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| }, | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.