@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
|
@@ -464,9 +464,15 @@ export class FeishuAdapter {
|
|
|
464
464
|
catch {
|
|
465
465
|
parsed = {};
|
|
466
466
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
467
|
+
// `post` (富文本/rich-text) is what Feishu sends when a message mixes text and
|
|
468
|
+
// images — the text is NOT a top-level `parsed.text` but buried in a 2D array
|
|
469
|
+
// of paragraph element-runs, so the simple text/raw-string path below would
|
|
470
|
+
// yield '' and drop the user's message. Parse post specially.
|
|
471
|
+
const text = messageType === 'post'
|
|
472
|
+
? this.parsePostContent(parsed).text
|
|
473
|
+
: (typeof parsed.text === 'string'
|
|
474
|
+
? parsed.text
|
|
475
|
+
: (typeof message.content === 'string' && !message.content.startsWith('{') ? message.content : ''));
|
|
470
476
|
const ref = {
|
|
471
477
|
conduit: this._wrap(chatId),
|
|
472
478
|
messageId,
|
|
@@ -527,10 +533,75 @@ export class FeishuAdapter {
|
|
|
527
533
|
if (!parsed.image_key)
|
|
528
534
|
return undefined;
|
|
529
535
|
return mk(parsed.image_key, `${parsed.image_key}.png`, 'image/png', 'image');
|
|
536
|
+
case 'post': {
|
|
537
|
+
// A rich-text post may embed any number of inline images (tag:'img'). Each
|
|
538
|
+
// image_key is a resource of THIS message, downloadable via the same
|
|
539
|
+
// messageResource.get(type:'image') path as a standalone image message.
|
|
540
|
+
const { imageKeys } = this.parsePostContent(parsed);
|
|
541
|
+
if (imageKeys.length === 0)
|
|
542
|
+
return undefined;
|
|
543
|
+
return imageKeys.map(k => ({
|
|
544
|
+
id: k,
|
|
545
|
+
name: `${k}.png`,
|
|
546
|
+
mimetype: 'image/png',
|
|
547
|
+
url: '',
|
|
548
|
+
conduit: this._wrap(chatId),
|
|
549
|
+
raw: { message_id: messageId, resourceType: 'image' },
|
|
550
|
+
}));
|
|
551
|
+
}
|
|
530
552
|
default:
|
|
531
553
|
return undefined;
|
|
532
554
|
}
|
|
533
555
|
}
|
|
556
|
+
/**
|
|
557
|
+
* Parse a Feishu `post` (富文本/rich-text) message content payload. Feishu wraps
|
|
558
|
+
* a single message that mixes text and images as a post, whose `content` is a 2D
|
|
559
|
+
* array of paragraphs, each a run of element nodes:
|
|
560
|
+
* { title?, content: [ [ {tag:'text',text}, {tag:'a',text,href}, {tag:'at',user_name},
|
|
561
|
+
* {tag:'img',image_key} ], ... ] }
|
|
562
|
+
* Returns the concatenated text (paragraphs joined by '\n', non-empty title
|
|
563
|
+
* prefixed) and the list of inline image_keys, so callers recover BOTH the text
|
|
564
|
+
* and the images from one mixed message.
|
|
565
|
+
*/
|
|
566
|
+
parsePostContent(parsed) {
|
|
567
|
+
const imageKeys = [];
|
|
568
|
+
const content = parsed?.content;
|
|
569
|
+
if (!Array.isArray(content))
|
|
570
|
+
return { text: '', imageKeys };
|
|
571
|
+
const lines = [];
|
|
572
|
+
for (const paragraph of content) {
|
|
573
|
+
if (!Array.isArray(paragraph))
|
|
574
|
+
continue;
|
|
575
|
+
let line = '';
|
|
576
|
+
for (const node of paragraph) {
|
|
577
|
+
if (!node || typeof node !== 'object')
|
|
578
|
+
continue;
|
|
579
|
+
switch (node.tag) {
|
|
580
|
+
case 'text':
|
|
581
|
+
case 'a':
|
|
582
|
+
if (typeof node.text === 'string')
|
|
583
|
+
line += node.text;
|
|
584
|
+
break;
|
|
585
|
+
case 'at':
|
|
586
|
+
if (typeof node.user_name === 'string')
|
|
587
|
+
line += `@${node.user_name}`;
|
|
588
|
+
break;
|
|
589
|
+
case 'img':
|
|
590
|
+
if (typeof node.image_key === 'string')
|
|
591
|
+
imageKeys.push(node.image_key);
|
|
592
|
+
break;
|
|
593
|
+
default:
|
|
594
|
+
break;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
lines.push(line);
|
|
598
|
+
}
|
|
599
|
+
let text = lines.join('\n').trim();
|
|
600
|
+
if (typeof parsed.title === 'string' && parsed.title.trim()) {
|
|
601
|
+
text = text ? `${parsed.title}\n${text}` : parsed.title.trim();
|
|
602
|
+
}
|
|
603
|
+
return { text, imageKeys };
|
|
604
|
+
}
|
|
534
605
|
async handleCardAction(data) {
|
|
535
606
|
const event = data.event || data;
|
|
536
607
|
const action = event.action || {};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// pos: Platform-independent interactive component builder
|
|
4
4
|
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
5
|
import { Icons } from '../core/icons.js';
|
|
6
|
+
import { t } from '../core/i18n.js';
|
|
6
7
|
// --- AskUserQuestion builders ---
|
|
7
8
|
export function buildQuestionGroupBlocks(group) {
|
|
8
9
|
const blocks = [];
|
|
@@ -26,7 +27,7 @@ export function buildQuestionGroupBlocks(group) {
|
|
|
26
27
|
type: 'actions',
|
|
27
28
|
elements: [{
|
|
28
29
|
type: 'button',
|
|
29
|
-
text:
|
|
30
|
+
text: t('modal.answer', { answered: group.answers.size, total: group.questions.length }),
|
|
30
31
|
actionId: 'ask_user_question_open_modal',
|
|
31
32
|
value: group.groupId,
|
|
32
33
|
style: 'primary',
|
|
@@ -51,9 +52,9 @@ export function buildQuestionModalDefinition(group) {
|
|
|
51
52
|
fields.push({
|
|
52
53
|
type: q.multiSelect ? 'multi_select' : 'select',
|
|
53
54
|
blockId: `q_${qIdx}`,
|
|
54
|
-
label: q.multiSelect ? '
|
|
55
|
+
label: q.multiSelect ? t('modal.selectOneOrMore') : t('modal.selectOne'),
|
|
55
56
|
actionId: 'selection',
|
|
56
|
-
placeholder: q.multiSelect ? '
|
|
57
|
+
placeholder: q.multiSelect ? t('modal.selectOneOrMore') : t('modal.selectOne'),
|
|
57
58
|
options: q.options.map((option, optIdx) => ({
|
|
58
59
|
label: option.label,
|
|
59
60
|
value: String(optIdx),
|
|
@@ -63,9 +64,9 @@ export function buildQuestionModalDefinition(group) {
|
|
|
63
64
|
fields.push({
|
|
64
65
|
type: 'text_input',
|
|
65
66
|
blockId: `q_${qIdx}_other`,
|
|
66
|
-
label: '
|
|
67
|
+
label: t('modal.typeAnswerLabel'),
|
|
67
68
|
actionId: 'other_text',
|
|
68
|
-
placeholder: '
|
|
69
|
+
placeholder: t('modal.customAnswerPlaceholder'),
|
|
69
70
|
optional: true,
|
|
70
71
|
});
|
|
71
72
|
}
|
|
@@ -74,18 +75,18 @@ export function buildQuestionModalDefinition(group) {
|
|
|
74
75
|
fields.push({
|
|
75
76
|
type: 'text_input',
|
|
76
77
|
blockId: `q_${qIdx}_other`,
|
|
77
|
-
label: '
|
|
78
|
+
label: t('modal.yourAnswerLabel'),
|
|
78
79
|
actionId: 'other_text',
|
|
79
|
-
placeholder: '
|
|
80
|
+
placeholder: t('modal.yourAnswerPlaceholder'),
|
|
80
81
|
optional: false,
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
return {
|
|
85
86
|
callbackId: 'ask_user_question_modal_submit',
|
|
86
|
-
title: '
|
|
87
|
-
submitLabel: '
|
|
88
|
-
closeLabel: '
|
|
87
|
+
title: t('modal.questionsTitle'),
|
|
88
|
+
submitLabel: t('modal.submit'),
|
|
89
|
+
closeLabel: t('modal.cancel'),
|
|
89
90
|
privateMetadata: JSON.stringify({ groupId: group.groupId }),
|
|
90
91
|
fields,
|
|
91
92
|
};
|
|
@@ -94,28 +95,28 @@ export function buildQuestionModalDefinition(group) {
|
|
|
94
95
|
export function buildPlanApprovalContent(requestId) {
|
|
95
96
|
return {
|
|
96
97
|
richBlocks: [
|
|
97
|
-
{ type: 'section', text: `${Icons.memo}
|
|
98
|
+
{ type: 'section', text: `${Icons.memo} ${t('modal.planReady')}` },
|
|
98
99
|
],
|
|
99
100
|
actions: [
|
|
100
|
-
{ type: 'button', text: '
|
|
101
|
-
{ type: 'button', text: '
|
|
101
|
+
{ type: 'button', text: t('modal.approve'), actionId: 'hook_plan_approve', value: requestId, style: 'primary' },
|
|
102
|
+
{ type: 'button', text: t('modal.provideFeedback'), actionId: 'hook_plan_feedback', value: requestId },
|
|
102
103
|
],
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
106
|
export function buildPlanFeedbackModal(requestId) {
|
|
106
107
|
return {
|
|
107
108
|
callbackId: 'hook_plan_feedback_submit',
|
|
108
|
-
title: '
|
|
109
|
-
submitLabel: '
|
|
110
|
-
closeLabel: '
|
|
109
|
+
title: t('modal.planFeedbackTitle'),
|
|
110
|
+
submitLabel: t('modal.submit'),
|
|
111
|
+
closeLabel: t('modal.cancel'),
|
|
111
112
|
privateMetadata: JSON.stringify({ requestId }),
|
|
112
113
|
fields: [{
|
|
113
114
|
type: 'text_input',
|
|
114
115
|
blockId: 'feedback',
|
|
115
|
-
label: '
|
|
116
|
+
label: t('modal.feedbackLabel'),
|
|
116
117
|
actionId: 'text',
|
|
117
118
|
multiline: true,
|
|
118
|
-
placeholder: '
|
|
119
|
+
placeholder: t('modal.feedbackPlaceholder'),
|
|
119
120
|
}],
|
|
120
121
|
};
|
|
121
122
|
}
|
|
@@ -20,3 +20,10 @@ export interface MigrationOptions {
|
|
|
20
20
|
storeDir?: string;
|
|
21
21
|
}
|
|
22
22
|
export declare function runMigrations(opts?: MigrationOptions): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Migrate config.yaml from CORTEX_HOME/config/ (wrong location before 2026.6.11)
|
|
25
|
+
* to ~/.aistatus/config.yaml (correct location read by aistatus).
|
|
26
|
+
* Idempotent: if target already exists and is valid YAML, source is deleted without copying.
|
|
27
|
+
* If source is malformed YAML, it's deleted to avoid interfering with aistatus.
|
|
28
|
+
*/
|
|
29
|
+
export declare function migrateAistatusConfigLocation(dataDir: string): Promise<void>;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
7
7
|
import * as path from 'node:path';
|
|
8
8
|
import * as fs from 'node:fs/promises';
|
|
9
|
+
import * as os from 'node:os';
|
|
9
10
|
import { CORTEX_VERSION } from '../core/version.js';
|
|
10
11
|
import { DATA_DIR, DEFAULTS_DIR } from '../core/paths.js';
|
|
11
12
|
import { atomicWrite } from '../core/atomic-write.js';
|
|
@@ -298,3 +299,90 @@ export async function runMigrations(opts = {}) {
|
|
|
298
299
|
}
|
|
299
300
|
await saveVersionsTo(versionsFile, versions);
|
|
300
301
|
}
|
|
302
|
+
// ── File location migrations ───────────────────────────────────
|
|
303
|
+
/**
|
|
304
|
+
* Migrate config.yaml from CORTEX_HOME/config/ (wrong location before 2026.6.11)
|
|
305
|
+
* to ~/.aistatus/config.yaml (correct location read by aistatus).
|
|
306
|
+
* Idempotent: if target already exists and is valid YAML, source is deleted without copying.
|
|
307
|
+
* If source is malformed YAML, it's deleted to avoid interfering with aistatus.
|
|
308
|
+
*/
|
|
309
|
+
export async function migrateAistatusConfigLocation(dataDir) {
|
|
310
|
+
const srcPath = path.join(dataDir, 'config', 'config.yaml');
|
|
311
|
+
const dstPath = path.join(os.homedir(), '.aistatus', 'config.yaml');
|
|
312
|
+
// Check if source exists
|
|
313
|
+
let srcExists = false;
|
|
314
|
+
try {
|
|
315
|
+
await fs.access(srcPath);
|
|
316
|
+
srcExists = true;
|
|
317
|
+
}
|
|
318
|
+
catch {
|
|
319
|
+
// Source does not exist — nothing to migrate
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
// Check if target already exists
|
|
323
|
+
let dstExists = false;
|
|
324
|
+
let dstValid = false;
|
|
325
|
+
try {
|
|
326
|
+
await fs.access(dstPath);
|
|
327
|
+
dstExists = true;
|
|
328
|
+
// Validate target is readable YAML (not corrupted)
|
|
329
|
+
const raw = await fs.readFile(dstPath, 'utf8');
|
|
330
|
+
// Simple YAML validation: must be parseable as key: value pairs
|
|
331
|
+
if (raw.trim().length === 0 || /^[a-zA-Z_][\w]*:/.test(raw)) {
|
|
332
|
+
dstValid = true;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
catch {
|
|
336
|
+
// Target does not exist or is not readable
|
|
337
|
+
}
|
|
338
|
+
// If target exists and is valid, source is redundant — just remove it
|
|
339
|
+
if (dstExists && dstValid) {
|
|
340
|
+
try {
|
|
341
|
+
await fs.unlink(srcPath);
|
|
342
|
+
log.info(`Migrated aistatus config: removed redundant ${srcPath} (target ${dstPath} already exists)`);
|
|
343
|
+
}
|
|
344
|
+
catch {
|
|
345
|
+
// Best effort — if we can't delete, log warning but don't fail
|
|
346
|
+
log.warn(`Could not remove old config file: ${srcPath}`);
|
|
347
|
+
}
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
// Read source, validate, and copy to target
|
|
351
|
+
let srcData;
|
|
352
|
+
try {
|
|
353
|
+
srcData = await fs.readFile(srcPath, 'utf8');
|
|
354
|
+
}
|
|
355
|
+
catch (err) {
|
|
356
|
+
log.warn(`Could not read old config file: ${srcPath}; skipping migration`);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
// Validate source is valid YAML before copying
|
|
360
|
+
if (srcData.trim().length === 0 || !/^[a-zA-Z_][\w]*:/.test(srcData)) {
|
|
361
|
+
// Source is empty or doesn't look like YAML — delete it to avoid pollution
|
|
362
|
+
try {
|
|
363
|
+
await fs.unlink(srcPath);
|
|
364
|
+
log.info(`Removed malformed old config file: ${srcPath}`);
|
|
365
|
+
}
|
|
366
|
+
catch {
|
|
367
|
+
log.warn(`Could not remove malformed old config file: ${srcPath}`);
|
|
368
|
+
}
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
// Copy source to target
|
|
372
|
+
try {
|
|
373
|
+
const dstDir = path.dirname(dstPath);
|
|
374
|
+
await fs.mkdir(dstDir, { recursive: true });
|
|
375
|
+
await atomicWrite(dstPath, srcData);
|
|
376
|
+
log.info(`Migrated aistatus config from ${srcPath} to ${dstPath}`);
|
|
377
|
+
// Clean up source after successful copy
|
|
378
|
+
try {
|
|
379
|
+
await fs.unlink(srcPath);
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
log.warn(`Could not remove old config file after migration: ${srcPath}`);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
catch (err) {
|
|
386
|
+
log.error(`Failed to migrate aistatus config to ${dstPath}: ${err.message}`);
|
|
387
|
+
}
|
|
388
|
+
}
|
package/package.json
CHANGED