@aigne/cli 1.25.1 → 1.26.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/CHANGELOG.md +32 -0
- package/dist/bunwrapper.js +0 -0
- package/dist/cli.js +2 -1
- package/dist/commands/aigne.d.ts +2 -2
- package/dist/commands/aigne.js +18 -11
- package/dist/commands/app.d.ts +2 -0
- package/dist/commands/app.js +98 -0
- package/dist/commands/connect.d.ts +6 -0
- package/dist/commands/connect.js +91 -0
- package/dist/commands/create.d.ts +6 -2
- package/dist/commands/create.js +62 -58
- package/dist/commands/observe.d.ts +7 -2
- package/dist/commands/observe.js +22 -13
- package/dist/commands/run.d.ts +6 -3
- package/dist/commands/run.js +96 -81
- package/dist/commands/serve-mcp.d.ts +10 -3
- package/dist/commands/serve-mcp.js +41 -23
- package/dist/commands/test.d.ts +7 -3
- package/dist/commands/test.js +20 -14
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/tracer/terminal.js +43 -19
- package/dist/type.d.ts +5 -0
- package/dist/type.js +1 -0
- package/dist/utils/download.d.ts +3 -1
- package/dist/utils/download.js +2 -2
- package/dist/utils/listr.js +5 -1
- package/dist/utils/load-aigne.d.ts +46 -1
- package/dist/utils/load-aigne.js +123 -91
- package/dist/utils/run-with-aigne.d.ts +26 -2
- package/dist/utils/run-with-aigne.js +80 -57
- package/package.json +41 -29
- package/LICENSE.md +0 -93
package/dist/commands/run.js
CHANGED
|
@@ -12,94 +12,109 @@ import { isV1Package, toAIGNEPackage } from "../utils/agent-v1.js";
|
|
|
12
12
|
import { downloadAndExtract } from "../utils/download.js";
|
|
13
13
|
import { loadAIGNE } from "../utils/load-aigne.js";
|
|
14
14
|
import { createRunAIGNECommand, parseAgentInputByCommander, runAgentWithAIGNE, } from "../utils/run-with-aigne.js";
|
|
15
|
-
export function createRunCommand({ aigneFilePath } = {}) {
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
15
|
+
export function createRunCommand({ aigneFilePath, } = {}) {
|
|
16
|
+
return {
|
|
17
|
+
command: "run [path]",
|
|
18
|
+
describe: "Run AIGNE from the specified agent",
|
|
19
|
+
builder: (yargs) => {
|
|
20
|
+
return createRunAIGNECommand(yargs)
|
|
21
|
+
.positional("path", {
|
|
22
|
+
describe: "Path to the agents directory or URL to aigne project",
|
|
23
|
+
type: "string",
|
|
24
|
+
default: ".",
|
|
25
|
+
alias: ["url"],
|
|
26
|
+
})
|
|
27
|
+
.option("entry-agent", {
|
|
28
|
+
describe: "Name of the agent to run (defaults to the first agent found)",
|
|
29
|
+
type: "string",
|
|
30
|
+
})
|
|
31
|
+
.option("cache-dir", {
|
|
32
|
+
describe: "Directory to download the package to (defaults to the ~/.aigne/xxx)",
|
|
33
|
+
type: "string",
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
handler: async (argv) => {
|
|
37
|
+
const options = argv;
|
|
38
|
+
const path = aigneFilePath || options.path;
|
|
39
|
+
if (options.logLevel)
|
|
40
|
+
logger.level = options.logLevel;
|
|
41
|
+
const { cacheDir, dir } = prepareDirs(path, options);
|
|
42
|
+
const { aigne, agent } = await new Listr([
|
|
43
|
+
{
|
|
44
|
+
title: "Prepare environment",
|
|
45
|
+
task: (_, task) => {
|
|
46
|
+
if (cacheDir) {
|
|
47
|
+
return task.newListr([
|
|
48
|
+
{
|
|
49
|
+
title: "Download package",
|
|
50
|
+
task: () => downloadPackage(path, cacheDir),
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
title: "Extract package",
|
|
54
|
+
task: () => extractPackage(cacheDir, dir),
|
|
55
|
+
},
|
|
56
|
+
]);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
42
59
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
{
|
|
61
|
+
title: "Initialize AIGNE",
|
|
62
|
+
task: async (ctx, task) => {
|
|
63
|
+
// Load env files in the aigne directory
|
|
64
|
+
config({ path: dir, silent: true });
|
|
65
|
+
const aigne = await loadAIGNE(dir, { ...options, model: options.model || process.env.MODEL }, {
|
|
66
|
+
inquirerPromptFn: (prompt) => {
|
|
67
|
+
return task
|
|
68
|
+
.prompt(ListrInquirerPromptAdapter)
|
|
69
|
+
.run(select, prompt)
|
|
70
|
+
.then((res) => ({ [prompt.name]: res }));
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
ctx.aigne = aigne;
|
|
74
|
+
},
|
|
58
75
|
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
throw new Error(`\
|
|
76
|
+
{
|
|
77
|
+
task: (ctx) => {
|
|
78
|
+
const { aigne } = ctx;
|
|
79
|
+
assert(aigne);
|
|
80
|
+
let entryAgent;
|
|
81
|
+
if (options.entryAgent) {
|
|
82
|
+
entryAgent = aigne.agents[options.entryAgent];
|
|
83
|
+
if (!entryAgent) {
|
|
84
|
+
throw new Error(`\
|
|
69
85
|
Agent "${options.entryAgent}" not found in ${aigne.rootDir}
|
|
70
86
|
|
|
71
87
|
Available agents:
|
|
72
88
|
${aigne.agents.map((agent) => ` - ${agent.name}`).join("\n")}
|
|
73
89
|
`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
entryAgent = aigne.agents[0];
|
|
94
|
+
if (!entryAgent)
|
|
95
|
+
throw new Error(`No any agent found in ${aigne.rootDir}`);
|
|
74
96
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
97
|
+
ctx.agent = entryAgent;
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
], {
|
|
101
|
+
rendererOptions: {
|
|
102
|
+
collapseSubtasks: false,
|
|
103
|
+
showErrorMessage: false,
|
|
104
|
+
timer: PRESET_TIMER,
|
|
82
105
|
},
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
await runAgentWithAIGNE(aigne, agent, { ...options, input });
|
|
96
|
-
}
|
|
97
|
-
finally {
|
|
98
|
-
await aigne.shutdown();
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
.showHelpAfterError(true)
|
|
102
|
-
.showSuggestionAfterError(true);
|
|
106
|
+
}).run();
|
|
107
|
+
assert(aigne);
|
|
108
|
+
assert(agent);
|
|
109
|
+
const input = await parseAgentInputByCommander(agent, options);
|
|
110
|
+
try {
|
|
111
|
+
await runAgentWithAIGNE(aigne, agent, { ...options, input });
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
await aigne.shutdown();
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
};
|
|
103
118
|
}
|
|
104
119
|
async function downloadPackage(url, cacheDir) {
|
|
105
120
|
await rm(cacheDir, { recursive: true, force: true });
|
|
@@ -121,7 +136,7 @@ function prepareDirs(path, options) {
|
|
|
121
136
|
if (!path.startsWith("http")) {
|
|
122
137
|
dir = isAbsolute(path) ? path : resolve(process.cwd(), path);
|
|
123
138
|
}
|
|
124
|
-
else if (options
|
|
139
|
+
else if (options?.cacheDir) {
|
|
125
140
|
dir = isAbsolute(options.cacheDir)
|
|
126
141
|
? options.cacheDir
|
|
127
142
|
: resolve(process.cwd(), options.cacheDir);
|
|
@@ -133,7 +148,7 @@ function prepareDirs(path, options) {
|
|
|
133
148
|
}
|
|
134
149
|
return { cacheDir, dir };
|
|
135
150
|
}
|
|
136
|
-
function getLocalPackagePathFromUrl(url, { subdir } = {}) {
|
|
151
|
+
export function getLocalPackagePathFromUrl(url, { subdir } = {}) {
|
|
137
152
|
const root = [homedir(), ".aigne", subdir].filter(isNonNullable);
|
|
138
153
|
const u = new URL(url);
|
|
139
154
|
return join(...root, u.hostname, u.pathname);
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { CommandModule } from "yargs";
|
|
2
|
+
interface ServeMCPOptions {
|
|
3
|
+
path: string;
|
|
4
|
+
host: string;
|
|
5
|
+
port?: number;
|
|
6
|
+
pathname: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function createServeMCPCommand({ aigneFilePath, }?: {
|
|
3
9
|
aigneFilePath?: string;
|
|
4
|
-
}):
|
|
10
|
+
}): CommandModule<{}, ServeMCPOptions>;
|
|
11
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isAbsolute, resolve } from "node:path";
|
|
2
2
|
import { tryOrThrow } from "@aigne/core/utils/type-utils.js";
|
|
3
|
-
import { Command } from "commander";
|
|
4
3
|
import { loadAIGNE } from "../utils/load-aigne.js";
|
|
5
4
|
import { serveMCPServer } from "../utils/serve-mcp.js";
|
|
6
5
|
const DEFAULT_PORT = () => tryOrThrow(() => {
|
|
@@ -12,26 +11,45 @@ const DEFAULT_PORT = () => tryOrThrow(() => {
|
|
|
12
11
|
throw new Error(`Invalid PORT: ${PORT}`);
|
|
13
12
|
return port;
|
|
14
13
|
}, (error) => new Error(`parse PORT error ${error.message}`));
|
|
15
|
-
export function createServeMCPCommand({ aigneFilePath } = {}) {
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
14
|
+
export function createServeMCPCommand({ aigneFilePath, } = {}) {
|
|
15
|
+
return {
|
|
16
|
+
command: "serve-mcp",
|
|
17
|
+
describe: "Serve the agents in the specified directory as a MCP server (streamable http)",
|
|
18
|
+
builder: (yargs) => {
|
|
19
|
+
return yargs
|
|
20
|
+
.option("path", {
|
|
21
|
+
describe: "Path to the agents directory or URL to aigne project",
|
|
22
|
+
type: "string",
|
|
23
|
+
default: ".",
|
|
24
|
+
alias: ["url"],
|
|
25
|
+
})
|
|
26
|
+
.option("host", {
|
|
27
|
+
describe: "Host to run the MCP server on, use 0.0.0.0 to publicly expose the server",
|
|
28
|
+
type: "string",
|
|
29
|
+
default: "localhost",
|
|
30
|
+
})
|
|
31
|
+
.option("port", {
|
|
32
|
+
describe: "Port to run the MCP server on",
|
|
33
|
+
type: "number",
|
|
34
|
+
})
|
|
35
|
+
.option("pathname", {
|
|
36
|
+
describe: "Pathname to the service",
|
|
37
|
+
type: "string",
|
|
38
|
+
default: "/mcp",
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
handler: async (options) => {
|
|
42
|
+
const path = aigneFilePath || options.path;
|
|
43
|
+
const absolutePath = isAbsolute(path) ? path : resolve(process.cwd(), path);
|
|
44
|
+
const port = options.port || DEFAULT_PORT();
|
|
45
|
+
const aigne = await loadAIGNE(absolutePath);
|
|
46
|
+
await serveMCPServer({
|
|
47
|
+
aigne,
|
|
48
|
+
host: options.host,
|
|
49
|
+
port,
|
|
50
|
+
pathname: options.pathname,
|
|
51
|
+
});
|
|
52
|
+
console.log(`MCP server is running on http://${options.host}:${port}${options.pathname}`);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
37
55
|
}
|
package/dist/commands/test.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { CommandModule } from "yargs";
|
|
2
|
+
interface TestOptions {
|
|
3
|
+
path: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function createTestCommand({ aigneFilePath, }?: {
|
|
3
6
|
aigneFilePath?: string;
|
|
4
|
-
}):
|
|
7
|
+
}): CommandModule<{}, TestOptions>;
|
|
8
|
+
export {};
|
package/dist/commands/test.js
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import assert from "node:assert";
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
3
|
import { isAbsolute, resolve } from "node:path";
|
|
4
|
-
import { Command } from "commander";
|
|
5
4
|
import { loadAIGNE } from "../utils/load-aigne.js";
|
|
6
|
-
export function createTestCommand({ aigneFilePath } = {}) {
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
export function createTestCommand({ aigneFilePath, } = {}) {
|
|
6
|
+
return {
|
|
7
|
+
command: "test",
|
|
8
|
+
describe: "Run tests in the specified agents directory",
|
|
9
|
+
builder: (yargs) => {
|
|
10
|
+
return yargs.option("path", {
|
|
11
|
+
describe: "Path to the agents directory or URL to aigne project",
|
|
12
|
+
type: "string",
|
|
13
|
+
default: ".",
|
|
14
|
+
alias: ["url"],
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
handler: async (options) => {
|
|
18
|
+
const path = aigneFilePath || options.path;
|
|
19
|
+
const absolutePath = isAbsolute(path) ? path : resolve(process.cwd(), path);
|
|
20
|
+
const aigne = await loadAIGNE(absolutePath);
|
|
21
|
+
assert(aigne.rootDir);
|
|
22
|
+
spawnSync("node", ["--test"], { cwd: aigne.rootDir, stdio: "inherit" });
|
|
23
|
+
},
|
|
24
|
+
};
|
|
19
25
|
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./type.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./type.js";
|
package/dist/tracer/terminal.js
CHANGED
|
@@ -3,9 +3,11 @@ import { inspect } from "node:util";
|
|
|
3
3
|
import { AIAgent, ChatModel, DEFAULT_OUTPUT_KEY, } from "@aigne/core";
|
|
4
4
|
import { LogLevel, logger } from "@aigne/core/utils/logger.js";
|
|
5
5
|
import { promiseWithResolvers } from "@aigne/core/utils/promise.js";
|
|
6
|
-
import { omit } from "@aigne/core/utils/type-utils.js";
|
|
6
|
+
import { flat, omit } from "@aigne/core/utils/type-utils.js";
|
|
7
7
|
import { figures } from "@aigne/listr2";
|
|
8
8
|
import { markedTerminal } from "@aigne/marked-terminal";
|
|
9
|
+
import * as prompts from "@inquirer/prompts";
|
|
10
|
+
import { ListrInquirerPromptAdapter } from "@listr2/prompt-adapter-inquirer";
|
|
9
11
|
import chalk from "chalk";
|
|
10
12
|
import { Marked } from "marked";
|
|
11
13
|
import { AIGNEListr } from "../utils/listr.js";
|
|
@@ -27,11 +29,13 @@ export class TerminalTracer {
|
|
|
27
29
|
: undefined,
|
|
28
30
|
formatResult: (result, options) => [this.formatResult(agent, context, result, options)].filter(Boolean),
|
|
29
31
|
}, [], { concurrent: true });
|
|
30
|
-
const
|
|
32
|
+
const onStart = async ({ context, agent }) => {
|
|
33
|
+
const contextId = context.id;
|
|
34
|
+
const parentContextId = context.parentId;
|
|
31
35
|
const task = {
|
|
32
36
|
...promiseWithResolvers(),
|
|
33
37
|
listr: promiseWithResolvers(),
|
|
34
|
-
startTime:
|
|
38
|
+
startTime: Date.now(),
|
|
35
39
|
};
|
|
36
40
|
this.tasks[contextId] = task;
|
|
37
41
|
const listrTask = {
|
|
@@ -56,12 +60,32 @@ export class TerminalTracer {
|
|
|
56
60
|
else {
|
|
57
61
|
listr.add(listrTask);
|
|
58
62
|
}
|
|
63
|
+
return {
|
|
64
|
+
options: {
|
|
65
|
+
prompts: new Proxy({}, {
|
|
66
|
+
get: (_target, prop) => {
|
|
67
|
+
// biome-ignore lint/performance/noDynamicNamespaceImportAccess: we need to access prompts dynamically
|
|
68
|
+
const method = prompts[prop];
|
|
69
|
+
if (!method)
|
|
70
|
+
return undefined;
|
|
71
|
+
return async (config) => {
|
|
72
|
+
const { taskWrapper } = await task.listr.promise;
|
|
73
|
+
return taskWrapper
|
|
74
|
+
.prompt(ListrInquirerPromptAdapter)
|
|
75
|
+
.run(method, config);
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
},
|
|
80
|
+
};
|
|
59
81
|
};
|
|
60
|
-
const
|
|
82
|
+
const onSuccess = async ({ context, agent, output }) => {
|
|
83
|
+
const contextId = context.id;
|
|
84
|
+
const parentContextId = context.parentId;
|
|
61
85
|
const task = this.tasks[contextId];
|
|
62
86
|
if (!task)
|
|
63
87
|
return;
|
|
64
|
-
task.endTime =
|
|
88
|
+
task.endTime = Date.now();
|
|
65
89
|
const { taskWrapper, ctx } = await task.listr.promise;
|
|
66
90
|
if (agent instanceof ChatModel) {
|
|
67
91
|
const { usage, model } = output;
|
|
@@ -76,27 +100,27 @@ export class TerminalTracer {
|
|
|
76
100
|
}
|
|
77
101
|
task.resolve();
|
|
78
102
|
};
|
|
79
|
-
const
|
|
103
|
+
const onError = async ({ context, agent, error }) => {
|
|
104
|
+
const contextId = context.id;
|
|
80
105
|
const task = this.tasks[contextId];
|
|
81
106
|
if (!task)
|
|
82
107
|
return;
|
|
83
|
-
task.endTime =
|
|
108
|
+
task.endTime = Date.now();
|
|
84
109
|
const { taskWrapper } = await task.listr.promise;
|
|
85
110
|
taskWrapper.title = this.formatTaskTitle(agent, { task, usage: true, time: true });
|
|
86
111
|
task.reject(error);
|
|
87
112
|
};
|
|
88
|
-
context.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
113
|
+
const result = await listr.run(() => context.invoke(agent, input, {
|
|
114
|
+
...options,
|
|
115
|
+
hooks: flat({
|
|
116
|
+
onStart,
|
|
117
|
+
onSuccess,
|
|
118
|
+
onError,
|
|
119
|
+
}, options?.hooks),
|
|
120
|
+
streaming: true,
|
|
121
|
+
newContext: false,
|
|
122
|
+
}));
|
|
123
|
+
return { result, context };
|
|
100
124
|
}
|
|
101
125
|
formatTokenUsage(usage, extra) {
|
|
102
126
|
const items = [
|
package/dist/type.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AgentInvokeOptions as _AgentInvokeOptions, UserContext } from "@aigne/core";
|
|
2
|
+
import type * as prompts from "@inquirer/prompts";
|
|
3
|
+
export interface AgentInvokeOptions<U extends UserContext = UserContext> extends _AgentInvokeOptions<U> {
|
|
4
|
+
prompts: typeof prompts;
|
|
5
|
+
}
|
package/dist/type.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils/download.d.ts
CHANGED
package/dist/utils/download.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Readable } from "node:stream";
|
|
2
2
|
import { finished } from "node:stream/promises";
|
|
3
3
|
import { x } from "tar";
|
|
4
|
-
export async function downloadAndExtract(url, dir) {
|
|
4
|
+
export async function downloadAndExtract(url, dir, options = {}) {
|
|
5
5
|
const response = await fetch(url).catch((error) => {
|
|
6
6
|
throw new Error(`Failed to download package from ${url}: ${error.message}`);
|
|
7
7
|
});
|
|
@@ -12,7 +12,7 @@ export async function downloadAndExtract(url, dir) {
|
|
|
12
12
|
throw new Error(`Failed to download package from ${url}: Unexpected to get empty response`);
|
|
13
13
|
}
|
|
14
14
|
try {
|
|
15
|
-
await finished(Readable.fromWeb(response.body).pipe(x({ C: dir })));
|
|
15
|
+
await finished(Readable.fromWeb(response.body).pipe(x({ C: dir, ...options })));
|
|
16
16
|
}
|
|
17
17
|
catch (error) {
|
|
18
18
|
error.message = `Failed to extract package from ${url}: ${error.message}`;
|
package/dist/utils/listr.js
CHANGED
|
@@ -98,7 +98,7 @@ export class AIGNEListrRenderer extends DefaultRenderer {
|
|
|
98
98
|
this._updater.clear();
|
|
99
99
|
this._logger.toStdout(logs.join(EOL));
|
|
100
100
|
}
|
|
101
|
-
let tasks = super.create(options);
|
|
101
|
+
let tasks = super.create({ ...options, prompt: false });
|
|
102
102
|
const bottomBar = this._options.aigne?.getBottomBarLogs?.({ running });
|
|
103
103
|
if (bottomBar?.length) {
|
|
104
104
|
tasks += EOL.repeat(2);
|
|
@@ -116,6 +116,10 @@ export class AIGNEListrRenderer extends DefaultRenderer {
|
|
|
116
116
|
tasks += output.split(EOL).slice(-Math.max(4, lines)).join(EOL);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
+
const prompt = super["renderPrompt"]();
|
|
120
|
+
if (prompt.length) {
|
|
121
|
+
tasks += `${EOL.repeat(2)}${prompt.join(EOL)}`;
|
|
122
|
+
}
|
|
119
123
|
return tasks;
|
|
120
124
|
}
|
|
121
125
|
_wrap(str) {
|
|
@@ -1,11 +1,54 @@
|
|
|
1
1
|
import { AIGNE } from "@aigne/core";
|
|
2
|
+
import type { LoadableModel } from "@aigne/core/loader/index.js";
|
|
3
|
+
import inquirer from "inquirer";
|
|
2
4
|
import { type RunAIGNECommandOptions } from "./run-with-aigne.js";
|
|
5
|
+
export declare const decrypt: (m: string, s: string, i: string) => string;
|
|
6
|
+
export declare const encrypt: (m: string, s: string, i: string) => string;
|
|
7
|
+
export declare const encodeEncryptionKey: (key: string) => string;
|
|
8
|
+
export declare const decodeEncryptionKey: (str: string) => Uint8Array<ArrayBuffer>;
|
|
9
|
+
export declare const AIGNE_ENV_FILE: string;
|
|
3
10
|
export interface RunOptions extends RunAIGNECommandOptions {
|
|
4
11
|
path: string;
|
|
5
12
|
entryAgent?: string;
|
|
6
13
|
cacheDir?: string;
|
|
7
14
|
}
|
|
8
|
-
|
|
15
|
+
type FetchResult = {
|
|
16
|
+
accessKeyId: string;
|
|
17
|
+
accessKeySecret: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const fetchConfigs: ({ connectUrl, sessionId, fetchInterval, fetchTimeout, }: {
|
|
20
|
+
connectUrl: string;
|
|
21
|
+
sessionId: string;
|
|
22
|
+
fetchInterval: number;
|
|
23
|
+
fetchTimeout: number;
|
|
24
|
+
}) => Promise<any>;
|
|
25
|
+
declare function baseWrapSpinner(_: string, waiting: () => Promise<FetchResult>): Promise<FetchResult>;
|
|
26
|
+
interface CreateConnectOptions {
|
|
27
|
+
connectUrl: string;
|
|
28
|
+
openPage?: (url: string) => void;
|
|
29
|
+
fetchInterval?: number;
|
|
30
|
+
retry?: number;
|
|
31
|
+
source?: string;
|
|
32
|
+
connectAction?: string;
|
|
33
|
+
wrapSpinner?: typeof baseWrapSpinner;
|
|
34
|
+
prettyUrl?: (url: string) => string;
|
|
35
|
+
closeOnSuccess?: boolean;
|
|
36
|
+
intervalFetchConfig?: (options: {
|
|
37
|
+
sessionId: string;
|
|
38
|
+
fetchInterval: number;
|
|
39
|
+
fetchTimeout: number;
|
|
40
|
+
}) => Promise<FetchResult>;
|
|
41
|
+
}
|
|
42
|
+
export declare function createConnect({ connectUrl, openPage, fetchInterval, retry, source, connectAction, wrapSpinner, closeOnSuccess, intervalFetchConfig, }: CreateConnectOptions): Promise<FetchResult>;
|
|
43
|
+
export declare const formatModelName: (models: LoadableModel[], model: string, inquirerPrompt: typeof inquirer.prompt) => Promise<string>;
|
|
44
|
+
export declare function connectToAIGNEHub(url: string): Promise<{
|
|
45
|
+
accessKey: string;
|
|
46
|
+
url: string;
|
|
47
|
+
} | {
|
|
48
|
+
accessKey: undefined;
|
|
49
|
+
url: undefined;
|
|
50
|
+
}>;
|
|
51
|
+
export declare function loadAIGNE(path: string, options?: RunOptions, actionOptions?: {
|
|
9
52
|
inquirerPromptFn?: (prompt: {
|
|
10
53
|
type: string;
|
|
11
54
|
name: string;
|
|
@@ -16,4 +59,6 @@ export declare function loadAIGNE(path: string, options?: RunOptions, checkAutho
|
|
|
16
59
|
}[];
|
|
17
60
|
default: any;
|
|
18
61
|
}) => Promise<any>;
|
|
62
|
+
runTest?: boolean;
|
|
19
63
|
}): Promise<AIGNE<import("@aigne/core").UserContext>>;
|
|
64
|
+
export {};
|