@covro/covro 0.9.0-beta.1 → 0.9.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/README.md +11 -11
- package/README.zh-CN.md +11 -11
- package/dist/backups/manager.js +21 -1
- package/dist/backups/manager.js.map +2 -2
- package/dist/cli/backup.js +33 -2
- package/dist/cli/backup.js.map +2 -2
- package/dist/cli/daemon.js +84 -18
- package/dist/cli/daemon.js.map +2 -2
- package/dist/cli/logs.js +141 -0
- package/dist/cli/logs.js.map +7 -0
- package/dist/cli/main.js +33 -10
- package/dist/cli/main.js.map +2 -2
- package/dist/cli/paths.js +9 -1
- package/dist/cli/paths.js.map +2 -2
- package/dist/codex/adapter.js +142 -37
- package/dist/codex/adapter.js.map +3 -3
- package/dist/codex/mapping.js +1 -0
- package/dist/codex/mapping.js.map +2 -2
- package/dist/codex/permissions.js.map +1 -1
- package/dist/codex/thread-titles.js +143 -21
- package/dist/codex/thread-titles.js.map +2 -2
- package/dist/codex/transport.js +32 -2
- package/dist/codex/transport.js.map +2 -2
- package/dist/drizzle/0008_pending_user_messages.sql +12 -0
- package/dist/drizzle/0009_question_tracking.sql +15 -0
- package/dist/drizzle/meta/0008_snapshot.json +606 -0
- package/dist/drizzle/meta/0009_snapshot.json +698 -0
- package/dist/drizzle/meta/_journal.json +14 -0
- package/dist/logging/bootstrap.js +25 -0
- package/dist/logging/bootstrap.js.map +7 -0
- package/dist/logging/config.js +38 -0
- package/dist/logging/config.js.map +7 -0
- package/dist/logging/context.js +11 -0
- package/dist/logging/context.js.map +7 -0
- package/dist/logging/fields.js +82 -0
- package/dist/logging/fields.js.map +7 -0
- package/dist/logging/lifecycle.js +14 -0
- package/dist/logging/lifecycle.js.map +7 -0
- package/dist/logging/logger.js +216 -0
- package/dist/logging/logger.js.map +7 -0
- package/dist/logging/retention.js +62 -0
- package/dist/logging/retention.js.map +7 -0
- package/dist/server/capacity-retry.js +26 -1
- package/dist/server/capacity-retry.js.map +2 -2
- package/dist/server/db/operations.js +96 -9
- package/dist/server/db/operations.js.map +3 -3
- package/dist/server/db/question-tracking.js +109 -0
- package/dist/server/db/question-tracking.js.map +7 -0
- package/dist/server/db/schema.js +41 -0
- package/dist/server/db/schema.js.map +2 -2
- package/dist/server/file-references.js +66 -0
- package/dist/server/file-references.js.map +7 -0
- package/dist/server/http.js +57 -2
- package/dist/server/http.js.map +3 -3
- package/dist/server/main.js +57 -10
- package/dist/server/main.js.map +2 -2
- package/dist/server/mcp/server.js +17 -3
- package/dist/server/mcp/server.js.map +2 -2
- package/dist/server/project-clones.js +19 -1
- package/dist/server/project-clones.js.map +2 -2
- package/dist/server/projection.js +4 -1
- package/dist/server/projection.js.map +2 -2
- package/dist/server/projects.js +6 -0
- package/dist/server/projects.js.map +2 -2
- package/dist/server/service.js +279 -34
- package/dist/server/service.js.map +3 -3
- package/dist/server/snapshot.js +4 -0
- package/dist/server/snapshot.js.map +2 -2
- package/dist/server/websocket.js +24 -4
- package/dist/server/websocket.js.map +2 -2
- package/dist/shared/file-references.js +17 -0
- package/dist/shared/file-references.js.map +7 -0
- package/dist/shared/question-resolution.js +27 -0
- package/dist/shared/question-resolution.js.map +7 -0
- package/dist/shared/thread-attention.js +1 -1
- package/dist/shared/thread-attention.js.map +2 -2
- package/dist/shared/user-message.js +26 -0
- package/dist/shared/user-message.js.map +7 -0
- package/dist/shared/validation.js +31 -2
- package/dist/shared/validation.js.map +2 -2
- package/dist/update-worker.cjs +17027 -299
- package/dist/updates/manager.js +32 -5
- package/dist/updates/manager.js.map +2 -2
- package/dist/updates/worker.js +37 -4
- package/dist/updates/worker.js.map +2 -2
- package/dist/web/assets/{abnfDiagram-WEYOIA3C-S3UPbxUn.js → abnfDiagram-WEYOIA3C-Cx5fNukN.js} +1 -1
- package/dist/web/assets/{arc-3lcNn0Sn.js → arc-CvujBlOF.js} +1 -1
- package/dist/web/assets/{architecture-WOLXFQ4H-BdBTX3Ik.js → architecture-WOLXFQ4H-3ybLGumz.js} +1 -1
- package/dist/web/assets/{architectureDiagram-ZHVYKT53-CYO1Q71x.js → architectureDiagram-ZHVYKT53-wxtyxK5o.js} +1 -1
- package/dist/web/assets/{blockDiagram-RJAE7QA3-Du1vGlhq.js → blockDiagram-RJAE7QA3-D7y8R5g1.js} +1 -1
- package/dist/web/assets/{c4Diagram-XDPPPE54-BQU2rZDm.js → c4Diagram-XDPPPE54-E9InvJ7d.js} +1 -1
- package/dist/web/assets/channel-DypBVo-B.js +1 -0
- package/dist/web/assets/{chunk-2E7WHVMD-CfYDSKsN.js → chunk-2E7WHVMD-BrPZeprc.js} +1 -1
- package/dist/web/assets/{chunk-4EMNKR2T-C0VVivc4.js → chunk-4EMNKR2T-BFldxvFo.js} +1 -1
- package/dist/web/assets/{chunk-55XCU76K-DEvJD_uM.js → chunk-55XCU76K-BXjetGjU.js} +1 -1
- package/dist/web/assets/{chunk-7S6XSTFO-DEcCtbei.js → chunk-7S6XSTFO-BzciJyKd.js} +1 -1
- package/dist/web/assets/{chunk-AQDTSKZB-Dceak6-P.js → chunk-AQDTSKZB-DT84u_td.js} +1 -1
- package/dist/web/assets/{chunk-DSNLSHJZ-Bh8qc9yO.js → chunk-DSNLSHJZ-CWQvN-bk.js} +1 -1
- package/dist/web/assets/{chunk-HAGFOTED-CKdZtmf4.js → chunk-HAGFOTED-D4qmeLdB.js} +1 -1
- package/dist/web/assets/{chunk-HNE4Q36P-q-kgi8BS.js → chunk-HNE4Q36P-DtooMKDY.js} +1 -1
- package/dist/web/assets/{chunk-NQOKRVIF-PxyUNnJf.js → chunk-NQOKRVIF-Do-2erYc.js} +1 -1
- package/dist/web/assets/{chunk-UHW7PFBP-CE-Yrd9K.js → chunk-UHW7PFBP-OTCsXbET.js} +1 -1
- package/dist/web/assets/{chunk-VQ5W62QI-BBXd5ndx.js → chunk-VQ5W62QI-BAtIyKwu.js} +1 -1
- package/dist/web/assets/{chunk-WQQL4CDK-72UkMpCp.js → chunk-WQQL4CDK-Bn7nUbm8.js} +1 -1
- package/dist/web/assets/{chunk-XXDRQBXY-CXuhKPsU.js → chunk-XXDRQBXY-BPz6YTDo.js} +1 -1
- package/dist/web/assets/{chunk-YZO67HFG-t98lnr0m.js → chunk-YZO67HFG-Byby9ij7.js} +1 -1
- package/dist/web/assets/{chunk-ZAUX2LTX-DqOZ4gqq.js → chunk-ZAUX2LTX-BzFuAXta.js} +1 -1
- package/dist/web/assets/{chunk-ZCHMQSOR-lgNaB4GA.js → chunk-ZCHMQSOR-CC0PoClQ.js} +1 -1
- package/dist/web/assets/{classDiagram-v2-4MYWR3UA-QK8_uANH.js → classDiagram-v2-4MYWR3UA-DH1Q5yVh.js} +1 -1
- package/dist/web/assets/{cose-bilkent-JH36ORCC-BGOXl_Hz.js → cose-bilkent-JH36ORCC-Dsj4-W1M.js} +1 -1
- package/dist/web/assets/{cynefin-EF2NZ3EQ-CXv-Eedg.js → cynefin-EF2NZ3EQ-DP_BOQeS.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-WF24UDRP-DTdPvUc5.js → cynefinDiagram-WF24UDRP-OawAYxmS.js} +1 -1
- package/dist/web/assets/{dagre-NK4GIZVX-DzKylJII.js → dagre-NK4GIZVX-Kz5A8ufe.js} +1 -1
- package/dist/web/assets/{diagram-CBK3MWTC-BhUuXouD.js → diagram-CBK3MWTC-D_YADuPq.js} +1 -1
- package/dist/web/assets/{diagram-I5XIIV2D-CPLG3Tb6.js → diagram-I5XIIV2D-BR5VFxth.js} +1 -1
- package/dist/web/assets/{diagram-ODIL2UCW-D2vrOgvO.js → diagram-ODIL2UCW-DFwKU4Tv.js} +1 -1
- package/dist/web/assets/{diagram-PFBEJUXE-BmVHhgip.js → diagram-PFBEJUXE-CxJaU-bd.js} +1 -1
- package/dist/web/assets/{diagram-RJA3I4VV-DvdSgYRm.js → diagram-RJA3I4VV-DJiLH_P1.js} +1 -1
- package/dist/web/assets/{diagram-TYUNFSNR-C-kwYvdx.js → diagram-TYUNFSNR-QeSUaD8v.js} +1 -1
- package/dist/web/assets/{dist-COT7f4nc.js → dist-jS8KdIhD.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-V4P3TTPT-BaBk_GlW.js → ebnfDiagram-V4P3TTPT-CiPKKgoI.js} +1 -1
- package/dist/web/assets/{elk-QONTBCTQ-DgWt62tl.js → elk-QONTBCTQ-aBrHmTjJ.js} +1 -1
- package/dist/web/assets/{erDiagram-KYQIGQAA-Dv4ryXsH.js → erDiagram-KYQIGQAA-gZ7L22LI.js} +1 -1
- package/dist/web/assets/{eventmodeling-K75KTNOO-CCK2dwe-.js → eventmodeling-K75KTNOO-ClwYBJYu.js} +1 -1
- package/dist/web/assets/flowDiagram-IUGLLWBU-1p4FhuBv.js +1 -0
- package/dist/web/assets/{ganttDiagram-R7GPNTJY-Pyf76BsN.js → ganttDiagram-R7GPNTJY-D3j_GrtN.js} +1 -1
- package/dist/web/assets/{gitGraph-VSP46ZUC-Blm_W-6d.js → gitGraph-VSP46ZUC-CmYuFnjp.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PDYL7XHY-CigkTBcw.js → gitGraphDiagram-PDYL7XHY-BzKqTlog.js} +1 -1
- package/dist/web/assets/index-BacZMc3i.js +164 -0
- package/dist/web/assets/index-DsTjqvUr.css +1 -0
- package/dist/web/assets/{info-OHQRW6UA-ShlgKH7M.js → info-OHQRW6UA-BcVxeh9f.js} +1 -1
- package/dist/web/assets/{infoDiagram-MVDRKAX5-RxgBtAAC.js → infoDiagram-MVDRKAX5-BmonUtsp.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-HPEHV2GE-BX8-EDzq.js → ishikawaDiagram-HPEHV2GE-8Slr6H-2.js} +1 -1
- package/dist/web/assets/{journeyDiagram-BOSHW7O7-m5ADc5x0.js → journeyDiagram-BOSHW7O7-RmMgorVY.js} +1 -1
- package/dist/web/assets/{kanban-definition-FNSA4HC5-XHL025KK.js → kanban-definition-FNSA4HC5-DBbTL1Zm.js} +1 -1
- package/dist/web/assets/{line-NbgYmjWR.js → line-CqZ94aMp.js} +1 -1
- package/dist/web/assets/{linear-D7AWFTyL.js → linear-Dp-bkWW7.js} +1 -1
- package/dist/web/assets/{mermaid-parser.core-tMbxgDMM.js → mermaid-parser.core-DKlJTWOR.js} +3 -3
- package/dist/web/assets/{mermaid.core-iuk9IKWM.js → mermaid.core-BpCkjk1v.js} +4 -4
- package/dist/web/assets/{mindmap-definition-6OY57UG3-B1oUT012.js → mindmap-definition-6OY57UG3-BSouhHkz.js} +1 -1
- package/dist/web/assets/{packet-JDAUHWVQ--2WQUs6L.js → packet-JDAUHWVQ-DY83sD75.js} +1 -1
- package/dist/web/assets/{pegDiagram-ECIUJNBX-DyfZGbQZ.js → pegDiagram-ECIUJNBX-CHwZBvkV.js} +1 -1
- package/dist/web/assets/{pie-XZMESJXO-D4Tktw-H.js → pie-XZMESJXO-D8XMpqGE.js} +1 -1
- package/dist/web/assets/{pieDiagram-GNMPY74T-lCdYfSDI.js → pieDiagram-GNMPY74T-H3KSozao.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-D57K4MC3-CDnovYRI.js → quadrantDiagram-D57K4MC3-BtEi48H8.js} +1 -1
- package/dist/web/assets/{radar-ABXABTNO-Dmx2XQHp.js → radar-ABXABTNO-DWPvIwjC.js} +1 -1
- package/dist/web/assets/{railroad-I3PHUGI6-DB6M_KbS.js → railroad-I3PHUGI6-BdGwCwO6.js} +1 -1
- package/dist/web/assets/{railroad-abnf-LNEFI6M7-Dh3msl5z.js → railroad-abnf-LNEFI6M7-D9lVhCce.js} +1 -1
- package/dist/web/assets/{railroad-ebnf-DWYD2UWJ-HqWpbl4O.js → railroad-ebnf-DWYD2UWJ-CXGd-djo.js} +1 -1
- package/dist/web/assets/{railroad-peg-JR7BVNR7-Di4pKM6e.js → railroad-peg-JR7BVNR7-G6NS4NPY.js} +1 -1
- package/dist/web/assets/{railroadDiagram-Y72NRBL7-CE4pSnbT.js → railroadDiagram-Y72NRBL7-H5hI2v4I.js} +1 -1
- package/dist/web/assets/{requirementDiagram-EQYSW5RA-CSG9Zp4o.js → requirementDiagram-EQYSW5RA-BcFtwJKt.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-SY24JHO5-DpZC04yw.js → sankeyDiagram-SY24JHO5-CwkMYkgl.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-BLEHNHQU-CrY79quh.js → sequenceDiagram-BLEHNHQU-D9PmTWnQ.js} +1 -1
- package/dist/web/assets/{src-BUbhWkiw.js → src-Ccx89M6O.js} +1 -1
- package/dist/web/assets/{stateDiagram-v2-A6IESKWZ-awZ_sZ7F.js → stateDiagram-v2-A6IESKWZ-ox-EtVVU.js} +1 -1
- package/dist/web/assets/{swimlanes-B3ENRKFQ-Ch_ropB1.js → swimlanes-B3ENRKFQ-fkXDXy19.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-AYQRV4AK-dOr-UAvA.js +8 -0
- package/dist/web/assets/{timeline-definition-JXYKGLGB-Bcpem9rA.js → timeline-definition-JXYKGLGB-DNea9fF7.js} +1 -1
- package/dist/web/assets/{treeView-D4JQ5SDB-C0bGVtpe.js → treeView-D4JQ5SDB-_rSSpnCs.js} +1 -1
- package/dist/web/assets/{treemap-SAJKECNS-Dw7NGs2U.js → treemap-SAJKECNS-BFNOwmhz.js} +1 -1
- package/dist/web/assets/{usecaseDiagram-WPOLBNNX-ujZyHzxq.js → usecaseDiagram-WPOLBNNX-CRlRRQrt.js} +1 -1
- package/dist/web/assets/{vennDiagram-Q3Y3IDCW-CwGzrjci.js → vennDiagram-Q3Y3IDCW-BcGm0sIz.js} +1 -1
- package/dist/web/assets/{wardley-7MLQ67FV-9IZyEtGB.js → wardley-7MLQ67FV-HmzuAOij.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-IVAIDKWA-f4pHJ9xt.js → wardleyDiagram-IVAIDKWA-DF4HqcnW.js} +1 -1
- package/dist/web/assets/{xychartDiagram-4URNHDU4-BJGN__WY.js → xychartDiagram-4URNHDU4-C_dmVTAV.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +9 -7
- package/dist/web/assets/channel-D4tNOYdn.js +0 -1
- package/dist/web/assets/flowDiagram-IUGLLWBU-D1v15lCS.js +0 -1
- package/dist/web/assets/index-Bbm1piVJ.css +0 -1
- package/dist/web/assets/index-DSpVsb8N.js +0 -158
- package/dist/web/assets/swimlanesDiagram-AYQRV4AK-CMMtNEM7.js +0 -8
package/dist/server/service.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
import { questionAnswers } from "../shared/question-resolution.js";
|
|
2
|
+
import { asyncQuestionId, parseQuestionReplies } from "../shared/async-questions.js";
|
|
3
|
+
import { QuestionTrackingStore } from "./db/question-tracking.js";
|
|
4
|
+
import { nullLogger } from "../logging/logger.js";
|
|
5
|
+
import { errorFields } from "../logging/fields.js";
|
|
6
|
+
import { logContext, withLogContext } from "../logging/context.js";
|
|
1
7
|
import { hasSkillToken } from "../shared/skills.js";
|
|
8
|
+
import { referenceMessage, validateReferencePath } from "./file-references.js";
|
|
9
|
+
import { containsPath } from "./projects.js";
|
|
2
10
|
import { CapacityRetries } from "./capacity-retry.js";
|
|
3
11
|
import { isModelCapacityError } from "../shared/turn-errors.js";
|
|
4
12
|
import { randomUUID } from "node:crypto";
|
|
@@ -14,6 +22,7 @@ import { WorkspaceRegistry } from "./workspaces.js";
|
|
|
14
22
|
import { UNASSIGNED_SCOPE } from "../shared/workspace-scope.js";
|
|
15
23
|
import { AppError } from "../shared/errors.js";
|
|
16
24
|
import { threadNameError } from "../shared/thread-name.js";
|
|
25
|
+
import { mergeUserMessage, submittedUserMessage } from "../shared/user-message.js";
|
|
17
26
|
import {
|
|
18
27
|
validateElicitationResolution,
|
|
19
28
|
validatePermissionResolution
|
|
@@ -38,8 +47,13 @@ import { createSessionSchema } from "../shared/validation.js";
|
|
|
38
47
|
class GatewayService {
|
|
39
48
|
constructor(options) {
|
|
40
49
|
this.options = options;
|
|
50
|
+
this.logger = (options.logger ?? nullLogger).child({ component: "operations" });
|
|
41
51
|
this.store = options.store;
|
|
42
52
|
this.turnUsage = new TurnUsageStore(this.store.database);
|
|
53
|
+
this.questionTracking = new QuestionTrackingStore(
|
|
54
|
+
this.store.database,
|
|
55
|
+
this.logger.child({ component: "question_tracking" })
|
|
56
|
+
);
|
|
43
57
|
this.projects = options.projects;
|
|
44
58
|
this.workspaces = new WorkspaceRegistry(
|
|
45
59
|
this.store.database,
|
|
@@ -53,7 +67,8 @@ class GatewayService {
|
|
|
53
67
|
this.events.publishProjects(this.projects.list());
|
|
54
68
|
return project;
|
|
55
69
|
},
|
|
56
|
-
(path) => this.projects.list().some((project) => project.canonicalRoot === path)
|
|
70
|
+
(path) => this.projects.list().some((project) => project.canonicalRoot === path),
|
|
71
|
+
this.logger.child({ component: "clones" })
|
|
57
72
|
);
|
|
58
73
|
this.codex = options.codex;
|
|
59
74
|
this.shell = new ShellService(this.codex);
|
|
@@ -61,13 +76,15 @@ class GatewayService {
|
|
|
61
76
|
this.projection = new Projection(options.limits?.itemBytes);
|
|
62
77
|
this.capacityRetries = new CapacityRetries(
|
|
63
78
|
(job) => this.dispatchCapacityRetry(job),
|
|
64
|
-
(id) => this.publishThread(id)
|
|
79
|
+
(id) => this.publishThread(id),
|
|
80
|
+
this.logger.child({ component: "capacity_retry" })
|
|
65
81
|
);
|
|
66
82
|
this.currentEpoch = this.codex.epoch;
|
|
67
83
|
this.store.recover();
|
|
68
84
|
this.removeListener = this.codex.onEvent((event) => this.consume(event));
|
|
69
85
|
}
|
|
70
86
|
options;
|
|
87
|
+
logger;
|
|
71
88
|
capacityRetries;
|
|
72
89
|
projectClones;
|
|
73
90
|
shell;
|
|
@@ -75,6 +92,7 @@ class GatewayService {
|
|
|
75
92
|
projection;
|
|
76
93
|
store;
|
|
77
94
|
turnUsage;
|
|
95
|
+
questionTracking;
|
|
78
96
|
projects;
|
|
79
97
|
workspaces;
|
|
80
98
|
codex;
|
|
@@ -293,6 +311,78 @@ class GatewayService {
|
|
|
293
311
|
};
|
|
294
312
|
});
|
|
295
313
|
}
|
|
314
|
+
referenceScope(cwd, threadId, draftId) {
|
|
315
|
+
return {
|
|
316
|
+
cwd,
|
|
317
|
+
excluded: [
|
|
318
|
+
...this.projects.referenceRoots().filter((root) => root !== cwd && containsPath(cwd, root)),
|
|
319
|
+
...this.workspaces.allocations().filter((row) => !(threadId && row.threadId === threadId) && row.operationId !== draftId).map((row) => row.canonicalRoot)
|
|
320
|
+
]
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
async searchFiles(input, signal) {
|
|
324
|
+
this.ensureReady();
|
|
325
|
+
if (!this.codex.searchFiles)
|
|
326
|
+
throw new AppError("METHOD_UNAVAILABLE", "Codex does not support fuzzyFileSearch", 409);
|
|
327
|
+
const thread = input.threadId ? await this.loadThread(input.threadId) : void 0;
|
|
328
|
+
if (thread && thread.projectId !== input.projectId)
|
|
329
|
+
throw new AppError("PROJECT_OWNERSHIP", "Session belongs to another workspace", 403);
|
|
330
|
+
const resolveCwd = () => thread ? this.workspaces.assertOwnership(thread.projectId, thread.cwd, thread.id).cwd : input.projectId === null ? this.workspaces.draft(input.draftId).cwd : this.projects.get(input.projectId).canonicalRoot;
|
|
331
|
+
const cwd = resolveCwd();
|
|
332
|
+
if (input.projectId !== null) this.workspaces.assertProjectDirectory(cwd);
|
|
333
|
+
const draftId = !thread && input.projectId === null ? input.draftId : void 0;
|
|
334
|
+
const scope = this.referenceScope(cwd, thread?.id, draftId);
|
|
335
|
+
const epoch = this.codex.epoch;
|
|
336
|
+
const timeout = AbortSignal.timeout(5e3);
|
|
337
|
+
const cancellation = AbortSignal.any([signal, timeout]);
|
|
338
|
+
try {
|
|
339
|
+
cancellation.throwIfAborted();
|
|
340
|
+
if (!input.query) return { cwd, paths: [], limited: false };
|
|
341
|
+
const result = await withLogContext(
|
|
342
|
+
{ threadId: thread?.id },
|
|
343
|
+
() => this.codex.searchFiles(cwd, input.query, cancellation)
|
|
344
|
+
);
|
|
345
|
+
const paths = [];
|
|
346
|
+
let unreadable = false;
|
|
347
|
+
for (const file of result.files.slice(0, 50)) {
|
|
348
|
+
cancellation.throwIfAborted();
|
|
349
|
+
if (file.root !== cwd || file.match_type !== "file") continue;
|
|
350
|
+
const path = process.platform === "win32" ? file.path.replaceAll("\\", "/") : file.path;
|
|
351
|
+
try {
|
|
352
|
+
await validateReferencePath(path, scope);
|
|
353
|
+
if (!paths.includes(path)) paths.push(path);
|
|
354
|
+
} catch (error) {
|
|
355
|
+
if (error instanceof AppError && error.code === "FILE_REFERENCE_UNREADABLE")
|
|
356
|
+
unreadable = true;
|
|
357
|
+
else if (!(error instanceof AppError)) throw error;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
cancellation.throwIfAborted();
|
|
361
|
+
this.ensureReady();
|
|
362
|
+
if (resolveCwd() !== cwd || this.codex.epoch !== epoch || JSON.stringify(this.referenceScope(cwd, thread?.id, draftId)) !== JSON.stringify(scope))
|
|
363
|
+
throw new AppError("FILE_REFERENCE_CHANGED", "Workspace changed; search again", 409);
|
|
364
|
+
if (unreadable && !paths.length)
|
|
365
|
+
throw new AppError("FILE_REFERENCE_UNREADABLE", "Matching files cannot be read", 403);
|
|
366
|
+
return { cwd, paths, limited: result.files.length >= 50 };
|
|
367
|
+
} catch (error) {
|
|
368
|
+
if (timeout.aborted)
|
|
369
|
+
throw new AppError("FILE_SEARCH_TIMEOUT", "File search timed out; narrow the path", 408);
|
|
370
|
+
if (signal.aborted) throw new AppError("FILE_SEARCH_CANCELLED", "File search cancelled", 499);
|
|
371
|
+
throw error;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
async fileMessage(thread, text, files = []) {
|
|
375
|
+
if (!files.length) return text;
|
|
376
|
+
const epoch = this.codex.epoch;
|
|
377
|
+
const ownership = this.workspaces.assertOwnership(thread.projectId, thread.cwd, thread.id);
|
|
378
|
+
const scope = this.referenceScope(ownership.cwd, thread.id);
|
|
379
|
+
const result = await referenceMessage(text, files, scope);
|
|
380
|
+
this.ensureManaged(thread);
|
|
381
|
+
this.workspaces.assertOwnership(thread.projectId, thread.cwd, thread.id);
|
|
382
|
+
if (this.codex.epoch !== epoch || JSON.stringify(this.referenceScope(ownership.cwd, thread.id)) !== JSON.stringify(scope))
|
|
383
|
+
throw new AppError("FILE_REFERENCE_CHANGED", "Workspace changed; select the file again", 409);
|
|
384
|
+
return result;
|
|
385
|
+
}
|
|
296
386
|
async listSkills(input) {
|
|
297
387
|
this.ensureReady();
|
|
298
388
|
if (!this.codex.listSkills)
|
|
@@ -593,7 +683,7 @@ class GatewayService {
|
|
|
593
683
|
const thread = this.projection.get(threadId);
|
|
594
684
|
if (!thread) return [];
|
|
595
685
|
this.workspaces.assertOwnership(thread.projectId, thread.cwd, thread.id);
|
|
596
|
-
return pendingAttention(thread);
|
|
686
|
+
return pendingAttention(this.threadView(thread));
|
|
597
687
|
}
|
|
598
688
|
async getThreadSnapshot(threadId) {
|
|
599
689
|
await this.getThread(threadId);
|
|
@@ -619,7 +709,7 @@ class GatewayService {
|
|
|
619
709
|
const root = links.get(turn.id);
|
|
620
710
|
if (root) turn.retryOf = root;
|
|
621
711
|
}
|
|
622
|
-
return page;
|
|
712
|
+
return this.threadView(page);
|
|
623
713
|
}
|
|
624
714
|
async exportThread(threadId) {
|
|
625
715
|
this.ensureReady();
|
|
@@ -920,11 +1010,27 @@ class GatewayService {
|
|
|
920
1010
|
if (isActive(this.projection.get(threadId)?.status ?? thread.status))
|
|
921
1011
|
throw new AppError("THREAD_BUSY", "Session already has an active task", 409);
|
|
922
1012
|
}
|
|
923
|
-
this.
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
1013
|
+
const fileText = input.files?.length ? await this.fileMessage(thread, input.text, input.files) : input.text;
|
|
1014
|
+
if (isActive(this.projection.get(threadId)?.status ?? thread.status))
|
|
1015
|
+
throw new AppError("THREAD_BUSY", "Session already has an active task", 409);
|
|
1016
|
+
if (parseQuestionReplies(fileText))
|
|
1017
|
+
await this.claimQuestionReplies(threadId, fileText, input.clientOperationId);
|
|
1018
|
+
const message = {
|
|
1019
|
+
...input,
|
|
1020
|
+
text: input.taskKind === "init" ? PROJECT_INIT_PROMPT : fileText
|
|
1021
|
+
};
|
|
1022
|
+
this.store.dispatch(
|
|
1023
|
+
input.clientOperationId,
|
|
1024
|
+
{
|
|
1025
|
+
threadId,
|
|
1026
|
+
workspaceKey: ownership.workspaceKey,
|
|
1027
|
+
codexEpoch: this.codex.epoch
|
|
1028
|
+
},
|
|
1029
|
+
message.text || message.images?.length ? {
|
|
1030
|
+
threadId,
|
|
1031
|
+
item: submittedUserMessage(input.clientOperationId, message)
|
|
1032
|
+
} : void 0
|
|
1033
|
+
);
|
|
928
1034
|
if (retry && !this.capacityRetries.owns(retry))
|
|
929
1035
|
throw new AppError("TURN_CONFLICT", "\u5BB9\u91CF\u91CD\u8BD5\u5DF2\u53D6\u6D88\u6216\u88AB\u66FF\u4EE3", 409);
|
|
930
1036
|
const candidate = retry ?? this.capacityRetries.begin(
|
|
@@ -940,10 +1046,11 @@ class GatewayService {
|
|
|
940
1046
|
const turn = await this.codex.startTurn(
|
|
941
1047
|
threadId,
|
|
942
1048
|
ownership.cwd,
|
|
943
|
-
|
|
1049
|
+
message.text,
|
|
944
1050
|
input.settings,
|
|
945
1051
|
input.images,
|
|
946
|
-
|
|
1052
|
+
skills.length ? skills : void 0,
|
|
1053
|
+
input.clientOperationId
|
|
947
1054
|
);
|
|
948
1055
|
this.store.attachTurn(input.clientOperationId, turn.id);
|
|
949
1056
|
this.turnBaselines.delete(input.clientOperationId);
|
|
@@ -1178,14 +1285,28 @@ class GatewayService {
|
|
|
1178
1285
|
409
|
|
1179
1286
|
);
|
|
1180
1287
|
this.ensureCompatibilityConfirmed();
|
|
1181
|
-
|
|
1288
|
+
let message = input.text;
|
|
1289
|
+
if (input.files?.length) {
|
|
1290
|
+
const thread = await this.loadThread(threadId);
|
|
1291
|
+
message = await this.fileMessage(thread, input.text, input.files);
|
|
1292
|
+
await this.requireActiveTurn(threadId, input.expectedTurnId);
|
|
1293
|
+
}
|
|
1294
|
+
if (parseQuestionReplies(message))
|
|
1295
|
+
await this.claimQuestionReplies(threadId, message, input.clientOperationId);
|
|
1296
|
+
this.store.dispatch(input.clientOperationId, void 0, {
|
|
1297
|
+
threadId,
|
|
1298
|
+
turnId: input.expectedTurnId,
|
|
1299
|
+
item: submittedUserMessage(input.clientOperationId, { ...input, text: message })
|
|
1300
|
+
});
|
|
1301
|
+
this.publishThread(threadId);
|
|
1182
1302
|
const result = await this.codex.steerTurn(
|
|
1183
1303
|
threadId,
|
|
1184
1304
|
input.expectedTurnId,
|
|
1185
|
-
|
|
1186
|
-
input.images
|
|
1305
|
+
message,
|
|
1306
|
+
input.images,
|
|
1307
|
+
input.clientOperationId
|
|
1187
1308
|
);
|
|
1188
|
-
return { result: { threadId, turnId: result.turnId } };
|
|
1309
|
+
return { result: { threadId, turnId: result.turnId }, turnId: result.turnId };
|
|
1189
1310
|
});
|
|
1190
1311
|
}
|
|
1191
1312
|
async updateLiveSettings(threadId, input) {
|
|
@@ -1260,9 +1381,88 @@ class GatewayService {
|
|
|
1260
1381
|
this.projection.resolveAction(actionId, "responding");
|
|
1261
1382
|
if (action.threadId) this.publishThread(action.threadId);
|
|
1262
1383
|
await this.codex.respond(actionId, input.resolution);
|
|
1384
|
+
if (action.kind === "questions") {
|
|
1385
|
+
this.projection.resolveAction(actionId, "responded");
|
|
1386
|
+
this.questionTracking.saveAction(
|
|
1387
|
+
action,
|
|
1388
|
+
questionAnswers(action.questions ?? [], input.resolution)
|
|
1389
|
+
);
|
|
1390
|
+
if (action.threadId) this.publishThread(action.threadId);
|
|
1391
|
+
}
|
|
1263
1392
|
return { result: { actionId } };
|
|
1264
1393
|
});
|
|
1265
1394
|
}
|
|
1395
|
+
/** This ends Covro tracking only. It must never start/steer/interrupt a native turn. */
|
|
1396
|
+
async dismissQuestions(threadId, input) {
|
|
1397
|
+
return this.perform("question.dismiss", threadId, input, async () => {
|
|
1398
|
+
await this.loadThread(threadId);
|
|
1399
|
+
const history = this.normalize(await this.codex.readThread(threadId));
|
|
1400
|
+
this.workspaces.assertOwnership(history.projectId, history.cwd, history.id);
|
|
1401
|
+
this.projection.thread(history, true);
|
|
1402
|
+
const states = this.questionTracking.states(threadId);
|
|
1403
|
+
for (const id of new Set(input.questionIds)) {
|
|
1404
|
+
const question = this.findAsyncQuestion(history, id);
|
|
1405
|
+
if (!question) throw new AppError("QUESTION_EXPIRED", "\u8BE5\u95EE\u9898\u5DF2\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5237\u65B0\u4F1A\u8BDD", 409);
|
|
1406
|
+
if (this.questionAnswered(history, id)) continue;
|
|
1407
|
+
if (states[id] && states[id].status !== "dismissed")
|
|
1408
|
+
throw new AppError("QUESTION_BUSY", "\u56DE\u7B54\u6B63\u5728\u63D0\u4EA4\u6216\u7ED3\u679C\u5F85\u6838\u5BF9\uFF0C\u8BF7\u5237\u65B0\u540E\u7EE7\u7EED", 409);
|
|
1409
|
+
}
|
|
1410
|
+
const ids = [...new Set(input.questionIds)].filter(
|
|
1411
|
+
(id) => !this.questionAnswered(history, id)
|
|
1412
|
+
);
|
|
1413
|
+
this.store.dispatch(input.clientOperationId);
|
|
1414
|
+
this.questionTracking.save(threadId, ids, "dismissed", input.clientOperationId);
|
|
1415
|
+
this.publishThread(threadId);
|
|
1416
|
+
return { result: { threadId, questionIds: ids } };
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
questionItems(history) {
|
|
1420
|
+
return [...history.turns, ...this.projection.get(history.id)?.turns ?? []].flatMap(
|
|
1421
|
+
(turn) => turn.items
|
|
1422
|
+
);
|
|
1423
|
+
}
|
|
1424
|
+
findAsyncQuestion(history, id) {
|
|
1425
|
+
for (const item of this.questionItems(history)) {
|
|
1426
|
+
if (item.type !== "agentMessage") continue;
|
|
1427
|
+
const index = item.questions?.findIndex((_, index2) => asyncQuestionId(item.id, index2) === id);
|
|
1428
|
+
if (index !== void 0 && index >= 0) return { item, question: item.questions[index] };
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
questionAnswered(history, id) {
|
|
1432
|
+
const source = this.findAsyncQuestion(history, id);
|
|
1433
|
+
return Boolean(
|
|
1434
|
+
source && this.questionItems(history).some(
|
|
1435
|
+
(item) => item.questionReplies?.some(
|
|
1436
|
+
(reply) => reply.questionItemId === id || reply.questionItemId === source.item.id && reply.question === source.question.title
|
|
1437
|
+
)
|
|
1438
|
+
)
|
|
1439
|
+
);
|
|
1440
|
+
}
|
|
1441
|
+
async claimQuestionReplies(threadId, text, operationId) {
|
|
1442
|
+
const replies = parseQuestionReplies(text);
|
|
1443
|
+
if (!replies) return;
|
|
1444
|
+
const history = this.normalize(await this.codex.readThread(threadId));
|
|
1445
|
+
this.workspaces.assertOwnership(history.projectId, history.cwd, history.id);
|
|
1446
|
+
this.projection.thread(history, true);
|
|
1447
|
+
const states = this.questionTracking.states(threadId);
|
|
1448
|
+
const ids = [];
|
|
1449
|
+
for (const reply of replies) {
|
|
1450
|
+
const source = this.findAsyncQuestion(history, reply.questionItemId) ?? (() => {
|
|
1451
|
+
const item = this.questionItems(history).find((item2) => item2.id === reply.questionItemId);
|
|
1452
|
+
const index2 = item?.questions?.findIndex((q) => q.title === reply.question);
|
|
1453
|
+
return item && index2 !== void 0 && index2 >= 0 ? this.findAsyncQuestion(history, asyncQuestionId(item.id, index2)) : void 0;
|
|
1454
|
+
})();
|
|
1455
|
+
const index = source?.item.questions?.indexOf(source.question);
|
|
1456
|
+
if (!source || index === void 0)
|
|
1457
|
+
throw new AppError("QUESTION_EXPIRED", "\u8BE5\u95EE\u9898\u5DF2\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5237\u65B0\u4F1A\u8BDD", 409);
|
|
1458
|
+
if (!reply.answer.trim()) throw new AppError("VALIDATION_ERROR", "\u56DE\u7B54\u4E0D\u80FD\u4E3A\u7A7A");
|
|
1459
|
+
const id = asyncQuestionId(source.item.id, index);
|
|
1460
|
+
if (states[id] || this.questionAnswered(history, id) || ids.includes(id))
|
|
1461
|
+
throw new AppError("QUESTION_CONFLICT", "\u8BE5\u95EE\u9898\u5DF2\u5904\u7406\u6216\u6B63\u5728\u63D0\u4EA4\uFF0C\u8BF7\u5237\u65B0\u4F1A\u8BDD", 409);
|
|
1462
|
+
ids.push(id);
|
|
1463
|
+
}
|
|
1464
|
+
this.questionTracking.save(threadId, ids, "submitting", operationId);
|
|
1465
|
+
}
|
|
1266
1466
|
getOperation(id) {
|
|
1267
1467
|
const row = this.store.get(id);
|
|
1268
1468
|
if (!row) throw new AppError("OPERATION_NOT_FOUND", "\u672A\u627E\u5230\u8BE5\u64CD\u4F5C", 404);
|
|
@@ -1344,13 +1544,32 @@ class GatewayService {
|
|
|
1344
1544
|
} catch (error) {
|
|
1345
1545
|
throw this.asAppError(error);
|
|
1346
1546
|
}
|
|
1347
|
-
|
|
1547
|
+
const logger = this.logger.child({
|
|
1548
|
+
...logContext(),
|
|
1549
|
+
operationId: input.clientOperationId,
|
|
1550
|
+
kind,
|
|
1551
|
+
...this.store.getThreadLink(target) ? { threadId: target } : {}
|
|
1552
|
+
});
|
|
1553
|
+
const started = performance.now();
|
|
1554
|
+
if (!accepted.inserted) {
|
|
1555
|
+
logger.debug("operation.replayed", { state: accepted.operation.state, replayed: true });
|
|
1556
|
+
return this.operation(accepted.operation);
|
|
1557
|
+
}
|
|
1558
|
+
logger.info("operation.accepted");
|
|
1348
1559
|
this.inFlightOperations.add(input.clientOperationId);
|
|
1349
1560
|
try {
|
|
1350
|
-
const { result, turnId, onAcknowledged } = await
|
|
1561
|
+
const { result, turnId, onAcknowledged } = await withLogContext(
|
|
1562
|
+
{ operationId: input.clientOperationId },
|
|
1563
|
+
work
|
|
1564
|
+
);
|
|
1351
1565
|
const operation = this.operation(
|
|
1352
1566
|
this.store.acknowledge(input.clientOperationId, result, turnId)
|
|
1353
1567
|
);
|
|
1568
|
+
logger.info("operation.acknowledged", {
|
|
1569
|
+
state: operation.status,
|
|
1570
|
+
turnId,
|
|
1571
|
+
durationMs: Math.round(performance.now() - started)
|
|
1572
|
+
});
|
|
1354
1573
|
if (operation.status === "acknowledged") onAcknowledged?.();
|
|
1355
1574
|
this.events.publish("operation", operation);
|
|
1356
1575
|
return operation;
|
|
@@ -1366,13 +1585,24 @@ class GatewayService {
|
|
|
1366
1585
|
uncertain
|
|
1367
1586
|
)
|
|
1368
1587
|
);
|
|
1588
|
+
logger.warn("operation.failed", {
|
|
1589
|
+
state: operation.status,
|
|
1590
|
+
uncertain,
|
|
1591
|
+
...errorFields(appError),
|
|
1592
|
+
durationMs: Math.round(performance.now() - started)
|
|
1593
|
+
});
|
|
1369
1594
|
if (dispatched && !uncertain && kind === "action.resolve" && this.projection.actions.get(target)?.status === "responding") {
|
|
1370
1595
|
const action = this.projection.resolveAction(target, "pending");
|
|
1371
1596
|
if (action?.threadId) this.publishThread(action.threadId);
|
|
1372
1597
|
}
|
|
1598
|
+
if (!uncertain && (kind === "turn.start" || kind === "turn.steer")) {
|
|
1599
|
+
this.questionTracking.release(input.clientOperationId);
|
|
1600
|
+
this.publishThread(target);
|
|
1601
|
+
}
|
|
1373
1602
|
if (kind === "turn.start")
|
|
1374
1603
|
this.capacityRetries.dispatchFailed(target, input.clientOperationId);
|
|
1375
|
-
if (dispatched && kind === "turn.start"
|
|
1604
|
+
if (dispatched && (kind === "turn.start" || kind === "turn.steer"))
|
|
1605
|
+
this.publishThread(target);
|
|
1376
1606
|
this.events.publish("operation", operation);
|
|
1377
1607
|
if (uncertain)
|
|
1378
1608
|
throw new AppError(
|
|
@@ -1386,7 +1616,8 @@ class GatewayService {
|
|
|
1386
1616
|
this.inFlightOperations.delete(input.clientOperationId);
|
|
1387
1617
|
this.pendingThreadCreations.delete(input.clientOperationId);
|
|
1388
1618
|
if (!this.store.activeForThread(target)) this.turnBaselines.delete(input.clientOperationId);
|
|
1389
|
-
if (kind === "thread.compact"
|
|
1619
|
+
if (kind === "thread.compact" || kind === "turn.start" || kind === "turn.steer")
|
|
1620
|
+
this.publishThread(target);
|
|
1390
1621
|
}
|
|
1391
1622
|
}
|
|
1392
1623
|
normalize(thread, projectId, managed = false) {
|
|
@@ -1528,19 +1759,7 @@ class GatewayService {
|
|
|
1528
1759
|
} else if (action.kind === "elicitation") {
|
|
1529
1760
|
validateElicitationResolution(action.elicitation, resolution);
|
|
1530
1761
|
} else if (action.kind === "questions") {
|
|
1531
|
-
|
|
1532
|
-
const questions = action.questions ?? [];
|
|
1533
|
-
if (Object.keys(resolution.answers).some(
|
|
1534
|
-
(id) => !questions.some((question) => question.id === id)
|
|
1535
|
-
))
|
|
1536
|
-
throw new AppError("VALIDATION_ERROR", "\u56DE\u7B54\u5305\u542B\u672A\u77E5\u95EE\u9898");
|
|
1537
|
-
for (const question of questions) {
|
|
1538
|
-
const answers = resolution.answers[question.id];
|
|
1539
|
-
if (!answers?.length || answers.some(
|
|
1540
|
-
(answer) => !answer.trim() || !question.isOther && question.options.length > 0 && !question.options.some((option) => option.label === answer)
|
|
1541
|
-
))
|
|
1542
|
-
throw new AppError("VALIDATION_ERROR", `\u95EE\u9898 ${question.header} \u7684\u56DE\u7B54\u4E0D\u7B26\u5408\u9009\u9879\u8981\u6C42`);
|
|
1543
|
-
}
|
|
1762
|
+
questionAnswers(action.questions ?? [], resolution);
|
|
1544
1763
|
} else if (!("decision" in resolution) || "content" in resolution || "persist" in resolution || !action.options.some((option) => option.id === resolution.decision))
|
|
1545
1764
|
throw new AppError("VALIDATION_ERROR", "\u8BF7\u9009\u62E9\u4E0A\u6E38\u63D0\u4F9B\u7684\u5408\u6CD5\u9009\u9879");
|
|
1546
1765
|
}
|
|
@@ -1616,7 +1835,22 @@ class GatewayService {
|
|
|
1616
1835
|
return links;
|
|
1617
1836
|
}
|
|
1618
1837
|
threadView(thread, copy = true) {
|
|
1838
|
+
const submissions = new Map(
|
|
1839
|
+
this.store.pendingMessages(thread.id).map((message) => [message.id, message])
|
|
1840
|
+
);
|
|
1841
|
+
if (submissions.size)
|
|
1842
|
+
for (const turn of thread.turns)
|
|
1843
|
+
for (const item of turn.items) {
|
|
1844
|
+
const pending = item.clientId ? submissions.get(item.clientId) : void 0;
|
|
1845
|
+
if (pending && (!pending.turnId || pending.turnId === turn.id)) {
|
|
1846
|
+
Object.assign(item, mergeUserMessage(item, pending.item));
|
|
1847
|
+
this.store.confirmMessage(thread.id, turn.id, item);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1619
1850
|
const result = copy ? structuredClone(thread) : { ...thread };
|
|
1851
|
+
const pendingMessages = this.store.pendingMessages(thread.id);
|
|
1852
|
+
if (pendingMessages.length) result.pendingMessages = pendingMessages;
|
|
1853
|
+
else delete result.pendingMessages;
|
|
1620
1854
|
const links = this.capacityLinks.get(thread.id) ?? (thread.turns.some((turn) => !turn.items.some((item) => item.type === "userMessage")) ? this.retryLinks(thread.id) : void 0);
|
|
1621
1855
|
result.turns = result.turns.map((turn) => {
|
|
1622
1856
|
const root = links?.get(turn.id);
|
|
@@ -1626,6 +1860,13 @@ class GatewayService {
|
|
|
1626
1860
|
if (retry) result.capacityRetry = structuredClone(retry);
|
|
1627
1861
|
else delete result.capacityRetry;
|
|
1628
1862
|
if (this.capacityRetries.pending(thread.id)) result.status = "running";
|
|
1863
|
+
result.questionTracking = this.questionTracking.states(thread.id);
|
|
1864
|
+
const savedActions = this.questionTracking.actions(thread.id);
|
|
1865
|
+
const actions = new Map(savedActions.map((action) => [action.actionId, action]));
|
|
1866
|
+
for (const action of thread.actions)
|
|
1867
|
+
if (action.status === "pending" || action.status === "responding" || !actions.has(action.actionId))
|
|
1868
|
+
actions.set(action.actionId, action);
|
|
1869
|
+
result.actions = [...actions.values()];
|
|
1629
1870
|
result.archived = thread.archived ?? false;
|
|
1630
1871
|
result.historyVisible = this.historyVisible(thread);
|
|
1631
1872
|
const marker = this.store.activeForThread(thread.id);
|
|
@@ -1722,8 +1963,11 @@ class GatewayService {
|
|
|
1722
1963
|
if (action.codexEpoch !== this.codex.epoch) return;
|
|
1723
1964
|
const known = this.projection.actions.has(action.actionId);
|
|
1724
1965
|
const owner = action.threadId ? this.projection.get(action.threadId) : void 0;
|
|
1725
|
-
const previous = new Set(
|
|
1966
|
+
const previous = new Set(
|
|
1967
|
+
owner ? pendingAttention(this.threadView(owner)).map(attentionKey) : []
|
|
1968
|
+
);
|
|
1726
1969
|
this.projection.action(action);
|
|
1970
|
+
if (action.kind === "questions") this.questionTracking.saveAction(action);
|
|
1727
1971
|
if (action.threadId) {
|
|
1728
1972
|
this.publishThread(action.threadId);
|
|
1729
1973
|
if (!known) this.publishNewAttention(action.threadId, previous);
|
|
@@ -1732,6 +1976,7 @@ class GatewayService {
|
|
|
1732
1976
|
}
|
|
1733
1977
|
if (event.type === "actionResolved") {
|
|
1734
1978
|
const action = this.projection.resolveAction(event.actionId, "responded");
|
|
1979
|
+
if (action?.kind === "questions") this.questionTracking.saveAction(action);
|
|
1735
1980
|
if (action?.threadId) this.publishThread(action.threadId);
|
|
1736
1981
|
return;
|
|
1737
1982
|
}
|
|
@@ -1749,7 +1994,7 @@ class GatewayService {
|
|
|
1749
1994
|
return;
|
|
1750
1995
|
}
|
|
1751
1996
|
const previousAttention = new Set(
|
|
1752
|
-
event.type === "item" || event.type === "turn" ? pendingAttention(thread).map(attentionKey) : []
|
|
1997
|
+
event.type === "item" || event.type === "turn" ? pendingAttention(this.threadView(thread)).map(attentionKey) : []
|
|
1753
1998
|
);
|
|
1754
1999
|
if (event.type === "tokenUsage") {
|
|
1755
2000
|
if (this.projection.tokenUsage(thread.id, event.usage)) this.publishThread(thread.id);
|