@kafca/agentdock 0.1.7
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 +70 -0
- package/bin/agentdock.mjs +275 -0
- package/build/icon.png +0 -0
- package/dist/renderer/assets/index-BaNpzC6d.js +482 -0
- package/dist/renderer/assets/index-CLWJyO0E.css +11 -0
- package/dist/renderer/favicon.svg +19 -0
- package/dist/renderer/index.html +14 -0
- package/dist/renderer/logo-options.svg +153 -0
- package/dist-electron/electron/knowledge-skill-script.test.js +125 -0
- package/dist-electron/electron/lac-cli.test.js +221 -0
- package/dist-electron/electron/local-core-refactor.test.js +1075 -0
- package/dist-electron/electron/main.js +163 -0
- package/dist-electron/electron/plugin-kernel.test.js +534 -0
- package/dist-electron/electron/preload.js +2 -0
- package/dist-electron/package.json +3 -0
- package/dist-electron/packages/contracts/src/index.js +18 -0
- package/dist-electron/packages/contracts/src/local-core.js +2 -0
- package/dist-electron/packages/core-sdk/src/index.js +406 -0
- package/dist-electron/packages/knowledge-api/src/ai-vector-provider.js +388 -0
- package/dist-electron/packages/knowledge-api/src/index.js +146 -0
- package/dist-electron/packages/knowledge-api/src/sqlite-store.js +467 -0
- package/dist-electron/packages/knowledge-api/src/thread-knowledge-store.js +21 -0
- package/dist-electron/packages/knowledge-api/test/ai-vector-provider.test.js +412 -0
- package/dist-electron/packages/plugin-sdk/src/index.js +2 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-backend.js +369 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-response-processor.js +110 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-session-coordinator.js +171 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-store.js +635 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-transport.js +190 -0
- package/dist-electron/services/local-ai-core/src/acp/local-core-acp-turn-coordinator.js +244 -0
- package/dist-electron/services/local-ai-core/src/acp/workspace-acp-permissions.js +52 -0
- package/dist-electron/services/local-ai-core/src/cli/lac.js +290 -0
- package/dist-electron/services/local-ai-core/src/gateway/local-core-lark-gateway.js +976 -0
- package/dist-electron/services/local-ai-core/src/gateway/local-core-weixin-gateway.js +1143 -0
- package/dist-electron/services/local-ai-core/src/kernel/bootstrap.js +291 -0
- package/dist-electron/services/local-ai-core/src/kernel/capability-registry.js +67 -0
- package/dist-electron/services/local-ai-core/src/kernel/diagnostics.js +27 -0
- package/dist-electron/services/local-ai-core/src/kernel/event-bus.js +27 -0
- package/dist-electron/services/local-ai-core/src/kernel/lifecycle-manager.js +85 -0
- package/dist-electron/services/local-ai-core/src/kernel/plugin-registry.js +60 -0
- package/dist-electron/services/local-ai-core/src/plugins/builtin/agent-localcore-acp-plugin.js +114 -0
- package/dist-electron/services/local-ai-core/src/plugins/builtin/channel-lark-plugin.js +59 -0
- package/dist-electron/services/local-ai-core/src/plugins/builtin/channel-weixin-plugin.js +56 -0
- package/dist-electron/services/local-ai-core/src/plugins/builtin/knowledge-ai-vector-plugin.js +7 -0
- package/dist-electron/services/local-ai-core/src/plugins/builtin/knowledge-noop-plugin.js +7 -0
- package/dist-electron/services/local-ai-core/src/plugins/builtin/runtime-capabilities-plugin.js +62 -0
- package/dist-electron/services/local-ai-core/src/plugins/builtin/scheduler-cron-plugin.js +49 -0
- package/dist-electron/services/local-ai-core/src/plugins/builtin/scheduler-lark-plugin.js +38 -0
- package/dist-electron/services/local-ai-core/src/plugins/builtin/scheduler-weixin-plugin.js +38 -0
- package/dist-electron/services/local-ai-core/src/router/workspace-route-config.js +230 -0
- package/dist-electron/services/local-ai-core/src/router/workspace-router-types.js +2 -0
- package/dist-electron/services/local-ai-core/src/router/workspace-router.js +389 -0
- package/dist-electron/services/local-ai-core/src/runtime/local-core-controller.js +315 -0
- package/dist-electron/services/local-ai-core/src/runtime/local-core-runtime-state.js +282 -0
- package/dist-electron/services/local-ai-core/src/runtime/server.js +465 -0
- package/dist-electron/services/local-ai-core/src/runtime/standalone.js +38 -0
- package/dist-electron/services/local-ai-core/src/scheduler/adapters.js +2 -0
- package/dist-electron/services/local-ai-core/src/scheduler/cron-command-detector.js +70 -0
- package/dist-electron/services/local-ai-core/src/scheduler/cron.js +53 -0
- package/dist-electron/services/local-ai-core/src/scheduler/execution-policy.js +2 -0
- package/dist-electron/services/local-ai-core/src/scheduler/lark-execution-policies.js +66 -0
- package/dist-electron/services/local-ai-core/src/scheduler/lark-schedule-adapter.js +77 -0
- package/dist-electron/services/local-ai-core/src/scheduler/scheduled-conversation-executor.js +46 -0
- package/dist-electron/services/local-ai-core/src/scheduler/scheduler-run-lifecycle.js +64 -0
- package/dist-electron/services/local-ai-core/src/scheduler/scheduler-service.js +133 -0
- package/dist-electron/services/local-ai-core/src/scheduler/weixin-execution-policies.js +66 -0
- package/dist-electron/services/local-ai-core/src/scheduler/weixin-schedule-adapter.js +78 -0
- package/dist-electron/services/local-ai-core/src/thread/workspace-thread-id.js +17 -0
- package/dist-electron/services/local-ai-core/src/thread/workspace-thread-mappers.js +43 -0
- package/dist-electron/shared/desktop.js +195 -0
- package/dist-electron/src/api/client.js +73 -0
- package/dist-electron/src/api/sessions.js +21 -0
- package/dist-electron/src/lib/session-utils.js +51 -0
- package/dist-electron/src/pages/Threads/thread-chat-model.js +246 -0
- package/dist-electron/src/pages/Threads/thread-chat-model.test.js +76 -0
- package/dist-electron/src/pages/Threads/thread-chat-permission.js +26 -0
- package/dist-electron/src/pages/Threads/thread-chat-permission.test.js +102 -0
- package/dist-electron/src/pages/Threads/thread-chat-task-state.js +65 -0
- package/package.json +146 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bootstrapLocalCoreKernel = bootstrapLocalCoreKernel;
|
|
4
|
+
exports.bootstrapLocalCoreRuntime = bootstrapLocalCoreRuntime;
|
|
5
|
+
const local_core_acp_store_js_1 = require("../acp/local-core-acp-store.js");
|
|
6
|
+
const capability_registry_js_1 = require("./capability-registry.js");
|
|
7
|
+
const diagnostics_js_1 = require("./diagnostics.js");
|
|
8
|
+
const event_bus_js_1 = require("./event-bus.js");
|
|
9
|
+
const lifecycle_manager_js_1 = require("./lifecycle-manager.js");
|
|
10
|
+
const plugin_registry_js_1 = require("./plugin-registry.js");
|
|
11
|
+
const agent_localcore_acp_plugin_js_1 = require("../plugins/builtin/agent-localcore-acp-plugin.js");
|
|
12
|
+
const channel_lark_plugin_js_1 = require("../plugins/builtin/channel-lark-plugin.js");
|
|
13
|
+
const channel_weixin_plugin_js_1 = require("../plugins/builtin/channel-weixin-plugin.js");
|
|
14
|
+
const knowledge_ai_vector_plugin_js_1 = require("../plugins/builtin/knowledge-ai-vector-plugin.js");
|
|
15
|
+
const knowledge_noop_plugin_js_1 = require("../plugins/builtin/knowledge-noop-plugin.js");
|
|
16
|
+
const scheduler_cron_plugin_js_1 = require("../plugins/builtin/scheduler-cron-plugin.js");
|
|
17
|
+
const scheduler_lark_plugin_js_1 = require("../plugins/builtin/scheduler-lark-plugin.js");
|
|
18
|
+
const scheduler_weixin_plugin_js_1 = require("../plugins/builtin/scheduler-weixin-plugin.js");
|
|
19
|
+
const workspace_router_js_1 = require("../router/workspace-router.js");
|
|
20
|
+
const local_core_runtime_state_js_1 = require("../runtime/local-core-runtime-state.js");
|
|
21
|
+
const scheduler_service_js_1 = require("../scheduler/scheduler-service.js");
|
|
22
|
+
function bootstrapLocalCoreKernel(options) {
|
|
23
|
+
const capabilities = new capability_registry_js_1.LocalCoreCapabilityRegistry();
|
|
24
|
+
const plugins = new plugin_registry_js_1.LocalCorePluginRegistry(options?.disabledPluginIds);
|
|
25
|
+
const context = {
|
|
26
|
+
bus: new event_bus_js_1.LocalCoreEventBus(),
|
|
27
|
+
capabilities,
|
|
28
|
+
logger: {
|
|
29
|
+
log(message) {
|
|
30
|
+
options?.log?.(message);
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const lifecycle = new lifecycle_manager_js_1.LocalCoreLifecycleManager(plugins, context);
|
|
35
|
+
const diagnostics = new diagnostics_js_1.LocalCoreDiagnostics(plugins, lifecycle);
|
|
36
|
+
const builtIns = [
|
|
37
|
+
...['codex', 'cursor', 'gemini', 'qoder', 'iflow'].map((agentType) => (0, agent_localcore_acp_plugin_js_1.createBuiltinStaticAgentCapabilityPlugin)(agentType)),
|
|
38
|
+
(0, agent_localcore_acp_plugin_js_1.createBuiltinLocalCoreAcpAgentPlugin)(),
|
|
39
|
+
(0, scheduler_cron_plugin_js_1.createBuiltinCronSchedulerPlugin)(),
|
|
40
|
+
];
|
|
41
|
+
for (const plugin of builtIns) {
|
|
42
|
+
plugins.register(plugin);
|
|
43
|
+
options?.log?.(`[plugin:${plugin.manifest.id}] registered`);
|
|
44
|
+
if (plugin.capabilities && plugins.isEnabled(plugin.manifest.id)) {
|
|
45
|
+
logCapabilityContributions(plugin, options?.log);
|
|
46
|
+
capabilities.registerContributions(plugin.capabilities);
|
|
47
|
+
}
|
|
48
|
+
else if (!plugins.isEnabled(plugin.manifest.id)) {
|
|
49
|
+
options?.log?.(`[plugin:${plugin.manifest.id}] disabled by runtime settings`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
context,
|
|
54
|
+
plugins,
|
|
55
|
+
capabilities,
|
|
56
|
+
lifecycle,
|
|
57
|
+
diagnostics,
|
|
58
|
+
getCapabilitySnapshot() {
|
|
59
|
+
const snapshot = capabilities.snapshot();
|
|
60
|
+
return {
|
|
61
|
+
adapters: {
|
|
62
|
+
channels: snapshot.channels.map((capability) => capability.platform),
|
|
63
|
+
agents: snapshot.agents.map((capability) => capability.agentType),
|
|
64
|
+
knowledge: snapshot.knowledge.some((capability) => capability.enabled !== false),
|
|
65
|
+
knowledgeProviders: [...new Set(snapshot.knowledge
|
|
66
|
+
.filter((capability) => capability.enabled !== false)
|
|
67
|
+
.map((capability) => capability.sourceType))],
|
|
68
|
+
},
|
|
69
|
+
scheduler: {
|
|
70
|
+
enabled: snapshot.schedulers.some((capability) => capability.enabled !== false),
|
|
71
|
+
triggerTypes: [...new Set(snapshot.schedulers.flatMap((capability) => capability.triggerTypes))],
|
|
72
|
+
deliveryTargets: [...new Set(snapshot.schedulers.flatMap((capability) => capability.deliveryTargets || capability.deliveryPlatforms || []))],
|
|
73
|
+
platforms: [...new Set(snapshot.schedulers.flatMap((capability) => capability.deliveryTargets || capability.deliveryPlatforms || []))],
|
|
74
|
+
},
|
|
75
|
+
snapshot,
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function registerPlugin(kernel, plugin) {
|
|
81
|
+
kernel.plugins.register(plugin);
|
|
82
|
+
kernel.context.logger.log(`[plugin:${plugin.manifest.id}] registered`);
|
|
83
|
+
if (plugin.capabilities && kernel.plugins.isEnabled(plugin.manifest.id)) {
|
|
84
|
+
logCapabilityContributions(plugin, kernel.context.logger.log);
|
|
85
|
+
kernel.capabilities.registerContributions(plugin.capabilities);
|
|
86
|
+
}
|
|
87
|
+
else if (!kernel.plugins.isEnabled(plugin.manifest.id)) {
|
|
88
|
+
kernel.context.logger.log(`[plugin:${plugin.manifest.id}] disabled by runtime settings`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function logCapabilityContributions(plugin, log) {
|
|
92
|
+
if (!log || !plugin.capabilities) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const capabilityIds = [
|
|
96
|
+
...(plugin.capabilities.agents || []).map((capability) => capability.id),
|
|
97
|
+
...(plugin.capabilities.channels || []).map((capability) => capability.id),
|
|
98
|
+
...(plugin.capabilities.knowledge || []).map((capability) => capability.id),
|
|
99
|
+
...(plugin.capabilities.schedulers || []).map((capability) => capability.id),
|
|
100
|
+
...(plugin.capabilities.ui || []).map((capability) => capability.id),
|
|
101
|
+
];
|
|
102
|
+
for (const capabilityId of capabilityIds) {
|
|
103
|
+
log(`[plugin:${plugin.manifest.id}][capability:${capabilityId}] registered`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function resolveKnowledgeRuntime(plugin, context) {
|
|
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) {
|
|
117
|
+
if (!plugin.createRuntime) {
|
|
118
|
+
throw new Error(`Channel plugin ${plugin.manifest.id} does not provide a runtime factory.`);
|
|
119
|
+
}
|
|
120
|
+
const runtime = plugin.createRuntime(context);
|
|
121
|
+
if (runtime instanceof Promise) {
|
|
122
|
+
throw new Error(`Channel plugin ${plugin.manifest.id} returned an async runtime factory during synchronous bootstrap.`);
|
|
123
|
+
}
|
|
124
|
+
return runtime;
|
|
125
|
+
}
|
|
126
|
+
function resolveAgentRuntime(plugin, context) {
|
|
127
|
+
if (!plugin.createRuntime) {
|
|
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 bootstrapLocalCoreRuntime(options) {
|
|
147
|
+
const state = (0, local_core_runtime_state_js_1.createLocalCoreRuntimeState)({
|
|
148
|
+
userDataPath: options.userDataPath,
|
|
149
|
+
onLog: options.log,
|
|
150
|
+
});
|
|
151
|
+
const disabledPluginIds = Object.entries(state.getSettings().plugins)
|
|
152
|
+
.filter(([, settings]) => settings.enabled === false)
|
|
153
|
+
.map(([pluginId]) => pluginId);
|
|
154
|
+
const kernel = bootstrapLocalCoreKernel({
|
|
155
|
+
log: options.log,
|
|
156
|
+
disabledPluginIds,
|
|
157
|
+
});
|
|
158
|
+
const store = new local_core_acp_store_js_1.LocalCoreAcpStore(options.userDataPath);
|
|
159
|
+
const localCoreAgentPlugin = kernel.plugins.get('builtin.agent-localcore-acp');
|
|
160
|
+
if (!localCoreAgentPlugin) {
|
|
161
|
+
throw new Error('Missing built-in LocalCore ACP agent plugin.');
|
|
162
|
+
}
|
|
163
|
+
const agentPlugins = [
|
|
164
|
+
localCoreAgentPlugin,
|
|
165
|
+
(0, agent_localcore_acp_plugin_js_1.createBuiltinOpencodeAgentPlugin)(),
|
|
166
|
+
(0, agent_localcore_acp_plugin_js_1.createBuiltinClaudeCodeAgentPlugin)(),
|
|
167
|
+
];
|
|
168
|
+
let workspaceRouter;
|
|
169
|
+
let weixinChannelRuntime;
|
|
170
|
+
const channelPlugin = (0, channel_lark_plugin_js_1.createBuiltinLarkChannelPlugin)({
|
|
171
|
+
store,
|
|
172
|
+
readConfig: async () => (await state.readConfigFile()).parsed,
|
|
173
|
+
getWorkspaceRouter: () => workspaceRouter,
|
|
174
|
+
log: options.log,
|
|
175
|
+
});
|
|
176
|
+
const weixinChannelPlugin = (0, channel_weixin_plugin_js_1.createBuiltinWeixinChannelPlugin)({
|
|
177
|
+
store,
|
|
178
|
+
readConfig: async () => (await state.readConfigFile()).parsed,
|
|
179
|
+
getWorkspaceRouter: () => workspaceRouter,
|
|
180
|
+
log: options.log,
|
|
181
|
+
});
|
|
182
|
+
const knowledgePlugin = options.enableKnowledge === false
|
|
183
|
+
? (0, knowledge_noop_plugin_js_1.createBuiltinNoopKnowledgePlugin)()
|
|
184
|
+
: (0, knowledge_ai_vector_plugin_js_1.createBuiltinAiVectorKnowledgePlugin)({
|
|
185
|
+
userDataPath: options.userDataPath,
|
|
186
|
+
getConfig: () => state.getKnowledgeConfig(),
|
|
187
|
+
setConfig: (input) => state.updateKnowledgeConfig(input),
|
|
188
|
+
});
|
|
189
|
+
const schedulerPlugins = [
|
|
190
|
+
(0, scheduler_lark_plugin_js_1.createBuiltinLarkSchedulerPlugin)({
|
|
191
|
+
store,
|
|
192
|
+
getWorkspaceRouter: () => workspaceRouter,
|
|
193
|
+
getChannelRuntime: () => channelRuntime,
|
|
194
|
+
log: options.log,
|
|
195
|
+
}),
|
|
196
|
+
(0, scheduler_weixin_plugin_js_1.createBuiltinWeixinSchedulerPlugin)({
|
|
197
|
+
store,
|
|
198
|
+
getWorkspaceRouter: () => workspaceRouter,
|
|
199
|
+
getChannelRuntime: () => weixinChannelRuntime,
|
|
200
|
+
log: options.log,
|
|
201
|
+
}),
|
|
202
|
+
];
|
|
203
|
+
for (const plugin of agentPlugins.filter((plugin) => plugin !== localCoreAgentPlugin)) {
|
|
204
|
+
registerPlugin(kernel, plugin);
|
|
205
|
+
}
|
|
206
|
+
registerPlugin(kernel, channelPlugin);
|
|
207
|
+
registerPlugin(kernel, weixinChannelPlugin);
|
|
208
|
+
registerPlugin(kernel, knowledgePlugin);
|
|
209
|
+
for (const plugin of schedulerPlugins) {
|
|
210
|
+
registerPlugin(kernel, plugin);
|
|
211
|
+
}
|
|
212
|
+
const agentRuntimes = agentPlugins
|
|
213
|
+
.filter((plugin) => kernel.plugins.isEnabled(plugin.manifest.id))
|
|
214
|
+
.map((plugin) => resolveAgentRuntime(plugin, kernel.context).runtime);
|
|
215
|
+
const channelRuntime = resolveChannelRuntime(channelPlugin, kernel.context).channel;
|
|
216
|
+
weixinChannelRuntime = resolveChannelRuntime(weixinChannelPlugin, kernel.context).channel;
|
|
217
|
+
const knowledgeRuntime = kernel.plugins.isEnabled(knowledgePlugin.manifest.id)
|
|
218
|
+
? resolveKnowledgeRuntime(knowledgePlugin, kernel.context)
|
|
219
|
+
: resolveKnowledgeRuntime((0, knowledge_noop_plugin_js_1.createBuiltinNoopKnowledgePlugin)(), kernel.context);
|
|
220
|
+
const cronSchedulerPlugin = (0, scheduler_cron_plugin_js_1.createBuiltinCronSchedulerPlugin)();
|
|
221
|
+
const schedulerRuntimes = [
|
|
222
|
+
...(kernel.plugins.isEnabled(cronSchedulerPlugin.manifest.id)
|
|
223
|
+
? [resolveSchedulerRuntime(cronSchedulerPlugin, kernel.context)]
|
|
224
|
+
: []),
|
|
225
|
+
...schedulerPlugins
|
|
226
|
+
.filter((plugin) => kernel.plugins.isEnabled(plugin.manifest.id))
|
|
227
|
+
.map((plugin) => resolveSchedulerRuntime(plugin, kernel.context)),
|
|
228
|
+
];
|
|
229
|
+
const schedulerTriggers = schedulerRuntimes.flatMap((runtime) => runtime.triggers || []);
|
|
230
|
+
const schedulerExecutors = schedulerRuntimes.flatMap((runtime) => runtime.executors || []);
|
|
231
|
+
const knowledgeProvider = knowledgeRuntime.provider;
|
|
232
|
+
const knowledgeAttachments = knowledgeRuntime.attachments;
|
|
233
|
+
workspaceRouter = (0, workspace_router_js_1.createWorkspaceRouter)({
|
|
234
|
+
store,
|
|
235
|
+
cliBinDir: state.cliBinDir,
|
|
236
|
+
localCoreBase: options.localCoreBase,
|
|
237
|
+
readConfigState: () => state.readConfigFile(),
|
|
238
|
+
getCapabilities: () => kernel.getCapabilitySnapshot(),
|
|
239
|
+
getAgentRuntimes: () => agentRuntimes,
|
|
240
|
+
eventBus: kernel.context.bus,
|
|
241
|
+
knowledgeProvider,
|
|
242
|
+
knowledgeAttachments,
|
|
243
|
+
log: options.log,
|
|
244
|
+
});
|
|
245
|
+
const scheduler = new scheduler_service_js_1.SchedulerService({
|
|
246
|
+
store,
|
|
247
|
+
triggers: schedulerTriggers,
|
|
248
|
+
executors: schedulerExecutors,
|
|
249
|
+
eventBus: kernel.context.bus,
|
|
250
|
+
log: options.log,
|
|
251
|
+
});
|
|
252
|
+
workspaceRouter.setSchedulerBridge({
|
|
253
|
+
createJob: async ({ workspaceId, platform, route, name, schedule, scheduleDescription, message }) => scheduler.createJob({
|
|
254
|
+
workspaceId,
|
|
255
|
+
platform,
|
|
256
|
+
route,
|
|
257
|
+
triggerType: 'cron',
|
|
258
|
+
cronExpr: schedule,
|
|
259
|
+
promptTemplate: message,
|
|
260
|
+
description: `${name} · ${scheduleDescription}`,
|
|
261
|
+
enabled: true,
|
|
262
|
+
}),
|
|
263
|
+
listJobsForThread: async (threadId) => scheduler
|
|
264
|
+
.listJobs()
|
|
265
|
+
.filter((job) => job.route.threadId === threadId),
|
|
266
|
+
deleteJob: async (jobId) => {
|
|
267
|
+
scheduler.deleteJob(jobId);
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
return {
|
|
271
|
+
kernel,
|
|
272
|
+
state,
|
|
273
|
+
store,
|
|
274
|
+
agentRuntimes,
|
|
275
|
+
channelRuntime,
|
|
276
|
+
weixinChannelRuntime,
|
|
277
|
+
knowledgeProvider,
|
|
278
|
+
knowledgeAttachments,
|
|
279
|
+
workspaceRouter,
|
|
280
|
+
scheduler,
|
|
281
|
+
async start() {
|
|
282
|
+
await kernel.lifecycle.startAll();
|
|
283
|
+
await scheduler.start();
|
|
284
|
+
},
|
|
285
|
+
async stop() {
|
|
286
|
+
await scheduler.stop();
|
|
287
|
+
await kernel.lifecycle.stopAll();
|
|
288
|
+
workspaceRouter.close();
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalCoreCapabilityRegistry = void 0;
|
|
4
|
+
class LocalCoreCapabilityRegistry {
|
|
5
|
+
agents = new Map();
|
|
6
|
+
channels = new Map();
|
|
7
|
+
knowledge = new Map();
|
|
8
|
+
schedulers = new Map();
|
|
9
|
+
ui = new Map();
|
|
10
|
+
registerAgent(capability) {
|
|
11
|
+
this.agents.set(capability.id, capability);
|
|
12
|
+
}
|
|
13
|
+
registerChannel(capability) {
|
|
14
|
+
this.channels.set(capability.id, capability);
|
|
15
|
+
}
|
|
16
|
+
registerKnowledge(capability) {
|
|
17
|
+
this.knowledge.set(capability.id, capability);
|
|
18
|
+
}
|
|
19
|
+
registerScheduler(capability) {
|
|
20
|
+
this.schedulers.set(capability.id, capability);
|
|
21
|
+
}
|
|
22
|
+
registerUi(capability) {
|
|
23
|
+
this.ui.set(capability.id, capability);
|
|
24
|
+
}
|
|
25
|
+
registerContributions(contributions) {
|
|
26
|
+
for (const capability of contributions.agents || []) {
|
|
27
|
+
this.registerAgent(capability);
|
|
28
|
+
}
|
|
29
|
+
for (const capability of contributions.channels || []) {
|
|
30
|
+
this.registerChannel(capability);
|
|
31
|
+
}
|
|
32
|
+
for (const capability of contributions.knowledge || []) {
|
|
33
|
+
this.registerKnowledge(capability);
|
|
34
|
+
}
|
|
35
|
+
for (const capability of contributions.schedulers || []) {
|
|
36
|
+
this.registerScheduler(capability);
|
|
37
|
+
}
|
|
38
|
+
for (const capability of contributions.ui || []) {
|
|
39
|
+
this.registerUi(capability);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
listAgents() {
|
|
43
|
+
return [...this.agents.values()];
|
|
44
|
+
}
|
|
45
|
+
listChannels() {
|
|
46
|
+
return [...this.channels.values()];
|
|
47
|
+
}
|
|
48
|
+
listKnowledge() {
|
|
49
|
+
return [...this.knowledge.values()];
|
|
50
|
+
}
|
|
51
|
+
listSchedulers() {
|
|
52
|
+
return [...this.schedulers.values()];
|
|
53
|
+
}
|
|
54
|
+
listUi() {
|
|
55
|
+
return [...this.ui.values()];
|
|
56
|
+
}
|
|
57
|
+
snapshot() {
|
|
58
|
+
return {
|
|
59
|
+
agents: this.listAgents(),
|
|
60
|
+
channels: this.listChannels(),
|
|
61
|
+
knowledge: this.listKnowledge(),
|
|
62
|
+
schedulers: this.listSchedulers(),
|
|
63
|
+
ui: this.listUi(),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.LocalCoreCapabilityRegistry = LocalCoreCapabilityRegistry;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalCoreDiagnostics = void 0;
|
|
4
|
+
class LocalCoreDiagnostics {
|
|
5
|
+
registry;
|
|
6
|
+
lifecycle;
|
|
7
|
+
constructor(registry, lifecycle) {
|
|
8
|
+
this.registry = registry;
|
|
9
|
+
this.lifecycle = lifecycle;
|
|
10
|
+
}
|
|
11
|
+
async snapshot() {
|
|
12
|
+
const plugins = this.registry.list();
|
|
13
|
+
const health = await this.lifecycle.healthCheckAll();
|
|
14
|
+
const healthByPlugin = new Map(health.map((entry) => [entry.pluginId, entry.health]));
|
|
15
|
+
return {
|
|
16
|
+
pluginCount: plugins.length,
|
|
17
|
+
enabledPluginCount: plugins.filter((plugin) => this.registry.isEnabled(plugin.manifest.id)).length,
|
|
18
|
+
plugins: plugins.map((plugin) => ({
|
|
19
|
+
pluginId: plugin.manifest.id,
|
|
20
|
+
enabled: this.registry.isEnabled(plugin.manifest.id),
|
|
21
|
+
manifest: plugin.manifest,
|
|
22
|
+
health: healthByPlugin.get(plugin.manifest.id) || { status: 'healthy' },
|
|
23
|
+
})),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.LocalCoreDiagnostics = LocalCoreDiagnostics;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalCoreEventBus = void 0;
|
|
4
|
+
class LocalCoreEventBus {
|
|
5
|
+
listeners = new Map();
|
|
6
|
+
emit(event) {
|
|
7
|
+
const listeners = this.listeners.get(event.type);
|
|
8
|
+
if (!listeners) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
for (const listener of listeners) {
|
|
12
|
+
listener(event.payload);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
on(type, listener) {
|
|
16
|
+
const listeners = this.listeners.get(type) || new Set();
|
|
17
|
+
listeners.add(listener);
|
|
18
|
+
this.listeners.set(type, listeners);
|
|
19
|
+
return () => {
|
|
20
|
+
listeners.delete(listener);
|
|
21
|
+
if (!listeners.size) {
|
|
22
|
+
this.listeners.delete(type);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.LocalCoreEventBus = LocalCoreEventBus;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalCoreLifecycleManager = void 0;
|
|
4
|
+
class LocalCoreLifecycleManager {
|
|
5
|
+
registry;
|
|
6
|
+
context;
|
|
7
|
+
initialized = false;
|
|
8
|
+
started = false;
|
|
9
|
+
constructor(registry, context) {
|
|
10
|
+
this.registry = registry;
|
|
11
|
+
this.context = context;
|
|
12
|
+
}
|
|
13
|
+
async initAll() {
|
|
14
|
+
if (this.initialized) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
for (const plugin of this.registry.listEnabled()) {
|
|
18
|
+
try {
|
|
19
|
+
await plugin.init?.(this.context);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
this.context.logger.log(`[plugin:${plugin.manifest.id}] init failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
this.initialized = true;
|
|
26
|
+
}
|
|
27
|
+
async startAll() {
|
|
28
|
+
if (this.started) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
await this.initAll();
|
|
32
|
+
for (const plugin of this.registry.listEnabled()) {
|
|
33
|
+
try {
|
|
34
|
+
await plugin.start?.();
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
this.context.logger.log(`[plugin:${plugin.manifest.id}] start failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
this.started = true;
|
|
41
|
+
}
|
|
42
|
+
async stopAll() {
|
|
43
|
+
if (!this.initialized) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const plugins = this.registry.listEnabled().slice().reverse();
|
|
47
|
+
for (const plugin of plugins) {
|
|
48
|
+
try {
|
|
49
|
+
await plugin.stop?.();
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
this.context.logger.log(`[plugin:${plugin.manifest.id}] stop failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
this.started = false;
|
|
56
|
+
}
|
|
57
|
+
async healthCheckAll() {
|
|
58
|
+
const results = [];
|
|
59
|
+
for (const plugin of this.registry.list()) {
|
|
60
|
+
if (!this.registry.isEnabled(plugin.manifest.id)) {
|
|
61
|
+
results.push({
|
|
62
|
+
pluginId: plugin.manifest.id,
|
|
63
|
+
health: { status: 'degraded', summary: 'Plugin is disabled by runtime settings.' },
|
|
64
|
+
});
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
let health;
|
|
68
|
+
try {
|
|
69
|
+
health = await plugin.healthCheck?.() || { status: 'healthy' };
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
health = {
|
|
73
|
+
status: 'failed',
|
|
74
|
+
summary: error instanceof Error ? error.message : String(error),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
results.push({
|
|
78
|
+
pluginId: plugin.manifest.id,
|
|
79
|
+
health,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return results;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.LocalCoreLifecycleManager = LocalCoreLifecycleManager;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalCorePluginRegistry = void 0;
|
|
4
|
+
class LocalCorePluginRegistry {
|
|
5
|
+
plugins = new Map();
|
|
6
|
+
disabledPluginIds = new Set();
|
|
7
|
+
registrationOrder = new Map();
|
|
8
|
+
nextRegistrationOrder = 0;
|
|
9
|
+
constructor(disabledPluginIds = []) {
|
|
10
|
+
for (const pluginId of disabledPluginIds) {
|
|
11
|
+
this.disabledPluginIds.add(pluginId);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
register(plugin) {
|
|
15
|
+
if (this.plugins.has(plugin.manifest.id)) {
|
|
16
|
+
throw new Error(`Plugin already registered: ${plugin.manifest.id}`);
|
|
17
|
+
}
|
|
18
|
+
this.plugins.set(plugin.manifest.id, plugin);
|
|
19
|
+
this.registrationOrder.set(plugin.manifest.id, this.nextRegistrationOrder++);
|
|
20
|
+
}
|
|
21
|
+
get(pluginId) {
|
|
22
|
+
return this.plugins.get(pluginId) || null;
|
|
23
|
+
}
|
|
24
|
+
list() {
|
|
25
|
+
const sorted = [];
|
|
26
|
+
const visiting = new Set();
|
|
27
|
+
const visited = new Set();
|
|
28
|
+
const visit = (plugin) => {
|
|
29
|
+
const pluginId = plugin.manifest.id;
|
|
30
|
+
if (visited.has(pluginId)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (visiting.has(pluginId)) {
|
|
34
|
+
throw new Error(`Plugin dependency cycle detected at: ${pluginId}`);
|
|
35
|
+
}
|
|
36
|
+
visiting.add(pluginId);
|
|
37
|
+
for (const dependencyId of plugin.manifest.dependsOn || []) {
|
|
38
|
+
const dependency = this.plugins.get(dependencyId);
|
|
39
|
+
if (!dependency) {
|
|
40
|
+
throw new Error(`Plugin dependency missing: ${pluginId} depends on ${dependencyId}`);
|
|
41
|
+
}
|
|
42
|
+
visit(dependency);
|
|
43
|
+
}
|
|
44
|
+
visiting.delete(pluginId);
|
|
45
|
+
visited.add(pluginId);
|
|
46
|
+
sorted.push(plugin);
|
|
47
|
+
};
|
|
48
|
+
for (const plugin of [...this.plugins.values()].sort((a, b) => (this.registrationOrder.get(a.manifest.id) ?? 0) - (this.registrationOrder.get(b.manifest.id) ?? 0))) {
|
|
49
|
+
visit(plugin);
|
|
50
|
+
}
|
|
51
|
+
return sorted;
|
|
52
|
+
}
|
|
53
|
+
isEnabled(pluginId) {
|
|
54
|
+
return !this.disabledPluginIds.has(pluginId);
|
|
55
|
+
}
|
|
56
|
+
listEnabled() {
|
|
57
|
+
return this.list().filter((plugin) => this.isEnabled(plugin.manifest.id));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.LocalCorePluginRegistry = LocalCorePluginRegistry;
|
package/dist-electron/services/local-ai-core/src/plugins/builtin/agent-localcore-acp-plugin.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBuiltinLocalCoreAcpAgentPlugin = createBuiltinLocalCoreAcpAgentPlugin;
|
|
4
|
+
exports.createBuiltinOpencodeAgentPlugin = createBuiltinOpencodeAgentPlugin;
|
|
5
|
+
exports.createBuiltinClaudeCodeAgentPlugin = createBuiltinClaudeCodeAgentPlugin;
|
|
6
|
+
exports.createBuiltinStaticAgentCapabilityPlugin = createBuiltinStaticAgentCapabilityPlugin;
|
|
7
|
+
const desktop_js_1 = require("../../../../../shared/desktop.js");
|
|
8
|
+
const workspace_route_config_js_1 = require("../../router/workspace-route-config.js");
|
|
9
|
+
function createRuntime(agentType, match) {
|
|
10
|
+
return {
|
|
11
|
+
agentType,
|
|
12
|
+
transport: desktop_js_1.LOCALCORE_ACP_AGENT_TYPE,
|
|
13
|
+
displayName: agentType,
|
|
14
|
+
matchesProject(project) {
|
|
15
|
+
const normalizedAgentType = String(project.agent?.type || '').trim().toLowerCase();
|
|
16
|
+
return match(normalizedAgentType);
|
|
17
|
+
},
|
|
18
|
+
createRoute(configState, project) {
|
|
19
|
+
if (!this.matchesProject(project)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
kind: desktop_js_1.LOCALCORE_ACP_AGENT_TYPE,
|
|
24
|
+
agentType,
|
|
25
|
+
transport: desktop_js_1.LOCALCORE_ACP_AGENT_TYPE,
|
|
26
|
+
config: {
|
|
27
|
+
...(0, workspace_route_config_js_1.toLocalCoreProjectConfig)(configState, project),
|
|
28
|
+
agentType,
|
|
29
|
+
},
|
|
30
|
+
supportsStreamingProbe: true,
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function createBuiltinAgentPlugin(options) {
|
|
36
|
+
let runtime = null;
|
|
37
|
+
return {
|
|
38
|
+
manifest: {
|
|
39
|
+
id: options.pluginId,
|
|
40
|
+
kind: 'agent',
|
|
41
|
+
version: '0.1.0',
|
|
42
|
+
provides: [`agent:${options.agentType}`],
|
|
43
|
+
},
|
|
44
|
+
capabilities: {
|
|
45
|
+
agents: [
|
|
46
|
+
{
|
|
47
|
+
id: `agent.${options.agentType}`,
|
|
48
|
+
agentType: options.agentType,
|
|
49
|
+
displayName: options.displayName || options.agentType,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
createRuntime(_ctx) {
|
|
54
|
+
if (!runtime) {
|
|
55
|
+
runtime = createRuntime(options.agentType, options.match);
|
|
56
|
+
}
|
|
57
|
+
return { runtime };
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function createBuiltinLocalCoreAcpAgentPlugin() {
|
|
62
|
+
const plugin = createBuiltinAgentPlugin({
|
|
63
|
+
pluginId: 'builtin.agent-localcore-acp',
|
|
64
|
+
agentType: desktop_js_1.LOCALCORE_ACP_AGENT_TYPE,
|
|
65
|
+
match: (normalizedAgentType) => !normalizedAgentType || normalizedAgentType === 'acp' || normalizedAgentType === desktop_js_1.LOCALCORE_ACP_AGENT_TYPE,
|
|
66
|
+
displayName: 'LocalCore ACP',
|
|
67
|
+
});
|
|
68
|
+
plugin.capabilities = {
|
|
69
|
+
...plugin.capabilities,
|
|
70
|
+
channels: [
|
|
71
|
+
{
|
|
72
|
+
id: `channel.${desktop_js_1.LOCALCORE_ACP_AGENT_TYPE}`,
|
|
73
|
+
platform: desktop_js_1.LOCALCORE_ACP_AGENT_TYPE,
|
|
74
|
+
displayName: 'LocalCore ACP',
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
return plugin;
|
|
79
|
+
}
|
|
80
|
+
function createBuiltinOpencodeAgentPlugin() {
|
|
81
|
+
return createBuiltinAgentPlugin({
|
|
82
|
+
pluginId: 'builtin.agent-opencode',
|
|
83
|
+
agentType: 'opencode',
|
|
84
|
+
match: (normalizedAgentType) => normalizedAgentType === 'opencode',
|
|
85
|
+
displayName: 'OpenCode',
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function createBuiltinClaudeCodeAgentPlugin() {
|
|
89
|
+
return createBuiltinAgentPlugin({
|
|
90
|
+
pluginId: 'builtin.agent-claudecode',
|
|
91
|
+
agentType: 'claudecode',
|
|
92
|
+
match: (normalizedAgentType) => normalizedAgentType === 'claudecode',
|
|
93
|
+
displayName: 'Claude Code',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function createBuiltinStaticAgentCapabilityPlugin(agentType) {
|
|
97
|
+
return {
|
|
98
|
+
manifest: {
|
|
99
|
+
id: `builtin.agent-${agentType}`,
|
|
100
|
+
kind: 'agent',
|
|
101
|
+
version: '0.1.0',
|
|
102
|
+
provides: [`agent:${agentType}`],
|
|
103
|
+
},
|
|
104
|
+
capabilities: {
|
|
105
|
+
agents: [
|
|
106
|
+
{
|
|
107
|
+
id: `agent.${agentType}`,
|
|
108
|
+
agentType,
|
|
109
|
+
displayName: agentType,
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|