@cortex-agent/server 2026.6.11 → 2026.6.18
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/defaults/config/thread-templates.json +2 -2
- package/defaults/hooks/task-status-check.mjs +9 -7
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +103 -16
- package/defaults/plugins/cortex-system/skills/orient/SKILL.md +6 -6
- package/defaults/plugins/cortex-system/skills/thread/SKILL.md +29 -35
- package/defaults/prompts/directives/manager.md +21 -11
- package/dist/agent-adapter/claude/spawn-args.d.ts +5 -0
- package/dist/agent-adapter/claude/spawn-args.js +6 -0
- package/dist/agent-adapter/types.d.ts +4 -0
- package/dist/core/gateway-generator.js +24 -3
- package/dist/core/i18n.d.ts +19 -0
- package/dist/core/i18n.js +46 -0
- package/dist/core/locales/en.d.ts +438 -0
- package/dist/core/locales/en.js +24 -0
- package/dist/core/locales/slices/commands.d.ts +214 -0
- package/dist/core/locales/slices/commands.js +462 -0
- package/dist/core/locales/slices/init.d.ts +121 -0
- package/dist/core/locales/slices/init.js +380 -0
- package/dist/core/locales/slices/interactions.d.ts +47 -0
- package/dist/core/locales/slices/interactions.js +102 -0
- package/dist/core/locales/slices/lang.d.ts +8 -0
- package/dist/core/locales/slices/lang.js +18 -0
- package/dist/core/locales/slices/scheduling.d.ts +36 -0
- package/dist/core/locales/slices/scheduling.js +74 -0
- package/dist/core/locales/slices/startup.d.ts +6 -0
- package/dist/core/locales/slices/startup.js +14 -0
- package/dist/core/locales/slices/status.d.ts +20 -0
- package/dist/core/locales/slices/status.js +48 -0
- package/dist/core/locales/zh.d.ts +5 -0
- package/dist/core/locales/zh.js +23 -0
- package/dist/core/singleton-lock.d.ts +23 -0
- package/dist/core/singleton-lock.js +53 -0
- package/dist/core/status-format.js +2 -1
- package/dist/core/task-parser.d.ts +6 -0
- package/dist/core/task-parser.js +10 -0
- package/dist/core/types/thread-types.d.ts +29 -0
- package/dist/core/utils.d.ts +9 -1
- package/dist/core/utils.js +9 -1
- package/dist/domain/agents/config.d.ts +2 -1
- package/dist/domain/agents/config.js +25 -6
- package/dist/domain/agents/facade.d.ts +4 -0
- package/dist/domain/agents/facade.js +3 -1
- package/dist/domain/mcp/core-server.js +15 -9
- package/dist/domain/mcp/tools/task-monitor.d.ts +2 -0
- package/dist/domain/mcp/tools/task-monitor.js +99 -0
- package/dist/domain/mcp/tools/thread-ops.js +50 -85
- package/dist/domain/scheduling/jobs/task-dispatch.js +18 -16
- package/dist/domain/scheduling/schedule-command.js +38 -37
- package/dist/domain/system/github-release.d.ts +18 -0
- package/dist/domain/system/github-release.js +106 -0
- package/dist/domain/system/preferences.d.ts +12 -0
- package/dist/domain/system/preferences.js +36 -0
- package/dist/domain/tasks/dispatch-utils.d.ts +5 -0
- package/dist/domain/tasks/dispatch-utils.js +9 -1
- package/dist/domain/tasks/dispatcher.d.ts +11 -2
- package/dist/domain/tasks/dispatcher.js +41 -11
- package/dist/domain/tasks/system/task-cli.d.ts +1 -0
- package/dist/domain/tasks/system/task-cli.js +82 -6
- package/dist/domain/tasks/system/task-mutations.d.ts +6 -1
- package/dist/domain/tasks/system/task-mutations.js +10 -1
- package/dist/domain/threads/hook-runner.js +1 -0
- package/dist/domain/threads/prompt-builder.d.ts +6 -0
- package/dist/domain/threads/prompt-builder.js +34 -11
- package/dist/domain/threads/runner.d.ts +5 -0
- package/dist/domain/threads/runner.js +44 -11
- package/dist/domain/threads/state-machine.d.ts +9 -12
- package/dist/domain/threads/state-machine.js +27 -50
- package/dist/entry/app.js +36 -3
- package/dist/entry/daemon.js +12 -30
- package/dist/entry/init.d.ts +4 -3
- package/dist/entry/init.js +151 -208
- package/dist/entry/startup-notify.js +6 -3
- package/dist/hooks/task-status-check.mjs +9 -7
- package/dist/orchestration/interactions/interaction-handlers.js +12 -11
- package/dist/orchestration/interactions/update-prompt-slack.js +11 -10
- package/dist/orchestration/interactions/update-prompt.js +66 -11
- package/dist/orchestration/lifecycle.js +13 -12
- package/dist/orchestration/routing/commands/cancel.js +10 -9
- package/dist/orchestration/routing/commands/channel.js +27 -26
- package/dist/orchestration/routing/commands/cost.js +10 -2
- package/dist/orchestration/routing/commands/device.js +11 -9
- package/dist/orchestration/routing/commands/dispatch.js +10 -10
- package/dist/orchestration/routing/commands/index.js +6 -2
- package/dist/orchestration/routing/commands/lang.d.ts +3 -0
- package/dist/orchestration/routing/commands/lang.js +31 -0
- package/dist/orchestration/routing/commands/mode.js +28 -27
- package/dist/orchestration/routing/commands/nvtop.js +13 -12
- package/dist/orchestration/routing/commands/orient.js +2 -1
- package/dist/orchestration/routing/commands/schedule.js +23 -22
- package/dist/orchestration/routing/commands/sendfile.js +8 -7
- package/dist/orchestration/routing/commands/session.js +11 -10
- package/dist/orchestration/routing/commands/status.js +78 -71
- package/dist/orchestration/routing/commands/tail.js +6 -5
- package/dist/orchestration/routing/commands/task.js +23 -22
- package/dist/orchestration/routing/commands/thread-handlers.js +40 -39
- package/dist/orchestration/routing/webhook.js +38 -1
- package/dist/orchestration/status-helpers.js +6 -5
- package/dist/orchestration/thread-callback.d.ts +11 -1
- package/dist/orchestration/thread-callback.js +66 -30
- package/dist/platform/adapters/feishu.d.ts +11 -0
- package/dist/platform/adapters/feishu.js +74 -3
- package/dist/platform/interactive-builder.js +19 -18
- package/dist/store/version-migrations.d.ts +7 -0
- package/dist/store/version-migrations.js +88 -0
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { queryGpuSnapshot, renderGpuSnapshot } from '../../../domain/monitor/gpu
|
|
|
2
2
|
import { getMachineRegistry, getLocalMachine } from '../../../domain/tasks/dispatch-utils.js';
|
|
3
3
|
import { sendCommand, isDeviceOnline } from '../../../domain/remote/client-manager.js';
|
|
4
4
|
import { Icons } from '../../../core/icons.js';
|
|
5
|
+
import { t } from '../../../core/i18n.js';
|
|
5
6
|
const NVTOP_REFRESH_MS = 1000;
|
|
6
7
|
const NVTOP_HISTORY_LIMIT = 12;
|
|
7
8
|
const activeNvtopMonitors = new Map();
|
|
@@ -30,24 +31,24 @@ export async function handleNvidiaSmiCmd(channel, adapter, trimmedMessage) {
|
|
|
30
31
|
const reg = getMachineRegistry()[machine];
|
|
31
32
|
if (!reg) {
|
|
32
33
|
const valid = Object.keys(getMachineRegistry()).filter(m => getMachineRegistry()[m].gpuCount > 0).map(m => `\`${m}\``).join(', ');
|
|
33
|
-
await adapter.postMessage(dest, { text: `${Icons.error}
|
|
34
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.unknownMachineGpu', { machine, valid })}` });
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
37
|
if (reg.gpuCount === 0) {
|
|
37
|
-
await adapter.postMessage(dest, { text: `${Icons.error}
|
|
38
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.noGpu', { machine })}` });
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
40
41
|
if (!isDeviceOnline(machine)) {
|
|
41
|
-
await adapter.postMessage(dest, { text: `${Icons.error}
|
|
42
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.deviceOffline', { machine })}` });
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
45
|
try {
|
|
45
46
|
const result = await sendCommand(machine, { action: 'bash', params: { command: 'nvidia-smi' }, timeout: 15000 });
|
|
46
|
-
const output = result.stdout || result.stderr || '
|
|
47
|
-
await adapter.postMessage(dest, { text:
|
|
47
|
+
const output = result.stdout || result.stderr || t('cmd.nvtop.noOutput');
|
|
48
|
+
await adapter.postMessage(dest, { text: t('cmd.nvtop.smiHeader', { machine, output }) });
|
|
48
49
|
}
|
|
49
50
|
catch (err) {
|
|
50
|
-
await adapter.postMessage(dest, { text: `${Icons.error}
|
|
51
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.smiFailed', { machine, error: err.message })}` });
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
export async function handleNvtopCmd(channel, adapter, trimmedMessage) {
|
|
@@ -56,27 +57,27 @@ export async function handleNvtopCmd(channel, adapter, trimmedMessage) {
|
|
|
56
57
|
if (args[0] === 'stop') {
|
|
57
58
|
const active = activeNvtopMonitors.get(channel);
|
|
58
59
|
if (!active) {
|
|
59
|
-
await adapter.postMessage(dest, { text: '
|
|
60
|
+
await adapter.postMessage(dest, { text: t('cmd.nvtop.noActive') });
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
clearInterval(active.interval);
|
|
63
64
|
activeNvtopMonitors.delete(channel);
|
|
64
|
-
await adapter.postMessage(dest, { text: `${Icons.stopped} nvtop
|
|
65
|
+
await adapter.postMessage(dest, { text: `${Icons.stopped} ${t('cmd.nvtop.stopped', { machine: active.machine })}` });
|
|
65
66
|
return;
|
|
66
67
|
}
|
|
67
68
|
if (activeNvtopMonitors.has(channel)) {
|
|
68
|
-
await adapter.postMessage(dest, { text: '
|
|
69
|
+
await adapter.postMessage(dest, { text: t('cmd.nvtop.alreadyRunning') });
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
72
|
const machine = args[0] || getLocalMachine();
|
|
72
73
|
const reg = getMachineRegistry()[machine];
|
|
73
74
|
if (!reg) {
|
|
74
75
|
const valid = Object.keys(getMachineRegistry()).filter(m => getMachineRegistry()[m].gpuCount > 0).map(m => `\`${m}\``).join(', ');
|
|
75
|
-
await adapter.postMessage(dest, { text: `${Icons.error}
|
|
76
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.unknownMachineGpu', { machine, valid })}` });
|
|
76
77
|
return;
|
|
77
78
|
}
|
|
78
79
|
if (reg.gpuCount === 0) {
|
|
79
|
-
await adapter.postMessage(dest, { text: `${Icons.error} nvtop
|
|
80
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.notSupported', { machine })}` });
|
|
80
81
|
return;
|
|
81
82
|
}
|
|
82
83
|
try {
|
|
@@ -101,6 +102,6 @@ export async function handleNvtopCmd(channel, adapter, trimmedMessage) {
|
|
|
101
102
|
});
|
|
102
103
|
}
|
|
103
104
|
catch (err) {
|
|
104
|
-
await adapter.postMessage(dest, { text: `${Icons.error} nvtop
|
|
105
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.failed', { machine, error: err.message })}` });
|
|
105
106
|
}
|
|
106
107
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { t } from '../../../core/i18n.js';
|
|
1
2
|
export async function handleOrientCmd(channel, adapter) {
|
|
2
3
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
3
|
-
await adapter.postMessage(dest, { text: '
|
|
4
|
+
await adapter.postMessage(dest, { text: t('cmd.orient.notImplemented') });
|
|
4
5
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { handleScheduleCommand } from '../../../domain/scheduling/schedule-command.js';
|
|
2
|
+
import { t } from '../../../core/i18n.js';
|
|
2
3
|
const MAX_SCHEDULE_BUTTONS = 10;
|
|
3
4
|
const FMT_OPTS = { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', hour12: false };
|
|
4
5
|
const fmtTime = (ts) => new Date(ts).toLocaleString('en-US', FMT_OPTS);
|
|
5
6
|
function formatTimeUntilCompact(ms) {
|
|
6
7
|
if (ms <= 0)
|
|
7
|
-
return 'now';
|
|
8
|
+
return t('cmd.schedule.now');
|
|
8
9
|
const seconds = Math.floor(ms / 1000);
|
|
9
10
|
if (seconds < 60)
|
|
10
11
|
return `${seconds}s`;
|
|
@@ -16,35 +17,35 @@ function formatTimeUntilCompact(ms) {
|
|
|
16
17
|
return `${hours}h`;
|
|
17
18
|
return `${Math.floor(hours / 24)}d`;
|
|
18
19
|
}
|
|
19
|
-
function formatTaskLine(
|
|
20
|
-
const id = `\`${
|
|
21
|
-
const profile =
|
|
22
|
-
const paused =
|
|
23
|
-
const nextMs = (
|
|
24
|
-
const next =
|
|
25
|
-
const msg =
|
|
26
|
-
return `${id} ${
|
|
20
|
+
function formatTaskLine(task, now) {
|
|
21
|
+
const id = `\`${task.id}\``;
|
|
22
|
+
const profile = task.profile ? ` · ${task.profile}` : '';
|
|
23
|
+
const paused = task.isPaused ? ` · *${t('cmd.schedule.paused')}*` : '';
|
|
24
|
+
const nextMs = (task.nextRun || task.runAt || 0) - now;
|
|
25
|
+
const next = task.isPaused ? '' : ` · ${t('cmd.schedule.nextLabel')}: ${formatTimeUntilCompact(nextMs)}`;
|
|
26
|
+
const msg = task.message.length > 40 ? task.message.slice(0, 37) + '...' : task.message;
|
|
27
|
+
return `${id} ${task.type}${profile}${paused}${next} · "${msg}"`;
|
|
27
28
|
}
|
|
28
29
|
function buildScheduleTaskButtons(tasks) {
|
|
29
30
|
const buttons = [];
|
|
30
31
|
for (let i = 0; i < Math.min(tasks.length, MAX_SCHEDULE_BUTTONS); i++) {
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
32
|
+
const task = tasks[i];
|
|
33
|
+
if (task.type === 'once') {
|
|
33
34
|
buttons.push({
|
|
34
|
-
type: 'button', text:
|
|
35
|
-
actionId: `cmd:schedule:remove-${i}`, value:
|
|
35
|
+
type: 'button', text: t('cmd.schedule.removeButton', { id: task.id }),
|
|
36
|
+
actionId: `cmd:schedule:remove-${i}`, value: task.id, style: 'danger',
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
|
-
else if (
|
|
39
|
+
else if (task.isPaused) {
|
|
39
40
|
buttons.push({
|
|
40
|
-
type: 'button', text:
|
|
41
|
-
actionId: `cmd:schedule:resume-${i}`, value:
|
|
41
|
+
type: 'button', text: t('cmd.schedule.resumeButton', { id: task.id }),
|
|
42
|
+
actionId: `cmd:schedule:resume-${i}`, value: task.id,
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
46
|
buttons.push({
|
|
46
|
-
type: 'button', text:
|
|
47
|
-
actionId: `cmd:schedule:pause-${i}`, value:
|
|
47
|
+
type: 'button', text: t('cmd.schedule.pauseButton', { id: task.id }),
|
|
48
|
+
actionId: `cmd:schedule:pause-${i}`, value: task.id,
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -56,8 +57,8 @@ export function createScheduleHandler(scheduler, router) {
|
|
|
56
57
|
const tasks = await scheduler.list();
|
|
57
58
|
const now = Date.now();
|
|
58
59
|
const text = tasks.length === 0
|
|
59
|
-
? '
|
|
60
|
-
:
|
|
60
|
+
? t('cmd.schedule.none')
|
|
61
|
+
: `${t('cmd.schedule.header', { n: tasks.length })}\n${tasks.map(task => `• ${formatTaskLine(task, now)}`).join('\n')}`;
|
|
61
62
|
await adapter.updateMessage(messageRef, {
|
|
62
63
|
text,
|
|
63
64
|
richBlocks: [
|
|
@@ -117,11 +118,11 @@ export function createScheduleHandler(scheduler, router) {
|
|
|
117
118
|
if (router && scheduler && (!sub || sub === 'list')) {
|
|
118
119
|
const tasks = await scheduler.list();
|
|
119
120
|
if (tasks.length === 0) {
|
|
120
|
-
await adapter.postMessage(dest, { text: '
|
|
121
|
+
await adapter.postMessage(dest, { text: t('cmd.schedule.none') });
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
124
|
const now = Date.now();
|
|
124
|
-
const text =
|
|
125
|
+
const text = `${t('cmd.schedule.header', { n: tasks.length })}\n${tasks.map(task => `• ${formatTaskLine(task, now)}`).join('\n')}`;
|
|
125
126
|
return {
|
|
126
127
|
text,
|
|
127
128
|
richBlocks: [{ type: 'section', text }],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getMachineRegistry } from '../../../domain/tasks/dispatch-utils.js';
|
|
2
2
|
import { Icons } from '../../../core/icons.js';
|
|
3
|
+
import { t } from '../../../core/i18n.js';
|
|
3
4
|
import { statSync, existsSync, mkdirSync, unlinkSync } from 'fs';
|
|
4
5
|
import { execFile } from 'child_process';
|
|
5
6
|
import * as os from 'os';
|
|
@@ -18,16 +19,16 @@ async function sendLocalFile(channel, adapter, reg, filePath, machine) {
|
|
|
18
19
|
resolved = path.resolve(reg.cortexPath, filePath);
|
|
19
20
|
}
|
|
20
21
|
if (!existsSync(resolved)) {
|
|
21
|
-
await adapter.postMessage(dest, { text: `${Icons.error}
|
|
22
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.sendfile.fileNotFound', { path: resolved })}` });
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
const stat = statSync(resolved);
|
|
25
26
|
if (!stat.isFile()) {
|
|
26
|
-
await adapter.postMessage(dest, { text: `${Icons.error}
|
|
27
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.sendfile.notAFile', { path: resolved })}` });
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
29
30
|
await adapter.uploadFile(dest, resolved, { filename: path.basename(resolved) });
|
|
30
|
-
await adapter.postMessage(dest, { text: `${Icons.ok}
|
|
31
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.sendfile.sent', { name: path.basename(resolved), size: (stat.size / 1024).toFixed(1), machine })}` });
|
|
31
32
|
}
|
|
32
33
|
async function sendRemoteFile(channel, adapter, reg, filePath, machine) {
|
|
33
34
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
@@ -61,13 +62,13 @@ async function sendRemoteFile(channel, adapter, reg, filePath, machine) {
|
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
64
|
catch (err) {
|
|
64
|
-
await adapter.postMessage(dest, { text: `${Icons.error}
|
|
65
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.sendfile.fetchFailed', { machine, error: err.message })}` });
|
|
65
66
|
return;
|
|
66
67
|
}
|
|
67
68
|
try {
|
|
68
69
|
const tmpStat = statSync(localTmp);
|
|
69
70
|
await adapter.uploadFile(dest, localTmp, { filename: fileName });
|
|
70
|
-
await adapter.postMessage(dest, { text: `${Icons.ok}
|
|
71
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.sendfile.sent', { name: fileName, size: (tmpStat.size / 1024).toFixed(1), machine })}` });
|
|
71
72
|
}
|
|
72
73
|
finally {
|
|
73
74
|
try {
|
|
@@ -80,14 +81,14 @@ export async function handleSendFileCmd(channel, adapter, trimmedMessage) {
|
|
|
80
81
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
81
82
|
const args = trimmedMessage.split(/\s+/).slice(1);
|
|
82
83
|
if (args.length < 2) {
|
|
83
|
-
await adapter.postMessage(dest, { text: '
|
|
84
|
+
await adapter.postMessage(dest, { text: t('cmd.sendfile.usage') });
|
|
84
85
|
return;
|
|
85
86
|
}
|
|
86
87
|
const machine = args[0];
|
|
87
88
|
const filePath = args.slice(1).join(' ');
|
|
88
89
|
const reg = getMachineRegistry()[machine];
|
|
89
90
|
if (!reg) {
|
|
90
|
-
await adapter.postMessage(dest, { text: `${Icons.error}
|
|
91
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.sendfile.unknownMachine', { machine, known: Object.keys(getMachineRegistry()).join(', ') })}` });
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
93
94
|
if (!reg.ssh)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '../../../core/log.js';
|
|
2
2
|
import { Icons } from '../../../core/icons.js';
|
|
3
|
+
import { t } from '../../../core/i18n.js';
|
|
3
4
|
import { closeSession, getActiveBackend, getActiveProfile } from '../../../domain/agents/index.js';
|
|
4
5
|
import { fireAndForgetPreCloseHook } from '../../../domain/sessions/session-hooks.js';
|
|
5
6
|
import { sessionStore } from '../../../store/session-registry-repo.js';
|
|
@@ -50,7 +51,7 @@ export async function handleNewCmd(channel, adapter, opts = {}, threadAnchorId)
|
|
|
50
51
|
if (cleared > 0)
|
|
51
52
|
log.info('Cleared pending plan for channel:', channel);
|
|
52
53
|
log.info('New conversation started in channel:', channel);
|
|
53
|
-
await adapter.postMessage(dest, { text:
|
|
54
|
+
await adapter.postMessage(dest, { text: t('cmd.session.newConversation', { profile: profileName }) });
|
|
54
55
|
}
|
|
55
56
|
const MAX_RESUME_BUTTONS = 10;
|
|
56
57
|
export function createResumeHandler(router) {
|
|
@@ -64,16 +65,16 @@ export function createResumeHandler(router) {
|
|
|
64
65
|
if (!record) {
|
|
65
66
|
if (ctx.messageRef) {
|
|
66
67
|
await adapter.updateMessage(ctx.messageRef, {
|
|
67
|
-
text: `${Icons.error}
|
|
68
|
+
text: `${Icons.error} ${t('cmd.session.notFound', { name })}`,
|
|
68
69
|
}).catch(() => { });
|
|
69
70
|
}
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
72
73
|
await attachExistingSession(ctx.channelId, { sessionId: record.sessionId, sessionName: name, backend: record.backend, profileName: record.profileName });
|
|
73
|
-
const profileNote = record.profileName ?
|
|
74
|
+
const profileNote = record.profileName ? t('cmd.session.profileNote', { profile: record.profileName }) : '';
|
|
74
75
|
if (ctx.messageRef) {
|
|
75
76
|
await adapter.updateMessage(ctx.messageRef, {
|
|
76
|
-
text: `${Icons.refresh}
|
|
77
|
+
text: `${Icons.refresh} ${t('cmd.session.switched', { name, profileNote })}`,
|
|
77
78
|
}).catch(() => { });
|
|
78
79
|
}
|
|
79
80
|
};
|
|
@@ -91,25 +92,25 @@ export function createResumeHandler(router) {
|
|
|
91
92
|
const name = args[0];
|
|
92
93
|
const record = await sessionStore.lookupSession(name);
|
|
93
94
|
if (!record) {
|
|
94
|
-
await adapter.postMessage(dest, { text: `${Icons.error}
|
|
95
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.session.notFoundList', { name })}` });
|
|
95
96
|
return;
|
|
96
97
|
}
|
|
97
98
|
await attachExistingSession(channel, { sessionId: record.sessionId, sessionName: name, backend: record.backend, profileName: record.profileName });
|
|
98
|
-
const profileNote = record.profileName ?
|
|
99
|
-
await adapter.postMessage(dest, { text: `${Icons.refresh}
|
|
99
|
+
const profileNote = record.profileName ? t('cmd.session.profileNote', { profile: record.profileName }) : '';
|
|
100
|
+
await adapter.postMessage(dest, { text: `${Icons.refresh} ${t('cmd.session.switched', { name, profileNote })}` });
|
|
100
101
|
return;
|
|
101
102
|
}
|
|
102
103
|
const sessions = await sessionStore.listRecentSessions(10);
|
|
103
104
|
if (sessions.length === 0) {
|
|
104
|
-
await adapter.postMessage(dest, { text: '
|
|
105
|
+
await adapter.postMessage(dest, { text: t('cmd.session.noSessions') });
|
|
105
106
|
return;
|
|
106
107
|
}
|
|
107
108
|
const activeId = await sessionStore.getActiveSessionName(channel, getActiveBackend());
|
|
108
109
|
const now = Date.now();
|
|
109
|
-
const lines = ['
|
|
110
|
+
const lines = [t('cmd.session.recentHeader')];
|
|
110
111
|
for (const s of sessions) {
|
|
111
112
|
const isActive = s.name === activeId;
|
|
112
|
-
const activeTag = isActive ? '
|
|
113
|
+
const activeTag = isActive ? t('cmd.session.activeTag') : '';
|
|
113
114
|
const ago = formatTimeAgo(now - new Date(s.lastUsedAt).getTime());
|
|
114
115
|
const label = s.label ? ` — ${s.label}` : '';
|
|
115
116
|
const kind = s.kind === 'scheduled' ? ` ${Icons.scheduled}` : '';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t } from '../../../core/i18n.js';
|
|
1
2
|
export function createStatusHandler(getExecutionStatusReport, router) {
|
|
2
3
|
// Register refresh action handler
|
|
3
4
|
if (router) {
|
|
@@ -17,7 +18,7 @@ export function createStatusHandler(getExecutionStatusReport, router) {
|
|
|
17
18
|
type: 'actions',
|
|
18
19
|
elements: [{
|
|
19
20
|
type: 'button',
|
|
20
|
-
text: '
|
|
21
|
+
text: t('cmd.status.refreshButton'),
|
|
21
22
|
actionId: 'cmd:status:refresh',
|
|
22
23
|
value: 'refresh',
|
|
23
24
|
}],
|
|
@@ -29,7 +30,7 @@ export function createStatusHandler(getExecutionStatusReport, router) {
|
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
return async function handleStatusCmd(channel, adapter) {
|
|
32
|
-
const text = getExecutionStatusReport ? getExecutionStatusReport() : '
|
|
33
|
+
const text = getExecutionStatusReport ? getExecutionStatusReport() : t('cmd.status.unavailable');
|
|
33
34
|
if (!router) {
|
|
34
35
|
await adapter.postMessage({ type: 'interactive-reply', conduit: channel, sessionId: '' }, { text });
|
|
35
36
|
return;
|
|
@@ -39,7 +40,7 @@ export function createStatusHandler(getExecutionStatusReport, router) {
|
|
|
39
40
|
richBlocks: [{ type: 'section', text }],
|
|
40
41
|
actions: [{
|
|
41
42
|
type: 'button',
|
|
42
|
-
text: '
|
|
43
|
+
text: t('cmd.status.refreshButton'),
|
|
43
44
|
actionId: 'cmd:status:refresh',
|
|
44
45
|
value: 'refresh',
|
|
45
46
|
}],
|
|
@@ -47,84 +48,90 @@ export function createStatusHandler(getExecutionStatusReport, router) {
|
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
// --- Help command categories ---
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
51
|
+
// Built per call so labels and command descriptions resolve in the ACTIVE locale (the !lang
|
|
52
|
+
// command can switch it at runtime). A module-level const would freeze English at import time.
|
|
53
|
+
function getHelpCategories() {
|
|
54
|
+
return {
|
|
55
|
+
session: {
|
|
56
|
+
label: t('cmd.help.catSession'),
|
|
57
|
+
commands: [
|
|
58
|
+
t('cmd.help.session.new'),
|
|
59
|
+
t('cmd.help.session.cancel'),
|
|
60
|
+
t('cmd.help.session.resume'),
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
config: {
|
|
64
|
+
label: t('cmd.help.catConfig'),
|
|
65
|
+
commands: [
|
|
66
|
+
t('cmd.help.config.mode'),
|
|
67
|
+
t('cmd.help.config.backend'),
|
|
68
|
+
t('cmd.help.config.model'),
|
|
69
|
+
t('cmd.help.config.profile'),
|
|
70
|
+
t('cmd.help.config.skills'),
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
monitoring: {
|
|
74
|
+
label: t('cmd.help.catMonitoring'),
|
|
75
|
+
commands: [
|
|
76
|
+
t('cmd.help.monitoring.cost'),
|
|
77
|
+
t('cmd.help.monitoring.status'),
|
|
78
|
+
t('cmd.help.monitoring.budget'),
|
|
79
|
+
t('cmd.help.monitoring.schedule'),
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
tasks: {
|
|
83
|
+
label: t('cmd.help.catTasks'),
|
|
84
|
+
commands: [
|
|
85
|
+
t('cmd.help.tasks.tasks'),
|
|
86
|
+
t('cmd.help.tasks.projects'),
|
|
87
|
+
t('cmd.help.tasks.register'),
|
|
88
|
+
t('cmd.help.tasks.unregister'),
|
|
89
|
+
t('cmd.help.tasks.projectDir'),
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
devices: {
|
|
93
|
+
label: t('cmd.help.catDevices'),
|
|
94
|
+
commands: [
|
|
95
|
+
t('cmd.help.devices.devices'),
|
|
96
|
+
t('cmd.help.devices.nvidiaSmi'),
|
|
97
|
+
t('cmd.help.devices.nvtop'),
|
|
98
|
+
t('cmd.help.devices.tail'),
|
|
99
|
+
t('cmd.help.devices.sendfile'),
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
threads: {
|
|
103
|
+
label: t('cmd.help.catThreads'),
|
|
104
|
+
commands: [
|
|
105
|
+
t('cmd.help.threads.thread'),
|
|
106
|
+
t('cmd.help.threads.agent'),
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
106
111
|
function buildHelpText(category) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
const categories = getHelpCategories();
|
|
113
|
+
if (category && category !== 'all' && categories[category]) {
|
|
114
|
+
const cat = categories[category];
|
|
115
|
+
return `${t('cmd.help.headingCategory', { label: cat.label })}\n${cat.commands.join('\n')}`;
|
|
110
116
|
}
|
|
111
|
-
const allCommands = Object.values(
|
|
112
|
-
return ['
|
|
117
|
+
const allCommands = Object.values(categories).flatMap(c => c.commands);
|
|
118
|
+
return [t('cmd.help.heading'), ...allCommands, t('cmd.help.selfLine')].join('\n');
|
|
113
119
|
}
|
|
114
120
|
// Slack section blocks have a 3000-char limit; split into one block per category.
|
|
115
121
|
function buildHelpRichBlocks(category) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
const categories = getHelpCategories();
|
|
123
|
+
if (category && category !== 'all' && categories[category]) {
|
|
124
|
+
const cat = categories[category];
|
|
125
|
+
return [{ type: 'section', text: `${t('cmd.help.headingCategory', { label: cat.label })}\n${cat.commands.join('\n')}` }];
|
|
119
126
|
}
|
|
120
|
-
return Object.values(
|
|
127
|
+
return Object.values(categories).map(cat => ({
|
|
121
128
|
type: 'section',
|
|
122
129
|
text: `*${cat.label}*\n${cat.commands.join('\n')}`,
|
|
123
130
|
}));
|
|
124
131
|
}
|
|
125
|
-
const HELP_CATEGORY_KEYS = [
|
|
132
|
+
const HELP_CATEGORY_KEYS = ['session', 'config', 'monitoring', 'tasks', 'devices', 'threads', 'all'];
|
|
126
133
|
function buildHelpButtons() {
|
|
127
|
-
const buttons = Object.entries(
|
|
134
|
+
const buttons = Object.entries(getHelpCategories()).map(([key, cat]) => ({
|
|
128
135
|
type: 'button',
|
|
129
136
|
text: cat.label,
|
|
130
137
|
actionId: `cmd:help:cat-${key}`,
|
|
@@ -132,7 +139,7 @@ function buildHelpButtons() {
|
|
|
132
139
|
}));
|
|
133
140
|
buttons.push({
|
|
134
141
|
type: 'button',
|
|
135
|
-
text: '
|
|
142
|
+
text: t('cmd.help.showAll'),
|
|
136
143
|
actionId: 'cmd:help:cat-all',
|
|
137
144
|
value: 'all',
|
|
138
145
|
});
|
|
@@ -2,18 +2,19 @@ import { statSync, openSync, readSync, closeSync } from 'fs';
|
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import { moduleDir } from '../../../core/utils.js';
|
|
4
4
|
import { Icons } from '../../../core/icons.js';
|
|
5
|
+
import { t } from '../../../core/i18n.js';
|
|
5
6
|
const DAEMON_LOG_PATH = path.join(moduleDir(import.meta.url), '..', '..', '..', '..', 'logs', 'daemon.log');
|
|
6
7
|
const activeTails = new Map();
|
|
7
8
|
async function stopTail(channel, adapter) {
|
|
8
9
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
9
10
|
const active = activeTails.get(channel);
|
|
10
11
|
if (!active) {
|
|
11
|
-
await adapter.postMessage(dest, { text: '
|
|
12
|
+
await adapter.postMessage(dest, { text: t('cmd.tail.noActive') });
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
14
15
|
clearInterval(active.interval);
|
|
15
16
|
activeTails.delete(channel);
|
|
16
|
-
await adapter.postMessage(dest, { text: `${Icons.stopped}
|
|
17
|
+
await adapter.postMessage(dest, { text: `${Icons.stopped} ${t('cmd.tail.stopped')}` });
|
|
17
18
|
}
|
|
18
19
|
async function sendInitialTailPreview(channel, adapter) {
|
|
19
20
|
const previewDest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
@@ -25,11 +26,11 @@ async function sendInitialTailPreview(channel, adapter) {
|
|
|
25
26
|
readSync(fd, buf, 0, previewBytes, stat.size - previewBytes);
|
|
26
27
|
closeSync(fd);
|
|
27
28
|
const lines = buf.toString('utf-8').split('\n').filter(Boolean).slice(-30);
|
|
28
|
-
await adapter.postMessage(previewDest, { text: `${Icons.scroll}
|
|
29
|
+
await adapter.postMessage(previewDest, { text: `${Icons.scroll} ${t('cmd.tail.preview', { n: lines.length, content: lines.join('\n') })}` });
|
|
29
30
|
return stat.size;
|
|
30
31
|
}
|
|
31
32
|
catch (err) {
|
|
32
|
-
await adapter.postMessage(previewDest, { text: `${Icons.error}
|
|
33
|
+
await adapter.postMessage(previewDest, { text: `${Icons.error} ${t('cmd.tail.cannotRead', { error: err.message })}` });
|
|
33
34
|
return null;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -68,7 +69,7 @@ export async function handleTailCmd(channel, adapter, trimmedMessage) {
|
|
|
68
69
|
return stopTail(channel, adapter);
|
|
69
70
|
const cmdDest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
70
71
|
if (activeTails.has(channel)) {
|
|
71
|
-
await adapter.postMessage(cmdDest, { text: '
|
|
72
|
+
await adapter.postMessage(cmdDest, { text: t('cmd.tail.alreadyTailing') });
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
74
75
|
const offset = await sendInitialTailPreview(channel, adapter);
|