@takutakahashi/claude-agentapi 0.9.0

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.
Files changed (118) hide show
  1. package/.claude/config.json.example +88 -0
  2. package/.env.example +97 -0
  3. package/LICENSE +21 -0
  4. package/README.md +815 -0
  5. package/bin/cli.js +78 -0
  6. package/dist/__tests__/routes/action.test.d.ts +2 -0
  7. package/dist/__tests__/routes/action.test.d.ts.map +1 -0
  8. package/dist/__tests__/routes/action.test.js +262 -0
  9. package/dist/__tests__/routes/action.test.js.map +1 -0
  10. package/dist/__tests__/routes/message.test.d.ts +2 -0
  11. package/dist/__tests__/routes/message.test.d.ts.map +1 -0
  12. package/dist/__tests__/routes/message.test.js +94 -0
  13. package/dist/__tests__/routes/message.test.js.map +1 -0
  14. package/dist/__tests__/routes/messages.test.d.ts +2 -0
  15. package/dist/__tests__/routes/messages.test.d.ts.map +1 -0
  16. package/dist/__tests__/routes/messages.test.js +105 -0
  17. package/dist/__tests__/routes/messages.test.js.map +1 -0
  18. package/dist/__tests__/routes/status.test.d.ts +2 -0
  19. package/dist/__tests__/routes/status.test.d.ts.map +1 -0
  20. package/dist/__tests__/routes/status.test.js +56 -0
  21. package/dist/__tests__/routes/status.test.js.map +1 -0
  22. package/dist/__tests__/routes/tool_status.test.d.ts +2 -0
  23. package/dist/__tests__/routes/tool_status.test.d.ts.map +1 -0
  24. package/dist/__tests__/routes/tool_status.test.js +93 -0
  25. package/dist/__tests__/routes/tool_status.test.js.map +1 -0
  26. package/dist/__tests__/services/session.test.d.ts +2 -0
  27. package/dist/__tests__/services/session.test.d.ts.map +1 -0
  28. package/dist/__tests__/services/session.test.js +121 -0
  29. package/dist/__tests__/services/session.test.js.map +1 -0
  30. package/dist/__tests__/types/api.test.d.ts +2 -0
  31. package/dist/__tests__/types/api.test.d.ts.map +1 -0
  32. package/dist/__tests__/types/api.test.js +256 -0
  33. package/dist/__tests__/types/api.test.js.map +1 -0
  34. package/dist/__tests__/utils/config.test.d.ts +2 -0
  35. package/dist/__tests__/utils/config.test.d.ts.map +1 -0
  36. package/dist/__tests__/utils/config.test.js +72 -0
  37. package/dist/__tests__/utils/config.test.js.map +1 -0
  38. package/dist/__tests__/utils/logger.test.d.ts +2 -0
  39. package/dist/__tests__/utils/logger.test.d.ts.map +1 -0
  40. package/dist/__tests__/utils/logger.test.js +56 -0
  41. package/dist/__tests__/utils/logger.test.js.map +1 -0
  42. package/dist/__tests__/utils/sse.test.d.ts +2 -0
  43. package/dist/__tests__/utils/sse.test.d.ts.map +1 -0
  44. package/dist/__tests__/utils/sse.test.js +76 -0
  45. package/dist/__tests__/utils/sse.test.js.map +1 -0
  46. package/dist/index.d.ts +2 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +69 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/routes/action.d.ts +3 -0
  51. package/dist/routes/action.d.ts.map +1 -0
  52. package/dist/routes/action.js +106 -0
  53. package/dist/routes/action.js.map +1 -0
  54. package/dist/routes/events.d.ts +3 -0
  55. package/dist/routes/events.d.ts.map +1 -0
  56. package/dist/routes/events.js +27 -0
  57. package/dist/routes/events.js.map +1 -0
  58. package/dist/routes/message.d.ts +3 -0
  59. package/dist/routes/message.d.ts.map +1 -0
  60. package/dist/routes/message.js +69 -0
  61. package/dist/routes/message.js.map +1 -0
  62. package/dist/routes/messages.d.ts +3 -0
  63. package/dist/routes/messages.d.ts.map +1 -0
  64. package/dist/routes/messages.js +15 -0
  65. package/dist/routes/messages.js.map +1 -0
  66. package/dist/routes/status.d.ts +3 -0
  67. package/dist/routes/status.d.ts.map +1 -0
  68. package/dist/routes/status.js +12 -0
  69. package/dist/routes/status.js.map +1 -0
  70. package/dist/routes/tool_status.d.ts +3 -0
  71. package/dist/routes/tool_status.d.ts.map +1 -0
  72. package/dist/routes/tool_status.js +14 -0
  73. package/dist/routes/tool_status.js.map +1 -0
  74. package/dist/server.d.ts +3 -0
  75. package/dist/server.d.ts.map +1 -0
  76. package/dist/server.js +50 -0
  77. package/dist/server.js.map +1 -0
  78. package/dist/services/agent.d.ts +45 -0
  79. package/dist/services/agent.d.ts.map +1 -0
  80. package/dist/services/agent.js +910 -0
  81. package/dist/services/agent.js.map +1 -0
  82. package/dist/services/metrics.d.ts +74 -0
  83. package/dist/services/metrics.d.ts.map +1 -0
  84. package/dist/services/metrics.js +219 -0
  85. package/dist/services/metrics.js.map +1 -0
  86. package/dist/services/session.d.ts +14 -0
  87. package/dist/services/session.d.ts.map +1 -0
  88. package/dist/services/session.js +49 -0
  89. package/dist/services/session.js.map +1 -0
  90. package/dist/types/agent.d.ts +12 -0
  91. package/dist/types/agent.d.ts.map +1 -0
  92. package/dist/types/agent.js +2 -0
  93. package/dist/types/agent.js.map +1 -0
  94. package/dist/types/api.d.ts +161 -0
  95. package/dist/types/api.d.ts.map +1 -0
  96. package/dist/types/api.js +74 -0
  97. package/dist/types/api.js.map +1 -0
  98. package/dist/types/config.d.ts +164 -0
  99. package/dist/types/config.d.ts.map +1 -0
  100. package/dist/types/config.js +6 -0
  101. package/dist/types/config.js.map +1 -0
  102. package/dist/utils/config.d.ts +15 -0
  103. package/dist/utils/config.d.ts.map +1 -0
  104. package/dist/utils/config.js +350 -0
  105. package/dist/utils/config.js.map +1 -0
  106. package/dist/utils/logger.d.ts +10 -0
  107. package/dist/utils/logger.d.ts.map +1 -0
  108. package/dist/utils/logger.js +22 -0
  109. package/dist/utils/logger.js.map +1 -0
  110. package/dist/utils/sse.d.ts +12 -0
  111. package/dist/utils/sse.d.ts.map +1 -0
  112. package/dist/utils/sse.js +43 -0
  113. package/dist/utils/sse.js.map +1 -0
  114. package/dist/utils/telemetry.d.ts +20 -0
  115. package/dist/utils/telemetry.d.ts.map +1 -0
  116. package/dist/utils/telemetry.js +68 -0
  117. package/dist/utils/telemetry.js.map +1 -0
  118. package/package.json +81 -0
