dominds 1.4.2 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/README.zh.md +24 -0
- package/dist/apps/app-json.js +38 -3
- package/dist/apps/dialog-run-controls.js +4 -0
- package/dist/apps/enabled-apps.js +8 -1
- package/dist/apps/installed-file.js +207 -0
- package/dist/apps/run-app-json.js +6 -6
- package/dist/apps/runtime-port.js +91 -0
- package/dist/apps/runtime.js +316 -68
- package/dist/apps-host/client.js +153 -3
- package/dist/apps-host/host.js +339 -2
- package/dist/apps-host/ipc-types.js +215 -30
- package/dist/cli/install.js +21 -1
- package/dist/dialog-fork.js +609 -0
- package/dist/dialog.js +2 -2
- package/dist/docs/agent-priming.md +38 -0
- package/dist/docs/agent-priming.zh.md +34 -0
- package/dist/docs/app-constitution.md +153 -2
- package/dist/docs/app-constitution.zh.md +153 -2
- package/dist/docs/dialog-persistence.md +31 -0
- package/dist/docs/dialog-persistence.zh.md +31 -0
- package/dist/docs/dialog-system.md +29 -0
- package/dist/docs/dialog-system.zh.md +29 -0
- package/dist/docs/kernel-app-architecture.md +286 -0
- package/dist/docs/kernel-app-architecture.zh.md +285 -0
- package/dist/llm/defaults.yaml +16 -0
- package/dist/llm/driver-entry.js +28 -0
- package/dist/llm/driver-v2/context-health.js +121 -0
- package/dist/llm/driver-v2/context.js +56 -0
- package/dist/llm/driver-v2/core.js +1545 -0
- package/dist/llm/driver-v2/index.js +26 -0
- package/dist/llm/driver-v2/orchestrator.js +158 -0
- package/dist/llm/driver-v2/policy.js +129 -0
- package/dist/llm/driver-v2/restore-dialog-hierarchy.js +73 -0
- package/dist/llm/driver-v2/round.js +366 -0
- package/dist/llm/driver-v2/runtime-utils.js +365 -0
- package/dist/llm/driver-v2/saying-events.js +20 -0
- package/dist/llm/driver-v2/subdialog-txn.js +42 -0
- package/dist/llm/driver-v2/supdialog-response.js +400 -0
- package/dist/llm/driver-v2/tellask-bridge.js +1148 -0
- package/dist/llm/driver-v2/types.js +10 -0
- package/dist/llm/driver-v2-ref-only/context-health.js +121 -0
- package/dist/llm/driver-v2-ref-only/context.js +17 -0
- package/dist/llm/driver-v2-ref-only/core.js +1710 -0
- package/dist/llm/driver-v2-ref-only/index.js +26 -0
- package/dist/llm/driver-v2-ref-only/orchestrator.js +158 -0
- package/dist/llm/driver-v2-ref-only/policy.js +129 -0
- package/dist/llm/driver-v2-ref-only/restore-dialog-hierarchy.js +73 -0
- package/dist/llm/driver-v2-ref-only/round.js +366 -0
- package/dist/llm/driver-v2-ref-only/runtime-utils.js +473 -0
- package/dist/llm/driver-v2-ref-only/saying-events.js +18 -0
- package/dist/llm/driver-v2-ref-only/subdialog-txn.js +42 -0
- package/dist/llm/driver-v2-ref-only/supdialog-response.js +453 -0
- package/dist/llm/driver-v2-ref-only/tellask-bridge.js +1178 -0
- package/dist/llm/driver-v2-ref-only/types.js +10 -0
- package/dist/llm/gen/anthropic.js +68 -15
- package/dist/llm/gen/codex.js +59 -10
- package/dist/llm/gen/openai-compatible.js +38 -9
- package/dist/llm/gen/openai.js +58 -11
- package/dist/llm/gen/tool-output-limit.js +50 -0
- package/dist/llm/kernel-driver/subdialog.js +23 -12
- package/dist/llm/kernel-driver/tellask-special.js +20 -4
- package/dist/minds/load.js +7 -0
- package/dist/persistence.js +216 -30
- package/dist/priming.js +171 -18
- package/dist/server/api-routes.js +82 -0
- package/dist/server/setup-routes.js +15 -0
- package/dist/shared/types/storage.js +77 -0
- package/dist/static/assets/{_basePickBy-B2o4z1Hf.js → _basePickBy-B-A5XrWM.js} +3 -3
- package/dist/static/assets/{_basePickBy-B2o4z1Hf.js.map → _basePickBy-B-A5XrWM.js.map} +1 -1
- package/dist/static/assets/{_baseUniq-CLmcxjdl.js → _baseUniq-BANLb0cu.js} +2 -2
- package/dist/static/assets/{_baseUniq-CLmcxjdl.js.map → _baseUniq-BANLb0cu.js.map} +1 -1
- package/dist/static/assets/{arc-CymD_KN7.js → arc-CYZYnojf.js} +2 -2
- package/dist/static/assets/{arc-CymD_KN7.js.map → arc-CYZYnojf.js.map} +1 -1
- package/dist/static/assets/{architectureDiagram-VXUJARFQ-DJQfSJUH.js → architectureDiagram-VXUJARFQ-Cxf4pmYG.js} +7 -7
- package/dist/static/assets/{architectureDiagram-VXUJARFQ-DJQfSJUH.js.map → architectureDiagram-VXUJARFQ-Cxf4pmYG.js.map} +1 -1
- package/dist/static/assets/{blockDiagram-VD42YOAC-pHVz60D0.js → blockDiagram-VD42YOAC-wvs0G30c.js} +7 -7
- package/dist/static/assets/{blockDiagram-VD42YOAC-pHVz60D0.js.map → blockDiagram-VD42YOAC-wvs0G30c.js.map} +1 -1
- package/dist/static/assets/{c4Diagram-YG6GDRKO-B0WnCfAT.js → c4Diagram-YG6GDRKO-BKFNexn4.js} +3 -3
- package/dist/static/assets/{c4Diagram-YG6GDRKO-B0WnCfAT.js.map → c4Diagram-YG6GDRKO-BKFNexn4.js.map} +1 -1
- package/dist/static/assets/{channel-CX9BlKil.js → channel-_1qpxJWy.js} +2 -2
- package/dist/static/assets/{channel-CX9BlKil.js.map → channel-_1qpxJWy.js.map} +1 -1
- package/dist/static/assets/{chunk-4BX2VUAB-lXArRj3o.js → chunk-4BX2VUAB-BIdC0phm.js} +2 -2
- package/dist/static/assets/{chunk-4BX2VUAB-lXArRj3o.js.map → chunk-4BX2VUAB-BIdC0phm.js.map} +1 -1
- package/dist/static/assets/{chunk-55IACEB6-CdqwynH9.js → chunk-55IACEB6-BNvGenQ9.js} +2 -2
- package/dist/static/assets/{chunk-55IACEB6-CdqwynH9.js.map → chunk-55IACEB6-BNvGenQ9.js.map} +1 -1
- package/dist/static/assets/{chunk-B4BG7PRW-Y-uXcJst.js → chunk-B4BG7PRW-jmf-1Wv7.js} +5 -5
- package/dist/static/assets/{chunk-B4BG7PRW-Y-uXcJst.js.map → chunk-B4BG7PRW-jmf-1Wv7.js.map} +1 -1
- package/dist/static/assets/{chunk-DI55MBZ5-C5xSbRST.js → chunk-DI55MBZ5-nmEmcikR.js} +4 -4
- package/dist/static/assets/{chunk-DI55MBZ5-C5xSbRST.js.map → chunk-DI55MBZ5-nmEmcikR.js.map} +1 -1
- package/dist/static/assets/{chunk-FMBD7UC4-5uefwCjI.js → chunk-FMBD7UC4-kGysaq_j.js} +2 -2
- package/dist/static/assets/{chunk-FMBD7UC4-5uefwCjI.js.map → chunk-FMBD7UC4-kGysaq_j.js.map} +1 -1
- package/dist/static/assets/{chunk-QN33PNHL-DzWVcvpI.js → chunk-QN33PNHL-8JwMLFIJ.js} +2 -2
- package/dist/static/assets/{chunk-QN33PNHL-DzWVcvpI.js.map → chunk-QN33PNHL-8JwMLFIJ.js.map} +1 -1
- package/dist/static/assets/{chunk-QZHKN3VN-BrrvAZdP.js → chunk-QZHKN3VN-DZleEj00.js} +2 -2
- package/dist/static/assets/{chunk-QZHKN3VN-BrrvAZdP.js.map → chunk-QZHKN3VN-DZleEj00.js.map} +1 -1
- package/dist/static/assets/{chunk-TZMSLE5B-DyKOlPTY.js → chunk-TZMSLE5B-CXxl_uqH.js} +2 -2
- package/dist/static/assets/{chunk-TZMSLE5B-DyKOlPTY.js.map → chunk-TZMSLE5B-CXxl_uqH.js.map} +1 -1
- package/dist/static/assets/{classDiagram-2ON5EDUG-FCrnlCWC.js → classDiagram-2ON5EDUG-C-7R0QB6.js} +6 -6
- package/dist/static/assets/{classDiagram-2ON5EDUG-FCrnlCWC.js.map → classDiagram-2ON5EDUG-C-7R0QB6.js.map} +1 -1
- package/dist/static/assets/{classDiagram-v2-WZHVMYZB-FCrnlCWC.js → classDiagram-v2-WZHVMYZB-C-7R0QB6.js} +6 -6
- package/dist/static/assets/{classDiagram-v2-WZHVMYZB-FCrnlCWC.js.map → classDiagram-v2-WZHVMYZB-C-7R0QB6.js.map} +1 -1
- package/dist/static/assets/{clone-BlI81KqZ.js → clone-BwOKYSj8.js} +2 -2
- package/dist/static/assets/{clone-BlI81KqZ.js.map → clone-BwOKYSj8.js.map} +1 -1
- package/dist/static/assets/{cose-bilkent-S5V4N54A-yM7S2atz.js → cose-bilkent-S5V4N54A-BCBalM7p.js} +2 -2
- package/dist/static/assets/{cose-bilkent-S5V4N54A-yM7S2atz.js.map → cose-bilkent-S5V4N54A-BCBalM7p.js.map} +1 -1
- package/dist/static/assets/{dagre-6UL2VRFP-BcweuZHt.js → dagre-6UL2VRFP-uV2ekQoj.js} +7 -7
- package/dist/static/assets/{dagre-6UL2VRFP-BcweuZHt.js.map → dagre-6UL2VRFP-uV2ekQoj.js.map} +1 -1
- package/dist/static/assets/{diagram-PSM6KHXK-D4-QwLW1.js → diagram-PSM6KHXK-D-ZMog1-.js} +8 -8
- package/dist/static/assets/{diagram-PSM6KHXK-D4-QwLW1.js.map → diagram-PSM6KHXK-D-ZMog1-.js.map} +1 -1
- package/dist/static/assets/{diagram-QEK2KX5R-BVbuejJn.js → diagram-QEK2KX5R-BThSELUH.js} +7 -7
- package/dist/static/assets/{diagram-QEK2KX5R-BVbuejJn.js.map → diagram-QEK2KX5R-BThSELUH.js.map} +1 -1
- package/dist/static/assets/{diagram-S2PKOQOG-pB6N6Tq_.js → diagram-S2PKOQOG-Di-YN5cd.js} +7 -7
- package/dist/static/assets/{diagram-S2PKOQOG-pB6N6Tq_.js.map → diagram-S2PKOQOG-Di-YN5cd.js.map} +1 -1
- package/dist/static/assets/{erDiagram-Q2GNP2WA-DLKmthuw.js → erDiagram-Q2GNP2WA-lBZ9DITn.js} +5 -5
- package/dist/static/assets/{erDiagram-Q2GNP2WA-DLKmthuw.js.map → erDiagram-Q2GNP2WA-lBZ9DITn.js.map} +1 -1
- package/dist/static/assets/{flowDiagram-NV44I4VS-BsBhWukh.js → flowDiagram-NV44I4VS-C_60PNQR.js} +6 -6
- package/dist/static/assets/{flowDiagram-NV44I4VS-BsBhWukh.js.map → flowDiagram-NV44I4VS-C_60PNQR.js.map} +1 -1
- package/dist/static/assets/{ganttDiagram-JELNMOA3-Debz-J-C.js → ganttDiagram-JELNMOA3-Dvqq-VHJ.js} +3 -3
- package/dist/static/assets/{ganttDiagram-JELNMOA3-Debz-J-C.js.map → ganttDiagram-JELNMOA3-Dvqq-VHJ.js.map} +1 -1
- package/dist/static/assets/{gitGraphDiagram-V2S2FVAM-BnAPFBGR.js → gitGraphDiagram-V2S2FVAM-BTj8orRe.js} +8 -8
- package/dist/static/assets/{gitGraphDiagram-V2S2FVAM-BnAPFBGR.js.map → gitGraphDiagram-V2S2FVAM-BTj8orRe.js.map} +1 -1
- package/dist/static/assets/{graph-DbzWiBNK.js → graph-BqCzR2Nl.js} +3 -3
- package/dist/static/assets/{graph-DbzWiBNK.js.map → graph-BqCzR2Nl.js.map} +1 -1
- package/dist/static/assets/{index-B-8J28g7.js → index-DrTqAfFy.js} +386 -201
- package/dist/static/assets/index-DrTqAfFy.js.map +1 -0
- package/dist/static/assets/{infoDiagram-HS3SLOUP-CZ5hWoxV.js → infoDiagram-HS3SLOUP-DlC6wsrv.js} +6 -6
- package/dist/static/assets/{infoDiagram-HS3SLOUP-CZ5hWoxV.js.map → infoDiagram-HS3SLOUP-DlC6wsrv.js.map} +1 -1
- package/dist/static/assets/{journeyDiagram-XKPGCS4Q-CKN3oSxk.js → journeyDiagram-XKPGCS4Q-Dg_RgtQX.js} +5 -5
- package/dist/static/assets/{journeyDiagram-XKPGCS4Q-CKN3oSxk.js.map → journeyDiagram-XKPGCS4Q-Dg_RgtQX.js.map} +1 -1
- package/dist/static/assets/{kanban-definition-3W4ZIXB7-BQCMklfJ.js → kanban-definition-3W4ZIXB7-DuGS3lId.js} +3 -3
- package/dist/static/assets/{kanban-definition-3W4ZIXB7-BQCMklfJ.js.map → kanban-definition-3W4ZIXB7-DuGS3lId.js.map} +1 -1
- package/dist/static/assets/{layout-C5B58szc.js → layout-FDz2bstZ.js} +5 -5
- package/dist/static/assets/{layout-C5B58szc.js.map → layout-FDz2bstZ.js.map} +1 -1
- package/dist/static/assets/{linear-_32fut6G.js → linear-CzsdvPGb.js} +2 -2
- package/dist/static/assets/{linear-_32fut6G.js.map → linear-CzsdvPGb.js.map} +1 -1
- package/dist/static/assets/{mindmap-definition-VGOIOE7T-C_goMzjx.js → mindmap-definition-VGOIOE7T-WsAF5UNp.js} +4 -4
- package/dist/static/assets/{mindmap-definition-VGOIOE7T-C_goMzjx.js.map → mindmap-definition-VGOIOE7T-WsAF5UNp.js.map} +1 -1
- package/dist/static/assets/{pieDiagram-ADFJNKIX-BQ2n0cOB.js → pieDiagram-ADFJNKIX-DJpRJ5ei.js} +8 -8
- package/dist/static/assets/{pieDiagram-ADFJNKIX-BQ2n0cOB.js.map → pieDiagram-ADFJNKIX-DJpRJ5ei.js.map} +1 -1
- package/dist/static/assets/{quadrantDiagram-AYHSOK5B-BLg7_neg.js → quadrantDiagram-AYHSOK5B-CMyIzTkY.js} +3 -3
- package/dist/static/assets/{quadrantDiagram-AYHSOK5B-BLg7_neg.js.map → quadrantDiagram-AYHSOK5B-CMyIzTkY.js.map} +1 -1
- package/dist/static/assets/{requirementDiagram-UZGBJVZJ-DwkJt0zi.js → requirementDiagram-UZGBJVZJ-D_yqVXGu.js} +4 -4
- package/dist/static/assets/{requirementDiagram-UZGBJVZJ-DwkJt0zi.js.map → requirementDiagram-UZGBJVZJ-D_yqVXGu.js.map} +1 -1
- package/dist/static/assets/{sankeyDiagram-TZEHDZUN-DmxmatUB.js → sankeyDiagram-TZEHDZUN-D4-cF724.js} +2 -2
- package/dist/static/assets/{sankeyDiagram-TZEHDZUN-DmxmatUB.js.map → sankeyDiagram-TZEHDZUN-D4-cF724.js.map} +1 -1
- package/dist/static/assets/{sequenceDiagram-WL72ISMW-KHU_eApU.js → sequenceDiagram-WL72ISMW-B7J3gWYN.js} +4 -4
- package/dist/static/assets/{sequenceDiagram-WL72ISMW-KHU_eApU.js.map → sequenceDiagram-WL72ISMW-B7J3gWYN.js.map} +1 -1
- package/dist/static/assets/{stateDiagram-FKZM4ZOC-B3DBCxAL.js → stateDiagram-FKZM4ZOC-DwEYYCcu.js} +9 -9
- package/dist/static/assets/{stateDiagram-FKZM4ZOC-B3DBCxAL.js.map → stateDiagram-FKZM4ZOC-DwEYYCcu.js.map} +1 -1
- package/dist/static/assets/{stateDiagram-v2-4FDKWEC3-C-uIk7gh.js → stateDiagram-v2-4FDKWEC3-D4LOOQV5.js} +5 -5
- package/dist/static/assets/{stateDiagram-v2-4FDKWEC3-C-uIk7gh.js.map → stateDiagram-v2-4FDKWEC3-D4LOOQV5.js.map} +1 -1
- package/dist/static/assets/{timeline-definition-IT6M3QCI-SysEcQCC.js → timeline-definition-IT6M3QCI-CyG-TJ_A.js} +3 -3
- package/dist/static/assets/{timeline-definition-IT6M3QCI-SysEcQCC.js.map → timeline-definition-IT6M3QCI-CyG-TJ_A.js.map} +1 -1
- package/dist/static/assets/{treemap-GDKQZRPO-d0AbKEc4.js → treemap-GDKQZRPO-yY4GiKmU.js} +5 -5
- package/dist/static/assets/{treemap-GDKQZRPO-d0AbKEc4.js.map → treemap-GDKQZRPO-yY4GiKmU.js.map} +1 -1
- package/dist/static/assets/{xychartDiagram-PRI3JC2R-CmSQMxUh.js → xychartDiagram-PRI3JC2R-5TYN_q15.js} +3 -3
- package/dist/static/assets/{xychartDiagram-PRI3JC2R-CmSQMxUh.js.map → xychartDiagram-PRI3JC2R-5TYN_q15.js.map} +1 -1
- package/dist/static/index.html +1 -1
- package/dist/team.js +33 -4
- package/dist/tools/app-reminders.js +280 -0
- package/dist/tools/prompts/memory/en/errors.md +155 -0
- package/dist/tools/prompts/memory/en/index.md +47 -0
- package/dist/tools/prompts/memory/en/principles.md +79 -0
- package/dist/tools/prompts/memory/en/scenarios.md +174 -0
- package/dist/tools/prompts/memory/en/tools.md +154 -0
- package/dist/tools/prompts/memory/zh/errors.md +155 -0
- package/dist/tools/prompts/memory/zh/index.md +47 -0
- package/dist/tools/prompts/memory/zh/principles.md +79 -0
- package/dist/tools/prompts/memory/zh/scenarios.md +174 -0
- package/dist/tools/prompts/memory/zh/tools.md +154 -0
- package/dist/tools/ripgrep.js +197 -63
- package/package.json +2 -2
- package/dist/static/assets/index-B-8J28g7.js.map +0 -1
|
@@ -9,6 +9,7 @@ const dialog_instance_registry_1 = require("../../dialog-instance-registry");
|
|
|
9
9
|
const log_1 = require("../../log");
|
|
10
10
|
const persistence_1 = require("../../persistence");
|
|
11
11
|
const runtime_language_1 = require("../../shared/runtime-language");
|
|
12
|
+
const storage_1 = require("../../shared/types/storage");
|
|
12
13
|
const inter_dialog_format_1 = require("../../shared/utils/inter-dialog-format");
|
|
13
14
|
const time_1 = require("../../shared/utils/time");
|
|
14
15
|
const pending_tellask_reminder_1 = require("../../tools/pending-tellask-reminder");
|
|
@@ -235,7 +236,14 @@ async function supplyResponseToSupdialog(args) {
|
|
|
235
236
|
(!Array.isArray(mentionList) || mentionList.length < 1)) {
|
|
236
237
|
mentionList = [`@${responderId}`];
|
|
237
238
|
}
|
|
238
|
-
await persistence_1.DialogPersistence.savePendingSubdialogs(parentDialog.id, filteredPending,
|
|
239
|
+
await persistence_1.DialogPersistence.savePendingSubdialogs(parentDialog.id, filteredPending, (0, storage_1.toRootGenerationAnchor)({
|
|
240
|
+
rootCourse: parentDialog instanceof dialog_1.SubDialog
|
|
241
|
+
? parentDialog.rootDialog.currentCourse
|
|
242
|
+
: parentDialog.currentCourse,
|
|
243
|
+
rootGenseq: parentDialog instanceof dialog_1.SubDialog
|
|
244
|
+
? (parentDialog.rootDialog.activeGenSeqOrUndefined ?? 0)
|
|
245
|
+
: (parentDialog.activeGenSeqOrUndefined ?? 0),
|
|
246
|
+
}), parentDialog.status);
|
|
239
247
|
const hasQ4H = await parentDialog.hasPendingQ4H();
|
|
240
248
|
const shouldRevive = !hasQ4H && filteredPending.length === 0;
|
|
241
249
|
if (shouldRevive && parentDialog instanceof dialog_1.RootDialog) {
|
|
@@ -250,12 +258,7 @@ async function supplyResponseToSupdialog(args) {
|
|
|
250
258
|
originMemberId,
|
|
251
259
|
sessionSlug,
|
|
252
260
|
callId: pendingRecord?.callId,
|
|
253
|
-
callingCourse: pendingRecord
|
|
254
|
-
typeof pendingRecord.callingCourse === 'number' &&
|
|
255
|
-
Number.isFinite(pendingRecord.callingCourse) &&
|
|
256
|
-
pendingRecord.callingCourse > 0
|
|
257
|
-
? Math.floor(pendingRecord.callingCourse)
|
|
258
|
-
: undefined,
|
|
261
|
+
callingCourse: pendingRecord?.callingCourse,
|
|
259
262
|
shouldRevive,
|
|
260
263
|
};
|
|
261
264
|
});
|
|
@@ -307,10 +310,14 @@ async function supplyResponseToSupdialog(args) {
|
|
|
307
310
|
anchorRole: 'response',
|
|
308
311
|
callId: resolvedCallId,
|
|
309
312
|
genseq: calleeResponseRef.genseq,
|
|
310
|
-
assignmentCourse: assignmentRef
|
|
311
|
-
assignmentGenseq: assignmentRef
|
|
313
|
+
assignmentCourse: assignmentRef !== undefined ? (0, storage_1.toAssignmentCourseNumber)(assignmentRef.course) : undefined,
|
|
314
|
+
assignmentGenseq: assignmentRef !== undefined
|
|
315
|
+
? (0, storage_1.toAssignmentGenerationSeqNumber)(assignmentRef.genseq)
|
|
316
|
+
: undefined,
|
|
312
317
|
callerDialogId: parentDialog.id.selfId,
|
|
313
|
-
callerCourse: result.callingCourse
|
|
318
|
+
callerCourse: result.callingCourse !== undefined
|
|
319
|
+
? (0, storage_1.toCallerCourseNumber)(result.callingCourse)
|
|
320
|
+
: undefined,
|
|
314
321
|
};
|
|
315
322
|
await persistence_1.DialogPersistence.appendEvent(subdialogId, calleeResponseRef.course, anchorRecord, parentDialog.status);
|
|
316
323
|
}
|
|
@@ -321,8 +328,12 @@ async function supplyResponseToSupdialog(args) {
|
|
|
321
328
|
callId: resolvedCallId,
|
|
322
329
|
originMemberId: requesterId,
|
|
323
330
|
sessionSlug: result.sessionSlug,
|
|
324
|
-
calleeCourse: calleeResponseRef
|
|
325
|
-
|
|
331
|
+
calleeCourse: calleeResponseRef !== undefined
|
|
332
|
+
? (0, storage_1.toCalleeCourseNumber)(calleeResponseRef.course)
|
|
333
|
+
: undefined,
|
|
334
|
+
calleeGenseq: calleeResponseRef !== undefined
|
|
335
|
+
? (0, storage_1.toCalleeGenerationSeqNumber)(calleeResponseRef.genseq)
|
|
336
|
+
: undefined,
|
|
326
337
|
});
|
|
327
338
|
const immediateMirror = {
|
|
328
339
|
type: 'tellask_result_msg',
|
|
@@ -10,6 +10,7 @@ const log_1 = require("../../log");
|
|
|
10
10
|
const persistence_1 = require("../../persistence");
|
|
11
11
|
const driver_messages_1 = require("../../shared/i18n/driver-messages");
|
|
12
12
|
const runtime_language_1 = require("../../shared/runtime-language");
|
|
13
|
+
const storage_1 = require("../../shared/types/storage");
|
|
13
14
|
const fbr_1 = require("../../shared/utils/fbr");
|
|
14
15
|
const id_1 = require("../../shared/utils/id");
|
|
15
16
|
const inter_dialog_format_1 = require("../../shared/utils/inter-dialog-format");
|
|
@@ -439,7 +440,7 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
|
|
|
439
440
|
const subdialogCallName = callName === 'tellaskBack' ? 'freshBootsReasoning' : callName;
|
|
440
441
|
const rawCallingCourse = dlg.activeGenCourseOrUndefined ?? dlg.currentCourse;
|
|
441
442
|
const callingCourse = Number.isFinite(rawCallingCourse) && rawCallingCourse > 0
|
|
442
|
-
?
|
|
443
|
+
? (0, storage_1.toCallingCourseNumber)(rawCallingCourse)
|
|
443
444
|
: undefined;
|
|
444
445
|
const firstMentionForError = options.targetForError ?? parseResult.agentId;
|
|
445
446
|
if (parseResult.type !== 'A' && member === null) {
|
|
@@ -562,7 +563,12 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
|
|
|
562
563
|
callType: 'C',
|
|
563
564
|
};
|
|
564
565
|
await (0, subdialog_txn_1.withSubdialogTxnLock)(dlg.id, async () => {
|
|
565
|
-
await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord)
|
|
566
|
+
await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord, (0, storage_1.toRootGenerationAnchor)({
|
|
567
|
+
rootCourse: dlg instanceof dialog_1.SubDialog ? dlg.rootDialog.currentCourse : dlg.currentCourse,
|
|
568
|
+
rootGenseq: dlg instanceof dialog_1.SubDialog
|
|
569
|
+
? (dlg.rootDialog.activeGenSeqOrUndefined ?? 0)
|
|
570
|
+
: (dlg.activeGenSeqOrUndefined ?? 0),
|
|
571
|
+
}));
|
|
566
572
|
});
|
|
567
573
|
await syncPendingTellaskReminderBestEffort(dlg, 'kernel-driver:executeTellaskCall:FBR-TypeC:appendPending:lastRound');
|
|
568
574
|
}
|
|
@@ -785,7 +791,12 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
|
|
|
785
791
|
sessionSlug: parseResult.sessionSlug,
|
|
786
792
|
};
|
|
787
793
|
await (0, subdialog_txn_1.withSubdialogTxnLock)(dlg.id, async () => {
|
|
788
|
-
await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord)
|
|
794
|
+
await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord, (0, storage_1.toRootGenerationAnchor)({
|
|
795
|
+
rootCourse: dlg instanceof dialog_1.SubDialog ? dlg.rootDialog.currentCourse : dlg.currentCourse,
|
|
796
|
+
rootGenseq: dlg instanceof dialog_1.SubDialog
|
|
797
|
+
? (dlg.rootDialog.activeGenSeqOrUndefined ?? 0)
|
|
798
|
+
: (dlg.activeGenSeqOrUndefined ?? 0),
|
|
799
|
+
}));
|
|
789
800
|
});
|
|
790
801
|
await syncPendingTellaskReminderBestEffort(dlg, 'kernel-driver:executeTellaskCall:TypeB-fallback:appendPending');
|
|
791
802
|
const initPrompt = {
|
|
@@ -962,7 +973,12 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
|
|
|
962
973
|
callType: 'C',
|
|
963
974
|
};
|
|
964
975
|
await (0, subdialog_txn_1.withSubdialogTxnLock)(dlg.id, async () => {
|
|
965
|
-
await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord)
|
|
976
|
+
await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord, (0, storage_1.toRootGenerationAnchor)({
|
|
977
|
+
rootCourse: dlg instanceof dialog_1.SubDialog ? dlg.rootDialog.currentCourse : dlg.currentCourse,
|
|
978
|
+
rootGenseq: dlg instanceof dialog_1.SubDialog
|
|
979
|
+
? (dlg.rootDialog.activeGenSeqOrUndefined ?? 0)
|
|
980
|
+
: (dlg.activeGenSeqOrUndefined ?? 0),
|
|
981
|
+
}));
|
|
966
982
|
});
|
|
967
983
|
await syncPendingTellaskReminderBestEffort(dlg, 'kernel-driver:executeTellaskCall:TypeC:appendPending');
|
|
968
984
|
const initPrompt = {
|
package/dist/minds/load.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.loadAgentMinds = loadAgentMinds;
|
|
7
7
|
const promises_1 = require("fs/promises");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const runtime_1 = require("../apps/runtime");
|
|
9
10
|
const dialog_1 = require("../dialog");
|
|
10
11
|
const log_1 = require("../log");
|
|
11
12
|
const runtime_language_1 = require("../shared/runtime-language");
|
|
@@ -106,6 +107,12 @@ async function readMindsTextPreferred(options) {
|
|
|
106
107
|
async function loadAgentMinds(agentId, dialog, options) {
|
|
107
108
|
const workingLanguage = (0, runtime_language_1.getWorkLanguage)();
|
|
108
109
|
const missingToolsetPolicy = options?.missingToolsetPolicy ?? 'warn';
|
|
110
|
+
try {
|
|
111
|
+
await (0, runtime_1.registerEnabledAppsToolProxies)({ rtwsRootAbs: process.cwd() });
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
log_1.log.warn(`Failed to refresh enabled app tool proxies before loading agent minds: ${error instanceof Error ? error.message : String(error)}`);
|
|
115
|
+
}
|
|
109
116
|
let team = await team_1.Team.load();
|
|
110
117
|
const agent = agentId === undefined ? team.getDefaultResponder() : team.getMember(agentId);
|
|
111
118
|
if (!agent)
|
package/dist/persistence.js
CHANGED
|
@@ -48,6 +48,7 @@ const dialog_1 = require("./dialog");
|
|
|
48
48
|
const evt_registry_1 = require("./evt-registry");
|
|
49
49
|
const log_1 = require("./log");
|
|
50
50
|
const async_fifo_mutex_1 = require("./shared/async-fifo-mutex");
|
|
51
|
+
const storage_1 = require("./shared/types/storage");
|
|
51
52
|
const time_1 = require("./shared/utils/time");
|
|
52
53
|
const registry_1 = require("./tools/registry");
|
|
53
54
|
function getErrorCode(error) {
|
|
@@ -59,6 +60,67 @@ function getErrorCode(error) {
|
|
|
59
60
|
function isRecord(value) {
|
|
60
61
|
return typeof value === 'object' && value !== null;
|
|
61
62
|
}
|
|
63
|
+
function serializeReminderSnapshot(reminder) {
|
|
64
|
+
const persistedReminder = reminder;
|
|
65
|
+
return {
|
|
66
|
+
content: reminder.content,
|
|
67
|
+
ownerName: reminder.owner?.name,
|
|
68
|
+
meta: reminder.meta,
|
|
69
|
+
echoback: reminder.echoback,
|
|
70
|
+
createdAt: persistedReminder.createdAt ?? (0, time_1.formatUnifiedTimestamp)(new Date()),
|
|
71
|
+
priority: persistedReminder.priority ?? 'medium',
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function cloneReminderSnapshot(snapshot) {
|
|
75
|
+
return {
|
|
76
|
+
content: snapshot.content,
|
|
77
|
+
ownerName: snapshot.ownerName,
|
|
78
|
+
meta: snapshot.meta,
|
|
79
|
+
echoback: snapshot.echoback,
|
|
80
|
+
createdAt: snapshot.createdAt,
|
|
81
|
+
priority: snapshot.priority,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function cloneRootGenerationAnchor(anchor) {
|
|
85
|
+
return {
|
|
86
|
+
rootCourse: anchor.rootCourse,
|
|
87
|
+
rootGenseq: anchor.rootGenseq,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function resolveRootGenerationAnchor(dialog) {
|
|
91
|
+
const rootDialog = dialog instanceof dialog_1.SubDialog ? dialog.rootDialog : dialog;
|
|
92
|
+
return (0, storage_1.toRootGenerationAnchor)({
|
|
93
|
+
rootCourse: rootDialog.currentCourse,
|
|
94
|
+
rootGenseq: rootDialog.activeGenSeqOrUndefined ?? 0,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function resolveReconciledRecordWriteTarget(dialog) {
|
|
98
|
+
return {
|
|
99
|
+
kind: 'dialog_course',
|
|
100
|
+
rootAnchor: resolveRootGenerationAnchor(dialog),
|
|
101
|
+
dialogCourse: (0, storage_1.toDialogCourseNumber)(dialog.activeGenCourseOrUndefined ?? dialog.currentCourse),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function rootAnchorWriteTarget(rootAnchor) {
|
|
105
|
+
return {
|
|
106
|
+
kind: 'root_anchor',
|
|
107
|
+
rootAnchor,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function resolveTargetCourseFromWriteTarget(writeTarget) {
|
|
111
|
+
if (writeTarget.kind === 'dialog_course') {
|
|
112
|
+
return writeTarget.dialogCourse;
|
|
113
|
+
}
|
|
114
|
+
return writeTarget.rootAnchor.rootCourse;
|
|
115
|
+
}
|
|
116
|
+
function attachRootGenerationRef(dialog, record) {
|
|
117
|
+
const anchor = resolveRootGenerationAnchor(dialog);
|
|
118
|
+
return {
|
|
119
|
+
...record,
|
|
120
|
+
rootCourse: anchor.rootCourse,
|
|
121
|
+
rootGenseq: anchor.rootGenseq,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
62
124
|
function isRootDialogMetadataFile(value) {
|
|
63
125
|
if (!isRecord(value))
|
|
64
126
|
return false;
|
|
@@ -459,6 +521,29 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
459
521
|
};
|
|
460
522
|
await DialogPersistence.saveSubdialogMetadata(subdialogId, metadata);
|
|
461
523
|
await DialogPersistence.saveDialogMetadata(subdialogId, metadata);
|
|
524
|
+
const rootAnchor = resolveRootGenerationAnchor(supdialog);
|
|
525
|
+
const parentCourse = supdialog.activeGenCourseOrUndefined ?? supdialog.currentCourse;
|
|
526
|
+
const subdialogCreatedRecord = {
|
|
527
|
+
ts: nowTs,
|
|
528
|
+
type: 'subdialog_created_record',
|
|
529
|
+
...cloneRootGenerationAnchor(rootAnchor),
|
|
530
|
+
subdialogId: subdialogId.selfId,
|
|
531
|
+
supdialogId: supdialog.id.selfId,
|
|
532
|
+
agentId: targetAgentId,
|
|
533
|
+
taskDocPath: supdialog.taskDocPath,
|
|
534
|
+
createdAt: nowTs,
|
|
535
|
+
sessionSlug: options.sessionSlug,
|
|
536
|
+
assignmentFromSup: {
|
|
537
|
+
callName: options.callName,
|
|
538
|
+
mentionList,
|
|
539
|
+
tellaskContent,
|
|
540
|
+
originMemberId: options.originMemberId,
|
|
541
|
+
callerDialogId: options.callerDialogId,
|
|
542
|
+
callId: options.callId,
|
|
543
|
+
collectiveTargets: options.collectiveTargets,
|
|
544
|
+
},
|
|
545
|
+
};
|
|
546
|
+
await this.appendEvent(supdialog, parentCourse, subdialogCreatedRecord);
|
|
462
547
|
// Initialize latest.yaml via the mutation API (write-back will flush).
|
|
463
548
|
await DialogPersistence.mutateDialogLatest(subdialogId, () => ({
|
|
464
549
|
kind: 'replace',
|
|
@@ -474,7 +559,6 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
474
559
|
},
|
|
475
560
|
}));
|
|
476
561
|
// Supdialog clarification context is persisted in subdialog metadata (supdialogCall)
|
|
477
|
-
const parentCourse = await DialogPersistence.getCurrentCourseNumber(supdialog.id);
|
|
478
562
|
const subdialogCreatedEvt = {
|
|
479
563
|
type: 'subdialog_created_evt',
|
|
480
564
|
dialog: {
|
|
@@ -537,7 +621,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
537
621
|
contentItems: funcResult.contentItems,
|
|
538
622
|
genseq: dialog.activeGenSeq,
|
|
539
623
|
};
|
|
540
|
-
await this.appendEvent(course, funcResultRecord);
|
|
624
|
+
await this.appendEvent(dialog, course, funcResultRecord);
|
|
541
625
|
// Send event to frontend
|
|
542
626
|
const funcResultEvt = {
|
|
543
627
|
type: 'func_result_evt',
|
|
@@ -573,7 +657,9 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
573
657
|
*/
|
|
574
658
|
async receiveTeammateCallResult(dialog, responderId, callName, mentionList, tellaskContent, result, status, callId) {
|
|
575
659
|
const course = dialog.activeGenCourseOrUndefined ?? dialog.currentCourse;
|
|
576
|
-
const calling_genseq = dialog.activeGenSeqOrUndefined
|
|
660
|
+
const calling_genseq = dialog.activeGenSeqOrUndefined !== undefined
|
|
661
|
+
? (0, storage_1.toCallingGenerationSeqNumber)(dialog.activeGenSeqOrUndefined)
|
|
662
|
+
: undefined;
|
|
577
663
|
// Persist record WITH callId for replay correlation
|
|
578
664
|
const ev = (() => {
|
|
579
665
|
switch (callName) {
|
|
@@ -607,7 +693,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
607
693
|
};
|
|
608
694
|
}
|
|
609
695
|
})();
|
|
610
|
-
await this.appendEvent(course, ev);
|
|
696
|
+
await this.appendEvent(dialog, course, ev);
|
|
611
697
|
// Emit TeammateCallResponseEvent WITH callId for UI correlation
|
|
612
698
|
const toolResponseEvt = (() => {
|
|
613
699
|
switch (callName) {
|
|
@@ -661,7 +747,9 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
661
747
|
*/
|
|
662
748
|
async receiveTeammateResponse(dialog, responderId, callName, mentionList, tellaskContent, status, calleeDialogId, options) {
|
|
663
749
|
const course = dialog.activeGenCourseOrUndefined ?? dialog.currentCourse;
|
|
664
|
-
const calling_genseq = dialog.activeGenSeqOrUndefined
|
|
750
|
+
const calling_genseq = dialog.activeGenSeqOrUndefined !== undefined
|
|
751
|
+
? (0, storage_1.toCallingGenerationSeqNumber)(dialog.activeGenSeqOrUndefined)
|
|
752
|
+
: undefined;
|
|
665
753
|
const calleeDialogSelfId = calleeDialogId ? calleeDialogId.selfId : undefined;
|
|
666
754
|
const response = options.response;
|
|
667
755
|
const agentId = options.agentId;
|
|
@@ -736,7 +824,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
736
824
|
};
|
|
737
825
|
}
|
|
738
826
|
})();
|
|
739
|
-
await this.appendEvent(course, ev);
|
|
827
|
+
await this.appendEvent(dialog, course, ev);
|
|
740
828
|
const teammateResponseEvt = (() => {
|
|
741
829
|
switch (callName) {
|
|
742
830
|
case 'tellask':
|
|
@@ -811,8 +899,8 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
811
899
|
/**
|
|
812
900
|
* Append event to course JSONL file (delegate to DialogPersistence)
|
|
813
901
|
*/
|
|
814
|
-
async appendEvent(course, event) {
|
|
815
|
-
await DialogPersistence.appendEvent(this.dialogId, course, event);
|
|
902
|
+
async appendEvent(dialog, course, event) {
|
|
903
|
+
await DialogPersistence.appendEvent(this.dialogId, course, attachRootGenerationRef(dialog, event));
|
|
816
904
|
}
|
|
817
905
|
/**
|
|
818
906
|
* Notify start of LLM generation for frontend bubble management
|
|
@@ -828,7 +916,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
828
916
|
type: 'gen_start_record',
|
|
829
917
|
genseq: genseq,
|
|
830
918
|
};
|
|
831
|
-
await this.appendEvent(course, ev);
|
|
919
|
+
await this.appendEvent(dialog, course, ev);
|
|
832
920
|
// Emit generating_start_evt event
|
|
833
921
|
// This event MUST be emitted and processed before any substream events
|
|
834
922
|
// to ensure the frontend has created the generation bubble before receiving
|
|
@@ -867,7 +955,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
867
955
|
contextHealth,
|
|
868
956
|
llmGenModel,
|
|
869
957
|
};
|
|
870
|
-
await this.appendEvent(course, ev);
|
|
958
|
+
await this.appendEvent(dialog, course, ev);
|
|
871
959
|
// Emit generating_finish_evt event (this was missing, causing double triggering issue)
|
|
872
960
|
const genFinishEvt = {
|
|
873
961
|
type: 'generating_finish_evt',
|
|
@@ -929,7 +1017,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
929
1017
|
genseq: dialog.activeGenSeq,
|
|
930
1018
|
content: sayingContent,
|
|
931
1019
|
};
|
|
932
|
-
await this.appendEvent(course, sayingMessageEvent);
|
|
1020
|
+
await this.appendEvent(dialog, course, sayingMessageEvent);
|
|
933
1021
|
}
|
|
934
1022
|
const evt = {
|
|
935
1023
|
type: 'markdown_finish_evt',
|
|
@@ -976,7 +1064,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
976
1064
|
content: thinkingContent,
|
|
977
1065
|
reasoning: this.thinkingReasoning,
|
|
978
1066
|
};
|
|
979
|
-
await this.appendEvent(course, thinkingMessageEvent);
|
|
1067
|
+
await this.appendEvent(dialog, course, thinkingMessageEvent);
|
|
980
1068
|
}
|
|
981
1069
|
const thinkingFinishEvt = {
|
|
982
1070
|
type: 'thinking_finish_evt',
|
|
@@ -1086,7 +1174,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
1086
1174
|
status: payload.status,
|
|
1087
1175
|
action: payload.action,
|
|
1088
1176
|
};
|
|
1089
|
-
await this.appendEvent(course, record);
|
|
1177
|
+
await this.appendEvent(dialog, course, record);
|
|
1090
1178
|
const evt = {
|
|
1091
1179
|
type: 'web_search_call_evt',
|
|
1092
1180
|
course,
|
|
@@ -1142,6 +1230,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
1142
1230
|
*/
|
|
1143
1231
|
async persistReminders(dialog, reminders) {
|
|
1144
1232
|
await DialogPersistence._saveReminderState(this.dialogId, reminders);
|
|
1233
|
+
await DialogPersistence.appendRemindersReconciledRecord(this.dialogId, reminders, resolveReconciledRecordWriteTarget(dialog), dialog.status);
|
|
1145
1234
|
}
|
|
1146
1235
|
/**
|
|
1147
1236
|
* Persist a user message to storage
|
|
@@ -1178,7 +1267,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
1178
1267
|
userLanguageCode,
|
|
1179
1268
|
q4hAnswerCallIds: normalizedQ4HAnswerCallIds,
|
|
1180
1269
|
};
|
|
1181
|
-
await this.appendEvent(course, humanEv);
|
|
1270
|
+
await this.appendEvent(dialog, course, humanEv);
|
|
1182
1271
|
// Note: end_of_user_saying_evt is now emitted by llm/driver.ts after tellask calls complete
|
|
1183
1272
|
}
|
|
1184
1273
|
/**
|
|
@@ -1201,7 +1290,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
1201
1290
|
genseq,
|
|
1202
1291
|
content: content || '',
|
|
1203
1292
|
};
|
|
1204
|
-
await this.appendEvent(course, event);
|
|
1293
|
+
await this.appendEvent(dialog, course, event);
|
|
1205
1294
|
}
|
|
1206
1295
|
async persistUiOnlyMarkdown(dialog, content, genseq) {
|
|
1207
1296
|
const course = dialog.activeGenCourseOrUndefined ?? dialog.currentCourse;
|
|
@@ -1211,7 +1300,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
1211
1300
|
genseq,
|
|
1212
1301
|
content: content || '',
|
|
1213
1302
|
};
|
|
1214
|
-
await this.appendEvent(course, ev);
|
|
1303
|
+
await this.appendEvent(dialog, course, ev);
|
|
1215
1304
|
}
|
|
1216
1305
|
/**
|
|
1217
1306
|
* Persist a function call to storage
|
|
@@ -1226,7 +1315,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
1226
1315
|
name,
|
|
1227
1316
|
arguments: arguments_,
|
|
1228
1317
|
};
|
|
1229
|
-
await this.appendEvent(course, funcCallEvent);
|
|
1318
|
+
await this.appendEvent(dialog, course, funcCallEvent);
|
|
1230
1319
|
// NOTE: func_call_evt REMOVED - persistence uses FuncCallRecord directly
|
|
1231
1320
|
// UI display uses func_call_requested_evt instead
|
|
1232
1321
|
}
|
|
@@ -1235,6 +1324,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
1235
1324
|
*/
|
|
1236
1325
|
async updateQuestions4Human(dialog, questions) {
|
|
1237
1326
|
await DialogPersistence._saveQuestions4HumanState(this.dialogId, questions);
|
|
1327
|
+
await DialogPersistence.appendQuestions4HumanReconciledRecord(this.dialogId, questions, resolveReconciledRecordWriteTarget(dialog), dialog.status);
|
|
1238
1328
|
}
|
|
1239
1329
|
/**
|
|
1240
1330
|
* Load Questions for Human state from storage
|
|
@@ -1259,8 +1349,14 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
1259
1349
|
sessionSlug: record.sessionSlug,
|
|
1260
1350
|
}));
|
|
1261
1351
|
}
|
|
1262
|
-
async saveSubdialogRegistry(rootDialogId, entries, status) {
|
|
1352
|
+
async saveSubdialogRegistry(dialog, rootDialogId, entries, status) {
|
|
1263
1353
|
await DialogPersistence.saveSubdialogRegistry(rootDialogId, entries, status);
|
|
1354
|
+
await DialogPersistence.appendSubdialogRegistryReconciledRecord(rootDialogId, entries.map((entry) => ({
|
|
1355
|
+
key: entry.key,
|
|
1356
|
+
subdialogId: entry.subdialogId.selfId,
|
|
1357
|
+
agentId: entry.agentId,
|
|
1358
|
+
sessionSlug: entry.sessionSlug,
|
|
1359
|
+
})), resolveReconciledRecordWriteTarget(dialog), status);
|
|
1264
1360
|
}
|
|
1265
1361
|
async loadSubdialogRegistry(rootDialog, status) {
|
|
1266
1362
|
const entries = await DialogPersistence.loadSubdialogRegistry(rootDialog.id, status);
|
|
@@ -1405,6 +1501,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
1405
1501
|
const previousCount = previousQuestions.length;
|
|
1406
1502
|
if (previousCount > 0) {
|
|
1407
1503
|
await DialogPersistence.clearQuestions4HumanState(dialog.id);
|
|
1504
|
+
await DialogPersistence.appendQuestions4HumanReconciledRecord(dialog.id, [], resolveReconciledRecordWriteTarget(dialog), dialog.status);
|
|
1408
1505
|
// Emit q4h_answered events for each removed question
|
|
1409
1506
|
for (const q of previousQuestions) {
|
|
1410
1507
|
const answeredEvent = {
|
|
@@ -1961,6 +2058,13 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
|
|
|
1961
2058
|
}
|
|
1962
2059
|
break;
|
|
1963
2060
|
}
|
|
2061
|
+
case 'subdialog_created_record':
|
|
2062
|
+
case 'reminders_reconciled_record':
|
|
2063
|
+
case 'questions4human_reconciled_record':
|
|
2064
|
+
case 'pending_subdialogs_reconciled_record':
|
|
2065
|
+
case 'subdialog_registry_reconciled_record':
|
|
2066
|
+
case 'subdialog_responses_reconciled_record':
|
|
2067
|
+
break;
|
|
1964
2068
|
case 'teammate_response_record': {
|
|
1965
2069
|
// Handle teammate response events (separate bubble for @teammate tellasks)
|
|
1966
2070
|
const mentionList = (() => {
|
|
@@ -2134,6 +2238,75 @@ class DialogPersistence {
|
|
|
2134
2238
|
static getPendingSubdialogsWriteBackKey(rootDialogId, status) {
|
|
2135
2239
|
return `${this.getDialogsRootDir()}|${status}|${rootDialogId.valueOf()}|pending-subdialogs`;
|
|
2136
2240
|
}
|
|
2241
|
+
static clonePendingSubdialogRecords(records) {
|
|
2242
|
+
return records.map((record) => ({
|
|
2243
|
+
...record,
|
|
2244
|
+
mentionList: record.mentionList ? [...record.mentionList] : undefined,
|
|
2245
|
+
}));
|
|
2246
|
+
}
|
|
2247
|
+
static cloneQuestions4Human(questions) {
|
|
2248
|
+
return questions.map((question) => ({
|
|
2249
|
+
...question,
|
|
2250
|
+
remainingCallIds: question.remainingCallIds ? [...question.remainingCallIds] : undefined,
|
|
2251
|
+
callSiteRef: { ...question.callSiteRef },
|
|
2252
|
+
}));
|
|
2253
|
+
}
|
|
2254
|
+
static cloneRegistryEntries(entries) {
|
|
2255
|
+
return entries.map((entry) => ({
|
|
2256
|
+
...entry,
|
|
2257
|
+
}));
|
|
2258
|
+
}
|
|
2259
|
+
static cloneSubdialogResponses(responses) {
|
|
2260
|
+
return responses.map((response) => ({
|
|
2261
|
+
...response,
|
|
2262
|
+
mentionList: response.mentionList ? [...response.mentionList] : undefined,
|
|
2263
|
+
}));
|
|
2264
|
+
}
|
|
2265
|
+
static async appendRemindersReconciledRecord(dialogId, reminders, writeTarget, status) {
|
|
2266
|
+
const record = {
|
|
2267
|
+
ts: (0, time_1.formatUnifiedTimestamp)(new Date()),
|
|
2268
|
+
type: 'reminders_reconciled_record',
|
|
2269
|
+
...cloneRootGenerationAnchor(writeTarget.rootAnchor),
|
|
2270
|
+
reminders: reminders.map((reminder) => serializeReminderSnapshot(reminder)),
|
|
2271
|
+
};
|
|
2272
|
+
await this.appendEvent(dialogId, resolveTargetCourseFromWriteTarget(writeTarget), record, status);
|
|
2273
|
+
}
|
|
2274
|
+
static async appendQuestions4HumanReconciledRecord(dialogId, questions, writeTarget, status) {
|
|
2275
|
+
const record = {
|
|
2276
|
+
ts: (0, time_1.formatUnifiedTimestamp)(new Date()),
|
|
2277
|
+
type: 'questions4human_reconciled_record',
|
|
2278
|
+
...cloneRootGenerationAnchor(writeTarget.rootAnchor),
|
|
2279
|
+
questions: this.cloneQuestions4Human(questions),
|
|
2280
|
+
};
|
|
2281
|
+
await this.appendEvent(dialogId, resolveTargetCourseFromWriteTarget(writeTarget), record, status);
|
|
2282
|
+
}
|
|
2283
|
+
static async appendPendingSubdialogsReconciledRecord(dialogId, pendingSubdialogs, writeTarget, status) {
|
|
2284
|
+
const record = {
|
|
2285
|
+
ts: (0, time_1.formatUnifiedTimestamp)(new Date()),
|
|
2286
|
+
type: 'pending_subdialogs_reconciled_record',
|
|
2287
|
+
...cloneRootGenerationAnchor(writeTarget.rootAnchor),
|
|
2288
|
+
pendingSubdialogs: this.clonePendingSubdialogRecords(pendingSubdialogs),
|
|
2289
|
+
};
|
|
2290
|
+
await this.appendEvent(dialogId, resolveTargetCourseFromWriteTarget(writeTarget), record, status);
|
|
2291
|
+
}
|
|
2292
|
+
static async appendSubdialogRegistryReconciledRecord(dialogId, entries, writeTarget, status) {
|
|
2293
|
+
const record = {
|
|
2294
|
+
ts: (0, time_1.formatUnifiedTimestamp)(new Date()),
|
|
2295
|
+
type: 'subdialog_registry_reconciled_record',
|
|
2296
|
+
...cloneRootGenerationAnchor(writeTarget.rootAnchor),
|
|
2297
|
+
entries: this.cloneRegistryEntries(entries),
|
|
2298
|
+
};
|
|
2299
|
+
await this.appendEvent(dialogId, resolveTargetCourseFromWriteTarget(writeTarget), record, status);
|
|
2300
|
+
}
|
|
2301
|
+
static async appendSubdialogResponsesReconciledRecord(dialogId, responses, writeTarget, status) {
|
|
2302
|
+
const record = {
|
|
2303
|
+
ts: (0, time_1.formatUnifiedTimestamp)(new Date()),
|
|
2304
|
+
type: 'subdialog_responses_reconciled_record',
|
|
2305
|
+
...cloneRootGenerationAnchor(writeTarget.rootAnchor),
|
|
2306
|
+
responses: this.cloneSubdialogResponses(responses),
|
|
2307
|
+
};
|
|
2308
|
+
await this.appendEvent(dialogId, resolveTargetCourseFromWriteTarget(writeTarget), record, status);
|
|
2309
|
+
}
|
|
2137
2310
|
/**
|
|
2138
2311
|
* Get the base dialogs directory path
|
|
2139
2312
|
*/
|
|
@@ -3091,9 +3264,9 @@ class DialogPersistence {
|
|
|
3091
3264
|
* Save pending subdialogs for Type A supply mechanism.
|
|
3092
3265
|
* Tracks subdialogs that were created but not yet completed.
|
|
3093
3266
|
*/
|
|
3094
|
-
static async savePendingSubdialogs(rootDialogId, pendingSubdialogs, status = 'running') {
|
|
3267
|
+
static async savePendingSubdialogs(rootDialogId, pendingSubdialogs, rootAnchor, status = 'running') {
|
|
3095
3268
|
const next = pendingSubdialogs.map((r) => ({ ...r }));
|
|
3096
|
-
await this.mutatePendingSubdialogs(rootDialogId, () => ({ kind: 'replace', records: next }), status);
|
|
3269
|
+
await this.mutatePendingSubdialogs(rootDialogId, () => ({ kind: 'replace', records: next }), rootAnchor, status);
|
|
3097
3270
|
}
|
|
3098
3271
|
/**
|
|
3099
3272
|
* Load pending subdialogs for Type A supply mechanism.
|
|
@@ -3181,7 +3354,7 @@ class DialogPersistence {
|
|
|
3181
3354
|
throw error;
|
|
3182
3355
|
}
|
|
3183
3356
|
}
|
|
3184
|
-
static async mutatePendingSubdialogs(rootDialogId, mutator, status = 'running') {
|
|
3357
|
+
static async mutatePendingSubdialogs(rootDialogId, mutator, rootAnchor, status = 'running') {
|
|
3185
3358
|
const key = this.getPendingSubdialogsWriteBackKey(rootDialogId, status);
|
|
3186
3359
|
const mutex = this.getPendingSubdialogsWriteBackMutex(key);
|
|
3187
3360
|
const release = await mutex.acquire();
|
|
@@ -3246,20 +3419,23 @@ class DialogPersistence {
|
|
|
3246
3419
|
if (pending.kind === 'flushing')
|
|
3247
3420
|
pending.dirty = true;
|
|
3248
3421
|
}
|
|
3422
|
+
if (rootAnchor) {
|
|
3423
|
+
await this.appendPendingSubdialogsReconciledRecord(rootDialogId, nextRecords, rootAnchorWriteTarget(rootAnchor), status);
|
|
3424
|
+
}
|
|
3249
3425
|
return { previousRecords, records: nextRecords, removedRecords };
|
|
3250
3426
|
}
|
|
3251
3427
|
finally {
|
|
3252
3428
|
release();
|
|
3253
3429
|
}
|
|
3254
3430
|
}
|
|
3255
|
-
static async appendPendingSubdialog(rootDialogId, record, status = 'running') {
|
|
3256
|
-
await this.mutatePendingSubdialogs(rootDialogId, () => ({ kind: 'append', record }), status);
|
|
3431
|
+
static async appendPendingSubdialog(rootDialogId, record, rootAnchor, status = 'running') {
|
|
3432
|
+
await this.mutatePendingSubdialogs(rootDialogId, () => ({ kind: 'append', record }), rootAnchor, status);
|
|
3257
3433
|
}
|
|
3258
|
-
static async removePendingSubdialog(rootDialogId, subdialogId, status = 'running') {
|
|
3259
|
-
await this.mutatePendingSubdialogs(rootDialogId, () => ({ kind: 'removeBySubdialogId', subdialogId }), status);
|
|
3434
|
+
static async removePendingSubdialog(rootDialogId, subdialogId, rootAnchor, status = 'running') {
|
|
3435
|
+
await this.mutatePendingSubdialogs(rootDialogId, () => ({ kind: 'removeBySubdialogId', subdialogId }), rootAnchor, status);
|
|
3260
3436
|
}
|
|
3261
|
-
static async clearPendingSubdialogs(rootDialogId, status = 'running') {
|
|
3262
|
-
await this.mutatePendingSubdialogs(rootDialogId, () => ({ kind: 'clear' }), status);
|
|
3437
|
+
static async clearPendingSubdialogs(rootDialogId, rootAnchor, status = 'running') {
|
|
3438
|
+
await this.mutatePendingSubdialogs(rootDialogId, () => ({ kind: 'clear' }), rootAnchor, status);
|
|
3263
3439
|
}
|
|
3264
3440
|
static async flushPendingSubdialogsWriteBack(key) {
|
|
3265
3441
|
const mutex = this.getPendingSubdialogsWriteBackMutex(key);
|
|
@@ -3388,7 +3564,7 @@ class DialogPersistence {
|
|
|
3388
3564
|
* Save subdialog responses for Type A supply mechanism.
|
|
3389
3565
|
* Tracks responses from completed subdialogs.
|
|
3390
3566
|
*/
|
|
3391
|
-
static async saveSubdialogResponses(rootDialogId, responses, status = 'running') {
|
|
3567
|
+
static async saveSubdialogResponses(rootDialogId, responses, rootAnchor, status = 'running') {
|
|
3392
3568
|
try {
|
|
3393
3569
|
const dialogPath = this.getDialogResponsesPath(rootDialogId, status);
|
|
3394
3570
|
await fs.promises.mkdir(dialogPath, { recursive: true });
|
|
@@ -3398,6 +3574,9 @@ class DialogPersistence {
|
|
|
3398
3574
|
const tempFile = path.join(dialogPath, `.${path.basename(filePath)}.${process.pid}.${(0, node_crypto_1.randomUUID)()}.tmp`);
|
|
3399
3575
|
await fs.promises.writeFile(tempFile, jsonContent, 'utf-8');
|
|
3400
3576
|
await this.renameWithRetry(tempFile, filePath, jsonContent);
|
|
3577
|
+
if (rootAnchor) {
|
|
3578
|
+
await this.appendSubdialogResponsesReconciledRecord(rootDialogId, responses, rootAnchorWriteTarget(rootAnchor), status);
|
|
3579
|
+
}
|
|
3401
3580
|
}
|
|
3402
3581
|
catch (error) {
|
|
3403
3582
|
log_1.log.error(`Failed to save subdialog responses for dialog ${rootDialogId}:`, error);
|
|
@@ -3471,10 +3650,10 @@ class DialogPersistence {
|
|
|
3471
3650
|
throw error;
|
|
3472
3651
|
}
|
|
3473
3652
|
}
|
|
3474
|
-
static async appendSubdialogResponse(dialogId, response, status = 'running') {
|
|
3653
|
+
static async appendSubdialogResponse(dialogId, response, rootAnchor, status = 'running') {
|
|
3475
3654
|
const existing = await this.loadSubdialogResponsesQueue(dialogId, status);
|
|
3476
3655
|
existing.push(response);
|
|
3477
|
-
await this.saveSubdialogResponses(dialogId, existing, status);
|
|
3656
|
+
await this.saveSubdialogResponses(dialogId, existing, rootAnchor, status);
|
|
3478
3657
|
}
|
|
3479
3658
|
static async takeSubdialogResponses(dialogId, status = 'running') {
|
|
3480
3659
|
const dialogPath = this.getDialogResponsesPath(dialogId, status);
|
|
@@ -4240,6 +4419,13 @@ class DialogPersistence {
|
|
|
4240
4419
|
// This record is UI navigation metadata for deep links in callee dialogs.
|
|
4241
4420
|
// It does not contribute to model context or chat transcript reconstruction.
|
|
4242
4421
|
break;
|
|
4422
|
+
case 'subdialog_created_record':
|
|
4423
|
+
case 'reminders_reconciled_record':
|
|
4424
|
+
case 'questions4human_reconciled_record':
|
|
4425
|
+
case 'pending_subdialogs_reconciled_record':
|
|
4426
|
+
case 'subdialog_registry_reconciled_record':
|
|
4427
|
+
case 'subdialog_responses_reconciled_record':
|
|
4428
|
+
break;
|
|
4243
4429
|
default:
|
|
4244
4430
|
log_1.log.warn(`Unknown event type in rebuildFromEvents`, undefined, { event });
|
|
4245
4431
|
break;
|