@covro/covro 0.8.1-dev.4 → 0.8.1-dev.6
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 +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/codex/adapter.js +24 -29
- package/dist/codex/adapter.js.map +2 -2
- package/dist/codex/permissions.js.map +1 -1
- package/dist/drizzle/0009_question_tracking.sql +15 -0
- package/dist/drizzle/meta/0009_snapshot.json +698 -0
- package/dist/drizzle/meta/_journal.json +7 -0
- package/dist/server/db/question-tracking.js +83 -0
- package/dist/server/db/question-tracking.js.map +7 -0
- package/dist/server/db/schema.js +22 -0
- package/dist/server/db/schema.js.map +2 -2
- package/dist/server/http.js +7 -0
- package/dist/server/http.js.map +2 -2
- package/dist/server/service.js +108 -17
- package/dist/server/service.js.map +3 -3
- 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/validation.js +8 -1
- package/dist/shared/validation.js.map +2 -2
- package/dist/web/assets/{abnfDiagram-WEYOIA3C-BCbBe9sD.js → abnfDiagram-WEYOIA3C-B--HLBRU.js} +1 -1
- package/dist/web/assets/{arc-Dmj0lNjC.js → arc-BA6LM9qR.js} +1 -1
- package/dist/web/assets/{architecture-WOLXFQ4H-Svdy_1x9.js → architecture-WOLXFQ4H-BxH8Y_8w.js} +1 -1
- package/dist/web/assets/{architectureDiagram-ZHVYKT53-C7y9lfSk.js → architectureDiagram-ZHVYKT53-Du_JEDSO.js} +1 -1
- package/dist/web/assets/{blockDiagram-RJAE7QA3-DYxD2Kch.js → blockDiagram-RJAE7QA3-0mm-0YlH.js} +1 -1
- package/dist/web/assets/{c4Diagram-XDPPPE54-6t2e5I0A.js → c4Diagram-XDPPPE54-Ca0mkJNX.js} +1 -1
- package/dist/web/assets/channel-DemP4h_q.js +1 -0
- package/dist/web/assets/{chunk-2E7WHVMD-75d2TU1O.js → chunk-2E7WHVMD-kp8Z0o7K.js} +1 -1
- package/dist/web/assets/{chunk-4EMNKR2T-K8d5Kk-R.js → chunk-4EMNKR2T-BKAE5YSO.js} +1 -1
- package/dist/web/assets/{chunk-55XCU76K-DdfehDJs.js → chunk-55XCU76K-Dv0RzzJs.js} +1 -1
- package/dist/web/assets/{chunk-7S6XSTFO-Dkj4l-ja.js → chunk-7S6XSTFO-dmBhSH5V.js} +1 -1
- package/dist/web/assets/{chunk-AQDTSKZB-CJ0iS2wK.js → chunk-AQDTSKZB-ub-4UHFO.js} +1 -1
- package/dist/web/assets/{chunk-DSNLSHJZ-BtpQNPbj.js → chunk-DSNLSHJZ-B4qpSl3v.js} +1 -1
- package/dist/web/assets/{chunk-HAGFOTED-BSQfMdak.js → chunk-HAGFOTED-CTAe2Flk.js} +1 -1
- package/dist/web/assets/{chunk-HNE4Q36P-BtYKKnn5.js → chunk-HNE4Q36P-wznprb2K.js} +1 -1
- package/dist/web/assets/{chunk-NQOKRVIF-2YqFnEzu.js → chunk-NQOKRVIF-DFuVmaPf.js} +1 -1
- package/dist/web/assets/{chunk-UHW7PFBP-Ce7TuUqP.js → chunk-UHW7PFBP-BcHbXwO0.js} +1 -1
- package/dist/web/assets/{chunk-VQ5W62QI-DQWomF93.js → chunk-VQ5W62QI-TO80sYcs.js} +1 -1
- package/dist/web/assets/{chunk-WQQL4CDK-BCbKpaT6.js → chunk-WQQL4CDK-C074NuuH.js} +1 -1
- package/dist/web/assets/{chunk-XXDRQBXY-C9rTpqIe.js → chunk-XXDRQBXY-Dv8lvdin.js} +1 -1
- package/dist/web/assets/{chunk-YZO67HFG-C9v0ova1.js → chunk-YZO67HFG-Cpt12wWD.js} +1 -1
- package/dist/web/assets/{chunk-ZAUX2LTX-BdGFguJi.js → chunk-ZAUX2LTX-BvVO4mcK.js} +1 -1
- package/dist/web/assets/{chunk-ZCHMQSOR-JZziUBXP.js → chunk-ZCHMQSOR-D6-S1iot.js} +1 -1
- package/dist/web/assets/{classDiagram-v2-4MYWR3UA-kaUa8Osh.js → classDiagram-v2-4MYWR3UA-Czyj6aDC.js} +1 -1
- package/dist/web/assets/{cose-bilkent-JH36ORCC-B7AoZpec.js → cose-bilkent-JH36ORCC-DlZgG4Hy.js} +1 -1
- package/dist/web/assets/{cynefin-EF2NZ3EQ-mZQH-v4h.js → cynefin-EF2NZ3EQ-DggCmuEk.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-WF24UDRP-VFu42UYD.js → cynefinDiagram-WF24UDRP-Y78QRDke.js} +1 -1
- package/dist/web/assets/{dagre-NK4GIZVX-BykPb3q5.js → dagre-NK4GIZVX-B2D2GmfS.js} +1 -1
- package/dist/web/assets/{diagram-CBK3MWTC-C8Sdoz2H.js → diagram-CBK3MWTC-B1fM9Qzn.js} +1 -1
- package/dist/web/assets/{diagram-I5XIIV2D-BngbS3N1.js → diagram-I5XIIV2D-BmltjFNx.js} +1 -1
- package/dist/web/assets/{diagram-ODIL2UCW-BXxXZOOz.js → diagram-ODIL2UCW-B0fi6X8i.js} +1 -1
- package/dist/web/assets/{diagram-PFBEJUXE-Ck5ASHbm.js → diagram-PFBEJUXE-RMJfHUUq.js} +1 -1
- package/dist/web/assets/{diagram-RJA3I4VV-cQN1z6Ay.js → diagram-RJA3I4VV-B_4_qIV3.js} +1 -1
- package/dist/web/assets/{diagram-TYUNFSNR-BeqL9hEh.js → diagram-TYUNFSNR-De-Mp1Xj.js} +1 -1
- package/dist/web/assets/{dist-BGAiDAIF.js → dist-BiJ4161L.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-V4P3TTPT-lMkPFQ2I.js → ebnfDiagram-V4P3TTPT-Cb5L22nj.js} +1 -1
- package/dist/web/assets/{elk-QONTBCTQ-DAmV761j.js → elk-QONTBCTQ-BN5FRcIS.js} +1 -1
- package/dist/web/assets/{erDiagram-KYQIGQAA-BneJIghq.js → erDiagram-KYQIGQAA-CTXR4zV5.js} +1 -1
- package/dist/web/assets/{eventmodeling-K75KTNOO-Bouh9S6K.js → eventmodeling-K75KTNOO-B24F56y5.js} +1 -1
- package/dist/web/assets/flowDiagram-IUGLLWBU-DXv5cjup.js +1 -0
- package/dist/web/assets/{ganttDiagram-R7GPNTJY-C6JqImIF.js → ganttDiagram-R7GPNTJY-DqIqpS5W.js} +1 -1
- package/dist/web/assets/{gitGraph-VSP46ZUC-8sSFlknu.js → gitGraph-VSP46ZUC-CNkDi5d2.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PDYL7XHY-8PTJIwji.js → gitGraphDiagram-PDYL7XHY-hXfHsAUl.js} +1 -1
- package/dist/web/assets/{index-B565iZDe.css → index-CJhiAWU_.css} +1 -1
- package/dist/web/assets/{index-ApDxvBFa.js → index-CPjR9NI_.js} +15 -14
- package/dist/web/assets/{info-OHQRW6UA-zV705KAN.js → info-OHQRW6UA-DZGW96Y3.js} +1 -1
- package/dist/web/assets/{infoDiagram-MVDRKAX5-BXkNK714.js → infoDiagram-MVDRKAX5-C9UeusiS.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-HPEHV2GE-DqWLS6ge.js → ishikawaDiagram-HPEHV2GE--HXMPDsM.js} +1 -1
- package/dist/web/assets/{journeyDiagram-BOSHW7O7-De_S2cBU.js → journeyDiagram-BOSHW7O7-eFghSzTd.js} +1 -1
- package/dist/web/assets/{kanban-definition-FNSA4HC5-CMsQu53V.js → kanban-definition-FNSA4HC5-Dp5pHCpQ.js} +1 -1
- package/dist/web/assets/{line-DwA1hUEs.js → line-J416Rwo7.js} +1 -1
- package/dist/web/assets/{linear-DRJbI_Aw.js → linear-dcDMI4fS.js} +1 -1
- package/dist/web/assets/{mermaid-parser.core-c4ZovFHr.js → mermaid-parser.core-6EMrqqvY.js} +3 -3
- package/dist/web/assets/{mermaid.core-Cz_9uyD3.js → mermaid.core-_EZe9w4Q.js} +4 -4
- package/dist/web/assets/{mindmap-definition-6OY57UG3-Dyz9R3e3.js → mindmap-definition-6OY57UG3-BVBTKQ8N.js} +1 -1
- package/dist/web/assets/{packet-JDAUHWVQ-CU_qWGhS.js → packet-JDAUHWVQ-D4OpL_fK.js} +1 -1
- package/dist/web/assets/{pegDiagram-ECIUJNBX-B__QgSw5.js → pegDiagram-ECIUJNBX-DCpMX73b.js} +1 -1
- package/dist/web/assets/{pie-XZMESJXO-B103X70p.js → pie-XZMESJXO-B_mtTP5p.js} +1 -1
- package/dist/web/assets/{pieDiagram-GNMPY74T-DidrtQvv.js → pieDiagram-GNMPY74T-Dk6Or5Uv.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-D57K4MC3-Bun_QO6q.js → quadrantDiagram-D57K4MC3-BnSh6JoJ.js} +1 -1
- package/dist/web/assets/{radar-ABXABTNO-CBQBwTY2.js → radar-ABXABTNO-CoN9Pkqv.js} +1 -1
- package/dist/web/assets/{railroad-I3PHUGI6-BTfftaKm.js → railroad-I3PHUGI6-DxA2tnxP.js} +1 -1
- package/dist/web/assets/{railroad-abnf-LNEFI6M7-CD1IiV4A.js → railroad-abnf-LNEFI6M7-DkDJfzRH.js} +1 -1
- package/dist/web/assets/{railroad-ebnf-DWYD2UWJ-CvkyeA5e.js → railroad-ebnf-DWYD2UWJ-Bo0zFBCo.js} +1 -1
- package/dist/web/assets/{railroad-peg-JR7BVNR7-CYy1mYRh.js → railroad-peg-JR7BVNR7-D3JyY5On.js} +1 -1
- package/dist/web/assets/{railroadDiagram-Y72NRBL7-B4Ra33yv.js → railroadDiagram-Y72NRBL7-CYcoEReQ.js} +1 -1
- package/dist/web/assets/{requirementDiagram-EQYSW5RA-CCJN-Jru.js → requirementDiagram-EQYSW5RA-DutpDlKa.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-SY24JHO5-BO8ztHMO.js → sankeyDiagram-SY24JHO5-Fbmy8e4_.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-BLEHNHQU-CHGTOFOk.js → sequenceDiagram-BLEHNHQU-B8SNnYz7.js} +1 -1
- package/dist/web/assets/{src-B2489Ca1.js → src-hqM7f81e.js} +1 -1
- package/dist/web/assets/{stateDiagram-v2-A6IESKWZ-BlFZedC_.js → stateDiagram-v2-A6IESKWZ-e4xY7mwP.js} +1 -1
- package/dist/web/assets/{swimlanes-B3ENRKFQ-6lN1F8kM.js → swimlanes-B3ENRKFQ-CI3leNOt.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-AYQRV4AK-DiqLNgRn.js +8 -0
- package/dist/web/assets/{timeline-definition-JXYKGLGB-C4dWJ3yz.js → timeline-definition-JXYKGLGB-D95GU6j8.js} +1 -1
- package/dist/web/assets/{treeView-D4JQ5SDB-CdID1eHR.js → treeView-D4JQ5SDB-Bsp-gDES.js} +1 -1
- package/dist/web/assets/{treemap-SAJKECNS-BjUWV6A_.js → treemap-SAJKECNS-DSI1aNHS.js} +1 -1
- package/dist/web/assets/{usecaseDiagram-WPOLBNNX-CvzHFCsX.js → usecaseDiagram-WPOLBNNX-DfD2COFw.js} +1 -1
- package/dist/web/assets/{vennDiagram-Q3Y3IDCW-BdU35j8g.js → vennDiagram-Q3Y3IDCW-DXUg2b7J.js} +1 -1
- package/dist/web/assets/{wardley-7MLQ67FV-B85NDF6v.js → wardley-7MLQ67FV-E0PgYABo.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-IVAIDKWA-DEzv-p3a.js → wardleyDiagram-IVAIDKWA-PNByLwH3.js} +1 -1
- package/dist/web/assets/{xychartDiagram-4URNHDU4-B1ck_pTM.js → xychartDiagram-4URNHDU4-DP2Jd2fL.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +6 -6
- package/dist/web/assets/channel-hEaJUY_g.js +0 -1
- package/dist/web/assets/flowDiagram-IUGLLWBU-Cmf_WJgx.js +0 -1
- package/dist/web/assets/swimlanesDiagram-AYQRV4AK-DLgtIkQE.js +0 -8
package/dist/server/service.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
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";
|
|
1
4
|
import { hasSkillToken } from "../shared/skills.js";
|
|
2
5
|
import { CapacityRetries } from "./capacity-retry.js";
|
|
3
6
|
import { isModelCapacityError } from "../shared/turn-errors.js";
|
|
@@ -41,6 +44,7 @@ class GatewayService {
|
|
|
41
44
|
this.options = options;
|
|
42
45
|
this.store = options.store;
|
|
43
46
|
this.turnUsage = new TurnUsageStore(this.store.database);
|
|
47
|
+
this.questionTracking = new QuestionTrackingStore(this.store.database);
|
|
44
48
|
this.projects = options.projects;
|
|
45
49
|
this.workspaces = new WorkspaceRegistry(
|
|
46
50
|
this.store.database,
|
|
@@ -76,6 +80,7 @@ class GatewayService {
|
|
|
76
80
|
projection;
|
|
77
81
|
store;
|
|
78
82
|
turnUsage;
|
|
83
|
+
questionTracking;
|
|
79
84
|
projects;
|
|
80
85
|
workspaces;
|
|
81
86
|
codex;
|
|
@@ -594,7 +599,7 @@ class GatewayService {
|
|
|
594
599
|
const thread = this.projection.get(threadId);
|
|
595
600
|
if (!thread) return [];
|
|
596
601
|
this.workspaces.assertOwnership(thread.projectId, thread.cwd, thread.id);
|
|
597
|
-
return pendingAttention(thread);
|
|
602
|
+
return pendingAttention(this.threadView(thread));
|
|
598
603
|
}
|
|
599
604
|
async getThreadSnapshot(threadId) {
|
|
600
605
|
await this.getThread(threadId);
|
|
@@ -620,7 +625,7 @@ class GatewayService {
|
|
|
620
625
|
const root = links.get(turn.id);
|
|
621
626
|
if (root) turn.retryOf = root;
|
|
622
627
|
}
|
|
623
|
-
return page;
|
|
628
|
+
return this.threadView(page);
|
|
624
629
|
}
|
|
625
630
|
async exportThread(threadId) {
|
|
626
631
|
this.ensureReady();
|
|
@@ -921,6 +926,8 @@ class GatewayService {
|
|
|
921
926
|
if (isActive(this.projection.get(threadId)?.status ?? thread.status))
|
|
922
927
|
throw new AppError("THREAD_BUSY", "Session already has an active task", 409);
|
|
923
928
|
}
|
|
929
|
+
if (parseQuestionReplies(input.text))
|
|
930
|
+
await this.claimQuestionReplies(threadId, input.text, input.clientOperationId);
|
|
924
931
|
const message = {
|
|
925
932
|
...input,
|
|
926
933
|
text: input.taskKind === "init" ? PROJECT_INIT_PROMPT : input.text
|
|
@@ -1191,6 +1198,8 @@ class GatewayService {
|
|
|
1191
1198
|
409
|
|
1192
1199
|
);
|
|
1193
1200
|
this.ensureCompatibilityConfirmed();
|
|
1201
|
+
if (parseQuestionReplies(input.text))
|
|
1202
|
+
await this.claimQuestionReplies(threadId, input.text, input.clientOperationId);
|
|
1194
1203
|
this.store.dispatch(input.clientOperationId, void 0, {
|
|
1195
1204
|
threadId,
|
|
1196
1205
|
turnId: input.expectedTurnId,
|
|
@@ -1279,9 +1288,88 @@ class GatewayService {
|
|
|
1279
1288
|
this.projection.resolveAction(actionId, "responding");
|
|
1280
1289
|
if (action.threadId) this.publishThread(action.threadId);
|
|
1281
1290
|
await this.codex.respond(actionId, input.resolution);
|
|
1291
|
+
if (action.kind === "questions") {
|
|
1292
|
+
this.projection.resolveAction(actionId, "responded");
|
|
1293
|
+
this.questionTracking.saveAction(
|
|
1294
|
+
action,
|
|
1295
|
+
questionAnswers(action.questions ?? [], input.resolution)
|
|
1296
|
+
);
|
|
1297
|
+
if (action.threadId) this.publishThread(action.threadId);
|
|
1298
|
+
}
|
|
1282
1299
|
return { result: { actionId } };
|
|
1283
1300
|
});
|
|
1284
1301
|
}
|
|
1302
|
+
/** This ends Covro tracking only. It must never start/steer/interrupt a native turn. */
|
|
1303
|
+
async dismissQuestions(threadId, input) {
|
|
1304
|
+
return this.perform("question.dismiss", threadId, input, async () => {
|
|
1305
|
+
await this.loadThread(threadId);
|
|
1306
|
+
const history = this.normalize(await this.codex.readThread(threadId));
|
|
1307
|
+
this.workspaces.assertOwnership(history.projectId, history.cwd, history.id);
|
|
1308
|
+
this.projection.thread(history, true);
|
|
1309
|
+
const states = this.questionTracking.states(threadId);
|
|
1310
|
+
for (const id of new Set(input.questionIds)) {
|
|
1311
|
+
const question = this.findAsyncQuestion(history, id);
|
|
1312
|
+
if (!question) throw new AppError("QUESTION_EXPIRED", "\u8BE5\u95EE\u9898\u5DF2\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5237\u65B0\u4F1A\u8BDD", 409);
|
|
1313
|
+
if (this.questionAnswered(history, id)) continue;
|
|
1314
|
+
if (states[id] && states[id].status !== "dismissed")
|
|
1315
|
+
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);
|
|
1316
|
+
}
|
|
1317
|
+
const ids = [...new Set(input.questionIds)].filter(
|
|
1318
|
+
(id) => !this.questionAnswered(history, id)
|
|
1319
|
+
);
|
|
1320
|
+
this.store.dispatch(input.clientOperationId);
|
|
1321
|
+
this.questionTracking.save(threadId, ids, "dismissed", input.clientOperationId);
|
|
1322
|
+
this.publishThread(threadId);
|
|
1323
|
+
return { result: { threadId, questionIds: ids } };
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
questionItems(history) {
|
|
1327
|
+
return [...history.turns, ...this.projection.get(history.id)?.turns ?? []].flatMap(
|
|
1328
|
+
(turn) => turn.items
|
|
1329
|
+
);
|
|
1330
|
+
}
|
|
1331
|
+
findAsyncQuestion(history, id) {
|
|
1332
|
+
for (const item of this.questionItems(history)) {
|
|
1333
|
+
if (item.type !== "agentMessage") continue;
|
|
1334
|
+
const index = item.questions?.findIndex((_, index2) => asyncQuestionId(item.id, index2) === id);
|
|
1335
|
+
if (index !== void 0 && index >= 0) return { item, question: item.questions[index] };
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
questionAnswered(history, id) {
|
|
1339
|
+
const source = this.findAsyncQuestion(history, id);
|
|
1340
|
+
return Boolean(
|
|
1341
|
+
source && this.questionItems(history).some(
|
|
1342
|
+
(item) => item.questionReplies?.some(
|
|
1343
|
+
(reply) => reply.questionItemId === id || reply.questionItemId === source.item.id && reply.question === source.question.title
|
|
1344
|
+
)
|
|
1345
|
+
)
|
|
1346
|
+
);
|
|
1347
|
+
}
|
|
1348
|
+
async claimQuestionReplies(threadId, text, operationId) {
|
|
1349
|
+
const replies = parseQuestionReplies(text);
|
|
1350
|
+
if (!replies) return;
|
|
1351
|
+
const history = this.normalize(await this.codex.readThread(threadId));
|
|
1352
|
+
this.workspaces.assertOwnership(history.projectId, history.cwd, history.id);
|
|
1353
|
+
this.projection.thread(history, true);
|
|
1354
|
+
const states = this.questionTracking.states(threadId);
|
|
1355
|
+
const ids = [];
|
|
1356
|
+
for (const reply of replies) {
|
|
1357
|
+
const source = this.findAsyncQuestion(history, reply.questionItemId) ?? (() => {
|
|
1358
|
+
const item = this.questionItems(history).find((item2) => item2.id === reply.questionItemId);
|
|
1359
|
+
const index2 = item?.questions?.findIndex((q) => q.title === reply.question);
|
|
1360
|
+
return item && index2 !== void 0 && index2 >= 0 ? this.findAsyncQuestion(history, asyncQuestionId(item.id, index2)) : void 0;
|
|
1361
|
+
})();
|
|
1362
|
+
const index = source?.item.questions?.indexOf(source.question);
|
|
1363
|
+
if (!source || index === void 0)
|
|
1364
|
+
throw new AppError("QUESTION_EXPIRED", "\u8BE5\u95EE\u9898\u5DF2\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5237\u65B0\u4F1A\u8BDD", 409);
|
|
1365
|
+
if (!reply.answer.trim()) throw new AppError("VALIDATION_ERROR", "\u56DE\u7B54\u4E0D\u80FD\u4E3A\u7A7A");
|
|
1366
|
+
const id = asyncQuestionId(source.item.id, index);
|
|
1367
|
+
if (states[id] || this.questionAnswered(history, id) || ids.includes(id))
|
|
1368
|
+
throw new AppError("QUESTION_CONFLICT", "\u8BE5\u95EE\u9898\u5DF2\u5904\u7406\u6216\u6B63\u5728\u63D0\u4EA4\uFF0C\u8BF7\u5237\u65B0\u4F1A\u8BDD", 409);
|
|
1369
|
+
ids.push(id);
|
|
1370
|
+
}
|
|
1371
|
+
this.questionTracking.save(threadId, ids, "submitting", operationId);
|
|
1372
|
+
}
|
|
1285
1373
|
getOperation(id) {
|
|
1286
1374
|
const row = this.store.get(id);
|
|
1287
1375
|
if (!row) throw new AppError("OPERATION_NOT_FOUND", "\u672A\u627E\u5230\u8BE5\u64CD\u4F5C", 404);
|
|
@@ -1389,6 +1477,10 @@ class GatewayService {
|
|
|
1389
1477
|
const action = this.projection.resolveAction(target, "pending");
|
|
1390
1478
|
if (action?.threadId) this.publishThread(action.threadId);
|
|
1391
1479
|
}
|
|
1480
|
+
if (!uncertain && (kind === "turn.start" || kind === "turn.steer")) {
|
|
1481
|
+
this.questionTracking.release(input.clientOperationId);
|
|
1482
|
+
this.publishThread(target);
|
|
1483
|
+
}
|
|
1392
1484
|
if (kind === "turn.start")
|
|
1393
1485
|
this.capacityRetries.dispatchFailed(target, input.clientOperationId);
|
|
1394
1486
|
if (dispatched && (kind === "turn.start" || kind === "turn.steer"))
|
|
@@ -1549,19 +1641,7 @@ class GatewayService {
|
|
|
1549
1641
|
} else if (action.kind === "elicitation") {
|
|
1550
1642
|
validateElicitationResolution(action.elicitation, resolution);
|
|
1551
1643
|
} else if (action.kind === "questions") {
|
|
1552
|
-
|
|
1553
|
-
const questions = action.questions ?? [];
|
|
1554
|
-
if (Object.keys(resolution.answers).some(
|
|
1555
|
-
(id) => !questions.some((question) => question.id === id)
|
|
1556
|
-
))
|
|
1557
|
-
throw new AppError("VALIDATION_ERROR", "\u56DE\u7B54\u5305\u542B\u672A\u77E5\u95EE\u9898");
|
|
1558
|
-
for (const question of questions) {
|
|
1559
|
-
const answers = resolution.answers[question.id];
|
|
1560
|
-
if (!answers?.length || answers.some(
|
|
1561
|
-
(answer) => !answer.trim() || !question.isOther && question.options.length > 0 && !question.options.some((option) => option.label === answer)
|
|
1562
|
-
))
|
|
1563
|
-
throw new AppError("VALIDATION_ERROR", `\u95EE\u9898 ${question.header} \u7684\u56DE\u7B54\u4E0D\u7B26\u5408\u9009\u9879\u8981\u6C42`);
|
|
1564
|
-
}
|
|
1644
|
+
questionAnswers(action.questions ?? [], resolution);
|
|
1565
1645
|
} else if (!("decision" in resolution) || "content" in resolution || "persist" in resolution || !action.options.some((option) => option.id === resolution.decision))
|
|
1566
1646
|
throw new AppError("VALIDATION_ERROR", "\u8BF7\u9009\u62E9\u4E0A\u6E38\u63D0\u4F9B\u7684\u5408\u6CD5\u9009\u9879");
|
|
1567
1647
|
}
|
|
@@ -1662,6 +1742,13 @@ class GatewayService {
|
|
|
1662
1742
|
if (retry) result.capacityRetry = structuredClone(retry);
|
|
1663
1743
|
else delete result.capacityRetry;
|
|
1664
1744
|
if (this.capacityRetries.pending(thread.id)) result.status = "running";
|
|
1745
|
+
result.questionTracking = this.questionTracking.states(thread.id);
|
|
1746
|
+
const savedActions = this.questionTracking.actions(thread.id);
|
|
1747
|
+
const actions = new Map(savedActions.map((action) => [action.actionId, action]));
|
|
1748
|
+
for (const action of thread.actions)
|
|
1749
|
+
if (action.status === "pending" || action.status === "responding" || !actions.has(action.actionId))
|
|
1750
|
+
actions.set(action.actionId, action);
|
|
1751
|
+
result.actions = [...actions.values()];
|
|
1665
1752
|
result.archived = thread.archived ?? false;
|
|
1666
1753
|
result.historyVisible = this.historyVisible(thread);
|
|
1667
1754
|
const marker = this.store.activeForThread(thread.id);
|
|
@@ -1758,8 +1845,11 @@ class GatewayService {
|
|
|
1758
1845
|
if (action.codexEpoch !== this.codex.epoch) return;
|
|
1759
1846
|
const known = this.projection.actions.has(action.actionId);
|
|
1760
1847
|
const owner = action.threadId ? this.projection.get(action.threadId) : void 0;
|
|
1761
|
-
const previous = new Set(
|
|
1848
|
+
const previous = new Set(
|
|
1849
|
+
owner ? pendingAttention(this.threadView(owner)).map(attentionKey) : []
|
|
1850
|
+
);
|
|
1762
1851
|
this.projection.action(action);
|
|
1852
|
+
if (action.kind === "questions") this.questionTracking.saveAction(action);
|
|
1763
1853
|
if (action.threadId) {
|
|
1764
1854
|
this.publishThread(action.threadId);
|
|
1765
1855
|
if (!known) this.publishNewAttention(action.threadId, previous);
|
|
@@ -1768,6 +1858,7 @@ class GatewayService {
|
|
|
1768
1858
|
}
|
|
1769
1859
|
if (event.type === "actionResolved") {
|
|
1770
1860
|
const action = this.projection.resolveAction(event.actionId, "responded");
|
|
1861
|
+
if (action?.kind === "questions") this.questionTracking.saveAction(action);
|
|
1771
1862
|
if (action?.threadId) this.publishThread(action.threadId);
|
|
1772
1863
|
return;
|
|
1773
1864
|
}
|
|
@@ -1785,7 +1876,7 @@ class GatewayService {
|
|
|
1785
1876
|
return;
|
|
1786
1877
|
}
|
|
1787
1878
|
const previousAttention = new Set(
|
|
1788
|
-
event.type === "item" || event.type === "turn" ? pendingAttention(thread).map(attentionKey) : []
|
|
1879
|
+
event.type === "item" || event.type === "turn" ? pendingAttention(this.threadView(thread)).map(attentionKey) : []
|
|
1789
1880
|
);
|
|
1790
1881
|
if (event.type === "tokenUsage") {
|
|
1791
1882
|
if (this.projection.tokenUsage(thread.id, event.usage)) this.publishThread(thread.id);
|