@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,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_test_1 = __importDefault(require("node:test"));
|
|
7
|
+
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
8
|
+
const node_http_1 = require("node:http");
|
|
9
|
+
const lac_js_1 = require("../services/local-ai-core/src/cli/lac.js");
|
|
10
|
+
function createIo() {
|
|
11
|
+
let stdout = '';
|
|
12
|
+
let stderr = '';
|
|
13
|
+
return {
|
|
14
|
+
io: {
|
|
15
|
+
stdout: {
|
|
16
|
+
write(chunk) {
|
|
17
|
+
stdout += chunk;
|
|
18
|
+
return true;
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
stderr: {
|
|
22
|
+
write(chunk) {
|
|
23
|
+
stderr += chunk;
|
|
24
|
+
return true;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
read: () => ({ stdout, stderr }),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
(0, node_test_1.default)('lac scheduler add posts a persistent Lark job from env context', async () => {
|
|
32
|
+
let capturedBody = null;
|
|
33
|
+
const server = (0, node_http_1.createServer)(async (req, res) => {
|
|
34
|
+
if (req.method === 'POST' && req.url === '/api/local/v1/scheduler/jobs') {
|
|
35
|
+
const chunks = [];
|
|
36
|
+
for await (const chunk of req) {
|
|
37
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
38
|
+
}
|
|
39
|
+
capturedBody = Buffer.concat(chunks).toString('utf8');
|
|
40
|
+
res.setHeader('content-type', 'application/json');
|
|
41
|
+
res.end(JSON.stringify({
|
|
42
|
+
ok: true,
|
|
43
|
+
data: {
|
|
44
|
+
id: 'job-1',
|
|
45
|
+
workspaceId: '知识库',
|
|
46
|
+
platform: 'lark',
|
|
47
|
+
route: {
|
|
48
|
+
type: 'channel.chat',
|
|
49
|
+
channelId: 'chat-1',
|
|
50
|
+
participantId: 'user-1',
|
|
51
|
+
threadId: 'thread-1',
|
|
52
|
+
},
|
|
53
|
+
executionMode: 'same-thread',
|
|
54
|
+
triggerType: 'cron',
|
|
55
|
+
cronExpr: '*/2 * * * *',
|
|
56
|
+
promptTemplate: 'ping',
|
|
57
|
+
description: 'two-minute ping',
|
|
58
|
+
enabled: true,
|
|
59
|
+
concurrencyPolicy: 'skip_if_running',
|
|
60
|
+
createdAt: '2026-04-22T06:00:00.000Z',
|
|
61
|
+
updatedAt: '2026-04-22T06:00:00.000Z',
|
|
62
|
+
},
|
|
63
|
+
}));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
res.statusCode = 404;
|
|
67
|
+
res.end(JSON.stringify({ ok: false, error: 'not found' }));
|
|
68
|
+
});
|
|
69
|
+
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
|
|
70
|
+
const address = server.address();
|
|
71
|
+
(0, strict_1.default)(address && typeof address === 'object');
|
|
72
|
+
const { io, read } = createIo();
|
|
73
|
+
const exitCode = await (0, lac_js_1.runCli)(['scheduler', 'add', '--cron', '*/2 * * * *', '--message', 'ping', '--desc', 'two-minute ping'], {
|
|
74
|
+
LOCAL_AI_CORE_BASE: `http://127.0.0.1:${address.port}/api/local/v1`,
|
|
75
|
+
LOCAL_AI_WORKSPACE_ID: '知识库',
|
|
76
|
+
LOCAL_AI_THREAD_ID: 'thread-1',
|
|
77
|
+
LOCAL_AI_PLATFORM: 'lark',
|
|
78
|
+
LOCAL_AI_CHAT_ID: 'chat-1',
|
|
79
|
+
LOCAL_AI_PLATFORM_USER_ID: 'user-1',
|
|
80
|
+
}, io);
|
|
81
|
+
server.close();
|
|
82
|
+
strict_1.default.equal(exitCode, 0);
|
|
83
|
+
(0, strict_1.default)(capturedBody);
|
|
84
|
+
strict_1.default.deepEqual(JSON.parse(capturedBody), {
|
|
85
|
+
workspaceId: '知识库',
|
|
86
|
+
platform: 'lark',
|
|
87
|
+
route: {
|
|
88
|
+
type: 'channel.chat',
|
|
89
|
+
channelId: 'chat-1',
|
|
90
|
+
participantId: 'user-1',
|
|
91
|
+
threadId: 'thread-1',
|
|
92
|
+
},
|
|
93
|
+
executionMode: 'same-thread',
|
|
94
|
+
triggerType: 'cron',
|
|
95
|
+
cronExpr: '*/2 * * * *',
|
|
96
|
+
promptTemplate: 'ping',
|
|
97
|
+
description: 'two-minute ping',
|
|
98
|
+
enabled: true,
|
|
99
|
+
});
|
|
100
|
+
strict_1.default.match(read().stdout, /Created scheduler job job-1/);
|
|
101
|
+
});
|
|
102
|
+
(0, node_test_1.default)('lac scheduler list shows workspace jobs by default', async () => {
|
|
103
|
+
const server = (0, node_http_1.createServer)((req, res) => {
|
|
104
|
+
if (req.method === 'GET' && req.url === '/api/local/v1/scheduler/jobs?workspace_id=%E7%9F%A5%E8%AF%86%E5%BA%93') {
|
|
105
|
+
res.setHeader('content-type', 'application/json');
|
|
106
|
+
res.end(JSON.stringify({
|
|
107
|
+
ok: true,
|
|
108
|
+
data: {
|
|
109
|
+
jobs: [
|
|
110
|
+
{
|
|
111
|
+
id: 'job-1',
|
|
112
|
+
workspaceId: '知识库',
|
|
113
|
+
platform: 'lark',
|
|
114
|
+
route: { type: 'channel.chat', channelId: 'chat-1', participantId: 'user-1', threadId: 'thread-1' },
|
|
115
|
+
executionMode: 'same-thread',
|
|
116
|
+
triggerType: 'cron',
|
|
117
|
+
cronExpr: '*/2 * * * *',
|
|
118
|
+
promptTemplate: 'ping',
|
|
119
|
+
description: 'current',
|
|
120
|
+
enabled: true,
|
|
121
|
+
concurrencyPolicy: 'skip_if_running',
|
|
122
|
+
createdAt: '2026-04-22T06:00:00.000Z',
|
|
123
|
+
updatedAt: '2026-04-22T06:00:00.000Z',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: 'job-2',
|
|
127
|
+
workspaceId: '知识库',
|
|
128
|
+
platform: 'lark',
|
|
129
|
+
route: { type: 'channel.chat', channelId: 'chat-2', participantId: 'user-2', threadId: 'thread-2' },
|
|
130
|
+
executionMode: 'side-thread',
|
|
131
|
+
triggerType: 'cron',
|
|
132
|
+
cronExpr: '0 9 * * *',
|
|
133
|
+
promptTemplate: 'pong',
|
|
134
|
+
description: 'other',
|
|
135
|
+
enabled: true,
|
|
136
|
+
concurrencyPolicy: 'skip_if_running',
|
|
137
|
+
createdAt: '2026-04-22T06:00:00.000Z',
|
|
138
|
+
updatedAt: '2026-04-22T06:00:00.000Z',
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
}));
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
res.statusCode = 404;
|
|
146
|
+
res.end(JSON.stringify({ ok: false, error: 'not found' }));
|
|
147
|
+
});
|
|
148
|
+
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
|
|
149
|
+
const address = server.address();
|
|
150
|
+
(0, strict_1.default)(address && typeof address === 'object');
|
|
151
|
+
const { io, read } = createIo();
|
|
152
|
+
const exitCode = await (0, lac_js_1.runCli)(['scheduler', 'list'], {
|
|
153
|
+
LOCAL_AI_CORE_BASE: `http://127.0.0.1:${address.port}/api/local/v1`,
|
|
154
|
+
LOCAL_AI_WORKSPACE_ID: '知识库',
|
|
155
|
+
LOCAL_AI_THREAD_ID: 'thread-1',
|
|
156
|
+
}, io);
|
|
157
|
+
server.close();
|
|
158
|
+
strict_1.default.equal(exitCode, 0);
|
|
159
|
+
strict_1.default.match(read().stdout, /job-1/);
|
|
160
|
+
strict_1.default.match(read().stdout, /job-2/);
|
|
161
|
+
});
|
|
162
|
+
(0, node_test_1.default)('lac scheduler list --thread filters by current thread context', async () => {
|
|
163
|
+
const server = (0, node_http_1.createServer)((req, res) => {
|
|
164
|
+
if (req.method === 'GET' && req.url === '/api/local/v1/scheduler/jobs?workspace_id=%E7%9F%A5%E8%AF%86%E5%BA%93') {
|
|
165
|
+
res.setHeader('content-type', 'application/json');
|
|
166
|
+
res.end(JSON.stringify({
|
|
167
|
+
ok: true,
|
|
168
|
+
data: {
|
|
169
|
+
jobs: [
|
|
170
|
+
{
|
|
171
|
+
id: 'job-1',
|
|
172
|
+
workspaceId: '知识库',
|
|
173
|
+
platform: 'lark',
|
|
174
|
+
route: { type: 'channel.chat', channelId: 'chat-1', participantId: 'user-1', threadId: 'thread-1' },
|
|
175
|
+
executionMode: 'same-thread',
|
|
176
|
+
triggerType: 'cron',
|
|
177
|
+
cronExpr: '*/2 * * * *',
|
|
178
|
+
promptTemplate: 'ping',
|
|
179
|
+
description: 'current',
|
|
180
|
+
enabled: true,
|
|
181
|
+
concurrencyPolicy: 'skip_if_running',
|
|
182
|
+
createdAt: '2026-04-22T06:00:00.000Z',
|
|
183
|
+
updatedAt: '2026-04-22T06:00:00.000Z',
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
id: 'job-2',
|
|
187
|
+
workspaceId: '知识库',
|
|
188
|
+
platform: 'lark',
|
|
189
|
+
route: { type: 'channel.chat', channelId: 'chat-2', participantId: 'user-2', threadId: 'thread-2' },
|
|
190
|
+
executionMode: 'side-thread',
|
|
191
|
+
triggerType: 'cron',
|
|
192
|
+
cronExpr: '0 9 * * *',
|
|
193
|
+
promptTemplate: 'pong',
|
|
194
|
+
description: 'other',
|
|
195
|
+
enabled: true,
|
|
196
|
+
concurrencyPolicy: 'skip_if_running',
|
|
197
|
+
createdAt: '2026-04-22T06:00:00.000Z',
|
|
198
|
+
updatedAt: '2026-04-22T06:00:00.000Z',
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
},
|
|
202
|
+
}));
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
res.statusCode = 404;
|
|
206
|
+
res.end(JSON.stringify({ ok: false, error: 'not found' }));
|
|
207
|
+
});
|
|
208
|
+
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
|
|
209
|
+
const address = server.address();
|
|
210
|
+
(0, strict_1.default)(address && typeof address === 'object');
|
|
211
|
+
const { io, read } = createIo();
|
|
212
|
+
const exitCode = await (0, lac_js_1.runCli)(['scheduler', 'list', '--thread'], {
|
|
213
|
+
LOCAL_AI_CORE_BASE: `http://127.0.0.1:${address.port}/api/local/v1`,
|
|
214
|
+
LOCAL_AI_WORKSPACE_ID: '知识库',
|
|
215
|
+
LOCAL_AI_THREAD_ID: 'thread-1',
|
|
216
|
+
}, io);
|
|
217
|
+
server.close();
|
|
218
|
+
strict_1.default.equal(exitCode, 0);
|
|
219
|
+
strict_1.default.match(read().stdout, /job-1/);
|
|
220
|
+
strict_1.default.doesNotMatch(read().stdout, /job-2/);
|
|
221
|
+
});
|