@kafca/agentdock 0.1.56 → 0.1.58
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 +7 -0
- package/dist/renderer/assets/{Badge-DjcoXx2J.js → Badge-BfY1VaHS.js} +1 -1
- package/dist/renderer/assets/Card-DWA_Tww_.js +1 -0
- package/dist/renderer/assets/Config-nHj3g1U5.js +21 -0
- package/dist/renderer/assets/CronList-BwkA_I7v.js +1 -0
- package/dist/renderer/assets/Dashboard-D0_A7k02.js +41 -0
- package/dist/renderer/assets/{EmptyState-DIZLiccW.js → EmptyState-zatDjLj_.js} +1 -1
- package/dist/renderer/assets/HighlightedMarkdown-CsM5n70d.js +12 -0
- package/dist/renderer/assets/Input-R1XdFK1K.js +1 -0
- package/dist/renderer/assets/{KnowledgeDetail-CJ9IYOsa.js → KnowledgeDetail-Co5sxeGd.js} +2 -2
- package/dist/renderer/assets/{KnowledgeHome-BLGPwnBO.js → KnowledgeHome-DwziPw5m.js} +3 -3
- package/dist/renderer/assets/Logs-NwZUtR_G.js +6 -0
- package/dist/renderer/assets/{Modal-CQiUpfl4.js → Modal-CrcIwIFL.js} +3 -3
- package/dist/renderer/assets/MonitorList-CS1uLS5A.js +1 -0
- package/dist/renderer/assets/Page-Dp0obeSw.js +1 -0
- package/dist/renderer/assets/{Select-D6z65IT3.js → Select-6mVQaf84.js} +2 -2
- package/dist/renderer/assets/ThreadChat-BFzbn3L6.js +86 -0
- package/dist/renderer/assets/Workspace-DCmo8BMm.js +19 -0
- package/dist/renderer/assets/{arrow-left-CV5cL3f4.js → arrow-left-9rjg_Hp4.js} +1 -1
- package/dist/renderer/assets/{book-open-DThvB7pj.js → book-open-Bu8GCHnG.js} +1 -1
- package/dist/renderer/assets/channels-BxVbG-6j.js +6 -0
- package/dist/renderer/assets/chevron-down-BE8uQmWM.js +11 -0
- package/dist/renderer/assets/index-B7TeF6Es.js +41 -0
- package/dist/renderer/assets/index-BIKL3fTP.css +11 -0
- package/dist/renderer/assets/index-BkI9POxj.js +167 -0
- package/dist/renderer/assets/knowledge-Kl19SqGS.js +1 -0
- package/dist/renderer/assets/{pencil-Dv5WxhdC.js → pencil-CPB7SK1m.js} +1 -1
- package/dist/renderer/assets/{play-DnCnft83.js → play-DGAO4OCu.js} +1 -1
- package/dist/renderer/assets/{plus-DsxIagzS.js → plus-Bt26z-4q.js} +1 -1
- package/dist/renderer/assets/{save-CST01lIc.js → save-Une7GMxT.js} +1 -1
- package/dist/renderer/assets/{search-B_bqy6Wd.js → search-DE0agJjJ.js} +1 -1
- package/dist/renderer/assets/{shield-check-D6lG5Aoc.js → shield-check-De7xaXZh.js} +1 -1
- package/dist/renderer/assets/threads-BnsNL5ei.js +1 -0
- package/dist/renderer/assets/{trash-2-Cefngb6Q.js → trash-2-6iGF59Ac.js} +1 -1
- package/dist/renderer/index.html +2 -2
- package/dist-electron/packages/contracts/src/automation.js +2 -0
- package/dist-electron/packages/contracts/src/channels.js +2 -0
- package/dist-electron/packages/contracts/src/knowledge.js +2 -0
- package/dist-electron/packages/contracts/src/local-core.js +15 -0
- package/dist-electron/packages/contracts/src/runtime.js +2 -0
- package/dist-electron/packages/contracts/src/scheduler.js +2 -0
- package/dist-electron/packages/contracts/src/threads.js +2 -0
- package/dist-electron/packages/core-sdk/src/automation.js +32 -0
- package/dist-electron/packages/core-sdk/src/channels.js +121 -0
- package/dist-electron/packages/core-sdk/src/client.js +455 -0
- package/dist-electron/packages/core-sdk/src/index.js +43 -607
- package/dist-electron/packages/core-sdk/src/knowledge.js +85 -0
- package/dist-electron/packages/core-sdk/src/request.js +22 -0
- package/dist-electron/packages/core-sdk/src/runtime.js +214 -0
- package/dist-electron/packages/core-sdk/src/scheduler.js +32 -0
- package/dist-electron/packages/core-sdk/src/threads.js +67 -0
- package/dist-electron/packages/plugin-sdk/src/agents.js +2 -0
- package/dist-electron/packages/plugin-sdk/src/automation.js +2 -0
- package/dist-electron/packages/plugin-sdk/src/channels.js +2 -0
- package/dist-electron/packages/plugin-sdk/src/index.js +21 -0
- package/dist-electron/packages/plugin-sdk/src/knowledge.js +2 -0
- package/dist-electron/packages/plugin-sdk/src/runtime.js +2 -0
- package/dist-electron/packages/plugin-sdk/src/scheduler.js +2 -0
- package/dist-electron/packages/plugin-sdk/src/threads.js +2 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-backend.js +5 -8
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-content.js +2 -2
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-turn-coordinator.js +3 -3
- package/dist-electron/services/local-ai-core/src/acp/store/agent-task-store.js +5 -5
- package/dist-electron/services/local-ai-core/src/acp/store/automation-monitor-store.js +12 -12
- package/dist-electron/services/local-ai-core/src/acp/store/local-core-acp-store.js +2 -2
- package/dist-electron/services/local-ai-core/src/acp/store/scheduler-store.js +11 -11
- package/dist-electron/services/local-ai-core/src/acp/store/security-store.js +3 -3
- package/dist-electron/services/local-ai-core/src/acp/store/thread-store.js +7 -7
- package/dist-electron/services/local-ai-core/src/acp/workspace-acp-permissions.js +2 -2
- package/dist-electron/services/local-ai-core/src/agents/claudecode/definition.js +3 -3
- package/dist-electron/services/local-ai-core/src/agents/codex/definition.js +3 -3
- package/dist-electron/services/local-ai-core/src/agents/localcore-acp/definition.js +2 -2
- package/dist-electron/services/local-ai-core/src/agents/localcore-acp/index.js +4 -4
- package/dist-electron/services/local-ai-core/src/agents/opencode/launch.js +2 -2
- package/dist-electron/services/local-ai-core/src/agents/pi/definition.js +2 -2
- package/dist-electron/services/local-ai-core/src/agents/pi/launch.js +3 -3
- package/dist-electron/services/local-ai-core/src/agents/pi/provider-materializer.js +1 -1
- package/dist-electron/services/local-ai-core/src/agents/shared/agent-plugin.js +4 -4
- package/dist-electron/services/local-ai-core/src/automation/automation-conversation-executor.js +6 -47
- package/dist-electron/services/local-ai-core/src/automation/automation-monitor-service.js +2 -5
- package/dist-electron/services/local-ai-core/src/channel/lark/cards.js +33 -18
- package/dist-electron/services/local-ai-core/src/channel/lark/config.js +2 -2
- package/dist-electron/services/local-ai-core/src/channel/lark/gateway-utils.js +91 -0
- package/dist-electron/services/local-ai-core/src/channel/lark/inbound-handler.js +180 -0
- package/dist-electron/services/local-ai-core/src/channel/lark/local-core-lark-gateway.js +58 -539
- package/dist-electron/services/local-ai-core/src/channel/lark/outbound-transport.js +112 -0
- package/dist-electron/services/local-ai-core/src/channel/lark/runtime-state.js +5 -20
- package/dist-electron/services/local-ai-core/src/channel/shared/base-channel-gateway.js +37 -0
- package/dist-electron/services/local-ai-core/src/channel/shared/bridge-event-helpers.js +23 -0
- package/dist-electron/services/local-ai-core/src/channel/shared/channel-keys.js +6 -0
- package/dist-electron/services/local-ai-core/src/channel/shared/inbound-authorization.js +54 -0
- package/dist-electron/services/local-ai-core/src/channel/weixin/config.js +2 -2
- package/dist-electron/services/local-ai-core/src/channel/weixin/inbound-media.js +21 -0
- package/dist-electron/services/local-ai-core/src/channel/weixin/inbound-poller.js +167 -0
- package/dist-electron/services/local-ai-core/src/channel/weixin/local-core-weixin-gateway.js +55 -512
- package/dist-electron/services/local-ai-core/src/channel/weixin/runtime-state.js +149 -0
- package/dist-electron/services/local-ai-core/src/channel/weixin/text-utils.js +92 -0
- package/dist-electron/services/local-ai-core/src/cli/lac.js +9 -11
- package/dist-electron/services/local-ai-core/src/cli/monitor-cli-parsers.js +2 -2
- package/dist-electron/services/local-ai-core/src/kernel/bootstrap.js +28 -70
- package/dist-electron/services/local-ai-core/src/kernel/local-core-errors.js +8 -0
- package/dist-electron/services/local-ai-core/src/plugins/builtin/knowledge-ai-vector-plugin.js +2 -2
- package/dist-electron/services/local-ai-core/src/plugins/builtin/knowledge-noop-plugin.js +2 -2
- package/dist-electron/services/local-ai-core/src/router/workspace-bridge-event-stream.js +29 -0
- package/dist-electron/services/local-ai-core/src/router/workspace-route-config.js +5 -5
- package/dist-electron/services/local-ai-core/src/router/workspace-router.js +47 -60
- package/dist-electron/services/local-ai-core/src/runtime/agent-runtime-detector.js +5 -5
- package/dist-electron/services/local-ai-core/src/runtime/config-migration.js +6 -6
- package/dist-electron/services/local-ai-core/src/runtime/deployment-diagnostics.js +3 -3
- package/dist-electron/services/local-ai-core/src/runtime/external-service.js +3 -1
- package/dist-electron/services/local-ai-core/src/runtime/handlers/automation-handler.js +11 -2
- package/dist-electron/services/local-ai-core/src/runtime/handlers/channel-handler.js +12 -6
- package/dist-electron/services/local-ai-core/src/runtime/handlers/external-handler.js +10 -2
- package/dist-electron/services/local-ai-core/src/runtime/handlers/knowledge-handler.js +18 -6
- package/dist-electron/services/local-ai-core/src/runtime/handlers/provider-handler.js +7 -2
- package/dist-electron/services/local-ai-core/src/runtime/handlers/runtime-handler.js +28 -3
- package/dist-electron/services/local-ai-core/src/runtime/handlers/scheduler-handler.js +10 -2
- package/dist-electron/services/local-ai-core/src/runtime/handlers/security-handler.js +18 -5
- package/dist-electron/services/local-ai-core/src/runtime/handlers/task-handler.js +14 -2
- package/dist-electron/services/local-ai-core/src/runtime/handlers/thread-handler.js +18 -15
- package/dist-electron/services/local-ai-core/src/runtime/handlers/workspace-handler.js +13 -2
- package/dist-electron/services/local-ai-core/src/runtime/local-core-controller.js +35 -8
- package/dist-electron/services/local-ai-core/src/runtime/request-validation.js +79 -0
- package/dist-electron/services/local-ai-core/src/runtime/runtime-detection-service.js +9 -9
- package/dist-electron/services/local-ai-core/src/runtime/server-helpers.js +10 -1
- package/dist-electron/services/local-ai-core/src/runtime/server.js +2 -1
- package/dist-electron/services/local-ai-core/src/runtime/workspace-project-registry.js +76 -0
- package/dist-electron/services/local-ai-core/src/sandbox/opensandbox-client.js +3 -2
- package/dist-electron/services/local-ai-core/src/sandbox/sandbox-config.js +8 -8
- package/dist-electron/services/local-ai-core/src/scheduler/base-channel-schedule-adapter.js +77 -0
- package/dist-electron/services/local-ai-core/src/scheduler/lark-schedule-adapter.js +13 -79
- package/dist-electron/services/local-ai-core/src/scheduler/local-schedule-adapter.js +2 -10
- package/dist-electron/services/local-ai-core/src/scheduler/run-polling.js +19 -0
- package/dist-electron/services/local-ai-core/src/scheduler/scheduled-conversation-executor.js +3 -37
- package/dist-electron/services/local-ai-core/src/scheduler/scheduled-job-route.js +20 -0
- package/dist-electron/services/local-ai-core/src/scheduler/scheduler-service.js +15 -28
- package/dist-electron/services/local-ai-core/src/scheduler/thread-resolution.js +12 -0
- package/dist-electron/services/local-ai-core/src/scheduler/weixin-schedule-adapter.js +13 -79
- package/dist-electron/services/local-ai-core/src/thread/agent-message-policy.js +75 -0
- package/dist-electron/shared/desktop.js +1 -64
- package/dist-electron/src/components/chat/chat-controller-state.js +60 -0
- package/dist-electron/src/components/chat/chat-event-gate.js +146 -0
- package/dist-electron/src/components/chat/markdown-code-block.js +8 -0
- package/dist-electron/src/pages/Desktop/workspace-model.js +212 -0
- package/dist-electron/src/pages/Threads/thread-chat-model.js +50 -51
- package/dist-electron/tests/contracts/agent-message-policy.test.js +21 -0
- package/dist-electron/tests/contracts/architecture-docs.test.js +56 -33
- package/dist-electron/tests/contracts/chat-event-gate.test.js +114 -0
- package/dist-electron/tests/contracts/chat-markdown.test.js +16 -0
- package/dist-electron/tests/contracts/thread-task-state.test.js +32 -0
- package/dist-electron/tests/contracts/workspace-identity.test.js +23 -0
- package/dist-electron/tests/electron/core-client.test.js +284 -0
- package/dist-electron/tests/electron/plugin-kernel.test.js +54 -0
- package/dist-electron/tests/electron/renderer-packaging.test.js +9 -0
- package/dist-electron/tests/electron/workspace-task-store.test.js +31 -0
- package/dist-electron/tests/integration/channel-inbound-authorization.test.js +80 -0
- package/dist-electron/tests/integration/lark-gateway-utils.test.js +13 -0
- package/dist-electron/tests/integration/lark-gateway.test.js +4 -4
- package/dist-electron/tests/integration/local-core-refactor.test.js +15 -8
- package/dist-electron/tests/integration/weixin-runtime-state.test.js +32 -0
- package/dist-electron/tests/integration/weixin-text-utils.test.js +15 -0
- package/package.json +9 -4
- package/dist/renderer/assets/Chat-C5Bkm9-M.js +0 -2
- package/dist/renderer/assets/ChatMarkdown-uc36EzyD.js +0 -45
- package/dist/renderer/assets/Config-DHtQuuLy.js +0 -21
- package/dist/renderer/assets/CronList-BYUnhzSC.js +0 -1
- package/dist/renderer/assets/Dashboard-BPnGMDg3.js +0 -26
- package/dist/renderer/assets/Logs-Dyd2Uwlt.js +0 -1
- package/dist/renderer/assets/MonitorList-Byg3E3Gt.js +0 -1
- package/dist/renderer/assets/Page-7DxXvTMm.js +0 -1
- package/dist/renderer/assets/ProjectDetail-Dfr5s0Ja.js +0 -11
- package/dist/renderer/assets/ProjectList-CDDQjAQ_.js +0 -1
- package/dist/renderer/assets/SessionChat-s7CAaCPL.js +0 -1
- package/dist/renderer/assets/SessionList-D-OycKKS.js +0 -1
- package/dist/renderer/assets/ThreadChat-CLdFynB5.js +0 -28
- package/dist/renderer/assets/Workspace-xfT5z4j_.js +0 -19
- package/dist/renderer/assets/bot-CWQ5-ovl.js +0 -6
- package/dist/renderer/assets/check-DKM7zfWG.js +0 -6
- package/dist/renderer/assets/chevron-down-Dfw2KU87.js +0 -6
- package/dist/renderer/assets/circle-CoP4RA4s.js +0 -6
- package/dist/renderer/assets/desktop-CsDYrOOU.js +0 -1
- package/dist/renderer/assets/desktop-JQkhNOF4.js +0 -5
- package/dist/renderer/assets/funnel-DpVLlG3g.js +0 -6
- package/dist/renderer/assets/heart-BMD36ejP.js +0 -6
- package/dist/renderer/assets/index-COxSYBjE.js +0 -182
- package/dist/renderer/assets/index-CTGTI-cm.js +0 -41
- package/dist/renderer/assets/index-CjCuR6DI.css +0 -11
- package/dist/renderer/assets/projects-DgjHcNgt.js +0 -1
- package/dist/renderer/assets/server-ecH4GNwa.js +0 -11
- package/dist/renderer/assets/session-utils-Dd_WKMYW.js +0 -6
- package/dist/renderer/assets/sessions-BQ33Mv4k.js +0 -1
- package/dist/renderer/assets/user-D_8RSH-T.js +0 -6
- package/dist/renderer/assets/wifi-off-DB9D-pOu.js +0 -11
- package/dist-electron/services/local-ai-core/src/scheduler/lark-execution-policies.js +0 -13
- package/dist-electron/services/local-ai-core/src/scheduler/weixin-execution-policies.js +0 -13
- package/dist-electron/src/api/client.js +0 -73
- package/dist-electron/src/api/sessions.js +0 -21
- package/dist-electron/src/lib/session-utils.js +0 -51
- package/dist-electron/src/pages/Projects/project-provider-config.js +0 -75
- package/dist-electron/tests/electron/project-provider-config.test.js +0 -71
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWeixinTurnState = createWeixinTurnState;
|
|
4
|
+
exports.getOrCreateWeixinTurnState = getOrCreateWeixinTurnState;
|
|
5
|
+
exports.consumeWeixinBridgeEvent = consumeWeixinBridgeEvent;
|
|
6
|
+
exports.renderWeixinTurnText = renderWeixinTurnText;
|
|
7
|
+
exports.isTerminalWeixinBridgeMessage = isTerminalWeixinBridgeMessage;
|
|
8
|
+
const bridge_event_helpers_js_1 = require("../shared/bridge-event-helpers.js");
|
|
9
|
+
function renderBridgeContent(event) {
|
|
10
|
+
const toolCall = event.toolCall;
|
|
11
|
+
if (!toolCall) {
|
|
12
|
+
return String(event.content || '').trim();
|
|
13
|
+
}
|
|
14
|
+
const name = String(toolCall.name || '').trim() || 'Tool update';
|
|
15
|
+
const status = String(toolCall.status || '').trim();
|
|
16
|
+
if (name === 'Tool update' && status === 'completed')
|
|
17
|
+
return '';
|
|
18
|
+
return [name, status].filter(Boolean).join(' - ');
|
|
19
|
+
}
|
|
20
|
+
function pushUnique(target, value) {
|
|
21
|
+
(0, bridge_event_helpers_js_1.pushUniqueLine)(target, value, 8);
|
|
22
|
+
}
|
|
23
|
+
function flushPendingThought(turn) {
|
|
24
|
+
const text = String(turn.pendingThoughtText || '').trim();
|
|
25
|
+
if (!text)
|
|
26
|
+
return;
|
|
27
|
+
pushUnique(turn.thinkingSteps, text);
|
|
28
|
+
turn.pendingThoughtText = undefined;
|
|
29
|
+
}
|
|
30
|
+
function createWeixinTurnState(sessionKey) {
|
|
31
|
+
return {
|
|
32
|
+
sessionKey,
|
|
33
|
+
sentCount: 0,
|
|
34
|
+
foldedProgressCount: 0,
|
|
35
|
+
awaitingPermission: false,
|
|
36
|
+
processing: false,
|
|
37
|
+
previewText: '',
|
|
38
|
+
finalText: '',
|
|
39
|
+
thinkingSteps: [],
|
|
40
|
+
pendingThoughtText: undefined,
|
|
41
|
+
statusLines: [],
|
|
42
|
+
buttonRows: [],
|
|
43
|
+
lastSentAt: 0,
|
|
44
|
+
lastSentText: '',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function getOrCreateWeixinTurnState(turns, sessionKey) {
|
|
48
|
+
const existing = turns.get(sessionKey);
|
|
49
|
+
if (existing)
|
|
50
|
+
return existing;
|
|
51
|
+
const turn = createWeixinTurnState(sessionKey);
|
|
52
|
+
turns.set(sessionKey, turn);
|
|
53
|
+
return turn;
|
|
54
|
+
}
|
|
55
|
+
function consumeWeixinBridgeEvent(turn, event) {
|
|
56
|
+
const content = renderBridgeContent(event);
|
|
57
|
+
const bridgeKind = (0, bridge_event_helpers_js_1.resolveBridgeEventKind)(event);
|
|
58
|
+
if (event.type === 'typing_start') {
|
|
59
|
+
Object.assign(turn, {
|
|
60
|
+
processing: true,
|
|
61
|
+
previewText: '',
|
|
62
|
+
finalText: '',
|
|
63
|
+
thinkingSteps: [],
|
|
64
|
+
pendingThoughtText: undefined,
|
|
65
|
+
statusLines: [],
|
|
66
|
+
buttonRows: [],
|
|
67
|
+
});
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (event.type === 'typing_stop') {
|
|
71
|
+
turn.processing = false;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (event.type === 'preview_start' || event.type === 'update_message') {
|
|
75
|
+
if (bridgeKind === 'thought') {
|
|
76
|
+
turn.pendingThoughtText = content;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
turn.previewText = content;
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (bridgeKind !== 'thought')
|
|
84
|
+
flushPendingThought(turn);
|
|
85
|
+
if (event.type === 'status') {
|
|
86
|
+
if (content) {
|
|
87
|
+
pushUnique(turn.statusLines, content);
|
|
88
|
+
turn.finalText = content;
|
|
89
|
+
turn.previewText = content;
|
|
90
|
+
}
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (event.type === 'buttons') {
|
|
94
|
+
turn.awaitingPermission = true;
|
|
95
|
+
turn.buttonRows = Array.isArray(event.buttonRows)
|
|
96
|
+
? event.buttonRows
|
|
97
|
+
.map((row) => Array.isArray(row)
|
|
98
|
+
? row.filter((button) => Boolean(button?.text && button?.data))
|
|
99
|
+
.map((button) => ({ text: button.text, data: button.data }))
|
|
100
|
+
: [])
|
|
101
|
+
.filter((row) => row.length > 0)
|
|
102
|
+
: [];
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (!content)
|
|
106
|
+
return;
|
|
107
|
+
if (bridgeKind === 'thought' || bridgeKind === 'plan') {
|
|
108
|
+
pushUnique(turn.thinkingSteps, content);
|
|
109
|
+
}
|
|
110
|
+
else if (bridgeKind === 'tool' || bridgeKind === 'status') {
|
|
111
|
+
pushUnique(turn.statusLines, content);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
turn.finalText = content;
|
|
115
|
+
turn.previewText = content;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function renderWeixinTurnText(turn) {
|
|
119
|
+
const sections = [];
|
|
120
|
+
if (turn.thinkingSteps.length > 0) {
|
|
121
|
+
sections.push(`**中间过程**\n${turn.thinkingSteps.map((step) => `• ${step.replace(/\s+/g, ' ').trim()}`).join('\n')}`);
|
|
122
|
+
}
|
|
123
|
+
if (turn.finalText) {
|
|
124
|
+
sections.push(turn.finalText);
|
|
125
|
+
}
|
|
126
|
+
else if (turn.previewText) {
|
|
127
|
+
sections.push(turn.previewText);
|
|
128
|
+
}
|
|
129
|
+
else if (turn.statusLines.length > 0) {
|
|
130
|
+
sections.push(`**处理中**\n${turn.statusLines.slice(-3).map((line) => `• ${line.replace(/\s+/g, ' ').trim()}`).join('\n')}`);
|
|
131
|
+
}
|
|
132
|
+
else if (turn.processing) {
|
|
133
|
+
sections.push('**处理中**\n正在思考...');
|
|
134
|
+
}
|
|
135
|
+
if (turn.awaitingPermission) {
|
|
136
|
+
sections.push('\n回复:`allow` / `allow all` / `deny`');
|
|
137
|
+
}
|
|
138
|
+
return sections.join('\n\n').trim();
|
|
139
|
+
}
|
|
140
|
+
function isTerminalWeixinBridgeMessage(event, rendered) {
|
|
141
|
+
if (event.type === 'buttons')
|
|
142
|
+
return true;
|
|
143
|
+
if (event.type !== 'reply')
|
|
144
|
+
return false;
|
|
145
|
+
const kind = (0, bridge_event_helpers_js_1.resolveBridgeEventKind)(event);
|
|
146
|
+
if (kind === 'tool' || kind === 'thought' || kind === 'plan' || kind === 'status')
|
|
147
|
+
return false;
|
|
148
|
+
return Boolean(rendered.trim());
|
|
149
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stripWeixinHtml = stripWeixinHtml;
|
|
4
|
+
exports.waitForWeixinRetry = waitForWeixinRetry;
|
|
5
|
+
exports.utf8ByteLength = utf8ByteLength;
|
|
6
|
+
exports.splitTextByUtf8Bytes = splitTextByUtf8Bytes;
|
|
7
|
+
exports.truncateTextByUtf8Bytes = truncateTextByUtf8Bytes;
|
|
8
|
+
function stripWeixinHtml(html) {
|
|
9
|
+
let result = html;
|
|
10
|
+
let previous;
|
|
11
|
+
do {
|
|
12
|
+
previous = result;
|
|
13
|
+
result = result.replace(/<[^>]*>/g, '');
|
|
14
|
+
} while (result !== previous);
|
|
15
|
+
return result
|
|
16
|
+
.replace(/&/g, '&')
|
|
17
|
+
.replace(/</g, '<')
|
|
18
|
+
.replace(/>/g, '>')
|
|
19
|
+
.replace(/"/g, '"')
|
|
20
|
+
.replace(/'/g, "'")
|
|
21
|
+
.replace(/ /g, ' ');
|
|
22
|
+
}
|
|
23
|
+
function waitForWeixinRetry(ms, signal) {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
const timer = setTimeout(resolve, ms);
|
|
26
|
+
const onAbort = () => {
|
|
27
|
+
clearTimeout(timer);
|
|
28
|
+
reject(new Error('aborted'));
|
|
29
|
+
};
|
|
30
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function utf8ByteLength(value) {
|
|
34
|
+
return Buffer.byteLength(value, 'utf-8');
|
|
35
|
+
}
|
|
36
|
+
function splitTextByUtf8Bytes(text, maxBytes) {
|
|
37
|
+
const normalized = String(text || '').replace(/\r\n/g, '\n').trim();
|
|
38
|
+
if (!normalized)
|
|
39
|
+
return [];
|
|
40
|
+
if (utf8ByteLength(normalized) <= maxBytes)
|
|
41
|
+
return [normalized];
|
|
42
|
+
const chunks = [];
|
|
43
|
+
let current = '';
|
|
44
|
+
const pushCurrent = () => {
|
|
45
|
+
const trimmed = current.trim();
|
|
46
|
+
if (trimmed)
|
|
47
|
+
chunks.push(trimmed);
|
|
48
|
+
current = '';
|
|
49
|
+
};
|
|
50
|
+
const appendPart = (part) => {
|
|
51
|
+
if (!part.trim())
|
|
52
|
+
return;
|
|
53
|
+
const separator = current ? '\n\n' : '';
|
|
54
|
+
if (current && utf8ByteLength(`${current}${separator}${part}`) <= maxBytes) {
|
|
55
|
+
current = `${current}${separator}${part}`;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (current)
|
|
59
|
+
pushCurrent();
|
|
60
|
+
if (utf8ByteLength(part) <= maxBytes) {
|
|
61
|
+
current = part;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
let segment = '';
|
|
65
|
+
for (const character of Array.from(part)) {
|
|
66
|
+
if (segment && utf8ByteLength(`${segment}${character}`) > maxBytes) {
|
|
67
|
+
chunks.push(segment);
|
|
68
|
+
segment = '';
|
|
69
|
+
}
|
|
70
|
+
segment += character;
|
|
71
|
+
}
|
|
72
|
+
current = segment;
|
|
73
|
+
};
|
|
74
|
+
for (const part of normalized.split(/\n{2,}/))
|
|
75
|
+
appendPart(part);
|
|
76
|
+
pushCurrent();
|
|
77
|
+
return chunks;
|
|
78
|
+
}
|
|
79
|
+
function truncateTextByUtf8Bytes(text, maxBytes) {
|
|
80
|
+
const normalized = String(text || '').replace(/\r\n/g, '\n').trim();
|
|
81
|
+
if (utf8ByteLength(normalized) <= maxBytes)
|
|
82
|
+
return normalized;
|
|
83
|
+
const suffix = '\n\n(内容过长,已截断以保证微信送达)';
|
|
84
|
+
const budget = Math.max(0, maxBytes - utf8ByteLength(suffix));
|
|
85
|
+
let result = '';
|
|
86
|
+
for (const character of Array.from(normalized)) {
|
|
87
|
+
if (utf8ByteLength(`${result}${character}`) > budget)
|
|
88
|
+
break;
|
|
89
|
+
result += character;
|
|
90
|
+
}
|
|
91
|
+
return `${result.trim()}${suffix}`;
|
|
92
|
+
}
|
|
@@ -5,11 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.runCli = runCli;
|
|
7
7
|
const node_process_1 = __importDefault(require("node:process"));
|
|
8
|
-
const
|
|
8
|
+
const superai_contracts_1 = require("../../../../packages/contracts/src/index.js");
|
|
9
9
|
const job_id_js_1 = require("../scheduler/job-id.js");
|
|
10
10
|
const scheduled_job_route_js_1 = require("../scheduler/scheduled-job-route.js");
|
|
11
11
|
const monitor_id_js_1 = require("../automation/monitor-id.js");
|
|
12
12
|
const monitor_cli_parsers_js_1 = require("./monitor-cli-parsers.js");
|
|
13
|
+
const local_core_errors_js_1 = require("../kernel/local-core-errors.js");
|
|
13
14
|
const DEFAULT_BASE_URL = 'http://127.0.0.1:9831/api/local/v1';
|
|
14
15
|
async function runCli(argv, env = node_process_1.default.env, io = node_process_1.default) {
|
|
15
16
|
try {
|
|
@@ -69,7 +70,7 @@ async function runCli(argv, env = node_process_1.default.env, io = node_process_
|
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
catch (error) {
|
|
72
|
-
io.stderr.write(`${
|
|
73
|
+
io.stderr.write(`${(0, local_core_errors_js_1.formatSafeError)(error)}\n`);
|
|
73
74
|
return 1;
|
|
74
75
|
}
|
|
75
76
|
}
|
|
@@ -148,7 +149,7 @@ async function handleMonitorEdit(monitorId, flags, env, io, json) {
|
|
|
148
149
|
if (typeof enabled === 'boolean')
|
|
149
150
|
input.enabled = enabled;
|
|
150
151
|
if (executionMode)
|
|
151
|
-
input.executionMode = (0,
|
|
152
|
+
input.executionMode = (0, superai_contracts_1.normalizeScheduledJobExecutionMode)(executionMode);
|
|
152
153
|
if (cooldown)
|
|
153
154
|
input.cooldownMs = (0, monitor_cli_parsers_js_1.parseDurationMs)(cooldown);
|
|
154
155
|
if (Object.keys(input).length === 0) {
|
|
@@ -181,7 +182,7 @@ async function handleChannelSendFile(flags, env, io, json) {
|
|
|
181
182
|
const context = resolveContext(flags, env);
|
|
182
183
|
const filePath = getRequiredFlag(flags, 'path');
|
|
183
184
|
const rawPlatform = getFlag(flags, 'platform') || context.platform;
|
|
184
|
-
const platform = rawPlatform ? (0,
|
|
185
|
+
const platform = rawPlatform ? (0, superai_contracts_1.normalizeChannelPlatform)(rawPlatform) : '';
|
|
185
186
|
if (!platform) {
|
|
186
187
|
throw new Error('channel send-file requires a platform. Set LOCAL_AI_PLATFORM or pass --platform.');
|
|
187
188
|
}
|
|
@@ -284,7 +285,7 @@ async function handleEdit(jobId, flags, env, io, json) {
|
|
|
284
285
|
input.enabled = enabled;
|
|
285
286
|
}
|
|
286
287
|
if (executionMode) {
|
|
287
|
-
input.executionMode = (0,
|
|
288
|
+
input.executionMode = (0, superai_contracts_1.normalizeScheduledJobExecutionMode)(executionMode);
|
|
288
289
|
}
|
|
289
290
|
if (Object.keys(input).length === 0) {
|
|
290
291
|
throw new Error('scheduler edit requires at least one editable field.');
|
|
@@ -324,7 +325,7 @@ async function request(baseUrl, method, path, body) {
|
|
|
324
325
|
});
|
|
325
326
|
}
|
|
326
327
|
catch (error) {
|
|
327
|
-
throw new Error(`Local AI Core is unavailable at ${baseUrl}: ${
|
|
328
|
+
throw new Error(`Local AI Core is unavailable at ${baseUrl}: ${(0, local_core_errors_js_1.formatSafeError)(error)}`);
|
|
328
329
|
}
|
|
329
330
|
const payload = await response.json();
|
|
330
331
|
if (!response.ok || !payload.ok) {
|
|
@@ -406,10 +407,10 @@ function normalizeMaybeBooleanFlag(value) {
|
|
|
406
407
|
return value === 'true' ? '' : value;
|
|
407
408
|
}
|
|
408
409
|
function getExecutionMode(flags) {
|
|
409
|
-
return (0,
|
|
410
|
+
return (0, superai_contracts_1.normalizeScheduledJobExecutionMode)(getFlag(flags, 'execution-mode'));
|
|
410
411
|
}
|
|
411
412
|
function getMonitorExecutionMode(flags) {
|
|
412
|
-
return (0,
|
|
413
|
+
return (0, superai_contracts_1.normalizeScheduledJobExecutionMode)(getFlag(flags, 'execution-mode') || 'side-thread');
|
|
413
414
|
}
|
|
414
415
|
function buildSourceConfig(sourceType, flags) {
|
|
415
416
|
const config = {};
|
|
@@ -517,9 +518,6 @@ function monitorMatchesCliContext(monitor, context) {
|
|
|
517
518
|
updatedAt: monitor.updatedAt,
|
|
518
519
|
}, context);
|
|
519
520
|
}
|
|
520
|
-
function formatError(error) {
|
|
521
|
-
return error instanceof Error ? error.message : String(error);
|
|
522
|
-
}
|
|
523
521
|
void (async () => {
|
|
524
522
|
if (require.main !== module) {
|
|
525
523
|
return;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseMonitorCondition = parseMonitorCondition;
|
|
4
4
|
exports.parseDurationMs = parseDurationMs;
|
|
5
|
-
const
|
|
5
|
+
const superai_contracts_1 = require("../../../../packages/contracts/src/index.js");
|
|
6
6
|
function parseMonitorCondition(value) {
|
|
7
7
|
const expression = String(value || '').trim();
|
|
8
8
|
if (expression.includes('&&') || expression.includes('||')) {
|
|
@@ -21,7 +21,7 @@ function parseMonitorCondition(value) {
|
|
|
21
21
|
const numeric = Number(rawValue);
|
|
22
22
|
return {
|
|
23
23
|
metric: String(match[1] || '').trim(),
|
|
24
|
-
operator: (0,
|
|
24
|
+
operator: (0, superai_contracts_1.normalizeAutomationMonitorConditionOperator)(match[2]),
|
|
25
25
|
value: Number.isFinite(numeric) && rawValue !== '' ? numeric : rawValue,
|
|
26
26
|
};
|
|
27
27
|
}
|
|
@@ -28,17 +28,7 @@ function bootstrapLocalCoreKernel(options) {
|
|
|
28
28
|
};
|
|
29
29
|
const lifecycle = new lifecycle_manager_js_1.LocalCoreLifecycleManager(plugins, context);
|
|
30
30
|
const diagnostics = new diagnostics_js_1.LocalCoreDiagnostics(plugins, lifecycle);
|
|
31
|
-
|
|
32
|
-
plugins.register(plugin);
|
|
33
|
-
options?.log?.(`[plugin:${plugin.manifest.id}] registered`);
|
|
34
|
-
if (plugin.capabilities && plugins.isEnabled(plugin.manifest.id)) {
|
|
35
|
-
logCapabilityContributions(plugin, options?.log);
|
|
36
|
-
capabilities.registerContributions(plugin.capabilities);
|
|
37
|
-
}
|
|
38
|
-
else if (!plugins.isEnabled(plugin.manifest.id)) {
|
|
39
|
-
options?.log?.(`[plugin:${plugin.manifest.id}] disabled by runtime settings`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
31
|
+
registerPluginSet(plugins, capabilities, context, (0, catalog_js_1.createKernelBuiltinPlugins)());
|
|
42
32
|
return {
|
|
43
33
|
context,
|
|
44
34
|
plugins,
|
|
@@ -77,14 +67,19 @@ function bootstrapLocalCoreKernel(options) {
|
|
|
77
67
|
};
|
|
78
68
|
}
|
|
79
69
|
function registerPlugin(kernel, plugin) {
|
|
80
|
-
kernel.plugins.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
70
|
+
registerPluginSet(kernel.plugins, kernel.capabilities, kernel.context, [plugin]);
|
|
71
|
+
}
|
|
72
|
+
function registerPluginSet(plugins, capabilities, context, pluginSet) {
|
|
73
|
+
for (const plugin of pluginSet) {
|
|
74
|
+
plugins.register(plugin);
|
|
75
|
+
context.logger.log(`[plugin:${plugin.manifest.id}] registered`);
|
|
76
|
+
if (plugin.capabilities && plugins.isEnabled(plugin.manifest.id)) {
|
|
77
|
+
logCapabilityContributions(plugin, context.logger.log);
|
|
78
|
+
capabilities.registerContributions(plugin.capabilities);
|
|
79
|
+
}
|
|
80
|
+
else if (!plugins.isEnabled(plugin.manifest.id)) {
|
|
81
|
+
context.logger.log(`[plugin:${plugin.manifest.id}] disabled by runtime settings`);
|
|
82
|
+
}
|
|
88
83
|
}
|
|
89
84
|
}
|
|
90
85
|
function logCapabilityContributions(plugin, log) {
|
|
@@ -103,55 +98,18 @@ function logCapabilityContributions(plugin, log) {
|
|
|
103
98
|
log(`[plugin:${plugin.manifest.id}][capability:${capabilityId}] registered`);
|
|
104
99
|
}
|
|
105
100
|
}
|
|
106
|
-
function
|
|
107
|
-
if (!plugin.createRuntime) {
|
|
108
|
-
throw new Error(`Knowledge plugin ${plugin.manifest.id} does not provide a runtime factory.`);
|
|
109
|
-
}
|
|
110
|
-
const runtime = plugin.createRuntime(context);
|
|
111
|
-
if (runtime instanceof Promise) {
|
|
112
|
-
throw new Error(`Knowledge plugin ${plugin.manifest.id} returned an async runtime factory during synchronous bootstrap.`);
|
|
113
|
-
}
|
|
114
|
-
return runtime;
|
|
115
|
-
}
|
|
116
|
-
function resolveChannelRuntime(plugin, context) {
|
|
101
|
+
function resolveRuntime(plugin, context) {
|
|
117
102
|
if (!plugin.createRuntime) {
|
|
118
|
-
throw new Error(`
|
|
103
|
+
throw new Error(`Plugin ${plugin.manifest.id} does not provide a runtime factory.`);
|
|
119
104
|
}
|
|
120
105
|
const runtime = plugin.createRuntime(context);
|
|
121
106
|
if (runtime instanceof Promise) {
|
|
122
|
-
throw new Error(`
|
|
107
|
+
throw new Error(`Plugin ${plugin.manifest.id} returned an async runtime factory during synchronous bootstrap.`);
|
|
123
108
|
}
|
|
124
109
|
return runtime;
|
|
125
110
|
}
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
throw new Error(`Agent plugin ${plugin.manifest.id} does not provide a runtime factory.`);
|
|
129
|
-
}
|
|
130
|
-
const runtime = plugin.createRuntime(context);
|
|
131
|
-
if (runtime instanceof Promise) {
|
|
132
|
-
throw new Error(`Agent plugin ${plugin.manifest.id} returned an async runtime factory during synchronous bootstrap.`);
|
|
133
|
-
}
|
|
134
|
-
return runtime;
|
|
135
|
-
}
|
|
136
|
-
function resolveSchedulerRuntime(plugin, context) {
|
|
137
|
-
if (!plugin.createRuntime) {
|
|
138
|
-
throw new Error(`Scheduler plugin ${plugin.manifest.id} does not provide a runtime factory.`);
|
|
139
|
-
}
|
|
140
|
-
const runtime = plugin.createRuntime(context);
|
|
141
|
-
if (runtime instanceof Promise) {
|
|
142
|
-
throw new Error(`Scheduler plugin ${plugin.manifest.id} returned an async runtime factory during synchronous bootstrap.`);
|
|
143
|
-
}
|
|
144
|
-
return runtime;
|
|
145
|
-
}
|
|
146
|
-
function resolveMonitorRuntime(plugin, context) {
|
|
147
|
-
if (!plugin.createRuntime) {
|
|
148
|
-
throw new Error(`Monitor plugin ${plugin.manifest.id} does not provide a runtime factory.`);
|
|
149
|
-
}
|
|
150
|
-
const runtime = plugin.createRuntime(context);
|
|
151
|
-
if (runtime instanceof Promise) {
|
|
152
|
-
throw new Error(`Monitor plugin ${plugin.manifest.id} returned an async runtime factory during synchronous bootstrap.`);
|
|
153
|
-
}
|
|
154
|
-
return runtime;
|
|
111
|
+
function isAgentPlugin(plugin) {
|
|
112
|
+
return Boolean(plugin && (plugin.manifest.kind === 'agent' || plugin.manifest.kind === 'composite'));
|
|
155
113
|
}
|
|
156
114
|
function bootstrapLocalCoreRuntime(options) {
|
|
157
115
|
const state = (0, local_core_runtime_state_js_1.createLocalCoreRuntimeState)({
|
|
@@ -167,7 +125,7 @@ function bootstrapLocalCoreRuntime(options) {
|
|
|
167
125
|
});
|
|
168
126
|
const store = new local_core_acp_store_js_1.LocalCoreAcpStore(options.userDataPath);
|
|
169
127
|
const localCoreAgentPlugin = kernel.plugins.get('builtin.agent-localcore-acp');
|
|
170
|
-
if (!localCoreAgentPlugin) {
|
|
128
|
+
if (!isAgentPlugin(localCoreAgentPlugin)) {
|
|
171
129
|
throw new Error('Missing built-in LocalCore ACP agent plugin.');
|
|
172
130
|
}
|
|
173
131
|
const agentPlugins = (0, catalog_js_1.createRuntimeAgentPlugins)(localCoreAgentPlugin);
|
|
@@ -209,30 +167,30 @@ function bootstrapLocalCoreRuntime(options) {
|
|
|
209
167
|
}
|
|
210
168
|
const agentRuntimes = agentPlugins
|
|
211
169
|
.filter((plugin) => kernel.plugins.isEnabled(plugin.manifest.id))
|
|
212
|
-
.map((plugin) =>
|
|
213
|
-
const channelRuntime =
|
|
214
|
-
weixinChannelRuntime =
|
|
170
|
+
.map((plugin) => resolveRuntime(plugin, kernel.context).runtime);
|
|
171
|
+
const channelRuntime = resolveRuntime(channelPlugin, kernel.context).channel;
|
|
172
|
+
weixinChannelRuntime = resolveRuntime(weixinChannelPlugin, kernel.context).channel;
|
|
215
173
|
const channelRuntimes = [
|
|
216
174
|
channelRuntime,
|
|
217
175
|
weixinChannelRuntime,
|
|
218
176
|
];
|
|
219
177
|
const knowledgeRuntime = kernel.plugins.isEnabled(knowledgePlugin.manifest.id)
|
|
220
|
-
?
|
|
221
|
-
:
|
|
178
|
+
? resolveRuntime(knowledgePlugin, kernel.context)
|
|
179
|
+
: resolveRuntime((0, catalog_js_1.createBuiltinNoopKnowledgePlugin)(), kernel.context);
|
|
222
180
|
const cronSchedulerPlugin = (0, catalog_js_1.createBuiltinCronSchedulerPlugin)();
|
|
223
181
|
const schedulerRuntimes = [
|
|
224
182
|
...(kernel.plugins.isEnabled(cronSchedulerPlugin.manifest.id)
|
|
225
|
-
? [
|
|
183
|
+
? [resolveRuntime(cronSchedulerPlugin, kernel.context)]
|
|
226
184
|
: []),
|
|
227
185
|
...schedulerPlugins
|
|
228
186
|
.filter((plugin) => kernel.plugins.isEnabled(plugin.manifest.id))
|
|
229
|
-
.map((plugin) =>
|
|
187
|
+
.map((plugin) => resolveRuntime(plugin, kernel.context)),
|
|
230
188
|
];
|
|
231
189
|
const schedulerTriggers = schedulerRuntimes.flatMap((runtime) => runtime.triggers || []);
|
|
232
190
|
const schedulerExecutors = schedulerRuntimes.flatMap((runtime) => runtime.executors || []);
|
|
233
191
|
const monitorRuntimes = monitorPlugins
|
|
234
192
|
.filter((plugin) => kernel.plugins.isEnabled(plugin.manifest.id))
|
|
235
|
-
.map((plugin) =>
|
|
193
|
+
.map((plugin) => resolveRuntime(plugin, kernel.context));
|
|
236
194
|
const monitorProviders = monitorRuntimes.flatMap((runtime) => runtime.providers || []);
|
|
237
195
|
const knowledgeProvider = knowledgeRuntime.provider;
|
|
238
196
|
const knowledgeAttachments = knowledgeRuntime.attachments;
|
|
@@ -4,6 +4,7 @@ exports.LocalCoreErrorReporter = exports.LocalCoreError = void 0;
|
|
|
4
4
|
exports.toLocalCoreErrorInfo = toLocalCoreErrorInfo;
|
|
5
5
|
exports.formatUserError = formatUserError;
|
|
6
6
|
exports.formatLogError = formatLogError;
|
|
7
|
+
exports.formatSafeError = formatSafeError;
|
|
7
8
|
exports.errorInfoToHttpBody = errorInfoToHttpBody;
|
|
8
9
|
const DEFAULTS = {
|
|
9
10
|
runtime_not_found: {
|
|
@@ -175,6 +176,13 @@ function formatLogError(info) {
|
|
|
175
176
|
const message = typeof info.message === 'string' ? info.message : safeStringify(info.message);
|
|
176
177
|
return `${info.code}: ${message}${suffix}`;
|
|
177
178
|
}
|
|
179
|
+
function formatSafeError(error) {
|
|
180
|
+
if (error instanceof Error) {
|
|
181
|
+
const cause = error.cause;
|
|
182
|
+
return cause !== undefined ? `${error.message}: ${cause instanceof Error ? cause.message : coerceErrorMessage(cause)}` : error.message;
|
|
183
|
+
}
|
|
184
|
+
return coerceErrorMessage(error);
|
|
185
|
+
}
|
|
178
186
|
function errorInfoToHttpBody(info) {
|
|
179
187
|
return {
|
|
180
188
|
ok: false,
|
package/dist-electron/services/local-ai-core/src/plugins/builtin/knowledge-ai-vector-plugin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createBuiltinAiVectorKnowledgePlugin = createBuiltinAiVectorKnowledgePlugin;
|
|
4
|
-
const
|
|
4
|
+
const knowledge_api_1 = require("../../../../../packages/knowledge-api/src/index.js");
|
|
5
5
|
function createBuiltinAiVectorKnowledgePlugin(options) {
|
|
6
|
-
return (0,
|
|
6
|
+
return (0, knowledge_api_1.createAiVectorKnowledgePlugin)(options);
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createBuiltinNoopKnowledgePlugin = createBuiltinNoopKnowledgePlugin;
|
|
4
|
-
const
|
|
4
|
+
const knowledge_api_1 = require("../../../../../packages/knowledge-api/src/index.js");
|
|
5
5
|
function createBuiltinNoopKnowledgePlugin() {
|
|
6
|
-
return (0,
|
|
6
|
+
return (0, knowledge_api_1.createNoopKnowledgePlugin)();
|
|
7
7
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkspaceBridgeEventStream = void 0;
|
|
4
|
+
class WorkspaceBridgeEventStream {
|
|
5
|
+
eventBus;
|
|
6
|
+
subscribers = new Set();
|
|
7
|
+
constructor(eventBus) {
|
|
8
|
+
this.eventBus = eventBus;
|
|
9
|
+
}
|
|
10
|
+
emit(event) {
|
|
11
|
+
this.eventBus.emit({
|
|
12
|
+
type: 'platform.bridge.updated',
|
|
13
|
+
payload: event,
|
|
14
|
+
});
|
|
15
|
+
for (const subscriber of this.subscribers) {
|
|
16
|
+
subscriber(event);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
subscribe(subscriber) {
|
|
20
|
+
this.subscribers.add(subscriber);
|
|
21
|
+
return () => {
|
|
22
|
+
this.subscribers.delete(subscriber);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
clear() {
|
|
26
|
+
this.subscribers.clear();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.WorkspaceBridgeEventStream = WorkspaceBridgeEventStream;
|
|
@@ -4,25 +4,25 @@ exports.normalizePlatformTypes = normalizePlatformTypes;
|
|
|
4
4
|
exports.isLocalCoreNativeAcpProject = isLocalCoreNativeAcpProject;
|
|
5
5
|
exports.toLocalCoreProjectConfig = toLocalCoreProjectConfig;
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
7
|
-
const
|
|
7
|
+
const superai_contracts_1 = require("../../../../packages/contracts/src/index.js");
|
|
8
8
|
const index_js_1 = require("../agents/index.js");
|
|
9
9
|
const launch_utils_js_1 = require("../agents/shared/launch-utils.js");
|
|
10
10
|
const agent_execution_backend_js_1 = require("../execution/agent-execution-backend.js");
|
|
11
11
|
function normalizePlatformTypes(project) {
|
|
12
12
|
return Array.isArray(project?.platforms)
|
|
13
|
-
? project.platforms.map((platform) => (0,
|
|
13
|
+
? project.platforms.map((platform) => (0, superai_contracts_1.normalizeDesktopPlatformType)(platform?.type)).filter(Boolean)
|
|
14
14
|
: [];
|
|
15
15
|
}
|
|
16
16
|
function isLocalCoreNativeAcpProject(project) {
|
|
17
17
|
const agentType = String(project?.agent?.type || '').trim().toLowerCase();
|
|
18
18
|
return !agentType
|
|
19
19
|
|| agentType === 'acp'
|
|
20
|
-
|| agentType ===
|
|
20
|
+
|| agentType === superai_contracts_1.LOCALCORE_ACP_AGENT_TYPE;
|
|
21
21
|
}
|
|
22
22
|
function resolveAgentModel(project, providers, definition) {
|
|
23
23
|
const agentType = String(project.agent?.type || '').trim().toLowerCase();
|
|
24
24
|
const rawModel = String(project.agent?.options?.model || '').trim();
|
|
25
|
-
const normalizedModel = (0,
|
|
25
|
+
const normalizedModel = (0, superai_contracts_1.normalizeDesktopAgentModel)(agentType, rawModel);
|
|
26
26
|
return definition?.resolveModel?.({
|
|
27
27
|
project,
|
|
28
28
|
providers,
|
|
@@ -63,7 +63,7 @@ function toLocalCoreProjectConfig(configState, project) {
|
|
|
63
63
|
}
|
|
64
64
|
const defaultArgs = launchDefaults.args || [];
|
|
65
65
|
const launchConfig = {
|
|
66
|
-
workspaceId: project.name,
|
|
66
|
+
workspaceId: project.workspace_id || project.name,
|
|
67
67
|
agentType,
|
|
68
68
|
workDir,
|
|
69
69
|
command,
|