@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
|
@@ -2,17 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerSecurityHandlers = registerSecurityHandlers;
|
|
4
4
|
const server_helpers_js_1 = require("../server-helpers.js");
|
|
5
|
+
const request_validation_js_1 = require("../request-validation.js");
|
|
5
6
|
function registerSecurityHandlers(map, workspaceRouter) {
|
|
6
7
|
map.set('workspace-security.get', async (route, _req, res) => {
|
|
7
8
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.getWorkspaceSecuritySettings(route.workspaceId));
|
|
8
9
|
});
|
|
9
10
|
map.set('workspace-security.update', async (route, req, res) => {
|
|
10
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req)
|
|
11
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), {
|
|
12
|
+
permissions: 'object', allowPaths: { kind: 'array', elementKind: 'string' },
|
|
13
|
+
denyPaths: { kind: 'array', elementKind: 'string' }, updatedBy: 'string',
|
|
14
|
+
});
|
|
11
15
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.updateWorkspaceSecuritySettings(route.workspaceId, body));
|
|
12
16
|
});
|
|
13
17
|
map.set('security.command-risk.classify', async (_route, req, res) => {
|
|
14
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req)
|
|
15
|
-
|
|
18
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), {
|
|
19
|
+
command: { kind: 'string', required: true }, workspaceId: 'string',
|
|
20
|
+
});
|
|
21
|
+
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.classifyCommand(body.command, body.workspaceId));
|
|
16
22
|
});
|
|
17
23
|
map.set('approvals.list', async (_route, _req, res, url) => {
|
|
18
24
|
const statusParam = url.searchParams.get('status') || '';
|
|
@@ -25,14 +31,21 @@ function registerSecurityHandlers(map, workspaceRouter) {
|
|
|
25
31
|
}));
|
|
26
32
|
});
|
|
27
33
|
map.set('approvals.create', async (_route, req, res) => {
|
|
28
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req)
|
|
34
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), {
|
|
35
|
+
workspaceId: { kind: 'string', required: true }, taskId: 'string', threadId: 'string', runId: 'string', deviceId: 'string',
|
|
36
|
+
kind: { kind: 'string', required: true }, riskLevel: { kind: 'string', required: true }, title: { kind: 'string', required: true },
|
|
37
|
+
description: { kind: 'string', required: true }, requestedAction: { kind: 'string', required: true }, command: 'string',
|
|
38
|
+
scopes: { kind: 'array', elementKind: 'string' }, options: 'array', requestedBy: 'string', expiresAt: 'string', metadata: 'object',
|
|
39
|
+
});
|
|
29
40
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.createApprovalRequest(body));
|
|
30
41
|
});
|
|
31
42
|
map.set('approval.get', async (route, _req, res) => {
|
|
32
43
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.getApprovalRequest(route.approvalId));
|
|
33
44
|
});
|
|
34
45
|
map.set('approval.resolve', async (route, req, res) => {
|
|
35
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req)
|
|
46
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), {
|
|
47
|
+
status: { kind: 'string', required: true }, resolvedBy: 'string', resolution: 'string',
|
|
48
|
+
});
|
|
36
49
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.resolveApprovalRequest(route.approvalId, body));
|
|
37
50
|
});
|
|
38
51
|
map.set('audit-events.list', async (_route, _req, res, url) => {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerTaskHandlers = registerTaskHandlers;
|
|
4
4
|
const server_helpers_js_1 = require("../server-helpers.js");
|
|
5
|
+
const request_validation_js_1 = require("../request-validation.js");
|
|
5
6
|
function registerTaskHandlers(map, workspaceRouter) {
|
|
6
7
|
map.set('tasks.list', async (_route, _req, res, url) => {
|
|
7
8
|
const statusParam = url.searchParams.get('status') || '';
|
|
@@ -14,14 +15,25 @@ function registerTaskHandlers(map, workspaceRouter) {
|
|
|
14
15
|
}));
|
|
15
16
|
});
|
|
16
17
|
map.set('tasks.create', async (_route, req, res) => {
|
|
17
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req)
|
|
18
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), {
|
|
19
|
+
workspaceId: { kind: 'string', required: true },
|
|
20
|
+
runtimeId: { kind: 'string', required: true },
|
|
21
|
+
threadId: 'string',
|
|
22
|
+
title: { kind: 'string', required: true },
|
|
23
|
+
prompt: 'string',
|
|
24
|
+
metadata: 'object',
|
|
25
|
+
});
|
|
18
26
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.createAgentTask(body));
|
|
19
27
|
});
|
|
20
28
|
map.set('task.get', async (route, _req, res) => {
|
|
21
29
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.getAgentTask(route.taskId));
|
|
22
30
|
});
|
|
23
31
|
map.set('task.update', async (route, req, res) => {
|
|
24
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req)
|
|
32
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), {
|
|
33
|
+
status: 'string', threadId: 'string', runId: 'string', title: 'string', summary: 'string',
|
|
34
|
+
error: { kind: 'string', nullable: true }, timelineItem: 'object', log: 'object', artifact: 'object',
|
|
35
|
+
approvalId: 'string', metadata: 'object',
|
|
36
|
+
});
|
|
25
37
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.updateAgentTask(route.taskId, body));
|
|
26
38
|
});
|
|
27
39
|
}
|
|
@@ -2,43 +2,46 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerThreadHandlers = registerThreadHandlers;
|
|
4
4
|
const server_helpers_js_1 = require("../server-helpers.js");
|
|
5
|
+
const request_validation_js_1 = require("../request-validation.js");
|
|
5
6
|
function registerThreadHandlers(map, workspaceRouter) {
|
|
6
7
|
map.set('threads.list', async (_route, _req, res, url) => {
|
|
7
8
|
const workspaceId = String(url.searchParams.get('workspace_id') || '');
|
|
8
9
|
(0, server_helpers_js_1.json)(res, 200, { threads: workspaceId ? await workspaceRouter.listThreads(workspaceId) : [] });
|
|
9
10
|
});
|
|
10
11
|
map.set('threads.create', async (_route, req, res) => {
|
|
11
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req)
|
|
12
|
-
|
|
12
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), {
|
|
13
|
+
workspaceId: { kind: 'string', required: true },
|
|
14
|
+
title: 'string',
|
|
15
|
+
});
|
|
16
|
+
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.createThread(body.workspaceId, body.title || undefined));
|
|
13
17
|
});
|
|
14
18
|
map.set('thread.get', async (route, _req, res) => {
|
|
15
19
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.getThread(route.threadId));
|
|
16
20
|
});
|
|
17
21
|
map.set('thread.update-knowledge-bases', async (route, req, res) => {
|
|
18
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.updateThreadKnowledgeBases(route.threadId, knowledgeBaseIds));
|
|
22
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), {
|
|
23
|
+
knowledgeBaseIds: { kind: 'array', required: true, elementKind: 'string' },
|
|
24
|
+
});
|
|
25
|
+
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.updateThreadKnowledgeBases(route.threadId, body.knowledgeBaseIds));
|
|
23
26
|
});
|
|
24
27
|
map.set('thread.update-mode', async (route, req, res) => {
|
|
25
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req);
|
|
26
|
-
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.setThreadMode(route.threadId,
|
|
28
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), { mode: { kind: 'string', required: true } });
|
|
29
|
+
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.setThreadMode(route.threadId, body.mode));
|
|
27
30
|
});
|
|
28
31
|
map.set('thread.rename', async (route, req, res) => {
|
|
29
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req);
|
|
30
|
-
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.renameThread(route.threadId,
|
|
32
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), { title: { kind: 'string', required: true } });
|
|
33
|
+
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.renameThread(route.threadId, body.title));
|
|
31
34
|
});
|
|
32
35
|
map.set('thread.delete', async (route, _req, res) => {
|
|
33
36
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.deleteThread(route.threadId));
|
|
34
37
|
});
|
|
35
38
|
map.set('thread.messages.send', async (route, req, res) => {
|
|
36
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req);
|
|
37
|
-
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.sendThreadMessage(route.threadId,
|
|
39
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), { content: { kind: 'string', required: true } });
|
|
40
|
+
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.sendThreadMessage(route.threadId, body.content));
|
|
38
41
|
});
|
|
39
42
|
map.set('thread.actions.send', async (route, req, res) => {
|
|
40
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req);
|
|
41
|
-
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.sendThreadAction(route.threadId,
|
|
43
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), { content: { kind: 'string', required: true } });
|
|
44
|
+
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.sendThreadAction(route.threadId, body.content));
|
|
42
45
|
});
|
|
43
46
|
map.set('run.interrupt', async (route, _req, res) => {
|
|
44
47
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.interruptRun(route.runId));
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerWorkspaceHandlers = registerWorkspaceHandlers;
|
|
4
4
|
const server_helpers_js_1 = require("../server-helpers.js");
|
|
5
|
+
const request_validation_js_1 = require("../request-validation.js");
|
|
5
6
|
function registerWorkspaceHandlers(map, workspaceRouter) {
|
|
6
7
|
map.set('workspaces.list', async (_route, _req, res) => {
|
|
7
8
|
(0, server_helpers_js_1.json)(res, 200, { workspaces: await workspaceRouter.listWorkspaces() });
|
|
@@ -13,14 +14,24 @@ function registerWorkspaceHandlers(map, workspaceRouter) {
|
|
|
13
14
|
(0, server_helpers_js_1.json)(res, 200, { workspaces: await workspaceRouter.listWorkspaceRegistry() });
|
|
14
15
|
});
|
|
15
16
|
map.set('workspace-registry.create', async (_route, req, res) => {
|
|
16
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req)
|
|
17
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), {
|
|
18
|
+
displayName: { kind: 'string', required: true },
|
|
19
|
+
path: { kind: 'string', required: true },
|
|
20
|
+
defaultRuntimeId: 'string',
|
|
21
|
+
metadata: 'object',
|
|
22
|
+
});
|
|
17
23
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.createWorkspaceRegistryEntry(body));
|
|
18
24
|
});
|
|
19
25
|
map.set('workspace-registry.get', async (route, _req, res) => {
|
|
20
26
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.getWorkspaceRegistryEntry(route.workspaceId));
|
|
21
27
|
});
|
|
22
28
|
map.set('workspace-registry.update', async (route, req, res) => {
|
|
23
|
-
const body = await (0, server_helpers_js_1.readJsonBody)(req)
|
|
29
|
+
const body = (0, request_validation_js_1.validateBody)(await (0, server_helpers_js_1.readJsonBody)(req), {
|
|
30
|
+
displayName: 'string',
|
|
31
|
+
path: 'string',
|
|
32
|
+
defaultRuntimeId: { kind: 'string', nullable: true },
|
|
33
|
+
metadata: 'object',
|
|
34
|
+
});
|
|
24
35
|
(0, server_helpers_js_1.json)(res, 200, await workspaceRouter.updateWorkspaceRegistryEntry(route.workspaceId, body));
|
|
25
36
|
});
|
|
26
37
|
map.set('workspace-registry.delete', async (route, _req, res) => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LocalCoreController = void 0;
|
|
4
4
|
const node_events_1 = require("node:events");
|
|
5
|
-
const
|
|
5
|
+
const superai_contracts_1 = require("../../../../packages/contracts/src/index.js");
|
|
6
6
|
const bootstrap_js_1 = require("../kernel/bootstrap.js");
|
|
7
7
|
const local_core_errors_js_1 = require("../kernel/local-core-errors.js");
|
|
8
8
|
const runtime_detection_service_js_1 = require("./runtime-detection-service.js");
|
|
@@ -10,6 +10,7 @@ const provider_config_migration_js_1 = require("./provider-config-migration.js")
|
|
|
10
10
|
const channel_service_js_1 = require("./channel-service.js");
|
|
11
11
|
const external_service_js_1 = require("./external-service.js");
|
|
12
12
|
const deployment_diagnostics_js_1 = require("./deployment-diagnostics.js");
|
|
13
|
+
const workspace_project_registry_js_1 = require("./workspace-project-registry.js");
|
|
13
14
|
class LocalCoreController extends node_events_1.EventEmitter {
|
|
14
15
|
userDataPath;
|
|
15
16
|
store;
|
|
@@ -109,18 +110,17 @@ class LocalCoreController extends node_events_1.EventEmitter {
|
|
|
109
110
|
const settings = this.state.getSettings();
|
|
110
111
|
const workspaceIds = Array.isArray(runtimeConfig.config?.projects)
|
|
111
112
|
? runtimeConfig.config.projects
|
|
112
|
-
.map((project) => String(project?.
|
|
113
|
+
.map((project) => String(project?.workspace_id || '').trim())
|
|
113
114
|
.filter(Boolean)
|
|
114
115
|
: [];
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
: workspaceIds[0] || '';
|
|
116
|
+
const configuredDefault = runtimeConfig.config.projects?.find((project) => project.workspace_id === settings.defaultProject || project.name === settings.defaultProject)?.workspace_id;
|
|
117
|
+
const defaultProject = configuredDefault || workspaceIds[0] || '';
|
|
118
118
|
return {
|
|
119
119
|
mode: 'desktop',
|
|
120
120
|
phase: 'api_ready',
|
|
121
121
|
pendingRestart: false,
|
|
122
122
|
service,
|
|
123
|
-
roles: (0,
|
|
123
|
+
roles: (0, superai_contracts_1.deriveDesktopRuntimeRoles)(service),
|
|
124
124
|
settings: {
|
|
125
125
|
...settings,
|
|
126
126
|
defaultProject,
|
|
@@ -152,11 +152,19 @@ class LocalCoreController extends node_events_1.EventEmitter {
|
|
|
152
152
|
}
|
|
153
153
|
async saveRuntimeConfig(config) {
|
|
154
154
|
const migrated = (0, provider_config_migration_js_1.migrateLegacyProjectProvidersToStore)(config, this.store);
|
|
155
|
-
|
|
155
|
+
if (typeof this.store.listWorkspaceRegistry !== 'function') {
|
|
156
|
+
const next = this.store.saveRuntimeConfig(migrated.config);
|
|
157
|
+
await this.channelService.refreshBindings();
|
|
158
|
+
await this.emitRuntime();
|
|
159
|
+
return { ...next, warnings: [...(next.warnings || []), ...migrated.warnings] };
|
|
160
|
+
}
|
|
161
|
+
const projects = (0, workspace_project_registry_js_1.persistProjectsInRegistry)(this.store, migrated.config.projects || []);
|
|
162
|
+
const next = this.store.saveRuntimeConfig((0, workspace_project_registry_js_1.withoutRuntimeProjects)(migrated.config));
|
|
156
163
|
await this.channelService.refreshBindings();
|
|
157
164
|
await this.emitRuntime();
|
|
158
165
|
return {
|
|
159
166
|
...next,
|
|
167
|
+
config: { ...next.config, projects },
|
|
160
168
|
warnings: [
|
|
161
169
|
...(next.warnings || []),
|
|
162
170
|
...migrated.warnings,
|
|
@@ -284,7 +292,26 @@ class LocalCoreController extends node_events_1.EventEmitter {
|
|
|
284
292
|
}
|
|
285
293
|
}
|
|
286
294
|
async readAndMigrateRuntimeConfig() {
|
|
287
|
-
|
|
295
|
+
const current = this.store.readRuntimeConfig();
|
|
296
|
+
const migrated = (0, provider_config_migration_js_1.migrateLegacyProjectProvidersToStore)(current.config, this.store);
|
|
297
|
+
if (typeof this.store.listWorkspaceRegistry !== 'function') {
|
|
298
|
+
return { ...current, config: migrated.config, warnings: [...(current.warnings || []), ...migrated.warnings] };
|
|
299
|
+
}
|
|
300
|
+
const legacyProjects = migrated.config.projects || [];
|
|
301
|
+
let warnings = [...(current.warnings || []), ...migrated.warnings];
|
|
302
|
+
if (legacyProjects.length > 0) {
|
|
303
|
+
(0, workspace_project_registry_js_1.persistProjectsInRegistry)(this.store, legacyProjects, { preserveLegacyIds: true });
|
|
304
|
+
const saved = this.store.saveRuntimeConfig((0, workspace_project_registry_js_1.withoutRuntimeProjects)(migrated.config));
|
|
305
|
+
warnings = [...warnings, ...(saved.warnings || []), 'Migrated runtime projects into the workspace registry.'];
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
...this.store.readRuntimeConfig(),
|
|
309
|
+
config: {
|
|
310
|
+
...this.store.readRuntimeConfig().config,
|
|
311
|
+
projects: (0, workspace_project_registry_js_1.listRegistryProjects)(this.store),
|
|
312
|
+
},
|
|
313
|
+
warnings: [...new Set(warnings)],
|
|
314
|
+
};
|
|
288
315
|
}
|
|
289
316
|
}
|
|
290
317
|
exports.LocalCoreController = LocalCoreController;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequestValidationError = void 0;
|
|
4
|
+
exports.validateBody = validateBody;
|
|
5
|
+
exports.assertJsonObject = assertJsonObject;
|
|
6
|
+
const local_core_errors_js_1 = require("../kernel/local-core-errors.js");
|
|
7
|
+
class RequestValidationError extends local_core_errors_js_1.LocalCoreError {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super('config_invalid', message, {
|
|
10
|
+
userMessage: message,
|
|
11
|
+
retryable: false,
|
|
12
|
+
});
|
|
13
|
+
this.name = 'RequestValidationError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.RequestValidationError = RequestValidationError;
|
|
17
|
+
function validateBody(value, schema, label = 'Request body') {
|
|
18
|
+
if (!isRecord(value)) {
|
|
19
|
+
throw new RequestValidationError(`${label} must be a JSON object.`);
|
|
20
|
+
}
|
|
21
|
+
for (const [field, rawRule] of Object.entries(schema)) {
|
|
22
|
+
const rule = typeof rawRule === 'string' ? { kind: rawRule } : rawRule;
|
|
23
|
+
const fieldValue = value[field];
|
|
24
|
+
if (fieldValue === undefined) {
|
|
25
|
+
if (rule.required) {
|
|
26
|
+
throw new RequestValidationError(`${label}.${field} is required.`);
|
|
27
|
+
}
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (fieldValue === null && rule.nullable) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (!matchesKind(fieldValue, rule.kind)) {
|
|
34
|
+
throw new RequestValidationError(`${label}.${field} must be ${article(rule.kind)} ${rule.kind}.`);
|
|
35
|
+
}
|
|
36
|
+
if (rule.kind === 'string' && rule.required && !fieldValue.trim()) {
|
|
37
|
+
throw new RequestValidationError(`${label}.${field} must not be empty.`);
|
|
38
|
+
}
|
|
39
|
+
if (rule.allowedValues && !rule.allowedValues.includes(fieldValue)) {
|
|
40
|
+
throw new RequestValidationError(`${label}.${field} must be one of: ${rule.allowedValues.join(', ')}.`);
|
|
41
|
+
}
|
|
42
|
+
if (rule.kind === 'object' && rule.fields) {
|
|
43
|
+
validateBody(fieldValue, rule.fields, `${label}.${field}`);
|
|
44
|
+
}
|
|
45
|
+
if (rule.kind === 'object' && rule.valueSchema) {
|
|
46
|
+
for (const [key, item] of Object.entries(fieldValue)) {
|
|
47
|
+
validateBody(item, rule.valueSchema, `${label}.${field}.${key}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (rule.kind === 'array' && rule.elementKind) {
|
|
51
|
+
const invalidIndex = fieldValue.findIndex((item) => !matchesKind(item, rule.elementKind));
|
|
52
|
+
if (invalidIndex >= 0) {
|
|
53
|
+
throw new RequestValidationError(`${label}.${field}[${invalidIndex}] must be ${article(rule.elementKind)} ${rule.elementKind}.`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
function assertJsonObject(value) {
|
|
60
|
+
if (!isRecord(value)) {
|
|
61
|
+
throw new RequestValidationError('Request body must be a JSON object.');
|
|
62
|
+
}
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
function isRecord(value) {
|
|
66
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
67
|
+
}
|
|
68
|
+
function matchesKind(value, kind) {
|
|
69
|
+
if (kind === 'array') {
|
|
70
|
+
return Array.isArray(value);
|
|
71
|
+
}
|
|
72
|
+
if (kind === 'object') {
|
|
73
|
+
return isRecord(value);
|
|
74
|
+
}
|
|
75
|
+
return typeof value === kind && (kind !== 'number' || Number.isFinite(value));
|
|
76
|
+
}
|
|
77
|
+
function article(kind) {
|
|
78
|
+
return kind === 'object' || kind === 'array' ? 'an' : 'a';
|
|
79
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RuntimeDetectionService = void 0;
|
|
4
|
-
const
|
|
4
|
+
const superai_contracts_1 = require("../../../../packages/contracts/src/index.js");
|
|
5
5
|
const index_js_1 = require("../agents/index.js");
|
|
6
6
|
const agent_runtime_detector_js_1 = require("./agent-runtime-detector.js");
|
|
7
7
|
const runtime_detection_store_js_1 = require("./runtime-detection-store.js");
|
|
@@ -122,22 +122,22 @@ class RuntimeDetectionService {
|
|
|
122
122
|
}
|
|
123
123
|
createUnknownResults() {
|
|
124
124
|
const detectedAt = new Date(0).toISOString();
|
|
125
|
-
return
|
|
125
|
+
return superai_contracts_1.DESKTOP_AGENT_TYPE_OPTIONS.map((agentType) => ({
|
|
126
126
|
agentType,
|
|
127
127
|
runtimeId: agentType,
|
|
128
128
|
displayName: displayName(agentType),
|
|
129
|
-
status: agentType ===
|
|
130
|
-
installed: agentType ===
|
|
131
|
-
readiness: agentType ===
|
|
129
|
+
status: agentType === superai_contracts_1.LOCALCORE_ACP_AGENT_TYPE ? 'installed' : 'unknown',
|
|
130
|
+
installed: agentType === superai_contracts_1.LOCALCORE_ACP_AGENT_TYPE,
|
|
131
|
+
readiness: agentType === superai_contracts_1.LOCALCORE_ACP_AGENT_TYPE ? 'ready' : 'unknown',
|
|
132
132
|
detectedAt,
|
|
133
|
-
summary: agentType ===
|
|
133
|
+
summary: agentType === superai_contracts_1.LOCALCORE_ACP_AGENT_TYPE
|
|
134
134
|
? `${displayName(agentType)} is built in.`
|
|
135
135
|
: `${displayName(agentType)} has not been checked yet.`,
|
|
136
136
|
issues: [],
|
|
137
|
-
recommendedActions: agentType ===
|
|
137
|
+
recommendedActions: agentType === superai_contracts_1.LOCALCORE_ACP_AGENT_TYPE
|
|
138
138
|
? []
|
|
139
139
|
: [{ label: 'Run detection', description: 'Refresh runtime detection to check this machine.' }],
|
|
140
|
-
source: agentType ===
|
|
140
|
+
source: agentType === superai_contracts_1.LOCALCORE_ACP_AGENT_TYPE ? 'builtin' : 'path',
|
|
141
141
|
}));
|
|
142
142
|
}
|
|
143
143
|
filter(runtimes, runtimeId) {
|
|
@@ -147,7 +147,7 @@ class RuntimeDetectionService {
|
|
|
147
147
|
return runtimes.filter((runtime) => runtime.runtimeId === runtimeId || runtime.agentType === runtimeId);
|
|
148
148
|
}
|
|
149
149
|
markChecking(runtimeId) {
|
|
150
|
-
this.checkingRuntimeIds = new Set(runtimeId ? [runtimeId] :
|
|
150
|
+
this.checkingRuntimeIds = new Set(runtimeId ? [runtimeId] : superai_contracts_1.DESKTOP_AGENT_TYPE_OPTIONS);
|
|
151
151
|
}
|
|
152
152
|
unmarkChecking() {
|
|
153
153
|
this.checkingRuntimeIds.clear();
|
|
@@ -14,6 +14,7 @@ exports.sanitizeOpenAiId = sanitizeOpenAiId;
|
|
|
14
14
|
exports.diffAccumulatedText = diffAccumulatedText;
|
|
15
15
|
exports.isTerminalAgentTaskStatus = isTerminalAgentTaskStatus;
|
|
16
16
|
const local_core_errors_js_1 = require("../kernel/local-core-errors.js");
|
|
17
|
+
const request_validation_js_1 = require("./request-validation.js");
|
|
17
18
|
function json(res, statusCode, data, ok = true, error) {
|
|
18
19
|
res.statusCode = statusCode;
|
|
19
20
|
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
@@ -44,7 +45,15 @@ async function readJsonBody(req) {
|
|
|
44
45
|
if (!body.length) {
|
|
45
46
|
return {};
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
try {
|
|
49
|
+
return (0, request_validation_js_1.assertJsonObject)(JSON.parse(Buffer.from(body).toString('utf8')));
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error instanceof request_validation_js_1.RequestValidationError) {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
throw new request_validation_js_1.RequestValidationError('Request body must contain valid JSON.');
|
|
56
|
+
}
|
|
48
57
|
}
|
|
49
58
|
async function readRawBody(req) {
|
|
50
59
|
const chunks = [];
|
|
@@ -18,6 +18,7 @@ const provider_handler_js_1 = require("./handlers/provider-handler.js");
|
|
|
18
18
|
const channel_handler_js_1 = require("./handlers/channel-handler.js");
|
|
19
19
|
const external_handler_js_1 = require("./handlers/external-handler.js");
|
|
20
20
|
const openai_handler_js_1 = require("./handlers/openai-handler.js");
|
|
21
|
+
const request_validation_js_1 = require("./request-validation.js");
|
|
21
22
|
class LocalAiCoreServer {
|
|
22
23
|
bindings;
|
|
23
24
|
host;
|
|
@@ -179,7 +180,7 @@ class LocalAiCoreServer {
|
|
|
179
180
|
(0, server_helpers_js_1.jsonError)(res, 404, new Error(`Unknown route: ${path}`));
|
|
180
181
|
}
|
|
181
182
|
catch (error) {
|
|
182
|
-
(0, server_helpers_js_1.jsonError)(res, 500, error);
|
|
183
|
+
(0, server_helpers_js_1.jsonError)(res, error instanceof request_validation_js_1.RequestValidationError ? 400 : 500, error);
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
attachSseClient(res) {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectWorkspaceId = projectWorkspaceId;
|
|
4
|
+
exports.workspacePathFromProject = workspacePathFromProject;
|
|
5
|
+
exports.listRegistryProjects = listRegistryProjects;
|
|
6
|
+
exports.persistProjectsInRegistry = persistProjectsInRegistry;
|
|
7
|
+
exports.withoutRuntimeProjects = withoutRuntimeProjects;
|
|
8
|
+
const PROJECT_SOURCE = 'runtime-project';
|
|
9
|
+
function projectWorkspaceId(project) {
|
|
10
|
+
return String(project.workspace_id || '').trim();
|
|
11
|
+
}
|
|
12
|
+
function workspacePathFromProject(project) {
|
|
13
|
+
const options = project.agent?.options || {};
|
|
14
|
+
for (const key of ['work_dir', 'workDir', 'cwd', 'path', 'workspacePath', 'root']) {
|
|
15
|
+
const value = options[key];
|
|
16
|
+
if (typeof value === 'string' && value.trim())
|
|
17
|
+
return value.trim();
|
|
18
|
+
}
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
function listRegistryProjects(store) {
|
|
22
|
+
return store.listWorkspaceRegistry()
|
|
23
|
+
.map(projectFromEntry)
|
|
24
|
+
.filter((project) => Boolean(project));
|
|
25
|
+
}
|
|
26
|
+
function persistProjectsInRegistry(store, projects, options = {}) {
|
|
27
|
+
const existing = store.listWorkspaceRegistry();
|
|
28
|
+
const managed = existing.filter((entry) => entry.metadata?.source === PROJECT_SOURCE);
|
|
29
|
+
const byDisplayName = new Map(managed.map((entry) => [entry.displayName, entry]));
|
|
30
|
+
const retainedIds = new Set();
|
|
31
|
+
const normalized = projects.map((project) => {
|
|
32
|
+
const existingByName = byDisplayName.get(project.name);
|
|
33
|
+
const workspaceId = projectWorkspaceId(project)
|
|
34
|
+
|| existingByName?.workspaceId
|
|
35
|
+
|| project.name;
|
|
36
|
+
const nextProject = { ...project, workspace_id: workspaceId };
|
|
37
|
+
const previous = existing.find((entry) => entry.workspaceId === workspaceId);
|
|
38
|
+
const path = workspacePathFromProject(nextProject);
|
|
39
|
+
retainedIds.add(workspaceId);
|
|
40
|
+
store.upsertWorkspaceRegistryEntry({
|
|
41
|
+
workspaceId,
|
|
42
|
+
displayName: nextProject.name,
|
|
43
|
+
path,
|
|
44
|
+
deviceId: previous?.deviceId || 'local',
|
|
45
|
+
defaultRuntimeId: nextProject.agent?.type,
|
|
46
|
+
git: previous?.git,
|
|
47
|
+
health: previous?.health,
|
|
48
|
+
metadata: {
|
|
49
|
+
...(previous?.metadata || {}),
|
|
50
|
+
source: PROJECT_SOURCE,
|
|
51
|
+
project: nextProject,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
return nextProject;
|
|
55
|
+
});
|
|
56
|
+
for (const entry of managed) {
|
|
57
|
+
if (!retainedIds.has(entry.workspaceId))
|
|
58
|
+
store.deleteWorkspaceRegistryEntry(entry.workspaceId);
|
|
59
|
+
}
|
|
60
|
+
return normalized;
|
|
61
|
+
}
|
|
62
|
+
function withoutRuntimeProjects(config) {
|
|
63
|
+
const next = { ...config };
|
|
64
|
+
delete next.projects;
|
|
65
|
+
return next;
|
|
66
|
+
}
|
|
67
|
+
function projectFromEntry(entry) {
|
|
68
|
+
const project = entry.metadata?.project;
|
|
69
|
+
if (!project?.agent)
|
|
70
|
+
return null;
|
|
71
|
+
return {
|
|
72
|
+
...project,
|
|
73
|
+
workspace_id: entry.workspaceId,
|
|
74
|
+
name: entry.displayName,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -15,7 +15,7 @@ exports.sanitizePathSegment = sanitizePathSegment;
|
|
|
15
15
|
exports.resolveHostPathFromConfigDir = resolveHostPathFromConfigDir;
|
|
16
16
|
const node_fs_1 = require("node:fs");
|
|
17
17
|
const node_path_1 = require("node:path");
|
|
18
|
-
const
|
|
18
|
+
const superai_contracts_1 = require("../../../../packages/contracts/src/index.js");
|
|
19
19
|
exports.DEFAULT_OPENSANDBOX_SERVER_URL = 'http://127.0.0.1:8080';
|
|
20
20
|
exports.DEFAULT_OPENSANDBOX_SERVER_URL_ENV = 'AGENTDOCK_OPENSANDBOX_SERVER_URL';
|
|
21
21
|
exports.DEFAULT_OPENSANDBOX_API_KEY_ENV = 'OPEN_SANDBOX_API_KEY';
|
|
@@ -46,7 +46,7 @@ function normalizeSandboxLaunchConfig(input) {
|
|
|
46
46
|
const agentType = input.launchConfig.agentType || String(input.project.agent?.type || '').trim().toLowerCase() || 'agent';
|
|
47
47
|
const desktopConfig = input.configState.config || {};
|
|
48
48
|
const deploymentProfileId = String(raw.deployment_profile || desktopConfig.deployment_profile || process.env.AGENTDOCK_DEPLOYMENT_PROFILE || '').trim();
|
|
49
|
-
const profile = (0,
|
|
49
|
+
const profile = (0, superai_contracts_1.getDesktopDeploymentProfile)(deploymentProfileId);
|
|
50
50
|
const sandboxProvider = resolveSandboxProvider(desktopConfig.sandbox_providers, raw, profile.id);
|
|
51
51
|
const runtimeImage = resolveSandboxRuntimeImage(desktopConfig.sandbox_runtime_images, raw, agentType);
|
|
52
52
|
const stateScope = normalizeStateScope(raw.state_scope);
|
|
@@ -107,14 +107,14 @@ function resolveSandboxProvider(providers, raw, profileId) {
|
|
|
107
107
|
const providerId = String(raw.provider_id || '').trim();
|
|
108
108
|
const selected = Array.isArray(providers)
|
|
109
109
|
? providers.find((provider) => provider.id === providerId)
|
|
110
|
-
|| providers.find((provider) => provider.id ===
|
|
110
|
+
|| providers.find((provider) => provider.id === superai_contracts_1.DEFAULT_SANDBOX_PROVIDER_ID)
|
|
111
111
|
: undefined;
|
|
112
112
|
if (selected) {
|
|
113
113
|
return selected;
|
|
114
114
|
}
|
|
115
115
|
if (raw.server_url || raw.api_key_env || raw.provider) {
|
|
116
116
|
return {
|
|
117
|
-
id: providerId ||
|
|
117
|
+
id: providerId || superai_contracts_1.DEFAULT_SANDBOX_PROVIDER_ID,
|
|
118
118
|
type: raw.provider || 'opensandbox',
|
|
119
119
|
name: 'OpenSandbox',
|
|
120
120
|
server_url: raw.server_url || defaultOpenSandboxServerUrl(),
|
|
@@ -122,7 +122,7 @@ function resolveSandboxProvider(providers, raw, profileId) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
return {
|
|
125
|
-
...(0,
|
|
125
|
+
...(0, superai_contracts_1.defaultSandboxProviderForProfile)(profileId),
|
|
126
126
|
server_url: defaultOpenSandboxServerUrl(),
|
|
127
127
|
};
|
|
128
128
|
}
|
|
@@ -133,14 +133,14 @@ function resolveSandboxRuntimeImage(images, raw, agentType) {
|
|
|
133
133
|
|| images.find((image) => image.agent_type === agentType)
|
|
134
134
|
: undefined;
|
|
135
135
|
if (selected) {
|
|
136
|
-
const fallback = (0,
|
|
136
|
+
const fallback = (0, superai_contracts_1.defaultSandboxRuntimeImage)(agentType);
|
|
137
137
|
return {
|
|
138
138
|
...selected,
|
|
139
139
|
transport: normalizeSandboxTransport(selected.transport || fallback.transport),
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
if (raw.image || raw.transport || raw.acp_port || raw.entrypoint || raw.workspace_mount_path || raw.state_mount_path) {
|
|
143
|
-
const fallback = (0,
|
|
143
|
+
const fallback = (0, superai_contracts_1.defaultSandboxRuntimeImage)(agentType);
|
|
144
144
|
return {
|
|
145
145
|
id: runtimeImageId || fallback.id,
|
|
146
146
|
agent_type: agentType,
|
|
@@ -152,7 +152,7 @@ function resolveSandboxRuntimeImage(images, raw, agentType) {
|
|
|
152
152
|
state_mount_path: raw.state_mount_path || fallback.state_mount_path,
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
return (0,
|
|
155
|
+
return (0, superai_contracts_1.defaultSandboxRuntimeImage)(agentType);
|
|
156
156
|
}
|
|
157
157
|
function resolveSandboxStateHostPath(config, threadId, runId) {
|
|
158
158
|
if (!config.stateHostPath) {
|