@jixo/cli 0.13.0 → 0.20.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/README.md +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +18 -71
- package/dist/cli.js.map +1 -1
- package/dist/commands/apply.d.ts +9 -0
- package/dist/commands/apply.d.ts.map +1 -0
- package/dist/commands/apply.js +59 -0
- package/dist/commands/apply.js.map +1 -0
- package/dist/commands/gen.d.ts +9 -0
- package/dist/commands/gen.d.ts.map +1 -0
- package/dist/commands/gen.js +43 -0
- package/dist/commands/gen.js.map +1 -0
- package/dist/commands/google-aistudio.d.ts +8 -0
- package/dist/commands/google-aistudio.d.ts.map +1 -0
- package/dist/commands/google-aistudio.js +51 -0
- package/dist/commands/google-aistudio.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -25
- package/dist/commands/daemon.d.ts +0 -5
- package/dist/commands/daemon.d.ts.map +0 -1
- package/dist/commands/daemon.js +0 -20
- package/dist/commands/daemon.js.map +0 -1
- package/dist/commands/doctor/config.d.ts +0 -3
- package/dist/commands/doctor/config.d.ts.map +0 -1
- package/dist/commands/doctor/config.js +0 -17
- package/dist/commands/doctor/config.js.map +0 -1
- package/dist/commands/doctor/doctor.d.ts +0 -3
- package/dist/commands/doctor/doctor.d.ts.map +0 -1
- package/dist/commands/doctor/doctor.js +0 -158
- package/dist/commands/doctor/doctor.js.map +0 -1
- package/dist/commands/doctor/doctor.test.d.ts +0 -2
- package/dist/commands/doctor/doctor.test.d.ts.map +0 -1
- package/dist/commands/doctor/doctor.test.js +0 -14
- package/dist/commands/doctor/doctor.test.js.map +0 -1
- package/dist/commands/doctor/index.d.ts +0 -2
- package/dist/commands/doctor/index.d.ts.map +0 -1
- package/dist/commands/doctor/index.js +0 -8
- package/dist/commands/doctor/index.js.map +0 -1
- package/dist/commands/doctor/types.d.ts +0 -45
- package/dist/commands/doctor/types.d.ts.map +0 -1
- package/dist/commands/doctor/types.js +0 -3
- package/dist/commands/doctor/types.js.map +0 -1
- package/dist/commands/init.d.ts +0 -2
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -40
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/prompts/list.d.ts +0 -2
- package/dist/commands/prompts/list.d.ts.map +0 -1
- package/dist/commands/prompts/list.js +0 -14
- package/dist/commands/prompts/list.js.map +0 -1
- package/dist/commands/prompts/upgrade.d.ts +0 -4
- package/dist/commands/prompts/upgrade.d.ts.map +0 -1
- package/dist/commands/prompts/upgrade.js +0 -17
- package/dist/commands/prompts/upgrade.js.map +0 -1
- package/dist/commands/tasks/AiTaskTui.d.ts +0 -22
- package/dist/commands/tasks/AiTaskTui.d.ts.map +0 -1
- package/dist/commands/tasks/AiTaskTui.js +0 -52
- package/dist/commands/tasks/AiTaskTui.js.map +0 -1
- package/dist/commands/tasks/ai-tasl-tui.d.ts +0 -22
- package/dist/commands/tasks/ai-tasl-tui.d.ts.map +0 -1
- package/dist/commands/tasks/ai-tasl-tui.js +0 -53
- package/dist/commands/tasks/ai-tasl-tui.js.map +0 -1
- package/dist/commands/tasks/ai-tools.d.ts +0 -804
- package/dist/commands/tasks/ai-tools.d.ts.map +0 -1
- package/dist/commands/tasks/ai-tools.js +0 -140
- package/dist/commands/tasks/ai-tools.js.map +0 -1
- package/dist/commands/tasks/model-providers.d.ts +0 -13
- package/dist/commands/tasks/model-providers.d.ts.map +0 -1
- package/dist/commands/tasks/model-providers.js +0 -84
- package/dist/commands/tasks/model-providers.js.map +0 -1
- package/dist/commands/tasks/run-ai-task.d.ts +0 -4
- package/dist/commands/tasks/run-ai-task.d.ts.map +0 -1
- package/dist/commands/tasks/run-ai-task.js +0 -348
- package/dist/commands/tasks/run-ai-task.js.map +0 -1
- package/dist/commands/tasks/run.d.ts +0 -10
- package/dist/commands/tasks/run.d.ts.map +0 -1
- package/dist/commands/tasks/run.js +0 -44
- package/dist/commands/tasks/run.js.map +0 -1
- package/dist/config.d.ts +0 -15
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -23
- package/dist/config.js.map +0 -1
- package/dist/env.d.ts +0 -6
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -16
- package/dist/env.js.map +0 -1
- package/dist/helper/ai-retry-error.d.ts +0 -3
- package/dist/helper/ai-retry-error.d.ts.map +0 -1
- package/dist/helper/ai-retry-error.js +0 -108
- package/dist/helper/ai-retry-error.js.map +0 -1
- package/dist/helper/find-changes.d.ts +0 -3
- package/dist/helper/find-changes.d.ts.map +0 -1
- package/dist/helper/find-changes.js +0 -113
- package/dist/helper/find-changes.js.map +0 -1
- package/dist/helper/find-changes.test.d.ts +0 -2
- package/dist/helper/find-changes.test.d.ts.map +0 -1
- package/dist/helper/find-changes.test.js +0 -22
- package/dist/helper/find-changes.test.js.map +0 -1
- package/dist/helper/handle-ai-error.d.ts +0 -5
- package/dist/helper/handle-ai-error.d.ts.map +0 -1
- package/dist/helper/handle-ai-error.js +0 -122
- package/dist/helper/handle-ai-error.js.map +0 -1
- package/dist/helper/logger.d.ts +0 -3
- package/dist/helper/logger.d.ts.map +0 -1
- package/dist/helper/logger.js +0 -26
- package/dist/helper/logger.js.map +0 -1
- package/dist/helper/parse-progress.d.ts +0 -2
- package/dist/helper/parse-progress.d.ts.map +0 -1
- package/dist/helper/parse-progress.js +0 -28
- package/dist/helper/parse-progress.js.map +0 -1
- package/dist/helper/prompts-loader.d.ts +0 -11
- package/dist/helper/prompts-loader.d.ts.map +0 -1
- package/dist/helper/prompts-loader.js +0 -28
- package/dist/helper/prompts-loader.js.map +0 -1
- package/dist/helper/resolve-ai-tasks.d.ts +0 -42
- package/dist/helper/resolve-ai-tasks.d.ts.map +0 -1
- package/dist/helper/resolve-ai-tasks.js +0 -162
- package/dist/helper/resolve-ai-tasks.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
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;gBAmDjB,MAAM;oBAkBH,MAAM;;;;;;;;;;;;CAgD1B,CAAC"}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { func_lazy, func_remember, map_get_or_put_async } from "@gaubee/util";
|
|
2
|
-
import { experimental_createMCPClient as createMCPClient, tool } from "ai";
|
|
3
|
-
import { Experimental_StdioMCPTransport } from "ai/mcp-stdio";
|
|
4
|
-
import z from "zod";
|
|
5
|
-
import { getAllPromptConfigs, getAllSkillMap } from "../../helper/prompts-loader.js";
|
|
6
|
-
export const tools = {
|
|
7
|
-
fileSystem: func_lazy(() => {
|
|
8
|
-
const map = new Map();
|
|
9
|
-
return (cwd) => {
|
|
10
|
-
return map_get_or_put_async(map, cwd, async () => {
|
|
11
|
-
const mcpClient = await createMCPClient({
|
|
12
|
-
transport: new Experimental_StdioMCPTransport({
|
|
13
|
-
command: "pnpm",
|
|
14
|
-
args: ["mcp-fs", cwd],
|
|
15
|
-
}),
|
|
16
|
-
});
|
|
17
|
-
const tools = await mcpClient.tools();
|
|
18
|
-
return tools;
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
}),
|
|
22
|
-
memory: func_lazy(() => {
|
|
23
|
-
const map = new Map();
|
|
24
|
-
return (memory_filepath) => {
|
|
25
|
-
return map_get_or_put_async(map, memory_filepath, async () => {
|
|
26
|
-
const mcpClient = await createMCPClient({
|
|
27
|
-
transport: new Experimental_StdioMCPTransport({
|
|
28
|
-
command: "pnpx",
|
|
29
|
-
args: ["@modelcontextprotocol/server-memory"],
|
|
30
|
-
env: {
|
|
31
|
-
MEMORY_FILE_PATH: memory_filepath,
|
|
32
|
-
},
|
|
33
|
-
}),
|
|
34
|
-
});
|
|
35
|
-
const tools = await mcpClient.tools();
|
|
36
|
-
return tools;
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
}),
|
|
40
|
-
pnpm: func_remember(async () => {
|
|
41
|
-
const mcpClient = await createMCPClient({
|
|
42
|
-
transport: new Experimental_StdioMCPTransport({
|
|
43
|
-
// command: "pnpx",
|
|
44
|
-
// args: ["@jixo/mcp-pnpm"],
|
|
45
|
-
command: "pnpm",
|
|
46
|
-
args: ["mcp-pnpm"],
|
|
47
|
-
}),
|
|
48
|
-
});
|
|
49
|
-
const tools = await mcpClient.tools();
|
|
50
|
-
return tools;
|
|
51
|
-
}),
|
|
52
|
-
sequentialThinking: func_remember(async () => {
|
|
53
|
-
const mcpClient = await createMCPClient({
|
|
54
|
-
transport: new Experimental_StdioMCPTransport({
|
|
55
|
-
command: "pnpx",
|
|
56
|
-
args: ["@modelcontextprotocol/server-sequential-thinking"],
|
|
57
|
-
}),
|
|
58
|
-
});
|
|
59
|
-
const tools = await mcpClient.tools();
|
|
60
|
-
return tools;
|
|
61
|
-
}),
|
|
62
|
-
fetch: func_remember(async () => {
|
|
63
|
-
const mcpClient = await createMCPClient({
|
|
64
|
-
transport: new Experimental_StdioMCPTransport({
|
|
65
|
-
command: "uvx",
|
|
66
|
-
args: ["mcp-server-fetch"],
|
|
67
|
-
}),
|
|
68
|
-
});
|
|
69
|
-
const tools = await mcpClient.tools();
|
|
70
|
-
return tools;
|
|
71
|
-
}),
|
|
72
|
-
git: func_lazy(() => {
|
|
73
|
-
const map = new Map();
|
|
74
|
-
return (repo) => {
|
|
75
|
-
return map_get_or_put_async(map, repo, async () => {
|
|
76
|
-
const mcpClient = await createMCPClient({
|
|
77
|
-
transport: new Experimental_StdioMCPTransport({
|
|
78
|
-
command: "uvx",
|
|
79
|
-
args: ["mcp-server-git", "--repository", repo],
|
|
80
|
-
}),
|
|
81
|
-
});
|
|
82
|
-
const tools = await mcpClient.tools();
|
|
83
|
-
return tools;
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
}),
|
|
87
|
-
jixo: func_lazy(() => {
|
|
88
|
-
// const map = new Map<string, ToolSet>();
|
|
89
|
-
const configs = getAllPromptConfigs();
|
|
90
|
-
const allSkillMap = getAllSkillMap();
|
|
91
|
-
return (ai_task) => {
|
|
92
|
-
return {
|
|
93
|
-
get_jixo_skill: tool({
|
|
94
|
-
description: "Get the JIXO skill prompt by name",
|
|
95
|
-
parameters: z.object({
|
|
96
|
-
name: z.string().describe("The name to get the skill for"),
|
|
97
|
-
}),
|
|
98
|
-
execute: async ({ name }) => {
|
|
99
|
-
if (name in allSkillMap) {
|
|
100
|
-
return Reflect.get(configs, name);
|
|
101
|
-
}
|
|
102
|
-
return { type: "error", message: "Skill not found" };
|
|
103
|
-
},
|
|
104
|
-
}),
|
|
105
|
-
...(() => {
|
|
106
|
-
// TODO: use process shared lock-manager
|
|
107
|
-
return {
|
|
108
|
-
jixo_log_lock: tool({
|
|
109
|
-
description: "Lock the log file for writing, will return log file content",
|
|
110
|
-
parameters: z.object({}),
|
|
111
|
-
execute: async () => {
|
|
112
|
-
ai_task.reloadLog();
|
|
113
|
-
return { type: "success", filepath: ai_task.log.filepath, content: ai_task.log.content };
|
|
114
|
-
},
|
|
115
|
-
}),
|
|
116
|
-
jixo_log_unlock: tool({
|
|
117
|
-
description: "Unlock the log file, for other locker can read the log file and then write.",
|
|
118
|
-
parameters: z.object({}),
|
|
119
|
-
execute: async () => {
|
|
120
|
-
return { type: "success" };
|
|
121
|
-
},
|
|
122
|
-
}),
|
|
123
|
-
jixo_tasks_exit: tool({
|
|
124
|
-
description: "Exit the tasks.",
|
|
125
|
-
parameters: z.object({
|
|
126
|
-
code: z.number({ description: "Exit code: 0 is Success; 1 is Error; 2 is No Tasks" }),
|
|
127
|
-
reason: z.string({ description: "Exit reasons that provide human-readable information" }),
|
|
128
|
-
}),
|
|
129
|
-
execute: async ({ code, reason }) => {
|
|
130
|
-
ai_task.exit(code, reason);
|
|
131
|
-
return { type: "success" };
|
|
132
|
-
},
|
|
133
|
-
}),
|
|
134
|
-
};
|
|
135
|
-
})(),
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
}),
|
|
139
|
-
};
|
|
140
|
-
//# sourceMappingURL=ai-tools.js.map
|
|
@@ -1 +0,0 @@
|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CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;CACH,CAAC","sourcesContent":["import {func_lazy, func_remember, map_get_or_put_async} from \"@gaubee/util\";\nimport {experimental_createMCPClient as createMCPClient, tool, type ToolSet} from \"ai\";\nimport {Experimental_StdioMCPTransport} from \"ai/mcp-stdio\";\nimport z from \"zod\";\nimport {getAllPromptConfigs, getAllSkillMap} from \"../../helper/prompts-loader.js\";\nimport type {AiTask} from \"../../helper/resolve-ai-tasks.js\";\n\nexport const tools = {\n fileSystem: func_lazy(() => {\n const map = new Map<string, ToolSet>();\n return (cwd: string) => {\n return map_get_or_put_async(map, cwd, async () => {\n const mcpClient = await createMCPClient({\n transport: new Experimental_StdioMCPTransport({\n command: \"pnpm\",\n args: [\"mcp-fs\", cwd],\n }),\n });\n const tools = await mcpClient.tools();\n return tools;\n });\n };\n }),\n memory: func_lazy(() => {\n const map = new Map<string, ToolSet>();\n return (memory_filepath: string) => {\n return map_get_or_put_async(map, memory_filepath, async () => {\n const mcpClient = await createMCPClient({\n transport: new Experimental_StdioMCPTransport({\n command: \"pnpx\",\n args: [\"@modelcontextprotocol/server-memory\"],\n env: {\n MEMORY_FILE_PATH: memory_filepath,\n },\n }),\n });\n const tools = await mcpClient.tools();\n return tools;\n });\n };\n }),\n pnpm: func_remember(async () => {\n const mcpClient = await createMCPClient({\n transport: new Experimental_StdioMCPTransport({\n // command: \"pnpx\",\n // args: [\"@jixo/mcp-pnpm\"],\n command: \"pnpm\",\n args: [\"mcp-pnpm\"],\n }),\n });\n const tools = await mcpClient.tools();\n return tools;\n }),\n sequentialThinking: func_remember(async () => {\n const mcpClient = await createMCPClient({\n transport: new Experimental_StdioMCPTransport({\n command: \"pnpx\",\n args: [\"@modelcontextprotocol/server-sequential-thinking\"],\n }),\n });\n const tools = await mcpClient.tools();\n return tools;\n }),\n fetch: func_remember(async () => {\n const mcpClient = await createMCPClient({\n transport: new Experimental_StdioMCPTransport({\n command: \"uvx\",\n args: [\"mcp-server-fetch\"],\n }),\n });\n const tools = await mcpClient.tools();\n return tools;\n }),\n git: func_lazy(() => {\n const map = new Map<string, ToolSet>();\n\n return (repo: string) => {\n return map_get_or_put_async(map, repo, async () => {\n const mcpClient = await createMCPClient({\n transport: new Experimental_StdioMCPTransport({\n command: \"uvx\",\n args: [\"mcp-server-git\", \"--repository\", repo],\n }),\n });\n const tools = await mcpClient.tools();\n return tools;\n });\n };\n }),\n\n jixo: func_lazy(() => {\n // const map = new Map<string, ToolSet>();\n const configs = getAllPromptConfigs();\n const allSkillMap = getAllSkillMap();\n return (ai_task: AiTask) => {\n return {\n get_jixo_skill: tool({\n description: \"Get the JIXO skill prompt by name\",\n parameters: z.object({\n name: z.string().describe(\"The name to get the skill for\"),\n }),\n execute: async ({name}) => {\n if (name in allSkillMap) {\n return Reflect.get(configs, name);\n }\n return {type: \"error\", message: \"Skill not found\"};\n },\n }),\n ...(() => {\n // TODO: use process shared lock-manager\n return {\n jixo_log_lock: tool({\n description: \"Lock the log file for writing, will return log file content\",\n parameters: z.object({}),\n execute: async () => {\n ai_task.reloadLog();\n return {type: \"success\", filepath: ai_task.log.filepath, content: ai_task.log.content};\n },\n }),\n jixo_log_unlock: tool({\n description: \"Unlock the log file, for other locker can read the log file and then write.\",\n parameters: z.object({}),\n execute: async () => {\n return {type: \"success\"};\n },\n }),\n jixo_tasks_exit: tool({\n description: \"Exit the tasks.\",\n parameters: z.object({\n code: z.number({description: \"Exit code: 0 is Success; 1 is Error; 2 is No Tasks\"}),\n reason: z.string({description: \"Exit reasons that provide human-readable information\"}),\n }),\n execute: async ({code, reason}) => {\n ai_task.exit(code, reason);\n return {type: \"success\"};\n },\n }),\n };\n })(),\n };\n };\n }),\n};\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type OpenAIProvider } from "@ai-sdk/openai";
|
|
2
|
-
export declare const providers: {
|
|
3
|
-
readonly deepseek: import("@ai-sdk/deepseek").DeepSeekProvider;
|
|
4
|
-
readonly anthropic: import("@ai-sdk/anthropic").AnthropicProvider;
|
|
5
|
-
readonly google: import("@ai-sdk/google").GoogleGenerativeAIProvider;
|
|
6
|
-
readonly openai: OpenAIProvider;
|
|
7
|
-
readonly xai: import("@ai-sdk/xai").XaiProvider;
|
|
8
|
-
readonly deepinfra: import("@ai-sdk/deepinfra").DeepInfraProvider;
|
|
9
|
-
};
|
|
10
|
-
type LanguageModelV2 = ReturnType<OpenAIProvider>;
|
|
11
|
-
export declare const getModel: (model?: string) => LanguageModelV2;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=model-providers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model-providers.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/model-providers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,KAAK,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAOjE,eAAO,MAAM,SAAS;;;;;;;CA2CpB,CAAC;AAEH,KAAK,eAAe,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;AAClD,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,KAAG,eA6BzC,CAAC"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
2
|
-
import { createDeepInfra } from "@ai-sdk/deepinfra";
|
|
3
|
-
import { createDeepSeek } from "@ai-sdk/deepseek";
|
|
4
|
-
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
5
|
-
import { createOpenAI } from "@ai-sdk/openai";
|
|
6
|
-
import { createXai } from "@ai-sdk/xai";
|
|
7
|
-
import { obj_lazify } from "@gaubee/util";
|
|
8
|
-
import { match, P } from "ts-pattern";
|
|
9
|
-
import { safeEnv } from "../../env.js";
|
|
10
|
-
// const wrapper = (provider:)
|
|
11
|
-
export const providers = obj_lazify({
|
|
12
|
-
get deepseek() {
|
|
13
|
-
return createDeepSeek({
|
|
14
|
-
baseURL: safeEnv.JIXO_DEEPSEEK_BASE_URL || undefined,
|
|
15
|
-
apiKey: safeEnv.JIXO_DEEPSEEK_API_KEY,
|
|
16
|
-
});
|
|
17
|
-
},
|
|
18
|
-
get anthropic() {
|
|
19
|
-
// const bashTool = anthropic.tools.bash_20250124({
|
|
20
|
-
// execute: async ({command, restart}) => execSync(command).toString(),
|
|
21
|
-
// });
|
|
22
|
-
const provider = createAnthropic({
|
|
23
|
-
baseURL: safeEnv.JIXO_ANTHROPIC_BASE_URL || undefined,
|
|
24
|
-
apiKey: safeEnv.JIXO_ANTHROPIC_API_KEY,
|
|
25
|
-
});
|
|
26
|
-
return provider;
|
|
27
|
-
},
|
|
28
|
-
get google() {
|
|
29
|
-
return createGoogleGenerativeAI({
|
|
30
|
-
baseURL: safeEnv.JIXO_GOOGLE_BASE_URL || undefined,
|
|
31
|
-
apiKey: safeEnv.JIXO_GOOGLE_API_KEY,
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
get openai() {
|
|
35
|
-
return createOpenAI({
|
|
36
|
-
baseURL: safeEnv.JIXO_OPENAI_BASE_URL || undefined,
|
|
37
|
-
apiKey: safeEnv.JIXO_OPENAI_API_KEY,
|
|
38
|
-
organization: safeEnv.JIXO_OPENAI_ORGANIZATION || undefined,
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
get xai() {
|
|
42
|
-
return createXai({
|
|
43
|
-
baseURL: safeEnv.JIXO_XAI_BASE_URL || undefined,
|
|
44
|
-
apiKey: safeEnv.JIXO_XAI_API_KEY,
|
|
45
|
-
});
|
|
46
|
-
},
|
|
47
|
-
get deepinfra() {
|
|
48
|
-
return createDeepInfra({
|
|
49
|
-
baseURL: safeEnv.JIXO_DEEPINFRA_BASE_URL || undefined,
|
|
50
|
-
apiKey: safeEnv.JIXO_DEEPINFRA_API_KEY,
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
export const getModel = (model) => {
|
|
55
|
-
return match(model)
|
|
56
|
-
.with(P.string.startsWith("deepseek-"), (model) => providers.deepseek(model))
|
|
57
|
-
.with(P.string.startsWith("gemini-"), (model) => providers.google(model))
|
|
58
|
-
.with(P.string.startsWith("o3-"), P.string.startsWith("o1-"), P.string.startsWith("gpt-"), (model) => providers.openai(model))
|
|
59
|
-
.with(P.string.startsWith("claude-"), (model) => providers.anthropic(model))
|
|
60
|
-
.with(P.string.startsWith("grok-"), (model) => providers.xai(model))
|
|
61
|
-
.with(P.string.includes("/"), (model) => providers.deepinfra(model))
|
|
62
|
-
.otherwise(() => {
|
|
63
|
-
if (safeEnv.JIXO_DEEPSEEK_API_KEY) {
|
|
64
|
-
return providers.deepseek("deepseek-reasoner");
|
|
65
|
-
}
|
|
66
|
-
if (safeEnv.JIXO_GOOGLE_API_KEY) {
|
|
67
|
-
return providers.google("gemini-2.5-pro-preview-05-06");
|
|
68
|
-
}
|
|
69
|
-
if (safeEnv.JIXO_OPENAI_API_KEY) {
|
|
70
|
-
return providers.openai("o3-mini");
|
|
71
|
-
}
|
|
72
|
-
if (safeEnv.JIXO_ANTHROPIC_API_KEY) {
|
|
73
|
-
return providers.anthropic("claude-4-sonnet-20250514");
|
|
74
|
-
}
|
|
75
|
-
if (safeEnv.JIXO_XAI_API_KEY) {
|
|
76
|
-
return providers.xai("grok-3-beta");
|
|
77
|
-
}
|
|
78
|
-
if (safeEnv.JIXO_DEEPINFRA_API_KEY) {
|
|
79
|
-
return providers.deepinfra("meta-llama/Meta-Llama-3.1-405B-Instruct");
|
|
80
|
-
}
|
|
81
|
-
return providers.deepseek("deepseek-reasoner");
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
//# sourceMappingURL=model-providers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model-providers.js","sourceRoot":"","sources":["../../../src/commands/tasks/model-providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;A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IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;SACnE,SAAS,CAAC,GAAG,EAAE;QACd,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;YAClC,OAAO,SAAS,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;YAChC,OAAO,SAAS,CAAC,MAAM,CAAC,8BAA8B,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;YAChC,OAAO,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC;YACnC,OAAO,SAAS,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC7B,OAAO,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACtC,CAAC;QACD,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC;YACnC,OAAO,SAAS,CAAC,SAAS,CAAC,yCAAyC,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,SAAS,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["import {createAnthropic} from \"@ai-sdk/anthropic\";\nimport {createDeepInfra} from \"@ai-sdk/deepinfra\";\nimport {createDeepSeek} from \"@ai-sdk/deepseek\";\nimport {createGoogleGenerativeAI} from \"@ai-sdk/google\";\nimport {createOpenAI, type OpenAIProvider} from \"@ai-sdk/openai\";\nimport {createXai} from \"@ai-sdk/xai\";\nimport {obj_lazify} from \"@gaubee/util\";\nimport {match, P} from \"ts-pattern\";\nimport {safeEnv} from \"../../env.js\";\n\n// const wrapper = (provider:)\nexport const providers = obj_lazify({\n get deepseek() {\n return createDeepSeek({\n baseURL: safeEnv.JIXO_DEEPSEEK_BASE_URL || undefined,\n apiKey: safeEnv.JIXO_DEEPSEEK_API_KEY,\n });\n },\n get anthropic() {\n // const bashTool = anthropic.tools.bash_20250124({\n // execute: async ({command, restart}) => execSync(command).toString(),\n // });\n\n const provider = createAnthropic({\n baseURL: safeEnv.JIXO_ANTHROPIC_BASE_URL || undefined,\n apiKey: safeEnv.JIXO_ANTHROPIC_API_KEY,\n });\n return provider;\n },\n get google() {\n return createGoogleGenerativeAI({\n baseURL: safeEnv.JIXO_GOOGLE_BASE_URL || undefined,\n apiKey: safeEnv.JIXO_GOOGLE_API_KEY,\n });\n },\n get openai() {\n return createOpenAI({\n baseURL: safeEnv.JIXO_OPENAI_BASE_URL || undefined,\n apiKey: safeEnv.JIXO_OPENAI_API_KEY,\n organization: safeEnv.JIXO_OPENAI_ORGANIZATION || undefined,\n });\n },\n get xai() {\n return createXai({\n baseURL: safeEnv.JIXO_XAI_BASE_URL || undefined,\n apiKey: safeEnv.JIXO_XAI_API_KEY,\n });\n },\n get deepinfra() {\n return createDeepInfra({\n baseURL: safeEnv.JIXO_DEEPINFRA_BASE_URL || undefined,\n apiKey: safeEnv.JIXO_DEEPINFRA_API_KEY,\n });\n },\n});\n\ntype LanguageModelV2 = ReturnType<OpenAIProvider>;\nexport const getModel = (model?: string): LanguageModelV2 => {\n return match(model)\n .with(P.string.startsWith(\"deepseek-\"), (model) => providers.deepseek(model))\n .with(P.string.startsWith(\"gemini-\"), (model) => providers.google(model))\n .with(P.string.startsWith(\"o3-\"), P.string.startsWith(\"o1-\"), P.string.startsWith(\"gpt-\"), (model) => providers.openai(model))\n .with(P.string.startsWith(\"claude-\"), (model) => providers.anthropic(model))\n .with(P.string.startsWith(\"grok-\"), (model) => providers.xai(model))\n .with(P.string.includes(\"/\"), (model) => providers.deepinfra(model))\n .otherwise(() => {\n if (safeEnv.JIXO_DEEPSEEK_API_KEY) {\n return providers.deepseek(\"deepseek-reasoner\");\n }\n if (safeEnv.JIXO_GOOGLE_API_KEY) {\n return providers.google(\"gemini-2.5-pro-preview-05-06\");\n }\n if (safeEnv.JIXO_OPENAI_API_KEY) {\n return providers.openai(\"o3-mini\");\n }\n if (safeEnv.JIXO_ANTHROPIC_API_KEY) {\n return providers.anthropic(\"claude-4-sonnet-20250514\");\n }\n if (safeEnv.JIXO_XAI_API_KEY) {\n return providers.xai(\"grok-3-beta\");\n }\n if (safeEnv.JIXO_DEEPINFRA_API_KEY) {\n return providers.deepinfra(\"meta-llama/Meta-Llama-3.1-405B-Instruct\");\n }\n return providers.deepseek(\"deepseek-reasoner\");\n });\n};\n"]}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { FileEntry } from "@gaubee/nodekit";
|
|
2
|
-
import type { AiTask } from "../../helper/resolve-ai-tasks.js";
|
|
3
|
-
export declare const runAiTask: (ai_task: AiTask, loopTimes: number, allFiles: FileEntry[], changedFilesSet: Record<string, FileEntry[]>) => Promise<void>;
|
|
4
|
-
//# sourceMappingURL=run-ai-task.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-ai-task.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/run-ai-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAA0C,MAAM,iBAAiB,CAAC;AAW/F,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,kCAAkC,CAAC;AAO7D,eAAO,MAAM,SAAS,GAAU,SAAS,MAAM,EAAE,WAAW,MAAM,EAAE,UAAU,SAAS,EAAE,EAAE,iBAAiB,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,kBAwCtI,CAAC"}
|
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
import { blue, cyan, FileEntry, gray, green, red, spinner, YAML, yellow } from "@gaubee/nodekit";
|
|
2
|
-
import { func_catch, obj_omit } from "@gaubee/util";
|
|
3
|
-
import { streamText } from "ai";
|
|
4
|
-
import ms from "ms";
|
|
5
|
-
import { open } from "node:fs/promises";
|
|
6
|
-
import os from "node:os";
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
import { match, P } from "ts-pattern";
|
|
9
|
-
import { handleError } from "../../helper/handle-ai-error.js";
|
|
10
|
-
import { createDebug } from "../../helper/logger.js";
|
|
11
|
-
import { getAllPromptConfigs, getAllSkillMap as getAllSkillNavMap } from "../../helper/prompts-loader.js";
|
|
12
|
-
import { AiTaskTui } from "./ai-tasl-tui.js";
|
|
13
|
-
import { tools } from "./ai-tools.js";
|
|
14
|
-
import { getModel } from "./model-providers.js";
|
|
15
|
-
const log = createDebug("jixo:run-ai-task");
|
|
16
|
-
export const runAiTask = async (ai_task, loopTimes, allFiles, changedFilesSet) => {
|
|
17
|
-
const tool_spinner = spinner({
|
|
18
|
-
prefixText: "🧰",
|
|
19
|
-
text: "Preparing AI tools...",
|
|
20
|
-
});
|
|
21
|
-
tool_spinner.start();
|
|
22
|
-
const availableTools = {
|
|
23
|
-
...(await tools.fileSystem(ai_task.cwd)),
|
|
24
|
-
...(await tools.pnpm()),
|
|
25
|
-
...(await tools.jixo(ai_task)),
|
|
26
|
-
...(await tools.git(ai_task.cwd)),
|
|
27
|
-
};
|
|
28
|
-
tool_spinner.clear();
|
|
29
|
-
tool_spinner.stop();
|
|
30
|
-
const json_line_log_file_handle = await open(path.join(ai_task.cwd, ".jixo", `${ai_task.runner}.log.jsonl`), "a");
|
|
31
|
-
const __writeJsonLineLog = (...lineDatas) => {
|
|
32
|
-
for (const lineData of lineDatas) {
|
|
33
|
-
try {
|
|
34
|
-
const log = typeof lineData === "function" ? lineData() : lineData;
|
|
35
|
-
json_line_log_file_handle.appendFile(JSON.stringify(log) + "\n");
|
|
36
|
-
}
|
|
37
|
-
catch { }
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const tui = new AiTaskTui(ai_task, spinner({ text: `Initializing AI task: ${cyan(ai_task.jobName)}...`, prefixText: "⏳ " }));
|
|
41
|
-
tui.spinner.start();
|
|
42
|
-
const updateTuiState = () => {
|
|
43
|
-
tui.setStatus("loop and time", `${green(`[${loopTimes}]`)} ${cyan(`+${ms(Date.now() - new Date(ai_task.startTime).getTime())}`)}`);
|
|
44
|
-
};
|
|
45
|
-
const ti = setInterval(updateTuiState, 1000);
|
|
46
|
-
updateTuiState();
|
|
47
|
-
try {
|
|
48
|
-
await _runAiTask(ai_task, availableTools, allFiles, changedFilesSet, tui, __writeJsonLineLog);
|
|
49
|
-
}
|
|
50
|
-
finally {
|
|
51
|
-
// Fallback spinner stop if loop exits unexpectedly
|
|
52
|
-
clearInterval(ti);
|
|
53
|
-
tui.stop();
|
|
54
|
-
json_line_log_file_handle.close();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const _runAiTask = async (ai_task, availableTools, allFiles, changedFilesSet, tui, __writeJsonLineLog) => {
|
|
58
|
-
const model = getModel(ai_task.model);
|
|
59
|
-
const initialMessages = [];
|
|
60
|
-
const maxTurns = 40; // Safeguard against infinite loops
|
|
61
|
-
const promptConfigs = getAllPromptConfigs();
|
|
62
|
-
for (const role of ["system", "user"]) {
|
|
63
|
-
const promptConfig = promptConfigs[role];
|
|
64
|
-
const promptContent = promptConfig.content //
|
|
65
|
-
.replace(/\{\{task.([\.\w]+)\}\}/g, (_, key) => {
|
|
66
|
-
if (key.includes(".")) {
|
|
67
|
-
const paths = key.split(".");
|
|
68
|
-
let res = ai_task;
|
|
69
|
-
for (const p of paths) {
|
|
70
|
-
res = Reflect.get(res, p);
|
|
71
|
-
if (!res) {
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return res;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
return Reflect.get(ai_task, key);
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
.replace(/\{\{env.(\w+)\}\}/g, (_, key) => {
|
|
82
|
-
const envKey = key.toUpperCase();
|
|
83
|
-
const envValue = Reflect.get(process.env, envKey) ??
|
|
84
|
-
match(envKey)
|
|
85
|
-
.with("USER", () => os.userInfo().username)
|
|
86
|
-
.otherwise(() => "");
|
|
87
|
-
return envValue;
|
|
88
|
-
})
|
|
89
|
-
.replaceAll("{{allSkills}}", (_, key) => {
|
|
90
|
-
return YAML.stringify(getAllSkillNavMap());
|
|
91
|
-
})
|
|
92
|
-
.replaceAll("{{allFiles}}", YAML.stringify({
|
|
93
|
-
[ai_task.cwd]: {
|
|
94
|
-
count: allFiles.length,
|
|
95
|
-
file: allFiles.map((e) => e.relativePath),
|
|
96
|
-
},
|
|
97
|
-
}))
|
|
98
|
-
.replaceAll("{{maxTurns}}", () => `${maxTurns}`)
|
|
99
|
-
.replaceAll("{{changedFiles}}", YAML.stringify(Object.entries(changedFilesSet).reduce((tree, [dir, changedFiles]) => {
|
|
100
|
-
tree[dir] = {
|
|
101
|
-
count: changedFiles.length,
|
|
102
|
-
files: changedFiles.map((e) => e.relativePath),
|
|
103
|
-
};
|
|
104
|
-
return tree;
|
|
105
|
-
}, {})));
|
|
106
|
-
log(`PROMPT ${role}:`, promptContent);
|
|
107
|
-
initialMessages.push({
|
|
108
|
-
role: role,
|
|
109
|
-
content: promptContent,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
const currentMessages = [...initialMessages];
|
|
113
|
-
__writeJsonLineLog(...currentMessages);
|
|
114
|
-
loop: for (let turn = 0; turn < maxTurns; turn++) {
|
|
115
|
-
if (turn === 0) {
|
|
116
|
-
tui.setStatus("turns", `Connecting To ${model.provider}...`);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
tui.setStatus("turns", `Processing step ${turn + 1}/${maxTurns}...`);
|
|
120
|
-
const userTurnMessage = {
|
|
121
|
-
role: "user",
|
|
122
|
-
content: `Turns: ${turn}/${maxTurns}`,
|
|
123
|
-
};
|
|
124
|
-
currentMessages.push(userTurnMessage);
|
|
125
|
-
__writeJsonLineLog(userTurnMessage);
|
|
126
|
-
}
|
|
127
|
-
const result = await streamText({
|
|
128
|
-
model: model,
|
|
129
|
-
messages: currentMessages,
|
|
130
|
-
tools: availableTools,
|
|
131
|
-
toolChoice: "auto", // Changed to auto for more flexibility
|
|
132
|
-
onError: () => { },
|
|
133
|
-
});
|
|
134
|
-
let fullReasoningText = "";
|
|
135
|
-
let fullText = "";
|
|
136
|
-
let firstStreamPart = true;
|
|
137
|
-
const requestedToolCalls = []; // Using any for now, should be ToolCallPart from 'ai'
|
|
138
|
-
const assistantMessageContent = [];
|
|
139
|
-
const _currentAssistantMessage = { role: "assistant", content: assistantMessageContent };
|
|
140
|
-
const LOOP_SIGNALS = {
|
|
141
|
-
RETURN: "RETURN",
|
|
142
|
-
BREAK: "BREAK",
|
|
143
|
-
CONTINUE: "CONTINUE",
|
|
144
|
-
ERROR: "ERROR",
|
|
145
|
-
};
|
|
146
|
-
for await (const part of result.fullStream) {
|
|
147
|
-
__writeJsonLineLog(() => match(part)
|
|
148
|
-
.with({ type: "start-step" }, (p) => {
|
|
149
|
-
obj_omit(p, "request");
|
|
150
|
-
})
|
|
151
|
-
.otherwise((p) => p));
|
|
152
|
-
if (firstStreamPart) {
|
|
153
|
-
firstStreamPart = false;
|
|
154
|
-
tui.text = ""; // Clear initial connecting/processing message
|
|
155
|
-
}
|
|
156
|
-
const LOOP_SIGNAL = await match(part)
|
|
157
|
-
.with({ type: "text" }, (textPart) => {
|
|
158
|
-
tui.prefixText = "🤖 ";
|
|
159
|
-
let assistantTextPart = assistantMessageContent.findLast((part) => part.type === "text");
|
|
160
|
-
if (assistantTextPart == null) {
|
|
161
|
-
assistantTextPart = { type: "text", text: "" };
|
|
162
|
-
assistantMessageContent.push(assistantTextPart);
|
|
163
|
-
}
|
|
164
|
-
assistantTextPart.text += textPart.text;
|
|
165
|
-
if (fullText === "")
|
|
166
|
-
tui.text = "";
|
|
167
|
-
fullText += textPart.text;
|
|
168
|
-
tui.text = "\n" + fullText.split("\n").slice(-10).join("\n");
|
|
169
|
-
})
|
|
170
|
-
.with({ type: "tool-call" }, (callPart) => {
|
|
171
|
-
tui.prefixText = "🛠️ ";
|
|
172
|
-
tui.text = "Requesting tool: " + blue(callPart.toolName);
|
|
173
|
-
log("\nQAQ tool-call: %y", callPart);
|
|
174
|
-
requestedToolCalls.push(callPart);
|
|
175
|
-
// Update assistant message to include tool calls
|
|
176
|
-
assistantMessageContent.push({
|
|
177
|
-
type: "tool-call",
|
|
178
|
-
toolCallId: callPart.toolCallId,
|
|
179
|
-
toolName: callPart.toolName,
|
|
180
|
-
args: callPart.args,
|
|
181
|
-
});
|
|
182
|
-
})
|
|
183
|
-
.with({ type: "error" }, async (errorPart) => {
|
|
184
|
-
tui.prefixText = tui.endInfo.prefixText = "❌ ";
|
|
185
|
-
tui.text = tui.endInfo.text = red(`${errorPart.error}`);
|
|
186
|
-
const handled = await handleError(errorPart.error, tui);
|
|
187
|
-
if (!handled) {
|
|
188
|
-
return LOOP_SIGNALS.BREAK; // Stop processing on error
|
|
189
|
-
}
|
|
190
|
-
})
|
|
191
|
-
.with({ type: "reasoning" }, (reasoningPart) => {
|
|
192
|
-
tui.prefixText = "🤔 ";
|
|
193
|
-
if (fullReasoningText === "")
|
|
194
|
-
tui.text = "";
|
|
195
|
-
fullReasoningText += reasoningPart.text;
|
|
196
|
-
tui.text = "\n" + gray(fullReasoningText.split("\n").slice(-3).join("\n"));
|
|
197
|
-
})
|
|
198
|
-
// Add other console logs for debugging if needed, but keep them minimal for production
|
|
199
|
-
.with({ type: "file" }, (p) => {
|
|
200
|
-
tui.prefixText = "📃 ";
|
|
201
|
-
tui.text = p.file.mediaType;
|
|
202
|
-
log("\nQAQ file: %y", p.file);
|
|
203
|
-
})
|
|
204
|
-
.with({ type: "source" }, (p) => {
|
|
205
|
-
tui.prefixText = "🔗 ";
|
|
206
|
-
if (p.sourceType === "url") {
|
|
207
|
-
if (p.title) {
|
|
208
|
-
tui.text = `[${p.title}](${p.url})`;
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
tui.text = p.url;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
if (p.filename) {
|
|
216
|
-
tui.text = `[${p.title}](${p.filename})`;
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
tui.text = p.title;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
log("\nQAQ source: %y", p);
|
|
223
|
-
})
|
|
224
|
-
.with({ type: "tool-result" }, (p) => log("\nQAQ tool-result: %y", p))
|
|
225
|
-
.with({ type: "tool-call-streaming-start" }, (p) => log("\nQAQ tool-call-streaming-start: %y", p))
|
|
226
|
-
.with({ type: "tool-call-delta" }, (p) => log("\nQAQ tool-call-delta: %y", p))
|
|
227
|
-
.with({ type: "reasoning-part-finish" }, (p) => log("\nQAQ reasoning-part-finish: %y", p))
|
|
228
|
-
.with({ type: "start-step" }, (p) => log("\nQAQ start-step: %y", p))
|
|
229
|
-
.with({ type: "finish-step" }, (p) => {
|
|
230
|
-
log("\nQAQ finish-step: %y", p);
|
|
231
|
-
/**
|
|
232
|
-
* This event marks the end of an intermediate step, not the entire turn.
|
|
233
|
-
* We handle potential issues here, but the main logic for continuing or
|
|
234
|
-
* stopping the loop is in the final 'finish' event handler.
|
|
235
|
-
*/
|
|
236
|
-
return match(p)
|
|
237
|
-
.with({ finishReason: P.union("content-filter", "error") }, (part) => {
|
|
238
|
-
// A step finishing due to an error or content filter is a serious issue.
|
|
239
|
-
// Update the TUI to reflect this problem immediately.
|
|
240
|
-
const reasonText = part.finishReason === "content-filter" ? "Content filter violation" : "Model error";
|
|
241
|
-
tui.prefixText = tui.endInfo.prefixText = "⚠️ ";
|
|
242
|
-
tui.text = tui.endInfo.text = red(`Step failed due to ${reasonText}. Will be retry.`);
|
|
243
|
-
log(red(`Step finished with critical reason: ${part.finishReason}`));
|
|
244
|
-
return LOOP_SIGNALS.RETURN;
|
|
245
|
-
})
|
|
246
|
-
.with({ finishReason: P.union("other", "unknown") }, (part) => {
|
|
247
|
-
// Log unusual finish reasons for debugging purposes.
|
|
248
|
-
log(yellow(`Step finished with an unusual reason: ${part.finishReason}`));
|
|
249
|
-
})
|
|
250
|
-
.otherwise(() => {
|
|
251
|
-
// This covers 'stop', 'length', and 'tool-calls'. These are normal
|
|
252
|
-
// reasons for a step to finish. The final 'finish' event will
|
|
253
|
-
// determine the overall outcome of the turn. No special action is needed here.
|
|
254
|
-
log(`Step finished with normal reason: ${p.finishReason}. Awaiting end of turn.`);
|
|
255
|
-
});
|
|
256
|
-
})
|
|
257
|
-
.with({ type: "start" }, (p) => log("\nQAQ start: %y", p))
|
|
258
|
-
.with({ type: "finish" }, async (finishPart) => {
|
|
259
|
-
log("\nQAQ finish: %y", finishPart);
|
|
260
|
-
// Add the assistant's message from this step to the history
|
|
261
|
-
currentMessages.push(_currentAssistantMessage);
|
|
262
|
-
__writeJsonLineLog(_currentAssistantMessage);
|
|
263
|
-
if (finishPart.finishReason === "stop" || finishPart.finishReason === "length") {
|
|
264
|
-
tui.prefixText = tui.endInfo.prefixText = "✅ ";
|
|
265
|
-
tui.text = tui.endInfo.text = green(`${cyan(`[${ai_task.jobName}]`)} Completed`);
|
|
266
|
-
// Task finished without tool calls or after tool calls that didn't lead to more calls.
|
|
267
|
-
return LOOP_SIGNALS.RETURN; // Exit the outer loop and function
|
|
268
|
-
}
|
|
269
|
-
if (finishPart.finishReason === "tool-calls") {
|
|
270
|
-
if (requestedToolCalls.length === 0) {
|
|
271
|
-
tui.prefixText = tui.endInfo.prefixText = "🚧 ";
|
|
272
|
-
tui.text = tui.endInfo.text = yellow(`${cyan(`[${ai_task.jobName}]`)} finished with 'tool-calls' but no tools were requested.`);
|
|
273
|
-
return LOOP_SIGNALS.RETURN; // Exit, something is off
|
|
274
|
-
}
|
|
275
|
-
const toolResultMessages = [];
|
|
276
|
-
for (const toolCall of requestedToolCalls) {
|
|
277
|
-
const toolToExecute = availableTools[toolCall.toolName];
|
|
278
|
-
if (!toolToExecute || typeof toolToExecute.execute !== "function") {
|
|
279
|
-
console.error(`Tool ${toolCall.toolName} not found or not executable.`);
|
|
280
|
-
toolResultMessages.push({
|
|
281
|
-
role: "tool",
|
|
282
|
-
content: [
|
|
283
|
-
{
|
|
284
|
-
type: "tool-result",
|
|
285
|
-
toolCallId: toolCall.toolCallId,
|
|
286
|
-
toolName: toolCall.toolName,
|
|
287
|
-
result: JSON.stringify({ error: `Tool ${toolCall.toolName} not found or not executable.` }),
|
|
288
|
-
isError: true,
|
|
289
|
-
},
|
|
290
|
-
],
|
|
291
|
-
});
|
|
292
|
-
continue;
|
|
293
|
-
}
|
|
294
|
-
tui.text = `Executing tool: ${toolCall.toolName}...`;
|
|
295
|
-
const executionResult = await func_catch(() => toolToExecute.execute(toolCall.args, {
|
|
296
|
-
toolCallId: toolCall.toolCallId,
|
|
297
|
-
messages: currentMessages,
|
|
298
|
-
}))();
|
|
299
|
-
toolResultMessages.push({
|
|
300
|
-
role: "tool",
|
|
301
|
-
content: [
|
|
302
|
-
{
|
|
303
|
-
type: "tool-result",
|
|
304
|
-
toolCallId: toolCall.toolCallId,
|
|
305
|
-
toolName: toolCall.toolName,
|
|
306
|
-
isError: !executionResult.success,
|
|
307
|
-
result: JSON.stringify(executionResult.success ? executionResult.result : executionResult.error),
|
|
308
|
-
},
|
|
309
|
-
],
|
|
310
|
-
});
|
|
311
|
-
if (executionResult.success) {
|
|
312
|
-
tui.text = `Tool ${toolCall.toolName} executed.`;
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
tui.text = `Error executing tool ${toolCall.toolName}.`;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
currentMessages.push(...toolResultMessages);
|
|
319
|
-
__writeJsonLineLog(...toolResultMessages);
|
|
320
|
-
// Loop continues for the next step
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
// Other finish reasons, potentially an error or unexpected state
|
|
324
|
-
tui.prefixText = tui.endInfo.prefixText = "🛑 ";
|
|
325
|
-
tui.text = tui.endInfo.text = red(`${cyan(`[${ai_task.jobName}]`)} task finished with unhandled reason: ${finishPart.finishReason}`);
|
|
326
|
-
return LOOP_SIGNALS.ERROR;
|
|
327
|
-
}
|
|
328
|
-
})
|
|
329
|
-
.otherwise(() => { }); // Handle any other part types if necessary
|
|
330
|
-
if (LOOP_SIGNAL === LOOP_SIGNALS.ERROR) {
|
|
331
|
-
throw LOOP_SIGNAL;
|
|
332
|
-
}
|
|
333
|
-
if (LOOP_SIGNAL === LOOP_SIGNALS.RETURN) {
|
|
334
|
-
break loop;
|
|
335
|
-
}
|
|
336
|
-
else if (LOOP_SIGNAL === LOOP_SIGNALS.BREAK) {
|
|
337
|
-
break;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
// If the stream finishes without a 'finish' part (e.g. error thrown inside), this loop might exit. Ensure spinner stops.
|
|
341
|
-
if (turn === maxTurns - 1) {
|
|
342
|
-
tui.prefixText = tui.endInfo.prefixText = "🚧 ";
|
|
343
|
-
tui.text = tui.endInfo.text = yellow(`${cyan(`[${ai_task.jobName}]`)} Max interaction turns reached.`);
|
|
344
|
-
break;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
//# sourceMappingURL=run-ai-task.js.map
|