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
package/dist/dialog.js
ADDED
|
@@ -0,0 +1,1024 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DialogStore = exports.RootDialog = exports.SubDialog = exports.Dialog = exports.DialogID = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Module: dialog
|
|
6
|
+
*
|
|
7
|
+
* Provides the `Dialog` object for orchestrating conversations:
|
|
8
|
+
* - Tracks messages, agent identity, optional supdialog/subdialog relationships
|
|
9
|
+
* - Receivers for streaming LLM output and tool results
|
|
10
|
+
* - Helpers for spawning subdialogs and prompting human input
|
|
11
|
+
* - Persistence support for dialog state and message history
|
|
12
|
+
*
|
|
13
|
+
* Architecture (Phase 2):
|
|
14
|
+
* - `Dialog` - Abstract base class for all dialogs
|
|
15
|
+
* - `RootDialog` - Root dialog with subdialog registry
|
|
16
|
+
* - `SubDialog` - Subdialog with root dialog reference and dynamic supdialog resolution
|
|
17
|
+
*/
|
|
18
|
+
const util_1 = require("util");
|
|
19
|
+
const evt_registry_1 = require("./evt-registry");
|
|
20
|
+
const log_1 = require("./log");
|
|
21
|
+
const async_fifo_mutex_1 = require("./shared/async-fifo-mutex");
|
|
22
|
+
const runtime_language_1 = require("./shared/runtime-language");
|
|
23
|
+
const id_1 = require("./shared/utils/id");
|
|
24
|
+
const inter_dialog_format_1 = require("./shared/utils/inter-dialog-format");
|
|
25
|
+
const time_1 = require("./shared/utils/time");
|
|
26
|
+
const id_2 = require("./utils/id");
|
|
27
|
+
class DialogID {
|
|
28
|
+
constructor(selfId, rootId) {
|
|
29
|
+
this.selfId = selfId;
|
|
30
|
+
this.rootId = rootId || selfId;
|
|
31
|
+
if (typeof selfId !== 'string')
|
|
32
|
+
throw new Error(`Wrong type [${typeof selfId}] passed as dlg id: ${(0, util_1.inspect)(selfId)}`);
|
|
33
|
+
if (rootId && typeof rootId !== 'string')
|
|
34
|
+
throw new Error(`Wrong type [${typeof rootId}] passed as dlg id: ${(0, util_1.inspect)(rootId)}`);
|
|
35
|
+
}
|
|
36
|
+
key() {
|
|
37
|
+
return this.valueOf();
|
|
38
|
+
}
|
|
39
|
+
valueOf() {
|
|
40
|
+
if (!this.rootId || this.rootId === this.selfId) {
|
|
41
|
+
return this.selfId;
|
|
42
|
+
}
|
|
43
|
+
return this.rootId + '#' + this.selfId;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Pretty print representation for debugging and display
|
|
47
|
+
*/
|
|
48
|
+
toString() {
|
|
49
|
+
return this.valueOf();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Check equality with another DialogID
|
|
53
|
+
*/
|
|
54
|
+
equals(other) {
|
|
55
|
+
if (other === null || other === undefined) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return this.selfId === other.selfId && this.rootId === other.rootId;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Generate hash code for Map/Set usage
|
|
62
|
+
*/
|
|
63
|
+
hashCode() {
|
|
64
|
+
return this.valueOf();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.DialogID = DialogID;
|
|
68
|
+
const globalDialogMutexes = new Map();
|
|
69
|
+
function getGlobalDialogMutex(dialogId) {
|
|
70
|
+
const key = dialogId.key();
|
|
71
|
+
const existing = globalDialogMutexes.get(key);
|
|
72
|
+
if (existing)
|
|
73
|
+
return existing;
|
|
74
|
+
const created = new async_fifo_mutex_1.AsyncFifoMutex();
|
|
75
|
+
globalDialogMutexes.set(key, created);
|
|
76
|
+
return created;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Abstract base class for all dialog types.
|
|
80
|
+
* Contains common properties and methods shared between RootDialog and SubDialog.
|
|
81
|
+
*/
|
|
82
|
+
class Dialog {
|
|
83
|
+
constructor(dlgStore, taskDocPath, id, agentId, initialState) {
|
|
84
|
+
// Persistence state
|
|
85
|
+
this._currentRound = 1;
|
|
86
|
+
this._remindersVer = 0;
|
|
87
|
+
// Track whether the current round's initial events (user_text, generating_start)
|
|
88
|
+
// have been fully processed. Used to ensure subdialog_final_response_evt arrives
|
|
89
|
+
// only after parent events are emitted.
|
|
90
|
+
this._generationStarted = false;
|
|
91
|
+
// Track the generation sequence when _generationStarted was set
|
|
92
|
+
// Used to ensure proper ordering when multiple generations occur
|
|
93
|
+
this._generationStartedGenseq = 0;
|
|
94
|
+
// Pending subdialog IDs (for auto-revive tracking)
|
|
95
|
+
this._pendingSubdialogIds = [];
|
|
96
|
+
// Phase 11: Suspension state for Type A subdialog mechanism
|
|
97
|
+
// Tracks whether this dialog is in normal state, suspended, or resuming from suspension
|
|
98
|
+
this._suspensionState = 'active';
|
|
99
|
+
// Keep-going (diligence auto-continue) budget counter (runtime-only).
|
|
100
|
+
// Intentionally not persisted: this is a per-process safety valve, not dialog state.
|
|
101
|
+
this.diligenceAutoContinueCount = 0;
|
|
102
|
+
// Keep-going disable switch (persisted via latest.yaml; default = false).
|
|
103
|
+
this.disableDiligencePush = false;
|
|
104
|
+
// Current callId for tellask tool-call correlation
|
|
105
|
+
// - Set during tool_call_finish_evt (from TellaskStreamParser)
|
|
106
|
+
// - Retrieved during tool response (for receiveToolResponse callId parameter)
|
|
107
|
+
// - Enables frontend to attach result INLINE to the calling section
|
|
108
|
+
// - NOT used for teammate tellasks (which use calleeDialogId instead)
|
|
109
|
+
this._currentCallId = null;
|
|
110
|
+
// Validate required parameters
|
|
111
|
+
if (!taskDocPath || taskDocPath.trim() === '') {
|
|
112
|
+
throw new Error('Taskdoc path is required for creating a dialog');
|
|
113
|
+
}
|
|
114
|
+
this.dlgStore = dlgStore;
|
|
115
|
+
this.taskDocPath = taskDocPath.trim();
|
|
116
|
+
if (id === undefined) {
|
|
117
|
+
const generatedId = (0, id_2.generateDialogID)();
|
|
118
|
+
id = new DialogID(generatedId);
|
|
119
|
+
}
|
|
120
|
+
this.id = id;
|
|
121
|
+
this._mutex = getGlobalDialogMutex(this.id);
|
|
122
|
+
this.agentId = agentId;
|
|
123
|
+
this.reminders = initialState?.reminders || [];
|
|
124
|
+
this.msgs = initialState?.messages || [];
|
|
125
|
+
// Initialize persistence state
|
|
126
|
+
const now = (0, time_1.formatUnifiedTimestamp)(new Date());
|
|
127
|
+
this._createdAt = initialState?.createdAt || now;
|
|
128
|
+
this._updatedAt = initialState?.updatedAt || now;
|
|
129
|
+
this._currentRound = initialState?.currentRound || 1;
|
|
130
|
+
this._uiLanguage = (0, runtime_language_1.getWorkLanguage)();
|
|
131
|
+
this._lastUserLanguageCode = (0, runtime_language_1.getWorkLanguage)();
|
|
132
|
+
this._lastContextHealth = initialState?.contextHealth;
|
|
133
|
+
this._lastContextHealthGenseq = undefined;
|
|
134
|
+
}
|
|
135
|
+
setLastContextHealth(snapshot) {
|
|
136
|
+
this._lastContextHealth = snapshot;
|
|
137
|
+
// Track the generation sequence that produced this snapshot, so reminder owners
|
|
138
|
+
// can distinguish pre-generation updates (previous snapshot) from post-generation
|
|
139
|
+
// updates (current snapshot) without relying on heuristics.
|
|
140
|
+
this._lastContextHealthGenseq = this._activeGenSeq;
|
|
141
|
+
}
|
|
142
|
+
getLastContextHealth() {
|
|
143
|
+
return this._lastContextHealth;
|
|
144
|
+
}
|
|
145
|
+
getLastContextHealthGenseq() {
|
|
146
|
+
return this._lastContextHealthGenseq;
|
|
147
|
+
}
|
|
148
|
+
get remindersVer() {
|
|
149
|
+
return this._remindersVer;
|
|
150
|
+
}
|
|
151
|
+
get supdialog() {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
getUiLanguage() {
|
|
155
|
+
return this._uiLanguage;
|
|
156
|
+
}
|
|
157
|
+
setUiLanguage(language) {
|
|
158
|
+
this._uiLanguage = language;
|
|
159
|
+
}
|
|
160
|
+
getLastUserLanguageCode() {
|
|
161
|
+
return this._lastUserLanguageCode;
|
|
162
|
+
}
|
|
163
|
+
setLastUserLanguageCode(language) {
|
|
164
|
+
this._lastUserLanguageCode = language;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get the current callId for tool-call correlation
|
|
168
|
+
*
|
|
169
|
+
* Call Types:
|
|
170
|
+
* - Tool Call (`!?@tool_name`): callId is set during tool_call_start_evt, used for inline result
|
|
171
|
+
* - Teammate Tellask (@agentName): Uses calleeDialogId, not callId
|
|
172
|
+
*
|
|
173
|
+
* @returns The current callId for tool correlation, or null if no active tool call
|
|
174
|
+
*/
|
|
175
|
+
getCurrentCallId() {
|
|
176
|
+
return this._currentCallId;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Set the current callId (called during tool_call_finish_evt for tool calls)
|
|
180
|
+
*
|
|
181
|
+
* @param callId - The correlation ID from TellaskEventsReceiver.callFinish()
|
|
182
|
+
*/
|
|
183
|
+
setCurrentCallId(callId) {
|
|
184
|
+
this._currentCallId = callId;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Clear the current callId (called after tool response is sent)
|
|
188
|
+
*/
|
|
189
|
+
clearCurrentCallId() {
|
|
190
|
+
this._currentCallId = null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Acquire the dialog mutex. Returns a release callback.
|
|
194
|
+
* FIFO queue ensures fairness when multiple callers wait.
|
|
195
|
+
*/
|
|
196
|
+
async acquire() {
|
|
197
|
+
return await this._mutex.acquire();
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Check if the dialog mutex is currently locked.
|
|
201
|
+
*/
|
|
202
|
+
isLocked() {
|
|
203
|
+
return this._mutex.isLocked();
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Check if dialog has pending Q4H questions.
|
|
207
|
+
* Queries persistence for current questions4Human state.
|
|
208
|
+
*/
|
|
209
|
+
async hasPendingQ4H() {
|
|
210
|
+
try {
|
|
211
|
+
const questions = await this.dlgStore.loadQuestions4Human(this.id, this.status);
|
|
212
|
+
return questions.length > 0;
|
|
213
|
+
}
|
|
214
|
+
catch (err) {
|
|
215
|
+
log_1.log.warn('Failed to load Q4H state for pending check', {
|
|
216
|
+
dialogId: this.id.selfId,
|
|
217
|
+
error: err,
|
|
218
|
+
});
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Check if dialog has pending subdialogs.
|
|
224
|
+
*/
|
|
225
|
+
async hasPendingSubdialogs() {
|
|
226
|
+
try {
|
|
227
|
+
const pending = await this.dlgStore.loadPendingSubdialogs(this.id, this.status);
|
|
228
|
+
return pending.length > 0;
|
|
229
|
+
}
|
|
230
|
+
catch (err) {
|
|
231
|
+
log_1.log.warn('Failed to load pending subdialogs for pending check', {
|
|
232
|
+
dialogId: this.id.selfId,
|
|
233
|
+
error: err,
|
|
234
|
+
});
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Check if dialog can be driven (not suspended for Q4H or subdialogs).
|
|
240
|
+
*/
|
|
241
|
+
async canDrive() {
|
|
242
|
+
const hasQ4H = await this.hasPendingQ4H();
|
|
243
|
+
const hasSubdialogs = await this.hasPendingSubdialogs();
|
|
244
|
+
return !hasQ4H && !hasSubdialogs;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Get suspension status for logging/debugging.
|
|
248
|
+
*/
|
|
249
|
+
async getSuspensionStatus() {
|
|
250
|
+
const hasQ4H = await this.hasPendingQ4H();
|
|
251
|
+
const hasSubdialogs = await this.hasPendingSubdialogs();
|
|
252
|
+
return {
|
|
253
|
+
q4h: hasQ4H,
|
|
254
|
+
subdialogs: hasSubdialogs,
|
|
255
|
+
canDrive: !hasQ4H && !hasSubdialogs,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
get pendingSubdialogIds() {
|
|
259
|
+
return this._pendingSubdialogIds;
|
|
260
|
+
}
|
|
261
|
+
addPendingSubdialogs(ids) {
|
|
262
|
+
this._pendingSubdialogIds.push(...ids);
|
|
263
|
+
}
|
|
264
|
+
removePendingSubdialog(id) {
|
|
265
|
+
this._pendingSubdialogIds = this._pendingSubdialogIds.filter((pending) => pending.selfId !== id.selfId);
|
|
266
|
+
}
|
|
267
|
+
clearPendingSubdialogs() {
|
|
268
|
+
this._pendingSubdialogIds = [];
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Load pending subdialogs from persistence into memory.
|
|
272
|
+
* Used during crash recovery to restore suspension state.
|
|
273
|
+
*/
|
|
274
|
+
async loadPendingSubdialogsFromPersistence() {
|
|
275
|
+
try {
|
|
276
|
+
const pending = await this.dlgStore.loadPendingSubdialogs(this.id, this.status);
|
|
277
|
+
this.clearPendingSubdialogs();
|
|
278
|
+
this.addPendingSubdialogs(pending.map((record) => record.subdialogId));
|
|
279
|
+
}
|
|
280
|
+
catch (err) {
|
|
281
|
+
log_1.log.warn('Failed to load pending subdialogs from persistence', {
|
|
282
|
+
dialogId: this.id.selfId,
|
|
283
|
+
error: err,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Post a dialog event using the standard event registry.
|
|
289
|
+
*/
|
|
290
|
+
postEvent(event) {
|
|
291
|
+
(0, evt_registry_1.postDialogEvent)(this, event);
|
|
292
|
+
}
|
|
293
|
+
// - return true if human response has been collected and incorporated into the msgs, thus
|
|
294
|
+
// should continue generating next llm messages immediately;
|
|
295
|
+
//
|
|
296
|
+
// Reminder management methods
|
|
297
|
+
addReminder(content, owner, meta, position) {
|
|
298
|
+
const reminder = { content, owner, meta };
|
|
299
|
+
const insertIndex = position !== undefined ? position : this.reminders.length;
|
|
300
|
+
if (insertIndex < 0 || insertIndex > this.reminders.length) {
|
|
301
|
+
throw new Error(`Invalid reminder position ${insertIndex}. Valid range: 0-${this.reminders.length}`);
|
|
302
|
+
}
|
|
303
|
+
this.reminders.splice(insertIndex, 0, reminder);
|
|
304
|
+
this._updatedAt = (0, time_1.formatUnifiedTimestamp)(new Date());
|
|
305
|
+
// Increment version for conditional event emission in driver
|
|
306
|
+
this._remindersVer++;
|
|
307
|
+
}
|
|
308
|
+
deleteReminder(index) {
|
|
309
|
+
if (index < 0 || index >= this.reminders.length) {
|
|
310
|
+
throw new Error(`Reminder index ${index} does not exist. Available reminders: 0-${this.reminders.length - 1}`);
|
|
311
|
+
}
|
|
312
|
+
const deleted = this.reminders.splice(index, 1)[0];
|
|
313
|
+
this._updatedAt = (0, time_1.formatUnifiedTimestamp)(new Date());
|
|
314
|
+
// Increment version for conditional event emission in driver
|
|
315
|
+
this._remindersVer++;
|
|
316
|
+
return deleted;
|
|
317
|
+
}
|
|
318
|
+
updateReminder(index, content, meta) {
|
|
319
|
+
if (index < 0 || index >= this.reminders.length) {
|
|
320
|
+
throw new Error(`Reminder index ${index} does not exist. Available reminders: 0-${this.reminders.length - 1}`);
|
|
321
|
+
}
|
|
322
|
+
const oldReminder = this.reminders[index];
|
|
323
|
+
const updatedReminder = {
|
|
324
|
+
content,
|
|
325
|
+
owner: oldReminder.owner,
|
|
326
|
+
meta: meta !== undefined ? meta : oldReminder.meta,
|
|
327
|
+
};
|
|
328
|
+
this.reminders[index] = updatedReminder;
|
|
329
|
+
this._updatedAt = (0, time_1.formatUnifiedTimestamp)(new Date());
|
|
330
|
+
// Increment version for conditional event emission in driver
|
|
331
|
+
this._remindersVer++;
|
|
332
|
+
return oldReminder;
|
|
333
|
+
}
|
|
334
|
+
clearReminders() {
|
|
335
|
+
this.reminders.length = 0;
|
|
336
|
+
this._updatedAt = (0, time_1.formatUnifiedTimestamp)(new Date());
|
|
337
|
+
// Increment version for conditional event emission in driver
|
|
338
|
+
this._remindersVer++;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Process reminder updates before LLM generation.
|
|
342
|
+
* Calls updateReminder on each tool that owns reminders to allow them to update/drop/keep their reminders.
|
|
343
|
+
* Returns reminder contents with metadata for the frontend.
|
|
344
|
+
*/
|
|
345
|
+
async processReminderUpdates() {
|
|
346
|
+
const indicesToRemove = [];
|
|
347
|
+
for (let i = 0; i < this.reminders.length; i++) {
|
|
348
|
+
const reminder = this.reminders[i];
|
|
349
|
+
// Skip if the reminder has no owner or the owner doesn't have an updateReminder method
|
|
350
|
+
if (!reminder.owner || !reminder.owner.updateReminder) {
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
try {
|
|
354
|
+
const result = await reminder.owner.updateReminder(this, reminder);
|
|
355
|
+
switch (result.treatment) {
|
|
356
|
+
case 'drop':
|
|
357
|
+
indicesToRemove.push(i);
|
|
358
|
+
break;
|
|
359
|
+
case 'update':
|
|
360
|
+
if (result.updatedContent !== undefined) {
|
|
361
|
+
const updatedReminder = {
|
|
362
|
+
content: result.updatedContent,
|
|
363
|
+
owner: reminder.owner,
|
|
364
|
+
meta: result.updatedMeta !== undefined ? result.updatedMeta : reminder.meta,
|
|
365
|
+
};
|
|
366
|
+
this.reminders[i] = updatedReminder;
|
|
367
|
+
}
|
|
368
|
+
break;
|
|
369
|
+
case 'keep':
|
|
370
|
+
// No action needed
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
catch (error) {
|
|
375
|
+
log_1.log.error(`Error updating reminder from tool ${reminder.owner}:`, error);
|
|
376
|
+
// Continue processing other reminders even if one fails
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
// Remove reminders marked for deletion (in reverse order to maintain indices)
|
|
380
|
+
for (let i = indicesToRemove.length - 1; i >= 0; i--) {
|
|
381
|
+
this.reminders.splice(indicesToRemove[i], 1);
|
|
382
|
+
}
|
|
383
|
+
if (indicesToRemove.length > 0) {
|
|
384
|
+
this._updatedAt = (0, time_1.formatUnifiedTimestamp)(new Date());
|
|
385
|
+
}
|
|
386
|
+
// Centralized persistence - called when emitting event.
|
|
387
|
+
// Must be awaited to avoid overlapping writes (reminders.json.tmp rename races).
|
|
388
|
+
try {
|
|
389
|
+
await this.dlgStore.persistReminders(this, this.reminders);
|
|
390
|
+
}
|
|
391
|
+
catch (err) {
|
|
392
|
+
log_1.log.warn('Failed to persist reminders', err, { dialogId: this.id.valueOf() });
|
|
393
|
+
}
|
|
394
|
+
const reminders = this.reminders.map((r) => ({
|
|
395
|
+
content: r.content,
|
|
396
|
+
meta: r.meta,
|
|
397
|
+
}));
|
|
398
|
+
// Emit full_reminders_update event with complete reminder list including metadata
|
|
399
|
+
const fullRemindersEvt = {
|
|
400
|
+
type: 'full_reminders_update',
|
|
401
|
+
reminders,
|
|
402
|
+
};
|
|
403
|
+
(0, evt_registry_1.postDialogEvent)(this, fullRemindersEvt);
|
|
404
|
+
return reminders;
|
|
405
|
+
}
|
|
406
|
+
// only to be used by the driver
|
|
407
|
+
async addChatMessages(...msgs) {
|
|
408
|
+
this.msgs.push(...msgs);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Get current round number
|
|
412
|
+
*/
|
|
413
|
+
get currentRound() {
|
|
414
|
+
return this._currentRound;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Get current generation sequence number
|
|
418
|
+
*/
|
|
419
|
+
get activeGenSeq() {
|
|
420
|
+
if (!this._activeGenSeq) {
|
|
421
|
+
throw new Error(`No active genseq, this is bug!!`);
|
|
422
|
+
}
|
|
423
|
+
return this._activeGenSeq;
|
|
424
|
+
}
|
|
425
|
+
get activeGenSeqOrUndefined() {
|
|
426
|
+
return this._activeGenSeq;
|
|
427
|
+
}
|
|
428
|
+
get activeGenRoundOrUndefined() {
|
|
429
|
+
return this._activeGenRound;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Check if generation has started for the current round.
|
|
433
|
+
* Used to ensure subdialog_final_response_evt arrives after parent events.
|
|
434
|
+
*/
|
|
435
|
+
get generationStarted() {
|
|
436
|
+
return this._generationStarted;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Mark generation as started (after user_text event has been emitted).
|
|
440
|
+
* This ensures subdialog_final_response_evt waits for this signal.
|
|
441
|
+
* @param genseq The generation sequence number when this flag is set
|
|
442
|
+
*/
|
|
443
|
+
markGenerationStarted(genseq) {
|
|
444
|
+
this._generationStarted = true;
|
|
445
|
+
this._generationStartedGenseq = genseq ?? this._activeGenSeq ?? 0;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Get the genseq when generation was marked as started
|
|
449
|
+
*/
|
|
450
|
+
get generationStartedGenseq() {
|
|
451
|
+
return this._generationStartedGenseq;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Phase 11: Get current suspension state
|
|
455
|
+
* @returns 'active' | 'suspended' | 'resumed'
|
|
456
|
+
*/
|
|
457
|
+
getSuspensionState() {
|
|
458
|
+
return this._suspensionState;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Phase 11: Set suspension state
|
|
462
|
+
* @param state The new suspension state
|
|
463
|
+
*/
|
|
464
|
+
setSuspensionState(state) {
|
|
465
|
+
this._suspensionState = state;
|
|
466
|
+
this._updatedAt = (0, time_1.formatUnifiedTimestamp)(new Date());
|
|
467
|
+
}
|
|
468
|
+
get createdAt() {
|
|
469
|
+
return this._createdAt;
|
|
470
|
+
}
|
|
471
|
+
get updatedAt() {
|
|
472
|
+
return this._updatedAt;
|
|
473
|
+
}
|
|
474
|
+
setUpNextPrompt(prompt) {
|
|
475
|
+
const trimmed = prompt.trim();
|
|
476
|
+
if (!trimmed) {
|
|
477
|
+
throw new Error('newRoundPrompt is required to start a new round');
|
|
478
|
+
}
|
|
479
|
+
this._upNext = {
|
|
480
|
+
prompt: trimmed,
|
|
481
|
+
msgId: (0, id_1.generateShortId)(),
|
|
482
|
+
userLanguageCode: this._lastUserLanguageCode,
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
hasUpNext() {
|
|
486
|
+
return this._upNext !== undefined;
|
|
487
|
+
}
|
|
488
|
+
takeUpNext() {
|
|
489
|
+
const next = this._upNext;
|
|
490
|
+
this._upNext = undefined;
|
|
491
|
+
return next;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Start a new round - clears conversational noise, Q4H, and increments round counter.
|
|
495
|
+
* Queues a new-round prompt for the driver to consume on the next drive cycle.
|
|
496
|
+
* This is the single entry point for mental clarity operations (clear_mind, change_mind).
|
|
497
|
+
*/
|
|
498
|
+
async startNewRound(newRoundPrompt) {
|
|
499
|
+
const trimmedPrompt = newRoundPrompt.trim();
|
|
500
|
+
if (!trimmedPrompt) {
|
|
501
|
+
throw new Error('newRoundPrompt is required to start a new round');
|
|
502
|
+
}
|
|
503
|
+
// Clear all messages and Q4H questions for mental clarity
|
|
504
|
+
this.msgs.length = 0;
|
|
505
|
+
await this.dlgStore.clearQuestions4Human(this);
|
|
506
|
+
// Delegate to DialogStore for round start persistence
|
|
507
|
+
if (this.dlgStore) {
|
|
508
|
+
await this.dlgStore.startNewRound(this, trimmedPrompt);
|
|
509
|
+
}
|
|
510
|
+
const storeRound = this.dlgStore
|
|
511
|
+
? await this.dlgStore.loadCurrentRound(this.id)
|
|
512
|
+
: this._currentRound + 1;
|
|
513
|
+
this._currentRound = storeRound;
|
|
514
|
+
this._updatedAt = (0, time_1.formatUnifiedTimestamp)(new Date());
|
|
515
|
+
// Principle: user should see what the model sees.
|
|
516
|
+
// For subdialogs, include the original supdialog assignment together with the new-round prompt
|
|
517
|
+
// as the first user message in the new round (persisted by the driver).
|
|
518
|
+
const combinedPrompt = this instanceof SubDialog
|
|
519
|
+
? `${(0, inter_dialog_format_1.formatAssignmentFromSupdialog)({
|
|
520
|
+
fromAgentId: this.assignmentFromSup.originMemberId,
|
|
521
|
+
toAgentId: this.agentId,
|
|
522
|
+
headLine: this.assignmentFromSup.headLine,
|
|
523
|
+
callBody: this.assignmentFromSup.callBody,
|
|
524
|
+
language: (0, runtime_language_1.getWorkLanguage)(),
|
|
525
|
+
collectiveTargets: this.assignmentFromSup.collectiveTargets ?? [this.agentId],
|
|
526
|
+
})}\n---\n${trimmedPrompt}`
|
|
527
|
+
: trimmedPrompt;
|
|
528
|
+
this.setUpNextPrompt(combinedPrompt);
|
|
529
|
+
}
|
|
530
|
+
// Proxy methods for DialogStore - route calls through dialog object instead of direct dlgStore access
|
|
531
|
+
async receiveFuncResult(result) {
|
|
532
|
+
return await this.dlgStore.receiveFuncResult(this, result);
|
|
533
|
+
}
|
|
534
|
+
async notifyGeneratingStart() {
|
|
535
|
+
// Capture the generation's starting round so any events emitted during this generation
|
|
536
|
+
// remain attributed to the correct round even if a tool mutates dialog.currentRound
|
|
537
|
+
// mid-generation (e.g., clear_mind).
|
|
538
|
+
this._activeGenRound = this.currentRound;
|
|
539
|
+
if (typeof this._activeGenSeq === 'number') {
|
|
540
|
+
this._activeGenSeq++;
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
// Get next sequence number from store
|
|
544
|
+
const genseq = await this.dlgStore.getNextSeq(this.id, this.currentRound);
|
|
545
|
+
this._activeGenSeq = genseq;
|
|
546
|
+
}
|
|
547
|
+
// Mark generation as started with the actual genseq
|
|
548
|
+
// This ensures subdialog_final_response_evt waits for both user_text and generating_start_evt
|
|
549
|
+
this.markGenerationStarted();
|
|
550
|
+
await this.dlgStore.notifyGeneratingStart(this);
|
|
551
|
+
}
|
|
552
|
+
async notifyGeneratingFinish(contextHealth, llmGenModel) {
|
|
553
|
+
if (contextHealth) {
|
|
554
|
+
this.setLastContextHealth(contextHealth);
|
|
555
|
+
}
|
|
556
|
+
try {
|
|
557
|
+
await this.dlgStore.notifyGeneratingFinish(this, contextHealth, llmGenModel);
|
|
558
|
+
}
|
|
559
|
+
catch (err) {
|
|
560
|
+
log_1.log.warn('notifyGeneratingFinish failed', undefined, {
|
|
561
|
+
genseq: this._activeGenSeq,
|
|
562
|
+
error: err,
|
|
563
|
+
message: err instanceof Error ? err.message : String(err),
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
// Reset generation tracking for the next round
|
|
567
|
+
this._generationStarted = false;
|
|
568
|
+
this._generationStartedGenseq = 0;
|
|
569
|
+
this._activeGenRound = undefined;
|
|
570
|
+
}
|
|
571
|
+
async streamError(error) {
|
|
572
|
+
if (this.dlgStore) {
|
|
573
|
+
await this.dlgStore.streamError(this, error);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
async thinkingStart() {
|
|
577
|
+
await this.dlgStore.thinkingStart(this);
|
|
578
|
+
}
|
|
579
|
+
async thinkingChunk(chunk) {
|
|
580
|
+
await this.dlgStore.thinkingChunk(this, chunk);
|
|
581
|
+
}
|
|
582
|
+
async markdownStart() {
|
|
583
|
+
await this.dlgStore.markdownStart(this);
|
|
584
|
+
}
|
|
585
|
+
async markdownChunk(chunk) {
|
|
586
|
+
await this.dlgStore.markdownChunk(this, chunk);
|
|
587
|
+
}
|
|
588
|
+
async thinkingFinish() {
|
|
589
|
+
await this.dlgStore.thinkingFinish(this);
|
|
590
|
+
}
|
|
591
|
+
async markdownFinish() {
|
|
592
|
+
await this.dlgStore.markdownFinish(this);
|
|
593
|
+
}
|
|
594
|
+
async sayingStart() {
|
|
595
|
+
await this.dlgStore.sayingStart(this);
|
|
596
|
+
}
|
|
597
|
+
async sayingChunk(chunk) {
|
|
598
|
+
await this.dlgStore.sayingChunk(this, chunk);
|
|
599
|
+
// No frontend event needed - frontend gets content through streaming parser
|
|
600
|
+
}
|
|
601
|
+
async sayingFinish() {
|
|
602
|
+
await this.dlgStore.sayingFinish(this);
|
|
603
|
+
}
|
|
604
|
+
// Function call events (non-streaming mode - single event captures entire call)
|
|
605
|
+
async funcCallRequested(funcId, funcName, argumentsStr) {
|
|
606
|
+
await this.dlgStore.funcCallRequested(this, funcId, funcName, argumentsStr);
|
|
607
|
+
}
|
|
608
|
+
// Tellask call events (streaming mode - `!?@...` blocks)
|
|
609
|
+
async callingStart(validation) {
|
|
610
|
+
await this.dlgStore.callingStart(this, validation);
|
|
611
|
+
}
|
|
612
|
+
async callingHeadlineChunk(chunk) {
|
|
613
|
+
await this.dlgStore.callingHeadlineChunk(this, chunk);
|
|
614
|
+
}
|
|
615
|
+
async callingHeadlineFinish() {
|
|
616
|
+
await this.dlgStore.callingHeadlineFinish(this);
|
|
617
|
+
}
|
|
618
|
+
async callingBodyStart() {
|
|
619
|
+
await this.dlgStore.callingBodyStart(this);
|
|
620
|
+
}
|
|
621
|
+
async callingBodyChunk(chunk) {
|
|
622
|
+
await this.dlgStore.callingBodyChunk(this, chunk);
|
|
623
|
+
}
|
|
624
|
+
async callingBodyFinish() {
|
|
625
|
+
await this.dlgStore.callingBodyFinish(this);
|
|
626
|
+
}
|
|
627
|
+
async callingFinish(callId) {
|
|
628
|
+
// Store callId for tool call correlation
|
|
629
|
+
this.setCurrentCallId(callId);
|
|
630
|
+
await this.dlgStore.callingFinish(this, callId);
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Receive tool response with callId for inline correlation
|
|
634
|
+
*/
|
|
635
|
+
async receiveToolResponse(responderId, headLine, result, status, callId) {
|
|
636
|
+
return await this.dlgStore.receiveToolResponse(this, responderId, headLine, result, status, callId);
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Receive teammate response (separate bubble for @teammate tellasks)
|
|
640
|
+
*/
|
|
641
|
+
async receiveTeammateResponse(responderId, headLine, status, subdialogId, options) {
|
|
642
|
+
return await this.dlgStore.receiveTeammateResponse(this, responderId, headLine, status, subdialogId, options);
|
|
643
|
+
}
|
|
644
|
+
async updateQuestions4Human(questions) {
|
|
645
|
+
return await this.dlgStore.updateQuestions4Human(this, questions);
|
|
646
|
+
}
|
|
647
|
+
async persistUserMessage(content, msgId, grammar, userLanguageCode) {
|
|
648
|
+
return await this.dlgStore.persistUserMessage(this, content, msgId, grammar, userLanguageCode);
|
|
649
|
+
}
|
|
650
|
+
async persistAgentMessage(content, genseq, type, provider_data) {
|
|
651
|
+
return await this.dlgStore.persistAgentMessage(this, content, genseq, type, provider_data);
|
|
652
|
+
}
|
|
653
|
+
async persistFunctionCall(id, name, arguments_, genseq) {
|
|
654
|
+
return await this.dlgStore.persistFunctionCall(this, id, name, arguments_, genseq);
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Post subdialog completion response to this dialog.
|
|
658
|
+
* Phase 14: No wait - emit immediately with virtual gen markers for Type C subdialogs
|
|
659
|
+
*/
|
|
660
|
+
async postSubdialogResponse(subdialogId, response) {
|
|
661
|
+
try {
|
|
662
|
+
let responderId = subdialogId.rootId;
|
|
663
|
+
let responderAgentId;
|
|
664
|
+
let headLine = response;
|
|
665
|
+
let originMemberId = responderId;
|
|
666
|
+
let callId = '';
|
|
667
|
+
try {
|
|
668
|
+
const metadata = await this.dlgStore.loadDialogMetadata(subdialogId, 'running');
|
|
669
|
+
if (metadata) {
|
|
670
|
+
if (metadata.agentId) {
|
|
671
|
+
responderId = metadata.agentId;
|
|
672
|
+
responderAgentId = metadata.agentId;
|
|
673
|
+
originMemberId = metadata.agentId;
|
|
674
|
+
}
|
|
675
|
+
if (metadata.assignmentFromSup) {
|
|
676
|
+
headLine = metadata.assignmentFromSup.headLine;
|
|
677
|
+
originMemberId = metadata.assignmentFromSup.originMemberId;
|
|
678
|
+
callId = metadata.assignmentFromSup.callId;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
catch (err) {
|
|
683
|
+
log_1.log.warn('Failed to load subdialog metadata for response labeling', {
|
|
684
|
+
dialogId: this.id.selfId,
|
|
685
|
+
subdialogId: subdialogId.selfId,
|
|
686
|
+
error: err,
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
if (callId.trim() === '') {
|
|
690
|
+
log_1.log.warn('Missing callId for subdialog response', undefined, {
|
|
691
|
+
dialogId: this.id.selfId,
|
|
692
|
+
subdialogId: subdialogId.selfId,
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
if (headLine.trim() === '') {
|
|
696
|
+
headLine = response;
|
|
697
|
+
}
|
|
698
|
+
// NO WAIT - emit immediately with virtual gen markers
|
|
699
|
+
// Emit virtual generating_start_evt for subdialog response bubble
|
|
700
|
+
await this.notifyGeneratingStart();
|
|
701
|
+
const formattedResult = (0, inter_dialog_format_1.formatTeammateResponseContent)({
|
|
702
|
+
responderId,
|
|
703
|
+
requesterId: originMemberId,
|
|
704
|
+
originalCallHeadLine: headLine,
|
|
705
|
+
responseBody: response,
|
|
706
|
+
language: (0, runtime_language_1.getWorkLanguage)(),
|
|
707
|
+
});
|
|
708
|
+
// Emit TeammateResponseEvent
|
|
709
|
+
const evt = {
|
|
710
|
+
type: 'teammate_response_evt',
|
|
711
|
+
responderId,
|
|
712
|
+
calleeDialogId: subdialogId.selfId,
|
|
713
|
+
headLine,
|
|
714
|
+
status: 'completed',
|
|
715
|
+
result: formattedResult,
|
|
716
|
+
round: this.currentRound,
|
|
717
|
+
response,
|
|
718
|
+
agentId: responderAgentId ?? responderId,
|
|
719
|
+
callId,
|
|
720
|
+
originMemberId,
|
|
721
|
+
};
|
|
722
|
+
(0, evt_registry_1.postDialogEvent)(this, evt);
|
|
723
|
+
// Emit virtual generating_finish_evt
|
|
724
|
+
await this.notifyGeneratingFinish();
|
|
725
|
+
}
|
|
726
|
+
catch (err) {
|
|
727
|
+
log_1.log.warn('Failed to post teammate_response_evt event', undefined, {
|
|
728
|
+
error: err,
|
|
729
|
+
message: err instanceof Error ? err.message : String(err),
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
exports.Dialog = Dialog;
|
|
735
|
+
/**
|
|
736
|
+
* SubDialog - A subdialog created by a RootDialog for autonomous teammate tellasks.
|
|
737
|
+
* Stores the root dialog for registry and lookup, and resolves its effective supdialog dynamically.
|
|
738
|
+
*/
|
|
739
|
+
class SubDialog extends Dialog {
|
|
740
|
+
constructor(dlgStore, rootDialog, taskDocPath, id, agentId, assignmentFromSup, tellaskSession, initialState) {
|
|
741
|
+
super(dlgStore, taskDocPath, id, agentId, initialState);
|
|
742
|
+
this.rootDialog = rootDialog;
|
|
743
|
+
this.tellaskSession = tellaskSession;
|
|
744
|
+
this.assignmentFromSup = assignmentFromSup;
|
|
745
|
+
const resolvedSupdialog = rootDialog.lookupDialog(assignmentFromSup.callerDialogId);
|
|
746
|
+
if (resolvedSupdialog && resolvedSupdialog.id.selfId === this.id.selfId) {
|
|
747
|
+
log_1.log.warn('SubDialog assignmentFromSup.callerDialogId resolved to self; falling back to root', {
|
|
748
|
+
dialogId: this.id.selfId,
|
|
749
|
+
callerDialogId: assignmentFromSup.callerDialogId,
|
|
750
|
+
});
|
|
751
|
+
this._supdialog = rootDialog;
|
|
752
|
+
}
|
|
753
|
+
else if (resolvedSupdialog) {
|
|
754
|
+
this._supdialog = resolvedSupdialog;
|
|
755
|
+
}
|
|
756
|
+
else {
|
|
757
|
+
// If we can't resolve the caller dialog in the in-memory registry, fall back to root.
|
|
758
|
+
// This can happen when restoring a dialog tree without restoring the full parent chain.
|
|
759
|
+
log_1.log.warn('SubDialog failed to resolve callerDialogId in root registry; falling back to root', {
|
|
760
|
+
dialogId: this.id.selfId,
|
|
761
|
+
callerDialogId: assignmentFromSup.callerDialogId,
|
|
762
|
+
rootId: rootDialog.id.rootId,
|
|
763
|
+
});
|
|
764
|
+
this._supdialog = rootDialog;
|
|
765
|
+
}
|
|
766
|
+
this.rootDialog.registerDialog(this);
|
|
767
|
+
}
|
|
768
|
+
get supdialog() {
|
|
769
|
+
return this._supdialog;
|
|
770
|
+
}
|
|
771
|
+
get status() {
|
|
772
|
+
return this.rootDialog.status;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Create a subdialog under the same root dialog tree.
|
|
776
|
+
* The new subdialog's effective supdialog is resolved via AssignmentFromSup.callerDialogId.
|
|
777
|
+
*/
|
|
778
|
+
async createSubDialog(targetAgentId, headLine, callBody, options) {
|
|
779
|
+
return await this.rootDialog.createSubDialog(targetAgentId, headLine, callBody, options);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
exports.SubDialog = SubDialog;
|
|
783
|
+
/**
|
|
784
|
+
* RootDialog - The main/root dialog that can create and manage subdialogs.
|
|
785
|
+
* Uses in-memory registries for O(1) dialog and Type B lookup.
|
|
786
|
+
*/
|
|
787
|
+
class RootDialog extends Dialog {
|
|
788
|
+
constructor(dlgStore, taskDocPath, id, agentId, initialState) {
|
|
789
|
+
super(dlgStore, taskDocPath, id, agentId, initialState);
|
|
790
|
+
this._status = 'running';
|
|
791
|
+
// Tracks all dialogs in this dialog tree for O(1) lookup
|
|
792
|
+
this._localRegistry = new Map();
|
|
793
|
+
// Tracks TYPE B registered subdialogs by agentId!tellaskSession
|
|
794
|
+
this._subdialogRegistry = new Map();
|
|
795
|
+
this.registerDialog(this);
|
|
796
|
+
}
|
|
797
|
+
get status() {
|
|
798
|
+
return this._status;
|
|
799
|
+
}
|
|
800
|
+
setPersistenceStatus(status) {
|
|
801
|
+
this._status = status;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Register a dialog (self or subdialog) in the local registry.
|
|
805
|
+
*/
|
|
806
|
+
registerDialog(dialog) {
|
|
807
|
+
this._localRegistry.set(dialog.id.selfId, dialog);
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Lookup a dialog by selfId in the local registry.
|
|
811
|
+
*/
|
|
812
|
+
lookupDialog(selfId) {
|
|
813
|
+
return this._localRegistry.get(selfId);
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Get all registered dialogs in this dialog tree.
|
|
817
|
+
*/
|
|
818
|
+
getAllDialogs() {
|
|
819
|
+
return Array.from(this._localRegistry.values());
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Remove a dialog from the local registry.
|
|
823
|
+
*/
|
|
824
|
+
unregisterDialog(selfId) {
|
|
825
|
+
this._localRegistry.delete(selfId);
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Generate a registry key from agentId and tellaskSession.
|
|
829
|
+
*/
|
|
830
|
+
static makeSubdialogKey(agentId, tellaskSession) {
|
|
831
|
+
return `${agentId}!${tellaskSession}`;
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Register a TYPE B subdialog for resumption.
|
|
835
|
+
*/
|
|
836
|
+
registerSubdialog(subdialog) {
|
|
837
|
+
if (!subdialog.tellaskSession) {
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
const key = RootDialog.makeSubdialogKey(subdialog.agentId, subdialog.tellaskSession);
|
|
841
|
+
this._subdialogRegistry.set(key, subdialog);
|
|
842
|
+
this.registerDialog(subdialog);
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Lookup a TYPE B subdialog by agentId and tellaskSession.
|
|
846
|
+
*/
|
|
847
|
+
lookupSubdialog(agentId, tellaskSession) {
|
|
848
|
+
const key = RootDialog.makeSubdialogKey(agentId, tellaskSession);
|
|
849
|
+
return this._subdialogRegistry.get(key);
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Remove a TYPE B subdialog from registry.
|
|
853
|
+
*/
|
|
854
|
+
unregisterSubdialog(agentId, tellaskSession) {
|
|
855
|
+
const key = RootDialog.makeSubdialogKey(agentId, tellaskSession);
|
|
856
|
+
const subdialog = this._subdialogRegistry.get(key);
|
|
857
|
+
if (subdialog) {
|
|
858
|
+
this._localRegistry.delete(subdialog.id.selfId);
|
|
859
|
+
return this._subdialogRegistry.delete(key);
|
|
860
|
+
}
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Get all registered subdialogs.
|
|
865
|
+
*/
|
|
866
|
+
getRegisteredSubdialogs() {
|
|
867
|
+
return Array.from(this._subdialogRegistry.values());
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* Create a new subdialog for autonomous teammate tellasks.
|
|
871
|
+
*/
|
|
872
|
+
async createSubDialog(targetAgentId, headLine, callBody, options) {
|
|
873
|
+
return await this.dlgStore.createSubDialog(this, targetAgentId, headLine, callBody, options);
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Save subdialog registry to disk (registry.yaml).
|
|
877
|
+
*/
|
|
878
|
+
async saveSubdialogRegistry() {
|
|
879
|
+
const entries = Array.from(this._subdialogRegistry.entries()).map(([key, subdialog]) => ({
|
|
880
|
+
key,
|
|
881
|
+
subdialogId: subdialog.id,
|
|
882
|
+
agentId: subdialog.agentId,
|
|
883
|
+
tellaskSession: subdialog.tellaskSession,
|
|
884
|
+
}));
|
|
885
|
+
await this.dlgStore.saveSubdialogRegistry(this.id, entries, this.status);
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Load subdialog registry from disk (registry.yaml).
|
|
889
|
+
*/
|
|
890
|
+
async loadSubdialogRegistry() {
|
|
891
|
+
await this.dlgStore.loadSubdialogRegistry(this, this.status);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
exports.RootDialog = RootDialog;
|
|
895
|
+
/**
|
|
896
|
+
* The UI showing a dialog in realtime
|
|
897
|
+
*/
|
|
898
|
+
class DialogStore {
|
|
899
|
+
/**
|
|
900
|
+
* almost certainly, the subclass should override this method to be (sub)dialog structure aware
|
|
901
|
+
*
|
|
902
|
+
* impl here serves for demo purpose only
|
|
903
|
+
*
|
|
904
|
+
* @param supdialog
|
|
905
|
+
* @param targetAgentId
|
|
906
|
+
* @param headLine
|
|
907
|
+
* @param callBody
|
|
908
|
+
* @returns
|
|
909
|
+
*/
|
|
910
|
+
async createSubDialog(supdialog, targetAgentId, headLine, callBody, options) {
|
|
911
|
+
const generatedId = (0, id_2.generateDialogID)();
|
|
912
|
+
// For subdialogs, use the supdialog's root dialog ID as the root
|
|
913
|
+
const subdialogId = new DialogID(generatedId, supdialog.id.rootId);
|
|
914
|
+
return new SubDialog(this, supdialog, supdialog.taskDocPath, subdialogId, targetAgentId, {
|
|
915
|
+
headLine,
|
|
916
|
+
callBody,
|
|
917
|
+
originMemberId: options.originMemberId,
|
|
918
|
+
callerDialogId: options.callerDialogId,
|
|
919
|
+
callId: options.callId,
|
|
920
|
+
collectiveTargets: options.collectiveTargets,
|
|
921
|
+
}, options.tellaskSession);
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Receive and handle LLM generation streams (Markdown stream + tellask call stream)
|
|
925
|
+
*/
|
|
926
|
+
/**
|
|
927
|
+
* Notify start of LLM generation lifecycle (generating_start_evt)
|
|
928
|
+
*/
|
|
929
|
+
async notifyGeneratingStart(_dialog) { }
|
|
930
|
+
/**
|
|
931
|
+
* Notify end of LLM generation lifecycle (generating_finish_evt)
|
|
932
|
+
*/
|
|
933
|
+
async notifyGeneratingFinish(_dialog, _contextHealth, _llmGenModel) { }
|
|
934
|
+
// Explicit phase notifications (driver-driven)
|
|
935
|
+
thinkingStart(_dialog) { }
|
|
936
|
+
thinkingChunk(_dialog, _chunk) { }
|
|
937
|
+
thinkingFinish(_dialog) { }
|
|
938
|
+
markdownStart(_dialog) { }
|
|
939
|
+
markdownChunk(_dialog, _chunk) { }
|
|
940
|
+
markdownFinish(_dialog) { }
|
|
941
|
+
// Saying streaming methods (different from markdown)
|
|
942
|
+
sayingStart(_dialog) { }
|
|
943
|
+
sayingChunk(_dialog, _chunk) { }
|
|
944
|
+
sayingFinish(_dialog) { }
|
|
945
|
+
async receiveFuncResult(_dialog, _funcResult) { }
|
|
946
|
+
/**
|
|
947
|
+
* Receive tool response with callId for inline correlation
|
|
948
|
+
*/
|
|
949
|
+
async receiveToolResponse(_dialog, _responderId, _headLine, _result, _status, _callId) { }
|
|
950
|
+
/**
|
|
951
|
+
* Receive teammate response (separate bubble for @teammate tellasks)
|
|
952
|
+
*/
|
|
953
|
+
async receiveTeammateResponse(_dialog, _responderId, _headLine, _status, _subdialogId, _options) { }
|
|
954
|
+
async updateQuestions4Human(_dialog, _questions) { }
|
|
955
|
+
/**
|
|
956
|
+
* Load Questions for Human state from storage
|
|
957
|
+
*/
|
|
958
|
+
async loadQuestions4Human(_dialogId, _status) {
|
|
959
|
+
return [];
|
|
960
|
+
}
|
|
961
|
+
async loadDialogMetadata(_dialogId, _status) {
|
|
962
|
+
return null;
|
|
963
|
+
}
|
|
964
|
+
async loadPendingSubdialogs(_dialogId, _status) {
|
|
965
|
+
return [];
|
|
966
|
+
}
|
|
967
|
+
async saveSubdialogRegistry(_rootDialogId, _entries, _status) { }
|
|
968
|
+
async loadSubdialogRegistry(_rootDialog, _status) { }
|
|
969
|
+
/**
|
|
970
|
+
* Clear Questions for Human state in storage
|
|
971
|
+
*/
|
|
972
|
+
async clearQuestions4Human(_dialog) { }
|
|
973
|
+
// Tellask call streaming methods
|
|
974
|
+
async callingStart(_dialog, _validation) { }
|
|
975
|
+
async callingHeadlineChunk(_dialog, _chunk) { }
|
|
976
|
+
async callingHeadlineFinish(_dialog) { }
|
|
977
|
+
async callingBodyStart(_dialog) { }
|
|
978
|
+
async callingBodyChunk(_dialog, _chunk) { }
|
|
979
|
+
async callingBodyFinish(_dialog) { }
|
|
980
|
+
async callingFinish(_dialog, _callId) { }
|
|
981
|
+
// Function call event (non-streaming mode - single event)
|
|
982
|
+
async funcCallRequested(_dialog, _funcId, _funcName, _argumentsStr) { }
|
|
983
|
+
/**
|
|
984
|
+
* Load current round number from persisted metadata
|
|
985
|
+
* This method should be implemented by subclasses to read from storage
|
|
986
|
+
*/
|
|
987
|
+
async loadCurrentRound(_dialogId) {
|
|
988
|
+
// Default implementation returns 1
|
|
989
|
+
return 1;
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Get next sequence number for generation
|
|
993
|
+
* This method should be implemented by subclasses for sequence allocation
|
|
994
|
+
*/
|
|
995
|
+
async getNextSeq(_dialogId, _round) {
|
|
996
|
+
// Default implementation returns 1
|
|
997
|
+
return 1;
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Persist reminders to storage (event emission handled by processReminderUpdates)
|
|
1001
|
+
*/
|
|
1002
|
+
async persistReminders(_dialog, _reminders) { }
|
|
1003
|
+
/**
|
|
1004
|
+
* Persist a user message to storage
|
|
1005
|
+
*/
|
|
1006
|
+
async persistUserMessage(_dialog, _content, _msgId, _grammar, _userLanguageCode) { }
|
|
1007
|
+
/**
|
|
1008
|
+
* Persist an assistant message to storage
|
|
1009
|
+
*/
|
|
1010
|
+
async persistAgentMessage(_dialog, _content, _genseq, _type, _provider_data) { }
|
|
1011
|
+
/**
|
|
1012
|
+
* Persist a function call to storage
|
|
1013
|
+
*/
|
|
1014
|
+
async persistFunctionCall(_dialog, _id, _name, _arguments, _genseq) { }
|
|
1015
|
+
/**
|
|
1016
|
+
* Start a new round in storage
|
|
1017
|
+
*/
|
|
1018
|
+
async startNewRound(_dialog, _newRoundPrompt) { }
|
|
1019
|
+
/**
|
|
1020
|
+
* Handle stream error
|
|
1021
|
+
*/
|
|
1022
|
+
async streamError(_dialog, _error) { }
|
|
1023
|
+
}
|
|
1024
|
+
exports.DialogStore = DialogStore;
|