autoclaw 1.0.34 → 1.0.36
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/agent.js +1 -0
- package/dist/index.js +17 -9
- package/dist/tools/image.js +24 -7
- package/package.json +1 -1
package/dist/agent.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { Agent } from './agent.js';
|
|
|
7
7
|
import * as fs from 'fs';
|
|
8
8
|
import * as path from 'path';
|
|
9
9
|
import * as os from 'os';
|
|
10
|
+
import * as readline from 'node:readline/promises';
|
|
10
11
|
import { fileURLToPath } from 'url';
|
|
11
12
|
// Handle Ctrl+C gracefully
|
|
12
13
|
function handleExit() {
|
|
@@ -393,23 +394,27 @@ async function runChat(queryParts, options) {
|
|
|
393
394
|
}
|
|
394
395
|
}
|
|
395
396
|
// Main chat loop
|
|
397
|
+
const rl = readline.createInterface({
|
|
398
|
+
input: process.stdin,
|
|
399
|
+
output: process.stdout,
|
|
400
|
+
terminal: true
|
|
401
|
+
});
|
|
396
402
|
try {
|
|
397
403
|
while (true) {
|
|
398
|
-
const
|
|
399
|
-
{
|
|
400
|
-
type: 'input',
|
|
401
|
-
name: 'userInput',
|
|
402
|
-
message: 'You >',
|
|
403
|
-
prefix: chalk.green('?')
|
|
404
|
-
}
|
|
405
|
-
]);
|
|
404
|
+
const userInput = await rl.question(chalk.green('?') + ' You > ');
|
|
406
405
|
if (userInput.toLowerCase() === 'exit' || userInput.toLowerCase() === 'quit') {
|
|
407
406
|
console.log(chalk.cyan("Goodbye!"));
|
|
408
407
|
break;
|
|
409
408
|
}
|
|
410
409
|
if (userInput.trim() === '')
|
|
411
410
|
continue;
|
|
412
|
-
|
|
411
|
+
rl.pause();
|
|
412
|
+
try {
|
|
413
|
+
await agent.chat(userInput);
|
|
414
|
+
}
|
|
415
|
+
finally {
|
|
416
|
+
rl.resume();
|
|
417
|
+
}
|
|
413
418
|
}
|
|
414
419
|
}
|
|
415
420
|
catch (err) {
|
|
@@ -420,6 +425,9 @@ async function runChat(queryParts, options) {
|
|
|
420
425
|
console.error(chalk.red("Error in chat loop:"), err);
|
|
421
426
|
}
|
|
422
427
|
}
|
|
428
|
+
finally {
|
|
429
|
+
rl.close();
|
|
430
|
+
}
|
|
423
431
|
}
|
|
424
432
|
// Global error handler
|
|
425
433
|
main().catch(err => {
|
package/dist/tools/image.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
|
+
import chalk from 'chalk';
|
|
2
3
|
import * as fs from 'fs';
|
|
3
4
|
import * as path from 'path';
|
|
4
5
|
const toolDefinition = {
|
|
@@ -28,8 +29,7 @@ const toolDefinition = {
|
|
|
28
29
|
},
|
|
29
30
|
model: {
|
|
30
31
|
type: "string",
|
|
31
|
-
|
|
32
|
-
description: "The AI model to use. 'dall-e-3' for high quality (default), 'dall-e-2' for faster/smaller generation or editing.",
|
|
32
|
+
description: "The AI model to use. 'dall-e-3' for high quality (default), 'dall-e-2' for editing, or a custom model like 'doubao-seedream-4-5-251128'.",
|
|
33
33
|
default: "dall-e-3"
|
|
34
34
|
},
|
|
35
35
|
n: {
|
|
@@ -39,7 +39,7 @@ const toolDefinition = {
|
|
|
39
39
|
},
|
|
40
40
|
size: {
|
|
41
41
|
type: "string",
|
|
42
|
-
description: "
|
|
42
|
+
description: "Resolution/Aspect Ratio. YOU should infer the best size based on the prompt content.\n- DALL-E 3: '1024x1024' (Square), '1792x1024' (Landscape), '1024x1792' (Portrait).\n- Doubao/High-Res: MUST be >3.6M pixels. Use '2048x2048' (Square), '2560x1440' (Landscape), '1440x2560' (Portrait).",
|
|
43
43
|
default: "1024x1024"
|
|
44
44
|
},
|
|
45
45
|
quality: {
|
|
@@ -80,9 +80,22 @@ const handler = async (args, config) => {
|
|
|
80
80
|
apiKey: apiKey,
|
|
81
81
|
baseURL: baseURL
|
|
82
82
|
});
|
|
83
|
-
const { prompt, image_path, mask_path,
|
|
83
|
+
const { prompt, image_path, mask_path, output_dir = "." } = args;
|
|
84
|
+
const n = args.n || config.imageN || 1;
|
|
85
|
+
// Model-specific default size
|
|
84
86
|
let mode = args.mode;
|
|
85
|
-
let model = args.model
|
|
87
|
+
let model = args.model;
|
|
88
|
+
if (config.imageModel && (!model || model === 'dall-e-3')) {
|
|
89
|
+
model = config.imageModel;
|
|
90
|
+
}
|
|
91
|
+
model = model || "dall-e-3";
|
|
92
|
+
let defaultSize = "1024x1024";
|
|
93
|
+
if (model.toLowerCase().includes("doubao")) {
|
|
94
|
+
defaultSize = "2048x2048";
|
|
95
|
+
}
|
|
96
|
+
const size = args.size || config.imageSize || defaultSize;
|
|
97
|
+
const quality = args.quality || config.imageQuality || "standard";
|
|
98
|
+
const style = args.style || config.imageStyle || "vivid";
|
|
86
99
|
// Infer mode if not provided
|
|
87
100
|
if (!mode) {
|
|
88
101
|
if (image_path && mask_path)
|
|
@@ -148,9 +161,9 @@ const handler = async (args, config) => {
|
|
|
148
161
|
}
|
|
149
162
|
}
|
|
150
163
|
else {
|
|
151
|
-
// DALL-E 2
|
|
164
|
+
// DALL-E 2 or Custom Model
|
|
152
165
|
const response = await client.images.generate({
|
|
153
|
-
model:
|
|
166
|
+
model: model,
|
|
154
167
|
prompt: prompt,
|
|
155
168
|
n: n,
|
|
156
169
|
size: size,
|
|
@@ -229,6 +242,10 @@ const handler = async (args, config) => {
|
|
|
229
242
|
return `Successfully generated ${generatedFiles.length} image(s):\n${generatedFiles.join('\n')}`;
|
|
230
243
|
}
|
|
231
244
|
catch (error) {
|
|
245
|
+
console.error(chalk.red(`Image Generation Failed: ${error.message}`));
|
|
246
|
+
if (error.response && error.response.data) {
|
|
247
|
+
console.error(chalk.dim(JSON.stringify(error.response.data)));
|
|
248
|
+
}
|
|
232
249
|
return `Error generating image: ${error.message}`;
|
|
233
250
|
}
|
|
234
251
|
};
|