poe-code 1.2.1 → 2.0.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 +16 -20
- package/dist/cli/bootstrap.d.ts +4 -0
- package/dist/cli/bootstrap.js +75 -0
- package/dist/cli/bootstrap.js.map +1 -0
- package/dist/cli/commands/configure.d.ts +2 -1
- package/dist/cli/commands/configure.js +7 -7
- package/dist/cli/commands/configure.js.map +1 -1
- package/dist/cli/container.d.ts +0 -5
- package/dist/cli/container.js +0 -8
- package/dist/cli/container.js.map +1 -1
- package/dist/cli/error-logger.d.ts +17 -2
- package/dist/cli/error-logger.js.map +1 -1
- package/dist/cli/errors.d.ts +6 -0
- package/dist/cli/errors.js +8 -0
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/program.js +6 -26
- package/dist/cli/program.js.map +1 -1
- package/dist/cli/prompt-runner.d.ts +3 -0
- package/dist/cli/prompt-runner.js +9 -0
- package/dist/cli/prompt-runner.js.map +1 -0
- package/dist/cli/service-registry.d.ts +8 -0
- package/dist/cli/service-registry.js.map +1 -1
- package/dist/cli/ui/service-menu.d.ts +6 -0
- package/dist/cli/ui/service-menu.js +37 -0
- package/dist/cli/ui/service-menu.js.map +1 -0
- package/dist/cli/ui/theme.d.ts +16 -0
- package/dist/cli/ui/theme.js +78 -0
- package/dist/cli/ui/theme.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -74
- package/dist/index.js.map +1 -1
- package/dist/providers/claude-code-adapter.js +6 -0
- package/dist/providers/claude-code-adapter.js.map +1 -1
- package/dist/providers/codex-adapter.js +6 -0
- package/dist/providers/codex-adapter.js.map +1 -1
- package/dist/providers/opencode-adapter.js +6 -0
- package/dist/providers/opencode-adapter.js.map +1 -1
- package/package.json +13 -34
- package/dist/cli/api-client.d.ts +0 -14
- package/dist/cli/api-client.js +0 -140
- package/dist/cli/api-client.js.map +0 -1
- package/dist/cli/chat.d.ts +0 -32
- package/dist/cli/chat.js +0 -2
- package/dist/cli/chat.js.map +0 -1
- package/dist/cli/commands/agent.d.ts +0 -18
- package/dist/cli/commands/agent.js +0 -84
- package/dist/cli/commands/agent.js.map +0 -1
- package/dist/cli/commands/configure-agents.d.ts +0 -3
- package/dist/cli/commands/configure-agents.js +0 -72
- package/dist/cli/commands/configure-agents.js.map +0 -1
- package/dist/cli/commands/init.d.ts +0 -8
- package/dist/cli/commands/init.js +0 -45
- package/dist/cli/commands/init.js.map +0 -1
- package/dist/cli/commands/interactive.d.ts +0 -3
- package/dist/cli/commands/interactive.js +0 -17
- package/dist/cli/commands/interactive.js.map +0 -1
- package/dist/cli/commands/login.d.ts +0 -6
- package/dist/cli/commands/login.js +0 -51
- package/dist/cli/commands/login.js.map +0 -1
- package/dist/cli/commands/logout.d.ts +0 -3
- package/dist/cli/commands/logout.js +0 -31
- package/dist/cli/commands/logout.js.map +0 -1
- package/dist/cli/commands/prerequisites.d.ts +0 -3
- package/dist/cli/commands/prerequisites.js +0 -23
- package/dist/cli/commands/prerequisites.js.map +0 -1
- package/dist/cli/commands/query.d.ts +0 -7
- package/dist/cli/commands/query.js +0 -46
- package/dist/cli/commands/query.js.map +0 -1
- package/dist/cli/commands/remove.d.ts +0 -6
- package/dist/cli/commands/remove.js +0 -80
- package/dist/cli/commands/remove.js.map +0 -1
- package/dist/cli/commands/root.d.ts +0 -3
- package/dist/cli/commands/root.js +0 -7
- package/dist/cli/commands/root.js.map +0 -1
- package/dist/cli/commands/spawn-worktree.d.ts +0 -6
- package/dist/cli/commands/spawn-worktree.js +0 -91
- package/dist/cli/commands/spawn-worktree.js.map +0 -1
- package/dist/cli/commands/spawn.d.ts +0 -7
- package/dist/cli/commands/spawn.js +0 -112
- package/dist/cli/commands/spawn.js.map +0 -1
- package/dist/cli/commands/test.d.ts +0 -6
- package/dist/cli/commands/test.js +0 -26
- package/dist/cli/commands/test.js.map +0 -1
- package/dist/cli/file-mentions.d.ts +0 -13
- package/dist/cli/file-mentions.js +0 -87
- package/dist/cli/file-mentions.js.map +0 -1
- package/dist/cli/file-picker-state.d.ts +0 -14
- package/dist/cli/file-picker-state.js +0 -23
- package/dist/cli/file-picker-state.js.map +0 -1
- package/dist/cli/interactive-command-runner.d.ts +0 -11
- package/dist/cli/interactive-command-runner.js +0 -142
- package/dist/cli/interactive-command-runner.js.map +0 -1
- package/dist/cli/interactive-launcher.d.ts +0 -2
- package/dist/cli/interactive-launcher.js +0 -404
- package/dist/cli/interactive-launcher.js.map +0 -1
- package/dist/cli/interactive-tasks.d.ts +0 -7
- package/dist/cli/interactive-tasks.js +0 -199
- package/dist/cli/interactive-tasks.js.map +0 -1
- package/dist/cli/interactive.d.ts +0 -19
- package/dist/cli/interactive.js +0 -479
- package/dist/cli/interactive.js.map +0 -1
- package/dist/cli/markdown-renderer.d.ts +0 -27
- package/dist/cli/markdown-renderer.js +0 -178
- package/dist/cli/markdown-renderer.js.map +0 -1
- package/dist/cli/markdown-renderer.test.d.ts +0 -1
- package/dist/cli/markdown-renderer.test.js +0 -105
- package/dist/cli/markdown-renderer.test.js.map +0 -1
- package/dist/commands/init.d.ts +0 -9
- package/dist/commands/init.js +0 -43
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/spawn-worktree.d.ts +0 -25
- package/dist/commands/spawn-worktree.js +0 -139
- package/dist/commands/spawn-worktree.js.map +0 -1
- package/dist/services/agent-config-manager.d.ts +0 -32
- package/dist/services/agent-config-manager.js +0 -130
- package/dist/services/agent-config-manager.js.map +0 -1
- package/dist/services/agent-registry.d.ts +0 -27
- package/dist/services/agent-registry.js +0 -89
- package/dist/services/agent-registry.js.map +0 -1
- package/dist/services/agent-session.d.ts +0 -24
- package/dist/services/agent-session.js +0 -107
- package/dist/services/agent-session.js.map +0 -1
- package/dist/services/agent-task-registry.d.ts +0 -131
- package/dist/services/agent-task-registry.js +0 -491
- package/dist/services/agent-task-registry.js.map +0 -1
- package/dist/services/chat.d.ts +0 -94
- package/dist/services/chat.js +0 -241
- package/dist/services/chat.js.map +0 -1
- package/dist/services/mcp-client.d.ts +0 -38
- package/dist/services/mcp-client.js +0 -170
- package/dist/services/mcp-client.js.map +0 -1
- package/dist/services/mcp-manager.d.ts +0 -28
- package/dist/services/mcp-manager.js +0 -157
- package/dist/services/mcp-manager.js.map +0 -1
- package/dist/services/poe-code.d.ts +0 -7
- package/dist/services/poe-code.js +0 -5
- package/dist/services/poe-code.js.map +0 -1
- package/dist/services/task-logger.d.ts +0 -24
- package/dist/services/task-logger.js +0 -73
- package/dist/services/task-logger.js.map +0 -1
- package/dist/services/task-runner.d.ts +0 -19
- package/dist/services/task-runner.js +0 -157
- package/dist/services/task-runner.js.map +0 -1
- package/dist/services/tools.d.ts +0 -76
- package/dist/services/tools.js +0 -870
- package/dist/services/tools.js.map +0 -1
- package/dist/utils/e2e-flags.d.ts +0 -1
- package/dist/utils/e2e-flags.js +0 -9
- package/dist/utils/e2e-flags.js.map +0 -1
- package/dist/utils/worktree.d.ts +0 -40
- package/dist/utils/worktree.js +0 -179
- package/dist/utils/worktree.js.map +0 -1
- package/shared/conversation-layout.cjs +0 -11
- package/shared/conversation-layout.d.ts +0 -7
- package/shared/conversation-layout.js +0 -11
- package/shared/package.json +0 -13
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { CommandRunner, CommandRunnerResult } from "../utils/prerequisites.js";
|
|
2
|
-
export interface SpawnPoeCodeOptions {
|
|
3
|
-
prompt: string;
|
|
4
|
-
args?: string[];
|
|
5
|
-
runCommand: CommandRunner;
|
|
6
|
-
}
|
|
7
|
-
export declare function spawnPoeCode(options: SpawnPoeCodeOptions): Promise<CommandRunnerResult>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"poe-code.js","sourceRoot":"","sources":["../../src/services/poe-code.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAA4B;IAE5B,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;IAChE,OAAO,MAAM,OAAO,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { FsLike } from "./agent-task-registry.js";
|
|
2
|
-
export interface TaskLoggerOptions {
|
|
3
|
-
fs: FsLike;
|
|
4
|
-
filePath: string;
|
|
5
|
-
maxSize?: number;
|
|
6
|
-
maxBackups?: number;
|
|
7
|
-
now?: () => Date;
|
|
8
|
-
}
|
|
9
|
-
export declare class TaskLogger {
|
|
10
|
-
private readonly fs;
|
|
11
|
-
private readonly filePath;
|
|
12
|
-
private readonly maxSize;
|
|
13
|
-
private readonly maxBackups;
|
|
14
|
-
private readonly now;
|
|
15
|
-
constructor(options: TaskLoggerOptions);
|
|
16
|
-
info(message: string): void;
|
|
17
|
-
error(message: string): void;
|
|
18
|
-
debug(message: string): void;
|
|
19
|
-
private write;
|
|
20
|
-
private rotateIfNeeded;
|
|
21
|
-
private performRotation;
|
|
22
|
-
private ensureDirectory;
|
|
23
|
-
private buildBackupPath;
|
|
24
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
const DEFAULT_MAX_SIZE = 10 * 1024 * 1024;
|
|
3
|
-
const DEFAULT_MAX_BACKUPS = 3;
|
|
4
|
-
export class TaskLogger {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
this.fs = options.fs;
|
|
7
|
-
this.filePath = options.filePath;
|
|
8
|
-
this.maxSize = options.maxSize ?? DEFAULT_MAX_SIZE;
|
|
9
|
-
this.maxBackups = options.maxBackups ?? DEFAULT_MAX_BACKUPS;
|
|
10
|
-
this.now = options.now ?? (() => new Date());
|
|
11
|
-
this.ensureDirectory();
|
|
12
|
-
}
|
|
13
|
-
info(message) {
|
|
14
|
-
this.write("INFO", message);
|
|
15
|
-
}
|
|
16
|
-
error(message) {
|
|
17
|
-
this.write("ERROR", message);
|
|
18
|
-
}
|
|
19
|
-
debug(message) {
|
|
20
|
-
this.write("DEBUG", message);
|
|
21
|
-
}
|
|
22
|
-
write(level, message) {
|
|
23
|
-
this.rotateIfNeeded();
|
|
24
|
-
const timestamp = this.now().toISOString();
|
|
25
|
-
const line = `[${timestamp}] TASK ${level} ${message}\n`;
|
|
26
|
-
this.fs.appendFileSync(this.filePath, line);
|
|
27
|
-
}
|
|
28
|
-
rotateIfNeeded() {
|
|
29
|
-
if (!this.fs.existsSync(this.filePath)) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const stats = this.fs.statSync(this.filePath);
|
|
33
|
-
if (stats.size < this.maxSize) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
this.performRotation();
|
|
37
|
-
}
|
|
38
|
-
performRotation() {
|
|
39
|
-
if (this.maxBackups < 1) {
|
|
40
|
-
this.fs.unlinkSync(this.filePath);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const oldestIndex = this.maxBackups;
|
|
44
|
-
const oldestPath = this.buildBackupPath(oldestIndex);
|
|
45
|
-
if (this.fs.existsSync(oldestPath)) {
|
|
46
|
-
this.fs.unlinkSync(oldestPath);
|
|
47
|
-
}
|
|
48
|
-
for (let index = this.maxBackups - 1; index >= 1; index--) {
|
|
49
|
-
const source = this.buildBackupPath(index);
|
|
50
|
-
if (!this.fs.existsSync(source)) {
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const target = this.buildBackupPath(index + 1);
|
|
54
|
-
this.fs.renameSync(source, target);
|
|
55
|
-
}
|
|
56
|
-
if (this.fs.existsSync(this.filePath)) {
|
|
57
|
-
this.fs.renameSync(this.filePath, this.buildBackupPath(1));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
ensureDirectory() {
|
|
61
|
-
const directory = path.dirname(this.filePath);
|
|
62
|
-
if (!this.fs.existsSync(directory)) {
|
|
63
|
-
this.fs.mkdirSync(directory, { recursive: true });
|
|
64
|
-
}
|
|
65
|
-
if (!this.fs.existsSync(this.filePath)) {
|
|
66
|
-
this.fs.writeFileSync(this.filePath, "", { encoding: "utf8" });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
buildBackupPath(index) {
|
|
70
|
-
return `${this.filePath}.${index}`;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=task-logger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"task-logger.js","sourceRoot":"","sources":["../../src/services/task-logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAW7B,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1C,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,MAAM,OAAO,UAAU;IAOrB,YAAY,OAA0B;QACpC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC;QACnD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,mBAAmB,CAAC;QAC5D,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAE7C,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,OAAe;QACnB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,OAAe;QACnB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,O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istry } from "./agent-task-registry.js";
|
|
2
|
-
import type { FsLike } from "./agent-task-registry.js";
|
|
3
|
-
export interface TaskRunnerOptions {
|
|
4
|
-
fs: FsLike;
|
|
5
|
-
tasksDir: string;
|
|
6
|
-
logsDir: string;
|
|
7
|
-
taskId: string;
|
|
8
|
-
toolName: string;
|
|
9
|
-
args: Record<string, unknown>;
|
|
10
|
-
registry: Pick<AgentTaskRegistry, "getTask" | "updateTask">;
|
|
11
|
-
executor: (input: {
|
|
12
|
-
toolName: string;
|
|
13
|
-
args: Record<string, unknown>;
|
|
14
|
-
log: (message: string) => void;
|
|
15
|
-
progress: (message: string) => void;
|
|
16
|
-
}) => Promise<string>;
|
|
17
|
-
now?: () => number;
|
|
18
|
-
}
|
|
19
|
-
export declare function runTask(options: TaskRunnerOptions): Promise<void>;
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import * as fs from "node:fs";
|
|
4
|
-
import { TaskLogger } from "./task-logger.js";
|
|
5
|
-
import { AgentTaskRegistry } from "./agent-task-registry.js";
|
|
6
|
-
import { DefaultToolExecutor } from "./tools.js";
|
|
7
|
-
export async function runTask(options) {
|
|
8
|
-
const now = options.now ?? Date.now;
|
|
9
|
-
const task = options.registry.getTask(options.taskId);
|
|
10
|
-
if (!task) {
|
|
11
|
-
throw new Error(`Task "${options.taskId}" not found`);
|
|
12
|
-
}
|
|
13
|
-
const logger = new TaskLogger({
|
|
14
|
-
fs: options.fs,
|
|
15
|
-
filePath: path.join(options.logsDir, `${options.taskId}.log`),
|
|
16
|
-
now: () => new Date(now())
|
|
17
|
-
});
|
|
18
|
-
const progressFile = path.join(options.tasksDir, `${options.taskId}.progress.jsonl`);
|
|
19
|
-
if (!options.fs.existsSync(progressFile)) {
|
|
20
|
-
options.fs.writeFileSync(progressFile, "", { encoding: "utf8" });
|
|
21
|
-
}
|
|
22
|
-
const writeProgress = (update) => {
|
|
23
|
-
const line = JSON.stringify(update);
|
|
24
|
-
options.fs.appendFileSync(progressFile, `${line}\n`);
|
|
25
|
-
};
|
|
26
|
-
const startTimestamp = now();
|
|
27
|
-
logger.info(`Starting ${options.toolName}`);
|
|
28
|
-
writeProgress({
|
|
29
|
-
type: "progress",
|
|
30
|
-
message: `Starting ${options.toolName}`,
|
|
31
|
-
timestamp: startTimestamp
|
|
32
|
-
});
|
|
33
|
-
try {
|
|
34
|
-
const result = await options.executor({
|
|
35
|
-
toolName: options.toolName,
|
|
36
|
-
args: options.args,
|
|
37
|
-
log: (message) => logger.info(message),
|
|
38
|
-
progress: (message) => writeProgress({
|
|
39
|
-
type: "progress",
|
|
40
|
-
message,
|
|
41
|
-
timestamp: now()
|
|
42
|
-
})
|
|
43
|
-
});
|
|
44
|
-
const end = now();
|
|
45
|
-
options.registry.updateTask(options.taskId, {
|
|
46
|
-
status: "completed",
|
|
47
|
-
result,
|
|
48
|
-
endTime: end
|
|
49
|
-
});
|
|
50
|
-
writeProgress({
|
|
51
|
-
type: "complete",
|
|
52
|
-
result,
|
|
53
|
-
timestamp: end
|
|
54
|
-
});
|
|
55
|
-
logger.info(`Task completed: ${result}`);
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
59
|
-
const end = now();
|
|
60
|
-
options.registry.updateTask(options.taskId, {
|
|
61
|
-
status: "failed",
|
|
62
|
-
error: message,
|
|
63
|
-
endTime: end
|
|
64
|
-
});
|
|
65
|
-
writeProgress({
|
|
66
|
-
type: "error",
|
|
67
|
-
error: message,
|
|
68
|
-
timestamp: end
|
|
69
|
-
});
|
|
70
|
-
logger.error(`Task failed: ${message}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function parsePayload(argv) {
|
|
74
|
-
const index = argv.indexOf("--payload");
|
|
75
|
-
if (index === -1) {
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
const raw = argv[index + 1];
|
|
79
|
-
if (!raw) {
|
|
80
|
-
throw new Error("Missing payload for task runner");
|
|
81
|
-
}
|
|
82
|
-
return JSON.parse(raw);
|
|
83
|
-
}
|
|
84
|
-
async function main() {
|
|
85
|
-
const payload = parsePayload(process.argv);
|
|
86
|
-
if (!payload) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const fsLike = fs;
|
|
90
|
-
const nodeFileSystem = createNodeFileSystem();
|
|
91
|
-
const registry = new AgentTaskRegistry({
|
|
92
|
-
fs: fsLike,
|
|
93
|
-
tasksDir: payload.directories.tasks,
|
|
94
|
-
logsDir: payload.directories.logs
|
|
95
|
-
});
|
|
96
|
-
try {
|
|
97
|
-
const executor = new DefaultToolExecutor({
|
|
98
|
-
fs: nodeFileSystem,
|
|
99
|
-
cwd: payload.context.cwd
|
|
100
|
-
});
|
|
101
|
-
await runTask({
|
|
102
|
-
fs: fsLike,
|
|
103
|
-
tasksDir: payload.directories.tasks,
|
|
104
|
-
logsDir: payload.directories.logs,
|
|
105
|
-
taskId: payload.taskId,
|
|
106
|
-
toolName: payload.toolName,
|
|
107
|
-
args: payload.args,
|
|
108
|
-
registry,
|
|
109
|
-
executor: async ({ toolName, args, progress }) => {
|
|
110
|
-
const result = await executor.executeTool(toolName, args);
|
|
111
|
-
const lines = result.split("\n").filter((line) => line.trim().length > 0);
|
|
112
|
-
for (const line of lines) {
|
|
113
|
-
progress(line);
|
|
114
|
-
}
|
|
115
|
-
return result;
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
finally {
|
|
120
|
-
registry.dispose();
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
const modulePath = fileURLToPath(import.meta.url);
|
|
124
|
-
if (process.argv[1] && path.resolve(process.argv[1]) === path.resolve(modulePath)) {
|
|
125
|
-
void main().catch((error) => {
|
|
126
|
-
// eslint-disable-next-line no-console
|
|
127
|
-
console.error("Task runner failed", error);
|
|
128
|
-
process.exitCode = 1;
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
function createNodeFileSystem() {
|
|
132
|
-
const promises = fs.promises;
|
|
133
|
-
function readFile(path, encoding) {
|
|
134
|
-
if (encoding) {
|
|
135
|
-
return promises.readFile(path, encoding);
|
|
136
|
-
}
|
|
137
|
-
return promises.readFile(path);
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
readFile,
|
|
141
|
-
writeFile: async (path, data, options) => {
|
|
142
|
-
await promises.writeFile(path, data, options);
|
|
143
|
-
},
|
|
144
|
-
mkdir: async (target, options) => {
|
|
145
|
-
await promises.mkdir(target, options);
|
|
146
|
-
},
|
|
147
|
-
stat: (target) => promises.stat(target),
|
|
148
|
-
unlink: (target) => promises.unlink(target),
|
|
149
|
-
readdir: (target) => promises.readdir(target),
|
|
150
|
-
rm: promises.rm ? ((path, options) => promises.rm(path, options)) : undefined,
|
|
151
|
-
copyFile: promises.copyFile
|
|
152
|
-
? ((src, dest) => promises.copyFile(src, dest))
|
|
153
|
-
: undefined,
|
|
154
|
-
chmod: promises.chmod ? ((target, mode) => promises.chmod(target, mode)) : undefined
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
//# sourceMappingURL=task-runner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"task-runner.js","sourceRoot":"","sources":["../../src/services/task-runner.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAoBjD,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAA0B;IACtD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI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AAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;KACrF,CAAC;AACJ,CAAC"}
|
package/dist/services/tools.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { Tool, ToolExecutor } from "./chat.js";
|
|
2
|
-
import type { FileSystem } from "../utils/file-system.js";
|
|
3
|
-
import type { McpManager } from "./mcp-manager.js";
|
|
4
|
-
import type { AgentTaskRegistry } from "./agent-task-registry.js";
|
|
5
|
-
import { AgentRegistry } from "./agent-registry.js";
|
|
6
|
-
import { AgentConfigManager } from "./agent-config-manager.js";
|
|
7
|
-
interface BackgroundTaskRequest {
|
|
8
|
-
taskId: string;
|
|
9
|
-
toolName: string;
|
|
10
|
-
args: Record<string, unknown>;
|
|
11
|
-
context: {
|
|
12
|
-
cwd: string;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
type BackgroundTaskSpawner = (request: BackgroundTaskRequest) => Promise<void> | void;
|
|
16
|
-
export interface ToolExecutorDependencies {
|
|
17
|
-
fs: FileSystem;
|
|
18
|
-
cwd: string;
|
|
19
|
-
allowedPaths?: string[];
|
|
20
|
-
mcpManager?: McpManager;
|
|
21
|
-
onWriteFile?: (details: {
|
|
22
|
-
absolutePath: string;
|
|
23
|
-
relativePath: string;
|
|
24
|
-
previousContent: string | null;
|
|
25
|
-
nextContent: string;
|
|
26
|
-
}) => void | Promise<void>;
|
|
27
|
-
taskRegistry?: AgentTaskRegistry;
|
|
28
|
-
spawnBackgroundTask?: BackgroundTaskSpawner;
|
|
29
|
-
logger?: (event: string, payload?: Record<string, unknown>) => void;
|
|
30
|
-
now?: () => number;
|
|
31
|
-
agentRegistry?: AgentRegistry;
|
|
32
|
-
agentConfigManager?: AgentConfigManager;
|
|
33
|
-
homeDir?: string;
|
|
34
|
-
}
|
|
35
|
-
export declare class DefaultToolExecutor implements ToolExecutor {
|
|
36
|
-
private fs;
|
|
37
|
-
private cwd;
|
|
38
|
-
private allowedPaths;
|
|
39
|
-
private mcpManager?;
|
|
40
|
-
private onWriteFile?;
|
|
41
|
-
private taskRegistry?;
|
|
42
|
-
private spawnTask?;
|
|
43
|
-
private eventLogger;
|
|
44
|
-
private now;
|
|
45
|
-
private agentRegistry;
|
|
46
|
-
private agentConfigManager?;
|
|
47
|
-
private homeDir?;
|
|
48
|
-
constructor(dependencies: ToolExecutorDependencies);
|
|
49
|
-
executeTool(name: string, args: Record<string, unknown>): Promise<string>;
|
|
50
|
-
private isPathAllowed;
|
|
51
|
-
private readFile;
|
|
52
|
-
private writeFile;
|
|
53
|
-
private listFiles;
|
|
54
|
-
private runCommand;
|
|
55
|
-
private isManagedCommand;
|
|
56
|
-
private runManagedCommand;
|
|
57
|
-
private executeClaudeCodeCommand;
|
|
58
|
-
private executeExternalCommand;
|
|
59
|
-
private runProcess;
|
|
60
|
-
private formatProcessOutput;
|
|
61
|
-
private isNotFoundError;
|
|
62
|
-
private searchWeb;
|
|
63
|
-
private spawnGitWorktreeTool;
|
|
64
|
-
private createBackgroundSpawner;
|
|
65
|
-
private executeWorktreeSynchronously;
|
|
66
|
-
private resolveAgent;
|
|
67
|
-
private parseWorktreeArgs;
|
|
68
|
-
private tryReadFile;
|
|
69
|
-
}
|
|
70
|
-
export interface GetAvailableToolsOptions {
|
|
71
|
-
agentRegistry?: AgentRegistry;
|
|
72
|
-
agentConfigManager?: AgentConfigManager;
|
|
73
|
-
mcpManager?: McpManager;
|
|
74
|
-
}
|
|
75
|
-
export declare function getAvailableTools(options?: GetAvailableToolsOptions): Promise<Tool[]>;
|
|
76
|
-
export {};
|