@cortex-agent/server 2026.6.11 → 2026.6.18-2
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 +27 -0
- package/dist/platform/adapters/feishu.js +136 -4
- 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
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
// pos: send DM notification to admin channel during startup
|
|
4
4
|
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
5
|
import { CORTEX_VERSION } from '../core/version.js';
|
|
6
|
+
import { t } from '../core/i18n.js';
|
|
6
7
|
function buildStartupMessage({ machine, restartReason }) {
|
|
7
8
|
const machineLabel = machine || 'unknown-machine';
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const base = t(restartReason ? 'startup.restarted' : 'startup.started', {
|
|
10
|
+
version: CORTEX_VERSION,
|
|
11
|
+
machine: machineLabel,
|
|
12
|
+
});
|
|
13
|
+
return restartReason ? `${base}${t('startup.reason', { reason: restartReason })}` : base;
|
|
11
14
|
}
|
|
12
15
|
async function sendStartupDmIfConfigured(adapter, { machine, restartReason } = {}) {
|
|
13
16
|
try {
|
|
@@ -119,13 +119,15 @@ async function main() {
|
|
|
119
119
|
|
|
120
120
|
if (!project || !taskId) { noop(); return; }
|
|
121
121
|
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
|
|
122
|
+
// Out-of-band control intent (DR-0015): the agent signalled abort/split/wait via a tool, not
|
|
123
|
+
// by writing a marker into the artifact. Read the typed signal — never scan the artifact (prose
|
|
124
|
+
// mentioning "[ABORT]"/"[SPLIT]" must not trip this).
|
|
125
|
+
// - split: the task is INTENTIONALLY not done — the dispatcher decomposes it keep-parent and
|
|
126
|
+
// unclaims right after this hook returns. Don't burn an agent turn nagging. (The runner
|
|
127
|
+
// leaves pendingControl set for the dispatch path, so it is still present here.)
|
|
128
|
+
// - abort: the runner already blocked the task BEFORE this hook (DR-0015 problem 2) and cleared
|
|
129
|
+
// the control, so the blocked-by guard below covers it; this is belt-and-suspenders.
|
|
130
|
+
if (ctx.pendingControlAction === 'split' || ctx.pendingControlAction === 'abort') { noop(); return; }
|
|
129
131
|
|
|
130
132
|
const tasksPath = path.join(PROJECTS_DIR, project, 'TASKS.yaml');
|
|
131
133
|
if (!existsSync(tasksPath)) { noop(); return; }
|
|
@@ -18,6 +18,7 @@ import { conversationLedger } from '../../store/conversation-ledger-repo.js';
|
|
|
18
18
|
import { closeSession, getActiveBackend, getActiveProfile, setActiveProfile, resolveBackendForChannel } from '../../domain/agents/index.js';
|
|
19
19
|
import { fireAndForgetPreCloseHook } from '../../domain/sessions/session-hooks.js';
|
|
20
20
|
import { Icons } from '../../core/icons.js';
|
|
21
|
+
import { t } from '../../core/i18n.js';
|
|
21
22
|
import * as sessionBackup from '../../domain/sessions/session-backup.js';
|
|
22
23
|
import { cancelThread as cancelThreadById } from '../../domain/threads/index.js';
|
|
23
24
|
import { createLogger } from '../../core/log.js';
|
|
@@ -46,7 +47,7 @@ async function handleOpenModal(ctx) {
|
|
|
46
47
|
if (!group || askUserQuestion.isExpired(group)) {
|
|
47
48
|
if (group && askUserQuestion.isExpired(group))
|
|
48
49
|
askUserQuestion.deleteGroup(group.groupId);
|
|
49
|
-
const msg = group ? '
|
|
50
|
+
const msg = group ? t('interaction.askExpired') : t('interaction.askInactive');
|
|
50
51
|
if (ctx.channelId) {
|
|
51
52
|
const expiredDest = { type: 'interactive-reply', conduit: ctx.channelId, sessionId: '' };
|
|
52
53
|
await _adapter.postMessage(expiredDest, { text: msg }).catch(() => { });
|
|
@@ -123,7 +124,7 @@ function collectModalAnswers(group, values) {
|
|
|
123
124
|
answer = q.options[parseInt(idx)]?.label;
|
|
124
125
|
}
|
|
125
126
|
if (!answer || (Array.isArray(answer) && answer.length === 0)) {
|
|
126
|
-
errors[`q_${qIdx}`] = '
|
|
127
|
+
errors[`q_${qIdx}`] = t('interaction.selectOrType');
|
|
127
128
|
}
|
|
128
129
|
else {
|
|
129
130
|
collected.set(q.pendingId, { header: q.header, value: answer });
|
|
@@ -137,7 +138,7 @@ async function updateQuestionMessage(group) {
|
|
|
137
138
|
if (!group.responseMessageTs || !_adapter)
|
|
138
139
|
return;
|
|
139
140
|
await _adapter.updateMessage({ conduit: group.channel, messageId: group.responseMessageTs }, {
|
|
140
|
-
text:
|
|
141
|
+
text: t('interaction.questionsProgress', { answered: group.answers.size, total: group.questions.length }),
|
|
141
142
|
richBlocks: askUserQuestion.buildQuestionGroupBlocks(group),
|
|
142
143
|
}).catch(() => { });
|
|
143
144
|
}
|
|
@@ -190,8 +191,8 @@ function registerExitPlanModeHandlers(adapter) {
|
|
|
190
191
|
}
|
|
191
192
|
if (ctx.messageRef) {
|
|
192
193
|
await adapter.updateMessage(ctx.messageRef, {
|
|
193
|
-
text: `${Icons.ok}
|
|
194
|
-
richBlocks: [{ type: 'section', text: `${Icons.ok}
|
|
194
|
+
text: `${Icons.ok} ${t('interaction.planApproved')}`,
|
|
195
|
+
richBlocks: [{ type: 'section', text: `${Icons.ok} ${t('interaction.planApprovedRich')}` }],
|
|
195
196
|
}).catch(() => { });
|
|
196
197
|
}
|
|
197
198
|
});
|
|
@@ -207,12 +208,12 @@ function registerExitPlanModeHandlers(adapter) {
|
|
|
207
208
|
const pending = planApprovals.reject(requestId);
|
|
208
209
|
if (!pending)
|
|
209
210
|
return;
|
|
210
|
-
const feedback = ctx.values?.feedback?.text?.value || '
|
|
211
|
+
const feedback = ctx.values?.feedback?.text?.value || t('interaction.noSpecificFeedback');
|
|
211
212
|
// PI path: send extension_ui_response directly; Claude path: resolve pending HTTP request
|
|
212
213
|
if (!tryResolvePIPlan(pending, feedback)) {
|
|
213
214
|
resolveHookRequest(requestId, { approved: false, reason: feedback });
|
|
214
215
|
}
|
|
215
|
-
const feedbackText = `${Icons.edit}
|
|
216
|
+
const feedbackText = `${Icons.edit} ${t('interaction.planFeedbackSent', { feedback })}`;
|
|
216
217
|
const streamingCb = getStreamingCallback(pending.channel);
|
|
217
218
|
const feedbackDest = { type: 'interactive-reply', conduit: pending.channel, sessionId: '' };
|
|
218
219
|
if (streamingCb) {
|
|
@@ -260,7 +261,7 @@ async function handleStatusCancel(ctx) {
|
|
|
260
261
|
conduitQueues.delete(exec.channel ?? channel);
|
|
261
262
|
if (ctx.messageRef) {
|
|
262
263
|
await _adapter.updateMessage(ctx.messageRef, {
|
|
263
|
-
text: `${Icons.stopped}
|
|
264
|
+
text: `${Icons.stopped} ${t('interaction.cancelledPreserved')}`,
|
|
264
265
|
}).catch(() => { });
|
|
265
266
|
}
|
|
266
267
|
return;
|
|
@@ -303,10 +304,10 @@ async function handleStatusResume(ctx) {
|
|
|
303
304
|
await conversationLedger.switchSession(ctx.channelId, {
|
|
304
305
|
sessionId: record.sessionId, sessionName, backend: record.backend, profileName: record.profileName,
|
|
305
306
|
});
|
|
306
|
-
const profileNote = record.profileName ?
|
|
307
|
+
const profileNote = record.profileName ? t('interaction.sessionProfileNote', { profileName: record.profileName }) : '';
|
|
307
308
|
const resumeDest = { type: 'interactive-reply', conduit: ctx.channelId, sessionId: record.sessionId ?? '' };
|
|
308
309
|
await _adapter.postMessage(resumeDest, {
|
|
309
|
-
text: `${Icons.refresh}
|
|
310
|
+
text: `${Icons.refresh} ${t('interaction.sessionActive', { sessionName, profileNote })}`,
|
|
310
311
|
}).catch(() => { });
|
|
311
312
|
}
|
|
312
313
|
async function handleStatusNew(ctx) {
|
|
@@ -329,6 +330,6 @@ async function handleStatusNew(ctx) {
|
|
|
329
330
|
planApprovals.clearByChannel(channel);
|
|
330
331
|
const newDest = { type: 'interactive-reply', conduit: ctx.channelId, sessionId: '' };
|
|
331
332
|
await _adapter.postMessage(newDest, {
|
|
332
|
-
text:
|
|
333
|
+
text: t('interaction.newConversation', { profileName }),
|
|
333
334
|
}).catch(() => { });
|
|
334
335
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// pos: Slack-specific UpdatePrompt implementation — pre-registers three actionIds on router,
|
|
4
4
|
// posts interactive message to system-notice, resolves ask() promise on button click.
|
|
5
5
|
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
6
|
+
import { t } from '../../core/i18n.js';
|
|
6
7
|
const DEFAULT_TIMEOUT_MS = 86_400_000; // 24h
|
|
7
8
|
// --- Factory ---
|
|
8
9
|
export function createSlackUpdatePrompt(adapter, router, opts) {
|
|
@@ -20,11 +21,11 @@ export function createSlackUpdatePrompt(adapter, router, opts) {
|
|
|
20
21
|
const resolveText = (choice, version) => {
|
|
21
22
|
switch (choice) {
|
|
22
23
|
case 'apply':
|
|
23
|
-
return
|
|
24
|
+
return t('update.installing', { version });
|
|
24
25
|
case 'skip':
|
|
25
|
-
return
|
|
26
|
+
return t('update.skipped', { version });
|
|
26
27
|
case 'cancel':
|
|
27
|
-
return
|
|
28
|
+
return t('update.cancelled');
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
31
|
// --- Build click handlers ---
|
|
@@ -51,9 +52,9 @@ export function createSlackUpdatePrompt(adapter, router, opts) {
|
|
|
51
52
|
});
|
|
52
53
|
// --- Button templates (value filled in at ask time) ---
|
|
53
54
|
const buttonTemplates = [
|
|
54
|
-
{ type: 'button', text: '
|
|
55
|
-
{ type: 'button', text: '
|
|
56
|
-
{ type: 'button', text: '
|
|
55
|
+
{ type: 'button', text: t('update.button.update'), actionId: 'cmd:update:apply', value: '', style: 'primary' },
|
|
56
|
+
{ type: 'button', text: t('update.button.skip'), actionId: 'cmd:update:skip', value: '' },
|
|
57
|
+
{ type: 'button', text: t('update.button.cancel'), actionId: 'cmd:update:cancel', value: '', style: 'danger' },
|
|
57
58
|
];
|
|
58
59
|
// --- Return the UpdatePrompt implementation ---
|
|
59
60
|
return {
|
|
@@ -64,7 +65,7 @@ export function createSlackUpdatePrompt(adapter, router, opts) {
|
|
|
64
65
|
clearPending();
|
|
65
66
|
old.resolve(null);
|
|
66
67
|
if (old.messageRef) {
|
|
67
|
-
await adapter.updateMessage(old.messageRef, { text: '
|
|
68
|
+
await adapter.updateMessage(old.messageRef, { text: t('update.superseded') }).catch(() => { });
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
// Stamp version onto buttons
|
|
@@ -77,9 +78,9 @@ export function createSlackUpdatePrompt(adapter, router, opts) {
|
|
|
77
78
|
// button row. Pattern follows buildPlanApprovalContent
|
|
78
79
|
// (platform/interactive-builder.ts:117-127).
|
|
79
80
|
const messageRef = await adapter.postInteractive({ type: 'system-notice' }, {
|
|
80
|
-
text:
|
|
81
|
+
text: t('update.available', { version: spec.latestVersion }),
|
|
81
82
|
richBlocks: [
|
|
82
|
-
{ type: 'section', text:
|
|
83
|
+
{ type: 'section', text: t('update.availableSection', { version: spec.latestVersion }) },
|
|
83
84
|
],
|
|
84
85
|
actions: versionedButtons,
|
|
85
86
|
});
|
|
@@ -92,7 +93,7 @@ export function createSlackUpdatePrompt(adapter, router, opts) {
|
|
|
92
93
|
const ref = pending.messageRef;
|
|
93
94
|
clearPending();
|
|
94
95
|
resolve(null);
|
|
95
|
-
adapter.updateMessage(ref, { text: '
|
|
96
|
+
adapter.updateMessage(ref, { text: t('update.timedOut') }).catch(() => { });
|
|
96
97
|
}, timeoutMs).unref();
|
|
97
98
|
});
|
|
98
99
|
},
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
// pos: Platform-neutral UpdatePrompt implementation — pre-registers three actionIds on router,
|
|
4
4
|
// posts interactive message to system-notice, resolves ask() promise on button click.
|
|
5
5
|
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
6
|
+
import { fetchReleaseNote, buildGitHubReleaseUrl } from '../../domain/system/github-release.js';
|
|
7
|
+
import { createLogger } from '../../core/log.js';
|
|
8
|
+
import { t } from '../../core/i18n.js';
|
|
9
|
+
const log = createLogger('update-prompt');
|
|
6
10
|
const DEFAULT_TIMEOUT_MS = 86_400_000; // 24h
|
|
7
11
|
// --- Factory ---
|
|
8
12
|
export function createUpdatePrompt(adapter, router, opts) {
|
|
@@ -20,13 +24,33 @@ export function createUpdatePrompt(adapter, router, opts) {
|
|
|
20
24
|
const resolveText = (choice, version) => {
|
|
21
25
|
switch (choice) {
|
|
22
26
|
case 'apply':
|
|
23
|
-
return
|
|
27
|
+
return t('update.installing', { version });
|
|
24
28
|
case 'skip':
|
|
25
|
-
return
|
|
29
|
+
return t('update.skipped', { version });
|
|
26
30
|
case 'cancel':
|
|
27
|
-
return
|
|
31
|
+
return t('update.cancelled');
|
|
28
32
|
}
|
|
29
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Format release note info into a message.
|
|
36
|
+
* Truncates if too long (safe for Slack/Feishu 4000 char limit).
|
|
37
|
+
*/
|
|
38
|
+
const formatReleaseNoteMessage = (releaseInfo) => {
|
|
39
|
+
let body = releaseInfo.body || t('update.releaseNotesEmpty');
|
|
40
|
+
// Truncate to safe length (~3500 chars to leave room for header/footer)
|
|
41
|
+
if (body.length > 3500) {
|
|
42
|
+
body = body.substring(0, 3500).trimEnd() + t('update.releaseNotesTruncated');
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
text: t('update.releaseNotesTitle', { version: releaseInfo.version }),
|
|
46
|
+
richBlocks: [
|
|
47
|
+
{
|
|
48
|
+
type: 'section',
|
|
49
|
+
text: t('update.releaseNotesBody', { name: releaseInfo.name, body, url: releaseInfo.htmlUrl }),
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
};
|
|
30
54
|
// --- Build click handlers ---
|
|
31
55
|
const buildHandler = (choice) => {
|
|
32
56
|
return async (ctx) => {
|
|
@@ -41,19 +65,50 @@ export function createUpdatePrompt(adapter, router, opts) {
|
|
|
41
65
|
}
|
|
42
66
|
};
|
|
43
67
|
};
|
|
44
|
-
|
|
68
|
+
const handleReleaseNote = async (ctx) => {
|
|
69
|
+
if (!pending)
|
|
70
|
+
return;
|
|
71
|
+
const version = pending.latestVersion;
|
|
72
|
+
log.debug(`Fetching release notes for version ${version}`);
|
|
73
|
+
try {
|
|
74
|
+
const releaseInfo = await fetchReleaseNote(version);
|
|
75
|
+
if (releaseInfo) {
|
|
76
|
+
const message = formatReleaseNoteMessage(releaseInfo);
|
|
77
|
+
await adapter.postMessage({ type: 'system-notice' }, message).catch((e) => {
|
|
78
|
+
log.error(`Failed to post release note message: ${e.message}`);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// Fallback: send GitHub link
|
|
83
|
+
const url = buildGitHubReleaseUrl(version);
|
|
84
|
+
await adapter
|
|
85
|
+
.postMessage({ type: 'system-notice' }, {
|
|
86
|
+
text: t('update.releaseNotesFetchFailed', { version, url }),
|
|
87
|
+
})
|
|
88
|
+
.catch((e) => {
|
|
89
|
+
log.error(`Failed to post fallback release note: ${e.message}`);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
log.error(`Error in release note handler: ${error.message}`);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
// --- Pre-register four actionIds on router ---
|
|
45
98
|
router.registerCommand('update', {
|
|
46
99
|
actions: [
|
|
47
100
|
{ actionId: 'apply', handler: buildHandler('apply') },
|
|
48
101
|
{ actionId: 'skip', handler: buildHandler('skip') },
|
|
49
102
|
{ actionId: 'cancel', handler: buildHandler('cancel') },
|
|
103
|
+
{ actionId: 'release-note', handler: handleReleaseNote },
|
|
50
104
|
],
|
|
51
105
|
});
|
|
52
106
|
// --- Button templates (value filled in at ask time) ---
|
|
53
107
|
const buttonTemplates = [
|
|
54
|
-
{ type: 'button', text: '
|
|
55
|
-
{ type: 'button', text: '
|
|
56
|
-
{ type: 'button', text: '
|
|
108
|
+
{ type: 'button', text: t('update.button.update'), actionId: 'cmd:update:apply', value: '', style: 'primary' },
|
|
109
|
+
{ type: 'button', text: t('update.button.releaseNote'), actionId: 'cmd:update:release-note', value: '' },
|
|
110
|
+
{ type: 'button', text: t('update.button.skip'), actionId: 'cmd:update:skip', value: '' },
|
|
111
|
+
{ type: 'button', text: t('update.button.cancel'), actionId: 'cmd:update:cancel', value: '', style: 'danger' },
|
|
57
112
|
];
|
|
58
113
|
// --- Return the UpdatePrompt implementation ---
|
|
59
114
|
return {
|
|
@@ -64,7 +119,7 @@ export function createUpdatePrompt(adapter, router, opts) {
|
|
|
64
119
|
clearPending();
|
|
65
120
|
old.resolve(null);
|
|
66
121
|
if (old.messageRef) {
|
|
67
|
-
await adapter.updateMessage(old.messageRef, { text: '
|
|
122
|
+
await adapter.updateMessage(old.messageRef, { text: t('update.superseded') }).catch(() => { });
|
|
68
123
|
}
|
|
69
124
|
}
|
|
70
125
|
// Stamp version onto buttons
|
|
@@ -77,9 +132,9 @@ export function createUpdatePrompt(adapter, router, opts) {
|
|
|
77
132
|
// button row. Pattern follows buildPlanApprovalContent
|
|
78
133
|
// (platform/interactive-builder.ts:117-127).
|
|
79
134
|
const messageRef = await adapter.postInteractive({ type: 'system-notice' }, {
|
|
80
|
-
text:
|
|
135
|
+
text: t('update.available', { version: spec.latestVersion }),
|
|
81
136
|
richBlocks: [
|
|
82
|
-
{ type: 'section', text:
|
|
137
|
+
{ type: 'section', text: t('update.availableSection', { version: spec.latestVersion }) },
|
|
83
138
|
],
|
|
84
139
|
actions: versionedButtons,
|
|
85
140
|
});
|
|
@@ -92,7 +147,7 @@ export function createUpdatePrompt(adapter, router, opts) {
|
|
|
92
147
|
const ref = pending.messageRef;
|
|
93
148
|
clearPending();
|
|
94
149
|
resolve(null);
|
|
95
|
-
adapter.updateMessage(ref, { text: '
|
|
150
|
+
adapter.updateMessage(ref, { text: t('update.timedOut') }).catch(() => { });
|
|
96
151
|
}, timeoutMs).unref();
|
|
97
152
|
});
|
|
98
153
|
},
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
5
|
import { createLogger } from '../core/log.js';
|
|
6
6
|
import { Icons } from '../core/icons.js';
|
|
7
|
+
import { t } from '../core/i18n.js';
|
|
7
8
|
import { trackPendingTask } from './busy-tracker.js';
|
|
8
9
|
import { enqueue } from './conduit-queue.js';
|
|
9
10
|
import { supersededEdits } from './superseded-edits.js';
|
|
@@ -37,8 +38,8 @@ export async function handleAgentSuccess({ result, channel, adapter, statusMsg,
|
|
|
37
38
|
const stream = onAssistantMessage?.stream ?? null;
|
|
38
39
|
const askCount = await askUserQuestion.sendMessages(result, channel, adapter, statusMsg.messageId, threadAnchorId, stream);
|
|
39
40
|
const statusText = askCount > 0
|
|
40
|
-
? `${Icons.waiting} ${sessionTag}
|
|
41
|
-
: `${Icons.ok}
|
|
41
|
+
? `${Icons.waiting} ${sessionTag}${t('status.waitingForUserInput')} (${elapsedStr}${metrics})`
|
|
42
|
+
: `${Icons.ok} ${t('status.done')} | ${sessionTag}(${elapsedStr}${metrics})`;
|
|
42
43
|
await sealStatus(adapter, statusMsg, statusText, buildSealedStatusActionBlocks(statusText, { channel, sessionName, isDm: true }));
|
|
43
44
|
if (userMessageTs) {
|
|
44
45
|
await conversationLedger.completeTurn(channel, userMessageTs, { executionId });
|
|
@@ -110,7 +111,7 @@ export async function handleAgentError({ error, channel, adapter, statusMsg, sta
|
|
|
110
111
|
if (error?.cancelled && supersededEdits.check(channel)) {
|
|
111
112
|
supersededEdits.clear(channel);
|
|
112
113
|
finalizeLocalExecution({ executionId, status: 'cancelled', error, durationS: elapsedS });
|
|
113
|
-
const supersededText = `${Icons.superseded} ${sessionTag}
|
|
114
|
+
const supersededText = `${Icons.superseded} ${sessionTag}${t('status.supersededByEdit')} (${elapsedStr})`;
|
|
114
115
|
await sealStatus(adapter, statusMsg, supersededText, buildSealedStatusActionBlocks(supersededText, { channel, sessionName, isDm: true }));
|
|
115
116
|
return;
|
|
116
117
|
}
|
|
@@ -119,21 +120,21 @@ export async function handleAgentError({ error, channel, adapter, statusMsg, sta
|
|
|
119
120
|
await conversationLedger.completeTurn(channel, userMessageTs, { executionId });
|
|
120
121
|
if (error?.cancelled) {
|
|
121
122
|
finalizeLocalExecution({ executionId, status: 'failed', error, durationS: elapsedS });
|
|
122
|
-
const cancelledText = `${Icons.stopped} ${sessionTag}
|
|
123
|
+
const cancelledText = `${Icons.stopped} ${sessionTag}${t('status.cancelled')} (${elapsedStr})`;
|
|
123
124
|
await sealStatus(adapter, statusMsg, cancelledText, buildSealedStatusActionBlocks(cancelledText, { channel, sessionName, isDm: true }));
|
|
124
125
|
return;
|
|
125
126
|
}
|
|
126
127
|
log.error('Agent error:', error.message);
|
|
127
128
|
finalizeLocalExecution({ executionId, status: 'failed', error, durationS: elapsedS });
|
|
128
|
-
const errorText = `${Icons.error} ${sessionTag}
|
|
129
|
+
const errorText = `${Icons.error} ${sessionTag}${t('status.error')} (${elapsedStr})`;
|
|
129
130
|
await sealStatus(adapter, statusMsg, errorText, buildSealedStatusActionBlocks(errorText, { channel, sessionName, isDm: true }));
|
|
130
131
|
const errorDest = { type: 'interactive-reply', conduit: channel, sessionId: resolvedSessionId ?? '' };
|
|
131
132
|
const queue = getOutboundQueue();
|
|
132
133
|
if (queue) {
|
|
133
|
-
await durablePost(queue, adapter, errorDest, { text:
|
|
134
|
+
await durablePost(queue, adapter, errorDest, { text: t('status.errorBody', { message: error.message }) }, threadAnchorId ? { threadId: threadAnchorId } : undefined);
|
|
134
135
|
}
|
|
135
136
|
else {
|
|
136
|
-
await adapter.postMessage(errorDest, { text:
|
|
137
|
+
await adapter.postMessage(errorDest, { text: t('status.errorBody', { message: error.message }) }, threadAnchorId ? { threadId: threadAnchorId } : undefined);
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
async function persistErrorSession(resolvedSessionId, sessionName, channel, adapter) {
|
|
@@ -152,7 +153,7 @@ async function persistErrorSession(resolvedSessionId, sessionName, channel, adap
|
|
|
152
153
|
// --- AskUserQuestion resume ---
|
|
153
154
|
export async function resumeAskUserQuestionGroup({ adapter, group, responseText }) {
|
|
154
155
|
const askDest = { type: 'interactive-reply', conduit: group.channel, sessionId: group.sessionId };
|
|
155
|
-
const statusMsg = await adapter.postMessage(askDest, { text: `${Icons.processing}
|
|
156
|
+
const statusMsg = await adapter.postMessage(askDest, { text: `${Icons.processing} ${t('status.processingAskResponse')}` });
|
|
156
157
|
const startTime = Date.now();
|
|
157
158
|
let executionId = null;
|
|
158
159
|
let handle;
|
|
@@ -201,7 +202,7 @@ async function executeRetry(channel, text, adapter, opts) {
|
|
|
201
202
|
const sessionName = opts.sessionName || await sessionStore.generateSessionName();
|
|
202
203
|
const userMessageTs = opts.originalTs;
|
|
203
204
|
const retryDest = { type: 'interactive-reply', conduit: channel, sessionId: sessionId ?? '' };
|
|
204
|
-
const retryPrefix = `${Icons.refresh}
|
|
205
|
+
const retryPrefix = `${Icons.refresh} ${t('status.retry')} (${t('status.retryEdited')}) | `;
|
|
205
206
|
const retryStatusText = retryPrefix + buildUserProcessingMessage({ startTime, profileName: getActiveProfile(channel), sessionName, sessionId });
|
|
206
207
|
const retryBlocksTemplate = { channel, sessionName, isDm: true };
|
|
207
208
|
const statusMsg = await adapter.postMessage(retryDest, {
|
|
@@ -242,7 +243,7 @@ async function runRetryAgent({ channel, text, adapter, statusMsg, startTime, ses
|
|
|
242
243
|
await maybeNotifyCodexLowUsage({ adapter, result });
|
|
243
244
|
if (result?.rateLimited) {
|
|
244
245
|
const { elapsedStr } = computeElapsed(startTime);
|
|
245
|
-
const rateLimitText = `${Icons.warning} ${buildSessionTag(sessionName, sessionId)}
|
|
246
|
+
const rateLimitText = `${Icons.warning} ${buildSessionTag(sessionName, sessionId)}${t('status.rateLimitedExhausted')} (${elapsedStr})`;
|
|
246
247
|
await sealStatus(adapter, statusMsg, rateLimitText, buildSealedStatusActionBlocks(rateLimitText, { channel, sessionName, isDm: true }));
|
|
247
248
|
}
|
|
248
249
|
else {
|
|
@@ -271,11 +272,11 @@ function updateRetryPermalinks(adapter, channel, userMessageTs, statusMsg, super
|
|
|
271
272
|
: Promise.resolve(null);
|
|
272
273
|
Promise.all([userPermalinkP, statusPermalinkP]).then(([userPermalink, statusPermalink]) => {
|
|
273
274
|
if (userPermalink) {
|
|
274
|
-
writeStatus(adapter, statusMsg, `${Icons.refresh}
|
|
275
|
+
writeStatus(adapter, statusMsg, `${Icons.refresh} ${t('status.retry')} (<${userPermalink}|${t('status.retryEdited')}>) | ` + buildUserProcessingMessage({ startTime, profileName: getActiveProfile(channel), sessionName, sessionId }));
|
|
275
276
|
}
|
|
276
277
|
if (statusPermalink && supersededTimestamps?.length) {
|
|
277
278
|
for (const oldTs of supersededTimestamps) {
|
|
278
|
-
adapter.updateMessage({ conduit: channel, messageId: oldTs }, { text: `${Icons.superseded}
|
|
279
|
+
adapter.updateMessage({ conduit: channel, messageId: oldTs }, { text: `${Icons.superseded} ${t('status.supersededByEdit')} \u2014 <${statusPermalink}|${t('status.supersededSeeNewReply')}>` }).catch(() => { });
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
282
|
}).catch(() => { });
|
|
@@ -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 { runningExecutions } from '../../../core/running-executions.js';
|
|
4
5
|
import { conduitQueues } from '../../conduit-queue.js';
|
|
5
6
|
import { cancelThread as cancelThreadById } from '../../../domain/threads/index.js';
|
|
@@ -41,7 +42,7 @@ export function createCancelHandler(cancelDispatchedTask, router) {
|
|
|
41
42
|
conduitQueues.delete(ctx.channelId);
|
|
42
43
|
if (ctx.messageRef) {
|
|
43
44
|
await adapter.updateMessage(ctx.messageRef, {
|
|
44
|
-
text: `${Icons.stopped}
|
|
45
|
+
text: `${Icons.stopped} ${t('cmd.cancel.cancelledShort', { id: threadId || executionId })}`,
|
|
45
46
|
}).catch(() => { });
|
|
46
47
|
}
|
|
47
48
|
};
|
|
@@ -61,14 +62,14 @@ export function createCancelHandler(cancelDispatchedTask, router) {
|
|
|
61
62
|
if (firstArg === '--all') {
|
|
62
63
|
const executions = runningExecutions.getByChannel(channel);
|
|
63
64
|
if (executions.length === 0) {
|
|
64
|
-
await adapter.postMessage(dest, { text: '
|
|
65
|
+
await adapter.postMessage(dest, { text: t('cmd.cancel.nothingRunning') });
|
|
65
66
|
return;
|
|
66
67
|
}
|
|
67
68
|
for (const exec of executions) {
|
|
68
69
|
await cancelLive(exec, channel);
|
|
69
70
|
}
|
|
70
71
|
conduitQueues.delete(channel);
|
|
71
|
-
await adapter.postMessage(dest, { text: `${Icons.stopped}
|
|
72
|
+
await adapter.postMessage(dest, { text: `${Icons.stopped} ${t('cmd.cancel.cancelledN', { n: executions.length })}` });
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
74
75
|
// Thread ID pattern: kill by threadId + cancel thread store record
|
|
@@ -77,16 +78,16 @@ export function createCancelHandler(cancelDispatchedTask, router) {
|
|
|
77
78
|
if (exec) {
|
|
78
79
|
await cancelLive(exec, channel);
|
|
79
80
|
log.info('Cancel requested for thread:', firstArg);
|
|
80
|
-
await adapter.postMessage(dest, { text: `${Icons.stopped}
|
|
81
|
+
await adapter.postMessage(dest, { text: `${Icons.stopped} ${t('cmd.cancel.threadCancelled', { id: firstArg })}` });
|
|
81
82
|
}
|
|
82
83
|
else {
|
|
83
|
-
await adapter.postMessage(dest, { text:
|
|
84
|
+
await adapter.postMessage(dest, { text: t('cmd.cancel.threadNotFound', { id: firstArg }) });
|
|
84
85
|
}
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
88
|
// Fallback: dispatched-task cancellation
|
|
88
89
|
if (!cancelDispatchedTask) {
|
|
89
|
-
await adapter.postMessage(dest, { text: '
|
|
90
|
+
await adapter.postMessage(dest, { text: t('cmd.cancel.dispatchUnavailable') });
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
93
|
const result = await cancelDispatchedTask({ taskId: firstArg, channel });
|
|
@@ -104,19 +105,19 @@ export function createCancelHandler(cancelDispatchedTask, router) {
|
|
|
104
105
|
if (executions.length === 1) {
|
|
105
106
|
await cancelLive(executions[0], channel);
|
|
106
107
|
conduitQueues.delete(channel);
|
|
107
|
-
await adapter.postMessage(dest, { text: `${Icons.stopped}
|
|
108
|
+
await adapter.postMessage(dest, { text: `${Icons.stopped} ${t('cmd.cancel.cancelledSessionPreserved')}` });
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
111
|
// 2+ executions: show interactive list with cancel buttons
|
|
111
112
|
return {
|
|
112
|
-
text:
|
|
113
|
+
text: t('cmd.cancel.runningTasks', { n: executions.length }),
|
|
113
114
|
richBlocks: executions.map(exec => ({
|
|
114
115
|
type: 'section',
|
|
115
116
|
text: `\`${exec.threadId || exec.registryKey}\` · started ${new Date(exec.startTime).toLocaleTimeString()} · ${exec.backend}${exec.channel ? ` · ${exec.channel}` : ''}`,
|
|
116
117
|
})),
|
|
117
118
|
actions: executions.map((exec, i) => ({
|
|
118
119
|
type: 'button',
|
|
119
|
-
text:
|
|
120
|
+
text: t('cmd.cancel.cancelButton', { id: exec.threadId || exec.registryKey }),
|
|
120
121
|
actionId: `cmd:cancel:exec-${i}`,
|
|
121
122
|
value: JSON.stringify({
|
|
122
123
|
threadId: exec.threadId,
|