dominds 0.1.0
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/LICENSE +157 -0
- package/README.md +250 -0
- package/README.zh.md +161 -0
- package/dist/access-control.js +253 -0
- package/dist/cli/create.js +263 -0
- package/dist/cli/read.js +84 -0
- package/dist/cli/tui.js +199 -0
- package/dist/cli/webui.js +169 -0
- package/dist/cli.js +227 -0
- package/dist/dialog-factory.js +53 -0
- package/dist/dialog-global-registry.js +68 -0
- package/dist/dialog-instance-registry.js +78 -0
- package/dist/dialog-run-state.js +198 -0
- package/dist/dialog.js +1024 -0
- package/dist/evt-registry.js +103 -0
- package/dist/index.js +8 -0
- package/dist/llm/client.js +69 -0
- package/dist/llm/defaults.yaml +386 -0
- package/dist/llm/driver.js +3214 -0
- package/dist/llm/gen/anthropic.js +611 -0
- package/dist/llm/gen/codex.js +375 -0
- package/dist/llm/gen/mock.js +326 -0
- package/dist/llm/gen/openai.js +470 -0
- package/dist/llm/gen/registry.js +26 -0
- package/dist/llm/gen.js +2 -0
- package/dist/llm/tools-projection.js +37 -0
- package/dist/log.js +228 -0
- package/dist/mcp/config.js +230 -0
- package/dist/mcp/sdk-client.js +129 -0
- package/dist/mcp/server-runtime.js +57 -0
- package/dist/mcp/stdio-client.js +280 -0
- package/dist/mcp/supervisor.js +979 -0
- package/dist/mcp/tool-names.js +109 -0
- package/dist/minds/builtin/cmdr/persona.md +3 -0
- package/dist/minds/builtin/dijiang/knowledge.md +287 -0
- package/dist/minds/builtin/dijiang/persona.md +7 -0
- package/dist/minds/builtin/fuxi/persona.en.md +59 -0
- package/dist/minds/builtin/fuxi/persona.zh.md +49 -0
- package/dist/minds/builtin/pangu/persona.en.md +78 -0
- package/dist/minds/builtin/pangu/persona.zh.md +71 -0
- package/dist/minds/load.js +617 -0
- package/dist/minds/minds-i18n.js +131 -0
- package/dist/minds/system-prompt.js +281 -0
- package/dist/persistence.js +3128 -0
- package/dist/problems.js +109 -0
- package/dist/server/api-routes.js +1031 -0
- package/dist/server/auth.js +180 -0
- package/dist/server/mime-types.js +32 -0
- package/dist/server/prompts-routes.js +543 -0
- package/dist/server/server-core.js +235 -0
- package/dist/server/setup-routes.js +697 -0
- package/dist/server/static-server.js +132 -0
- package/dist/server/websocket-handler.js +1011 -0
- package/dist/server.js +164 -0
- package/dist/shared/async-fifo-mutex.js +36 -0
- package/dist/shared/diligence.js +20 -0
- package/dist/shared/dotenv.js +144 -0
- package/dist/shared/evt.js +195 -0
- package/dist/shared/i18n/driver-messages.js +267 -0
- package/dist/shared/i18n/text.js +9 -0
- package/dist/shared/i18n/tool-result-messages.js +51 -0
- package/dist/shared/rtws-cli.js +73 -0
- package/dist/shared/runtime-language.js +47 -0
- package/dist/shared/team-mgmt-manual.js +116 -0
- package/dist/shared/types/context-health.js +2 -0
- package/dist/shared/types/dialog.js +11 -0
- package/dist/shared/types/i18n.js +2 -0
- package/dist/shared/types/index.js +26 -0
- package/dist/shared/types/language.js +40 -0
- package/dist/shared/types/problems.js +2 -0
- package/dist/shared/types/prompts.js +2 -0
- package/dist/shared/types/q4h.js +7 -0
- package/dist/shared/types/run-state.js +8 -0
- package/dist/shared/types/setup.js +2 -0
- package/dist/shared/types/storage.js +10 -0
- package/dist/shared/types/tellask.js +8 -0
- package/dist/shared/types/tools-registry.js +2 -0
- package/dist/shared/types/wire.js +12 -0
- package/dist/shared/utils/fmt.js +9 -0
- package/dist/shared/utils/html.js +20 -0
- package/dist/shared/utils/id.js +18 -0
- package/dist/shared/utils/inter-dialog-format.js +101 -0
- package/dist/shared/utils/time.js +13 -0
- package/dist/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/static/assets/_baseUniq-Crfl3d5Y.js +661 -0
- package/dist/static/assets/_baseUniq-Crfl3d5Y.js.map +1 -0
- package/dist/static/assets/arc-CbA_x9GD.js +132 -0
- package/dist/static/assets/arc-CbA_x9GD.js.map +1 -0
- package/dist/static/assets/architectureDiagram-VXUJARFQ-lcFS8ZQJ.js +8685 -0
- package/dist/static/assets/architectureDiagram-VXUJARFQ-lcFS8ZQJ.js.map +1 -0
- package/dist/static/assets/blockDiagram-VD42YOAC-B3Q36qRc.js +3608 -0
- package/dist/static/assets/blockDiagram-VD42YOAC-B3Q36qRc.js.map +1 -0
- package/dist/static/assets/c4Diagram-YG6GDRKO-Mt-aq3VH.js +2482 -0
- package/dist/static/assets/c4Diagram-YG6GDRKO-Mt-aq3VH.js.map +1 -0
- package/dist/static/assets/channel-BVr1Yke-.js +8 -0
- package/dist/static/assets/channel-BVr1Yke-.js.map +1 -0
- package/dist/static/assets/chunk-4BX2VUAB-qCIn5Iic.js +17 -0
- package/dist/static/assets/chunk-4BX2VUAB-qCIn5Iic.js.map +1 -0
- package/dist/static/assets/chunk-55IACEB6-q172NeCV.js +14 -0
- package/dist/static/assets/chunk-55IACEB6-q172NeCV.js.map +1 -0
- package/dist/static/assets/chunk-B4BG7PRW-CMJmtYzq.js +1827 -0
- package/dist/static/assets/chunk-B4BG7PRW-CMJmtYzq.js.map +1 -0
- package/dist/static/assets/chunk-DI55MBZ5-DiuwwZPL.js +1916 -0
- package/dist/static/assets/chunk-DI55MBZ5-DiuwwZPL.js.map +1 -0
- package/dist/static/assets/chunk-FMBD7UC4-06sqZTTn.js +20 -0
- package/dist/static/assets/chunk-FMBD7UC4-06sqZTTn.js.map +1 -0
- package/dist/static/assets/chunk-QN33PNHL-CnpBNkpP.js +25 -0
- package/dist/static/assets/chunk-QN33PNHL-CnpBNkpP.js.map +1 -0
- package/dist/static/assets/chunk-QZHKN3VN-CNgjMR-e.js +18 -0
- package/dist/static/assets/chunk-QZHKN3VN-CNgjMR-e.js.map +1 -0
- package/dist/static/assets/chunk-TZMSLE5B-BxtzW6--.js +109 -0
- package/dist/static/assets/chunk-TZMSLE5B-BxtzW6--.js.map +1 -0
- package/dist/static/assets/classDiagram-2ON5EDUG-29huvmn-.js +23 -0
- package/dist/static/assets/classDiagram-2ON5EDUG-29huvmn-.js.map +1 -0
- package/dist/static/assets/classDiagram-v2-WZHVMYZB-29huvmn-.js +23 -0
- package/dist/static/assets/classDiagram-v2-WZHVMYZB-29huvmn-.js.map +1 -0
- package/dist/static/assets/clone-D2OgLSSn.js +9 -0
- package/dist/static/assets/clone-D2OgLSSn.js.map +1 -0
- package/dist/static/assets/cose-bilkent-S5V4N54A-BNegDCxl.js +4943 -0
- package/dist/static/assets/cose-bilkent-S5V4N54A-BNegDCxl.js.map +1 -0
- package/dist/static/assets/cytoscape.esm-Bm8DJGmZ.js +30240 -0
- package/dist/static/assets/cytoscape.esm-Bm8DJGmZ.js.map +1 -0
- package/dist/static/assets/dagre-6UL2VRFP-f1XrTRSn.js +695 -0
- package/dist/static/assets/dagre-6UL2VRFP-f1XrTRSn.js.map +1 -0
- package/dist/static/assets/defaultLocale-DVr69WTU.js +207 -0
- package/dist/static/assets/defaultLocale-DVr69WTU.js.map +1 -0
- package/dist/static/assets/diagram-PSM6KHXK-8w1WbeDi.js +849 -0
- package/dist/static/assets/diagram-PSM6KHXK-8w1WbeDi.js.map +1 -0
- package/dist/static/assets/diagram-QEK2KX5R-CF4wtMmR.js +303 -0
- package/dist/static/assets/diagram-QEK2KX5R-CF4wtMmR.js.map +1 -0
- package/dist/static/assets/diagram-S2PKOQOG-8p3Avgn2.js +213 -0
- package/dist/static/assets/diagram-S2PKOQOG-8p3Avgn2.js.map +1 -0
- package/dist/static/assets/erDiagram-Q2GNP2WA-BMKLxlM9.js +1159 -0
- package/dist/static/assets/erDiagram-Q2GNP2WA-BMKLxlM9.js.map +1 -0
- package/dist/static/assets/favicon-Cmg5RbCj.svg +8 -0
- package/dist/static/assets/flowDiagram-NV44I4VS-CgEuPNK2.js +2332 -0
- package/dist/static/assets/flowDiagram-NV44I4VS-CgEuPNK2.js.map +1 -0
- package/dist/static/assets/ganttDiagram-JELNMOA3-bJkDCf-9.js +3681 -0
- package/dist/static/assets/ganttDiagram-JELNMOA3-bJkDCf-9.js.map +1 -0
- package/dist/static/assets/gitGraphDiagram-NY62KEGX-4QE9kesp.js +1206 -0
- package/dist/static/assets/gitGraphDiagram-NY62KEGX-4QE9kesp.js.map +1 -0
- package/dist/static/assets/graph-CS0Pmm7c.js +597 -0
- package/dist/static/assets/graph-CS0Pmm7c.js.map +1 -0
- package/dist/static/assets/index-BS6HnGzC.js +112303 -0
- package/dist/static/assets/index-BS6HnGzC.js.map +1 -0
- package/dist/static/assets/index-DaIsSzC_.css +483 -0
- package/dist/static/assets/infoDiagram-WHAUD3N6-ypBcKfUs.js +34 -0
- package/dist/static/assets/infoDiagram-WHAUD3N6-ypBcKfUs.js.map +1 -0
- package/dist/static/assets/init-ZxktEp_H.js +17 -0
- package/dist/static/assets/init-ZxktEp_H.js.map +1 -0
- package/dist/static/assets/journeyDiagram-XKPGCS4Q-QnrxDowJ.js +1255 -0
- package/dist/static/assets/journeyDiagram-XKPGCS4Q-QnrxDowJ.js.map +1 -0
- package/dist/static/assets/kanban-definition-3W4ZIXB7-CfvEc4z5.js +1048 -0
- package/dist/static/assets/kanban-definition-3W4ZIXB7-CfvEc4z5.js.map +1 -0
- package/dist/static/assets/layout-8TGxpm23.js +2218 -0
- package/dist/static/assets/layout-8TGxpm23.js.map +1 -0
- package/dist/static/assets/linear-BATBPQQv.js +341 -0
- package/dist/static/assets/linear-BATBPQQv.js.map +1 -0
- package/dist/static/assets/min-B3oVH3AC.js +42 -0
- package/dist/static/assets/min-B3oVH3AC.js.map +1 -0
- package/dist/static/assets/mindmap-definition-VGOIOE7T-L7VLwwF8.js +1127 -0
- package/dist/static/assets/mindmap-definition-VGOIOE7T-L7VLwwF8.js.map +1 -0
- package/dist/static/assets/ordinal-CxptdPJm.js +77 -0
- package/dist/static/assets/ordinal-CxptdPJm.js.map +1 -0
- package/dist/static/assets/pieDiagram-ADFJNKIX-CFW3zIhM.js +241 -0
- package/dist/static/assets/pieDiagram-ADFJNKIX-CFW3zIhM.js.map +1 -0
- package/dist/static/assets/quadrantDiagram-AYHSOK5B-B7ssen3E.js +1338 -0
- package/dist/static/assets/quadrantDiagram-AYHSOK5B-B7ssen3E.js.map +1 -0
- package/dist/static/assets/requirementDiagram-UZGBJVZJ-D0v5BArv.js +1162 -0
- package/dist/static/assets/requirementDiagram-UZGBJVZJ-D0v5BArv.js.map +1 -0
- package/dist/static/assets/sankeyDiagram-TZEHDZUN-B7slncJe.js +1195 -0
- package/dist/static/assets/sankeyDiagram-TZEHDZUN-B7slncJe.js.map +1 -0
- package/dist/static/assets/sequenceDiagram-WL72ISMW-oXU2lRh_.js +3875 -0
- package/dist/static/assets/sequenceDiagram-WL72ISMW-oXU2lRh_.js.map +1 -0
- package/dist/static/assets/stateDiagram-FKZM4ZOC-CFYsEd0x.js +452 -0
- package/dist/static/assets/stateDiagram-FKZM4ZOC-CFYsEd0x.js.map +1 -0
- package/dist/static/assets/stateDiagram-v2-4FDKWEC3-C0UWaNA7.js +22 -0
- package/dist/static/assets/stateDiagram-v2-4FDKWEC3-C0UWaNA7.js.map +1 -0
- package/dist/static/assets/timeline-definition-IT6M3QCI-C3KODUrh.js +1223 -0
- package/dist/static/assets/timeline-definition-IT6M3QCI-C3KODUrh.js.map +1 -0
- package/dist/static/assets/treemap-KMMF4GRG-DAGDLhj2.js +18753 -0
- package/dist/static/assets/treemap-KMMF4GRG-DAGDLhj2.js.map +1 -0
- package/dist/static/assets/xychartDiagram-PRI3JC2R-C0J9iwTO.js +1888 -0
- package/dist/static/assets/xychartDiagram-PRI3JC2R-C0J9iwTO.js.map +1 -0
- package/dist/static/index.html +71 -0
- package/dist/static/testing/dom-observation-utils.js +425 -0
- package/dist/static/testing/e2e-test-helper.js +3119 -0
- package/dist/team.js +1160 -0
- package/dist/tellask.js +431 -0
- package/dist/tool.js +150 -0
- package/dist/tools/apply-patch.js +542 -0
- package/dist/tools/builtins.js +196 -0
- package/dist/tools/context-health.js +177 -0
- package/dist/tools/ctrl.js +478 -0
- package/dist/tools/diag.js +583 -0
- package/dist/tools/env.js +184 -0
- package/dist/tools/fs.js +818 -0
- package/dist/tools/mcp.js +138 -0
- package/dist/tools/mem.js +349 -0
- package/dist/tools/os.js +751 -0
- package/dist/tools/prompts/team_mgmt.en.md +70 -0
- package/dist/tools/prompts/team_mgmt.zh.md +70 -0
- package/dist/tools/prompts/ws_mod.en.md +86 -0
- package/dist/tools/prompts/ws_mod.zh.md +87 -0
- package/dist/tools/registry-snapshot.js +31 -0
- package/dist/tools/registry.js +121 -0
- package/dist/tools/ripgrep.js +678 -0
- package/dist/tools/team-mgmt.js +3300 -0
- package/dist/tools/txt.js +3178 -0
- package/dist/utils/id.js +72 -0
- package/dist/utils/task-doc.js +236 -0
- package/dist/utils/task-package.js +522 -0
- package/dist/utils/taskdoc-search.js +280 -0
- package/dist/utils/taskdoc.js +400 -0
- package/package.json +69 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Module: tools/mcp
|
|
4
|
+
*
|
|
5
|
+
* Local MCP supervisor control tools for testing and operations.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.mcpLeaseReminderOwner = exports.mcpReleaseTool = exports.mcpRestartTool = void 0;
|
|
9
|
+
const log_1 = require("../log");
|
|
10
|
+
const supervisor_1 = require("../mcp/supervisor");
|
|
11
|
+
const log = (0, log_1.createLogger)('tools/mcp');
|
|
12
|
+
function parseMcpRestartArgs(args) {
|
|
13
|
+
const serverId = args.serverId;
|
|
14
|
+
if (typeof serverId !== 'string' || !serverId.trim()) {
|
|
15
|
+
throw new Error(`mcp_restart.serverId must be a non-empty string`);
|
|
16
|
+
}
|
|
17
|
+
return { serverId };
|
|
18
|
+
}
|
|
19
|
+
function parseMcpReleaseArgs(args) {
|
|
20
|
+
const serverId = args.serverId;
|
|
21
|
+
if (typeof serverId !== 'string' || !serverId.trim()) {
|
|
22
|
+
throw new Error(`mcp_release.serverId must be a non-empty string`);
|
|
23
|
+
}
|
|
24
|
+
return { serverId };
|
|
25
|
+
}
|
|
26
|
+
function isMcpLeaseReminderMeta(value) {
|
|
27
|
+
if (!isRecord(value) || Array.isArray(value))
|
|
28
|
+
return false;
|
|
29
|
+
if (value.kind !== 'mcp_lease')
|
|
30
|
+
return false;
|
|
31
|
+
return typeof value.serverId === 'string' && value.serverId.trim().length > 0;
|
|
32
|
+
}
|
|
33
|
+
const mcpRestartSchema = {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
serverId: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
description: "MCP server id from `.minds/mcp.yaml` (e.g., 'sdk_stdio'). Restarts this server only.",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
required: ['serverId'],
|
|
42
|
+
additionalProperties: false,
|
|
43
|
+
};
|
|
44
|
+
const mcpReleaseSchema = {
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: {
|
|
47
|
+
serverId: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: "MCP server id from `.minds/mcp.yaml` (e.g., 'playwright'). Releases the leased MCP client for this dialog.",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
required: ['serverId'],
|
|
53
|
+
additionalProperties: false,
|
|
54
|
+
};
|
|
55
|
+
exports.mcpRestartTool = {
|
|
56
|
+
type: 'func',
|
|
57
|
+
name: 'mcp_restart',
|
|
58
|
+
description: 'Restart a configured MCP server using the current `.minds/mcp.yaml` config (best-effort).',
|
|
59
|
+
descriptionI18n: {
|
|
60
|
+
en: 'Restart a configured MCP server using the current `.minds/mcp.yaml` config (best-effort).',
|
|
61
|
+
zh: '使用当前的 `.minds/mcp.yaml` 配置重启指定的 MCP 服务器(尽力而为)。',
|
|
62
|
+
},
|
|
63
|
+
parameters: mcpRestartSchema,
|
|
64
|
+
argsValidation: 'dominds',
|
|
65
|
+
call: async (_dlg, caller, args) => {
|
|
66
|
+
const parsed = parseMcpRestartArgs(args);
|
|
67
|
+
const res = await (0, supervisor_1.requestMcpServerRestart)(parsed.serverId);
|
|
68
|
+
log.warn('mcp_restart', { caller: caller.id, serverId: parsed.serverId, ok: res.ok });
|
|
69
|
+
if (!res.ok)
|
|
70
|
+
return `error: ${res.errorText}`;
|
|
71
|
+
return `ok: restarted ${parsed.serverId}`;
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
exports.mcpReleaseTool = {
|
|
75
|
+
type: 'func',
|
|
76
|
+
name: 'mcp_release',
|
|
77
|
+
description: 'Release a leased MCP toolset client for this dialog (stops the underlying process/connection).',
|
|
78
|
+
descriptionI18n: {
|
|
79
|
+
en: 'Release a leased MCP toolset client for this dialog (stops the underlying process/connection).',
|
|
80
|
+
zh: '释放当前对话租用的 MCP toolset client(停止底层进程/连接)。',
|
|
81
|
+
},
|
|
82
|
+
parameters: mcpReleaseSchema,
|
|
83
|
+
argsValidation: 'dominds',
|
|
84
|
+
call: async (dlg, caller, args) => {
|
|
85
|
+
const parsed = parseMcpReleaseArgs(args);
|
|
86
|
+
const dialogKey = dlg.id.key();
|
|
87
|
+
const res = (0, supervisor_1.releaseMcpToolsetLeaseForDialog)(parsed.serverId, dialogKey);
|
|
88
|
+
log.warn('mcp_release', {
|
|
89
|
+
caller: caller.id,
|
|
90
|
+
serverId: parsed.serverId,
|
|
91
|
+
ok: res.ok,
|
|
92
|
+
released: res.ok ? res.released : undefined,
|
|
93
|
+
});
|
|
94
|
+
if (!res.ok)
|
|
95
|
+
return `error: ${res.errorText}`;
|
|
96
|
+
if (!res.released) {
|
|
97
|
+
return `ok: no active lease for ${parsed.serverId} (or server is truely-stateless)`;
|
|
98
|
+
}
|
|
99
|
+
return `ok: released ${parsed.serverId} for dialog ${dialogKey}`;
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
exports.mcpLeaseReminderOwner = {
|
|
103
|
+
name: 'mcpLease',
|
|
104
|
+
async updateReminder(dlg, reminder) {
|
|
105
|
+
if (reminder.owner !== exports.mcpLeaseReminderOwner)
|
|
106
|
+
return { treatment: 'keep' };
|
|
107
|
+
if (!isMcpLeaseReminderMeta(reminder.meta))
|
|
108
|
+
return { treatment: 'keep' };
|
|
109
|
+
const dialogKey = dlg.id.key();
|
|
110
|
+
const leased = (0, supervisor_1.isMcpToolsetLeasedToDialog)(reminder.meta.serverId, dialogKey);
|
|
111
|
+
if (!leased) {
|
|
112
|
+
return { treatment: 'drop' };
|
|
113
|
+
}
|
|
114
|
+
return { treatment: 'keep' };
|
|
115
|
+
},
|
|
116
|
+
async renderReminder(dlg, reminder, index) {
|
|
117
|
+
if (reminder.owner !== exports.mcpLeaseReminderOwner || !isMcpLeaseReminderMeta(reminder.meta)) {
|
|
118
|
+
return {
|
|
119
|
+
type: 'transient_guide_msg',
|
|
120
|
+
role: 'assistant',
|
|
121
|
+
content: `System Reminder #${index + 1}\n\n${reminder.content}`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const serverId = reminder.meta.serverId;
|
|
125
|
+
return {
|
|
126
|
+
type: 'transient_guide_msg',
|
|
127
|
+
role: 'assistant',
|
|
128
|
+
content: `MCP toolset lease #${index + 1}: \`${serverId}\`\n\n` +
|
|
129
|
+
`This MCP server is treated as non-stateless. A dedicated MCP client instance is leased to this dialog.\n\n` +
|
|
130
|
+
`When you are confident you won't need this toolset in the near future, release it to stop the underlying MCP process/connection:\n` +
|
|
131
|
+
`- \`mcp_release({\"serverId\":\"${serverId}\"})\`\n\n` +
|
|
132
|
+
`If another dialog uses the same MCP toolset concurrently, Dominds will spawn a separate MCP client instance for that dialog.`,
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
function isRecord(value) {
|
|
137
|
+
return typeof value === 'object' && value !== null;
|
|
138
|
+
}
|
|
@@ -0,0 +1,349 @@
|
|
|
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
|
+
exports.clearSharedMemoryTool = exports.replaceSharedMemoryTool = exports.dropSharedMemoryTool = exports.addSharedMemoryTool = exports.clearMemoryTool = exports.replaceMemoryTool = exports.dropMemoryTool = exports.addMemoryTool = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Module: tools/mem
|
|
9
|
+
*
|
|
10
|
+
* Memory management tools for personal and shared memory under `.minds/memory`.
|
|
11
|
+
* Add, drop, replace, clear operations with strict path validation.
|
|
12
|
+
*/
|
|
13
|
+
const fs_1 = __importDefault(require("fs"));
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const tool_result_messages_1 = require("../shared/i18n/tool-result-messages");
|
|
16
|
+
const runtime_language_1 = require("../shared/runtime-language");
|
|
17
|
+
function getMemoryPath(params) {
|
|
18
|
+
if (path_1.default.isAbsolute(params.filePath)) {
|
|
19
|
+
return {
|
|
20
|
+
kind: 'invalid_path',
|
|
21
|
+
message: params.language === 'zh'
|
|
22
|
+
? '❌ **错误**\n\n记忆路径必须是相对路径(不允许以 `/` 开头)。'
|
|
23
|
+
: '❌ **Error**\n\nMemory paths must be relative (absolute paths are not allowed).',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// Prevent path traversal by rejecting paths with '..'
|
|
27
|
+
if (params.filePath.includes('..')) {
|
|
28
|
+
return {
|
|
29
|
+
kind: 'invalid_path',
|
|
30
|
+
message: params.language === 'zh'
|
|
31
|
+
? '❌ **错误**\n\n记忆路径不允许包含 `..`(禁止路径穿越)。'
|
|
32
|
+
: '❌ **Error**\n\nPath traversal is not allowed in memory paths (`..` is forbidden).',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const mindsDir = '.minds/memory';
|
|
36
|
+
const isShared = params.isShared === true;
|
|
37
|
+
const rel = isShared
|
|
38
|
+
? path_1.default.join(mindsDir, 'team_shared', params.filePath)
|
|
39
|
+
: path_1.default.join(mindsDir, 'individual', params.caller.id, params.filePath);
|
|
40
|
+
return { kind: 'ok', rel };
|
|
41
|
+
}
|
|
42
|
+
exports.addMemoryTool = {
|
|
43
|
+
type: 'func',
|
|
44
|
+
name: 'add_memory',
|
|
45
|
+
description: 'Add a new memory file to the personal memory store.',
|
|
46
|
+
descriptionI18n: {
|
|
47
|
+
en: 'Add a new memory file to the personal memory store.',
|
|
48
|
+
zh: '向个人记忆库新增一个记忆文件。',
|
|
49
|
+
},
|
|
50
|
+
parameters: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
additionalProperties: false,
|
|
53
|
+
required: ['path', 'content'],
|
|
54
|
+
properties: {
|
|
55
|
+
path: { type: 'string', description: 'Relative path inside your personal memory store.' },
|
|
56
|
+
content: { type: 'string', description: 'Memory content (written as-is).' },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
argsValidation: 'dominds',
|
|
60
|
+
async call(_dlg, caller, args) {
|
|
61
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
62
|
+
const pathValue = args['path'];
|
|
63
|
+
const contentValue = args['content'];
|
|
64
|
+
const filePath = typeof pathValue === 'string' ? pathValue.trim() : '';
|
|
65
|
+
const content = typeof contentValue === 'string' ? contentValue : '';
|
|
66
|
+
if (!filePath) {
|
|
67
|
+
return language === 'zh' ? '错误:需要提供文件路径。' : 'Error: File path is required.';
|
|
68
|
+
}
|
|
69
|
+
if (content.length === 0) {
|
|
70
|
+
return language === 'zh'
|
|
71
|
+
? '错误:需要提供记忆内容(content)。'
|
|
72
|
+
: 'Error: Memory content is required (content).';
|
|
73
|
+
}
|
|
74
|
+
const memoryPath = getMemoryPath({ language, caller, filePath });
|
|
75
|
+
if (memoryPath.kind === 'invalid_path') {
|
|
76
|
+
return memoryPath.message;
|
|
77
|
+
}
|
|
78
|
+
const fullPath = path_1.default.resolve(process.cwd(), memoryPath.rel);
|
|
79
|
+
if (fs_1.default.existsSync(fullPath)) {
|
|
80
|
+
return language === 'zh'
|
|
81
|
+
? `错误:记忆文件 '${filePath}' 已存在。请使用 replace_memory 更新它。`
|
|
82
|
+
: `Error: Memory file '${filePath}' already exists. Use replace_memory to update it.`;
|
|
83
|
+
}
|
|
84
|
+
const dir = path_1.default.dirname(fullPath);
|
|
85
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
86
|
+
fs_1.default.writeFileSync(fullPath, content, 'utf8');
|
|
87
|
+
return (0, tool_result_messages_1.formatToolActionResult)(language, 'added');
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
exports.dropMemoryTool = {
|
|
91
|
+
type: 'func',
|
|
92
|
+
name: 'drop_memory',
|
|
93
|
+
description: 'Remove a memory file from the personal memory store.',
|
|
94
|
+
descriptionI18n: {
|
|
95
|
+
en: 'Remove a memory file from the personal memory store.',
|
|
96
|
+
zh: '从个人记忆库删除一个记忆文件。',
|
|
97
|
+
},
|
|
98
|
+
parameters: {
|
|
99
|
+
type: 'object',
|
|
100
|
+
additionalProperties: false,
|
|
101
|
+
required: ['path'],
|
|
102
|
+
properties: {
|
|
103
|
+
path: { type: 'string', description: 'Relative path inside your personal memory store.' },
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
argsValidation: 'dominds',
|
|
107
|
+
async call(_dlg, caller, args) {
|
|
108
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
109
|
+
const pathValue = args['path'];
|
|
110
|
+
const filePath = typeof pathValue === 'string' ? pathValue.trim() : '';
|
|
111
|
+
if (!filePath) {
|
|
112
|
+
return language === 'zh' ? '错误:需要提供文件路径。' : 'Error: File path is required.';
|
|
113
|
+
}
|
|
114
|
+
const memoryPath = getMemoryPath({ language, caller, filePath });
|
|
115
|
+
if (memoryPath.kind === 'invalid_path') {
|
|
116
|
+
return memoryPath.message;
|
|
117
|
+
}
|
|
118
|
+
const fullPath = path_1.default.resolve(process.cwd(), memoryPath.rel);
|
|
119
|
+
if (!fs_1.default.existsSync(fullPath)) {
|
|
120
|
+
return language === 'zh'
|
|
121
|
+
? `错误:记忆文件 '${filePath}' 不存在。`
|
|
122
|
+
: `Error: Memory file '${filePath}' does not exist.`;
|
|
123
|
+
}
|
|
124
|
+
fs_1.default.unlinkSync(fullPath);
|
|
125
|
+
return (0, tool_result_messages_1.formatToolActionResult)(language, 'deleted');
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
exports.replaceMemoryTool = {
|
|
129
|
+
type: 'func',
|
|
130
|
+
name: 'replace_memory',
|
|
131
|
+
description: 'Replace the content of an existing memory file in the personal memory store.',
|
|
132
|
+
descriptionI18n: {
|
|
133
|
+
en: 'Replace the content of an existing memory file in the personal memory store.',
|
|
134
|
+
zh: '替换个人记忆库中已存在记忆文件的内容。',
|
|
135
|
+
},
|
|
136
|
+
parameters: {
|
|
137
|
+
type: 'object',
|
|
138
|
+
additionalProperties: false,
|
|
139
|
+
required: ['path', 'content'],
|
|
140
|
+
properties: {
|
|
141
|
+
path: { type: 'string', description: 'Relative path inside your personal memory store.' },
|
|
142
|
+
content: { type: 'string', description: 'New memory content (written as-is).' },
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
argsValidation: 'dominds',
|
|
146
|
+
async call(_dlg, caller, args) {
|
|
147
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
148
|
+
const pathValue = args['path'];
|
|
149
|
+
const contentValue = args['content'];
|
|
150
|
+
const filePath = typeof pathValue === 'string' ? pathValue.trim() : '';
|
|
151
|
+
const content = typeof contentValue === 'string' ? contentValue : '';
|
|
152
|
+
if (!filePath) {
|
|
153
|
+
return language === 'zh' ? '错误:需要提供文件路径。' : 'Error: File path is required.';
|
|
154
|
+
}
|
|
155
|
+
if (content.length === 0) {
|
|
156
|
+
return language === 'zh'
|
|
157
|
+
? '错误:需要提供记忆内容(content)。'
|
|
158
|
+
: 'Error: Memory content is required (content).';
|
|
159
|
+
}
|
|
160
|
+
const memoryPath = getMemoryPath({ language, caller, filePath });
|
|
161
|
+
if (memoryPath.kind === 'invalid_path') {
|
|
162
|
+
return memoryPath.message;
|
|
163
|
+
}
|
|
164
|
+
const fullPath = path_1.default.resolve(process.cwd(), memoryPath.rel);
|
|
165
|
+
if (!fs_1.default.existsSync(fullPath)) {
|
|
166
|
+
return language === 'zh'
|
|
167
|
+
? `错误:记忆文件 '${filePath}' 不存在。请使用 add_memory 创建它。`
|
|
168
|
+
: `Error: Memory file '${filePath}' does not exist. Use add_memory to create it.`;
|
|
169
|
+
}
|
|
170
|
+
fs_1.default.writeFileSync(fullPath, content, 'utf8');
|
|
171
|
+
return (0, tool_result_messages_1.formatToolActionResult)(language, 'updated');
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
exports.clearMemoryTool = {
|
|
175
|
+
type: 'func',
|
|
176
|
+
name: 'clear_memory',
|
|
177
|
+
description: 'Clear all memory files from the personal memory store.',
|
|
178
|
+
descriptionI18n: {
|
|
179
|
+
en: 'Clear all memory files from the personal memory store.',
|
|
180
|
+
zh: '清空个人记忆库中的所有记忆文件。',
|
|
181
|
+
},
|
|
182
|
+
parameters: { type: 'object', additionalProperties: false, properties: {} },
|
|
183
|
+
argsValidation: 'dominds',
|
|
184
|
+
async call(_dlg, caller, _args) {
|
|
185
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
186
|
+
const memoryDir = path_1.default.join('.minds/memory/individual', caller.id);
|
|
187
|
+
const fullPath = path_1.default.resolve(process.cwd(), memoryDir);
|
|
188
|
+
if (!fs_1.default.existsSync(fullPath)) {
|
|
189
|
+
return language === 'zh' ? '没有可清空的个人记忆。' : 'No personal memory to clear.';
|
|
190
|
+
}
|
|
191
|
+
fs_1.default.rmSync(fullPath, { recursive: true, force: true });
|
|
192
|
+
fs_1.default.mkdirSync(fullPath, { recursive: true });
|
|
193
|
+
return (0, tool_result_messages_1.formatToolActionResult)(language, 'cleared');
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
exports.addSharedMemoryTool = {
|
|
197
|
+
type: 'func',
|
|
198
|
+
name: 'add_team_memory',
|
|
199
|
+
description: 'Add a new memory file to the shared team memory store.',
|
|
200
|
+
descriptionI18n: {
|
|
201
|
+
en: 'Add a new memory file to the shared team memory store.',
|
|
202
|
+
zh: '向团队共享记忆库新增一个记忆文件。',
|
|
203
|
+
},
|
|
204
|
+
parameters: {
|
|
205
|
+
type: 'object',
|
|
206
|
+
additionalProperties: false,
|
|
207
|
+
required: ['path', 'content'],
|
|
208
|
+
properties: {
|
|
209
|
+
path: { type: 'string', description: 'Relative path inside the shared team memory store.' },
|
|
210
|
+
content: { type: 'string', description: 'Shared memory content (written as-is).' },
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
argsValidation: 'dominds',
|
|
214
|
+
async call(_dlg, caller, args) {
|
|
215
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
216
|
+
const pathValue = args['path'];
|
|
217
|
+
const contentValue = args['content'];
|
|
218
|
+
const filePath = typeof pathValue === 'string' ? pathValue.trim() : '';
|
|
219
|
+
const content = typeof contentValue === 'string' ? contentValue : '';
|
|
220
|
+
if (!filePath) {
|
|
221
|
+
return language === 'zh' ? '错误:需要提供文件路径。' : 'Error: File path is required.';
|
|
222
|
+
}
|
|
223
|
+
if (content.length === 0) {
|
|
224
|
+
return language === 'zh'
|
|
225
|
+
? '错误:需要提供共享记忆内容(content)。'
|
|
226
|
+
: 'Error: Shared memory content is required (content).';
|
|
227
|
+
}
|
|
228
|
+
const memoryPath = getMemoryPath({ language, caller, filePath, isShared: true });
|
|
229
|
+
if (memoryPath.kind === 'invalid_path') {
|
|
230
|
+
return memoryPath.message;
|
|
231
|
+
}
|
|
232
|
+
const fullPath = path_1.default.resolve(process.cwd(), memoryPath.rel);
|
|
233
|
+
if (fs_1.default.existsSync(fullPath)) {
|
|
234
|
+
return language === 'zh'
|
|
235
|
+
? `错误:共享记忆文件 '${filePath}' 已存在。请使用 replace_team_memory 更新它。`
|
|
236
|
+
: `Error: Shared memory file '${filePath}' already exists. Use replace_team_memory to update it.`;
|
|
237
|
+
}
|
|
238
|
+
const dir = path_1.default.dirname(fullPath);
|
|
239
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
240
|
+
fs_1.default.writeFileSync(fullPath, content, 'utf8');
|
|
241
|
+
return (0, tool_result_messages_1.formatToolActionResult)(language, 'added');
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
exports.dropSharedMemoryTool = {
|
|
245
|
+
type: 'func',
|
|
246
|
+
name: 'drop_team_memory',
|
|
247
|
+
description: 'Remove a memory file from the shared team memory store.',
|
|
248
|
+
descriptionI18n: {
|
|
249
|
+
en: 'Remove a memory file from the shared team memory store.',
|
|
250
|
+
zh: '从团队共享记忆库删除一个记忆文件。',
|
|
251
|
+
},
|
|
252
|
+
parameters: {
|
|
253
|
+
type: 'object',
|
|
254
|
+
additionalProperties: false,
|
|
255
|
+
required: ['path'],
|
|
256
|
+
properties: {
|
|
257
|
+
path: { type: 'string', description: 'Relative path inside the shared team memory store.' },
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
argsValidation: 'dominds',
|
|
261
|
+
async call(_dlg, caller, args) {
|
|
262
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
263
|
+
const pathValue = args['path'];
|
|
264
|
+
const filePath = typeof pathValue === 'string' ? pathValue.trim() : '';
|
|
265
|
+
if (!filePath) {
|
|
266
|
+
return language === 'zh' ? '错误:需要提供文件路径。' : 'Error: File path is required.';
|
|
267
|
+
}
|
|
268
|
+
const memoryPath = getMemoryPath({ language, caller, filePath, isShared: true });
|
|
269
|
+
if (memoryPath.kind === 'invalid_path') {
|
|
270
|
+
return memoryPath.message;
|
|
271
|
+
}
|
|
272
|
+
const fullPath = path_1.default.resolve(process.cwd(), memoryPath.rel);
|
|
273
|
+
if (!fs_1.default.existsSync(fullPath)) {
|
|
274
|
+
return language === 'zh'
|
|
275
|
+
? `错误:共享记忆文件 '${filePath}' 不存在。`
|
|
276
|
+
: `Error: Shared memory file '${filePath}' does not exist.`;
|
|
277
|
+
}
|
|
278
|
+
fs_1.default.unlinkSync(fullPath);
|
|
279
|
+
return (0, tool_result_messages_1.formatToolActionResult)(language, 'deleted');
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
exports.replaceSharedMemoryTool = {
|
|
283
|
+
type: 'func',
|
|
284
|
+
name: 'replace_team_memory',
|
|
285
|
+
description: 'Replace the content of an existing memory file in the shared team memory store.',
|
|
286
|
+
descriptionI18n: {
|
|
287
|
+
en: 'Replace the content of an existing memory file in the shared team memory store.',
|
|
288
|
+
zh: '替换团队共享记忆库中已存在记忆文件的内容。',
|
|
289
|
+
},
|
|
290
|
+
parameters: {
|
|
291
|
+
type: 'object',
|
|
292
|
+
additionalProperties: false,
|
|
293
|
+
required: ['path', 'content'],
|
|
294
|
+
properties: {
|
|
295
|
+
path: { type: 'string', description: 'Relative path inside the shared team memory store.' },
|
|
296
|
+
content: { type: 'string', description: 'New shared memory content (written as-is).' },
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
argsValidation: 'dominds',
|
|
300
|
+
async call(_dlg, caller, args) {
|
|
301
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
302
|
+
const pathValue = args['path'];
|
|
303
|
+
const contentValue = args['content'];
|
|
304
|
+
const filePath = typeof pathValue === 'string' ? pathValue.trim() : '';
|
|
305
|
+
const content = typeof contentValue === 'string' ? contentValue : '';
|
|
306
|
+
if (!filePath) {
|
|
307
|
+
return language === 'zh' ? '错误:需要提供文件路径。' : 'Error: File path is required.';
|
|
308
|
+
}
|
|
309
|
+
if (content.length === 0) {
|
|
310
|
+
return language === 'zh'
|
|
311
|
+
? '错误:需要提供共享记忆内容(content)。'
|
|
312
|
+
: 'Error: Shared memory content is required (content).';
|
|
313
|
+
}
|
|
314
|
+
const memoryPath = getMemoryPath({ language, caller, filePath, isShared: true });
|
|
315
|
+
if (memoryPath.kind === 'invalid_path') {
|
|
316
|
+
return memoryPath.message;
|
|
317
|
+
}
|
|
318
|
+
const fullPath = path_1.default.resolve(process.cwd(), memoryPath.rel);
|
|
319
|
+
if (!fs_1.default.existsSync(fullPath)) {
|
|
320
|
+
return language === 'zh'
|
|
321
|
+
? `错误:共享记忆文件 '${filePath}' 不存在。请使用 add_team_memory 创建它。`
|
|
322
|
+
: `Error: Shared memory file '${filePath}' does not exist. Use add_team_memory to create it.`;
|
|
323
|
+
}
|
|
324
|
+
fs_1.default.writeFileSync(fullPath, content, 'utf8');
|
|
325
|
+
return (0, tool_result_messages_1.formatToolActionResult)(language, 'updated');
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
exports.clearSharedMemoryTool = {
|
|
329
|
+
type: 'func',
|
|
330
|
+
name: 'clear_team_memory',
|
|
331
|
+
description: 'Clear all files from the shared team memory store.',
|
|
332
|
+
descriptionI18n: {
|
|
333
|
+
en: 'Clear all files from the shared team memory store.',
|
|
334
|
+
zh: '清空团队共享记忆库中的所有文件。',
|
|
335
|
+
},
|
|
336
|
+
parameters: { type: 'object', additionalProperties: false, properties: {} },
|
|
337
|
+
argsValidation: 'dominds',
|
|
338
|
+
async call(_dlg, _caller, _args) {
|
|
339
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
340
|
+
const memoryDir = '.minds/memory/team_shared';
|
|
341
|
+
const fullPath = path_1.default.resolve(process.cwd(), memoryDir);
|
|
342
|
+
if (!fs_1.default.existsSync(fullPath)) {
|
|
343
|
+
return language === 'zh' ? '没有可清空的共享记忆。' : 'No shared memory to clear.';
|
|
344
|
+
}
|
|
345
|
+
fs_1.default.rmSync(fullPath, { recursive: true, force: true });
|
|
346
|
+
fs_1.default.mkdirSync(fullPath, { recursive: true });
|
|
347
|
+
return (0, tool_result_messages_1.formatToolActionResult)(language, 'cleared');
|
|
348
|
+
},
|
|
349
|
+
};
|