autoclaw 1.0.35 → 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 +21 -8
- 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: {
|
|
@@ -82,11 +82,20 @@ const handler = async (args, config) => {
|
|
|
82
82
|
});
|
|
83
83
|
const { prompt, image_path, mask_path, output_dir = "." } = args;
|
|
84
84
|
const n = args.n || config.imageN || 1;
|
|
85
|
-
|
|
85
|
+
// Model-specific default size
|
|
86
|
+
let mode = args.mode;
|
|
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;
|
|
86
97
|
const quality = args.quality || config.imageQuality || "standard";
|
|
87
98
|
const style = args.style || config.imageStyle || "vivid";
|
|
88
|
-
let mode = args.mode;
|
|
89
|
-
let model = args.model || config.imageModel || "dall-e-3";
|
|
90
99
|
// Infer mode if not provided
|
|
91
100
|
if (!mode) {
|
|
92
101
|
if (image_path && mask_path)
|
|
@@ -152,9 +161,9 @@ const handler = async (args, config) => {
|
|
|
152
161
|
}
|
|
153
162
|
}
|
|
154
163
|
else {
|
|
155
|
-
// DALL-E 2
|
|
164
|
+
// DALL-E 2 or Custom Model
|
|
156
165
|
const response = await client.images.generate({
|
|
157
|
-
model:
|
|
166
|
+
model: model,
|
|
158
167
|
prompt: prompt,
|
|
159
168
|
n: n,
|
|
160
169
|
size: size,
|
|
@@ -233,6 +242,10 @@ const handler = async (args, config) => {
|
|
|
233
242
|
return `Successfully generated ${generatedFiles.length} image(s):\n${generatedFiles.join('\n')}`;
|
|
234
243
|
}
|
|
235
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
|
+
}
|
|
236
249
|
return `Error generating image: ${error.message}`;
|
|
237
250
|
}
|
|
238
251
|
};
|