@pheem49/mint 1.5.5 → 1.6.1
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/.codex +0 -0
- package/.github/FUNDING.yml +2 -0
- package/.github/workflows/ci.yml +45 -0
- package/.github/workflows/release.yml +79 -0
- package/Cargo.lock +5792 -0
- package/Cargo.toml +32 -0
- package/README.md +387 -353
- package/assets/icon.png +0 -0
- package/bin/mint +0 -0
- package/crates/mint-cli/Cargo.toml +23 -0
- package/crates/mint-cli/src/agent.rs +851 -0
- package/crates/mint-cli/src/gmail.rs +216 -0
- package/crates/mint-cli/src/image.rs +142 -0
- package/crates/mint-cli/src/main.rs +2837 -0
- package/crates/mint-cli/src/mcp.rs +63 -0
- package/crates/mint-cli/src/onboard.rs +1149 -0
- package/crates/mint-cli/src/setup.rs +390 -0
- package/crates/mint-cli/src/skills.rs +8 -0
- package/crates/mint-cli/src/updater.rs +279 -0
- package/crates/mint-core/Cargo.toml +22 -0
- package/crates/mint-core/src/agent_loop.rs +94 -0
- package/crates/mint-core/src/api_server.rs +991 -0
- package/crates/mint-core/src/channels.rs +248 -0
- package/crates/mint-core/src/chat.rs +895 -0
- package/crates/mint-core/src/code_tools.rs +729 -0
- package/crates/mint-core/src/config.rs +368 -0
- package/crates/mint-core/src/files.rs +159 -0
- package/crates/mint-core/src/knowledge.rs +541 -0
- package/crates/mint-core/src/lib.rs +84 -0
- package/crates/mint-core/src/mcp.rs +273 -0
- package/crates/mint-core/src/memory.rs +673 -0
- package/crates/mint-core/src/orchestration.rs +2157 -0
- package/crates/mint-core/src/pictures.rs +314 -0
- package/crates/mint-core/src/plugins.rs +727 -0
- package/crates/mint-core/src/safety.rs +416 -0
- package/crates/mint-core/src/semantic.rs +254 -0
- package/crates/mint-core/src/shell.rs +317 -0
- package/crates/mint-core/src/skills.rs +71 -0
- package/crates/mint-core/src/symbols.rs +157 -0
- package/crates/mint-core/src/tasks.rs +308 -0
- package/crates/mint-core/src/tts.rs +92 -0
- package/crates/mint-core/src/weather.rs +93 -0
- package/crates/mint-core/src/web_search.rs +200 -0
- package/crates/mint-core/src/workflows.rs +81 -0
- package/crates/mint-core/tests/mcp_stdio.rs +45 -0
- package/crates/mint-core/tests/memory_persistence.rs +172 -0
- package/crates/mint-core/tests/pictures_storage.rs +14 -0
- package/crates/mint-core/tests/task_lifecycle.rs +87 -0
- package/package.json +35 -99
- package/src/bin/index.js +16 -0
- package/src/renderer/index-web.html +17 -0
- package/src/renderer/index.html +17 -0
- package/src/renderer/public/Live2DCubismCore.js +9 -0
- package/src/renderer/public/assets/icon.png +0 -0
- package/src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.model3.json +36 -0
- package/src/renderer/src/App.tsx +33 -0
- package/src/renderer/src/calculator.ts +47 -0
- package/src/renderer/src/components/ChatPanel.tsx +1598 -0
- package/src/renderer/src/components/DashboardSidebar.tsx +358 -0
- package/src/renderer/src/components/Live2DStage.tsx +374 -0
- package/src/renderer/src/components/MintDashboard.tsx +950 -0
- package/src/renderer/src/components/ModelPanel.tsx +154 -0
- package/src/renderer/src/components/PicturesLibrary.tsx +46 -0
- package/src/renderer/src/components/ProactiveGlow.tsx +19 -0
- package/src/renderer/src/components/ScreenPicker.tsx +579 -0
- package/src/renderer/src/components/SettingsWindow.tsx +1467 -0
- package/src/renderer/src/components/SpotlightWindow.tsx +280 -0
- package/src/renderer/src/components/WidgetWindow.tsx +36 -0
- package/src/renderer/src/components/WorkspacePanel.tsx +268 -0
- package/src/{UI → renderer/src/css}/settings.css +69 -16
- package/src/renderer/src/css/spotlight.css +113 -0
- package/src/renderer/src/css/styles.css +3722 -0
- package/src/renderer/src/css/widget.css +185 -0
- package/src/renderer/src/env.d.ts +116 -0
- package/src/renderer/src/index.css +379 -0
- package/src/renderer/src/main.tsx +13 -0
- package/src/renderer/src/tauri.ts +996 -0
- package/src/renderer/src-web/App.tsx +25 -0
- package/src/renderer/src-web/calculator.ts +47 -0
- package/src/renderer/src-web/components/ChatPanel.tsx +1662 -0
- package/src/renderer/src-web/components/DashboardSidebar.tsx +242 -0
- package/src/renderer/src-web/components/MintDashboard.tsx +763 -0
- package/src/renderer/src-web/components/PicturesLibrary.tsx +73 -0
- package/src/renderer/src-web/components/SettingsWindow.tsx +1500 -0
- package/src/renderer/src-web/css/settings.css +1100 -0
- package/src/{UI → renderer/src-web/css}/spotlight.css +4 -4
- package/src/{UI → renderer/src-web/css}/styles.css +1055 -159
- package/src/{UI → renderer/src-web/css}/widget.css +2 -2
- package/src/renderer/src-web/env.d.ts +107 -0
- package/src/renderer/src-web/index.css +379 -0
- package/src/renderer/src-web/main.tsx +13 -0
- package/src/renderer/src-web/tauri.ts +983 -0
- package/tsconfig.json +30 -0
- package/vite.config.ts +33 -0
- package/vite.config.web.ts +51 -0
- package/GUIDE_TH.md +0 -125
- package/assets/Agent_Mint.png +0 -0
- package/assets/CLI_Screen.png +0 -0
- package/assets/Settings.png +0 -0
- package/benchmark_ai.js +0 -71
- package/install.ps1 +0 -64
- package/install.sh +0 -54
- package/main.js +0 -139
- package/mint-cli-logic.js +0 -3
- package/mint-cli.js +0 -410
- package/models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.model3.json +0 -47
- package/models/Shiroko_Model/Shiroko//342/232/241/351/253/230/344/272/256/342/232/241/344/275/277/347/224/250/346/225/231/347/250/213/344/270/216/346/263/250/346/204/217/344/272/213/351/241/271.txt +0 -23
- package/preload-picker.js +0 -11
- package/preload-settings.js +0 -11
- package/preload.js +0 -41
- package/scripts/install_linux_desktop_entry.js +0 -48
- package/src/AI_Brain/Gemini_API.js +0 -813
- package/src/AI_Brain/agent_orchestrator.js +0 -73
- package/src/AI_Brain/autonomous_brain.js +0 -179
- package/src/AI_Brain/behavior_memory.js +0 -135
- package/src/AI_Brain/headless_agent.js +0 -143
- package/src/AI_Brain/knowledge_base.js +0 -349
- package/src/AI_Brain/memory_store.js +0 -662
- package/src/AI_Brain/proactive_engine.js +0 -172
- package/src/AI_Brain/provider_adapter.js +0 -365
- package/src/Automation_Layer/browser_automation.js +0 -149
- package/src/Automation_Layer/file_operations.js +0 -286
- package/src/Automation_Layer/open_app.js +0 -85
- package/src/Automation_Layer/open_website.js +0 -38
- package/src/CLI/approval_handler.js +0 -47
- package/src/CLI/chat_router.js +0 -247
- package/src/CLI/chat_ui.js +0 -1159
- package/src/CLI/cli_colors.js +0 -115
- package/src/CLI/cli_formatters.js +0 -94
- package/src/CLI/code_agent.js +0 -1667
- package/src/CLI/code_session_memory.js +0 -62
- package/src/CLI/gmail_auth.js +0 -210
- package/src/CLI/image_input.js +0 -90
- package/src/CLI/intent_detectors.js +0 -181
- package/src/CLI/interactive_chat.js +0 -658
- package/src/CLI/list_features.js +0 -64
- package/src/CLI/onboarding.js +0 -416
- package/src/CLI/repo_summarizer.js +0 -282
- package/src/CLI/semantic_code_search.js +0 -312
- package/src/CLI/skill_manager.js +0 -41
- package/src/CLI/slash_command_handler.js +0 -418
- package/src/CLI/symbol_indexer.js +0 -231
- package/src/CLI/updater.js +0 -230
- package/src/CLI/workspace_manager.js +0 -90
- package/src/Channels/brave_search_bridge.js +0 -35
- package/src/Channels/discord_bridge.js +0 -66
- package/src/Channels/google_search_bridge.js +0 -38
- package/src/Channels/line_bridge.js +0 -60
- package/src/Channels/slack_bridge.js +0 -48
- package/src/Channels/telegram_bridge.js +0 -41
- package/src/Channels/whatsapp_bridge.js +0 -57
- package/src/Command_Parser/parser.js +0 -45
- package/src/Plugins/dev_tools.js +0 -41
- package/src/Plugins/discord.js +0 -20
- package/src/Plugins/docker.js +0 -47
- package/src/Plugins/gmail.js +0 -251
- package/src/Plugins/google_calendar.js +0 -252
- package/src/Plugins/mcp_manager.js +0 -95
- package/src/Plugins/notion.js +0 -256
- package/src/Plugins/obsidian.js +0 -54
- package/src/Plugins/plugin_manager.js +0 -81
- package/src/Plugins/spotify.js +0 -173
- package/src/Plugins/system_metrics.js +0 -31
- package/src/Plugins/system_monitor.js +0 -72
- package/src/System/action_executor.js +0 -178
- package/src/System/bridge_manager.js +0 -76
- package/src/System/chat_history_manager.js +0 -83
- package/src/System/config_manager.js +0 -194
- package/src/System/custom_workflows.js +0 -163
- package/src/System/daemon_manager.js +0 -67
- package/src/System/google_tts_urls.js +0 -51
- package/src/System/granular_automation.js +0 -157
- package/src/System/ipc_handlers.js +0 -332
- package/src/System/notifications.js +0 -23
- package/src/System/optional_require.js +0 -23
- package/src/System/picture_store.js +0 -109
- package/src/System/proactive_loop.js +0 -153
- package/src/System/safety_manager.js +0 -273
- package/src/System/sandbox_runner.js +0 -182
- package/src/System/screen_capture.js +0 -175
- package/src/System/smart_context.js +0 -227
- package/src/System/system_automation.js +0 -162
- package/src/System/system_events.js +0 -79
- package/src/System/system_info.js +0 -125
- package/src/System/task_manager.js +0 -222
- package/src/System/tool_registry.js +0 -293
- package/src/System/window_manager.js +0 -220
- package/src/UI/floating.css +0 -80
- package/src/UI/floating.html +0 -17
- package/src/UI/floating.js +0 -67
- package/src/UI/live2d_manager.js +0 -600
- package/src/UI/preload-floating.js +0 -7
- package/src/UI/preload-spotlight.js +0 -11
- package/src/UI/preload-widget.js +0 -5
- package/src/UI/proactive-glow.html +0 -42
- package/src/UI/renderer.js +0 -2127
- package/src/UI/screenPicker.html +0 -214
- package/src/UI/screenPicker.js +0 -262
- package/src/UI/settings.html +0 -577
- package/src/UI/settings.js +0 -770
- package/src/UI/spotlight.html +0 -23
- package/src/UI/spotlight.js +0 -185
- package/src/UI/widget.html +0 -29
- package/src/UI/widget.js +0 -10
- /package/{models → src/renderer/public/models}/Shiroko_Model/Shiroko/Shiroko_Core/72d86db84cfa9730b894c241fd24c0db.png +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//345/233/264/350/243/231.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/apron.exp3.json} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//347/214/253/345/222/252/346/273/244/351/225/234.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/catfilter.exp3.json} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//347/202/271/344/270/200/344/270/213.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/click.exp3.json} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//345/221/206/347/214/253.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/dazed.exp3.json} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//345/221/206/347/214/253/347/234/274/347/217/240/346/221/207/346/231/203.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/dazedeyes.exp3.json} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//347/234/274/351/225/234.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/glasses.exp3.json} +0 -0
- /package/{models → src/renderer/public/models}/Shiroko_Model/Shiroko/Shiroko_Core/items_pinned_to_model.json +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//346/213/277/347/254/224.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/pen.exp3.json} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//346/213/215/347/205/247.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/photo.exp3.json} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.4096/texture_00.png" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.4096/texture_00.png} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.4096/texture_01.png" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.4096/texture_01.png} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.4096/texture_02.png" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.4096/texture_02.png} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.4096/texture_03.png" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.4096/texture_03.png} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.cdi3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.cdi3.json} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.moc3" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.moc3} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.physics3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.physics3.json} +0 -0
- /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.vtube.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.vtube.json} +0 -0
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const os = require('os');
|
|
4
|
-
|
|
5
|
-
const CONFIG_DIR = path.join(os.homedir(), '.config', 'mint');
|
|
6
|
-
const TASKS_FILE = path.join(CONFIG_DIR, 'tasks.json');
|
|
7
|
-
|
|
8
|
-
// Ensure directory exists
|
|
9
|
-
if (!fs.existsSync(CONFIG_DIR)) {
|
|
10
|
-
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Migration Logic: Move tasks.json from ~/.mint to ~/.config/mint
|
|
14
|
-
if (!fs.existsSync(TASKS_FILE)) {
|
|
15
|
-
const legacyPath = path.join(os.homedir(), '.mint', 'tasks.json');
|
|
16
|
-
if (fs.existsSync(legacyPath)) {
|
|
17
|
-
try {
|
|
18
|
-
fs.copyFileSync(legacyPath, TASKS_FILE);
|
|
19
|
-
console.log('[TaskManager] Migrated tasks from ~/.mint');
|
|
20
|
-
} catch (e) { console.error('[TaskManager] Migration failed:', e); }
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Task Statuses:
|
|
26
|
-
* - 'pending': Waiting for agent to pick up
|
|
27
|
-
* - 'running': Agent is currently working on it
|
|
28
|
-
* - 'completed': Done
|
|
29
|
-
* - 'failed': Error occurred
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
function readTasks() {
|
|
33
|
-
if (!fs.existsSync(TASKS_FILE)) return [];
|
|
34
|
-
try {
|
|
35
|
-
const content = fs.readFileSync(TASKS_FILE, 'utf8');
|
|
36
|
-
return JSON.parse(content);
|
|
37
|
-
} catch (e) {
|
|
38
|
-
console.error('[TaskManager] Error reading tasks:', e.message);
|
|
39
|
-
return [];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function writeTasks(tasks) {
|
|
44
|
-
try {
|
|
45
|
-
fs.writeFileSync(TASKS_FILE, JSON.stringify(tasks, null, 2));
|
|
46
|
-
} catch (e) {
|
|
47
|
-
console.error('[TaskManager] Error writing tasks:', e.message);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function addTask(description) {
|
|
52
|
-
const tasks = readTasks();
|
|
53
|
-
const newTask = {
|
|
54
|
-
id: Date.now().toString(),
|
|
55
|
-
description,
|
|
56
|
-
status: 'pending',
|
|
57
|
-
createdAt: new Date().toISOString(),
|
|
58
|
-
updatedAt: new Date().toISOString(),
|
|
59
|
-
steps: [],
|
|
60
|
-
subtasks: [],
|
|
61
|
-
checkpoints: [],
|
|
62
|
-
artifacts: [],
|
|
63
|
-
retryCount: 0,
|
|
64
|
-
maxRetries: 1,
|
|
65
|
-
lastCheckpointAt: null,
|
|
66
|
-
result: null
|
|
67
|
-
};
|
|
68
|
-
tasks.push(newTask);
|
|
69
|
-
writeTasks(tasks);
|
|
70
|
-
return newTask;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function getPendingTask() {
|
|
74
|
-
const tasks = readTasks();
|
|
75
|
-
return tasks.find(t => t.status === 'pending');
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function updateTask(id, updates) {
|
|
79
|
-
const tasks = readTasks();
|
|
80
|
-
const idx = tasks.findIndex(t => t.id === id);
|
|
81
|
-
if (idx !== -1) {
|
|
82
|
-
tasks[idx] = { ...tasks[idx], ...updates, updatedAt: new Date().toISOString() };
|
|
83
|
-
writeTasks(tasks);
|
|
84
|
-
return tasks[idx];
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function getTask(id) {
|
|
90
|
-
return readTasks().find(t => t.id === id) || null;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function normalizeTask(task) {
|
|
94
|
-
return {
|
|
95
|
-
...task,
|
|
96
|
-
steps: Array.isArray(task.steps) ? task.steps : [],
|
|
97
|
-
subtasks: Array.isArray(task.subtasks) ? task.subtasks : [],
|
|
98
|
-
checkpoints: Array.isArray(task.checkpoints) ? task.checkpoints : [],
|
|
99
|
-
artifacts: Array.isArray(task.artifacts) ? task.artifacts : [],
|
|
100
|
-
retryCount: Number.isFinite(task.retryCount) ? task.retryCount : 0,
|
|
101
|
-
maxRetries: Number.isFinite(task.maxRetries) ? task.maxRetries : 1
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function mutateTask(id, mutator) {
|
|
106
|
-
const tasks = readTasks();
|
|
107
|
-
const idx = tasks.findIndex(t => t.id === id);
|
|
108
|
-
if (idx === -1) return null;
|
|
109
|
-
const next = normalizeTask(tasks[idx]);
|
|
110
|
-
mutator(next);
|
|
111
|
-
next.updatedAt = new Date().toISOString();
|
|
112
|
-
tasks[idx] = next;
|
|
113
|
-
writeTasks(tasks);
|
|
114
|
-
return next;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function addSubtask(taskId, title, extra = {}) {
|
|
118
|
-
return mutateTask(taskId, task => {
|
|
119
|
-
task.subtasks.push({
|
|
120
|
-
id: `${taskId}-${task.subtasks.length + 1}`,
|
|
121
|
-
title,
|
|
122
|
-
status: extra.status || 'pending',
|
|
123
|
-
createdAt: new Date().toISOString(),
|
|
124
|
-
updatedAt: new Date().toISOString(),
|
|
125
|
-
...extra
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function updateSubtask(taskId, subtaskId, updates = {}) {
|
|
131
|
-
return mutateTask(taskId, task => {
|
|
132
|
-
const subtask = task.subtasks.find(item => item.id === subtaskId);
|
|
133
|
-
if (!subtask) return;
|
|
134
|
-
Object.assign(subtask, updates, { updatedAt: new Date().toISOString() });
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function addCheckpoint(taskId, checkpoint = {}) {
|
|
139
|
-
return mutateTask(taskId, task => {
|
|
140
|
-
const entry = {
|
|
141
|
-
id: `${taskId}-checkpoint-${task.checkpoints.length + 1}`,
|
|
142
|
-
time: new Date().toISOString(),
|
|
143
|
-
...checkpoint
|
|
144
|
-
};
|
|
145
|
-
task.checkpoints.push(entry);
|
|
146
|
-
task.lastCheckpointAt = entry.time;
|
|
147
|
-
task.steps.push(entry);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function addArtifact(taskId, artifact = {}) {
|
|
152
|
-
return mutateTask(taskId, task => {
|
|
153
|
-
task.artifacts.push({
|
|
154
|
-
id: `${taskId}-artifact-${task.artifacts.length + 1}`,
|
|
155
|
-
time: new Date().toISOString(),
|
|
156
|
-
...artifact
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function failTaskWithRetry(id, errorMessage) {
|
|
162
|
-
return mutateTask(id, task => {
|
|
163
|
-
const retryCount = Number(task.retryCount) || 0;
|
|
164
|
-
const maxRetries = Number.isFinite(task.maxRetries) ? task.maxRetries : 1;
|
|
165
|
-
task.result = errorMessage;
|
|
166
|
-
task.retryCount = retryCount + 1;
|
|
167
|
-
task.status = task.retryCount <= maxRetries ? 'pending' : 'failed';
|
|
168
|
-
const checkpoint = {
|
|
169
|
-
id: `${id}-checkpoint-${task.checkpoints.length + 1}`,
|
|
170
|
-
time: new Date().toISOString(),
|
|
171
|
-
phase: task.status === 'pending' ? 'retry_scheduled' : 'failed',
|
|
172
|
-
message: errorMessage,
|
|
173
|
-
retryCount: task.retryCount,
|
|
174
|
-
maxRetries
|
|
175
|
-
};
|
|
176
|
-
task.checkpoints.push(checkpoint);
|
|
177
|
-
task.steps.push(checkpoint);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function resumeRunningTasks() {
|
|
182
|
-
const resumed = [];
|
|
183
|
-
const tasks = readTasks().map(task => {
|
|
184
|
-
if (task.status !== 'running') return task;
|
|
185
|
-
const normalized = normalizeTask(task);
|
|
186
|
-
normalized.status = 'pending';
|
|
187
|
-
const checkpoint = {
|
|
188
|
-
id: `${normalized.id}-checkpoint-${normalized.checkpoints.length + 1}`,
|
|
189
|
-
time: new Date().toISOString(),
|
|
190
|
-
phase: 'resume_after_restart',
|
|
191
|
-
message: 'Task was running during shutdown and has been re-queued.'
|
|
192
|
-
};
|
|
193
|
-
normalized.checkpoints.push(checkpoint);
|
|
194
|
-
normalized.steps.push(checkpoint);
|
|
195
|
-
normalized.updatedAt = new Date().toISOString();
|
|
196
|
-
resumed.push(normalized);
|
|
197
|
-
return normalized;
|
|
198
|
-
});
|
|
199
|
-
writeTasks(tasks);
|
|
200
|
-
return resumed;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function clearCompletedTasks() {
|
|
204
|
-
const tasks = readTasks();
|
|
205
|
-
const activeTasks = tasks.filter(t => t.status === 'pending' || t.status === 'running');
|
|
206
|
-
writeTasks(activeTasks);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
module.exports = {
|
|
210
|
-
addTask,
|
|
211
|
-
addArtifact,
|
|
212
|
-
addCheckpoint,
|
|
213
|
-
addSubtask,
|
|
214
|
-
failTaskWithRetry,
|
|
215
|
-
getTask,
|
|
216
|
-
getPendingTask,
|
|
217
|
-
resumeRunningTasks,
|
|
218
|
-
updateTask,
|
|
219
|
-
updateSubtask,
|
|
220
|
-
readTasks,
|
|
221
|
-
clearCompletedTasks
|
|
222
|
-
};
|
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
const TOOL_REGISTRY = Object.freeze({
|
|
2
|
-
none: {
|
|
3
|
-
permission: 'safe',
|
|
4
|
-
required: [],
|
|
5
|
-
description: 'No action.'
|
|
6
|
-
},
|
|
7
|
-
web_search: {
|
|
8
|
-
permission: 'safe',
|
|
9
|
-
required: ['query'],
|
|
10
|
-
codeAgentOnly: true,
|
|
11
|
-
description: 'Search the internet when outside knowledge is required.'
|
|
12
|
-
},
|
|
13
|
-
list_files: {
|
|
14
|
-
permission: 'safe',
|
|
15
|
-
required: [],
|
|
16
|
-
codeAgentOnly: true,
|
|
17
|
-
description: 'List files under a workspace-relative path.'
|
|
18
|
-
},
|
|
19
|
-
read_file: {
|
|
20
|
-
permission: 'safe',
|
|
21
|
-
required: ['path'],
|
|
22
|
-
codeAgentOnly: true,
|
|
23
|
-
description: 'Read a workspace file, optionally bounded by startLine/endLine.'
|
|
24
|
-
},
|
|
25
|
-
search_code: {
|
|
26
|
-
permission: 'safe',
|
|
27
|
-
required: ['query'],
|
|
28
|
-
codeAgentOnly: true,
|
|
29
|
-
description: 'Search text in the workspace.'
|
|
30
|
-
},
|
|
31
|
-
find_path: {
|
|
32
|
-
permission: 'safe',
|
|
33
|
-
required: ['query'],
|
|
34
|
-
chatAction: true,
|
|
35
|
-
description: 'Find files or folders by name.'
|
|
36
|
-
},
|
|
37
|
-
run_shell: {
|
|
38
|
-
permission: 'approval',
|
|
39
|
-
required: ['command'],
|
|
40
|
-
codeAgentOnly: true,
|
|
41
|
-
important: true,
|
|
42
|
-
description: 'Run a non-destructive shell command after user approval.'
|
|
43
|
-
},
|
|
44
|
-
verify: {
|
|
45
|
-
permission: 'approval',
|
|
46
|
-
required: [],
|
|
47
|
-
codeAgentOnly: true,
|
|
48
|
-
important: true,
|
|
49
|
-
description: 'Run test/build/lint verification commands after user approval.'
|
|
50
|
-
},
|
|
51
|
-
plan: {
|
|
52
|
-
permission: 'approval',
|
|
53
|
-
required: ['plan'],
|
|
54
|
-
codeAgentOnly: true,
|
|
55
|
-
description: 'Present a multi-file edit plan before changing files.'
|
|
56
|
-
},
|
|
57
|
-
apply_patch: {
|
|
58
|
-
permission: 'approval',
|
|
59
|
-
required: ['patch'],
|
|
60
|
-
codeAgentOnly: true,
|
|
61
|
-
important: true,
|
|
62
|
-
description: 'Patch an existing file after user approval.'
|
|
63
|
-
},
|
|
64
|
-
write_file: {
|
|
65
|
-
permission: 'approval',
|
|
66
|
-
required: ['path', 'content'],
|
|
67
|
-
codeAgentOnly: true,
|
|
68
|
-
important: true,
|
|
69
|
-
description: 'Create or replace a file after user approval.'
|
|
70
|
-
},
|
|
71
|
-
ask_user: {
|
|
72
|
-
permission: 'safe',
|
|
73
|
-
required: ['question'],
|
|
74
|
-
codeAgentOnly: true,
|
|
75
|
-
description: 'Ask the user for clarification.'
|
|
76
|
-
},
|
|
77
|
-
open_url: {
|
|
78
|
-
permission: 'safe',
|
|
79
|
-
required: ['target'],
|
|
80
|
-
chatAction: true,
|
|
81
|
-
description: 'Open a URL.'
|
|
82
|
-
},
|
|
83
|
-
search: {
|
|
84
|
-
permission: 'safe',
|
|
85
|
-
required: ['target'],
|
|
86
|
-
chatAction: true,
|
|
87
|
-
description: 'Open a web search.'
|
|
88
|
-
},
|
|
89
|
-
open_app: {
|
|
90
|
-
permission: 'safe',
|
|
91
|
-
required: ['target'],
|
|
92
|
-
chatAction: true,
|
|
93
|
-
description: 'Open a local application.'
|
|
94
|
-
},
|
|
95
|
-
web_automation: {
|
|
96
|
-
permission: 'safe',
|
|
97
|
-
required: ['target'],
|
|
98
|
-
chatAction: true,
|
|
99
|
-
important: true,
|
|
100
|
-
description: 'Perform browser automation.'
|
|
101
|
-
},
|
|
102
|
-
create_folder: {
|
|
103
|
-
permission: 'safe',
|
|
104
|
-
required: ['target'],
|
|
105
|
-
chatAction: true,
|
|
106
|
-
description: 'Create a folder.'
|
|
107
|
-
},
|
|
108
|
-
open_file: {
|
|
109
|
-
permission: 'safe',
|
|
110
|
-
required: ['target'],
|
|
111
|
-
chatAction: true,
|
|
112
|
-
description: 'Open a local file.'
|
|
113
|
-
},
|
|
114
|
-
open_folder: {
|
|
115
|
-
permission: 'safe',
|
|
116
|
-
required: ['target'],
|
|
117
|
-
chatAction: true,
|
|
118
|
-
description: 'Open a local folder.'
|
|
119
|
-
},
|
|
120
|
-
delete_file: {
|
|
121
|
-
permission: 'dangerous',
|
|
122
|
-
required: ['target'],
|
|
123
|
-
chatAction: true,
|
|
124
|
-
important: true,
|
|
125
|
-
description: 'Delete a file only after explicit dangerous-action permission.'
|
|
126
|
-
},
|
|
127
|
-
clipboard_write: {
|
|
128
|
-
permission: 'safe',
|
|
129
|
-
required: ['target'],
|
|
130
|
-
chatAction: true,
|
|
131
|
-
description: 'Write text to clipboard.'
|
|
132
|
-
},
|
|
133
|
-
learn_file: {
|
|
134
|
-
permission: 'safe',
|
|
135
|
-
required: ['target'],
|
|
136
|
-
chatAction: true,
|
|
137
|
-
description: 'Index a file into the knowledge base.'
|
|
138
|
-
},
|
|
139
|
-
learn_folder: {
|
|
140
|
-
permission: 'safe',
|
|
141
|
-
required: ['target'],
|
|
142
|
-
chatAction: true,
|
|
143
|
-
description: 'Index a folder into the knowledge base.'
|
|
144
|
-
},
|
|
145
|
-
system_info: {
|
|
146
|
-
permission: 'safe',
|
|
147
|
-
required: [],
|
|
148
|
-
chatAction: true,
|
|
149
|
-
description: 'Read local system info, or weather when target is a city.'
|
|
150
|
-
},
|
|
151
|
-
plugin: {
|
|
152
|
-
permission: 'safe',
|
|
153
|
-
required: ['pluginName', 'target'],
|
|
154
|
-
chatAction: true,
|
|
155
|
-
description: 'Run a Mint plugin.'
|
|
156
|
-
},
|
|
157
|
-
mcp_tool: {
|
|
158
|
-
permission: 'safe',
|
|
159
|
-
required: ['server', 'target'],
|
|
160
|
-
chatAction: true,
|
|
161
|
-
description: 'Call an MCP tool.'
|
|
162
|
-
},
|
|
163
|
-
mouse_click: {
|
|
164
|
-
permission: 'safe',
|
|
165
|
-
required: ['x', 'y'],
|
|
166
|
-
chatAction: true,
|
|
167
|
-
important: true,
|
|
168
|
-
description: 'Click at screen coordinates.'
|
|
169
|
-
},
|
|
170
|
-
mouse_move: {
|
|
171
|
-
permission: 'safe',
|
|
172
|
-
required: ['x', 'y'],
|
|
173
|
-
chatAction: true,
|
|
174
|
-
description: 'Move the mouse.'
|
|
175
|
-
},
|
|
176
|
-
type_text: {
|
|
177
|
-
permission: 'safe',
|
|
178
|
-
required: ['target'],
|
|
179
|
-
chatAction: true,
|
|
180
|
-
important: true,
|
|
181
|
-
description: 'Type text into the active UI.'
|
|
182
|
-
},
|
|
183
|
-
key_tap: {
|
|
184
|
-
permission: 'safe',
|
|
185
|
-
required: ['target'],
|
|
186
|
-
chatAction: true,
|
|
187
|
-
important: true,
|
|
188
|
-
description: 'Press a key.'
|
|
189
|
-
},
|
|
190
|
-
system_automation: {
|
|
191
|
-
permission: 'approval',
|
|
192
|
-
required: ['target'],
|
|
193
|
-
chatAction: true,
|
|
194
|
-
important: true,
|
|
195
|
-
description: 'Change system settings after approval.'
|
|
196
|
-
},
|
|
197
|
-
finish: {
|
|
198
|
-
permission: 'safe',
|
|
199
|
-
required: ['summary'],
|
|
200
|
-
codeAgentOnly: true,
|
|
201
|
-
description: 'Finish the task and reply.'
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
function getTool(name) {
|
|
206
|
-
return TOOL_REGISTRY[name] || null;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function listToolNames(filter = {}) {
|
|
210
|
-
return Object.entries(TOOL_REGISTRY)
|
|
211
|
-
.filter(([, tool]) => {
|
|
212
|
-
if (filter.chatAction === true && tool.chatAction !== true) return false;
|
|
213
|
-
if (filter.codeAgent === true && tool.chatAction === true && tool.codeAgentOnly !== true) return true;
|
|
214
|
-
return true;
|
|
215
|
-
})
|
|
216
|
-
.map(([name]) => name);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function listChatActionNames() {
|
|
220
|
-
return Object.entries(TOOL_REGISTRY)
|
|
221
|
-
.filter(([, tool]) => tool.chatAction === true)
|
|
222
|
-
.map(([name]) => name);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function listCodeAgentActionNames() {
|
|
226
|
-
return Object.entries(TOOL_REGISTRY)
|
|
227
|
-
.filter(([, tool]) => tool.codeAgentOnly === true || tool.chatAction === true || tool.required)
|
|
228
|
-
.map(([name]) => name);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function isEmptyToolValue(value) {
|
|
232
|
-
if (value === undefined || value === null) return true;
|
|
233
|
-
if (typeof value === 'string') return value.trim() === '';
|
|
234
|
-
if (Array.isArray(value)) return value.length === 0;
|
|
235
|
-
if (typeof value === 'object') return Object.keys(value).length === 0;
|
|
236
|
-
return false;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function validateToolInput(action, input = {}) {
|
|
240
|
-
const tool = getTool(action);
|
|
241
|
-
if (!tool) {
|
|
242
|
-
throw new Error(`Unsupported action: ${action}`);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const missing = (tool.required || []).filter(field => {
|
|
246
|
-
if (!isEmptyToolValue(input[field])) return false;
|
|
247
|
-
if (field === 'target' && (!isEmptyToolValue(input.path) || !isEmptyToolValue(input.query))) return false;
|
|
248
|
-
if (field === 'query' && !isEmptyToolValue(input.target)) return false;
|
|
249
|
-
return true;
|
|
250
|
-
});
|
|
251
|
-
if (missing.length > 0) {
|
|
252
|
-
throw new Error(`Action "${action}" is missing required input field(s): ${missing.join(', ')}`);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
if (action === 'apply_patch') {
|
|
256
|
-
const patchInput = input.patch || {};
|
|
257
|
-
if (!patchInput.path || !Array.isArray(patchInput.hunks) || patchInput.hunks.length === 0) {
|
|
258
|
-
throw new Error('Action "apply_patch" requires input.patch.path and at least one hunk.');
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
return tool;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function isImportantAction(action) {
|
|
266
|
-
const tool = getTool(action);
|
|
267
|
-
return !!(tool && tool.important);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function buildChatActionTypeUnion() {
|
|
271
|
-
return ['none', ...listChatActionNames()].filter((name, index, arr) => arr.indexOf(name) === index).map(name => `"${name}"`).join(' | ');
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function buildToolPromptSection() {
|
|
275
|
-
const lines = ['\n\nAVAILABLE BUILT-IN ACTIONS:'];
|
|
276
|
-
for (const name of listChatActionNames()) {
|
|
277
|
-
const tool = getTool(name);
|
|
278
|
-
lines.push(`- ${name}: ${tool.description}`);
|
|
279
|
-
}
|
|
280
|
-
return lines.join('\n');
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
module.exports = {
|
|
284
|
-
TOOL_REGISTRY,
|
|
285
|
-
getTool,
|
|
286
|
-
listToolNames,
|
|
287
|
-
listChatActionNames,
|
|
288
|
-
listCodeAgentActionNames,
|
|
289
|
-
validateToolInput,
|
|
290
|
-
isImportantAction,
|
|
291
|
-
buildChatActionTypeUnion,
|
|
292
|
-
buildToolPromptSection
|
|
293
|
-
};
|