@unityclaw/sdk 1.0.1 → 1.0.3
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/README.md +173 -0
- package/dist/chunk-WG7OYNEX.js +71 -0
- package/dist/cli.cjs +160 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +82 -0
- package/dist/index.cjs +117 -65
- package/dist/index.d.cts +69 -34
- package/dist/index.d.ts +69 -34
- package/dist/index.js +58 -64
- package/package.json +8 -4
- package/src/cli.ts +95 -0
package/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# @unityclaw/sdk
|
|
2
|
+
|
|
3
|
+
Node.js SDK for UnityClaw API - AI-powered image/video generation, media analysis, and more.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @unityclaw/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { UnityClawClient } from '@unityclaw/sdk';
|
|
15
|
+
|
|
16
|
+
// Reads UNITYCLAW_API_KEY from environment variable
|
|
17
|
+
const client = new UnityClawClient();
|
|
18
|
+
|
|
19
|
+
// Or with explicit config
|
|
20
|
+
const client = new UnityClawClient({
|
|
21
|
+
apiKey: 'your-api-key',
|
|
22
|
+
baseUrl: 'https://unityclaw.com',
|
|
23
|
+
taskDir: './tasks'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Generate image
|
|
27
|
+
const imageResult = await client.image.gemini({
|
|
28
|
+
prompt: 'A beautiful sunset over mountains'
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Generate video
|
|
32
|
+
const videoResult = await client.video.sora({
|
|
33
|
+
prompt: 'A cat playing piano',
|
|
34
|
+
orientation: { value: 'landscape', label: 'Landscape' }
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Translate document
|
|
38
|
+
const docResult = await client.document.translate({
|
|
39
|
+
attachment: [{ tmp_url: 'https://...', name: 'doc.pdf' }],
|
|
40
|
+
source_language: { value: 'en', label: 'English' },
|
|
41
|
+
target_language: { value: 'zh', label: 'Chinese' }
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Analyze media
|
|
45
|
+
const mediaResult = await client.media.analyze({
|
|
46
|
+
url: [{ link: 'https://youtube.com/watch?v=...' }]
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Configuration
|
|
51
|
+
|
|
52
|
+
### Environment Variables
|
|
53
|
+
|
|
54
|
+
- `UNITYCLAW_API_KEY` - Your UnityClaw API key
|
|
55
|
+
- `UNITYCLAW_BASE_URL` - API base URL (optional, defaults to https://unityclaw.com)
|
|
56
|
+
|
|
57
|
+
### CLI Configuration
|
|
58
|
+
|
|
59
|
+
Use the CLI to persist configuration:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Install globally
|
|
63
|
+
npm install -g @unityclaw/sdk
|
|
64
|
+
|
|
65
|
+
# Set API key (stored in ~/.unityclaw/config.json)
|
|
66
|
+
unityclaw-sdk config set apiKey your-api-key
|
|
67
|
+
|
|
68
|
+
# Set custom base URL
|
|
69
|
+
unityclaw-sdk config set baseUrl https://custom.example.com
|
|
70
|
+
|
|
71
|
+
# View current configuration
|
|
72
|
+
unityclaw-sdk config
|
|
73
|
+
|
|
74
|
+
# Get a specific value
|
|
75
|
+
unityclaw-sdk config get apiKey
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Configuration Priority
|
|
79
|
+
|
|
80
|
+
1. Constructor parameters (highest priority)
|
|
81
|
+
2. Environment variables
|
|
82
|
+
3. Config file (~/.unityclaw/config.json)
|
|
83
|
+
4. Default values (lowest priority)
|
|
84
|
+
|
|
85
|
+
## Task Folders
|
|
86
|
+
|
|
87
|
+
Each SDK execution creates a task folder with:
|
|
88
|
+
|
|
89
|
+
- `logs/request.json` - Request details
|
|
90
|
+
- `logs/response.json` - API response
|
|
91
|
+
- `logs/execution.log` - Execution log
|
|
92
|
+
- `attachments/` - Downloaded attachments (to avoid link expiration)
|
|
93
|
+
|
|
94
|
+
### Default Task Directory
|
|
95
|
+
|
|
96
|
+
Tasks are stored in `~/.unityclaw/tasks/` by default. You can override this:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
const client = new UnityClawClient({
|
|
100
|
+
taskDir: '/path/to/custom/tasks'
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## API Reference
|
|
105
|
+
|
|
106
|
+
### Image Generation
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
// Gemini
|
|
110
|
+
await client.image.gemini({
|
|
111
|
+
prompt: 'A sunset over mountains',
|
|
112
|
+
aspect_ratio: '16:9'
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// JiMeng (Doubao)
|
|
116
|
+
await client.image.jimeng({
|
|
117
|
+
prompt: 'A futuristic city',
|
|
118
|
+
model: 'v6.0'
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Video Generation
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
// Sora
|
|
126
|
+
await client.video.sora({
|
|
127
|
+
prompt: 'A cat playing piano',
|
|
128
|
+
orientation: 'landscape'
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Veo
|
|
132
|
+
await client.video.veo({
|
|
133
|
+
prompt: 'Ocean waves at sunset'
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// Kling
|
|
137
|
+
await client.video.kling({
|
|
138
|
+
prompt: 'A dancing robot',
|
|
139
|
+
version: 'v1.5'
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Document Processing
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
// Translate document
|
|
147
|
+
await client.document.translate({
|
|
148
|
+
attachment: [{ tmp_url: 'https://...', name: 'doc.pdf' }],
|
|
149
|
+
source_language: { value: 'en', label: 'English' },
|
|
150
|
+
target_language: { value: 'zh', label: 'Chinese' }
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Convert document
|
|
154
|
+
await client.document.convert({
|
|
155
|
+
attachment: [{ tmp_url: 'https://...', name: 'doc.pdf' }],
|
|
156
|
+
target_format: { value: 'word', label: 'Word' }
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Media Analysis
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
const result = await client.media.analyze({
|
|
164
|
+
url: [{ link: 'https://youtube.com/watch?v=...' }]
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
console.log(result.data.summary);
|
|
168
|
+
console.log(result.data.subtitle);
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
MIT
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
import os from "os";
|
|
4
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
5
|
+
var CONFIG_DIR = path.join(os.homedir(), ".unityclaw");
|
|
6
|
+
var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
7
|
+
var DEFAULT_TASKS_DIR = path.join(CONFIG_DIR, "tasks");
|
|
8
|
+
function getConfigPath() {
|
|
9
|
+
return CONFIG_FILE;
|
|
10
|
+
}
|
|
11
|
+
function loadConfig() {
|
|
12
|
+
try {
|
|
13
|
+
if (existsSync(CONFIG_FILE)) {
|
|
14
|
+
const content = readFileSync(CONFIG_FILE, "utf-8");
|
|
15
|
+
return JSON.parse(content);
|
|
16
|
+
}
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
function saveConfig(config) {
|
|
22
|
+
if (!existsSync(CONFIG_DIR)) {
|
|
23
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), "utf-8");
|
|
26
|
+
}
|
|
27
|
+
function setConfigValue(key, value) {
|
|
28
|
+
const config = loadConfig();
|
|
29
|
+
const keyMap = {
|
|
30
|
+
"apiKey": "apiKey",
|
|
31
|
+
"api_key": "apiKey",
|
|
32
|
+
"key": "apiKey",
|
|
33
|
+
"baseUrl": "baseUrl",
|
|
34
|
+
"base_url": "baseUrl",
|
|
35
|
+
"url": "baseUrl",
|
|
36
|
+
"taskDir": "taskDir",
|
|
37
|
+
"task_dir": "taskDir",
|
|
38
|
+
"tasks": "taskDir"
|
|
39
|
+
};
|
|
40
|
+
const configKey = keyMap[key] || key;
|
|
41
|
+
config[configKey] = value;
|
|
42
|
+
saveConfig(config);
|
|
43
|
+
}
|
|
44
|
+
function getConfigValue(key) {
|
|
45
|
+
const config = loadConfig();
|
|
46
|
+
const keyMap = {
|
|
47
|
+
"apiKey": "apiKey",
|
|
48
|
+
"api_key": "apiKey",
|
|
49
|
+
"key": "apiKey",
|
|
50
|
+
"baseUrl": "baseUrl",
|
|
51
|
+
"base_url": "baseUrl",
|
|
52
|
+
"url": "baseUrl",
|
|
53
|
+
"taskDir": "taskDir",
|
|
54
|
+
"task_dir": "taskDir",
|
|
55
|
+
"tasks": "taskDir"
|
|
56
|
+
};
|
|
57
|
+
const configKey = keyMap[key] || key;
|
|
58
|
+
const value = config[configKey];
|
|
59
|
+
return value ? String(value) : void 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
CONFIG_DIR,
|
|
64
|
+
CONFIG_FILE,
|
|
65
|
+
DEFAULT_TASKS_DIR,
|
|
66
|
+
getConfigPath,
|
|
67
|
+
loadConfig,
|
|
68
|
+
saveConfig,
|
|
69
|
+
setConfigValue,
|
|
70
|
+
getConfigValue
|
|
71
|
+
};
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/config.ts
|
|
27
|
+
var import_path = __toESM(require("path"), 1);
|
|
28
|
+
var import_os = __toESM(require("os"), 1);
|
|
29
|
+
var import_fs = require("fs");
|
|
30
|
+
var CONFIG_DIR = import_path.default.join(import_os.default.homedir(), ".unityclaw");
|
|
31
|
+
var CONFIG_FILE = import_path.default.join(CONFIG_DIR, "config.json");
|
|
32
|
+
var DEFAULT_TASKS_DIR = import_path.default.join(CONFIG_DIR, "tasks");
|
|
33
|
+
function getConfigPath() {
|
|
34
|
+
return CONFIG_FILE;
|
|
35
|
+
}
|
|
36
|
+
function loadConfig() {
|
|
37
|
+
try {
|
|
38
|
+
if ((0, import_fs.existsSync)(CONFIG_FILE)) {
|
|
39
|
+
const content = (0, import_fs.readFileSync)(CONFIG_FILE, "utf-8");
|
|
40
|
+
return JSON.parse(content);
|
|
41
|
+
}
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
function saveConfig(config) {
|
|
47
|
+
if (!(0, import_fs.existsSync)(CONFIG_DIR)) {
|
|
48
|
+
(0, import_fs.mkdirSync)(CONFIG_DIR, { recursive: true });
|
|
49
|
+
}
|
|
50
|
+
(0, import_fs.writeFileSync)(CONFIG_FILE, JSON.stringify(config, null, 2), "utf-8");
|
|
51
|
+
}
|
|
52
|
+
function setConfigValue(key, value) {
|
|
53
|
+
const config = loadConfig();
|
|
54
|
+
const keyMap = {
|
|
55
|
+
"apiKey": "apiKey",
|
|
56
|
+
"api_key": "apiKey",
|
|
57
|
+
"key": "apiKey",
|
|
58
|
+
"baseUrl": "baseUrl",
|
|
59
|
+
"base_url": "baseUrl",
|
|
60
|
+
"url": "baseUrl",
|
|
61
|
+
"taskDir": "taskDir",
|
|
62
|
+
"task_dir": "taskDir",
|
|
63
|
+
"tasks": "taskDir"
|
|
64
|
+
};
|
|
65
|
+
const configKey = keyMap[key] || key;
|
|
66
|
+
config[configKey] = value;
|
|
67
|
+
saveConfig(config);
|
|
68
|
+
}
|
|
69
|
+
function getConfigValue(key) {
|
|
70
|
+
const config = loadConfig();
|
|
71
|
+
const keyMap = {
|
|
72
|
+
"apiKey": "apiKey",
|
|
73
|
+
"api_key": "apiKey",
|
|
74
|
+
"key": "apiKey",
|
|
75
|
+
"baseUrl": "baseUrl",
|
|
76
|
+
"base_url": "baseUrl",
|
|
77
|
+
"url": "baseUrl",
|
|
78
|
+
"taskDir": "taskDir",
|
|
79
|
+
"task_dir": "taskDir",
|
|
80
|
+
"tasks": "taskDir"
|
|
81
|
+
};
|
|
82
|
+
const configKey = keyMap[key] || key;
|
|
83
|
+
const value = config[configKey];
|
|
84
|
+
return value ? String(value) : void 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/cli.ts
|
|
88
|
+
var args = process.argv.slice(2);
|
|
89
|
+
var command = args[0];
|
|
90
|
+
function showHelp() {
|
|
91
|
+
console.log(`
|
|
92
|
+
@unityclaw/sdk CLI - Configuration Management
|
|
93
|
+
|
|
94
|
+
Usage:
|
|
95
|
+
unityclaw-sdk config Show current configuration
|
|
96
|
+
unityclaw-sdk config set <key> <value> Set a configuration value
|
|
97
|
+
unityclaw-sdk config get <key> Get a configuration value
|
|
98
|
+
unityclaw-sdk config list List all configuration
|
|
99
|
+
|
|
100
|
+
Configuration keys:
|
|
101
|
+
apiKey API key for UnityClaw
|
|
102
|
+
baseUrl Base URL for API (default: https://unityclaw.com)
|
|
103
|
+
taskDir Directory for task folders (default: ~/.unityclaw/tasks)
|
|
104
|
+
|
|
105
|
+
Examples:
|
|
106
|
+
unityclaw-sdk config set apiKey your-api-key
|
|
107
|
+
unityclaw-sdk config set baseUrl https://custom.example.com
|
|
108
|
+
unityclaw-sdk config get apiKey
|
|
109
|
+
unityclaw-sdk config list
|
|
110
|
+
`);
|
|
111
|
+
}
|
|
112
|
+
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
113
|
+
showHelp();
|
|
114
|
+
process.exit(0);
|
|
115
|
+
}
|
|
116
|
+
if (command === "config") {
|
|
117
|
+
const action = args[1];
|
|
118
|
+
const key = args[2];
|
|
119
|
+
const value = args[3];
|
|
120
|
+
if (!action) {
|
|
121
|
+
const config = loadConfig();
|
|
122
|
+
console.log("\nCurrent configuration:\n");
|
|
123
|
+
console.log(` Config file: ${getConfigPath()}
|
|
124
|
+
`);
|
|
125
|
+
if (Object.keys(config).length === 0) {
|
|
126
|
+
console.log(" (empty - no configuration set)\n");
|
|
127
|
+
} else {
|
|
128
|
+
for (const [k, v] of Object.entries(config)) {
|
|
129
|
+
const displayValue = k === "apiKey" && v ? `${String(v).slice(0, 8)}...${String(v).slice(-4)}` : v;
|
|
130
|
+
console.log(` ${k}: ${displayValue}`);
|
|
131
|
+
}
|
|
132
|
+
console.log();
|
|
133
|
+
}
|
|
134
|
+
} else if (action === "set" && key && value) {
|
|
135
|
+
setConfigValue(key, value);
|
|
136
|
+
console.log(`\u2705 Config saved to ${getConfigPath()}`);
|
|
137
|
+
} else if (action === "get" && key) {
|
|
138
|
+
const val = getConfigValue(key);
|
|
139
|
+
if (val) {
|
|
140
|
+
console.log(val);
|
|
141
|
+
} else {
|
|
142
|
+
console.log(`(not set)`);
|
|
143
|
+
}
|
|
144
|
+
} else if (action === "list") {
|
|
145
|
+
const config = loadConfig();
|
|
146
|
+
console.log("\nConfiguration:\n");
|
|
147
|
+
for (const [k, v] of Object.entries(config)) {
|
|
148
|
+
const displayValue = k === "apiKey" && v ? `${String(v).slice(0, 8)}...${String(v).slice(-4)}` : v;
|
|
149
|
+
console.log(` ${k}: ${displayValue}`);
|
|
150
|
+
}
|
|
151
|
+
console.log();
|
|
152
|
+
} else {
|
|
153
|
+
console.error("Invalid usage. Run `unityclaw-sdk config --help` for help.");
|
|
154
|
+
process.exit(1);
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
console.error(`Unknown command: ${command}`);
|
|
158
|
+
showHelp();
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getConfigPath,
|
|
4
|
+
getConfigValue,
|
|
5
|
+
loadConfig,
|
|
6
|
+
setConfigValue
|
|
7
|
+
} from "./chunk-WG7OYNEX.js";
|
|
8
|
+
|
|
9
|
+
// src/cli.ts
|
|
10
|
+
var args = process.argv.slice(2);
|
|
11
|
+
var command = args[0];
|
|
12
|
+
function showHelp() {
|
|
13
|
+
console.log(`
|
|
14
|
+
@unityclaw/sdk CLI - Configuration Management
|
|
15
|
+
|
|
16
|
+
Usage:
|
|
17
|
+
unityclaw-sdk config Show current configuration
|
|
18
|
+
unityclaw-sdk config set <key> <value> Set a configuration value
|
|
19
|
+
unityclaw-sdk config get <key> Get a configuration value
|
|
20
|
+
unityclaw-sdk config list List all configuration
|
|
21
|
+
|
|
22
|
+
Configuration keys:
|
|
23
|
+
apiKey API key for UnityClaw
|
|
24
|
+
baseUrl Base URL for API (default: https://unityclaw.com)
|
|
25
|
+
taskDir Directory for task folders (default: ~/.unityclaw/tasks)
|
|
26
|
+
|
|
27
|
+
Examples:
|
|
28
|
+
unityclaw-sdk config set apiKey your-api-key
|
|
29
|
+
unityclaw-sdk config set baseUrl https://custom.example.com
|
|
30
|
+
unityclaw-sdk config get apiKey
|
|
31
|
+
unityclaw-sdk config list
|
|
32
|
+
`);
|
|
33
|
+
}
|
|
34
|
+
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
35
|
+
showHelp();
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
if (command === "config") {
|
|
39
|
+
const action = args[1];
|
|
40
|
+
const key = args[2];
|
|
41
|
+
const value = args[3];
|
|
42
|
+
if (!action) {
|
|
43
|
+
const config = loadConfig();
|
|
44
|
+
console.log("\nCurrent configuration:\n");
|
|
45
|
+
console.log(` Config file: ${getConfigPath()}
|
|
46
|
+
`);
|
|
47
|
+
if (Object.keys(config).length === 0) {
|
|
48
|
+
console.log(" (empty - no configuration set)\n");
|
|
49
|
+
} else {
|
|
50
|
+
for (const [k, v] of Object.entries(config)) {
|
|
51
|
+
const displayValue = k === "apiKey" && v ? `${String(v).slice(0, 8)}...${String(v).slice(-4)}` : v;
|
|
52
|
+
console.log(` ${k}: ${displayValue}`);
|
|
53
|
+
}
|
|
54
|
+
console.log();
|
|
55
|
+
}
|
|
56
|
+
} else if (action === "set" && key && value) {
|
|
57
|
+
setConfigValue(key, value);
|
|
58
|
+
console.log(`\u2705 Config saved to ${getConfigPath()}`);
|
|
59
|
+
} else if (action === "get" && key) {
|
|
60
|
+
const val = getConfigValue(key);
|
|
61
|
+
if (val) {
|
|
62
|
+
console.log(val);
|
|
63
|
+
} else {
|
|
64
|
+
console.log(`(not set)`);
|
|
65
|
+
}
|
|
66
|
+
} else if (action === "list") {
|
|
67
|
+
const config = loadConfig();
|
|
68
|
+
console.log("\nConfiguration:\n");
|
|
69
|
+
for (const [k, v] of Object.entries(config)) {
|
|
70
|
+
const displayValue = k === "apiKey" && v ? `${String(v).slice(0, 8)}...${String(v).slice(-4)}` : v;
|
|
71
|
+
console.log(` ${k}: ${displayValue}`);
|
|
72
|
+
}
|
|
73
|
+
console.log();
|
|
74
|
+
} else {
|
|
75
|
+
console.error("Invalid usage. Run `unityclaw-sdk config --help` for help.");
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
console.error(`Unknown command: ${command}`);
|
|
80
|
+
showHelp();
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|