@kafca/agentdock 0.1.23 → 0.1.25
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/README.md +3 -0
- package/dist/renderer/assets/{Badge-C2K5apfV.js → Badge-Bn2h-Qkf.js} +1 -1
- package/dist/renderer/assets/{Chat-DI2YeVKb.js → Chat-Cgo9aneg.js} +1 -1
- package/dist/renderer/assets/{ChatMarkdown-DMAr15Oi.js → ChatMarkdown-CYzHfSiR.js} +1 -1
- package/dist/renderer/assets/{Config-7rP3EuUf.js → Config-DljB2-eP.js} +1 -1
- package/dist/renderer/assets/{CronList-81QslYE8.js → CronList-DeVbiY9a.js} +1 -1
- package/dist/renderer/assets/{Dashboard-Db2T7rSZ.js → Dashboard-fSqx5sm8.js} +2 -2
- package/dist/renderer/assets/{EmptyState-BBJ3cTvB.js → EmptyState-DgqKDwlq.js} +1 -1
- package/dist/renderer/assets/{KnowledgeDetail-Dz_6flG3.js → KnowledgeDetail-u8s2SmPV.js} +1 -1
- package/dist/renderer/assets/{KnowledgeHome-DIh046mN.js → KnowledgeHome-BdQw8nbY.js} +1 -1
- package/dist/renderer/assets/{Logs-BXBtHJLf.js → Logs-DSbndMpy.js} +1 -1
- package/dist/renderer/assets/{Modal-BB2Av_Xs.js → Modal-0d0EmAuK.js} +1 -1
- package/dist/renderer/assets/{Page-DPSdvMgU.js → Page-CVbOH_Kh.js} +1 -1
- package/dist/renderer/assets/{ProjectDetail-C6EWGvGg.js → ProjectDetail-C91tF7uA.js} +1 -1
- package/dist/renderer/assets/{ProjectList-BBo5ygnS.js → ProjectList-D78Pc-BQ.js} +1 -1
- package/dist/renderer/assets/{Select-CNX-Tx_O.js → Select-BbKzAIuO.js} +1 -1
- package/dist/renderer/assets/{SessionChat-BIn46jqZ.js → SessionChat-BERvL5e4.js} +1 -1
- package/dist/renderer/assets/{SessionList-CZt6f1Rd.js → SessionList-Bomz335M.js} +1 -1
- package/dist/renderer/assets/ThreadChat-CLr3amU2.js +23 -0
- package/dist/renderer/assets/{Workspace-C_4tdpjX.js → Workspace-In91z4W2.js} +1 -1
- package/dist/renderer/assets/{arrow-left-cHr5wkpq.js → arrow-left-FBnVKKBl.js} +1 -1
- package/dist/renderer/assets/{book-open-4nx5C8T-.js → book-open-4_CuP6Sa.js} +1 -1
- package/dist/renderer/assets/{check-exTS-R-x.js → check-vsoVjvac.js} +1 -1
- package/dist/renderer/assets/{chevron-down-DSvxXQa0.js → chevron-down-DFpmFTJW.js} +1 -1
- package/dist/renderer/assets/{circle-DyvEovdw.js → circle-vRULegER.js} +1 -1
- package/dist/renderer/assets/desktop-BkMW-h5p.js +4 -0
- package/dist/renderer/assets/{desktop-B-KVT10D.js → desktop-ul0Tpzyc.js} +1 -1
- package/dist/renderer/assets/{funnel-DA9qVdTy.js → funnel-Gu0E_hJ_.js} +1 -1
- package/dist/renderer/assets/{heart-DuEV0ZRJ.js → heart-DsdofOHf.js} +1 -1
- package/dist/renderer/assets/{index-Biz-aexG.js → index-BD3aCyBa.js} +3 -3
- package/dist/renderer/assets/{index-BgflqkCN.js → index-pJUFobU7.js} +1 -1
- package/dist/renderer/assets/{pencil-DBDxeNmO.js → pencil-DbKmV8nD.js} +1 -1
- package/dist/renderer/assets/{play-IzlP83_7.js → play-BDMsRxSm.js} +1 -1
- package/dist/renderer/assets/{plug-CuT-qFnW.js → plug-t2dMl78-.js} +1 -1
- package/dist/renderer/assets/{plus-DEqgkn63.js → plus-BUb6zOAe.js} +1 -1
- package/dist/renderer/assets/projects-4F6D_Q8t.js +1 -0
- package/dist/renderer/assets/{save-D4sRo07y.js → save-C-_5rQdv.js} +1 -1
- package/dist/renderer/assets/{search-DbPZLuV8.js → search-R3ekHFPM.js} +1 -1
- package/dist/renderer/assets/{server-D1jUQmwN.js → server-BTuvHf5n.js} +1 -1
- package/dist/renderer/assets/{session-utils-Aife8ep2.js → session-utils-ClX6VPFG.js} +1 -1
- package/dist/renderer/assets/{sessions-DaH3H7gC.js → sessions-AFKIC-ub.js} +1 -1
- package/dist/renderer/assets/{shield-check-BGwUFWNr.js → shield-check-CqMW8CHe.js} +1 -1
- package/dist/renderer/assets/{trash-2-CIFBioBa.js → trash-2-BNLcHyUw.js} +1 -1
- package/dist/renderer/assets/{user-CnKcvHdo.js → user-BCCN8FYK.js} +1 -1
- package/dist/renderer/assets/{wifi-off-ClO53WGa.js → wifi-off-BsNsx3oX.js} +1 -1
- package/dist/renderer/index.html +1 -1
- package/dist-electron/electron/agent-runtime-detector.test.js +64 -0
- package/dist-electron/electron/architecture-docs.test.js +56 -0
- package/dist-electron/electron/channel-content.test.js +37 -0
- package/dist-electron/electron/lac-cli.test.js +297 -4
- package/dist-electron/electron/local-core-acp-content.test.js +39 -0
- package/dist-electron/electron/local-core-contracts.test.js +67 -0
- package/dist-electron/electron/local-core-refactor.test.js +789 -3
- package/dist-electron/electron/plugin-kernel.test.js +108 -0
- package/dist-electron/electron/renderer-packaging.test.js +77 -0
- package/dist-electron/electron/workspace-task-store.test.js +181 -0
- package/dist-electron/packages/contracts/src/local-core.js +110 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-backend.js +67 -6
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-content.js +25 -4
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-permission-lifecycle.js +76 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-progress.js +201 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-response-processor.js +3 -2
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-session-coordinator.js +29 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-store.js +74 -46
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-turn-coordinator.js +112 -210
- package/dist-electron/services/local-ai-core/src/acp/local-core-slash-commands.js +60 -0
- package/dist-electron/services/local-ai-core/src/acp/workspace-acp-permissions.js +5 -48
- package/dist-electron/services/local-ai-core/src/channel/lark/local-core-lark-gateway.js +83 -28
- package/dist-electron/services/local-ai-core/src/channel/lark/runtime-state.js +11 -0
- package/dist-electron/services/local-ai-core/src/channel/shared/content.js +23 -0
- package/dist-electron/services/local-ai-core/src/channel/shared/file-utils.js +13 -1
- package/dist-electron/services/local-ai-core/src/channel/weixin/local-core-weixin-gateway.js +31 -29
- package/dist-electron/services/local-ai-core/src/cli/lac.js +22 -17
- package/dist-electron/services/local-ai-core/src/kernel/bootstrap.js +1 -0
- package/dist-electron/services/local-ai-core/src/plugins/builtin/agent-localcore-acp-plugin.js +9 -0
- package/dist-electron/services/local-ai-core/src/router/workspace-route-config.js +221 -10
- package/dist-electron/services/local-ai-core/src/runtime/agent-runtime-detector.js +39 -9
- package/dist-electron/services/local-ai-core/src/runtime/local-core-controller.js +1 -0
- package/dist-electron/services/local-ai-core/src/runtime/runtime-detection-service.js +1 -0
- package/dist-electron/services/local-ai-core/src/runtime/server-routes.js +439 -0
- package/dist-electron/services/local-ai-core/src/runtime/server.js +208 -303
- package/dist-electron/services/local-ai-core/src/scheduler/job-id.js +15 -0
- package/dist-electron/services/local-ai-core/src/scheduler/scheduler-service.js +30 -5
- package/dist-electron/shared/desktop.js +34 -8
- package/dist-electron/src/pages/Threads/thread-chat-message-blocks.js +187 -0
- package/dist-electron/src/pages/Threads/thread-chat-model.js +58 -0
- package/dist-electron/src/pages/Threads/thread-chat-page-state.js +96 -0
- package/dist-electron/src/pages/Threads/thread-chat-permission.js +18 -0
- package/dist-electron/src/pages/Threads/thread-chat-permission.test.js +347 -0
- package/package.json +4 -2
- package/dist/renderer/assets/ThreadChat-BotD0gKQ.js +0 -23
- package/dist/renderer/assets/desktop-CVibRyAw.js +0 -4
- package/dist/renderer/assets/projects-DDtDN1rc.js +0 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeThreadMessageInput = normalizeThreadMessageInput;
|
|
4
4
|
exports.createTextMessageInput = createTextMessageInput;
|
|
5
|
+
const index_js_1 = require("../../../../packages/contracts/src/index.js");
|
|
5
6
|
function normalizeThreadMessageInput(input) {
|
|
6
7
|
if (typeof input === 'string') {
|
|
7
8
|
return {
|
|
@@ -32,7 +33,13 @@ function isSupportedContentPart(part) {
|
|
|
32
33
|
if (!part || typeof part !== 'object') {
|
|
33
34
|
return false;
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
+
let type;
|
|
37
|
+
try {
|
|
38
|
+
type = (0, index_js_1.normalizeChannelContentPartType)(part.type);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
36
43
|
if (type === 'text') {
|
|
37
44
|
return Boolean(String(part.text || ''));
|
|
38
45
|
}
|
|
@@ -40,6 +47,10 @@ function isSupportedContentPart(part) {
|
|
|
40
47
|
const image = part;
|
|
41
48
|
return Boolean(String(image.data || image.uri || ''));
|
|
42
49
|
}
|
|
50
|
+
if (type === 'file') {
|
|
51
|
+
const file = part;
|
|
52
|
+
return Boolean(String(file.data || file.uri || file.path || ''));
|
|
53
|
+
}
|
|
43
54
|
return false;
|
|
44
55
|
}
|
|
45
56
|
function summarizeContentParts(parts) {
|
|
@@ -52,9 +63,19 @@ function summarizeContentParts(parts) {
|
|
|
52
63
|
if (text) {
|
|
53
64
|
return text;
|
|
54
65
|
}
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
const summaries = parts
|
|
67
|
+
.map((part) => {
|
|
68
|
+
if (part.type === 'image') {
|
|
69
|
+
return part.fileName ? `[Image: ${part.fileName}]` : '[Image]';
|
|
70
|
+
}
|
|
71
|
+
if (part.type === 'file') {
|
|
72
|
+
return part.fileName ? `[File: ${part.fileName}]` : '[File]';
|
|
73
|
+
}
|
|
74
|
+
return '';
|
|
75
|
+
})
|
|
76
|
+
.filter(Boolean);
|
|
77
|
+
if (summaries.length > 0) {
|
|
78
|
+
return summaries.join('\n');
|
|
58
79
|
}
|
|
59
80
|
return '';
|
|
60
81
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePermissionOptions = parsePermissionOptions;
|
|
4
|
+
exports.createRunningPermissionRequest = createRunningPermissionRequest;
|
|
5
|
+
exports.createPermissionApprovalInput = createPermissionApprovalInput;
|
|
6
|
+
exports.createPermissionPrompt = createPermissionPrompt;
|
|
7
|
+
exports.applyPendingPermissionRequest = applyPendingPermissionRequest;
|
|
8
|
+
exports.isSchedulerAddCommand = isSchedulerAddCommand;
|
|
9
|
+
const workspace_acp_permissions_js_1 = require("./workspace-acp-permissions.js");
|
|
10
|
+
function parsePermissionOptions(options) {
|
|
11
|
+
return Array.isArray(options)
|
|
12
|
+
? options
|
|
13
|
+
.map((option) => ({
|
|
14
|
+
optionId: String(option?.optionId || '').trim(),
|
|
15
|
+
name: String(option?.name || option?.optionId || '').trim(),
|
|
16
|
+
kind: String(option?.kind || '').trim(),
|
|
17
|
+
normalizedAction: (0, workspace_acp_permissions_js_1.normalizePermissionOptionAction)({
|
|
18
|
+
optionId: option?.optionId,
|
|
19
|
+
name: option?.name,
|
|
20
|
+
kind: option?.kind,
|
|
21
|
+
}),
|
|
22
|
+
}))
|
|
23
|
+
.filter((option) => option.optionId)
|
|
24
|
+
: [];
|
|
25
|
+
}
|
|
26
|
+
function createRunningPermissionRequest(input) {
|
|
27
|
+
return {
|
|
28
|
+
requestId: input.requestId,
|
|
29
|
+
toolTitle: input.toolTitle,
|
|
30
|
+
isSchedulerAdd: isSchedulerAddCommand(input.toolTitle),
|
|
31
|
+
options: input.options,
|
|
32
|
+
...(input.approvalId ? { approvalId: input.approvalId } : {}),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function createPermissionApprovalInput(input) {
|
|
36
|
+
return {
|
|
37
|
+
threadId: input.threadId,
|
|
38
|
+
runId: input.runId,
|
|
39
|
+
title: input.toolTitle ? `Approve ${input.toolTitle}` : 'Approve agent action',
|
|
40
|
+
description: input.toolTitle || 'Agent requested permission before continuing.',
|
|
41
|
+
command: input.toolTitle,
|
|
42
|
+
options: input.options,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function createPermissionPrompt(toolTitle) {
|
|
46
|
+
return [
|
|
47
|
+
'等待工具确认',
|
|
48
|
+
'',
|
|
49
|
+
toolTitle,
|
|
50
|
+
'',
|
|
51
|
+
'请选择一个选项继续执行。',
|
|
52
|
+
'',
|
|
53
|
+
'若按钮没有显示,请直接回复:allow all / allow / deny',
|
|
54
|
+
].join('\n');
|
|
55
|
+
}
|
|
56
|
+
function applyPendingPermissionRequest(input) {
|
|
57
|
+
input.session.pendingPermissionByRun.set(input.runId, input.permissionRequest);
|
|
58
|
+
const currentTurn = input.session.currentTurn;
|
|
59
|
+
if (!currentTurn) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
currentTurn.permission = input.permissionRequest;
|
|
63
|
+
const toolTitle = input.permissionRequest.toolTitle;
|
|
64
|
+
if (!toolTitle || toolTitle === 'Permission required before continuing.') {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
currentTurn.pendingToolCallDetail = toolTitle;
|
|
68
|
+
const toolCall = input.resolveFallbackToolCall(currentTurn);
|
|
69
|
+
if (toolCall) {
|
|
70
|
+
toolCall.detail = toolTitle;
|
|
71
|
+
input.syncLegacyPendingToolCall(currentTurn, toolCall);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function isSchedulerAddCommand(value) {
|
|
75
|
+
return /\blac\s+scheduler\s+add\b/.test(String(value || ''));
|
|
76
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyAssistantMessageChunk = applyAssistantMessageChunk;
|
|
4
|
+
exports.applyThoughtChunk = applyThoughtChunk;
|
|
5
|
+
exports.registerPendingToolCall = registerPendingToolCall;
|
|
6
|
+
exports.resolveToolCallForUpdate = resolveToolCallForUpdate;
|
|
7
|
+
exports.resolveFallbackToolCall = resolveFallbackToolCall;
|
|
8
|
+
exports.getToolCallsInOrder = getToolCallsInOrder;
|
|
9
|
+
exports.deletePendingToolCall = deletePendingToolCall;
|
|
10
|
+
exports.syncLegacyPendingToolCall = syncLegacyPendingToolCall;
|
|
11
|
+
exports.extractToolUpdateContent = extractToolUpdateContent;
|
|
12
|
+
exports.formatToolProgressMessage = formatToolProgressMessage;
|
|
13
|
+
exports.resolveToolUpdateDisplayTitle = resolveToolUpdateDisplayTitle;
|
|
14
|
+
exports.isEmptyRunningToolUpdate = isEmptyRunningToolUpdate;
|
|
15
|
+
exports.isTerminalToolStatus = isTerminalToolStatus;
|
|
16
|
+
exports.formatPlanProgress = formatPlanProgress;
|
|
17
|
+
exports.extractToolCallKey = extractToolCallKey;
|
|
18
|
+
exports.extractToolCallInput = extractToolCallInput;
|
|
19
|
+
function applyAssistantMessageChunk(currentTurn, text) {
|
|
20
|
+
if (!text) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
currentTurn.assistantText += text;
|
|
24
|
+
if (!currentTurn.previewStarted) {
|
|
25
|
+
currentTurn.previewStarted = true;
|
|
26
|
+
return {
|
|
27
|
+
bridgeType: 'preview_start',
|
|
28
|
+
previewHandle: currentTurn.previewHandle,
|
|
29
|
+
content: currentTurn.assistantText,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
bridgeType: 'update_message',
|
|
34
|
+
previewHandle: currentTurn.previewHandle,
|
|
35
|
+
content: currentTurn.assistantText,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function applyThoughtChunk(currentTurn, text) {
|
|
39
|
+
if (!text) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
currentTurn.thoughtText = mergeStreamingText(currentTurn.thoughtText, text);
|
|
43
|
+
const content = `💭 ${currentTurn.thoughtText.trim()}`;
|
|
44
|
+
if (!currentTurn.thoughtPreviewStarted) {
|
|
45
|
+
currentTurn.thoughtPreviewStarted = true;
|
|
46
|
+
return {
|
|
47
|
+
bridgeType: 'preview_start',
|
|
48
|
+
previewHandle: currentTurn.thoughtPreviewHandle,
|
|
49
|
+
messageId: currentTurn.thoughtMessageId,
|
|
50
|
+
content,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
bridgeType: 'update_message',
|
|
55
|
+
previewHandle: currentTurn.thoughtPreviewHandle,
|
|
56
|
+
messageId: currentTurn.thoughtMessageId,
|
|
57
|
+
content,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function mergeStreamingText(current, next) {
|
|
61
|
+
if (!current) {
|
|
62
|
+
return next;
|
|
63
|
+
}
|
|
64
|
+
if (next.startsWith(current)) {
|
|
65
|
+
return next;
|
|
66
|
+
}
|
|
67
|
+
if (current.endsWith(next)) {
|
|
68
|
+
return current;
|
|
69
|
+
}
|
|
70
|
+
const maxOverlap = Math.min(current.length, next.length);
|
|
71
|
+
for (let size = maxOverlap; size > 0; size -= 1) {
|
|
72
|
+
if (current.endsWith(next.slice(0, size))) {
|
|
73
|
+
return current + next.slice(size);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return current + next;
|
|
77
|
+
}
|
|
78
|
+
function registerPendingToolCall(input) {
|
|
79
|
+
const title = String(input.update.title || 'Running tool').trim();
|
|
80
|
+
const nextSequence = (input.currentTurn.toolCallSequence || 0) + 1;
|
|
81
|
+
input.currentTurn.toolCallSequence = nextSequence;
|
|
82
|
+
const key = extractToolCallKey(input.update) || `sequence:${nextSequence}`;
|
|
83
|
+
const toolInput = extractToolCallInput(input.update);
|
|
84
|
+
const toolCall = {
|
|
85
|
+
key,
|
|
86
|
+
title,
|
|
87
|
+
messageId: `${input.runId}-tool-${nextSequence}`,
|
|
88
|
+
...(toolInput === undefined ? {} : { input: toolInput }),
|
|
89
|
+
sequence: nextSequence,
|
|
90
|
+
emitted: false,
|
|
91
|
+
};
|
|
92
|
+
input.currentTurn.pendingToolCalls = {
|
|
93
|
+
...(input.currentTurn.pendingToolCalls || {}),
|
|
94
|
+
[key]: toolCall,
|
|
95
|
+
};
|
|
96
|
+
input.currentTurn.pendingToolCallOrder = [
|
|
97
|
+
...(input.currentTurn.pendingToolCallOrder || []).filter((item) => item !== key),
|
|
98
|
+
key,
|
|
99
|
+
];
|
|
100
|
+
input.currentTurn.activeToolCallKey = key;
|
|
101
|
+
return toolCall;
|
|
102
|
+
}
|
|
103
|
+
function resolveToolCallForUpdate(currentTurn, update) {
|
|
104
|
+
const explicitKey = extractToolCallKey(update);
|
|
105
|
+
if (explicitKey && currentTurn.pendingToolCalls?.[explicitKey]) {
|
|
106
|
+
currentTurn.activeToolCallKey = explicitKey;
|
|
107
|
+
return currentTurn.pendingToolCalls[explicitKey];
|
|
108
|
+
}
|
|
109
|
+
return resolveFallbackToolCall(currentTurn);
|
|
110
|
+
}
|
|
111
|
+
function resolveFallbackToolCall(currentTurn) {
|
|
112
|
+
const active = currentTurn.activeToolCallKey
|
|
113
|
+
? currentTurn.pendingToolCalls?.[currentTurn.activeToolCallKey]
|
|
114
|
+
: undefined;
|
|
115
|
+
if (active) {
|
|
116
|
+
return active;
|
|
117
|
+
}
|
|
118
|
+
const ordered = getToolCallsInOrder(currentTurn);
|
|
119
|
+
return ordered[ordered.length - 1];
|
|
120
|
+
}
|
|
121
|
+
function getToolCallsInOrder(currentTurn) {
|
|
122
|
+
const toolCalls = currentTurn.pendingToolCalls || {};
|
|
123
|
+
const orderedKeys = currentTurn.pendingToolCallOrder || [];
|
|
124
|
+
return orderedKeys
|
|
125
|
+
.map((key) => toolCalls[key])
|
|
126
|
+
.filter((toolCall) => Boolean(toolCall));
|
|
127
|
+
}
|
|
128
|
+
function deletePendingToolCall(currentTurn, key) {
|
|
129
|
+
if (currentTurn.pendingToolCalls) {
|
|
130
|
+
delete currentTurn.pendingToolCalls[key];
|
|
131
|
+
}
|
|
132
|
+
currentTurn.pendingToolCallOrder = (currentTurn.pendingToolCallOrder || []).filter((item) => item !== key);
|
|
133
|
+
if (currentTurn.activeToolCallKey === key) {
|
|
134
|
+
currentTurn.activeToolCallKey = undefined;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function syncLegacyPendingToolCall(currentTurn, toolCall) {
|
|
138
|
+
currentTurn.pendingToolCallTitle = toolCall?.title;
|
|
139
|
+
currentTurn.pendingToolCallId = toolCall?.messageId;
|
|
140
|
+
currentTurn.pendingToolCallDetail = toolCall?.detail;
|
|
141
|
+
currentTurn.activeToolCallKey = toolCall?.key;
|
|
142
|
+
}
|
|
143
|
+
function extractToolUpdateContent(content) {
|
|
144
|
+
return Array.isArray(content)
|
|
145
|
+
? content
|
|
146
|
+
.map((entry) => entry?.type === 'content' && entry?.content?.type === 'text'
|
|
147
|
+
? String(entry.content.text || '')
|
|
148
|
+
: '')
|
|
149
|
+
.filter(Boolean)
|
|
150
|
+
.join('\n')
|
|
151
|
+
: '';
|
|
152
|
+
}
|
|
153
|
+
function formatToolProgressMessage(input) {
|
|
154
|
+
const detail = [input.title, input.status, input.content].filter(Boolean).join(' - ');
|
|
155
|
+
return input.toolName ? `🔧 ${input.toolName}: ${detail || 'Tool update'}` : `🔧 ${detail || 'Tool update'}`;
|
|
156
|
+
}
|
|
157
|
+
function resolveToolUpdateDisplayTitle(input) {
|
|
158
|
+
const title = input.title.trim();
|
|
159
|
+
if (input.priorDetail && (isTerminalToolStatus(input.status) || /^tool update$/i.test(title))) {
|
|
160
|
+
return input.priorDetail;
|
|
161
|
+
}
|
|
162
|
+
if (isTerminalToolStatus(input.status) && /^tool update$/i.test(title)) {
|
|
163
|
+
return '';
|
|
164
|
+
}
|
|
165
|
+
return input.title;
|
|
166
|
+
}
|
|
167
|
+
function isEmptyRunningToolUpdate(input) {
|
|
168
|
+
return !input.content.trim() &&
|
|
169
|
+
/^running$/i.test(input.status) &&
|
|
170
|
+
(!input.title.trim() || /^tool update$/i.test(input.title));
|
|
171
|
+
}
|
|
172
|
+
function isTerminalToolStatus(status) {
|
|
173
|
+
return /^(completed|failed|error|cancelled|canceled)$/i.test(status.trim());
|
|
174
|
+
}
|
|
175
|
+
function formatPlanProgress(entries) {
|
|
176
|
+
const summary = entries
|
|
177
|
+
.map((entry) => String(entry?.content || '').trim())
|
|
178
|
+
.filter(Boolean)
|
|
179
|
+
.join(' | ');
|
|
180
|
+
return summary ? `💭 ${summary}` : '';
|
|
181
|
+
}
|
|
182
|
+
function extractToolCallKey(update) {
|
|
183
|
+
for (const key of ['toolCallId', 'tool_call_id', 'callId', 'call_id', 'invocationId', 'invocation_id', 'id']) {
|
|
184
|
+
const value = update[key];
|
|
185
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
186
|
+
const normalized = String(value).trim();
|
|
187
|
+
if (normalized) {
|
|
188
|
+
return normalized;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return '';
|
|
193
|
+
}
|
|
194
|
+
function extractToolCallInput(update) {
|
|
195
|
+
for (const key of ['input', 'parameters', 'arguments', 'args', 'rawInput']) {
|
|
196
|
+
if (Object.prototype.hasOwnProperty.call(update, key)) {
|
|
197
|
+
return update[key];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LocalCoreAcpResponseProcessor = void 0;
|
|
4
4
|
const cron_command_detector_js_1 = require("../scheduler/cron-command-detector.js");
|
|
5
|
+
const job_id_js_1 = require("../scheduler/job-id.js");
|
|
5
6
|
class LocalCoreAcpResponseProcessor {
|
|
6
7
|
options;
|
|
7
8
|
constructor(options) {
|
|
@@ -82,7 +83,7 @@ class LocalCoreAcpResponseProcessor {
|
|
|
82
83
|
scheduleDescription: command.scheduleDescription,
|
|
83
84
|
message: command.message,
|
|
84
85
|
});
|
|
85
|
-
return `已创建定时任务:${job.description || command.name},计划 ${command.scheduleDescription}(${command.schedule}),ID: ${job.id}`;
|
|
86
|
+
return `已创建定时任务:${job.description || command.name},计划 ${command.scheduleDescription}(${command.schedule}),ID: ${(0, job_id_js_1.toPublicScheduledJobId)(job.id)}`;
|
|
86
87
|
}
|
|
87
88
|
case 'list': {
|
|
88
89
|
const jobs = await this.options.scheduler.listJobsForThread(threadId);
|
|
@@ -91,7 +92,7 @@ class LocalCoreAcpResponseProcessor {
|
|
|
91
92
|
}
|
|
92
93
|
return [
|
|
93
94
|
'当前对话定时任务:',
|
|
94
|
-
...jobs.map((job) => `- ${job.description || job.id} | ${job.triggerType === 'cron' ? job.cronExpr : job.runAt} | ${job.enabled ? 'enabled' : 'disabled'} | ${job.id}`),
|
|
95
|
+
...jobs.map((job) => `- ${job.description || (0, job_id_js_1.toPublicScheduledJobId)(job.id)} | ${job.triggerType === 'cron' ? job.cronExpr : job.runAt} | ${job.enabled ? 'enabled' : 'disabled'} | ${(0, job_id_js_1.toPublicScheduledJobId)(job.id)}`),
|
|
95
96
|
].join('\n');
|
|
96
97
|
}
|
|
97
98
|
case 'delete': {
|
|
@@ -68,6 +68,7 @@ class LocalCoreAcpSessionCoordinator {
|
|
|
68
68
|
const created = await this.options.transport.request(session, 'session/new', {
|
|
69
69
|
cwd: config.workDir,
|
|
70
70
|
mcpServers: [],
|
|
71
|
+
_meta: this.buildSessionMeta(threadId),
|
|
71
72
|
}, 30000);
|
|
72
73
|
session.sessionId = String(created.sessionId || created.session_id || created.id || created.session?.sessionId || created.session?.session_id || created.session?.id || '').trim();
|
|
73
74
|
if (!session.sessionId) {
|
|
@@ -82,6 +83,16 @@ class LocalCoreAcpSessionCoordinator {
|
|
|
82
83
|
}
|
|
83
84
|
return session;
|
|
84
85
|
}
|
|
86
|
+
async setThreadMode(threadId, mode) {
|
|
87
|
+
const session = this.sessions.get(threadId);
|
|
88
|
+
if (!session || session.closed || !session.sessionId) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
await this.options.transport.request(session, 'session/set_mode', {
|
|
92
|
+
sessionId: session.sessionId,
|
|
93
|
+
modeId: mode,
|
|
94
|
+
}, 30000);
|
|
95
|
+
}
|
|
85
96
|
async interruptRun(runId) {
|
|
86
97
|
const threadId = this.options.runThreadMap.get(runId);
|
|
87
98
|
if (!threadId) {
|
|
@@ -154,6 +165,10 @@ class LocalCoreAcpSessionCoordinator {
|
|
|
154
165
|
LOCAL_AI_WORKSPACE_ID: row.workspace_id,
|
|
155
166
|
LOCAL_AI_THREAD_ID: threadId,
|
|
156
167
|
};
|
|
168
|
+
const workspace = this.options.store.getWorkspaceRegistryEntry(row.workspace_id);
|
|
169
|
+
if (workspace?.path) {
|
|
170
|
+
env.LOCAL_AI_WORKSPACE_PATH = workspace.path;
|
|
171
|
+
}
|
|
157
172
|
if (binding) {
|
|
158
173
|
env.LOCAL_AI_PLATFORM = binding.platform;
|
|
159
174
|
env.LOCAL_AI_ROUTE_TYPE = 'lark_chat';
|
|
@@ -167,5 +182,19 @@ class LocalCoreAcpSessionCoordinator {
|
|
|
167
182
|
}
|
|
168
183
|
return env;
|
|
169
184
|
}
|
|
185
|
+
buildSessionMeta(threadId) {
|
|
186
|
+
const row = this.options.store.getThreadRow(threadId);
|
|
187
|
+
const mode = String(row?.agent_mode || '').trim();
|
|
188
|
+
if (!mode || mode === 'default') {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
claudeCode: {
|
|
193
|
+
options: {
|
|
194
|
+
permissionMode: mode,
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
170
199
|
}
|
|
171
200
|
exports.LocalCoreAcpSessionCoordinator = LocalCoreAcpSessionCoordinator;
|