@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/codex/adapter.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { questionAnswers } from "../shared/question-resolution.js";
|
|
2
|
+
import { nullLogger } from "../logging/logger.js";
|
|
3
|
+
import { errorFields } from "../logging/fields.js";
|
|
4
|
+
import { logContext, withLogContext } from "../logging/context.js";
|
|
1
5
|
import { CODEX_COMPATIBILITY } from "./compatibility.js";
|
|
2
6
|
import { AccountUsageReader } from "./account-usage.js";
|
|
3
7
|
import { SHELL_TIMEOUT_MS, SHELL_OUTPUT_BYTES } from "../shared/shell.js";
|
|
@@ -46,7 +50,7 @@ import {
|
|
|
46
50
|
} from "./transport.js";
|
|
47
51
|
import { CodexError as CodexError2 } from "./transport.js";
|
|
48
52
|
const VERIFIED_CODEX_VERSION = CODEX_COMPATIBILITY.recommended;
|
|
49
|
-
const LIVE_SETTINGS_CODEX_VERSION = "0.
|
|
53
|
+
const LIVE_SETTINGS_CODEX_VERSION = "0.167.0";
|
|
50
54
|
const CAPABILITIES = [
|
|
51
55
|
"command/exec",
|
|
52
56
|
"command/exec/terminate",
|
|
@@ -72,6 +76,7 @@ const CAPABILITIES = [
|
|
|
72
76
|
"turn/interrupt",
|
|
73
77
|
"model/list",
|
|
74
78
|
"skills/list",
|
|
79
|
+
"fuzzyFileSearch",
|
|
75
80
|
"config/read",
|
|
76
81
|
"config/batchWrite",
|
|
77
82
|
"configRequirements/read",
|
|
@@ -102,6 +107,7 @@ function permissionPathLabel(path) {
|
|
|
102
107
|
class CodexAdapter {
|
|
103
108
|
constructor(options) {
|
|
104
109
|
this.options = options;
|
|
110
|
+
this.logger = (options.logger ?? nullLogger).child({ component: "codex" });
|
|
105
111
|
}
|
|
106
112
|
options;
|
|
107
113
|
accountUsage = new AccountUsageReader({
|
|
@@ -153,6 +159,7 @@ class CodexAdapter {
|
|
|
153
159
|
models: [],
|
|
154
160
|
capabilities: []
|
|
155
161
|
};
|
|
162
|
+
logger;
|
|
156
163
|
get pid() {
|
|
157
164
|
return this.child?.pid;
|
|
158
165
|
}
|
|
@@ -209,6 +216,7 @@ class CodexAdapter {
|
|
|
209
216
|
});
|
|
210
217
|
const version = stdout.trim().replace(/^codex-cli\s+/, "");
|
|
211
218
|
this.state.codexVersion = version;
|
|
219
|
+
this.logger.info("codex.starting", { codexEpoch: this.epoch, codexVersion: version });
|
|
212
220
|
this.permissionState.clear();
|
|
213
221
|
this.liveCapabilities.clear();
|
|
214
222
|
this.denials.clear();
|
|
@@ -224,10 +232,15 @@ class CodexAdapter {
|
|
|
224
232
|
this.child = child;
|
|
225
233
|
const rpc = new RpcTransport(child.stdin, child.stdout, {
|
|
226
234
|
timeoutMs: this.options.requestTimeoutMs,
|
|
227
|
-
maxLineBytes: this.options.maxLineBytes
|
|
235
|
+
maxLineBytes: this.options.maxLineBytes,
|
|
236
|
+
logger: this.logger.child({ codexEpoch: this.epoch, component: "codex.rpc" })
|
|
228
237
|
});
|
|
229
238
|
this.rpc = rpc;
|
|
230
|
-
this.titles = new ThreadTitles(
|
|
239
|
+
this.titles = new ThreadTitles(
|
|
240
|
+
rpc,
|
|
241
|
+
this.options.titleTimeoutMs,
|
|
242
|
+
this.logger.child({ codexEpoch: this.epoch, component: "codex.titles" })
|
|
243
|
+
);
|
|
231
244
|
child.stderr.on("data", (chunk) => {
|
|
232
245
|
const max = this.options.maxStderrBytes ?? 64 * 1024;
|
|
233
246
|
this.stderrTail = Buffer.concat([this.stderrTail, chunk.subarray(-max)]).subarray(-max);
|
|
@@ -237,6 +250,12 @@ class CodexAdapter {
|
|
|
237
250
|
(error) => rpc.fail(new CodexError("CODEX_UNAVAILABLE", `Cannot start Codex: ${error.message}`, true))
|
|
238
251
|
);
|
|
239
252
|
child.on("exit", (code, signal) => {
|
|
253
|
+
this.logger[this.stopped ? "info" : "error"]("codex.exited", {
|
|
254
|
+
codexEpoch: this.epoch,
|
|
255
|
+
exitCode: code,
|
|
256
|
+
signal,
|
|
257
|
+
receivedBytes: this.stderrTail.length
|
|
258
|
+
});
|
|
240
259
|
rpc.fail(
|
|
241
260
|
new CodexError(
|
|
242
261
|
"CODEX_UNAVAILABLE",
|
|
@@ -275,22 +294,24 @@ class CodexAdapter {
|
|
|
275
294
|
kill.unref();
|
|
276
295
|
child.once("exit", () => clearTimeout(kill));
|
|
277
296
|
if (wasReady && !this.stopped) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
...error
|
|
297
|
+
this.logger.error("codex.connection_failed", {
|
|
298
|
+
codexEpoch: this.epoch,
|
|
299
|
+
...errorFields(error)
|
|
281
300
|
});
|
|
282
301
|
this.scheduleRestart();
|
|
283
302
|
}
|
|
284
303
|
});
|
|
304
|
+
const capabilities = {
|
|
305
|
+
experimentalApi: true,
|
|
306
|
+
requiredHumanApproval: true,
|
|
307
|
+
requestAttestation: false,
|
|
308
|
+
explicitGatewayOauth: true
|
|
309
|
+
};
|
|
285
310
|
const initialized = await this.call(
|
|
286
311
|
"initialize",
|
|
287
312
|
{
|
|
288
313
|
clientInfo: { name: "codex_web_ui", title: "Codex Web UI", version: "0.1.0" },
|
|
289
|
-
capabilities
|
|
290
|
-
experimentalApi: true,
|
|
291
|
-
requestAttestation: false,
|
|
292
|
-
explicitGatewayOauth: true
|
|
293
|
-
}
|
|
314
|
+
capabilities
|
|
294
315
|
},
|
|
295
316
|
true
|
|
296
317
|
);
|
|
@@ -347,11 +368,16 @@ class CodexAdapter {
|
|
|
347
368
|
);
|
|
348
369
|
this.state.ready = true;
|
|
349
370
|
this.state.connection = "ready";
|
|
371
|
+
this.logger.info("codex.ready", {
|
|
372
|
+
codexEpoch: this.epoch,
|
|
373
|
+
codexVersion: this.state.codexVersion
|
|
374
|
+
});
|
|
350
375
|
this.state.capabilities = CAPABILITIES.filter((method) => !this.disabled.has(method));
|
|
351
376
|
this.publishRuntime();
|
|
352
377
|
void this.refreshAccountUsage();
|
|
353
378
|
} catch (error) {
|
|
354
379
|
const failure = asCodexError(error);
|
|
380
|
+
this.logger.error("codex.start_failed", { codexEpoch: this.epoch, ...errorFields(failure) });
|
|
355
381
|
this.state.ready = false;
|
|
356
382
|
this.state.connection = "unavailable";
|
|
357
383
|
this.state.error = failure.message;
|
|
@@ -455,6 +481,7 @@ class CodexAdapter {
|
|
|
455
481
|
cursor,
|
|
456
482
|
limit: 30,
|
|
457
483
|
archived,
|
|
484
|
+
modelProviders: [],
|
|
458
485
|
sourceKinds: ["cli", "appServer", "vscode"],
|
|
459
486
|
sortKey: "updated_at",
|
|
460
487
|
sortDirection: "desc"
|
|
@@ -487,6 +514,7 @@ class CodexAdapter {
|
|
|
487
514
|
const page = await this.call("thread/list", {
|
|
488
515
|
archived: true,
|
|
489
516
|
cwd: thread.cwd,
|
|
517
|
+
modelProviders: [],
|
|
490
518
|
cursor,
|
|
491
519
|
limit: 100,
|
|
492
520
|
sourceKinds: [
|
|
@@ -904,6 +932,59 @@ class CodexAdapter {
|
|
|
904
932
|
);
|
|
905
933
|
}
|
|
906
934
|
}
|
|
935
|
+
fileSearches = 0;
|
|
936
|
+
async searchFiles(cwd, query, signal) {
|
|
937
|
+
signal.throwIfAborted();
|
|
938
|
+
if (this.fileSearches >= 4)
|
|
939
|
+
throw new AppError("FILE_SEARCH_BUSY", "File search is busy; retry shortly", 429);
|
|
940
|
+
const cancellationToken = crypto.randomUUID();
|
|
941
|
+
const epoch = this.epoch;
|
|
942
|
+
const { requestId, operationId, threadId, sourceThreadId, turnId } = logContext();
|
|
943
|
+
const context = {
|
|
944
|
+
requestId,
|
|
945
|
+
operationId,
|
|
946
|
+
threadId,
|
|
947
|
+
sourceThreadId,
|
|
948
|
+
turnId,
|
|
949
|
+
jobId: cancellationToken,
|
|
950
|
+
codexEpoch: epoch
|
|
951
|
+
};
|
|
952
|
+
const logger = this.logger.child({ ...context, component: "file_search" });
|
|
953
|
+
const started = performance.now();
|
|
954
|
+
this.fileSearches++;
|
|
955
|
+
const pending = withLogContext(
|
|
956
|
+
context,
|
|
957
|
+
() => this.call("fuzzyFileSearch", { query, roots: [cwd], cancellationToken }, false, 6500)
|
|
958
|
+
).finally(() => {
|
|
959
|
+
this.fileSearches--;
|
|
960
|
+
});
|
|
961
|
+
let abort = () => {
|
|
962
|
+
};
|
|
963
|
+
const cancelled = new Promise((_, reject) => {
|
|
964
|
+
abort = () => withLogContext(context, () => {
|
|
965
|
+
if (this.ready && this.epoch === epoch)
|
|
966
|
+
void this.call(
|
|
967
|
+
"fuzzyFileSearch",
|
|
968
|
+
{ query: "", roots: [], cancellationToken },
|
|
969
|
+
false,
|
|
970
|
+
1500
|
|
971
|
+
).catch(() => {
|
|
972
|
+
});
|
|
973
|
+
logger.debug("file_search.cancelled", {
|
|
974
|
+
reason: signal.reason instanceof DOMException && signal.reason.name === "TimeoutError" ? "timeout" : "aborted",
|
|
975
|
+
durationMs: Math.round(performance.now() - started)
|
|
976
|
+
});
|
|
977
|
+
reject(signal.reason);
|
|
978
|
+
});
|
|
979
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
980
|
+
if (signal.aborted) abort();
|
|
981
|
+
});
|
|
982
|
+
try {
|
|
983
|
+
return await Promise.race([pending, cancelled]);
|
|
984
|
+
} finally {
|
|
985
|
+
signal.removeEventListener("abort", abort);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
907
988
|
async listSkills(cwd, forceReload = false) {
|
|
908
989
|
const result = await this.call("skills/list", { cwds: [cwd], forceReload });
|
|
909
990
|
const entries = result.data.filter((entry) => entry.cwd === cwd);
|
|
@@ -915,15 +996,17 @@ class CodexAdapter {
|
|
|
915
996
|
);
|
|
916
997
|
return entries[0];
|
|
917
998
|
}
|
|
918
|
-
async startTurn(id, cwd, text, settings, images, skills) {
|
|
999
|
+
async startTurn(id, cwd, text, settings, images, skills, clientUserMessageId) {
|
|
919
1000
|
this.validateSettings(settings, this.permissionState.get(id));
|
|
920
1001
|
await this.validatePermissionSettings(cwd, settings, id);
|
|
1002
|
+
this.titles?.trackUserInput(id);
|
|
921
1003
|
const turn = mapTurn(
|
|
922
1004
|
id,
|
|
923
1005
|
(await this.call("turn/start", {
|
|
924
1006
|
threadId: id,
|
|
925
1007
|
cwd,
|
|
926
1008
|
input: taskInput(text, images, skills),
|
|
1009
|
+
...clientUserMessageId ? { clientUserMessageId } : {},
|
|
927
1010
|
...turnSettings(cwd, settings),
|
|
928
1011
|
...collaborationSelection(settings, this.permissionState.get(id))
|
|
929
1012
|
})).turn
|
|
@@ -986,11 +1069,12 @@ class CodexAdapter {
|
|
|
986
1069
|
);
|
|
987
1070
|
return mapTurn(id, result.turn);
|
|
988
1071
|
}
|
|
989
|
-
steerTurn(id, turnId, text, images) {
|
|
1072
|
+
steerTurn(id, turnId, text, images, clientUserMessageId) {
|
|
990
1073
|
return this.call("turn/steer", {
|
|
991
1074
|
threadId: id,
|
|
992
1075
|
expectedTurnId: turnId,
|
|
993
|
-
input: taskInput(text, images)
|
|
1076
|
+
input: taskInput(text, images),
|
|
1077
|
+
...clientUserMessageId ? { clientUserMessageId } : {}
|
|
994
1078
|
});
|
|
995
1079
|
}
|
|
996
1080
|
async interruptTurn(id, turnId) {
|
|
@@ -1162,6 +1246,15 @@ class CodexAdapter {
|
|
|
1162
1246
|
...totalTokens !== void 0 ? { totalTokens } : {}
|
|
1163
1247
|
}
|
|
1164
1248
|
});
|
|
1249
|
+
this.logger.info(event.method === "turn/completed" ? "turn.completed" : "turn.started", {
|
|
1250
|
+
threadId,
|
|
1251
|
+
turnId: turn.id,
|
|
1252
|
+
codexEpoch: this.epoch,
|
|
1253
|
+
outcome: turn.status,
|
|
1254
|
+
...turn.error ? {
|
|
1255
|
+
errorCode: turn.error.codexErrorInfo && typeof turn.error.codexErrorInfo === "string" ? turn.error.codexErrorInfo : "TURN_FAILED"
|
|
1256
|
+
} : {}
|
|
1257
|
+
});
|
|
1165
1258
|
if (event.method === "turn/completed")
|
|
1166
1259
|
this.expireActions(event.params.threadId, event.params.turn.id);
|
|
1167
1260
|
break;
|
|
@@ -1264,6 +1357,8 @@ class CodexAdapter {
|
|
|
1264
1357
|
case "serverRequest/resolved": {
|
|
1265
1358
|
const actionId = this.actionIds.get(event.params.requestId);
|
|
1266
1359
|
if (actionId) {
|
|
1360
|
+
const action = this.actions.get(actionId)?.action;
|
|
1361
|
+
if (action) this.actionLogger(action).info("action.resolved");
|
|
1267
1362
|
this.emit({ type: "actionResolved", actionId });
|
|
1268
1363
|
this.actions.delete(actionId);
|
|
1269
1364
|
this.actionIds.delete(event.params.requestId);
|
|
@@ -1285,6 +1380,12 @@ class CodexAdapter {
|
|
|
1285
1380
|
}
|
|
1286
1381
|
}
|
|
1287
1382
|
async serverRequest(message) {
|
|
1383
|
+
const existingId = this.actionIds.get(message.id);
|
|
1384
|
+
if (existingId) {
|
|
1385
|
+
const action2 = this.actions.get(existingId)?.action;
|
|
1386
|
+
if (action2) this.actionLogger(action2).debug("action.replayed", { replayed: true });
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1288
1389
|
if (isRecord(message.params) && this.titles?.isInternal(message.params.threadId)) {
|
|
1289
1390
|
await this.rpc?.reject(
|
|
1290
1391
|
message.id,
|
|
@@ -1308,18 +1409,21 @@ class CodexAdapter {
|
|
|
1308
1409
|
};
|
|
1309
1410
|
const decisions = /* @__PURE__ */ new Map();
|
|
1310
1411
|
if (request.method === "item/commandExecution/requestApproval" || request.method === "item/fileChange/requestApproval") {
|
|
1412
|
+
const humanCommand = request.method === "item/commandExecution/requestApproval" && params.kind === "humanCommand";
|
|
1311
1413
|
for (const [id, label] of [
|
|
1312
1414
|
["accept", "\u5141\u8BB8\u672C\u6B21"],
|
|
1313
1415
|
["acceptForSession", "\u672C\u4F1A\u8BDD\u5141\u8BB8"],
|
|
1314
1416
|
["decline", "\u62D2\u7EDD"],
|
|
1315
1417
|
["cancel", "\u53D6\u6D88\u5F53\u524D\u4EFB\u52A1"]
|
|
1316
1418
|
]) {
|
|
1419
|
+
if (humanCommand && id === "acceptForSession") continue;
|
|
1317
1420
|
action.options.push({ id, label });
|
|
1318
1421
|
decisions.set(id, id);
|
|
1319
1422
|
}
|
|
1320
1423
|
action.reason = request.params.reason ?? void 0;
|
|
1321
1424
|
if (request.method === "item/commandExecution/requestApproval") {
|
|
1322
1425
|
const p = request.params;
|
|
1426
|
+
if (humanCommand) action.requiresHumanApproval = true;
|
|
1323
1427
|
action.kind = p.networkApprovalContext ? "network" : "command";
|
|
1324
1428
|
action.title = p.networkApprovalContext ? `\u7F51\u7EDC\u6743\u9650\uFF1A${p.networkApprovalContext.protocol}://${p.networkApprovalContext.host}` : "\u547D\u4EE4\u5BA1\u6279";
|
|
1325
1429
|
action.command = p.command ?? void 0;
|
|
@@ -1329,7 +1433,7 @@ class CodexAdapter {
|
|
|
1329
1433
|
network: p.networkApprovalContext,
|
|
1330
1434
|
commandActions: p.commandActions
|
|
1331
1435
|
};
|
|
1332
|
-
if (p.proposedExecpolicyAmendment) {
|
|
1436
|
+
if (!humanCommand && p.proposedExecpolicyAmendment) {
|
|
1333
1437
|
action.options.push({
|
|
1334
1438
|
id: "acceptWithRule",
|
|
1335
1439
|
label: `\u5141\u8BB8\u5E76\u8BB0\u4F4F\u547D\u4EE4\u89C4\u5219\uFF1A${p.proposedExecpolicyAmendment.join(" ")}`
|
|
@@ -1338,13 +1442,14 @@ class CodexAdapter {
|
|
|
1338
1442
|
acceptWithExecpolicyAmendment: { execpolicy_amendment: p.proposedExecpolicyAmendment }
|
|
1339
1443
|
});
|
|
1340
1444
|
}
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1445
|
+
if (!humanCommand)
|
|
1446
|
+
p.proposedNetworkPolicyAmendments?.forEach((amendment, index) => {
|
|
1447
|
+
const id = `networkRule:${index}`;
|
|
1448
|
+
action.options.push({ id, label: `\u5E94\u7528\u7F51\u7EDC\u89C4\u5219\uFF1A${JSON.stringify(amendment)}` });
|
|
1449
|
+
decisions.set(id, {
|
|
1450
|
+
applyNetworkPolicyAmendment: { network_policy_amendment: amendment }
|
|
1451
|
+
});
|
|
1346
1452
|
});
|
|
1347
|
-
});
|
|
1348
1453
|
} else {
|
|
1349
1454
|
action.kind = "file";
|
|
1350
1455
|
action.title = "\u6587\u4EF6\u53D8\u66F4\u5BA1\u6279";
|
|
@@ -1421,6 +1526,7 @@ class CodexAdapter {
|
|
|
1421
1526
|
}
|
|
1422
1527
|
this.actions.set(action.actionId, { action, request, decisions, responding: false });
|
|
1423
1528
|
this.actionIds.set(message.id, action.actionId);
|
|
1529
|
+
this.actionLogger(action).info("action.requested");
|
|
1424
1530
|
this.emit({ type: "action", action: structuredClone(action) });
|
|
1425
1531
|
}
|
|
1426
1532
|
async respond(actionId, resolution) {
|
|
@@ -1450,22 +1556,7 @@ class CodexAdapter {
|
|
|
1450
1556
|
_meta: "decision" in resolution && resolution.persist === "session" ? { persist: "session" } : null
|
|
1451
1557
|
};
|
|
1452
1558
|
} else if (context.request.method === "item/tool/requestUserInput") {
|
|
1453
|
-
|
|
1454
|
-
throw new AppError("VALIDATION_ERROR", "\u6B64\u8BF7\u6C42\u9700\u8981\u7ED3\u6784\u5316\u56DE\u7B54");
|
|
1455
|
-
const questions = context.request.params.questions;
|
|
1456
|
-
const ids = new Set(questions.map((question) => question.id));
|
|
1457
|
-
if (Object.keys(resolution.answers).some((id) => !ids.has(id)))
|
|
1458
|
-
throw new AppError("VALIDATION_ERROR", "\u56DE\u7B54\u5305\u542B\u672A\u77E5\u9898\u76EE");
|
|
1459
|
-
const answers = {};
|
|
1460
|
-
for (const question of questions) {
|
|
1461
|
-
const values = resolution.answers[question.id];
|
|
1462
|
-
if (!Array.isArray(values) || !values.length || values.some((value) => typeof value !== "string" || !value.trim()))
|
|
1463
|
-
throw new AppError("VALIDATION_ERROR", `\u8BF7\u56DE\u7B54 ${question.header}`);
|
|
1464
|
-
if (question.options?.length && !question.isOther && values.some((value) => !question.options.some((option) => option.label === value)))
|
|
1465
|
-
throw new AppError("VALIDATION_ERROR", `\u9898\u76EE ${question.header} \u53EA\u63A5\u53D7\u6240\u5217\u9009\u9879`);
|
|
1466
|
-
answers[question.id] = { answers: values };
|
|
1467
|
-
}
|
|
1468
|
-
response = { answers };
|
|
1559
|
+
response = { answers: questionAnswers(context.action.questions ?? [], resolution) };
|
|
1469
1560
|
} else {
|
|
1470
1561
|
if (!("decision" in resolution) || "content" in resolution || "persist" in resolution || !context.decisions.has(resolution.decision))
|
|
1471
1562
|
throw new AppError("VALIDATION_ERROR", "\u6B64\u8BF7\u6C42\u4E0D\u652F\u6301\u6240\u63D0\u4EA4\u7684\u51B3\u5B9A");
|
|
@@ -1474,15 +1565,29 @@ class CodexAdapter {
|
|
|
1474
1565
|
context.responding = true;
|
|
1475
1566
|
try {
|
|
1476
1567
|
await this.rpc.respond(context.action.rpcId, response);
|
|
1568
|
+
this.actionLogger(context.action).info("action.reply_sent");
|
|
1477
1569
|
} catch (error) {
|
|
1570
|
+
this.actionLogger(context.action).warn("action.reply_failed", errorFields(error));
|
|
1478
1571
|
if (error instanceof CodexError && !error.uncertain) context.responding = false;
|
|
1479
1572
|
throw error;
|
|
1480
1573
|
}
|
|
1481
1574
|
}
|
|
1575
|
+
actionLogger(action) {
|
|
1576
|
+
return this.logger.child({
|
|
1577
|
+
actionId: action.actionId,
|
|
1578
|
+
rpcId: action.rpcId,
|
|
1579
|
+
codexEpoch: action.codexEpoch,
|
|
1580
|
+
threadId: action.threadId,
|
|
1581
|
+
turnId: action.turnId,
|
|
1582
|
+
kind: action.kind,
|
|
1583
|
+
reason: action.requiresHumanApproval ? "human_command" : void 0
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1482
1586
|
expireActions(threadId, turnId) {
|
|
1483
1587
|
for (const [id, context] of this.actions) {
|
|
1484
1588
|
if (threadId && context.action.threadId !== threadId) continue;
|
|
1485
1589
|
if (turnId && context.action.turnId !== turnId) continue;
|
|
1590
|
+
this.actionLogger(context.action).info("action.expired");
|
|
1486
1591
|
this.emit({ type: "action", action: { ...context.action, status: "expired" } });
|
|
1487
1592
|
this.actions.delete(id);
|
|
1488
1593
|
this.actionIds.delete(context.action.rpcId);
|