newcraw 1.0.2 → 1.0.4
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/dist/REPL-DECTPCL5.js +50 -0
- package/dist/{acp-J4WDYGRX.js → acp-HA476EHW.js} +69 -40
- package/dist/acp-HA476EHW.js.map +7 -0
- package/dist/{agentsValidate-UBOER2IN.js → agentsValidate-EDPFUUMG.js} +13 -10
- package/dist/{agentsValidate-UBOER2IN.js.map → agentsValidate-EDPFUUMG.js.map} +1 -1
- package/dist/{ask-MGUO3L35.js → ask-5SP4YYRD.js} +62 -52
- package/dist/ask-5SP4YYRD.js.map +7 -0
- package/dist/{autoUpdater-2GS6LRPK.js → autoUpdater-FFMM2DR7.js} +5 -4
- package/dist/chunk-2BVCVKKB.js +135 -0
- package/dist/chunk-2BVCVKKB.js.map +7 -0
- package/dist/{chunk-2C43OXE7.js → chunk-2JCTO2EY.js} +38 -59
- package/dist/chunk-2JCTO2EY.js.map +7 -0
- package/dist/{chunk-OJIMOLIC.js → chunk-3CKC4ABU.js} +3631 -7464
- package/dist/chunk-3CKC4ABU.js.map +7 -0
- package/dist/chunk-ARCEUG3V.js +88 -0
- package/dist/chunk-ARCEUG3V.js.map +7 -0
- package/dist/{chunk-RUXIBQ3B.js → chunk-BJYXLCRS.js} +4 -4
- package/dist/{chunk-VKI7ORIO.js → chunk-BMKE6FT5.js} +37 -18
- package/dist/{chunk-VKI7ORIO.js.map → chunk-BMKE6FT5.js.map} +1 -1
- package/dist/chunk-BQCOSNM3.js +93 -0
- package/dist/chunk-BQCOSNM3.js.map +7 -0
- package/dist/chunk-CHB5K4GI.js +107 -0
- package/dist/chunk-CHB5K4GI.js.map +7 -0
- package/dist/chunk-D4OZACS2.js +35 -0
- package/dist/chunk-EHQ2M5B4.js +166 -0
- package/dist/{chunk-ZYSVG4X3.js.map → chunk-EHQ2M5B4.js.map} +2 -2
- package/dist/chunk-EUBZGAIN.js +372 -0
- package/dist/chunk-EUBZGAIN.js.map +7 -0
- package/dist/{chunk-UYRR6F5S.js → chunk-FIMCETCB.js} +9 -3
- package/dist/{chunk-UYRR6F5S.js.map → chunk-FIMCETCB.js.map} +1 -1
- package/dist/{chunk-DEF3KFP7.js → chunk-GVLJUD6R.js} +4 -2
- package/dist/{chunk-DEF3KFP7.js.map → chunk-GVLJUD6R.js.map} +1 -1
- package/dist/chunk-HLBLZKZH.js +45 -0
- package/dist/chunk-HLBLZKZH.js.map +7 -0
- package/dist/{chunk-XS6PU75S.js → chunk-IVWPPTDM.js} +1 -1
- package/dist/{chunk-A7X6OCZE.js → chunk-IXFBUXQW.js} +1 -1
- package/dist/{chunk-HSJ6HYAO.js → chunk-IZZTKEZH.js} +18 -10
- package/dist/chunk-IZZTKEZH.js.map +7 -0
- package/dist/{chunk-2EFL22PV.js → chunk-JI4HCLK7.js} +7 -3
- package/dist/chunk-JI4HCLK7.js.map +7 -0
- package/dist/chunk-JLVECHVJ.js +36 -0
- package/dist/chunk-JLVECHVJ.js.map +7 -0
- package/dist/{chunk-XXU2NVOE.js → chunk-KJTPUTU7.js} +30 -6
- package/dist/chunk-KJTPUTU7.js.map +7 -0
- package/dist/{chunk-V5U6BHT2.js → chunk-KS646CDL.js} +7 -3
- package/dist/{chunk-V5U6BHT2.js.map → chunk-KS646CDL.js.map} +1 -1
- package/dist/{chunk-53A4JHFW.js → chunk-MJ3MLGVB.js} +23 -4
- package/dist/chunk-MJ3MLGVB.js.map +7 -0
- package/dist/chunk-MJLWBVZP.js +822 -0
- package/dist/chunk-MJLWBVZP.js.map +7 -0
- package/dist/chunk-MMF5RMLU.js +65 -0
- package/dist/chunk-MMF5RMLU.js.map +7 -0
- package/dist/{chunk-QH2M65BR.js → chunk-MUW3J7CP.js} +7 -3
- package/dist/{chunk-QH2M65BR.js.map → chunk-MUW3J7CP.js.map} +1 -1
- package/dist/{chunk-3LMXSKZ7.js → chunk-NFXLN6FJ.js} +1 -1
- package/dist/chunk-NT7RDVDA.js +33 -0
- package/dist/{chunk-KQSHIOZK.js.map → chunk-NT7RDVDA.js.map} +1 -1
- package/dist/{chunk-OZHBEG7U.js → chunk-O4EKE3YR.js} +15 -5
- package/dist/{chunk-OZHBEG7U.js.map → chunk-O4EKE3YR.js.map} +1 -1
- package/dist/chunk-Q2OBTLBI.js +5473 -0
- package/dist/chunk-Q2OBTLBI.js.map +7 -0
- package/dist/{chunk-WWDVA4NV.js → chunk-QJ7MQIHN.js} +22 -6
- package/dist/{chunk-WWDVA4NV.js.map → chunk-QJ7MQIHN.js.map} +1 -1
- package/dist/{chunk-N5OHRWG2.js → chunk-QSRXXZO7.js} +4 -2
- package/dist/{chunk-N5OHRWG2.js.map → chunk-QSRXXZO7.js.map} +1 -1
- package/dist/{chunk-GZTCXXSS.js → chunk-QT5GS374.js} +57 -46
- package/dist/{chunk-GZTCXXSS.js.map → chunk-QT5GS374.js.map} +1 -1
- package/dist/chunk-QX5Y5CE5.js +683 -0
- package/dist/{chunk-F3COCCAE.js.map → chunk-QX5Y5CE5.js.map} +1 -1
- package/dist/{chunk-IIFUDVGS.js → chunk-U6IF5D3J.js} +310 -177
- package/dist/chunk-U6IF5D3J.js.map +7 -0
- package/dist/{chunk-VQSCECTS.js → chunk-UPRKGNBR.js} +6 -4
- package/dist/{chunk-VQSCECTS.js.map → chunk-UPRKGNBR.js.map} +1 -1
- package/dist/chunk-UUCRNFMH.js +62 -0
- package/dist/chunk-UUCRNFMH.js.map +7 -0
- package/dist/chunk-UYWZQVH5.js +35 -0
- package/dist/chunk-UYWZQVH5.js.map +7 -0
- package/dist/{chunk-XMGUQHMF.js → chunk-VSSVN6WG.js} +11 -1
- package/dist/chunk-VSSVN6WG.js.map +7 -0
- package/dist/{chunk-VHS2MZQS.js → chunk-W7Q3VYAB.js} +9 -6
- package/dist/{chunk-VHS2MZQS.js.map → chunk-W7Q3VYAB.js.map} +1 -1
- package/dist/{chunk-JWXQNBBA.js → chunk-WAXMRSVR.js} +7 -1
- package/dist/{chunk-JWXQNBBA.js.map → chunk-WAXMRSVR.js.map} +1 -1
- package/dist/{chunk-BWYKUDJR.js → chunk-X3NER6FY.js} +14 -8
- package/dist/{chunk-BWYKUDJR.js.map → chunk-X3NER6FY.js.map} +1 -1
- package/dist/{chunk-IM33F5CM.js → chunk-XYQZLDRB.js} +1668 -1623
- package/dist/chunk-XYQZLDRB.js.map +7 -0
- package/dist/{chunk-LOIZNQOU.js → chunk-ZM5FMRLS.js} +9 -3
- package/dist/{chunk-LOIZNQOU.js.map → chunk-ZM5FMRLS.js.map} +1 -1
- package/dist/{chunk-755HIAI3.js → chunk-ZMO4E7IW.js} +3 -42
- package/dist/chunk-ZMO4E7IW.js.map +7 -0
- package/dist/{cli-KZGF3FV5.js → cli-4KO6TA5J.js} +251 -485
- package/dist/cli-4KO6TA5J.js.map +7 -0
- package/dist/commands-JSY7CGSU.js +54 -0
- package/dist/{config-GTJWCNPF.js → config-DQEFVW3Y.js} +9 -6
- package/dist/{context-WF3TTXQU.js → context-HVQCTO5R.js} +8 -7
- package/dist/{costTracker-2G3ZI2JF.js → costTracker-VSWW7SRT.js} +3 -2
- package/dist/{customCommands-QOWK57EX.js → customCommands-XCINU5TG.js} +6 -5
- package/dist/{env-37BAP7QF.js → env-ZOPEXWMF.js} +10 -7
- package/dist/{gateway-IZYO6YFJ.js → gateway-SUXSILQL.js} +542 -96
- package/dist/gateway-SUXSILQL.js.map +7 -0
- package/dist/identity-3KZQQVBG.js +16 -0
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/{kodeAgentSessionId-KTGFX2BE.js → kodeAgentSessionId-4SH24DVH.js} +1 -1
- package/dist/{kodeAgentSessionLoad-6F7SJXBC.js → kodeAgentSessionLoad-HB3BYVNG.js} +6 -5
- package/dist/{kodeAgentSessionResume-UEEDRJ3N.js → kodeAgentSessionResume-IGSZZY3G.js} +6 -5
- package/dist/{kodeAgentStreamJson-VIXFTYL5.js → kodeAgentStreamJson-4ZKIWKS3.js} +4 -2
- package/dist/{kodeAgentStreamJsonSession-XC3IPREZ.js → kodeAgentStreamJsonSession-4L76UC75.js} +15 -4
- package/dist/kodeAgentStreamJsonSession-4L76UC75.js.map +7 -0
- package/dist/{kodeAgentStructuredStdio-SI5C7AAD.js → kodeAgentStructuredStdio-5DCUC6V6.js} +3 -3
- package/dist/{kodeHooks-V36SHCTC.js → kodeHooks-H6DMC3XX.js} +6 -5
- package/dist/{llm-CYUDKJNR.js → llm-OJZ6DZVC.js} +306 -60
- package/dist/llm-OJZ6DZVC.js.map +7 -0
- package/dist/{llmLazy-IXVVBRTN.js → llmLazy-TDLZZDPL.js} +2 -2
- package/dist/{loader-OEJ6C3TN.js → loader-MOVYZ76M.js} +6 -5
- package/dist/{mcp-KE3SILMX.js → mcp-DUYSIR5L.js} +10 -9
- package/dist/{mentionProcessor-GAU2WAYB.js → mentionProcessor-EKVLXJN4.js} +14 -7
- package/dist/{mentionProcessor-GAU2WAYB.js.map → mentionProcessor-EKVLXJN4.js.map} +1 -1
- package/dist/{messages-WCSGGSEU.js → messages-23ICFVMC.js} +2 -2
- package/dist/{model-4TQIV5J2.js → model-FUBCTRTV.js} +10 -7
- package/dist/{openai-KTZV6F7N.js → openai-SMYIAIO4.js} +8 -7
- package/dist/{outputStyles-WX5RYQOA.js → outputStyles-HBOYJFBE.js} +6 -5
- package/dist/{pluginRuntime-JXMJZ2LC.js → pluginRuntime-ATZMDZA7.js} +11 -8
- package/dist/{pluginRuntime-JXMJZ2LC.js.map → pluginRuntime-ATZMDZA7.js.map} +1 -1
- package/dist/{pluginValidation-JNQZYLUP.js → pluginValidation-7CGOMT6F.js} +8 -7
- package/dist/prompts-MFESKNYZ.js +58 -0
- package/dist/query-BFEFOX4S.js +58 -0
- package/dist/{responsesStreaming-2AIT6GHG.js → responsesStreaming-JORGEFQC.js} +1 -1
- package/dist/{ripgrep-KDPQAMB2.js → ripgrep-KNJBCJIQ.js} +5 -4
- package/dist/sandbox-P3FR4G4D.js +63 -0
- package/dist/{skillMarketplace-IXAGP3Q2.js → skillMarketplace-PCMKVV4O.js} +5 -4
- package/dist/{state-MSCYLB6Y.js → state-XBYIQ7R4.js} +6 -3
- package/dist/structuredOutput-KAVFUV2Z.js +9 -0
- package/dist/theme-4ZSXUILR.js +15 -0
- package/dist/thinking-TTNUZUB3.js +18 -0
- package/dist/{toolPermissionContext-I3IXPVED.js → toolPermissionContext-JCQ5MFUT.js} +1 -1
- package/dist/toolPermissionContext-JCQ5MFUT.js.map +7 -0
- package/dist/toolPermissionContextState-R6ZGMKP6.js +24 -0
- package/dist/toolPermissionContextState-R6ZGMKP6.js.map +7 -0
- package/dist/{toolPermissionSettings-EUZKGZU2.js → toolPermissionSettings-GMEYTJEA.js} +9 -8
- package/dist/toolPermissionSettings-GMEYTJEA.js.map +7 -0
- package/dist/tools-7FVKB7BG.js +55 -0
- package/dist/tools-7FVKB7BG.js.map +7 -0
- package/dist/{userInput-LJL4CVOB.js → userInput-SZEUY5J6.js} +49 -34
- package/dist/{userInput-LJL4CVOB.js.map → userInput-SZEUY5J6.js.map} +1 -1
- package/dist/{uuid-VA3KVASX.js → uuid-RQH3OZ3W.js} +1 -1
- package/dist/uuid-RQH3OZ3W.js.map +7 -0
- package/dist/workspace-EP63OB5S.js +21 -0
- package/dist/workspace-EP63OB5S.js.map +7 -0
- package/package.json +2 -2
- package/web/dist/assets/index-XuLVvSQF.js +251 -0
- package/web/dist/assets/index-pSid9IlY.css +10 -0
- package/web/dist/index.html +2 -2
- package/dist/REPL-IAK7ZN2Z.js +0 -42
- package/dist/acp-J4WDYGRX.js.map +0 -7
- package/dist/ask-MGUO3L35.js.map +0 -7
- package/dist/chunk-2C43OXE7.js.map +0 -7
- package/dist/chunk-2EFL22PV.js.map +0 -7
- package/dist/chunk-53A4JHFW.js.map +0 -7
- package/dist/chunk-755HIAI3.js.map +0 -7
- package/dist/chunk-AXWJI6N5.js +0 -11
- package/dist/chunk-F3COCCAE.js +0 -654
- package/dist/chunk-HSJ6HYAO.js.map +0 -7
- package/dist/chunk-IIFUDVGS.js.map +0 -7
- package/dist/chunk-IM33F5CM.js.map +0 -7
- package/dist/chunk-KQSHIOZK.js +0 -24
- package/dist/chunk-OJIMOLIC.js.map +0 -7
- package/dist/chunk-XMGUQHMF.js.map +0 -7
- package/dist/chunk-XXU2NVOE.js.map +0 -7
- package/dist/chunk-ZYSVG4X3.js +0 -151
- package/dist/cli-KZGF3FV5.js.map +0 -7
- package/dist/commands-AVEBLFVS.js +0 -46
- package/dist/gateway-IZYO6YFJ.js.map +0 -7
- package/dist/kodeAgentStreamJsonSession-XC3IPREZ.js.map +0 -7
- package/dist/llm-CYUDKJNR.js.map +0 -7
- package/dist/prompts-LE6GK75N.js +0 -48
- package/dist/query-GGIP6PWG.js +0 -50
- package/dist/theme-GAMFOLBW.js +0 -14
- package/dist/tools-3HOUIDM3.js +0 -47
- package/web/dist/assets/index-COAJqX1Z.css +0 -1
- package/web/dist/assets/index-CzS_4LmC.js +0 -179
- /package/dist/{REPL-IAK7ZN2Z.js.map → REPL-DECTPCL5.js.map} +0 -0
- /package/dist/{autoUpdater-2GS6LRPK.js.map → autoUpdater-FFMM2DR7.js.map} +0 -0
- /package/dist/{chunk-RUXIBQ3B.js.map → chunk-BJYXLCRS.js.map} +0 -0
- /package/dist/{chunk-AXWJI6N5.js.map → chunk-D4OZACS2.js.map} +0 -0
- /package/dist/{chunk-XS6PU75S.js.map → chunk-IVWPPTDM.js.map} +0 -0
- /package/dist/{chunk-A7X6OCZE.js.map → chunk-IXFBUXQW.js.map} +0 -0
- /package/dist/{chunk-3LMXSKZ7.js.map → chunk-NFXLN6FJ.js.map} +0 -0
- /package/dist/{commands-AVEBLFVS.js.map → commands-JSY7CGSU.js.map} +0 -0
- /package/dist/{config-GTJWCNPF.js.map → config-DQEFVW3Y.js.map} +0 -0
- /package/dist/{context-WF3TTXQU.js.map → context-HVQCTO5R.js.map} +0 -0
- /package/dist/{costTracker-2G3ZI2JF.js.map → costTracker-VSWW7SRT.js.map} +0 -0
- /package/dist/{customCommands-QOWK57EX.js.map → customCommands-XCINU5TG.js.map} +0 -0
- /package/dist/{env-37BAP7QF.js.map → env-ZOPEXWMF.js.map} +0 -0
- /package/dist/{kodeAgentSessionId-KTGFX2BE.js.map → identity-3KZQQVBG.js.map} +0 -0
- /package/dist/{kodeAgentSessionLoad-6F7SJXBC.js.map → kodeAgentSessionId-4SH24DVH.js.map} +0 -0
- /package/dist/{kodeAgentSessionResume-UEEDRJ3N.js.map → kodeAgentSessionLoad-HB3BYVNG.js.map} +0 -0
- /package/dist/{kodeAgentStreamJson-VIXFTYL5.js.map → kodeAgentSessionResume-IGSZZY3G.js.map} +0 -0
- /package/dist/{kodeAgentStructuredStdio-SI5C7AAD.js.map → kodeAgentStreamJson-4ZKIWKS3.js.map} +0 -0
- /package/dist/{kodeHooks-V36SHCTC.js.map → kodeAgentStructuredStdio-5DCUC6V6.js.map} +0 -0
- /package/dist/{llmLazy-IXVVBRTN.js.map → kodeHooks-H6DMC3XX.js.map} +0 -0
- /package/dist/{loader-OEJ6C3TN.js.map → llmLazy-TDLZZDPL.js.map} +0 -0
- /package/dist/{mcp-KE3SILMX.js.map → loader-MOVYZ76M.js.map} +0 -0
- /package/dist/{messages-WCSGGSEU.js.map → mcp-DUYSIR5L.js.map} +0 -0
- /package/dist/{model-4TQIV5J2.js.map → messages-23ICFVMC.js.map} +0 -0
- /package/dist/{openai-KTZV6F7N.js.map → model-FUBCTRTV.js.map} +0 -0
- /package/dist/{outputStyles-WX5RYQOA.js.map → openai-SMYIAIO4.js.map} +0 -0
- /package/dist/{pluginValidation-JNQZYLUP.js.map → outputStyles-HBOYJFBE.js.map} +0 -0
- /package/dist/{prompts-LE6GK75N.js.map → pluginValidation-7CGOMT6F.js.map} +0 -0
- /package/dist/{query-GGIP6PWG.js.map → prompts-MFESKNYZ.js.map} +0 -0
- /package/dist/{responsesStreaming-2AIT6GHG.js.map → query-BFEFOX4S.js.map} +0 -0
- /package/dist/{ripgrep-KDPQAMB2.js.map → responsesStreaming-JORGEFQC.js.map} +0 -0
- /package/dist/{skillMarketplace-IXAGP3Q2.js.map → ripgrep-KNJBCJIQ.js.map} +0 -0
- /package/dist/{state-MSCYLB6Y.js.map → sandbox-P3FR4G4D.js.map} +0 -0
- /package/dist/{theme-GAMFOLBW.js.map → skillMarketplace-PCMKVV4O.js.map} +0 -0
- /package/dist/{toolPermissionContext-I3IXPVED.js.map → state-XBYIQ7R4.js.map} +0 -0
- /package/dist/{toolPermissionSettings-EUZKGZU2.js.map → structuredOutput-KAVFUV2Z.js.map} +0 -0
- /package/dist/{tools-3HOUIDM3.js.map → theme-4ZSXUILR.js.map} +0 -0
- /package/dist/{uuid-VA3KVASX.js.map → thinking-TTNUZUB3.js.map} +0 -0
|
@@ -3,45 +3,49 @@ const require = __newcrawCreateRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
getToolDescription
|
|
5
5
|
} from "./chunk-T25Z3JMG.js";
|
|
6
|
+
import {
|
|
7
|
+
isProviderAvailable,
|
|
8
|
+
markProviderFailure,
|
|
9
|
+
markProviderSuccess,
|
|
10
|
+
selectAvailableProvider
|
|
11
|
+
} from "./chunk-2BVCVKKB.js";
|
|
6
12
|
import {
|
|
7
13
|
processResponsesStream
|
|
8
14
|
} from "./chunk-BHNQGSLO.js";
|
|
15
|
+
import {
|
|
16
|
+
structuredOutputConfig
|
|
17
|
+
} from "./chunk-BQCOSNM3.js";
|
|
9
18
|
import {
|
|
10
19
|
formatSystemPromptWithContext,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
models_default
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-HSJ6HYAO.js";
|
|
21
|
-
import "./chunk-3LMXSKZ7.js";
|
|
22
|
-
import "./chunk-XXU2NVOE.js";
|
|
20
|
+
getCLISyspromptPrefix
|
|
21
|
+
} from "./chunk-3CKC4ABU.js";
|
|
22
|
+
import {
|
|
23
|
+
models_default
|
|
24
|
+
} from "./chunk-Q2OBTLBI.js";
|
|
25
|
+
import "./chunk-UPRKGNBR.js";
|
|
26
|
+
import "./chunk-NFXLN6FJ.js";
|
|
27
|
+
import "./chunk-IVWPPTDM.js";
|
|
28
|
+
import "./chunk-KJTPUTU7.js";
|
|
23
29
|
import "./chunk-JX5ZQYTQ.js";
|
|
24
30
|
import {
|
|
25
31
|
setRequestStatus
|
|
26
32
|
} from "./chunk-XJQATPV7.js";
|
|
27
|
-
import "./chunk-V5U6BHT2.js";
|
|
28
|
-
import "./chunk-7ZFLZNOW.js";
|
|
29
|
-
import "./chunk-VHS2MZQS.js";
|
|
30
33
|
import {
|
|
31
34
|
getCompletionWithProfile,
|
|
32
35
|
getGPT5CompletionWithProfile
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
import "./chunk-
|
|
38
|
-
import "./chunk-
|
|
36
|
+
} from "./chunk-MUW3J7CP.js";
|
|
37
|
+
import {
|
|
38
|
+
getReasoningEffort
|
|
39
|
+
} from "./chunk-MMF5RMLU.js";
|
|
40
|
+
import "./chunk-BJYXLCRS.js";
|
|
41
|
+
import "./chunk-QJ7MQIHN.js";
|
|
42
|
+
import "./chunk-IZZTKEZH.js";
|
|
43
|
+
import "./chunk-UUCRNFMH.js";
|
|
44
|
+
import "./chunk-X3NER6FY.js";
|
|
39
45
|
import "./chunk-U7S4MEYP.js";
|
|
40
|
-
import "./chunk-
|
|
46
|
+
import "./chunk-FIMCETCB.js";
|
|
41
47
|
import "./chunk-TY3CCSAT.js";
|
|
42
|
-
import "./chunk-
|
|
43
|
-
import "./chunk-INJSFEKL.js";
|
|
44
|
-
import "./chunk-2UO3BFZH.js";
|
|
48
|
+
import "./chunk-ZM5FMRLS.js";
|
|
45
49
|
import {
|
|
46
50
|
API_ERROR_MESSAGE_PREFIX,
|
|
47
51
|
CREDIT_BALANCE_TOO_LOW_ERROR_MESSAGE,
|
|
@@ -51,41 +55,67 @@ import {
|
|
|
51
55
|
PROMPT_TOO_LONG_ERROR_MESSAGE,
|
|
52
56
|
createAssistantAPIErrorMessage,
|
|
53
57
|
normalizeContentFromAPI
|
|
54
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-IXFBUXQW.js";
|
|
59
|
+
import "./chunk-WAXMRSVR.js";
|
|
60
|
+
import "./chunk-MJLWBVZP.js";
|
|
61
|
+
import "./chunk-KS646CDL.js";
|
|
62
|
+
import "./chunk-7ZFLZNOW.js";
|
|
63
|
+
import "./chunk-W7Q3VYAB.js";
|
|
64
|
+
import "./chunk-INJSFEKL.js";
|
|
65
|
+
import "./chunk-JI4HCLK7.js";
|
|
66
|
+
import "./chunk-JLVECHVJ.js";
|
|
67
|
+
import "./chunk-2JCTO2EY.js";
|
|
68
|
+
import "./chunk-2UO3BFZH.js";
|
|
69
|
+
import "./chunk-CHB5K4GI.js";
|
|
55
70
|
import {
|
|
56
71
|
USE_BEDROCK,
|
|
57
72
|
USE_VERTEX,
|
|
58
73
|
getModelManager,
|
|
59
|
-
getVertexRegionForModel
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
import
|
|
74
|
+
getVertexRegionForModel,
|
|
75
|
+
init_model
|
|
76
|
+
} from "./chunk-QX5Y5CE5.js";
|
|
77
|
+
import {
|
|
78
|
+
getProjectDocs
|
|
79
|
+
} from "./chunk-MJ3MLGVB.js";
|
|
80
|
+
import "./chunk-GVLJUD6R.js";
|
|
63
81
|
import {
|
|
64
82
|
getAnthropicApiKey,
|
|
65
|
-
getGlobalConfig
|
|
66
|
-
|
|
67
|
-
|
|
83
|
+
getGlobalConfig,
|
|
84
|
+
init_config
|
|
85
|
+
} from "./chunk-U6IF5D3J.js";
|
|
86
|
+
import "./chunk-NT7RDVDA.js";
|
|
68
87
|
import {
|
|
69
88
|
debug,
|
|
70
89
|
getCurrentRequest,
|
|
90
|
+
init_debugLogger,
|
|
71
91
|
logErrorWithDiagnosis,
|
|
72
92
|
logLLMInteraction,
|
|
73
93
|
logSystemPromptConstruction,
|
|
74
94
|
markPhase
|
|
75
|
-
} from "./chunk-
|
|
95
|
+
} from "./chunk-QT5GS374.js";
|
|
76
96
|
import {
|
|
77
|
-
PRODUCT_COMMAND,
|
|
78
97
|
env,
|
|
79
98
|
getCwd,
|
|
99
|
+
init_env,
|
|
100
|
+
init_log,
|
|
101
|
+
init_state,
|
|
80
102
|
logError
|
|
81
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-XYQZLDRB.js";
|
|
82
104
|
import {
|
|
83
|
-
|
|
84
|
-
|
|
105
|
+
PRODUCT_COMMAND,
|
|
106
|
+
init_product
|
|
107
|
+
} from "./chunk-UYWZQVH5.js";
|
|
108
|
+
import {
|
|
109
|
+
MACRO,
|
|
110
|
+
init_macros
|
|
111
|
+
} from "./chunk-EHQ2M5B4.js";
|
|
85
112
|
import {
|
|
86
113
|
addToTotalCost
|
|
87
|
-
} from "./chunk-
|
|
88
|
-
import "./chunk-
|
|
114
|
+
} from "./chunk-ZMO4E7IW.js";
|
|
115
|
+
import "./chunk-HLBLZKZH.js";
|
|
116
|
+
import {
|
|
117
|
+
__require
|
|
118
|
+
} from "./chunk-D4OZACS2.js";
|
|
89
119
|
|
|
90
120
|
// src/services/ai/llm.ts
|
|
91
121
|
import "@anthropic-ai/sdk/shims/node";
|
|
@@ -95,11 +125,17 @@ import { AnthropicVertex } from "@anthropic-ai/vertex-sdk";
|
|
|
95
125
|
import chalk from "chalk";
|
|
96
126
|
import { randomUUID } from "crypto";
|
|
97
127
|
import "dotenv/config";
|
|
128
|
+
init_config();
|
|
129
|
+
init_log();
|
|
98
130
|
|
|
99
131
|
// src/utils/system/http.ts
|
|
132
|
+
init_macros();
|
|
133
|
+
init_product();
|
|
100
134
|
var USER_AGENT = `${PRODUCT_COMMAND}/${MACRO.VERSION} (${process.env.USER_TYPE})`;
|
|
101
135
|
|
|
102
136
|
// src/services/system/vcr.ts
|
|
137
|
+
init_env();
|
|
138
|
+
init_state();
|
|
103
139
|
import { createHash } from "crypto";
|
|
104
140
|
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
105
141
|
import { dirname } from "path";
|
|
@@ -229,6 +265,8 @@ function hydrateValue(s) {
|
|
|
229
265
|
}
|
|
230
266
|
|
|
231
267
|
// src/services/ai/llm.ts
|
|
268
|
+
init_debugLogger();
|
|
269
|
+
init_model();
|
|
232
270
|
import { zodToJsonSchema as zodToJsonSchema4 } from "zod-to-json-schema";
|
|
233
271
|
|
|
234
272
|
// src/services/ai/adapters/base.ts
|
|
@@ -295,6 +333,8 @@ var ModelAPIAdapter = class {
|
|
|
295
333
|
};
|
|
296
334
|
|
|
297
335
|
// src/services/ai/adapters/openaiAdapter.ts
|
|
336
|
+
init_debugLogger();
|
|
337
|
+
init_log();
|
|
298
338
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
299
339
|
var OpenAIAdapter = class extends ModelAPIAdapter {
|
|
300
340
|
constructor(capabilities, modelProfile) {
|
|
@@ -465,6 +505,8 @@ var OpenAIAdapter = class extends ModelAPIAdapter {
|
|
|
465
505
|
|
|
466
506
|
// src/services/ai/adapters/responsesAPI.ts
|
|
467
507
|
import { zodToJsonSchema as zodToJsonSchema2 } from "zod-to-json-schema";
|
|
508
|
+
init_debugLogger();
|
|
509
|
+
init_log();
|
|
468
510
|
var ResponsesAPIAdapter = class extends OpenAIAdapter {
|
|
469
511
|
createRequest(params) {
|
|
470
512
|
const {
|
|
@@ -530,6 +572,8 @@ var ResponsesAPIAdapter = class extends OpenAIAdapter {
|
|
|
530
572
|
return request;
|
|
531
573
|
}
|
|
532
574
|
buildTools(tools) {
|
|
575
|
+
const provider = this.modelProfile.provider || "openai";
|
|
576
|
+
const config = structuredOutputConfig(provider);
|
|
533
577
|
return tools.map((tool) => {
|
|
534
578
|
let parameters = tool.inputJSONSchema;
|
|
535
579
|
if (!parameters && tool.inputSchema) {
|
|
@@ -555,7 +599,8 @@ var ResponsesAPIAdapter = class extends OpenAIAdapter {
|
|
|
555
599
|
type: "function",
|
|
556
600
|
name: tool.name,
|
|
557
601
|
description: getToolDescription(tool),
|
|
558
|
-
parameters: parameters || { type: "object", properties: {} }
|
|
602
|
+
parameters: parameters || { type: "object", properties: {} },
|
|
603
|
+
...config.enableStrictTools ? { strict: true } : {}
|
|
559
604
|
};
|
|
560
605
|
});
|
|
561
606
|
}
|
|
@@ -715,7 +760,7 @@ ${reasoningContent}
|
|
|
715
760
|
return state;
|
|
716
761
|
}
|
|
717
762
|
async parseStreamingOpenAIResponse(response) {
|
|
718
|
-
const { processResponsesStream: processResponsesStream2 } = await import("./responsesStreaming-
|
|
763
|
+
const { processResponsesStream: processResponsesStream2 } = await import("./responsesStreaming-JORGEFQC.js");
|
|
719
764
|
return await processResponsesStream2(
|
|
720
765
|
this.parseStreamingResponse(response),
|
|
721
766
|
Date.now(),
|
|
@@ -915,12 +960,15 @@ var ChatCompletionsAdapter = class extends OpenAIAdapter {
|
|
|
915
960
|
return request;
|
|
916
961
|
}
|
|
917
962
|
buildTools(tools) {
|
|
963
|
+
const provider = this.modelProfile.provider || "openai";
|
|
964
|
+
const config = structuredOutputConfig(provider);
|
|
918
965
|
return tools.map((tool) => ({
|
|
919
966
|
type: "function",
|
|
920
967
|
function: {
|
|
921
968
|
name: tool.name,
|
|
922
969
|
description: getToolDescription(tool),
|
|
923
|
-
parameters: tool.inputJSONSchema || zodToJsonSchema3(tool.inputSchema)
|
|
970
|
+
parameters: tool.inputJSONSchema || zodToJsonSchema3(tool.inputSchema),
|
|
971
|
+
...config.enableStrictTools ? { strict: true } : {}
|
|
924
972
|
}
|
|
925
973
|
}));
|
|
926
974
|
}
|
|
@@ -1389,6 +1437,8 @@ function getConversationId(agentId, messageId) {
|
|
|
1389
1437
|
}
|
|
1390
1438
|
|
|
1391
1439
|
// src/services/ai/llm.ts
|
|
1440
|
+
init_model();
|
|
1441
|
+
init_model();
|
|
1392
1442
|
import { nanoid } from "nanoid";
|
|
1393
1443
|
|
|
1394
1444
|
// src/utils/tooling/toolUsePartialJson.ts
|
|
@@ -1673,6 +1723,70 @@ function convertAnthropicMessagesToOpenAIMessages(messages) {
|
|
|
1673
1723
|
return finalMessages;
|
|
1674
1724
|
}
|
|
1675
1725
|
|
|
1726
|
+
// src/services/context/kodeContext.ts
|
|
1727
|
+
init_debugLogger();
|
|
1728
|
+
init_log();
|
|
1729
|
+
var KodeContextManager = class _KodeContextManager {
|
|
1730
|
+
static instance;
|
|
1731
|
+
projectDocsCache = "";
|
|
1732
|
+
cacheInitialized = false;
|
|
1733
|
+
initPromise = null;
|
|
1734
|
+
static getInstance() {
|
|
1735
|
+
if (!_KodeContextManager.instance) {
|
|
1736
|
+
_KodeContextManager.instance = new _KodeContextManager();
|
|
1737
|
+
}
|
|
1738
|
+
return _KodeContextManager.instance;
|
|
1739
|
+
}
|
|
1740
|
+
async initialize() {
|
|
1741
|
+
if (this.initPromise) return this.initPromise;
|
|
1742
|
+
this.initPromise = (async () => {
|
|
1743
|
+
try {
|
|
1744
|
+
const projectDocs = await getProjectDocs();
|
|
1745
|
+
this.projectDocsCache = projectDocs || "";
|
|
1746
|
+
this.cacheInitialized = true;
|
|
1747
|
+
} catch (error) {
|
|
1748
|
+
logError(error);
|
|
1749
|
+
debug.warn("NEWCRAW_CONTEXT_LOAD_FAILED", {
|
|
1750
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1751
|
+
});
|
|
1752
|
+
this.projectDocsCache = "";
|
|
1753
|
+
this.cacheInitialized = true;
|
|
1754
|
+
}
|
|
1755
|
+
})();
|
|
1756
|
+
return this.initPromise;
|
|
1757
|
+
}
|
|
1758
|
+
getKodeContext() {
|
|
1759
|
+
if (!this.cacheInitialized) {
|
|
1760
|
+
this.initialize().catch((error) => {
|
|
1761
|
+
logError(error);
|
|
1762
|
+
debug.warn("NEWCRAW_CONTEXT_LOAD_FAILED", {
|
|
1763
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1764
|
+
});
|
|
1765
|
+
});
|
|
1766
|
+
return "";
|
|
1767
|
+
}
|
|
1768
|
+
return this.projectDocsCache;
|
|
1769
|
+
}
|
|
1770
|
+
async refreshCache() {
|
|
1771
|
+
this.cacheInitialized = false;
|
|
1772
|
+
this.initPromise = null;
|
|
1773
|
+
await this.initialize();
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1776
|
+
var kodeContextManager = KodeContextManager.getInstance();
|
|
1777
|
+
var generateKodeContext = () => {
|
|
1778
|
+
return kodeContextManager.getKodeContext();
|
|
1779
|
+
};
|
|
1780
|
+
var refreshKodeContext = async () => {
|
|
1781
|
+
await kodeContextManager.refreshCache();
|
|
1782
|
+
};
|
|
1783
|
+
if (process.env.NODE_ENV !== "test") {
|
|
1784
|
+
setTimeout(() => {
|
|
1785
|
+
refreshKodeContext().catch(() => {
|
|
1786
|
+
});
|
|
1787
|
+
}, 0);
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1676
1790
|
// src/services/ai/llm.ts
|
|
1677
1791
|
function isGPT5Model(modelName) {
|
|
1678
1792
|
return modelName.startsWith("gpt-5");
|
|
@@ -2016,7 +2130,33 @@ async function handleMessageStream(stream, signal) {
|
|
|
2016
2130
|
usage
|
|
2017
2131
|
};
|
|
2018
2132
|
}
|
|
2019
|
-
|
|
2133
|
+
var ToolCallParseError = class extends Error {
|
|
2134
|
+
constructor(toolName, rawArguments, parseError) {
|
|
2135
|
+
super(`Failed to parse tool call arguments for "${toolName}": ${parseError instanceof Error ? parseError.message : String(parseError)}`);
|
|
2136
|
+
this.toolName = toolName;
|
|
2137
|
+
this.rawArguments = rawArguments;
|
|
2138
|
+
this.parseError = parseError;
|
|
2139
|
+
this.name = "ToolCallParseError";
|
|
2140
|
+
}
|
|
2141
|
+
};
|
|
2142
|
+
function validateToolArgsWithSchema(toolArgs, toolDef) {
|
|
2143
|
+
if (!toolDef) return { valid: true };
|
|
2144
|
+
const schema = toolDef.inputSchema ?? toolDef.input_schema;
|
|
2145
|
+
if (!schema || typeof schema !== "object") return { valid: true };
|
|
2146
|
+
try {
|
|
2147
|
+
const Ajv = __require("ajv");
|
|
2148
|
+
const ajv = new Ajv({ allErrors: true, strict: false });
|
|
2149
|
+
const validate = ajv.compile(schema);
|
|
2150
|
+
const valid = validate(toolArgs);
|
|
2151
|
+
if (!valid && validate.errors) {
|
|
2152
|
+
const errMsg = validate.errors.map((e) => `${e.instancePath || "/"}: ${e.message}`).join("; ");
|
|
2153
|
+
return { valid: false, errors: errMsg };
|
|
2154
|
+
}
|
|
2155
|
+
} catch {
|
|
2156
|
+
}
|
|
2157
|
+
return { valid: true };
|
|
2158
|
+
}
|
|
2159
|
+
function convertOpenAIResponseToAnthropic(response, tools, options) {
|
|
2020
2160
|
let contentBlocks = [];
|
|
2021
2161
|
const message = response.choices?.[0]?.message;
|
|
2022
2162
|
if (!message) {
|
|
@@ -2036,6 +2176,20 @@ function convertOpenAIResponseToAnthropic(response, tools) {
|
|
|
2036
2176
|
try {
|
|
2037
2177
|
toolArgs = tool?.arguments ? JSON.parse(tool.arguments) : {};
|
|
2038
2178
|
} catch (e) {
|
|
2179
|
+
if (options?.throwOnParseError) {
|
|
2180
|
+
throw new ToolCallParseError(toolName ?? "unknown", tool?.arguments ?? "", e);
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
if (options?.postValidate && Object.keys(toolArgs).length > 0) {
|
|
2184
|
+
const matchedTool = tools?.find((t) => t.name === toolName);
|
|
2185
|
+
const validation = validateToolArgsWithSchema(toolArgs, matchedTool);
|
|
2186
|
+
if (!validation.valid && options?.throwOnParseError) {
|
|
2187
|
+
throw new ToolCallParseError(
|
|
2188
|
+
toolName ?? "unknown",
|
|
2189
|
+
tool?.arguments ?? "",
|
|
2190
|
+
new Error(`AJV validation failed: ${validation.errors}`)
|
|
2191
|
+
);
|
|
2192
|
+
}
|
|
2039
2193
|
}
|
|
2040
2194
|
contentBlocks.push({
|
|
2041
2195
|
type: "tool_use",
|
|
@@ -2349,13 +2503,37 @@ async function queryLLMWithPromptCaching(messages, systemPrompt, maxThinkingToke
|
|
|
2349
2503
|
const config = getGlobalConfig();
|
|
2350
2504
|
const modelManager = getModelManager();
|
|
2351
2505
|
const toolUseContext = options.toolUseContext;
|
|
2352
|
-
|
|
2506
|
+
let modelProfile = options.modelProfile || modelManager.getModel("main");
|
|
2353
2507
|
let provider;
|
|
2354
2508
|
if (modelProfile) {
|
|
2355
2509
|
provider = modelProfile.provider || config.primaryProvider || "anthropic";
|
|
2356
2510
|
} else {
|
|
2357
2511
|
provider = config.primaryProvider || "anthropic";
|
|
2358
2512
|
}
|
|
2513
|
+
if (!isProviderAvailable(provider)) {
|
|
2514
|
+
const allProfiles = [
|
|
2515
|
+
modelManager.getModel("main"),
|
|
2516
|
+
modelManager.getModel("task"),
|
|
2517
|
+
modelManager.getModel("quick")
|
|
2518
|
+
].filter((p) => !!p && p.provider !== provider);
|
|
2519
|
+
const fallbackProviders = [...new Set(allProfiles.map((p) => p.provider))];
|
|
2520
|
+
const selected = selectAvailableProvider({
|
|
2521
|
+
primary: provider,
|
|
2522
|
+
fallbacks: fallbackProviders
|
|
2523
|
+
});
|
|
2524
|
+
if (selected && selected !== provider) {
|
|
2525
|
+
const fallbackProfile = allProfiles.find((p) => p.provider === selected);
|
|
2526
|
+
if (fallbackProfile) {
|
|
2527
|
+
debug.warn("PROVIDER_FAILOVER_ACTIVATED", {
|
|
2528
|
+
from: provider,
|
|
2529
|
+
to: selected,
|
|
2530
|
+
model: fallbackProfile.modelName
|
|
2531
|
+
});
|
|
2532
|
+
provider = selected;
|
|
2533
|
+
modelProfile = fallbackProfile;
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2359
2537
|
if (provider === "anthropic" || provider === "bigdream" || provider === "opendev" || provider === "minimax-coding") {
|
|
2360
2538
|
return queryAnthropicNative(
|
|
2361
2539
|
messages,
|
|
@@ -2699,8 +2877,10 @@ async function queryAnthropicNative(messages, systemPrompt, maxThinkingTokens, t
|
|
|
2699
2877
|
const costUSD = inputTokens / 1e6 * getModelInputTokenCostUSD(model) + outputTokens / 1e6 * getModelOutputTokenCostUSD(model) + cacheCreationInputTokens / 1e6 * getModelInputTokenCostUSD(model) + cacheReadInputTokens / 1e6 * (getModelInputTokenCostUSD(model) * 0.1);
|
|
2700
2878
|
assistantMessage.costUSD = costUSD;
|
|
2701
2879
|
addToTotalCost(costUSD, durationMs);
|
|
2880
|
+
markProviderSuccess(provider, durationMs);
|
|
2702
2881
|
return assistantMessage;
|
|
2703
2882
|
} catch (error) {
|
|
2883
|
+
markProviderFailure(provider, error instanceof Error ? error.message : String(error));
|
|
2704
2884
|
return getAssistantMessageFromError(error);
|
|
2705
2885
|
}
|
|
2706
2886
|
}
|
|
@@ -2766,18 +2946,26 @@ async function queryOpenAI(messages, systemPrompt, maxThinkingTokens, tools, sig
|
|
|
2766
2946
|
type: "text"
|
|
2767
2947
|
})
|
|
2768
2948
|
);
|
|
2949
|
+
const provider = modelProfile?.provider || config.primaryProvider || "openai";
|
|
2950
|
+
const { structuredOutputConfig: getStructuredConfig } = await import("./structuredOutput-KAVFUV2Z.js");
|
|
2951
|
+
const structuredConfig = getStructuredConfig(provider);
|
|
2769
2952
|
const toolSchemas = await Promise.all(
|
|
2770
2953
|
tools.map(
|
|
2771
|
-
async (_) =>
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2954
|
+
async (_) => {
|
|
2955
|
+
const parameters = "inputJSONSchema" in _ && _.inputJSONSchema ? _.inputJSONSchema : zodToJsonSchema4(_.inputSchema);
|
|
2956
|
+
const toolDef = {
|
|
2957
|
+
type: "function",
|
|
2958
|
+
function: {
|
|
2959
|
+
name: _.name,
|
|
2960
|
+
description: await _.prompt({
|
|
2961
|
+
safeMode: options?.safeMode
|
|
2962
|
+
}),
|
|
2963
|
+
parameters,
|
|
2964
|
+
...structuredConfig.enableStrictTools ? { strict: true } : {}
|
|
2965
|
+
}
|
|
2966
|
+
};
|
|
2967
|
+
return toolDef;
|
|
2968
|
+
}
|
|
2781
2969
|
)
|
|
2782
2970
|
);
|
|
2783
2971
|
const openaiSystem = system.map(
|
|
@@ -2837,13 +3025,17 @@ async function queryOpenAI(messages, systemPrompt, maxThinkingTokens, tools, sig
|
|
|
2837
3025
|
}
|
|
2838
3026
|
let queryResult;
|
|
2839
3027
|
let startIncludingRetries = Date.now();
|
|
2840
|
-
|
|
2841
|
-
|
|
3028
|
+
const toolCallMaxRetries = structuredConfig.maxRetries;
|
|
3029
|
+
const isPostValidateMode = structuredConfig.mode === "post_validate";
|
|
3030
|
+
let throwOnToolParseError = true;
|
|
3031
|
+
const executeQuery = async () => {
|
|
3032
|
+
const shouldThrowOnParse = throwOnToolParseError;
|
|
3033
|
+
return withRetry(
|
|
2842
3034
|
async () => {
|
|
2843
3035
|
start = Date.now();
|
|
2844
3036
|
if (adapterContext) {
|
|
2845
3037
|
if (adapterContext.shouldUseResponses) {
|
|
2846
|
-
const { callGPT5ResponsesAPI } = await import("./openai-
|
|
3038
|
+
const { callGPT5ResponsesAPI } = await import("./openai-SMYIAIO4.js");
|
|
2847
3039
|
const response = await callGPT5ResponsesAPI(
|
|
2848
3040
|
modelProfile,
|
|
2849
3041
|
adapterContext.request,
|
|
@@ -2879,7 +3071,7 @@ async function queryOpenAI(messages, systemPrompt, maxThinkingTokens, tools, sig
|
|
|
2879
3071
|
} else {
|
|
2880
3072
|
finalResponse2 = s2;
|
|
2881
3073
|
}
|
|
2882
|
-
const message2 = convertOpenAIResponseToAnthropic(finalResponse2, tools);
|
|
3074
|
+
const message2 = convertOpenAIResponseToAnthropic(finalResponse2, tools, { throwOnParseError: shouldThrowOnParse, postValidate: isPostValidateMode });
|
|
2883
3075
|
const assistantMsg2 = {
|
|
2884
3076
|
type: "assistant",
|
|
2885
3077
|
message: message2,
|
|
@@ -2915,6 +3107,30 @@ async function queryOpenAI(messages, systemPrompt, maxThinkingTokens, tools, sig
|
|
|
2915
3107
|
if (toolSchemas.length > 0) {
|
|
2916
3108
|
opts.tools = toolSchemas;
|
|
2917
3109
|
opts.tool_choice = "auto";
|
|
3110
|
+
if (structuredConfig.mode === "format_json") {
|
|
3111
|
+
;
|
|
3112
|
+
opts.format = "json";
|
|
3113
|
+
} else if (structuredConfig.mode === "guided_json" && toolSchemas.length > 0) {
|
|
3114
|
+
const toolParamSchemas = toolSchemas.map((t) => t.function?.parameters).filter(Boolean);
|
|
3115
|
+
if (toolParamSchemas.length > 0) {
|
|
3116
|
+
;
|
|
3117
|
+
opts.guided_json = toolParamSchemas[0];
|
|
3118
|
+
}
|
|
3119
|
+
} else if (structuredConfig.mode === "strict" && !config.stream) {
|
|
3120
|
+
const firstToolSchema = toolSchemas[0];
|
|
3121
|
+
const paramSchema = firstToolSchema?.function?.parameters;
|
|
3122
|
+
if (paramSchema) {
|
|
3123
|
+
;
|
|
3124
|
+
opts.response_format = {
|
|
3125
|
+
type: "json_schema",
|
|
3126
|
+
json_schema: {
|
|
3127
|
+
name: "tool_call_output",
|
|
3128
|
+
strict: true,
|
|
3129
|
+
schema: paramSchema
|
|
3130
|
+
}
|
|
3131
|
+
};
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
2918
3134
|
}
|
|
2919
3135
|
const reasoningEffort = await getReasoningEffort(modelProfile, messages);
|
|
2920
3136
|
if (reasoningEffort) {
|
|
@@ -2931,7 +3147,7 @@ async function queryOpenAI(messages, systemPrompt, maxThinkingTokens, tools, sig
|
|
|
2931
3147
|
} else {
|
|
2932
3148
|
finalResponse = s;
|
|
2933
3149
|
}
|
|
2934
|
-
const message = convertOpenAIResponseToAnthropic(finalResponse, tools);
|
|
3150
|
+
const message = convertOpenAIResponseToAnthropic(finalResponse, tools, { throwOnParseError: shouldThrowOnParse, postValidate: isPostValidateMode });
|
|
2935
3151
|
const assistantMsg = {
|
|
2936
3152
|
type: "assistant",
|
|
2937
3153
|
message,
|
|
@@ -2947,7 +3163,36 @@ async function queryOpenAI(messages, systemPrompt, maxThinkingTokens, tools, sig
|
|
|
2947
3163
|
},
|
|
2948
3164
|
{ signal }
|
|
2949
3165
|
);
|
|
3166
|
+
};
|
|
3167
|
+
try {
|
|
3168
|
+
for (let attempt = 0; attempt <= toolCallMaxRetries; attempt++) {
|
|
3169
|
+
try {
|
|
3170
|
+
queryResult = await executeQuery();
|
|
3171
|
+
break;
|
|
3172
|
+
} catch (error) {
|
|
3173
|
+
if (error instanceof ToolCallParseError && attempt < toolCallMaxRetries) {
|
|
3174
|
+
debug.warn("TOOL_CALL_PARSE_RETRY", {
|
|
3175
|
+
toolName: error.toolName,
|
|
3176
|
+
attempt: attempt + 1,
|
|
3177
|
+
maxRetries: toolCallMaxRetries,
|
|
3178
|
+
rawArgs: error.rawArguments.slice(0, 200)
|
|
3179
|
+
});
|
|
3180
|
+
continue;
|
|
3181
|
+
}
|
|
3182
|
+
if (error instanceof ToolCallParseError) {
|
|
3183
|
+
debug.warn("TOOL_CALL_PARSE_EXHAUSTED", {
|
|
3184
|
+
toolName: error.toolName,
|
|
3185
|
+
rawArgs: error.rawArguments.slice(0, 200)
|
|
3186
|
+
});
|
|
3187
|
+
throwOnToolParseError = false;
|
|
3188
|
+
queryResult = await executeQuery();
|
|
3189
|
+
break;
|
|
3190
|
+
}
|
|
3191
|
+
throw error;
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
2950
3194
|
} catch (error) {
|
|
3195
|
+
markProviderFailure(provider, error instanceof Error ? error.message : String(error));
|
|
2951
3196
|
logError(error);
|
|
2952
3197
|
return getAssistantMessageFromError(error);
|
|
2953
3198
|
}
|
|
@@ -2965,6 +3210,7 @@ async function queryOpenAI(messages, systemPrompt, maxThinkingTokens, tools, sig
|
|
|
2965
3210
|
const cacheCreationInputTokens = normalizedUsage.cache_creation_input_tokens ?? 0;
|
|
2966
3211
|
const costUSD = inputTokens / 1e6 * SONNET_COST_PER_MILLION_INPUT_TOKENS + outputTokens / 1e6 * SONNET_COST_PER_MILLION_OUTPUT_TOKENS + cacheReadInputTokens / 1e6 * SONNET_COST_PER_MILLION_PROMPT_CACHE_READ_TOKENS + cacheCreationInputTokens / 1e6 * SONNET_COST_PER_MILLION_PROMPT_CACHE_WRITE_TOKENS;
|
|
2967
3212
|
addToTotalCost(costUSD, durationMsIncludingRetries);
|
|
3213
|
+
markProviderSuccess(provider, durationMs);
|
|
2968
3214
|
logLLMInteraction({
|
|
2969
3215
|
systemPrompt: systemPrompt.join("\n"),
|
|
2970
3216
|
messages: [...openaiSystem, ...openaiMessages],
|