@kafca/agentdock 0.1.55 → 0.1.57
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 +14 -0
- package/dist/renderer/assets/{Badge-Bg_nNvBL.js → Badge-CDTbmw1h.js} +1 -1
- package/dist/renderer/assets/Card-DayUo35w.js +1 -0
- package/dist/renderer/assets/Config-ByGMQuzR.js +21 -0
- package/dist/renderer/assets/CronList-XqHdVlgu.js +1 -0
- package/dist/renderer/assets/Dashboard-CZj-oANw.js +41 -0
- package/dist/renderer/assets/{EmptyState-C60g3RMj.js → EmptyState-EFMkOjZO.js} +1 -1
- package/dist/renderer/assets/HighlightedMarkdown-DyvF3DHK.js +12 -0
- package/dist/renderer/assets/Input-DxoWVc9d.js +1 -0
- package/dist/renderer/assets/{KnowledgeDetail-CC5C7JYe.js → KnowledgeDetail-CbUb2tG7.js} +2 -2
- package/dist/renderer/assets/{KnowledgeHome-3rlvxgWf.js → KnowledgeHome-BWV1gz4f.js} +3 -3
- package/dist/renderer/assets/Logs-DqnanQTc.js +6 -0
- package/dist/renderer/assets/{Modal-BQUW9LSf.js → Modal-yY7TzR0x.js} +3 -3
- package/dist/renderer/assets/MonitorList-CIjGQkFs.js +1 -0
- package/dist/renderer/assets/Page-vwHNUdoj.js +1 -0
- package/dist/renderer/assets/{Select-CfRkos3z.js → Select-CmbK36pN.js} +2 -2
- package/dist/renderer/assets/ThreadChat-4OceMgM4.js +86 -0
- package/dist/renderer/assets/Workspace-DplPJOjJ.js +19 -0
- package/dist/renderer/assets/{arrow-left-D1DbXrLA.js → arrow-left-C8HfBt2K.js} +1 -1
- package/dist/renderer/assets/{book-open-BxC1z1C1.js → book-open-BCdZWncQ.js} +1 -1
- package/dist/renderer/assets/channels-hgO3cAIx.js +6 -0
- package/dist/renderer/assets/chevron-down-BPk77tqY.js +11 -0
- package/dist/renderer/assets/index-BIKL3fTP.css +11 -0
- package/dist/renderer/assets/index-BlA4xPdd.js +41 -0
- package/dist/renderer/assets/index-wYpjqVqC.js +167 -0
- package/dist/renderer/assets/knowledge-7pl06KuH.js +1 -0
- package/dist/renderer/assets/{pencil-X44UaxwR.js → pencil-CB1SWZ9A.js} +1 -1
- package/dist/renderer/assets/{play-ujo-De38.js → play-BvsoXUrM.js} +1 -1
- package/dist/renderer/assets/{plus-BHgVdG_A.js → plus-CokBDnaL.js} +1 -1
- package/dist/renderer/assets/{save-Cz6giKrE.js → save-D-w4kATO.js} +1 -1
- package/dist/renderer/assets/{search-DKWvTqi5.js → search-Cnsn6i4Q.js} +1 -1
- package/dist/renderer/assets/{shield-check-V82O8AC1.js → shield-check-Cjja2Gh6.js} +1 -1
- package/dist/renderer/assets/threads-BCm6j4eI.js +1 -0
- package/dist/renderer/assets/{trash-2-_Fgwk8mc.js → trash-2-CIxz9qYY.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 +6 -9
- 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/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 +52 -456
- package/dist-electron/services/local-ai-core/src/channel/lark/outbound-transport.js +124 -0
- package/dist-electron/services/local-ai-core/src/channel/shared/inbound-attachment-store.js +93 -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 +98 -483
- package/dist-electron/services/local-ai-core/src/channel/weixin/runtime-state.js +156 -0
- package/dist-electron/services/local-ai-core/src/channel/weixin/text-utils.js +100 -0
- package/dist-electron/services/local-ai-core/src/cli/lac.js +6 -6
- 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 +33 -5
- 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/sandbox-config.js +8 -8
- 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-attachment-store.test.js +117 -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 +58 -4
- package/dist-electron/tests/integration/local-core-errors.test.js +41 -0
- package/dist-electron/tests/integration/weixin-gateway.test.js +36 -0
- 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-BJveQQKu.js +0 -2
- package/dist/renderer/assets/ChatMarkdown-Bqn2HJ6f.js +0 -45
- package/dist/renderer/assets/Config-CMtZDRAE.js +0 -21
- package/dist/renderer/assets/CronList-C-ILB_Ae.js +0 -1
- package/dist/renderer/assets/Dashboard-CsKBSQIe.js +0 -26
- package/dist/renderer/assets/Logs-CktemGN0.js +0 -1
- package/dist/renderer/assets/MonitorList-B0hxjuOZ.js +0 -1
- package/dist/renderer/assets/Page-DL_Nv2i5.js +0 -1
- package/dist/renderer/assets/ProjectDetail-Djr9-MyT.js +0 -11
- package/dist/renderer/assets/ProjectList-BKl4eW7q.js +0 -1
- package/dist/renderer/assets/SessionChat-Dxv8D5DW.js +0 -1
- package/dist/renderer/assets/SessionList-BJ2GjXvR.js +0 -1
- package/dist/renderer/assets/ThreadChat-CAsIl9qf.js +0 -28
- package/dist/renderer/assets/Workspace-CaUhiGBX.js +0 -19
- package/dist/renderer/assets/bot-Fw3IzhJA.js +0 -6
- package/dist/renderer/assets/check-5zCTgp3A.js +0 -6
- package/dist/renderer/assets/chevron-down-N3PxTNxH.js +0 -6
- package/dist/renderer/assets/circle-C_chUflo.js +0 -6
- package/dist/renderer/assets/desktop-DkQTZNhe.js +0 -1
- package/dist/renderer/assets/desktop-JQkhNOF4.js +0 -5
- package/dist/renderer/assets/funnel-B8ZAv6I7.js +0 -6
- package/dist/renderer/assets/heart-M9A3E4Ed.js +0 -6
- package/dist/renderer/assets/index-Bwv855ID.js +0 -41
- package/dist/renderer/assets/index-CjCuR6DI.css +0 -11
- package/dist/renderer/assets/index-DJ8w4e0l.js +0 -182
- package/dist/renderer/assets/projects-DB1FLZ3A.js +0 -1
- package/dist/renderer/assets/server-BsuHcYl4.js +0 -11
- package/dist/renderer/assets/session-utils-DnAWL3eo.js +0 -6
- package/dist/renderer/assets/sessions-DptxO_BE.js +0 -1
- package/dist/renderer/assets/user-DQKTaUcR.js +0 -6
- package/dist/renderer/assets/wifi-off-vjH-MD2w.js +0 -11
- 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,156 @@
|
|
|
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
|
+
function renderBridgeContent(event) {
|
|
9
|
+
const toolCall = event.toolCall;
|
|
10
|
+
if (!toolCall) {
|
|
11
|
+
return String(event.content || '').trim();
|
|
12
|
+
}
|
|
13
|
+
const name = String(toolCall.name || '').trim() || 'Tool update';
|
|
14
|
+
const status = String(toolCall.status || '').trim();
|
|
15
|
+
if (name === 'Tool update' && status === 'completed')
|
|
16
|
+
return '';
|
|
17
|
+
return [name, status].filter(Boolean).join(' - ');
|
|
18
|
+
}
|
|
19
|
+
function bridgeEventKind(event) {
|
|
20
|
+
return event.bridgeKind || (event.type === 'status' ? 'status' : 'assistant');
|
|
21
|
+
}
|
|
22
|
+
function pushUnique(target, value) {
|
|
23
|
+
const normalized = value.trim();
|
|
24
|
+
if (!normalized || target[target.length - 1] === normalized)
|
|
25
|
+
return;
|
|
26
|
+
target.push(normalized);
|
|
27
|
+
if (target.length > 8)
|
|
28
|
+
target.splice(0, target.length - 8);
|
|
29
|
+
}
|
|
30
|
+
function flushPendingThought(turn) {
|
|
31
|
+
const text = String(turn.pendingThoughtText || '').trim();
|
|
32
|
+
if (!text)
|
|
33
|
+
return;
|
|
34
|
+
pushUnique(turn.thinkingSteps, text);
|
|
35
|
+
turn.pendingThoughtText = undefined;
|
|
36
|
+
}
|
|
37
|
+
function createWeixinTurnState(sessionKey) {
|
|
38
|
+
return {
|
|
39
|
+
sessionKey,
|
|
40
|
+
sentCount: 0,
|
|
41
|
+
foldedProgressCount: 0,
|
|
42
|
+
awaitingPermission: false,
|
|
43
|
+
processing: false,
|
|
44
|
+
previewText: '',
|
|
45
|
+
finalText: '',
|
|
46
|
+
thinkingSteps: [],
|
|
47
|
+
pendingThoughtText: undefined,
|
|
48
|
+
statusLines: [],
|
|
49
|
+
buttonRows: [],
|
|
50
|
+
lastSentAt: 0,
|
|
51
|
+
lastSentText: '',
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function getOrCreateWeixinTurnState(turns, sessionKey) {
|
|
55
|
+
const existing = turns.get(sessionKey);
|
|
56
|
+
if (existing)
|
|
57
|
+
return existing;
|
|
58
|
+
const turn = createWeixinTurnState(sessionKey);
|
|
59
|
+
turns.set(sessionKey, turn);
|
|
60
|
+
return turn;
|
|
61
|
+
}
|
|
62
|
+
function consumeWeixinBridgeEvent(turn, event) {
|
|
63
|
+
const content = renderBridgeContent(event);
|
|
64
|
+
const bridgeKind = bridgeEventKind(event);
|
|
65
|
+
if (event.type === 'typing_start') {
|
|
66
|
+
Object.assign(turn, {
|
|
67
|
+
processing: true,
|
|
68
|
+
previewText: '',
|
|
69
|
+
finalText: '',
|
|
70
|
+
thinkingSteps: [],
|
|
71
|
+
pendingThoughtText: undefined,
|
|
72
|
+
statusLines: [],
|
|
73
|
+
buttonRows: [],
|
|
74
|
+
});
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (event.type === 'typing_stop') {
|
|
78
|
+
turn.processing = false;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (event.type === 'preview_start' || event.type === 'update_message') {
|
|
82
|
+
if (bridgeKind === 'thought') {
|
|
83
|
+
turn.pendingThoughtText = content;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
turn.previewText = content;
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (bridgeKind !== 'thought')
|
|
91
|
+
flushPendingThought(turn);
|
|
92
|
+
if (event.type === 'status') {
|
|
93
|
+
if (content) {
|
|
94
|
+
pushUnique(turn.statusLines, content);
|
|
95
|
+
turn.finalText = content;
|
|
96
|
+
turn.previewText = content;
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (event.type === 'buttons') {
|
|
101
|
+
turn.awaitingPermission = true;
|
|
102
|
+
turn.buttonRows = Array.isArray(event.buttonRows)
|
|
103
|
+
? event.buttonRows
|
|
104
|
+
.map((row) => Array.isArray(row)
|
|
105
|
+
? row.filter((button) => Boolean(button?.text && button?.data))
|
|
106
|
+
.map((button) => ({ text: button.text, data: button.data }))
|
|
107
|
+
: [])
|
|
108
|
+
.filter((row) => row.length > 0)
|
|
109
|
+
: [];
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (!content)
|
|
113
|
+
return;
|
|
114
|
+
if (bridgeKind === 'thought' || bridgeKind === 'plan') {
|
|
115
|
+
pushUnique(turn.thinkingSteps, content);
|
|
116
|
+
}
|
|
117
|
+
else if (bridgeKind === 'tool' || bridgeKind === 'status') {
|
|
118
|
+
pushUnique(turn.statusLines, content);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
turn.finalText = content;
|
|
122
|
+
turn.previewText = content;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function renderWeixinTurnText(turn) {
|
|
126
|
+
const sections = [];
|
|
127
|
+
if (turn.thinkingSteps.length > 0) {
|
|
128
|
+
sections.push(`**中间过程**\n${turn.thinkingSteps.map((step) => `• ${step.replace(/\s+/g, ' ').trim()}`).join('\n')}`);
|
|
129
|
+
}
|
|
130
|
+
if (turn.finalText) {
|
|
131
|
+
sections.push(turn.finalText);
|
|
132
|
+
}
|
|
133
|
+
else if (turn.previewText) {
|
|
134
|
+
sections.push(turn.previewText);
|
|
135
|
+
}
|
|
136
|
+
else if (turn.statusLines.length > 0) {
|
|
137
|
+
sections.push(`**处理中**\n${turn.statusLines.slice(-3).map((line) => `• ${line.replace(/\s+/g, ' ').trim()}`).join('\n')}`);
|
|
138
|
+
}
|
|
139
|
+
else if (turn.processing) {
|
|
140
|
+
sections.push('**处理中**\n正在思考...');
|
|
141
|
+
}
|
|
142
|
+
if (turn.awaitingPermission) {
|
|
143
|
+
sections.push('\n回复:`allow` / `allow all` / `deny`');
|
|
144
|
+
}
|
|
145
|
+
return sections.join('\n\n').trim();
|
|
146
|
+
}
|
|
147
|
+
function isTerminalWeixinBridgeMessage(event, rendered) {
|
|
148
|
+
if (event.type === 'buttons')
|
|
149
|
+
return true;
|
|
150
|
+
if (event.type !== 'reply')
|
|
151
|
+
return false;
|
|
152
|
+
const kind = bridgeEventKind(event);
|
|
153
|
+
if (kind === 'tool' || kind === 'thought' || kind === 'plan' || kind === 'status')
|
|
154
|
+
return false;
|
|
155
|
+
return Boolean(rendered.trim());
|
|
156
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stripWeixinHtml = stripWeixinHtml;
|
|
4
|
+
exports.formatWeixinError = formatWeixinError;
|
|
5
|
+
exports.waitForWeixinRetry = waitForWeixinRetry;
|
|
6
|
+
exports.utf8ByteLength = utf8ByteLength;
|
|
7
|
+
exports.splitTextByUtf8Bytes = splitTextByUtf8Bytes;
|
|
8
|
+
exports.truncateTextByUtf8Bytes = truncateTextByUtf8Bytes;
|
|
9
|
+
function stripWeixinHtml(html) {
|
|
10
|
+
let result = html;
|
|
11
|
+
let previous;
|
|
12
|
+
do {
|
|
13
|
+
previous = result;
|
|
14
|
+
result = result.replace(/<[^>]*>/g, '');
|
|
15
|
+
} while (result !== previous);
|
|
16
|
+
return result
|
|
17
|
+
.replace(/&/g, '&')
|
|
18
|
+
.replace(/</g, '<')
|
|
19
|
+
.replace(/>/g, '>')
|
|
20
|
+
.replace(/"/g, '"')
|
|
21
|
+
.replace(/'/g, "'")
|
|
22
|
+
.replace(/ /g, ' ');
|
|
23
|
+
}
|
|
24
|
+
function formatWeixinError(error) {
|
|
25
|
+
if (error instanceof Error) {
|
|
26
|
+
const cause = error.cause;
|
|
27
|
+
return cause !== undefined ? `${error.message}: ${String(cause)}` : error.message;
|
|
28
|
+
}
|
|
29
|
+
return String(error);
|
|
30
|
+
}
|
|
31
|
+
function waitForWeixinRetry(ms, signal) {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const timer = setTimeout(resolve, ms);
|
|
34
|
+
const onAbort = () => {
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
reject(new Error('aborted'));
|
|
37
|
+
};
|
|
38
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function utf8ByteLength(value) {
|
|
42
|
+
return Buffer.byteLength(value, 'utf-8');
|
|
43
|
+
}
|
|
44
|
+
function splitTextByUtf8Bytes(text, maxBytes) {
|
|
45
|
+
const normalized = String(text || '').replace(/\r\n/g, '\n').trim();
|
|
46
|
+
if (!normalized)
|
|
47
|
+
return [];
|
|
48
|
+
if (utf8ByteLength(normalized) <= maxBytes)
|
|
49
|
+
return [normalized];
|
|
50
|
+
const chunks = [];
|
|
51
|
+
let current = '';
|
|
52
|
+
const pushCurrent = () => {
|
|
53
|
+
const trimmed = current.trim();
|
|
54
|
+
if (trimmed)
|
|
55
|
+
chunks.push(trimmed);
|
|
56
|
+
current = '';
|
|
57
|
+
};
|
|
58
|
+
const appendPart = (part) => {
|
|
59
|
+
if (!part.trim())
|
|
60
|
+
return;
|
|
61
|
+
const separator = current ? '\n\n' : '';
|
|
62
|
+
if (current && utf8ByteLength(`${current}${separator}${part}`) <= maxBytes) {
|
|
63
|
+
current = `${current}${separator}${part}`;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (current)
|
|
67
|
+
pushCurrent();
|
|
68
|
+
if (utf8ByteLength(part) <= maxBytes) {
|
|
69
|
+
current = part;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
let segment = '';
|
|
73
|
+
for (const character of Array.from(part)) {
|
|
74
|
+
if (segment && utf8ByteLength(`${segment}${character}`) > maxBytes) {
|
|
75
|
+
chunks.push(segment);
|
|
76
|
+
segment = '';
|
|
77
|
+
}
|
|
78
|
+
segment += character;
|
|
79
|
+
}
|
|
80
|
+
current = segment;
|
|
81
|
+
};
|
|
82
|
+
for (const part of normalized.split(/\n{2,}/))
|
|
83
|
+
appendPart(part);
|
|
84
|
+
pushCurrent();
|
|
85
|
+
return chunks;
|
|
86
|
+
}
|
|
87
|
+
function truncateTextByUtf8Bytes(text, maxBytes) {
|
|
88
|
+
const normalized = String(text || '').replace(/\r\n/g, '\n').trim();
|
|
89
|
+
if (utf8ByteLength(normalized) <= maxBytes)
|
|
90
|
+
return normalized;
|
|
91
|
+
const suffix = '\n\n(内容过长,已截断以保证微信送达)';
|
|
92
|
+
const budget = Math.max(0, maxBytes - utf8ByteLength(suffix));
|
|
93
|
+
let result = '';
|
|
94
|
+
for (const character of Array.from(normalized)) {
|
|
95
|
+
if (utf8ByteLength(`${result}${character}`) > budget)
|
|
96
|
+
break;
|
|
97
|
+
result += character;
|
|
98
|
+
}
|
|
99
|
+
return `${result.trim()}${suffix}`;
|
|
100
|
+
}
|
|
@@ -5,7 +5,7 @@ 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");
|
|
@@ -148,7 +148,7 @@ async function handleMonitorEdit(monitorId, flags, env, io, json) {
|
|
|
148
148
|
if (typeof enabled === 'boolean')
|
|
149
149
|
input.enabled = enabled;
|
|
150
150
|
if (executionMode)
|
|
151
|
-
input.executionMode = (0,
|
|
151
|
+
input.executionMode = (0, superai_contracts_1.normalizeScheduledJobExecutionMode)(executionMode);
|
|
152
152
|
if (cooldown)
|
|
153
153
|
input.cooldownMs = (0, monitor_cli_parsers_js_1.parseDurationMs)(cooldown);
|
|
154
154
|
if (Object.keys(input).length === 0) {
|
|
@@ -181,7 +181,7 @@ async function handleChannelSendFile(flags, env, io, json) {
|
|
|
181
181
|
const context = resolveContext(flags, env);
|
|
182
182
|
const filePath = getRequiredFlag(flags, 'path');
|
|
183
183
|
const rawPlatform = getFlag(flags, 'platform') || context.platform;
|
|
184
|
-
const platform = rawPlatform ? (0,
|
|
184
|
+
const platform = rawPlatform ? (0, superai_contracts_1.normalizeChannelPlatform)(rawPlatform) : '';
|
|
185
185
|
if (!platform) {
|
|
186
186
|
throw new Error('channel send-file requires a platform. Set LOCAL_AI_PLATFORM or pass --platform.');
|
|
187
187
|
}
|
|
@@ -284,7 +284,7 @@ async function handleEdit(jobId, flags, env, io, json) {
|
|
|
284
284
|
input.enabled = enabled;
|
|
285
285
|
}
|
|
286
286
|
if (executionMode) {
|
|
287
|
-
input.executionMode = (0,
|
|
287
|
+
input.executionMode = (0, superai_contracts_1.normalizeScheduledJobExecutionMode)(executionMode);
|
|
288
288
|
}
|
|
289
289
|
if (Object.keys(input).length === 0) {
|
|
290
290
|
throw new Error('scheduler edit requires at least one editable field.');
|
|
@@ -406,10 +406,10 @@ function normalizeMaybeBooleanFlag(value) {
|
|
|
406
406
|
return value === 'true' ? '' : value;
|
|
407
407
|
}
|
|
408
408
|
function getExecutionMode(flags) {
|
|
409
|
-
return (0,
|
|
409
|
+
return (0, superai_contracts_1.normalizeScheduledJobExecutionMode)(getFlag(flags, 'execution-mode'));
|
|
410
410
|
}
|
|
411
411
|
function getMonitorExecutionMode(flags) {
|
|
412
|
-
return (0,
|
|
412
|
+
return (0, superai_contracts_1.normalizeScheduledJobExecutionMode)(getFlag(flags, 'execution-mode') || 'side-thread');
|
|
413
413
|
}
|
|
414
414
|
function buildSourceConfig(sourceType, flags) {
|
|
415
415
|
const config = {};
|
|
@@ -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;
|
|
@@ -137,11 +137,12 @@ class LocalCoreError extends Error {
|
|
|
137
137
|
info;
|
|
138
138
|
constructor(code, message, input = {}) {
|
|
139
139
|
const defaults = DEFAULTS[code];
|
|
140
|
-
|
|
140
|
+
const messageStr = coerceErrorMessage(message) || defaults.userMessage;
|
|
141
|
+
super(messageStr);
|
|
141
142
|
this.name = 'LocalCoreError';
|
|
142
143
|
this.info = {
|
|
143
144
|
code,
|
|
144
|
-
message:
|
|
145
|
+
message: messageStr,
|
|
145
146
|
userMessage: input.userMessage || defaults.userMessage,
|
|
146
147
|
severity: input.severity || defaults.severity,
|
|
147
148
|
retryable: input.retryable ?? defaults.retryable,
|
|
@@ -158,9 +159,9 @@ function toLocalCoreErrorInfo(error, fallbackCode = 'internal_error', details =
|
|
|
158
159
|
}
|
|
159
160
|
const maybeInfo = error?.info;
|
|
160
161
|
if (maybeInfo?.code && maybeInfo.message) {
|
|
161
|
-
return mergeDetails(maybeInfo, details);
|
|
162
|
+
return mergeDetails(ensureInfoMessageString(maybeInfo), details);
|
|
162
163
|
}
|
|
163
|
-
const message = error instanceof Error ? error.message :
|
|
164
|
+
const message = coerceErrorMessage(error instanceof Error ? error.message : error);
|
|
164
165
|
const classifiedCode = classifyErrorMessage(message, fallbackCode);
|
|
165
166
|
return new LocalCoreError(classifiedCode, message || DEFAULTS[classifiedCode].userMessage, {
|
|
166
167
|
details: Object.keys(details).length ? details : undefined,
|
|
@@ -171,7 +172,8 @@ function formatUserError(info) {
|
|
|
171
172
|
}
|
|
172
173
|
function formatLogError(info) {
|
|
173
174
|
const suffix = info.cause ? ` cause=${info.cause}` : '';
|
|
174
|
-
|
|
175
|
+
const message = typeof info.message === 'string' ? info.message : safeStringify(info.message);
|
|
176
|
+
return `${info.code}: ${message}${suffix}`;
|
|
175
177
|
}
|
|
176
178
|
function errorInfoToHttpBody(info) {
|
|
177
179
|
return {
|
|
@@ -253,3 +255,29 @@ function mergeDetails(info, details) {
|
|
|
253
255
|
},
|
|
254
256
|
};
|
|
255
257
|
}
|
|
258
|
+
function ensureInfoMessageString(info) {
|
|
259
|
+
if (typeof info.message === 'string') {
|
|
260
|
+
return info;
|
|
261
|
+
}
|
|
262
|
+
return { ...info, message: safeStringify(info.message) };
|
|
263
|
+
}
|
|
264
|
+
function coerceErrorMessage(value) {
|
|
265
|
+
if (typeof value === 'string') {
|
|
266
|
+
return value;
|
|
267
|
+
}
|
|
268
|
+
if (value === null || value === undefined) {
|
|
269
|
+
return '';
|
|
270
|
+
}
|
|
271
|
+
return safeStringify(value);
|
|
272
|
+
}
|
|
273
|
+
function safeStringify(value) {
|
|
274
|
+
if (typeof value === 'string') {
|
|
275
|
+
return value;
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
return JSON.stringify(value);
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
return String(value);
|
|
282
|
+
}
|
|
283
|
+
}
|
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,
|