@bamboo-ai/claude 0.1.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.
- package/dist/bin/cli.js +46 -0
- package/package.json +46 -0
package/dist/bin/cli.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
5
|
+
const core_1 = require("@bamboo-ai/core");
|
|
6
|
+
const API_BASE = process.env.BAMBOO_API_BASE || 'https://api.bamboonode.cn';
|
|
7
|
+
const AUTH_URL = process.env.BAMBOO_AUTH_URL || 'https://www.bamboonode.cn';
|
|
8
|
+
async function main() {
|
|
9
|
+
try {
|
|
10
|
+
const authService = new core_1.AuthService(API_BASE, AUTH_URL);
|
|
11
|
+
const configService = new core_1.ConfigService(authService, API_BASE);
|
|
12
|
+
const processManager = new core_1.ProcessManager();
|
|
13
|
+
// 1. Resolve claude binary from PATH
|
|
14
|
+
const claudeBin = (0, core_1.resolveBin)('claude', '@anthropic-ai/claude-code');
|
|
15
|
+
// 2. Check Login
|
|
16
|
+
let apiKey = await authService.getToken();
|
|
17
|
+
if (!apiKey) {
|
|
18
|
+
console.log('Bamboo: Not logged in. Starting login flow...');
|
|
19
|
+
try {
|
|
20
|
+
apiKey = await authService.login();
|
|
21
|
+
console.log('Bamboo: Login successful!');
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
console.error(`Bamboo: Login failed — ${err.message || err}`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// 3. Get Config
|
|
29
|
+
console.log('Bamboo: Fetching configuration for Claude...');
|
|
30
|
+
const config = await configService.getConfig('claude');
|
|
31
|
+
// 4. Prepare Environment
|
|
32
|
+
const env = {
|
|
33
|
+
ANTHROPIC_API_KEY: config.apiKey,
|
|
34
|
+
ANTHROPIC_BASE_URL: config.baseUrl,
|
|
35
|
+
NODE_TLS_REJECT_UNAUTHORIZED: '0',
|
|
36
|
+
};
|
|
37
|
+
// 5. Spawn claude with user args
|
|
38
|
+
const args = process.argv.slice(2);
|
|
39
|
+
await processManager.run(claudeBin, args, env);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error(`Bamboo Error: ${error.message || error}`);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bamboo-ai/claude",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Bamboo wrapper for Claude Code — auto login, auto config, one command to start",
|
|
5
|
+
"bin": {
|
|
6
|
+
"bamboo-claude": "./dist/bin/cli.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=20.0.0"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"bamboo",
|
|
17
|
+
"claude-code",
|
|
18
|
+
"anthropic",
|
|
19
|
+
"ai",
|
|
20
|
+
"cli"
|
|
21
|
+
],
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/bamboo-ai/claude-code-router.git",
|
|
25
|
+
"directory": "packages/bamboo-claude"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"start": "node dist/bin/cli.js"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@bamboo-ai/core": "workspace:*"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@anthropic-ai/claude-code": "*"
|
|
36
|
+
},
|
|
37
|
+
"peerDependenciesMeta": {
|
|
38
|
+
"@anthropic-ai/claude-code": {
|
|
39
|
+
"optional": true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^20.0.0",
|
|
44
|
+
"typescript": "^5.0.0"
|
|
45
|
+
}
|
|
46
|
+
}
|