@daomar/agentfleet 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.
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.submitCommand = submitCommand;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const os = __importStar(require("os"));
40
+ const crypto = __importStar(require("crypto"));
41
+ const setup_1 = require("../services/setup");
42
+ const bootstrap_1 = require("../services/bootstrap");
43
+ const i18n_1 = require("../services/i18n");
44
+ async function submitCommand(options) {
45
+ const setup = new setup_1.SetupService();
46
+ await (0, bootstrap_1.bootstrap)({ setup });
47
+ const tasksDir = setup.getTasksDir();
48
+ // Generate unique task ID
49
+ const timestamp = new Date().toISOString().replace(/[-:T]/g, '').substring(0, 14);
50
+ const random = crypto.randomBytes(3).toString('hex');
51
+ const taskId = `task-${timestamp}-${random}`;
52
+ const task = {
53
+ id: taskId,
54
+ prompt: options.prompt,
55
+ title: options.title,
56
+ workingDirectory: path.resolve(options.workingDir),
57
+ createdAt: new Date().toISOString(),
58
+ createdBy: os.hostname(),
59
+ };
60
+ if (options.agent) {
61
+ task.command = options.agent;
62
+ }
63
+ const taskPath = path.join(tasksDir, `${taskId}.json`);
64
+ fs.writeFileSync(taskPath, JSON.stringify(task, null, 2));
65
+ console.log(`✅ ${(0, i18n_1.t)('submit.task_submitted', { taskId })}`);
66
+ console.log(` ${(0, i18n_1.t)('submit.title', { title: options.title || (0, i18n_1.t)('submit.title_none') })}`);
67
+ console.log(` ${(0, i18n_1.t)('submit.prompt', { prompt: options.prompt.substring(0, 80) + (options.prompt.length > 80 ? '...' : '') })}`);
68
+ console.log(` ${(0, i18n_1.t)('submit.working_dir', { path: task.workingDirectory || '' })}`);
69
+ console.log(` ${(0, i18n_1.t)('submit.file', { path: taskPath })}`);
70
+ console.log(`\n${(0, i18n_1.t)('submit.sync_hint')}`);
71
+ }
72
+ //# sourceMappingURL=submit.js.map
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uninstallCommand = uninstallCommand;
4
+ const auto_start_1 = require("../services/auto-start");
5
+ const daemon_1 = require("../services/daemon");
6
+ const i18n_1 = require("../services/i18n");
7
+ function uninstallCommand(_options, _cmdObj, dependencies = {}) {
8
+ const autoStartManager = dependencies.autoStartManager ?? (0, auto_start_1.createAutoStartManager)();
9
+ const daemonService = dependencies.daemonService ?? new daemon_1.DaemonService();
10
+ const exit = dependencies.exit ?? ((code) => process.exit(code));
11
+ const killProcess = dependencies.killProcess ?? ((pid) => process.kill(pid, 'SIGTERM'));
12
+ if (!autoStartManager.isSupported()) {
13
+ console.error(`❌ ${(0, i18n_1.t)('autostart.unsupported', { platform: process.platform })}`);
14
+ return exit(1);
15
+ }
16
+ const taskState = autoStartManager.queryState();
17
+ if (taskState === 'not-installed') {
18
+ console.log(`ℹ️ ${(0, i18n_1.t)('uninstall.not_installed')}`);
19
+ return;
20
+ }
21
+ // Stop running instance if any
22
+ const pid = daemonService.readPid();
23
+ if (pid !== null && daemonService.isRunning(pid)) {
24
+ try {
25
+ killProcess(pid);
26
+ console.log(`⏹️ ${(0, i18n_1.t)('uninstall.stopped', { pid })}`);
27
+ }
28
+ catch { /* ignore */ }
29
+ daemonService.removePid();
30
+ }
31
+ try {
32
+ autoStartManager.uninstall();
33
+ console.log(`✅ ${(0, i18n_1.t)('uninstall.removed')}`);
34
+ console.log(` ${(0, i18n_1.t)('uninstall.no_auto_start')}`);
35
+ }
36
+ catch (err) {
37
+ console.error(`❌ ${(0, i18n_1.t)('uninstall.failed', { message: err.message })}`);
38
+ return exit(1);
39
+ }
40
+ }
41
+ //# sourceMappingURL=uninstall.js.map
@@ -0,0 +1,162 @@
1
+ {
2
+ "cli.description": "Distributed agent orchestration, without a control plane.",
3
+
4
+ "cli.run_description": "Start AgentFleet: auto-initialize if needed, then watch for tasks",
5
+ "cli.run_option_poll": "Polling interval in seconds",
6
+ "cli.run_option_concurrency": "Maximum concurrent agent processes",
7
+ "cli.run_option_daemon": "Run as a background daemon process",
8
+ "cli.run_option_log_file": "Log file path (used with --daemon)",
9
+
10
+ "cli.submit_description": "Submit a new task for all machines to execute",
11
+ "cli.submit_option_prompt": "The prompt/instruction for the coding agent",
12
+ "cli.submit_option_title": "A short title for the task",
13
+ "cli.submit_option_working_dir": "Working directory for the agent",
14
+ "cli.submit_option_agent": "Agent command template. Use {prompt} as placeholder (e.g. \"claude -p {prompt} --allowed-tools WebSearch\")",
15
+
16
+ "cli.status_description": "Show status of all tasks or a specific task",
17
+ "cli.stop_description": "Stop the running AgentFleet instance",
18
+ "cli.install_description": "Install AgentFleet auto-start on login",
19
+ "cli.uninstall_description": "Remove AgentFleet auto-start and stop running instance",
20
+
21
+ "cli.version_update_available": "AgentFleet v{current} (latest: v{latest}) ⚡ Update available",
22
+ "cli.version_latest": "AgentFleet v{current} (latest)",
23
+ "cli.version_current": "AgentFleet v{current}",
24
+
25
+ "run.scheduled_task_running": "AgentFleet is running (PID {pid}) with auto-start on login.",
26
+ "run.scheduled_task_hint": "Use `agentfleet stop` to stop or `agentfleet uninstall` to remove auto-start.",
27
+ "run.scheduled_task_starting": "AgentFleet auto-start is configured. Starting through the configured auto-start registration...",
28
+ "run.already_running": "AgentFleet is already running (PID {pid})",
29
+ "run.daemon_started": "AgentFleet daemon started (PID {pid})",
30
+ "run.daemon_log_file": "Log file: {path}",
31
+ "run.daemon_pid_file": "PID file: {path}",
32
+ "run.starting": "AgentFleet - Starting",
33
+ "run.error": "{message}",
34
+ "run.running_on": "AgentFleet is running on {hostname}",
35
+ "run.concurrency": "Concurrency: {value}",
36
+ "run.poll_interval": "Poll interval: {value}s",
37
+ "run.press_ctrl_c": "Press Ctrl+C to stop",
38
+ "run.running_as_daemon": "Running as daemon (PID {pid})",
39
+ "run.submit_hint": "To submit a task: {command} submit --prompt \"your instruction here\"",
40
+ "run.shutting_down": "Shutting down...",
41
+ "run.task_error": "Error executing task {taskId}: {message}",
42
+
43
+ "submit.task_submitted": "Task submitted: {taskId}",
44
+ "submit.title": "Title: {title}",
45
+ "submit.prompt": "Prompt: {prompt}",
46
+ "submit.working_dir": "Working dir: {path}",
47
+ "submit.file": "File: {path}",
48
+ "submit.sync_hint": "This task will be synced to all machines via OneDrive.",
49
+ "submit.title_none": "(none)",
50
+
51
+ "status.running": "AgentFleet is running (PID {pid})",
52
+ "status.mode_auto_start": "Mode: daemon (auto-start on login)",
53
+ "status.mode_daemon": "Mode: daemon (background)",
54
+ "status.mode_foreground": "Mode: foreground",
55
+ "status.log_file": "Log file: {path}",
56
+ "status.pid_file": "PID file: {path}",
57
+ "status.auto_start_not_running": "AgentFleet auto-start is configured but not currently running",
58
+ "status.auto_start_hint": "Run `agentfleet run` to start, or it will auto-start on next login.",
59
+ "status.not_running": "AgentFleet is not running",
60
+ "status.version_update": "AgentFleet v{current} (latest: v{latest}) ⚡ Update available",
61
+ "status.version_latest": "AgentFleet v{current} (latest)",
62
+ "status.version_current": "AgentFleet v{current}",
63
+ "status.no_tasks": "No tasks found.",
64
+ "status.tasks_header": "Tasks ({count} total)",
65
+ "status.col_id": "ID",
66
+ "status.col_title": "Title",
67
+ "status.col_status": "Status",
68
+ "status.col_results": "Results",
69
+ "status.status_done": "done ({count})",
70
+ "status.status_pending": "pending",
71
+ "status.untitled": "(untitled)",
72
+ "status.error_reading": "(error reading file)",
73
+ "status.task_not_found": "Task not found: {taskId}",
74
+ "status.task_header": "Task: {taskId}",
75
+ "status.task_title": "Title: {title}",
76
+ "status.task_prompt": "Prompt: {prompt}",
77
+ "status.task_working_dir": "Working dir: {path}",
78
+ "status.task_agent": "Agent: {agent}",
79
+ "status.task_created": "Created: {date}",
80
+ "status.task_created_by": "Created by: {hostname}",
81
+ "status.task_title_none": "(none)",
82
+ "status.task_default": "(default)",
83
+ "status.task_unknown": "unknown",
84
+ "status.results_header": "Results ({count} machine(s)):",
85
+ "status.result_status": "Status: {status} (exit code: {exitCode})",
86
+ "status.result_started": "Started: {date}",
87
+ "status.result_completed": "Completed: {date}",
88
+ "status.result_error": "Error: {error}",
89
+ "status.output_files": "Output files:",
90
+ "status.no_results": "No results yet.",
91
+
92
+ "stop.not_running_no_pid": "AgentFleet is not running (no PID file found)",
93
+ "stop.not_running_stale": "AgentFleet is not running (stale PID file cleaned up)",
94
+ "stop.stopped": "AgentFleet stopped (PID {pid})",
95
+ "stop.failed": "Failed to stop AgentFleet (PID {pid}): {message}",
96
+
97
+ "install.already_installed_running": "AgentFleet auto-start is already installed and running.",
98
+ "install.pid": "PID: {pid}",
99
+ "install.already_running": "AgentFleet is already running (PID {pid}). Stop it first with `agentfleet stop`.",
100
+ "install.installed": "AgentFleet auto-start installed",
101
+ "install.task_name": "Auto-start name: {name}",
102
+ "install.auto_start_hint": "AgentFleet will auto-start on login via `npx -y @daomar/agentfleet run -d`",
103
+ "install.already_installed": "AgentFleet auto-start is already installed.",
104
+ "install.starting": "Starting AgentFleet...",
105
+ "install.started": "AgentFleet started (PID {pid})",
106
+ "install.submit_hint": "To submit a task: {command} submit --prompt \"your instruction here\"",
107
+ "install.failed": "Failed to install/start auto-start: {message}",
108
+
109
+ "uninstall.not_installed": "No AgentFleet auto-start is installed.",
110
+ "uninstall.stopped": "Stopped running AgentFleet (PID {pid})",
111
+ "uninstall.removed": "AgentFleet auto-start removed",
112
+ "uninstall.no_auto_start": "AgentFleet will no longer auto-start on login.",
113
+ "uninstall.failed": "Failed to remove auto-start: {message}",
114
+
115
+ "autostart.unsupported": "Auto-start is not supported on platform `{platform}`.",
116
+
117
+ "bootstrap.no_onedrive": "No supported OneDrive account found.\nPlease install OneDrive and sign in with either your personal or business account.\nDownload: https://www.microsoft.com/en-us/microsoft-365/onedrive/download",
118
+ "bootstrap.selected": "OneDrive selected: {name} ({type}) → {path}",
119
+
120
+ "setup.created_dir": "Created {path}",
121
+ "setup.created_onedrive_dir": "Created OneDrive directory: {path}",
122
+ "setup.symlink_valid": "Symlink valid: {link} → {target}",
123
+ "setup.symlink_stale": "Symlink stale, recreating: {link}",
124
+ "setup.symlink_exists_as_dir": "{path} exists as a regular directory, not a symlink. Skipping.",
125
+ "setup.created_junction": "Created junction: {link} → {target}",
126
+ "setup.created_symlink": "Created symlink: {link} → {target}",
127
+ "setup.symlink_failed": "Failed to create symlink or junction at {path}.\nOn Windows, try enabling Developer Mode:\n Settings → Update & Security → For developers → Developer Mode\nError: {error}",
128
+ "setup.config_missing_path": "Config file missing OneDrive path, recreating",
129
+ "setup.config_corrupt": "Config file corrupt, recreating",
130
+ "setup.onedrive_changed": "OneDrive selection changed, updating config",
131
+ "setup.config_loaded": "Config loaded: {path}",
132
+ "setup.config_created": "Config created: {path}",
133
+ "setup.migrated": "Migrated {label}: {from} → {to}",
134
+ "setup.migrated_reused": "Reused legacy {label}: {from} → {to}",
135
+ "setup.migrate_conflict": "Found both legacy and current {label} directories.\nLegacy: {legacy}\nCurrent: {current}\nPlease merge or remove one of them manually, then run \"agentfleet run\" again.",
136
+
137
+ "watcher.watching": "Watching for tasks in: {dir}",
138
+ "watcher.poll_interval": "Poll interval: {seconds}s",
139
+ "watcher.error": "Watcher error: {message}",
140
+ "watcher.stopped": "Task watcher stopped.",
141
+ "watcher.new_task": "New task detected: {taskId}{title}",
142
+ "watcher.read_error": "Error reading task file {file}: {message}",
143
+ "watcher.invalid_json": "Invalid JSON in {file}, skipping",
144
+ "watcher.missing_fields": "Task file {file} missing required fields: {fields}",
145
+ "watcher.load_processed_error": "Could not load processed.json, starting fresh",
146
+ "watcher.scan_error": "Error scanning tasks directory: {message}",
147
+
148
+ "executor.queued": "Task {taskId} queued ({running}/{max} running)",
149
+ "executor.executing": "Executing task {taskId} with: {command}",
150
+ "executor.working_dir": "Working directory: {dir}",
151
+ "executor.timeout": "Task {taskId} timed out after {minutes} minutes, killing process",
152
+
153
+ "result.written": "Results written to: {path}",
154
+
155
+ "shortcut.available": "`agentfleet` and `dma` commands are now available (shortcuts to `npx -y @daomar/agentfleet`)",
156
+ "shortcut.failed": "Shortcut registration failed: {error}",
157
+
158
+ "detector.multiple_accounts": "Multiple OneDrive accounts detected. Using the first one:",
159
+ "detector.detected": "OneDrive detected: {path}",
160
+
161
+ "logger.no_user_facing_strings": ""
162
+ }
@@ -0,0 +1,162 @@
1
+ {
2
+ "cli.description": "分布式智能体编排,无需控制平面。",
3
+
4
+ "cli.run_description": "启动 AgentFleet:如需初始化则自动完成,然后监听任务",
5
+ "cli.run_option_poll": "轮询间隔(秒)",
6
+ "cli.run_option_concurrency": "最大并发代理进程数",
7
+ "cli.run_option_daemon": "以后台守护进程方式运行",
8
+ "cli.run_option_log_file": "日志文件路径(配合 --daemon 使用)",
9
+
10
+ "cli.submit_description": "提交新任务,由所有机器执行",
11
+ "cli.submit_option_prompt": "编码代理的提示/指令",
12
+ "cli.submit_option_title": "任务的简短标题",
13
+ "cli.submit_option_working_dir": "代理的工作目录",
14
+ "cli.submit_option_agent": "代理命令模板。使用 {prompt} 作为占位符(例如 \"claude -p {prompt} --allowed-tools WebSearch\")",
15
+
16
+ "cli.status_description": "显示所有任务或指定任务的状态",
17
+ "cli.stop_description": "停止正在运行的 AgentFleet 实例",
18
+ "cli.install_description": "安装 AgentFleet 登录自启动",
19
+ "cli.uninstall_description": "移除 AgentFleet 自启动并停止运行中的实例",
20
+
21
+ "cli.version_update_available": "AgentFleet v{current}(最新: v{latest})⚡ 有可用更新",
22
+ "cli.version_latest": "AgentFleet v{current}(最新)",
23
+ "cli.version_current": "AgentFleet v{current}",
24
+
25
+ "run.scheduled_task_running": "AgentFleet 正在运行(PID {pid}),已配置登录自启动。",
26
+ "run.scheduled_task_hint": "使用 `agentfleet stop` 停止,或使用 `agentfleet uninstall` 移除自启动。",
27
+ "run.scheduled_task_starting": "AgentFleet 已配置自启动。正在通过已配置的自启动项启动...",
28
+ "run.already_running": "AgentFleet 已在运行(PID {pid})",
29
+ "run.daemon_started": "AgentFleet 守护进程已启动(PID {pid})",
30
+ "run.daemon_log_file": "日志文件: {path}",
31
+ "run.daemon_pid_file": "PID 文件: {path}",
32
+ "run.starting": "AgentFleet - 正在启动",
33
+ "run.error": "{message}",
34
+ "run.running_on": "AgentFleet 正在 {hostname} 上运行",
35
+ "run.concurrency": "并发数: {value}",
36
+ "run.poll_interval": "轮询间隔: {value}秒",
37
+ "run.press_ctrl_c": "按 Ctrl+C 停止",
38
+ "run.running_as_daemon": "以守护进程方式运行(PID {pid})",
39
+ "run.submit_hint": "提交任务: {command} submit --prompt \"你的指令\"",
40
+ "run.shutting_down": "正在关闭...",
41
+ "run.task_error": "执行任务 {taskId} 出错: {message}",
42
+
43
+ "submit.task_submitted": "任务已提交: {taskId}",
44
+ "submit.title": "标题: {title}",
45
+ "submit.prompt": "提示: {prompt}",
46
+ "submit.working_dir": "工作目录: {path}",
47
+ "submit.file": "文件: {path}",
48
+ "submit.sync_hint": "此任务将通过 OneDrive 同步到所有机器。",
49
+ "submit.title_none": "(无)",
50
+
51
+ "status.running": "AgentFleet 正在运行(PID {pid})",
52
+ "status.mode_auto_start": "模式: 守护进程(登录自启动)",
53
+ "status.mode_daemon": "模式: 守护进程(后台)",
54
+ "status.mode_foreground": "模式: 前台",
55
+ "status.log_file": "日志文件: {path}",
56
+ "status.pid_file": "PID 文件: {path}",
57
+ "status.auto_start_not_running": "AgentFleet 已配置自启动,但当前未运行",
58
+ "status.auto_start_hint": "运行 `agentfleet run` 启动,或将在下次登录时自动启动。",
59
+ "status.not_running": "AgentFleet 未运行",
60
+ "status.version_update": "AgentFleet v{current}(最新: v{latest})⚡ 有可用更新",
61
+ "status.version_latest": "AgentFleet v{current}(最新)",
62
+ "status.version_current": "AgentFleet v{current}",
63
+ "status.no_tasks": "未找到任务。",
64
+ "status.tasks_header": "任务(共 {count} 个)",
65
+ "status.col_id": "ID",
66
+ "status.col_title": "标题",
67
+ "status.col_status": "状态",
68
+ "status.col_results": "结果",
69
+ "status.status_done": "完成({count})",
70
+ "status.status_pending": "等待中",
71
+ "status.untitled": "(无标题)",
72
+ "status.error_reading": "(读取文件出错)",
73
+ "status.task_not_found": "未找到任务: {taskId}",
74
+ "status.task_header": "任务: {taskId}",
75
+ "status.task_title": "标题: {title}",
76
+ "status.task_prompt": "提示: {prompt}",
77
+ "status.task_working_dir": "工作目录: {path}",
78
+ "status.task_agent": "代理: {agent}",
79
+ "status.task_created": "创建时间: {date}",
80
+ "status.task_created_by": "创建者: {hostname}",
81
+ "status.task_title_none": "(无)",
82
+ "status.task_default": "(默认)",
83
+ "status.task_unknown": "未知",
84
+ "status.results_header": "结果({count} 台机器):",
85
+ "status.result_status": "状态: {status}(退出码: {exitCode})",
86
+ "status.result_started": "开始时间: {date}",
87
+ "status.result_completed": "完成时间: {date}",
88
+ "status.result_error": "错误: {error}",
89
+ "status.output_files": "输出文件:",
90
+ "status.no_results": "暂无结果。",
91
+
92
+ "stop.not_running_no_pid": "AgentFleet 未运行(未找到 PID 文件)",
93
+ "stop.not_running_stale": "AgentFleet 未运行(已清理过期的 PID 文件)",
94
+ "stop.stopped": "AgentFleet 已停止(PID {pid})",
95
+ "stop.failed": "停止 AgentFleet 失败(PID {pid}): {message}",
96
+
97
+ "install.already_installed_running": "AgentFleet 自启动已安装且正在运行。",
98
+ "install.pid": "PID: {pid}",
99
+ "install.already_running": "AgentFleet 已在运行(PID {pid})。请先使用 `agentfleet stop` 停止。",
100
+ "install.installed": "AgentFleet 自启动已安装",
101
+ "install.task_name": "自启动名称: {name}",
102
+ "install.auto_start_hint": "AgentFleet 将在登录时通过 `npx -y @daomar/agentfleet run -d` 自动启动",
103
+ "install.already_installed": "AgentFleet 自启动已安装。",
104
+ "install.starting": "正在启动 AgentFleet...",
105
+ "install.started": "AgentFleet 已启动(PID {pid})",
106
+ "install.submit_hint": "提交任务: {command} submit --prompt \"你的指令\"",
107
+ "install.failed": "安装/启动自启动项失败: {message}",
108
+
109
+ "uninstall.not_installed": "未安装 AgentFleet 自启动项。",
110
+ "uninstall.stopped": "已停止运行中的 AgentFleet(PID {pid})",
111
+ "uninstall.removed": "AgentFleet 自启动项已移除",
112
+ "uninstall.no_auto_start": "AgentFleet 将不再在登录时自动启动。",
113
+ "uninstall.failed": "移除自启动项失败: {message}",
114
+
115
+ "autostart.unsupported": "平台 `{platform}` 不支持自启动。",
116
+
117
+ "bootstrap.no_onedrive": "未找到支持的 OneDrive 帐户。\n请安装 OneDrive 并使用个人或企业帐户登录。\n下载: https://www.microsoft.com/zh-cn/microsoft-365/onedrive/download",
118
+ "bootstrap.selected": "已选择 OneDrive: {name}({type})→ {path}",
119
+
120
+ "setup.created_dir": "已创建 {path}",
121
+ "setup.created_onedrive_dir": "已创建 OneDrive 目录: {path}",
122
+ "setup.symlink_valid": "符号链接有效: {link} → {target}",
123
+ "setup.symlink_stale": "符号链接过期,正在重新创建: {link}",
124
+ "setup.symlink_exists_as_dir": "{path} 已作为常规目录存在,非符号链接。跳过。",
125
+ "setup.created_junction": "已创建目录连接: {link} → {target}",
126
+ "setup.created_symlink": "已创建符号链接: {link} → {target}",
127
+ "setup.symlink_failed": "无法在 {path} 创建符号链接或目录连接。\n在 Windows 上,请尝试启用开发者模式:\n 设置 → 更新和安全 → 开发者选项 → 开发人员模式\n错误: {error}",
128
+ "setup.config_missing_path": "配置文件缺少 OneDrive 路径,正在重新创建",
129
+ "setup.config_corrupt": "配置文件损坏,正在重新创建",
130
+ "setup.onedrive_changed": "OneDrive 选择已更改,正在更新配置",
131
+ "setup.config_loaded": "配置已加载: {path}",
132
+ "setup.config_created": "配置已创建: {path}",
133
+ "setup.migrated": "已迁移{label}: {from} → {to}",
134
+ "setup.migrated_reused": "已复用旧版{label}: {from} → {to}",
135
+ "setup.migrate_conflict": "同时发现旧版和当前版本的{label}目录。\n旧版: {legacy}\n当前: {current}\n请手动合并或删除其中一个,然后重新运行 \"agentfleet run\"。",
136
+
137
+ "watcher.watching": "正在监听任务目录: {dir}",
138
+ "watcher.poll_interval": "轮询间隔: {seconds}秒",
139
+ "watcher.error": "监听器错误: {message}",
140
+ "watcher.stopped": "任务监听器已停止。",
141
+ "watcher.new_task": "检测到新任务: {taskId}{title}",
142
+ "watcher.read_error": "读取任务文件 {file} 出错: {message}",
143
+ "watcher.invalid_json": "{file} 中的 JSON 无效,跳过",
144
+ "watcher.missing_fields": "任务文件 {file} 缺少必需字段: {fields}",
145
+ "watcher.load_processed_error": "无法加载 processed.json,从头开始",
146
+ "watcher.scan_error": "扫描任务目录出错: {message}",
147
+
148
+ "executor.queued": "任务 {taskId} 已排队({running}/{max} 正在运行)",
149
+ "executor.executing": "正在执行任务 {taskId},使用: {command}",
150
+ "executor.working_dir": "工作目录: {dir}",
151
+ "executor.timeout": "任务 {taskId} 在 {minutes} 分钟后超时,正在终止进程",
152
+
153
+ "result.written": "结果已写入: {path}",
154
+
155
+ "shortcut.available": "`agentfleet` 和 `dma` 命令现已可用(快捷方式指向 `npx -y @daomar/agentfleet`)",
156
+ "shortcut.failed": "快捷方式注册失败: {error}",
157
+
158
+ "detector.multiple_accounts": "检测到多个 OneDrive 账户,使用第一个:",
159
+ "detector.detected": "已检测到 OneDrive: {path}",
160
+
161
+ "logger.no_user_facing_strings": ""
162
+ }
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentExecutor = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const i18n_1 = require("./i18n");
6
+ class AgentExecutor {
7
+ constructor(config) {
8
+ this.runningCount = 0;
9
+ this.queue = [];
10
+ this.config = config;
11
+ }
12
+ /**
13
+ * Execute a task using the configured coding agent.
14
+ * Respects concurrency limits — queues if at max.
15
+ */
16
+ async execute(task) {
17
+ if (this.runningCount >= this.config.maxConcurrency) {
18
+ console.log(`⏳ ${(0, i18n_1.t)('executor.queued', { taskId: task.id, running: this.runningCount, max: this.config.maxConcurrency })}`);
19
+ return new Promise((resolve, reject) => {
20
+ this.queue.push({ task, resolve, reject });
21
+ });
22
+ }
23
+ return this.run(task);
24
+ }
25
+ async run(task) {
26
+ this.runningCount++;
27
+ const agentCommand = task.command || this.config.defaultAgentCommand;
28
+ const startedAt = new Date().toISOString();
29
+ console.log(`🚀 ${(0, i18n_1.t)('executor.executing', { taskId: task.id, command: agentCommand })}`);
30
+ if (task.workingDirectory) {
31
+ console.log(` ${(0, i18n_1.t)('executor.working_dir', { dir: task.workingDirectory })}`);
32
+ }
33
+ try {
34
+ const result = await this.spawnAgent(task, agentCommand);
35
+ return {
36
+ taskId: task.id,
37
+ ...result,
38
+ startedAt,
39
+ completedAt: new Date().toISOString(),
40
+ agentCommand,
41
+ };
42
+ }
43
+ finally {
44
+ this.runningCount--;
45
+ this.drainQueue();
46
+ }
47
+ }
48
+ drainQueue() {
49
+ if (this.queue.length > 0 && this.runningCount < this.config.maxConcurrency) {
50
+ const next = this.queue.shift();
51
+ this.run(next.task).then(next.resolve).catch(next.reject);
52
+ }
53
+ }
54
+ spawnAgent(task, agentCommand) {
55
+ return new Promise((resolve) => {
56
+ // Build full command: replace {prompt} placeholder, or append prompt at end
57
+ const quotedPrompt = JSON.stringify(task.prompt);
58
+ const fullCommand = agentCommand.includes('{prompt}')
59
+ ? agentCommand.replace('{prompt}', quotedPrompt)
60
+ : `${agentCommand} ${quotedPrompt}`;
61
+ let proc;
62
+ try {
63
+ proc = (0, child_process_1.spawn)(fullCommand, [], {
64
+ cwd: task.workingDirectory || process.cwd(),
65
+ shell: true,
66
+ stdio: ['ignore', 'pipe', 'pipe'],
67
+ windowsHide: true,
68
+ });
69
+ }
70
+ catch (err) {
71
+ resolve({
72
+ exitCode: 127,
73
+ status: 'failed',
74
+ stdout: '',
75
+ stderr: '',
76
+ error: `Failed to spawn agent: ${err.message}`,
77
+ });
78
+ return;
79
+ }
80
+ let stdout = '';
81
+ let stderr = '';
82
+ let stdoutTruncated = false;
83
+ let stderrTruncated = false;
84
+ const sizeLimit = this.config.outputSizeLimitBytes;
85
+ proc.stdout?.on('data', (data) => {
86
+ if (!stdoutTruncated) {
87
+ stdout += data.toString();
88
+ if (stdout.length > sizeLimit) {
89
+ stdout = stdout.substring(0, sizeLimit) + '\n\n[OUTPUT TRUNCATED - exceeded size limit]';
90
+ stdoutTruncated = true;
91
+ }
92
+ }
93
+ });
94
+ proc.stderr?.on('data', (data) => {
95
+ if (!stderrTruncated) {
96
+ stderr += data.toString();
97
+ if (stderr.length > sizeLimit) {
98
+ stderr = stderr.substring(0, sizeLimit) + '\n\n[OUTPUT TRUNCATED - exceeded size limit]';
99
+ stderrTruncated = true;
100
+ }
101
+ }
102
+ });
103
+ // Timeout handling
104
+ const timeoutMs = this.config.taskTimeoutMinutes * 60 * 1000;
105
+ const timer = setTimeout(() => {
106
+ console.warn(`⏰ ${(0, i18n_1.t)('executor.timeout', { taskId: task.id, minutes: this.config.taskTimeoutMinutes })}`);
107
+ proc.kill('SIGTERM');
108
+ setTimeout(() => {
109
+ if (!proc.killed)
110
+ proc.kill('SIGKILL');
111
+ }, 5000);
112
+ }, timeoutMs);
113
+ let timedOut = false;
114
+ proc.on('close', (code, signal) => {
115
+ clearTimeout(timer);
116
+ if (signal === 'SIGTERM' || signal === 'SIGKILL') {
117
+ timedOut = true;
118
+ }
119
+ if (timedOut) {
120
+ resolve({ exitCode: code ?? 1, status: 'timeout', stdout, stderr, error: 'Process timed out' });
121
+ }
122
+ else if (code === 0) {
123
+ resolve({ exitCode: 0, status: 'completed', stdout, stderr });
124
+ }
125
+ else {
126
+ resolve({ exitCode: code ?? 1, status: 'failed', stdout, stderr, error: `Process exited with code ${code}` });
127
+ }
128
+ });
129
+ proc.on('error', (err) => {
130
+ clearTimeout(timer);
131
+ resolve({
132
+ exitCode: 127,
133
+ status: 'failed',
134
+ stdout,
135
+ stderr,
136
+ error: `Agent command failed: ${agentCommand}. ${err.message}`,
137
+ });
138
+ });
139
+ });
140
+ }
141
+ }
142
+ exports.AgentExecutor = AgentExecutor;
143
+ //# sourceMappingURL=agent-executor.js.map
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAutoStartManager = createAutoStartManager;
4
+ const i18n_1 = require("./i18n");
5
+ const windows_service_1 = require("./windows-service");
6
+ const macos_auto_start_1 = require("./macos-auto-start");
7
+ class UnsupportedAutoStartManager {
8
+ constructor(platform) {
9
+ this.platform = platform;
10
+ }
11
+ isSupported() {
12
+ return false;
13
+ }
14
+ queryState() {
15
+ return 'not-installed';
16
+ }
17
+ install() {
18
+ throw new Error((0, i18n_1.t)('autostart.unsupported', { platform: this.platform }));
19
+ }
20
+ uninstall() {
21
+ throw new Error((0, i18n_1.t)('autostart.unsupported', { platform: this.platform }));
22
+ }
23
+ start() {
24
+ throw new Error((0, i18n_1.t)('autostart.unsupported', { platform: this.platform }));
25
+ }
26
+ getName() {
27
+ return this.platform;
28
+ }
29
+ }
30
+ function createAutoStartManager(options = {}) {
31
+ const platform = options.platform ?? process.platform;
32
+ switch (platform) {
33
+ case 'win32':
34
+ return new windows_service_1.ScheduledTaskManager(options.windowsDeps);
35
+ case 'darwin':
36
+ return new macos_auto_start_1.LaunchAgentManager(options.macosDeps);
37
+ default:
38
+ return new UnsupportedAutoStartManager(platform);
39
+ }
40
+ }
41
+ //# sourceMappingURL=auto-start.js.map
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bootstrap = bootstrap;
4
+ const onedrive_detector_1 = require("./onedrive-detector");
5
+ const setup_1 = require("./setup");
6
+ const provider_selection_1 = require("./provider-selection");
7
+ const i18n_1 = require("./i18n");
8
+ async function bootstrap(deps = {}) {
9
+ const setup = deps.setup ?? new setup_1.SetupService();
10
+ const existingConfig = setup.loadConfig();
11
+ if (existingConfig) {
12
+ const selection = (0, provider_selection_1.selectionFromConfig)(existingConfig);
13
+ return setup.setup(selection);
14
+ }
15
+ const detector = deps.detector ?? new onedrive_detector_1.OneDriveDetector();
16
+ const accounts = detector.detectAccounts();
17
+ if (accounts.length === 0) {
18
+ throw new Error((0, i18n_1.t)('bootstrap.no_onedrive'));
19
+ }
20
+ const selected = accounts[0];
21
+ console.log(`✓ ${(0, i18n_1.t)('bootstrap.selected', { name: selected.accountName, type: selected.accountType, path: selected.path })}`);
22
+ return setup.setup(selected);
23
+ }
24
+ //# sourceMappingURL=bootstrap.js.map