@@ -0,0 +1,88 @@
1
+ {
2
+ "mcpServers": {
3
+ "example-stdio-server": {
4
+ "type": "stdio",
5
+ "command": "node",
6
+ "args": ["/path/to/mcp-server.js"],
7
+ "env": {
8
+ "API_KEY": "your-api-key-here",
9
+ "DEBUG": "true"
10
+ },
11
+ "disabled": false
12
+ },
13
+ "example-http-server": {
14
+ "type": "http",
15
+ "url": "https://api.example.com/mcp",
16
+ "headers": {
17
+ "Authorization": "Bearer ${API_TOKEN}"
18
+ },
19
+ "disabled": false
20
+ },
21
+ "example-sse-server": {
22
+ "type": "sse",
23
+ "url": "https://api.example.com/mcp/sse",
24
+ "headers": {
25
+ "Authorization": "Bearer ${API_TOKEN}"
26
+ },
27
+ "disabled": false
28
+ },
29
+ "disabled-server": {
30
+ "command": "python",
31
+ "args": ["-m", "mcp_server"],
32
+ "disabled": true
33
+ }
34
+ },
35
+ "allowedTools": [
36
+ "mcp__example-stdio-server__*",
37
+ "mcp__example-http-server__*",
38
+ "mcp__example-sse-server__query"
39
+ ],
40
+ "env": {
41
+ "ENABLE_TOOL_SEARCH": "auto"
42
+ },
43
+ "plugins": {
44
+ "example-plugin": {
45
+ "enabled": true,
46
+ "config": {
47
+ "option1": "value1",
48
+ "option2": true
49
+ }
50
+ }
51
+ },
52
+ "skills": {
53
+ "example-skill": {
54
+ "enabled": true,
55
+ "config": {
56
+ "customOption": "customValue"
57
+ }
58
+ }
59
+ },
60
+ "hooks": {
61
+ "user-prompt-submit-hook": {
62
+ "command": "bash",
63
+ "args": ["-c", "echo 'User prompt submitted'"],
64
+ "env": {
65
+ "HOOK_TYPE": "user-prompt-submit"
66
+ }
67
+ },
68
+ "tool-call-hook": {
69
+ "command": "node",
70
+ "args": ["/path/to/tool-call-logger.js"]
71
+ }
72
+ },
73
+ "commands": {
74
+ "deploy": {
75
+ "command": "bash",
76
+ "args": ["-c", "npm run deploy"],
77
+ "description": "Deploy the application to production",
78
+ "env": {
79
+ "NODE_ENV": "production"
80
+ }
81
+ },
82
+ "test": {
83
+ "command": "npm",
84
+ "args": ["test"],
85
+ "description": "Run the test suite"
86
+ }
87
+ }
88
+ }
package/.env.example ADDED
@@ -0,0 +1,97 @@
1
+ # Server Configuration
2
+ PORT=3000
3
+ HOST=localhost
4
+
5
+ # Claude Agent SDK Configuration
6
+ # Set to 1 to use AWS Bedrock instead of Anthropic API
7
+ CLAUDE_CODE_USE_BEDROCK=1
8
+
9
+ # Claude Model Configuration
10
+ CLAUDE_MODEL=claude-sonnet-4-5-20250929
11
+
12
+ # AWS Bedrock Configuration (required when CLAUDE_CODE_USE_BEDROCK=1)
13
+ AWS_REGION=us-east-1
14
+ # AWS_ACCESS_KEY_ID=your_access_key_id
15
+ # AWS_SECRET_ACCESS_KEY=your_secret_access_key
16
+ # AWS_SESSION_TOKEN=your_session_token (optional)
17
+
18
+ # Anthropic API Configuration (required when CLAUDE_CODE_USE_BEDROCK is not set)
19
+ # Use either API Key or OAuth Token (not both)
20
+ # ANTHROPIC_API_KEY=your_anthropic_api_key
21
+ # ANTHROPIC_OAUTH_TOKEN=your_oauth_token
22
+
23
+ # Logging
24
+ DEBUG=false
25
+
26
+ # Message History Configuration
27
+ MAX_MESSAGE_HISTORY=100
28
+
29
+ # Telemetry Configuration
30
+ # Enable OpenTelemetry metrics export to Prometheus
31
+ # Set to 1 to enable telemetry collection
32
+ # CLAUDE_CODE_ENABLE_TELEMETRY=1
33
+
34
+ # Prometheus metrics server port
35
+ # PROMETHEUS_PORT=9464
36
+
37
+ # Agent Permission Configuration
38
+ # Working directory for the agent (defaults to current working directory)
39
+ # CLAUDE_WORKING_DIRECTORY=/path/to/your/project
40
+
41
+ # Permission mode for the agent
42
+ # Options: default, acceptEdits, bypassPermissions
43
+ # - default: Standard permission checks (prompt for confirmations)
44
+ # - acceptEdits: Automatically approve file edits
45
+ # - bypassPermissions: Skip all permission checks (use with caution!)
46
+ # CLAUDE_PERMISSION_MODE=default
47
+
48
+ # DANGEROUSLY_SKIP_PERMISSIONS=true is equivalent to CLAUDE_PERMISSION_MODE=bypassPermissions
49
+ # This can be set via CLI option: --dangerously-skip-permissions
50
+ # DANGEROUSLY_SKIP_PERMISSIONS=false
51
+
52
+ # ====================================
53
+ # MCP Servers and Plugins Configuration
54
+ # ====================================
55
+ # This server supports Claude Code compatible .claude/config.json files
56
+ # Configuration files are loaded in the following order (later configs override earlier ones):
57
+ # 1. Global: ~/.claude/config.json
58
+ # 2. Project: .claude/config.json (current working directory)
59
+ # 3. Working directory: {CLAUDE_WORKING_DIRECTORY}/.claude/config.json
60
+ #
61
+ # Example .claude/config.json structure:
62
+ # {
63
+ # "mcpServers": {
64
+ # "example-server": {
65
+ # "command": "node",
66
+ # "args": ["/path/to/mcp-server.js"],
67
+ # "env": {
68
+ # "API_KEY": "your-api-key"
69
+ # },
70
+ # "disabled": false
71
+ # }
72
+ # },
73
+ # "plugins": {
74
+ # "plugin-name": {
75
+ # "enabled": true,
76
+ # "config": {
77
+ # "option": "value"
78
+ # }
79
+ # }
80
+ # },
81
+ # "hooks": {
82
+ # "user-prompt-submit-hook": {
83
+ # "command": "bash",
84
+ # "args": ["-c", "echo 'Prompt submitted'"]
85
+ # }
86
+ # },
87
+ # "commands": {
88
+ # "test": {
89
+ # "command": "npm",
90
+ # "args": ["test"],
91
+ # "description": "Run tests"
92
+ # }
93
+ # }
94
+ # }
95
+ #
96
+ # Note: Environment variables in this .env file take precedence over config files
97
+ # for core settings like CLAUDE_WORKING_DIRECTORY and CLAUDE_PERMISSION_MODE
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Takuya TAKAHASHI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.