pybao-cli 1.5.12 → 1.5.14
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-BZ3IK37X.js +50 -0
- package/dist/{acp-Y5IIA2WP.js → acp-AT5V4HJH.js} +31 -31
- package/dist/{agentsValidate-DY2NM3DJ.js → agentsValidate-RAMCNNGN.js} +7 -7
- package/dist/{ask-GPGFZXW5.js → ask-MSHFKMOM.js} +30 -30
- package/dist/{autoUpdater-M2OUQGQB.js → autoUpdater-SKKUYQGP.js} +3 -3
- package/dist/{chunk-7TQBXHKB.js → chunk-2UWY74V2.js} +1 -1
- package/dist/{chunk-NGJAMMVA.js → chunk-3I7K6SG5.js} +4 -4
- package/dist/{chunk-6BD6I6S2.js → chunk-3O5DLN4S.js} +3 -3
- package/dist/{chunk-PAF6R5NZ.js → chunk-5GJVTQ6Z.js} +1 -1
- package/dist/{chunk-GAQ4MRQE.js → chunk-633CKZ4H.js} +2 -2
- package/dist/{chunk-A5VNXFCK.js → chunk-656DI2PZ.js} +3 -3
- package/dist/{chunk-H36NFG5R.js → chunk-6GFXJLN3.js} +4 -4
- package/dist/{chunk-2ITFLNCF.js → chunk-7RAZGTUT.js} +1 -1
- package/dist/{chunk-5OQ3NGHH.js → chunk-BLPZN5F3.js} +1 -1
- package/dist/{chunk-4SRPMRVV.js → chunk-CCGXQSUZ.js} +3 -3
- package/dist/{chunk-VP6FXGFA.js → chunk-DPM2NLYC.js} +4 -4
- package/dist/{chunk-QCT45V24.js → chunk-DY2JCWQE.js} +1 -1
- package/dist/{chunk-55ZZ26MV.js → chunk-EL45JJXX.js} +3 -3
- package/dist/{chunk-5VJYKH3Y.js → chunk-EOZR4EWJ.js} +2 -2
- package/dist/{chunk-TYOFB7OQ.js → chunk-G2NQTS2X.js} +2 -2
- package/dist/{chunk-WNSD3D42.js → chunk-G4URT4VU.js} +1 -1
- package/dist/{chunk-3BURXBWN.js → chunk-GP4PJUZ5.js} +1 -1
- package/dist/{chunk-6MWZ7CQZ.js → chunk-GWIJUNRO.js} +702 -758
- package/dist/{chunk-6MWZ7CQZ.js.map → chunk-GWIJUNRO.js.map} +4 -4
- package/dist/{chunk-J5TXPVLF.js → chunk-HWG2BWLL.js} +3 -3
- package/dist/{chunk-4PFJOP5W.js → chunk-JWJC3DE2.js} +1 -1
- package/dist/{chunk-J4QOIMCY.js → chunk-KROM73XA.js} +15 -15
- package/dist/{chunk-227OYWVC.js → chunk-LFCRI4XF.js} +2 -2
- package/dist/{chunk-7TYWNOBA.js → chunk-P6GUR3BQ.js} +2 -2
- package/dist/{chunk-PFX6IKOO.js → chunk-PD3UXMJI.js} +2 -2
- package/dist/{chunk-4RFXDDFR.js → chunk-RAT3UGPD.js} +3 -3
- package/dist/{chunk-NKKES2C5.js → chunk-RAWU5JAN.js} +1 -1
- package/dist/{chunk-2OOXJ4JL.js → chunk-RE4W2ZJB.js} +8 -13
- package/dist/chunk-RE4W2ZJB.js.map +7 -0
- package/dist/{chunk-EYP4MYSC.js → chunk-W2IIXSKF.js} +4 -4
- package/dist/{chunk-M2UVICYL.js → chunk-WGK3XBGW.js} +1 -1
- package/dist/{chunk-IPK7SMWY.js → chunk-WSYTRNNY.js} +3 -3
- package/dist/{chunk-XBS7CGQI.js → chunk-XFCLMIVU.js} +1 -1
- package/dist/{chunk-RLHWOGYA.js → chunk-YDZG5W4V.js} +2 -1
- package/dist/chunk-YDZG5W4V.js.map +7 -0
- package/dist/{cli-XKJKAXHT.js → cli-BOWVY6R3.js} +91 -91
- package/dist/commands-5TSQH2YJ.js +54 -0
- package/dist/{config-GVJLYS6J.js → config-I2D37MAO.js} +4 -4
- package/dist/{context-4CGVBFDS.js → context-VABSOXYH.js} +6 -6
- package/dist/{conversationPersistence-G424Q2MK.js → conversationPersistence-5VZYNRKZ.js} +3 -3
- package/dist/{conversationTracker-Q26GHUUC.js → conversationTracker-GLBFPNV5.js} +4 -4
- package/dist/{customCommands-LM4FM5U3.js → customCommands-XDBZLSTQ.js} +4 -4
- package/dist/{env-L3OOLUJ2.js → env-LQC4XU2Q.js} +2 -2
- package/dist/{file-WDYIWIDQ.js → file-GG4AHH6L.js} +4 -4
- package/dist/index.js +3 -3
- package/dist/{llm-D52SN2GV.js → llm-BPQNYHE3.js} +31 -31
- package/dist/{llmLazy-3NN2ZUR4.js → llmLazy-ERIDXKJP.js} +1 -1
- package/dist/{loader-D2S3WQNM.js → loader-4PJMU2RQ.js} +4 -4
- package/dist/{lsp-HEXOWAPA.js → lsp-TTHCC6GK.js} +6 -6
- package/dist/{lspAnchor-L56WS5TF.js → lspAnchor-GVGHDYX4.js} +6 -6
- package/dist/{mcp-6QYH5WSD.js → mcp-7UXI2HGT.js} +7 -7
- package/dist/{mentionProcessor-HSJQXOES.js → mentionProcessor-MJMQGTMD.js} +5 -5
- package/dist/{messages-M7O4ITWW.js → messages-BGURJH5A.js} +1 -1
- package/dist/{model-OBGYKN2R.js → model-73TIVV4A.js} +5 -5
- package/dist/{openai-WSL6ONMZ.js → openai-AKBW3O3B.js} +5 -5
- package/dist/{outputStyles-PEKSPFFT.js → outputStyles-3OQCURTS.js} +4 -4
- package/dist/{pluginRuntime-HXPNSVLK.js → pluginRuntime-QWYITTNV.js} +6 -6
- package/dist/{pluginValidation-LUNRNYN5.js → pluginValidation-6KF6BNI3.js} +6 -6
- package/dist/prompts-MOJ3I4T4.js +56 -0
- package/dist/{pybAgentSessionLoad-2HQF3WDO.js → pybAgentSessionLoad-O6E64X5A.js} +4 -4
- package/dist/{pybAgentSessionResume-DHJIRJQX.js → pybAgentSessionResume-AQOFIWCM.js} +4 -4
- package/dist/{pybAgentStreamJsonSession-BPIP4CM4.js → pybAgentStreamJsonSession-IFBVOQOE.js} +1 -1
- package/dist/{pybHooks-YGTJ3V7F.js → pybHooks-WDSZDXUD.js} +4 -4
- package/dist/query-OC3TMXBW.js +56 -0
- package/dist/{registry-V4XSGNR3.js → registry-MPFGTVV6.js} +5 -5
- package/dist/{ripgrep-2NKICK37.js → ripgrep-JAKZKDZN.js} +3 -3
- package/dist/{skillMarketplace-BHCLGUQJ.js → skillMarketplace-OGHKQY7N.js} +3 -3
- package/dist/{state-QXUVP75D.js → state-KCGPU2FP.js} +2 -2
- package/dist/{theme-2TTCOHK4.js → theme-LMMG2NKE.js} +5 -5
- package/dist/{toolPermissionSettings-XE4MDEZ2.js → toolPermissionSettings-HVQSSP7C.js} +6 -6
- package/dist/tools-NE4ZQ7RG.js +55 -0
- package/dist/{userInput-AUO3ADIL.js → userInput-WGDHQIMP.js} +32 -32
- package/package.json +2 -1
- package/scripts/session-behavior-invariant-gate.mjs +10 -0
- package/dist/REPL-GBEPTREF.js +0 -50
- package/dist/chunk-2OOXJ4JL.js.map +0 -7
- package/dist/chunk-RLHWOGYA.js.map +0 -7
- package/dist/commands-TUBV2Y5X.js +0 -54
- package/dist/prompts-DUBZMFLB.js +0 -56
- package/dist/query-QQZDEGH6.js +0 -56
- package/dist/tools-SD5RYBF4.js +0 -55
- /package/dist/{REPL-GBEPTREF.js.map → REPL-BZ3IK37X.js.map} +0 -0
- /package/dist/{acp-Y5IIA2WP.js.map → acp-AT5V4HJH.js.map} +0 -0
- /package/dist/{agentsValidate-DY2NM3DJ.js.map → agentsValidate-RAMCNNGN.js.map} +0 -0
- /package/dist/{ask-GPGFZXW5.js.map → ask-MSHFKMOM.js.map} +0 -0
- /package/dist/{autoUpdater-M2OUQGQB.js.map → autoUpdater-SKKUYQGP.js.map} +0 -0
- /package/dist/{chunk-7TQBXHKB.js.map → chunk-2UWY74V2.js.map} +0 -0
- /package/dist/{chunk-NGJAMMVA.js.map → chunk-3I7K6SG5.js.map} +0 -0
- /package/dist/{chunk-6BD6I6S2.js.map → chunk-3O5DLN4S.js.map} +0 -0
- /package/dist/{chunk-PAF6R5NZ.js.map → chunk-5GJVTQ6Z.js.map} +0 -0
- /package/dist/{chunk-GAQ4MRQE.js.map → chunk-633CKZ4H.js.map} +0 -0
- /package/dist/{chunk-A5VNXFCK.js.map → chunk-656DI2PZ.js.map} +0 -0
- /package/dist/{chunk-H36NFG5R.js.map → chunk-6GFXJLN3.js.map} +0 -0
- /package/dist/{chunk-2ITFLNCF.js.map → chunk-7RAZGTUT.js.map} +0 -0
- /package/dist/{chunk-5OQ3NGHH.js.map → chunk-BLPZN5F3.js.map} +0 -0
- /package/dist/{chunk-4SRPMRVV.js.map → chunk-CCGXQSUZ.js.map} +0 -0
- /package/dist/{chunk-VP6FXGFA.js.map → chunk-DPM2NLYC.js.map} +0 -0
- /package/dist/{chunk-QCT45V24.js.map → chunk-DY2JCWQE.js.map} +0 -0
- /package/dist/{chunk-55ZZ26MV.js.map → chunk-EL45JJXX.js.map} +0 -0
- /package/dist/{chunk-5VJYKH3Y.js.map → chunk-EOZR4EWJ.js.map} +0 -0
- /package/dist/{chunk-TYOFB7OQ.js.map → chunk-G2NQTS2X.js.map} +0 -0
- /package/dist/{chunk-WNSD3D42.js.map → chunk-G4URT4VU.js.map} +0 -0
- /package/dist/{chunk-3BURXBWN.js.map → chunk-GP4PJUZ5.js.map} +0 -0
- /package/dist/{chunk-J5TXPVLF.js.map → chunk-HWG2BWLL.js.map} +0 -0
- /package/dist/{chunk-4PFJOP5W.js.map → chunk-JWJC3DE2.js.map} +0 -0
- /package/dist/{chunk-J4QOIMCY.js.map → chunk-KROM73XA.js.map} +0 -0
- /package/dist/{chunk-227OYWVC.js.map → chunk-LFCRI4XF.js.map} +0 -0
- /package/dist/{chunk-7TYWNOBA.js.map → chunk-P6GUR3BQ.js.map} +0 -0
- /package/dist/{chunk-PFX6IKOO.js.map → chunk-PD3UXMJI.js.map} +0 -0
- /package/dist/{chunk-4RFXDDFR.js.map → chunk-RAT3UGPD.js.map} +0 -0
- /package/dist/{chunk-NKKES2C5.js.map → chunk-RAWU5JAN.js.map} +0 -0
- /package/dist/{chunk-EYP4MYSC.js.map → chunk-W2IIXSKF.js.map} +0 -0
- /package/dist/{chunk-M2UVICYL.js.map → chunk-WGK3XBGW.js.map} +0 -0
- /package/dist/{chunk-IPK7SMWY.js.map → chunk-WSYTRNNY.js.map} +0 -0
- /package/dist/{chunk-XBS7CGQI.js.map → chunk-XFCLMIVU.js.map} +0 -0
- /package/dist/{cli-XKJKAXHT.js.map → cli-BOWVY6R3.js.map} +0 -0
- /package/dist/{commands-TUBV2Y5X.js.map → commands-5TSQH2YJ.js.map} +0 -0
- /package/dist/{config-GVJLYS6J.js.map → config-I2D37MAO.js.map} +0 -0
- /package/dist/{context-4CGVBFDS.js.map → context-VABSOXYH.js.map} +0 -0
- /package/dist/{conversationPersistence-G424Q2MK.js.map → conversationPersistence-5VZYNRKZ.js.map} +0 -0
- /package/dist/{conversationTracker-Q26GHUUC.js.map → conversationTracker-GLBFPNV5.js.map} +0 -0
- /package/dist/{customCommands-LM4FM5U3.js.map → customCommands-XDBZLSTQ.js.map} +0 -0
- /package/dist/{env-L3OOLUJ2.js.map → env-LQC4XU2Q.js.map} +0 -0
- /package/dist/{file-WDYIWIDQ.js.map → file-GG4AHH6L.js.map} +0 -0
- /package/dist/{llm-D52SN2GV.js.map → llm-BPQNYHE3.js.map} +0 -0
- /package/dist/{llmLazy-3NN2ZUR4.js.map → llmLazy-ERIDXKJP.js.map} +0 -0
- /package/dist/{loader-D2S3WQNM.js.map → loader-4PJMU2RQ.js.map} +0 -0
- /package/dist/{lsp-HEXOWAPA.js.map → lsp-TTHCC6GK.js.map} +0 -0
- /package/dist/{lspAnchor-L56WS5TF.js.map → lspAnchor-GVGHDYX4.js.map} +0 -0
- /package/dist/{mcp-6QYH5WSD.js.map → mcp-7UXI2HGT.js.map} +0 -0
- /package/dist/{mentionProcessor-HSJQXOES.js.map → mentionProcessor-MJMQGTMD.js.map} +0 -0
- /package/dist/{messages-M7O4ITWW.js.map → messages-BGURJH5A.js.map} +0 -0
- /package/dist/{model-OBGYKN2R.js.map → model-73TIVV4A.js.map} +0 -0
- /package/dist/{openai-WSL6ONMZ.js.map → openai-AKBW3O3B.js.map} +0 -0
- /package/dist/{outputStyles-PEKSPFFT.js.map → outputStyles-3OQCURTS.js.map} +0 -0
- /package/dist/{pluginRuntime-HXPNSVLK.js.map → pluginRuntime-QWYITTNV.js.map} +0 -0
- /package/dist/{pluginValidation-LUNRNYN5.js.map → pluginValidation-6KF6BNI3.js.map} +0 -0
- /package/dist/{prompts-DUBZMFLB.js.map → prompts-MOJ3I4T4.js.map} +0 -0
- /package/dist/{pybAgentSessionLoad-2HQF3WDO.js.map → pybAgentSessionLoad-O6E64X5A.js.map} +0 -0
- /package/dist/{pybAgentSessionResume-DHJIRJQX.js.map → pybAgentSessionResume-AQOFIWCM.js.map} +0 -0
- /package/dist/{pybAgentStreamJsonSession-BPIP4CM4.js.map → pybAgentStreamJsonSession-IFBVOQOE.js.map} +0 -0
- /package/dist/{pybHooks-YGTJ3V7F.js.map → pybHooks-WDSZDXUD.js.map} +0 -0
- /package/dist/{query-QQZDEGH6.js.map → query-OC3TMXBW.js.map} +0 -0
- /package/dist/{registry-V4XSGNR3.js.map → registry-MPFGTVV6.js.map} +0 -0
- /package/dist/{ripgrep-2NKICK37.js.map → ripgrep-JAKZKDZN.js.map} +0 -0
- /package/dist/{skillMarketplace-BHCLGUQJ.js.map → skillMarketplace-OGHKQY7N.js.map} +0 -0
- /package/dist/{state-QXUVP75D.js.map → state-KCGPU2FP.js.map} +0 -0
- /package/dist/{theme-2TTCOHK4.js.map → theme-LMMG2NKE.js.map} +0 -0
- /package/dist/{toolPermissionSettings-XE4MDEZ2.js.map → toolPermissionSettings-HVQSSP7C.js.map} +0 -0
- /package/dist/{tools-SD5RYBF4.js.map → tools-NE4ZQ7RG.js.map} +0 -0
- /package/dist/{userInput-AUO3ADIL.js.map → userInput-WGDHQIMP.js.map} +0 -0
|
@@ -2,18 +2,18 @@ import { createRequire as __pybCreateRequire } from "node:module";
|
|
|
2
2
|
const require = __pybCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
loadPybAgentSessionMessages
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-DY2JCWQE.js";
|
|
6
6
|
import {
|
|
7
7
|
listPybAgentSessions
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5GJVTQ6Z.js";
|
|
9
9
|
import {
|
|
10
10
|
appendSessionCustomTitleRecord,
|
|
11
11
|
appendSessionTagRecord
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-GP4PJUZ5.js";
|
|
13
13
|
import {
|
|
14
14
|
formatValidationResult,
|
|
15
15
|
validatePluginOrMarketplacePath
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-CCGXQSUZ.js";
|
|
17
17
|
import {
|
|
18
18
|
ConversationTracker,
|
|
19
19
|
appendFinishState,
|
|
@@ -21,10 +21,10 @@ import {
|
|
|
21
21
|
getConversationTrackerForContext,
|
|
22
22
|
isFinishComplete,
|
|
23
23
|
mapFinishReason
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-2UWY74V2.js";
|
|
25
25
|
import {
|
|
26
26
|
FileSystemConversationPersistence
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-RAWU5JAN.js";
|
|
28
28
|
import {
|
|
29
29
|
beginReplSessionScope
|
|
30
30
|
} from "./chunk-F4AXICO7.js";
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
runStopHooks,
|
|
40
40
|
runUserPromptSubmitHooks,
|
|
41
41
|
updateHookTranscriptForMessages
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-3O5DLN4S.js";
|
|
43
43
|
import {
|
|
44
44
|
DEFAULT_OUTPUT_STYLE,
|
|
45
45
|
getAvailableOutputStyles,
|
|
@@ -48,11 +48,11 @@ import {
|
|
|
48
48
|
getOutputStyleSystemPromptAdditions,
|
|
49
49
|
resolveOutputStyleName,
|
|
50
50
|
setCurrentOutputStyle
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-EOZR4EWJ.js";
|
|
52
52
|
import {
|
|
53
53
|
fetchCustomModels,
|
|
54
54
|
getModelFeatures
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-LFCRI4XF.js";
|
|
56
56
|
import {
|
|
57
57
|
getSessionState
|
|
58
58
|
} from "./chunk-XKYHFZEC.js";
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
queryLLM,
|
|
61
61
|
queryQuick,
|
|
62
62
|
verifyApiKey
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-DPM2NLYC.js";
|
|
64
64
|
import {
|
|
65
65
|
DEFAULT_TIMEOUT_MS,
|
|
66
66
|
FallbackToolUseRejectedMessage,
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
listMCPServers,
|
|
75
75
|
loadMergedSettings,
|
|
76
76
|
normalizeSandboxRuntimeConfigFromSettings
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-W2IIXSKF.js";
|
|
78
78
|
import {
|
|
79
79
|
addMarketplace,
|
|
80
80
|
disableSkillPlugin,
|
|
@@ -87,11 +87,11 @@ import {
|
|
|
87
87
|
refreshMarketplaceAsync,
|
|
88
88
|
removeMarketplace,
|
|
89
89
|
uninstallSkillPlugin
|
|
90
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-WGK3XBGW.js";
|
|
91
91
|
import {
|
|
92
92
|
loadToolPermissionContextFromDisk,
|
|
93
93
|
persistToolPermissionUpdateToDisk
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-656DI2PZ.js";
|
|
95
95
|
import {
|
|
96
96
|
applyToolPermissionContextUpdate,
|
|
97
97
|
applyToolPermissionContextUpdates,
|
|
@@ -102,13 +102,13 @@ import {
|
|
|
102
102
|
generateSystemReminders,
|
|
103
103
|
resetReminderSession,
|
|
104
104
|
systemReminderService
|
|
105
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-P6GUR3BQ.js";
|
|
106
106
|
import {
|
|
107
107
|
clearAgentCache,
|
|
108
108
|
getActiveAgents,
|
|
109
109
|
getAgentByType,
|
|
110
110
|
getAllAgents
|
|
111
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-G2NQTS2X.js";
|
|
112
112
|
import {
|
|
113
113
|
API_ERROR_MESSAGE_PREFIX,
|
|
114
114
|
CANCEL_MESSAGE,
|
|
@@ -145,7 +145,7 @@ import {
|
|
|
145
145
|
reorderMessages,
|
|
146
146
|
resetAutoCompactTelemetry,
|
|
147
147
|
stripSystemMessages
|
|
148
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-G4URT4VU.js";
|
|
149
149
|
import {
|
|
150
150
|
getRequestStatus,
|
|
151
151
|
setRequestStatus,
|
|
@@ -175,7 +175,7 @@ import {
|
|
|
175
175
|
normalizeFilePath,
|
|
176
176
|
readTextContent,
|
|
177
177
|
writeTextContent
|
|
178
|
-
} from "./chunk-
|
|
178
|
+
} from "./chunk-PD3UXMJI.js";
|
|
179
179
|
import {
|
|
180
180
|
parseBlockEdits
|
|
181
181
|
} from "./chunk-QWIBSCDN.js";
|
|
@@ -185,18 +185,18 @@ import {
|
|
|
185
185
|
ParserRegistry,
|
|
186
186
|
initParser,
|
|
187
187
|
loadLanguage
|
|
188
|
-
} from "./chunk-
|
|
188
|
+
} from "./chunk-6GFXJLN3.js";
|
|
189
189
|
import {
|
|
190
190
|
getSettingsFileCandidates,
|
|
191
191
|
loadSettingsWithLegacyFallback,
|
|
192
192
|
readSettingsFile
|
|
193
|
-
} from "./chunk-
|
|
193
|
+
} from "./chunk-JWJC3DE2.js";
|
|
194
194
|
import {
|
|
195
195
|
getCustomCommandDirectories,
|
|
196
196
|
hasCustomCommands,
|
|
197
197
|
loadCustomCommands,
|
|
198
198
|
reloadCustomCommands
|
|
199
|
-
} from "./chunk-
|
|
199
|
+
} from "./chunk-633CKZ4H.js";
|
|
200
200
|
import {
|
|
201
201
|
getSessionPlugins
|
|
202
202
|
} from "./chunk-BJSWTHRM.js";
|
|
@@ -205,7 +205,7 @@ import {
|
|
|
205
205
|
buildModelProfileKey,
|
|
206
206
|
getModelManager,
|
|
207
207
|
isDefaultSlowAndCapableModel
|
|
208
|
-
} from "./chunk-
|
|
208
|
+
} from "./chunk-RAT3UGPD.js";
|
|
209
209
|
import {
|
|
210
210
|
getCodeStyle,
|
|
211
211
|
getContext,
|
|
@@ -213,16 +213,16 @@ import {
|
|
|
213
213
|
getIsGit,
|
|
214
214
|
getProjectDocs,
|
|
215
215
|
getProjectStructureStatisticsBlock
|
|
216
|
-
} from "./chunk-
|
|
216
|
+
} from "./chunk-3I7K6SG5.js";
|
|
217
217
|
import {
|
|
218
218
|
getRipgrepPath,
|
|
219
219
|
getRipgrepPolicyMode,
|
|
220
220
|
resolveRipgrepPolicy,
|
|
221
221
|
ripGrep
|
|
222
|
-
} from "./chunk-
|
|
222
|
+
} from "./chunk-XFCLMIVU.js";
|
|
223
223
|
import {
|
|
224
224
|
getTheme
|
|
225
|
-
} from "./chunk-
|
|
225
|
+
} from "./chunk-BLPZN5F3.js";
|
|
226
226
|
import {
|
|
227
227
|
DEFAULT_GLOBAL_CONFIG,
|
|
228
228
|
enableConfigs,
|
|
@@ -235,7 +235,7 @@ import {
|
|
|
235
235
|
saveGlobalConfig,
|
|
236
236
|
setAllPointersToModel,
|
|
237
237
|
setModelPointer
|
|
238
|
-
} from "./chunk-
|
|
238
|
+
} from "./chunk-EL45JJXX.js";
|
|
239
239
|
import {
|
|
240
240
|
AbortError
|
|
241
241
|
} from "./chunk-RQVLBMP7.js";
|
|
@@ -244,7 +244,7 @@ import {
|
|
|
244
244
|
getCurrentRequest,
|
|
245
245
|
logUserFriendly,
|
|
246
246
|
markPhase
|
|
247
|
-
} from "./chunk-
|
|
247
|
+
} from "./chunk-7RAZGTUT.js";
|
|
248
248
|
import {
|
|
249
249
|
ASCII_LOGO,
|
|
250
250
|
BunShell,
|
|
@@ -285,10 +285,10 @@ import {
|
|
|
285
285
|
setCwd,
|
|
286
286
|
shouldApplyToolOutputTruncation,
|
|
287
287
|
truncateToolOutput
|
|
288
|
-
} from "./chunk-
|
|
288
|
+
} from "./chunk-RE4W2ZJB.js";
|
|
289
289
|
import {
|
|
290
290
|
MACRO
|
|
291
|
-
} from "./chunk-
|
|
291
|
+
} from "./chunk-YDZG5W4V.js";
|
|
292
292
|
import {
|
|
293
293
|
__export
|
|
294
294
|
} from "./chunk-I3J4JYES.js";
|
|
@@ -469,7 +469,7 @@ var getCommandSubcommandPrefix = memoize(
|
|
|
469
469
|
var getCommandPrefix = memoize(
|
|
470
470
|
async (command4, abortSignal) => {
|
|
471
471
|
const { systemPrompt, userPrompt } = buildBashCommandPrefixDetectionPrompt(command4);
|
|
472
|
-
const { API_ERROR_MESSAGE_PREFIX: API_ERROR_MESSAGE_PREFIX2, queryQuick: queryQuick2 } = await import("./llm-
|
|
472
|
+
const { API_ERROR_MESSAGE_PREFIX: API_ERROR_MESSAGE_PREFIX2, queryQuick: queryQuick2 } = await import("./llm-BPQNYHE3.js");
|
|
473
473
|
const response = await queryQuick2({
|
|
474
474
|
systemPrompt,
|
|
475
475
|
userPrompt,
|
|
@@ -4271,7 +4271,7 @@ function formatParseError(error) {
|
|
|
4271
4271
|
return error instanceof Error ? error.message : String(error);
|
|
4272
4272
|
}
|
|
4273
4273
|
async function defaultGateQuery(args) {
|
|
4274
|
-
const { API_ERROR_MESSAGE_PREFIX: API_ERROR_MESSAGE_PREFIX2, queryLLM: queryLLM2 } = await import("./llm-
|
|
4274
|
+
const { API_ERROR_MESSAGE_PREFIX: API_ERROR_MESSAGE_PREFIX2, queryLLM: queryLLM2 } = await import("./llm-BPQNYHE3.js");
|
|
4275
4275
|
const queryLLMFn = args.queryLLMOverride ?? queryLLM2;
|
|
4276
4276
|
const messages = [
|
|
4277
4277
|
{
|
|
@@ -6664,7 +6664,7 @@ var FileEditTool = {
|
|
|
6664
6664
|
const originalFileContent = currentFileContent;
|
|
6665
6665
|
let totalPatch = [];
|
|
6666
6666
|
const { SmartEdit } = await import("./smart-edit-AWHJDSU6.js");
|
|
6667
|
-
const { findLspAnchor } = await import("./lspAnchor-
|
|
6667
|
+
const { findLspAnchor } = await import("./lspAnchor-GVGHDYX4.js");
|
|
6668
6668
|
for (const op of editOperations) {
|
|
6669
6669
|
const normalizedSearch = normalizeLineEndings(op.search);
|
|
6670
6670
|
const normalizedReplace = normalizeLineEndings(op.replace);
|
|
@@ -12149,7 +12149,7 @@ async function createAndStoreApiKey(accessToken) {
|
|
|
12149
12149
|
}
|
|
12150
12150
|
saveGlobalConfig(config2);
|
|
12151
12151
|
try {
|
|
12152
|
-
const { resetAnthropicClient } = await import("./llm-
|
|
12152
|
+
const { resetAnthropicClient } = await import("./llm-BPQNYHE3.js");
|
|
12153
12153
|
resetAnthropicClient();
|
|
12154
12154
|
} catch {
|
|
12155
12155
|
}
|
|
@@ -16573,7 +16573,7 @@ async function refreshPluginRuntimeFromInstalls() {
|
|
|
16573
16573
|
const existingRoots = getSessionPlugins().map((p) => p.rootDir);
|
|
16574
16574
|
const dirs = Array.from(/* @__PURE__ */ new Set([...existingRoots, ...installedRoots]));
|
|
16575
16575
|
if (dirs.length === 0) return [];
|
|
16576
|
-
const { configureSessionPlugins } = await import("./pluginRuntime-
|
|
16576
|
+
const { configureSessionPlugins } = await import("./pluginRuntime-QWYITTNV.js");
|
|
16577
16577
|
const { errors } = await configureSessionPlugins({ pluginDirs: dirs });
|
|
16578
16578
|
return errors;
|
|
16579
16579
|
}
|
|
@@ -17248,7 +17248,7 @@ async function call(onDone, context) {
|
|
|
17248
17248
|
ModelConfig,
|
|
17249
17249
|
{
|
|
17250
17250
|
onClose: () => {
|
|
17251
|
-
import("./model-
|
|
17251
|
+
import("./model-73TIVV4A.js").then(({ reloadModelManager: reloadModelManager2 }) => {
|
|
17252
17252
|
reloadModelManager2();
|
|
17253
17253
|
triggerModelConfigChange();
|
|
17254
17254
|
onDone();
|
|
@@ -25557,7 +25557,7 @@ function useStatusLine() {
|
|
|
25557
25557
|
// src/ui/components/PromptInput.tsx
|
|
25558
25558
|
async function interpretHashCommand(input) {
|
|
25559
25559
|
try {
|
|
25560
|
-
const { queryQuick: queryQuick2 } = await import("./llm-
|
|
25560
|
+
const { queryQuick: queryQuick2 } = await import("./llm-BPQNYHE3.js");
|
|
25561
25561
|
const systemPrompt = [
|
|
25562
25562
|
"You're helping the user structure notes that will be added to their PYB.md file.",
|
|
25563
25563
|
"Format the user's input into a well-structured note that will be useful for later reference.",
|
|
@@ -25870,7 +25870,7 @@ function PromptInput({
|
|
|
25870
25870
|
if (messages2.length) {
|
|
25871
25871
|
if (mode === "bash") {
|
|
25872
25872
|
onQuery(messages2, newAbortController).then(async () => {
|
|
25873
|
-
const { getCwd: getCwd2 } = await import("./state-
|
|
25873
|
+
const { getCwd: getCwd2 } = await import("./state-KCGPU2FP.js");
|
|
25874
25874
|
setCurrentPwd(getCwd2());
|
|
25875
25875
|
});
|
|
25876
25876
|
} else {
|
|
@@ -30040,6 +30040,271 @@ function flushConversationTrackerTelemetrySnapshot(options = {}) {
|
|
|
30040
30040
|
return record;
|
|
30041
30041
|
}
|
|
30042
30042
|
|
|
30043
|
+
// src/services/ai/streamTyped/projector.ts
|
|
30044
|
+
function supportsRichToolResultByProvider(provider) {
|
|
30045
|
+
return String(provider ?? "").trim().toLowerCase() === "anthropic";
|
|
30046
|
+
}
|
|
30047
|
+
function extractToolResultText2(content) {
|
|
30048
|
+
if (typeof content === "string") return { text: content, hasNonTextBlock: false };
|
|
30049
|
+
if (!Array.isArray(content)) return { text: "", hasNonTextBlock: false };
|
|
30050
|
+
let hasNonTextBlock = false;
|
|
30051
|
+
const text = content.filter((block) => {
|
|
30052
|
+
if (!block || typeof block !== "object") return false;
|
|
30053
|
+
if (block.type === "text") return true;
|
|
30054
|
+
hasNonTextBlock = true;
|
|
30055
|
+
return false;
|
|
30056
|
+
}).map((block) => String(block.text ?? "")).join("\n");
|
|
30057
|
+
return { text, hasNonTextBlock };
|
|
30058
|
+
}
|
|
30059
|
+
function extractTaggedText(text, tagName) {
|
|
30060
|
+
const normalized = String(text ?? "").trim();
|
|
30061
|
+
if (!normalized.startsWith(`<${tagName}>`)) return null;
|
|
30062
|
+
const pattern = new RegExp(`<${tagName}>([\\s\\S]*?)<\\/${tagName}>`, "i");
|
|
30063
|
+
const match = normalized.match(pattern);
|
|
30064
|
+
const content = String(match?.[1] ?? "").trim();
|
|
30065
|
+
return content.length > 0 ? content : null;
|
|
30066
|
+
}
|
|
30067
|
+
function projectAssistantMessage(state, message) {
|
|
30068
|
+
const content = message?.message?.content;
|
|
30069
|
+
if (!Array.isArray(content)) return;
|
|
30070
|
+
for (let i = 0; i < content.length; i += 1) {
|
|
30071
|
+
const block = content[i];
|
|
30072
|
+
if (!block || typeof block !== "object") continue;
|
|
30073
|
+
const type3 = String(block.type ?? "");
|
|
30074
|
+
if (type3 === "text") {
|
|
30075
|
+
const text = String(block.text ?? "");
|
|
30076
|
+
const toolProgressText = extractTaggedText(text, "tool-progress");
|
|
30077
|
+
if (toolProgressText) {
|
|
30078
|
+
state.parts.push(
|
|
30079
|
+
createSystemEventPart({
|
|
30080
|
+
requestId: state.requestId,
|
|
30081
|
+
eventType: "tool_progress",
|
|
30082
|
+
text: toolProgressText,
|
|
30083
|
+
source: state.source
|
|
30084
|
+
})
|
|
30085
|
+
);
|
|
30086
|
+
}
|
|
30087
|
+
const localStdoutText = extractTaggedText(text, "local-command-stdout");
|
|
30088
|
+
if (localStdoutText) {
|
|
30089
|
+
state.parts.push(
|
|
30090
|
+
createSystemEventPart({
|
|
30091
|
+
requestId: state.requestId,
|
|
30092
|
+
eventType: "local_command_stdout",
|
|
30093
|
+
text: localStdoutText,
|
|
30094
|
+
source: state.source
|
|
30095
|
+
})
|
|
30096
|
+
);
|
|
30097
|
+
}
|
|
30098
|
+
const localStderrText = extractTaggedText(text, "local-command-stderr");
|
|
30099
|
+
if (localStderrText) {
|
|
30100
|
+
state.parts.push(
|
|
30101
|
+
createSystemEventPart({
|
|
30102
|
+
requestId: state.requestId,
|
|
30103
|
+
eventType: "local_command_stderr",
|
|
30104
|
+
text: localStderrText,
|
|
30105
|
+
source: state.source
|
|
30106
|
+
})
|
|
30107
|
+
);
|
|
30108
|
+
}
|
|
30109
|
+
onTextStart({ textId: `text-${i}` }, state);
|
|
30110
|
+
onTextDelta({ textId: `text-${i}`, text }, state);
|
|
30111
|
+
onTextEnd({ textId: `text-${i}` }, state);
|
|
30112
|
+
continue;
|
|
30113
|
+
}
|
|
30114
|
+
if (type3 === "thinking" || type3 === "reasoning") {
|
|
30115
|
+
const text = String(block.thinking ?? block.reasoning ?? "");
|
|
30116
|
+
onReasoningStart({ reasoningId: `reasoning-${i}` }, state);
|
|
30117
|
+
onReasoningDelta({ reasoningId: `reasoning-${i}`, text }, state);
|
|
30118
|
+
onReasoningEnd({ reasoningId: `reasoning-${i}` }, state);
|
|
30119
|
+
continue;
|
|
30120
|
+
}
|
|
30121
|
+
if (type3 === "tool_use" || type3 === "server_tool_use" || type3 === "mcp_tool_use") {
|
|
30122
|
+
const toolCallId = String(block.id ?? `tool-${i}`);
|
|
30123
|
+
const toolName = String(block.name ?? "unknown");
|
|
30124
|
+
onToolCall({ toolCallId, toolName }, state);
|
|
30125
|
+
}
|
|
30126
|
+
}
|
|
30127
|
+
}
|
|
30128
|
+
function projectUserToolResult(projector, message) {
|
|
30129
|
+
const state = projector.state;
|
|
30130
|
+
const content = message?.message?.content;
|
|
30131
|
+
if (!Array.isArray(content)) return;
|
|
30132
|
+
for (let i = 0; i < content.length; i += 1) {
|
|
30133
|
+
const block = content[i];
|
|
30134
|
+
if (!block || typeof block !== "object") continue;
|
|
30135
|
+
if (block.type !== "tool_result") continue;
|
|
30136
|
+
const toolCallId = String(block.tool_use_id ?? `tool-${i}`);
|
|
30137
|
+
const extracted = extractToolResultText2(block.content);
|
|
30138
|
+
if (extracted.hasNonTextBlock) {
|
|
30139
|
+
projector.richToolResultBlockCount += 1;
|
|
30140
|
+
if (!projector.supportsRichToolResult) {
|
|
30141
|
+
projector.downgradedToolResultCount += 1;
|
|
30142
|
+
}
|
|
30143
|
+
}
|
|
30144
|
+
onToolResult(
|
|
30145
|
+
{
|
|
30146
|
+
toolCallId,
|
|
30147
|
+
status: block.is_error ? "failed" : "completed",
|
|
30148
|
+
outputText: extracted.text
|
|
30149
|
+
},
|
|
30150
|
+
state
|
|
30151
|
+
);
|
|
30152
|
+
}
|
|
30153
|
+
}
|
|
30154
|
+
function projectProgressMessage(state, message) {
|
|
30155
|
+
const toolCallId = String(message?.toolUseID ?? "").trim();
|
|
30156
|
+
if (!toolCallId) return;
|
|
30157
|
+
const content = String(
|
|
30158
|
+
message?.content?.message?.content?.find?.((block) => block?.type === "text")?.text ?? ""
|
|
30159
|
+
);
|
|
30160
|
+
const extractedProgressText = extractTaggedText(content, "tool-progress");
|
|
30161
|
+
const normalizedContent = content.trim();
|
|
30162
|
+
const toolProgressText = extractedProgressText ?? (normalizedContent.length > 0 ? normalizedContent : void 0);
|
|
30163
|
+
if (toolProgressText) {
|
|
30164
|
+
state.parts.push(
|
|
30165
|
+
createSystemEventPart({
|
|
30166
|
+
requestId: state.requestId,
|
|
30167
|
+
eventType: "tool_progress",
|
|
30168
|
+
text: toolProgressText,
|
|
30169
|
+
toolCallId,
|
|
30170
|
+
source: state.source
|
|
30171
|
+
})
|
|
30172
|
+
);
|
|
30173
|
+
}
|
|
30174
|
+
onToolResult(
|
|
30175
|
+
{
|
|
30176
|
+
toolCallId,
|
|
30177
|
+
status: "running",
|
|
30178
|
+
outputText: content || void 0
|
|
30179
|
+
},
|
|
30180
|
+
state
|
|
30181
|
+
);
|
|
30182
|
+
}
|
|
30183
|
+
function createStreamTypedProjector(options) {
|
|
30184
|
+
const provider = String(options.provider ?? "").trim().toLowerCase();
|
|
30185
|
+
return {
|
|
30186
|
+
state: createAssemblerState(options.requestId, options.source ?? "query_main"),
|
|
30187
|
+
provider,
|
|
30188
|
+
supportsRichToolResult: typeof options.supportsRichToolResult === "boolean" ? options.supportsRichToolResult : supportsRichToolResultByProvider(provider),
|
|
30189
|
+
richToolResultBlockCount: 0,
|
|
30190
|
+
downgradedToolResultCount: 0
|
|
30191
|
+
};
|
|
30192
|
+
}
|
|
30193
|
+
function consumeProjectorCompatibilityMetrics(projector) {
|
|
30194
|
+
const snapshot = {
|
|
30195
|
+
provider: projector.provider || "unknown",
|
|
30196
|
+
supportsRichToolResult: projector.supportsRichToolResult,
|
|
30197
|
+
richToolResultBlockCount: projector.richToolResultBlockCount,
|
|
30198
|
+
downgradedToolResultCount: projector.downgradedToolResultCount
|
|
30199
|
+
};
|
|
30200
|
+
projector.richToolResultBlockCount = 0;
|
|
30201
|
+
projector.downgradedToolResultCount = 0;
|
|
30202
|
+
return snapshot;
|
|
30203
|
+
}
|
|
30204
|
+
function projectMessageToTypedParts(projector, message) {
|
|
30205
|
+
if (!message || typeof message !== "object") return [];
|
|
30206
|
+
if (message.type === "assistant") {
|
|
30207
|
+
projectAssistantMessage(projector.state, message);
|
|
30208
|
+
} else if (message.type === "user") {
|
|
30209
|
+
projectUserToolResult(projector, message);
|
|
30210
|
+
} else if (message.type === "progress") {
|
|
30211
|
+
projectProgressMessage(projector.state, message);
|
|
30212
|
+
}
|
|
30213
|
+
return flushTypedParts(projector.state);
|
|
30214
|
+
}
|
|
30215
|
+
function projectLifecycleEventsToTypedParts(projector, events) {
|
|
30216
|
+
if (!Array.isArray(events) || events.length === 0) return [];
|
|
30217
|
+
const parts = [];
|
|
30218
|
+
for (const event of events) {
|
|
30219
|
+
if (!event || typeof event !== "object") continue;
|
|
30220
|
+
if (event.eventType === "start-step") {
|
|
30221
|
+
parts.push(
|
|
30222
|
+
createStepStartPart({
|
|
30223
|
+
requestId: projector.state.requestId,
|
|
30224
|
+
stepId: event.stepId,
|
|
30225
|
+
timeStart: event.timestamp,
|
|
30226
|
+
source: projector.state.source
|
|
30227
|
+
})
|
|
30228
|
+
);
|
|
30229
|
+
continue;
|
|
30230
|
+
}
|
|
30231
|
+
if (event.eventType === "finish-step") {
|
|
30232
|
+
parts.push(
|
|
30233
|
+
createStepFinishPart({
|
|
30234
|
+
requestId: projector.state.requestId,
|
|
30235
|
+
stepId: event.stepId,
|
|
30236
|
+
reason: event.reason,
|
|
30237
|
+
completedAt: event.completedAt,
|
|
30238
|
+
costUSD: event.costUSD,
|
|
30239
|
+
...event.tokens ? { tokens: event.tokens } : {},
|
|
30240
|
+
source: projector.state.source
|
|
30241
|
+
})
|
|
30242
|
+
);
|
|
30243
|
+
}
|
|
30244
|
+
}
|
|
30245
|
+
return parts;
|
|
30246
|
+
}
|
|
30247
|
+
|
|
30248
|
+
// src/services/ai/streamTyped/skeletonReader.ts
|
|
30249
|
+
function pushText(parts, value) {
|
|
30250
|
+
const text = String(value ?? "").trim();
|
|
30251
|
+
if (!text) return;
|
|
30252
|
+
parts.push({ type: "text", text });
|
|
30253
|
+
}
|
|
30254
|
+
function getToolState(part) {
|
|
30255
|
+
if (part.partType !== "tool") return null;
|
|
30256
|
+
const payload = part.payload;
|
|
30257
|
+
return payload?.state ?? null;
|
|
30258
|
+
}
|
|
30259
|
+
function buildSkeletonBlocksFromTypedParts(input) {
|
|
30260
|
+
const result = [];
|
|
30261
|
+
for (const part of input.parts) {
|
|
30262
|
+
if (!part || typeof part !== "object") continue;
|
|
30263
|
+
if (part.partType === "text") {
|
|
30264
|
+
pushText(result, part.payload?.text);
|
|
30265
|
+
continue;
|
|
30266
|
+
}
|
|
30267
|
+
if (part.partType === "reasoning" && input.role === "assistant") {
|
|
30268
|
+
const reasoning = String(part.payload?.text ?? "").trim();
|
|
30269
|
+
if (!reasoning) continue;
|
|
30270
|
+
result.push({ type: "reasoning", reasoning });
|
|
30271
|
+
continue;
|
|
30272
|
+
}
|
|
30273
|
+
if (part.partType !== "tool") continue;
|
|
30274
|
+
const payload = part.payload;
|
|
30275
|
+
const state = getToolState(part);
|
|
30276
|
+
const status = String(
|
|
30277
|
+
state?.status ?? payload?.status ?? ""
|
|
30278
|
+
).toLowerCase();
|
|
30279
|
+
const toolName = String(payload?.toolName ?? "").trim();
|
|
30280
|
+
const toolCallId = String(payload?.toolCallId ?? "").trim();
|
|
30281
|
+
if (!toolCallId) continue;
|
|
30282
|
+
if (input.role === "assistant") {
|
|
30283
|
+
if (status !== "pending") continue;
|
|
30284
|
+
result.push({
|
|
30285
|
+
type: "tool_use",
|
|
30286
|
+
id: toolCallId,
|
|
30287
|
+
name: toolName || "unknown",
|
|
30288
|
+
input: state?.input && typeof state.input === "object" ? state.input : payload?.input && typeof payload.input === "object" ? payload.input : {}
|
|
30289
|
+
});
|
|
30290
|
+
continue;
|
|
30291
|
+
}
|
|
30292
|
+
if (status !== "completed" && status !== "failed" && status !== "interrupted") {
|
|
30293
|
+
continue;
|
|
30294
|
+
}
|
|
30295
|
+
const content = String(
|
|
30296
|
+
state?.output ?? state?.error ?? state?.reason ?? payload?.outputText ?? ""
|
|
30297
|
+
).trim();
|
|
30298
|
+
result.push({
|
|
30299
|
+
type: "tool_result",
|
|
30300
|
+
tool_use_id: toolCallId,
|
|
30301
|
+
content,
|
|
30302
|
+
...status === "failed" ? { is_error: true } : {}
|
|
30303
|
+
});
|
|
30304
|
+
}
|
|
30305
|
+
return result;
|
|
30306
|
+
}
|
|
30307
|
+
|
|
30043
30308
|
// src/app/queryLifecycleEvents.ts
|
|
30044
30309
|
function createStepId(input) {
|
|
30045
30310
|
const base = (input.queryId || input.requestId || "unknown").replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
@@ -30274,13 +30539,6 @@ function resolveQuerySessionFeatureFlags() {
|
|
|
30274
30539
|
rolloutReason: "rollout_disabled"
|
|
30275
30540
|
};
|
|
30276
30541
|
}
|
|
30277
|
-
function buildQueryTypedRequestId(args) {
|
|
30278
|
-
if (args.currentRequestId) return `query_${args.currentRequestId}`;
|
|
30279
|
-
if (args.fallbackQueryId) return `query_${args.fallbackQueryId}`;
|
|
30280
|
-
const now = args.now ?? Date.now();
|
|
30281
|
-
const randomSuffix = args.randomSuffix ?? Math.random().toString(36).slice(2, 10);
|
|
30282
|
-
return `query_${now}_${randomSuffix}`;
|
|
30283
|
-
}
|
|
30284
30542
|
function prepareQueryTypedProjector(args) {
|
|
30285
30543
|
const modelPointer = args.modelPointer || "main";
|
|
30286
30544
|
const modelResolution = args.resolveModelWithInfo(modelPointer);
|
|
@@ -30290,16 +30548,7 @@ function prepareQueryTypedProjector(args) {
|
|
|
30290
30548
|
source: "query_main",
|
|
30291
30549
|
provider: typedProvider
|
|
30292
30550
|
});
|
|
30293
|
-
return {
|
|
30294
|
-
}
|
|
30295
|
-
function findLatestValue(args) {
|
|
30296
|
-
for (let index = args.items.length - 1; index >= 0; index -= 1) {
|
|
30297
|
-
const value = args.selectValue(args.items[index]);
|
|
30298
|
-
if (value !== void 0 && value !== null) {
|
|
30299
|
-
return value;
|
|
30300
|
-
}
|
|
30301
|
-
}
|
|
30302
|
-
return void 0;
|
|
30551
|
+
return { typedProjector };
|
|
30303
30552
|
}
|
|
30304
30553
|
function prepareQuerySessionExecution(args) {
|
|
30305
30554
|
args.onRolloutApplied(args.featureFlags);
|
|
@@ -30321,14 +30570,15 @@ function prepareQuerySessionExecution(args) {
|
|
|
30321
30570
|
}
|
|
30322
30571
|
function prepareQuerySessionPrimaryPlan(args) {
|
|
30323
30572
|
const shouldPersistSession = args.toolUseContext.options?.persistSession !== false && !args.isTestEnv;
|
|
30324
|
-
|
|
30325
|
-
|
|
30326
|
-
|
|
30327
|
-
|
|
30328
|
-
|
|
30329
|
-
|
|
30330
|
-
|
|
30331
|
-
}
|
|
30573
|
+
let fallbackQueryId;
|
|
30574
|
+
for (let index = args.messages.length - 1; index >= 0; index -= 1) {
|
|
30575
|
+
const value = args.extractUserQueryId(args.messages[index]);
|
|
30576
|
+
if (value !== void 0 && value !== null) {
|
|
30577
|
+
fallbackQueryId = value;
|
|
30578
|
+
break;
|
|
30579
|
+
}
|
|
30580
|
+
}
|
|
30581
|
+
const typedRequestId = args.currentRequestId ? `query_${args.currentRequestId}` : fallbackQueryId ? `query_${fallbackQueryId}` : `query_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
30332
30582
|
args.policyCoordinator?.setRequestId(typedRequestId);
|
|
30333
30583
|
const { typedProjector } = prepareQueryTypedProjector({
|
|
30334
30584
|
requestId: typedRequestId,
|
|
@@ -30466,28 +30716,19 @@ async function* runQuerySessionPrimaryAdapter(args) {
|
|
|
30466
30716
|
runner: runQuerySessionPrimary
|
|
30467
30717
|
});
|
|
30468
30718
|
}
|
|
30469
|
-
async function*
|
|
30719
|
+
async function* runQuerySessionLegacyCompatAdapter(args) {
|
|
30470
30720
|
const primaryInput = createQuerySessionPrimaryAdapterInput(args);
|
|
30471
30721
|
yield* runSessionCompatStreams({
|
|
30472
|
-
routingContext: args.routingContext,
|
|
30473
|
-
primaryInput,
|
|
30474
|
-
primaryRunner: runQuerySessionPrimaryAdapter,
|
|
30475
|
-
fallbackInput: args.fallbackInput,
|
|
30476
|
-
fallbackRunner: args.fallbackRunner,
|
|
30477
|
-
toolUseContext: args.toolUseContext
|
|
30478
|
-
});
|
|
30479
|
-
}
|
|
30480
|
-
async function* runQuerySessionLegacyCompatAdapter(args) {
|
|
30481
|
-
const streamRunner = args.stream;
|
|
30482
|
-
yield* runQuerySessionCompatAdapter({
|
|
30483
|
-
...args,
|
|
30484
30722
|
routingContext: {
|
|
30485
30723
|
sessionId: args.toolUseContext.sessionId,
|
|
30486
30724
|
agentId: args.toolUseContext.agentId,
|
|
30487
30725
|
requestId: args.requestId
|
|
30488
30726
|
},
|
|
30727
|
+
primaryInput,
|
|
30728
|
+
primaryRunner: runQuerySessionPrimaryAdapter,
|
|
30489
30729
|
fallbackInput: args.messages,
|
|
30490
|
-
fallbackRunner:
|
|
30730
|
+
fallbackRunner: args.stream,
|
|
30731
|
+
toolUseContext: args.toolUseContext
|
|
30491
30732
|
});
|
|
30492
30733
|
}
|
|
30493
30734
|
function processQuerySessionTypedOutput(args) {
|
|
@@ -30577,38 +30818,16 @@ async function* runSessionOrchestrator(args) {
|
|
|
30577
30818
|
runner: selectedRunner
|
|
30578
30819
|
});
|
|
30579
30820
|
}
|
|
30580
|
-
function
|
|
30581
|
-
|
|
30582
|
-
}
|
|
30583
|
-
async function* runSessionOrchestratorWithContext(args) {
|
|
30584
|
-
const replaySeed = createSessionReplaySeed(args.routingContext);
|
|
30821
|
+
async function* runSessionCompatStreams(args) {
|
|
30822
|
+
const sessionContext = ensureSessionContext(args.toolUseContext);
|
|
30823
|
+
const replaySeed = `${args.routingContext.sessionId ?? ""}:${args.routingContext.agentId ?? ""}:${args.routingContext.requestId ?? ""}`;
|
|
30585
30824
|
yield* runSessionOrchestrator({
|
|
30586
|
-
input: args.input,
|
|
30587
|
-
replaySeed,
|
|
30588
|
-
sessionRunner: args.sessionRunner,
|
|
30589
|
-
fallbackRunner: args.fallbackRunner
|
|
30590
|
-
});
|
|
30591
|
-
}
|
|
30592
|
-
async function* runSessionOrchestratorStreams(args) {
|
|
30593
|
-
yield* runSessionOrchestratorWithContext({
|
|
30594
30825
|
input: void 0,
|
|
30595
|
-
|
|
30826
|
+
replaySeed,
|
|
30596
30827
|
sessionRunner: async function* () {
|
|
30597
|
-
yield* args.sessionStream();
|
|
30598
|
-
},
|
|
30599
|
-
fallbackRunner: async function* () {
|
|
30600
|
-
yield* args.fallbackStream();
|
|
30601
|
-
}
|
|
30602
|
-
});
|
|
30603
|
-
}
|
|
30604
|
-
async function* runSessionCompatStreams(args) {
|
|
30605
|
-
const sessionContext = ensureSessionContext(args.toolUseContext);
|
|
30606
|
-
yield* runSessionOrchestratorStreams({
|
|
30607
|
-
routingContext: args.routingContext,
|
|
30608
|
-
sessionStream: async function* () {
|
|
30609
30828
|
yield* args.primaryRunner(args.primaryInput);
|
|
30610
30829
|
},
|
|
30611
|
-
|
|
30830
|
+
fallbackRunner: async function* () {
|
|
30612
30831
|
yield* runSessionWithEngine({
|
|
30613
30832
|
input: args.fallbackInput,
|
|
30614
30833
|
sessionContext,
|
|
@@ -30653,78 +30872,6 @@ function resolveSessionEngineReplaySample(replaySeed) {
|
|
|
30653
30872
|
return hash % 100;
|
|
30654
30873
|
}
|
|
30655
30874
|
|
|
30656
|
-
// src/app/queryRuntime/errorMapping.ts
|
|
30657
|
-
var ERROR_CLASS_BY_CODE = {
|
|
30658
|
-
ENOENT: "soft",
|
|
30659
|
-
EISDIR: "soft",
|
|
30660
|
-
EACCES: "retryable",
|
|
30661
|
-
EPERM: "retryable",
|
|
30662
|
-
EMFILE: "retryable",
|
|
30663
|
-
ENFILE: "retryable",
|
|
30664
|
-
EIO: "fatal",
|
|
30665
|
-
ENODEV: "fatal",
|
|
30666
|
-
EBUSY: "fatal"
|
|
30667
|
-
};
|
|
30668
|
-
function formatError(error) {
|
|
30669
|
-
if (!(error instanceof Error)) {
|
|
30670
|
-
return String(error);
|
|
30671
|
-
}
|
|
30672
|
-
const parts = [error.message];
|
|
30673
|
-
if ("stderr" in error && typeof error.stderr === "string") {
|
|
30674
|
-
parts.push(error.stderr);
|
|
30675
|
-
}
|
|
30676
|
-
if ("stdout" in error && typeof error.stdout === "string") {
|
|
30677
|
-
parts.push(error.stdout);
|
|
30678
|
-
}
|
|
30679
|
-
const fullMessage = parts.filter(Boolean).join("\n");
|
|
30680
|
-
if (fullMessage.length <= 1e4) {
|
|
30681
|
-
return fullMessage;
|
|
30682
|
-
}
|
|
30683
|
-
const halfLength = 5e3;
|
|
30684
|
-
const start = fullMessage.slice(0, halfLength);
|
|
30685
|
-
const end = fullMessage.slice(-halfLength);
|
|
30686
|
-
return `${start}
|
|
30687
|
-
|
|
30688
|
-
... [${fullMessage.length - 1e4} characters truncated] ...
|
|
30689
|
-
|
|
30690
|
-
${end}`;
|
|
30691
|
-
}
|
|
30692
|
-
function extractErrorCode(error) {
|
|
30693
|
-
if (!error || typeof error !== "object") {
|
|
30694
|
-
return void 0;
|
|
30695
|
-
}
|
|
30696
|
-
if ("code" in error && typeof error.code === "string") {
|
|
30697
|
-
return error.code;
|
|
30698
|
-
}
|
|
30699
|
-
return void 0;
|
|
30700
|
-
}
|
|
30701
|
-
function summarizeError(detail) {
|
|
30702
|
-
const line = detail.split("\n").map((part) => part.trim()).find((part) => part.length > 0);
|
|
30703
|
-
const summary = line ?? detail.trim();
|
|
30704
|
-
return summary.length > 200 ? summary.slice(0, 200) : summary;
|
|
30705
|
-
}
|
|
30706
|
-
function getErrorClassFromCode(errorCode) {
|
|
30707
|
-
if (!errorCode) return "soft";
|
|
30708
|
-
return ERROR_CLASS_BY_CODE[errorCode] ?? "soft";
|
|
30709
|
-
}
|
|
30710
|
-
function createErrorToolResultBlock(args) {
|
|
30711
|
-
const detail = typeof args.errorDetail === "string" ? args.errorDetail : typeof args.content === "string" ? args.content : JSON.stringify(args.content);
|
|
30712
|
-
const errorCode = args.errorCode;
|
|
30713
|
-
const errorClass = args.errorClass ?? getErrorClassFromCode(errorCode);
|
|
30714
|
-
const summary = detail ? summarizeError(detail) : "";
|
|
30715
|
-
return {
|
|
30716
|
-
type: "tool_result",
|
|
30717
|
-
content: args.content,
|
|
30718
|
-
is_error: true,
|
|
30719
|
-
tool_use_id: args.toolUseId,
|
|
30720
|
-
error_class: errorClass,
|
|
30721
|
-
...errorCode ? { error_code: errorCode } : {},
|
|
30722
|
-
...summary ? { error_summary: summary } : {},
|
|
30723
|
-
...detail ? { error_detail: detail } : {},
|
|
30724
|
-
...args.rootToolUseId ? { root_tool_use_id: args.rootToolUseId } : {}
|
|
30725
|
-
};
|
|
30726
|
-
}
|
|
30727
|
-
|
|
30728
30875
|
// src/app/queryRuntime/toolInput.ts
|
|
30729
30876
|
function normalizeToolInput(tool, input) {
|
|
30730
30877
|
switch (tool) {
|
|
@@ -30778,270 +30925,27 @@ function inferIsNewSessionForAutoCompact(messages) {
|
|
|
30778
30925
|
);
|
|
30779
30926
|
return !hasCompactionMarker && naturalMessages.length <= 2;
|
|
30780
30927
|
}
|
|
30781
|
-
|
|
30782
|
-
|
|
30783
|
-
|
|
30784
|
-
|
|
30785
|
-
}
|
|
30786
|
-
function extractToolResultText2(content) {
|
|
30787
|
-
if (typeof content === "string") return { text: content, hasNonTextBlock: false };
|
|
30788
|
-
if (!Array.isArray(content)) return { text: "", hasNonTextBlock: false };
|
|
30789
|
-
let hasNonTextBlock = false;
|
|
30790
|
-
const text = content.filter((block) => {
|
|
30791
|
-
if (!block || typeof block !== "object") return false;
|
|
30792
|
-
if (block.type === "text") return true;
|
|
30793
|
-
hasNonTextBlock = true;
|
|
30794
|
-
return false;
|
|
30795
|
-
}).map((block) => String(block.text ?? "")).join("\n");
|
|
30796
|
-
return { text, hasNonTextBlock };
|
|
30797
|
-
}
|
|
30798
|
-
function extractTaggedText(text, tagName) {
|
|
30799
|
-
const normalized = String(text ?? "").trim();
|
|
30800
|
-
if (!normalized.startsWith(`<${tagName}>`)) return null;
|
|
30801
|
-
const pattern = new RegExp(`<${tagName}>([\\s\\S]*?)<\\/${tagName}>`, "i");
|
|
30802
|
-
const match = normalized.match(pattern);
|
|
30803
|
-
const content = String(match?.[1] ?? "").trim();
|
|
30804
|
-
return content.length > 0 ? content : null;
|
|
30805
|
-
}
|
|
30806
|
-
function projectAssistantMessage(state, message) {
|
|
30807
|
-
const content = message?.message?.content;
|
|
30808
|
-
if (!Array.isArray(content)) return;
|
|
30809
|
-
for (let i = 0; i < content.length; i += 1) {
|
|
30810
|
-
const block = content[i];
|
|
30811
|
-
if (!block || typeof block !== "object") continue;
|
|
30812
|
-
const type3 = String(block.type ?? "");
|
|
30813
|
-
if (type3 === "text") {
|
|
30814
|
-
const text = String(block.text ?? "");
|
|
30815
|
-
const toolProgressText = extractTaggedText(text, "tool-progress");
|
|
30816
|
-
if (toolProgressText) {
|
|
30817
|
-
state.parts.push(
|
|
30818
|
-
createSystemEventPart({
|
|
30819
|
-
requestId: state.requestId,
|
|
30820
|
-
eventType: "tool_progress",
|
|
30821
|
-
text: toolProgressText,
|
|
30822
|
-
source: state.source
|
|
30823
|
-
})
|
|
30824
|
-
);
|
|
30825
|
-
}
|
|
30826
|
-
const localStdoutText = extractTaggedText(text, "local-command-stdout");
|
|
30827
|
-
if (localStdoutText) {
|
|
30828
|
-
state.parts.push(
|
|
30829
|
-
createSystemEventPart({
|
|
30830
|
-
requestId: state.requestId,
|
|
30831
|
-
eventType: "local_command_stdout",
|
|
30832
|
-
text: localStdoutText,
|
|
30833
|
-
source: state.source
|
|
30834
|
-
})
|
|
30835
|
-
);
|
|
30836
|
-
}
|
|
30837
|
-
const localStderrText = extractTaggedText(text, "local-command-stderr");
|
|
30838
|
-
if (localStderrText) {
|
|
30839
|
-
state.parts.push(
|
|
30840
|
-
createSystemEventPart({
|
|
30841
|
-
requestId: state.requestId,
|
|
30842
|
-
eventType: "local_command_stderr",
|
|
30843
|
-
text: localStderrText,
|
|
30844
|
-
source: state.source
|
|
30845
|
-
})
|
|
30846
|
-
);
|
|
30847
|
-
}
|
|
30848
|
-
onTextStart({ textId: `text-${i}` }, state);
|
|
30849
|
-
onTextDelta({ textId: `text-${i}`, text }, state);
|
|
30850
|
-
onTextEnd({ textId: `text-${i}` }, state);
|
|
30851
|
-
continue;
|
|
30852
|
-
}
|
|
30853
|
-
if (type3 === "thinking" || type3 === "reasoning") {
|
|
30854
|
-
const text = String(block.thinking ?? block.reasoning ?? "");
|
|
30855
|
-
onReasoningStart({ reasoningId: `reasoning-${i}` }, state);
|
|
30856
|
-
onReasoningDelta({ reasoningId: `reasoning-${i}`, text }, state);
|
|
30857
|
-
onReasoningEnd({ reasoningId: `reasoning-${i}` }, state);
|
|
30858
|
-
continue;
|
|
30859
|
-
}
|
|
30860
|
-
if (type3 === "tool_use" || type3 === "server_tool_use" || type3 === "mcp_tool_use") {
|
|
30861
|
-
const toolCallId = String(block.id ?? `tool-${i}`);
|
|
30862
|
-
const toolName = String(block.name ?? "unknown");
|
|
30863
|
-
onToolCall({ toolCallId, toolName }, state);
|
|
30864
|
-
}
|
|
30928
|
+
function extractUserPromptTextFromMessages(messages) {
|
|
30929
|
+
const last2 = messages[messages.length - 1];
|
|
30930
|
+
if (!last2 || typeof last2 !== "object" || last2.type !== "user") {
|
|
30931
|
+
return null;
|
|
30865
30932
|
}
|
|
30866
|
-
|
|
30867
|
-
|
|
30868
|
-
|
|
30869
|
-
const content = message?.message?.content;
|
|
30870
|
-
if (!Array.isArray(content)) return;
|
|
30871
|
-
for (let i = 0; i < content.length; i += 1) {
|
|
30872
|
-
const block = content[i];
|
|
30873
|
-
if (!block || typeof block !== "object") continue;
|
|
30874
|
-
if (block.type !== "tool_result") continue;
|
|
30875
|
-
const toolCallId = String(block.tool_use_id ?? `tool-${i}`);
|
|
30876
|
-
const extracted = extractToolResultText2(block.content);
|
|
30877
|
-
if (extracted.hasNonTextBlock) {
|
|
30878
|
-
projector.richToolResultBlockCount += 1;
|
|
30879
|
-
if (!projector.supportsRichToolResult) {
|
|
30880
|
-
projector.downgradedToolResultCount += 1;
|
|
30881
|
-
}
|
|
30882
|
-
}
|
|
30883
|
-
onToolResult(
|
|
30884
|
-
{
|
|
30885
|
-
toolCallId,
|
|
30886
|
-
status: block.is_error ? "failed" : "completed",
|
|
30887
|
-
outputText: extracted.text
|
|
30888
|
-
},
|
|
30889
|
-
state
|
|
30890
|
-
);
|
|
30933
|
+
const content = last2.message?.content;
|
|
30934
|
+
if (typeof content === "string") {
|
|
30935
|
+
return content;
|
|
30891
30936
|
}
|
|
30892
|
-
|
|
30893
|
-
|
|
30894
|
-
const toolCallId = String(message?.toolUseID ?? "").trim();
|
|
30895
|
-
if (!toolCallId) return;
|
|
30896
|
-
const content = String(
|
|
30897
|
-
message?.content?.message?.content?.find?.((block) => block?.type === "text")?.text ?? ""
|
|
30898
|
-
);
|
|
30899
|
-
const extractedProgressText = extractTaggedText(content, "tool-progress");
|
|
30900
|
-
const normalizedContent = content.trim();
|
|
30901
|
-
const toolProgressText = extractedProgressText ?? (normalizedContent.length > 0 ? normalizedContent : void 0);
|
|
30902
|
-
if (toolProgressText) {
|
|
30903
|
-
state.parts.push(
|
|
30904
|
-
createSystemEventPart({
|
|
30905
|
-
requestId: state.requestId,
|
|
30906
|
-
eventType: "tool_progress",
|
|
30907
|
-
text: toolProgressText,
|
|
30908
|
-
toolCallId,
|
|
30909
|
-
source: state.source
|
|
30910
|
-
})
|
|
30911
|
-
);
|
|
30937
|
+
if (!Array.isArray(content)) {
|
|
30938
|
+
return null;
|
|
30912
30939
|
}
|
|
30913
|
-
|
|
30914
|
-
|
|
30915
|
-
toolCallId,
|
|
30916
|
-
status: "running",
|
|
30917
|
-
outputText: content || void 0
|
|
30918
|
-
},
|
|
30919
|
-
state
|
|
30940
|
+
const hasToolResult = content.some(
|
|
30941
|
+
(block) => block && typeof block === "object" && block.type === "tool_result"
|
|
30920
30942
|
);
|
|
30921
|
-
|
|
30922
|
-
|
|
30923
|
-
const provider = String(options.provider ?? "").trim().toLowerCase();
|
|
30924
|
-
return {
|
|
30925
|
-
state: createAssemblerState(options.requestId, options.source ?? "query_main"),
|
|
30926
|
-
provider,
|
|
30927
|
-
supportsRichToolResult: typeof options.supportsRichToolResult === "boolean" ? options.supportsRichToolResult : supportsRichToolResultByProvider(provider),
|
|
30928
|
-
richToolResultBlockCount: 0,
|
|
30929
|
-
downgradedToolResultCount: 0
|
|
30930
|
-
};
|
|
30931
|
-
}
|
|
30932
|
-
function consumeProjectorCompatibilityMetrics(projector) {
|
|
30933
|
-
const snapshot = {
|
|
30934
|
-
provider: projector.provider || "unknown",
|
|
30935
|
-
supportsRichToolResult: projector.supportsRichToolResult,
|
|
30936
|
-
richToolResultBlockCount: projector.richToolResultBlockCount,
|
|
30937
|
-
downgradedToolResultCount: projector.downgradedToolResultCount
|
|
30938
|
-
};
|
|
30939
|
-
projector.richToolResultBlockCount = 0;
|
|
30940
|
-
projector.downgradedToolResultCount = 0;
|
|
30941
|
-
return snapshot;
|
|
30942
|
-
}
|
|
30943
|
-
function projectMessageToTypedParts(projector, message) {
|
|
30944
|
-
if (!message || typeof message !== "object") return [];
|
|
30945
|
-
if (message.type === "assistant") {
|
|
30946
|
-
projectAssistantMessage(projector.state, message);
|
|
30947
|
-
} else if (message.type === "user") {
|
|
30948
|
-
projectUserToolResult(projector, message);
|
|
30949
|
-
} else if (message.type === "progress") {
|
|
30950
|
-
projectProgressMessage(projector.state, message);
|
|
30951
|
-
}
|
|
30952
|
-
return flushTypedParts(projector.state);
|
|
30953
|
-
}
|
|
30954
|
-
function projectLifecycleEventsToTypedParts(projector, events) {
|
|
30955
|
-
if (!Array.isArray(events) || events.length === 0) return [];
|
|
30956
|
-
const parts = [];
|
|
30957
|
-
for (const event of events) {
|
|
30958
|
-
if (!event || typeof event !== "object") continue;
|
|
30959
|
-
if (event.eventType === "start-step") {
|
|
30960
|
-
parts.push(
|
|
30961
|
-
createStepStartPart({
|
|
30962
|
-
requestId: projector.state.requestId,
|
|
30963
|
-
stepId: event.stepId,
|
|
30964
|
-
timeStart: event.timestamp,
|
|
30965
|
-
source: projector.state.source
|
|
30966
|
-
})
|
|
30967
|
-
);
|
|
30968
|
-
continue;
|
|
30969
|
-
}
|
|
30970
|
-
if (event.eventType === "finish-step") {
|
|
30971
|
-
parts.push(
|
|
30972
|
-
createStepFinishPart({
|
|
30973
|
-
requestId: projector.state.requestId,
|
|
30974
|
-
stepId: event.stepId,
|
|
30975
|
-
reason: event.reason,
|
|
30976
|
-
completedAt: event.completedAt,
|
|
30977
|
-
costUSD: event.costUSD,
|
|
30978
|
-
...event.tokens ? { tokens: event.tokens } : {},
|
|
30979
|
-
source: projector.state.source
|
|
30980
|
-
})
|
|
30981
|
-
);
|
|
30982
|
-
}
|
|
30983
|
-
}
|
|
30984
|
-
return parts;
|
|
30985
|
-
}
|
|
30986
|
-
|
|
30987
|
-
// src/services/ai/streamTyped/skeletonReader.ts
|
|
30988
|
-
function pushText(parts, value) {
|
|
30989
|
-
const text = String(value ?? "").trim();
|
|
30990
|
-
if (!text) return;
|
|
30991
|
-
parts.push({ type: "text", text });
|
|
30992
|
-
}
|
|
30993
|
-
function getToolState(part) {
|
|
30994
|
-
if (part.partType !== "tool") return null;
|
|
30995
|
-
const payload = part.payload;
|
|
30996
|
-
return payload?.state ?? null;
|
|
30997
|
-
}
|
|
30998
|
-
function buildSkeletonBlocksFromTypedParts(input) {
|
|
30999
|
-
const result = [];
|
|
31000
|
-
for (const part of input.parts) {
|
|
31001
|
-
if (!part || typeof part !== "object") continue;
|
|
31002
|
-
if (part.partType === "text") {
|
|
31003
|
-
pushText(result, part.payload?.text);
|
|
31004
|
-
continue;
|
|
31005
|
-
}
|
|
31006
|
-
if (part.partType === "reasoning" && input.role === "assistant") {
|
|
31007
|
-
const reasoning = String(part.payload?.text ?? "").trim();
|
|
31008
|
-
if (!reasoning) continue;
|
|
31009
|
-
result.push({ type: "reasoning", reasoning });
|
|
31010
|
-
continue;
|
|
31011
|
-
}
|
|
31012
|
-
if (part.partType !== "tool") continue;
|
|
31013
|
-
const payload = part.payload;
|
|
31014
|
-
const state = getToolState(part);
|
|
31015
|
-
const status = String(
|
|
31016
|
-
state?.status ?? payload?.status ?? ""
|
|
31017
|
-
).toLowerCase();
|
|
31018
|
-
const toolName = String(payload?.toolName ?? "").trim();
|
|
31019
|
-
const toolCallId = String(payload?.toolCallId ?? "").trim();
|
|
31020
|
-
if (!toolCallId) continue;
|
|
31021
|
-
if (input.role === "assistant") {
|
|
31022
|
-
if (status !== "pending") continue;
|
|
31023
|
-
result.push({
|
|
31024
|
-
type: "tool_use",
|
|
31025
|
-
id: toolCallId,
|
|
31026
|
-
name: toolName || "unknown",
|
|
31027
|
-
input: state?.input && typeof state.input === "object" ? state.input : payload?.input && typeof payload.input === "object" ? payload.input : {}
|
|
31028
|
-
});
|
|
31029
|
-
continue;
|
|
31030
|
-
}
|
|
31031
|
-
if (status !== "completed" && status !== "failed" && status !== "interrupted") {
|
|
31032
|
-
continue;
|
|
31033
|
-
}
|
|
31034
|
-
const content = String(
|
|
31035
|
-
state?.output ?? state?.error ?? state?.reason ?? payload?.outputText ?? ""
|
|
31036
|
-
).trim();
|
|
31037
|
-
result.push({
|
|
31038
|
-
type: "tool_result",
|
|
31039
|
-
tool_use_id: toolCallId,
|
|
31040
|
-
content,
|
|
31041
|
-
...status === "failed" ? { is_error: true } : {}
|
|
31042
|
-
});
|
|
30943
|
+
if (hasToolResult) {
|
|
30944
|
+
return null;
|
|
31043
30945
|
}
|
|
31044
|
-
return
|
|
30946
|
+
return content.filter(
|
|
30947
|
+
(block) => block && typeof block === "object" && block.type === "text"
|
|
30948
|
+
).map((block) => String(block.text ?? "")).join("");
|
|
31045
30949
|
}
|
|
31046
30950
|
|
|
31047
30951
|
// src/utils/session/singleFactLayer.ts
|
|
@@ -31080,18 +30984,77 @@ function normalizeMessagesForSingleFactLayer(messages) {
|
|
|
31080
30984
|
});
|
|
31081
30985
|
}
|
|
31082
30986
|
|
|
31083
|
-
// src/app/queryRuntime/
|
|
31084
|
-
var
|
|
31085
|
-
|
|
31086
|
-
|
|
31087
|
-
|
|
31088
|
-
|
|
31089
|
-
|
|
31090
|
-
|
|
31091
|
-
|
|
31092
|
-
|
|
31093
|
-
|
|
30987
|
+
// src/app/queryRuntime/errorMapping.ts
|
|
30988
|
+
var ERROR_CLASS_BY_CODE = {
|
|
30989
|
+
ENOENT: "soft",
|
|
30990
|
+
EISDIR: "soft",
|
|
30991
|
+
EACCES: "retryable",
|
|
30992
|
+
EPERM: "retryable",
|
|
30993
|
+
EMFILE: "retryable",
|
|
30994
|
+
ENFILE: "retryable",
|
|
30995
|
+
EIO: "fatal",
|
|
30996
|
+
ENODEV: "fatal",
|
|
30997
|
+
EBUSY: "fatal"
|
|
31094
30998
|
};
|
|
30999
|
+
function formatError(error) {
|
|
31000
|
+
if (!(error instanceof Error)) {
|
|
31001
|
+
return String(error);
|
|
31002
|
+
}
|
|
31003
|
+
const parts = [error.message];
|
|
31004
|
+
if ("stderr" in error && typeof error.stderr === "string") {
|
|
31005
|
+
parts.push(error.stderr);
|
|
31006
|
+
}
|
|
31007
|
+
if ("stdout" in error && typeof error.stdout === "string") {
|
|
31008
|
+
parts.push(error.stdout);
|
|
31009
|
+
}
|
|
31010
|
+
const fullMessage = parts.filter(Boolean).join("\n");
|
|
31011
|
+
if (fullMessage.length <= 1e4) {
|
|
31012
|
+
return fullMessage;
|
|
31013
|
+
}
|
|
31014
|
+
const halfLength = 5e3;
|
|
31015
|
+
const start = fullMessage.slice(0, halfLength);
|
|
31016
|
+
const end = fullMessage.slice(-halfLength);
|
|
31017
|
+
return `${start}
|
|
31018
|
+
|
|
31019
|
+
... [${fullMessage.length - 1e4} characters truncated] ...
|
|
31020
|
+
|
|
31021
|
+
${end}`;
|
|
31022
|
+
}
|
|
31023
|
+
function extractErrorCode(error) {
|
|
31024
|
+
if (!error || typeof error !== "object") {
|
|
31025
|
+
return void 0;
|
|
31026
|
+
}
|
|
31027
|
+
if ("code" in error && typeof error.code === "string") {
|
|
31028
|
+
return error.code;
|
|
31029
|
+
}
|
|
31030
|
+
return void 0;
|
|
31031
|
+
}
|
|
31032
|
+
function summarizeError(detail) {
|
|
31033
|
+
const line = detail.split("\n").map((part) => part.trim()).find((part) => part.length > 0);
|
|
31034
|
+
const summary = line ?? detail.trim();
|
|
31035
|
+
return summary.length > 200 ? summary.slice(0, 200) : summary;
|
|
31036
|
+
}
|
|
31037
|
+
function getErrorClassFromCode(errorCode) {
|
|
31038
|
+
if (!errorCode) return "soft";
|
|
31039
|
+
return ERROR_CLASS_BY_CODE[errorCode] ?? "soft";
|
|
31040
|
+
}
|
|
31041
|
+
function createErrorToolResultBlock(args) {
|
|
31042
|
+
const detail = typeof args.errorDetail === "string" ? args.errorDetail : typeof args.content === "string" ? args.content : JSON.stringify(args.content);
|
|
31043
|
+
const errorCode = args.errorCode;
|
|
31044
|
+
const errorClass = args.errorClass ?? getErrorClassFromCode(errorCode);
|
|
31045
|
+
const summary = detail ? summarizeError(detail) : "";
|
|
31046
|
+
return {
|
|
31047
|
+
type: "tool_result",
|
|
31048
|
+
content: args.content,
|
|
31049
|
+
is_error: true,
|
|
31050
|
+
tool_use_id: args.toolUseId,
|
|
31051
|
+
error_class: errorClass,
|
|
31052
|
+
...errorCode ? { error_code: errorCode } : {},
|
|
31053
|
+
...summary ? { error_summary: summary } : {},
|
|
31054
|
+
...detail ? { error_detail: detail } : {},
|
|
31055
|
+
...args.rootToolUseId ? { root_tool_use_id: args.rootToolUseId } : {}
|
|
31056
|
+
};
|
|
31057
|
+
}
|
|
31095
31058
|
|
|
31096
31059
|
// src/app/queryRuntime/toolExecution.ts
|
|
31097
31060
|
function buildToolHookBaseArgs(context, toolUseId) {
|
|
@@ -31123,23 +31086,6 @@ function applyHookOutcomeSideEffects(context, hookOutcome) {
|
|
|
31123
31086
|
queueHookAdditionalContexts(context, hookOutcome.additionalContexts);
|
|
31124
31087
|
}
|
|
31125
31088
|
}
|
|
31126
|
-
function resolvePermissionExecutionPlan(args) {
|
|
31127
|
-
const effectiveShouldSkipPermissionCheck = args.hookPermissionDecision === "allow" ? true : args.hookPermissionDecision === "ask" ? false : args.shouldSkipPermissionCheck;
|
|
31128
|
-
const permissionContextForCall = args.hookPermissionDecision === "ask" && args.context.options?.toolPermissionContext && args.context.options.toolPermissionContext.mode !== "default" ? {
|
|
31129
|
-
...args.context,
|
|
31130
|
-
options: {
|
|
31131
|
-
...args.context.options,
|
|
31132
|
-
toolPermissionContext: {
|
|
31133
|
-
...args.context.options.toolPermissionContext,
|
|
31134
|
-
mode: "default"
|
|
31135
|
-
}
|
|
31136
|
-
}
|
|
31137
|
-
} : args.context;
|
|
31138
|
-
return {
|
|
31139
|
-
effectiveShouldSkipPermissionCheck,
|
|
31140
|
-
permissionContextForCall
|
|
31141
|
-
};
|
|
31142
|
-
}
|
|
31143
31089
|
function resolveToolResultAssistantContent(args) {
|
|
31144
31090
|
const rawContent = args.resultForAssistant ?? args.renderResultForAssistant(args.resultData);
|
|
31145
31091
|
const shouldTruncate = typeof rawContent === "string" && shouldApplyToolOutputTruncation(args.resultData);
|
|
@@ -31147,31 +31093,6 @@ function resolveToolResultAssistantContent(args) {
|
|
|
31147
31093
|
permissionMode: args.permissionMode
|
|
31148
31094
|
}).content : rawContent;
|
|
31149
31095
|
}
|
|
31150
|
-
function toStructuredToolResultMessages(newMessages) {
|
|
31151
|
-
if (!Array.isArray(newMessages)) {
|
|
31152
|
-
return [];
|
|
31153
|
-
}
|
|
31154
|
-
return newMessages.filter(
|
|
31155
|
-
(message) => Boolean(message) && typeof message === "object" && "type" in message
|
|
31156
|
-
);
|
|
31157
|
-
}
|
|
31158
|
-
function buildToolResultEnvelope(args) {
|
|
31159
|
-
return {
|
|
31160
|
-
blocks: [
|
|
31161
|
-
{
|
|
31162
|
-
type: "tool_result",
|
|
31163
|
-
content: args.content,
|
|
31164
|
-
tool_use_id: args.toolUseId
|
|
31165
|
-
}
|
|
31166
|
-
],
|
|
31167
|
-
toolUseResult: {
|
|
31168
|
-
data: args.resultData,
|
|
31169
|
-
resultForAssistant: args.content,
|
|
31170
|
-
...Array.isArray(args.newMessages) ? { newMessages: args.newMessages } : {},
|
|
31171
|
-
...args.contextModifier ? { contextModifier: args.contextModifier } : {}
|
|
31172
|
-
}
|
|
31173
|
-
};
|
|
31174
|
-
}
|
|
31175
31096
|
function createToolExecutionErrorBlock(args) {
|
|
31176
31097
|
const content = args.mode === "full" ? formatError(args.error) : `Tool execution failed: ${args.error instanceof Error ? args.error.message : String(args.error)}`;
|
|
31177
31098
|
return createErrorToolResultBlock({
|
|
@@ -31180,6 +31101,37 @@ function createToolExecutionErrorBlock(args) {
|
|
|
31180
31101
|
errorCode: extractErrorCode(args.error)
|
|
31181
31102
|
});
|
|
31182
31103
|
}
|
|
31104
|
+
function createToolNotFoundErrorMessage(args) {
|
|
31105
|
+
return createUserMessageFromBlocks([
|
|
31106
|
+
createErrorToolResultBlock({
|
|
31107
|
+
toolUseId: args.toolUseId,
|
|
31108
|
+
content: `Error: No such tool available: ${args.toolName}`,
|
|
31109
|
+
errorCode: "TOOL_NOT_FOUND",
|
|
31110
|
+
errorClass: "soft"
|
|
31111
|
+
})
|
|
31112
|
+
]);
|
|
31113
|
+
}
|
|
31114
|
+
function createSyntheticToolUseErrorMessage(args) {
|
|
31115
|
+
if (args.reason === "user_interrupted") {
|
|
31116
|
+
return createUserMessageFromBlocks([
|
|
31117
|
+
createErrorToolResultBlock({
|
|
31118
|
+
toolUseId: args.toolUseId,
|
|
31119
|
+
content: REJECT_MESSAGE,
|
|
31120
|
+
errorCode: "USER_INTERRUPTED",
|
|
31121
|
+
errorClass: "fatal"
|
|
31122
|
+
})
|
|
31123
|
+
]);
|
|
31124
|
+
}
|
|
31125
|
+
return createUserMessageFromBlocks([
|
|
31126
|
+
createErrorToolResultBlock({
|
|
31127
|
+
toolUseId: args.toolUseId,
|
|
31128
|
+
content: "<tool_use_error>Sibling tool call errored</tool_use_error>",
|
|
31129
|
+
errorCode: "SIBLING_ERROR",
|
|
31130
|
+
errorClass: "fatal",
|
|
31131
|
+
rootToolUseId: args.rootToolUseId
|
|
31132
|
+
})
|
|
31133
|
+
]);
|
|
31134
|
+
}
|
|
31183
31135
|
function resolveWarningText(warnings) {
|
|
31184
31136
|
if (!Array.isArray(warnings) || warnings.length === 0) {
|
|
31185
31137
|
return void 0;
|
|
@@ -31248,17 +31200,42 @@ async function resolveHookUpdatedInput(args) {
|
|
|
31248
31200
|
}
|
|
31249
31201
|
return { kind: "updated", normalizedInput };
|
|
31250
31202
|
}
|
|
31251
|
-
function
|
|
31252
|
-
|
|
31253
|
-
|
|
31254
|
-
|
|
31255
|
-
|
|
31256
|
-
|
|
31257
|
-
|
|
31258
|
-
|
|
31259
|
-
})
|
|
31260
|
-
|
|
31261
|
-
|
|
31203
|
+
function buildResultDispatchItems(args) {
|
|
31204
|
+
const items = [];
|
|
31205
|
+
const warningText = resolveWarningText(args.postWarnings);
|
|
31206
|
+
if (warningText) {
|
|
31207
|
+
items.push({
|
|
31208
|
+
kind: "warning_progress",
|
|
31209
|
+
warningText,
|
|
31210
|
+
tools: args.defaultTools
|
|
31211
|
+
});
|
|
31212
|
+
}
|
|
31213
|
+
items.push({
|
|
31214
|
+
kind: "user_message",
|
|
31215
|
+
blocks: [
|
|
31216
|
+
{
|
|
31217
|
+
type: "tool_result",
|
|
31218
|
+
content: args.content,
|
|
31219
|
+
tool_use_id: args.toolUseId
|
|
31220
|
+
}
|
|
31221
|
+
],
|
|
31222
|
+
toolUseResult: {
|
|
31223
|
+
data: args.resultData,
|
|
31224
|
+
resultForAssistant: args.content,
|
|
31225
|
+
...Array.isArray(args.newMessages) ? { newMessages: args.newMessages } : {},
|
|
31226
|
+
...args.contextModifier ? { contextModifier: args.contextModifier } : {}
|
|
31227
|
+
}
|
|
31228
|
+
});
|
|
31229
|
+
const structuredMessages = Array.isArray(args.newMessages) ? args.newMessages.filter(
|
|
31230
|
+
(message) => Boolean(message) && typeof message === "object" && "type" in message
|
|
31231
|
+
) : [];
|
|
31232
|
+
for (const message of structuredMessages) {
|
|
31233
|
+
items.push({
|
|
31234
|
+
kind: "structured_message",
|
|
31235
|
+
message
|
|
31236
|
+
});
|
|
31237
|
+
}
|
|
31238
|
+
return items;
|
|
31262
31239
|
}
|
|
31263
31240
|
function buildRunningProgressPayload(args) {
|
|
31264
31241
|
const normalizedPayload = normalizeProgressPayload({
|
|
@@ -31271,26 +31248,220 @@ function buildRunningProgressPayload(args) {
|
|
|
31271
31248
|
tools: normalizedPayload.tools.length > 0 ? normalizedPayload.tools : args.defaultTools
|
|
31272
31249
|
};
|
|
31273
31250
|
}
|
|
31274
|
-
function
|
|
31251
|
+
function buildWarningDispatchItems(args) {
|
|
31275
31252
|
const warningText = resolveWarningText(args.warnings);
|
|
31276
31253
|
if (!warningText) {
|
|
31277
|
-
return
|
|
31254
|
+
return [];
|
|
31278
31255
|
}
|
|
31279
|
-
return
|
|
31280
|
-
|
|
31281
|
-
|
|
31282
|
-
|
|
31256
|
+
return [
|
|
31257
|
+
{
|
|
31258
|
+
kind: "warning_progress",
|
|
31259
|
+
warningText,
|
|
31260
|
+
tools: args.defaultTools
|
|
31261
|
+
}
|
|
31262
|
+
];
|
|
31283
31263
|
}
|
|
31284
|
-
async function
|
|
31285
|
-
|
|
31286
|
-
|
|
31287
|
-
|
|
31288
|
-
|
|
31264
|
+
async function resolvePermissionCheckOutcome(args) {
|
|
31265
|
+
const effectiveShouldSkipPermissionCheck = args.hookPermissionDecision === "allow" ? true : args.hookPermissionDecision === "ask" ? false : args.shouldSkipPermissionCheck;
|
|
31266
|
+
const permissionContextForCall = args.hookPermissionDecision === "ask" && args.context.options?.toolPermissionContext && args.context.options.toolPermissionContext.mode !== "default" ? {
|
|
31267
|
+
...args.context,
|
|
31268
|
+
options: {
|
|
31269
|
+
...args.context.options,
|
|
31270
|
+
toolPermissionContext: {
|
|
31271
|
+
...args.context.options.toolPermissionContext,
|
|
31272
|
+
mode: "default"
|
|
31273
|
+
}
|
|
31274
|
+
}
|
|
31275
|
+
} : args.context;
|
|
31276
|
+
const permissionResult = effectiveShouldSkipPermissionCheck ? { result: true } : await args.canUseTool(
|
|
31289
31277
|
args.tool,
|
|
31290
31278
|
args.normalizedInput,
|
|
31291
|
-
{ ...
|
|
31279
|
+
{ ...permissionContextForCall, toolUseId: args.toolUseId },
|
|
31292
31280
|
args.assistantMessage
|
|
31293
31281
|
);
|
|
31282
|
+
return { permissionResult };
|
|
31283
|
+
}
|
|
31284
|
+
async function* checkPermissionsAndCallTool(args) {
|
|
31285
|
+
const preprocessedInput = preprocessToolInput(args.tool, args.input);
|
|
31286
|
+
const isValidInput = args.tool.inputSchema.safeParse(preprocessedInput);
|
|
31287
|
+
if (!isValidInput.success) {
|
|
31288
|
+
const errorMessage = resolveInitialInputValidationMessage({
|
|
31289
|
+
toolName: args.tool.name,
|
|
31290
|
+
preprocessedInput,
|
|
31291
|
+
validationMessage: isValidInput.error.message
|
|
31292
|
+
});
|
|
31293
|
+
yield createUserMessageFromBlocks([
|
|
31294
|
+
createInputValidationErrorBlock({
|
|
31295
|
+
toolUseId: args.toolUseID,
|
|
31296
|
+
content: errorMessage
|
|
31297
|
+
})
|
|
31298
|
+
]);
|
|
31299
|
+
return;
|
|
31300
|
+
}
|
|
31301
|
+
let normalizedInput = normalizeToolInput(args.tool, isValidInput.data);
|
|
31302
|
+
const isValidCall = await args.tool.validateInput?.(
|
|
31303
|
+
normalizedInput,
|
|
31304
|
+
args.context
|
|
31305
|
+
);
|
|
31306
|
+
if (isValidCall?.result === false) {
|
|
31307
|
+
yield createUserMessageFromBlocks([
|
|
31308
|
+
createInputValidationErrorBlock({
|
|
31309
|
+
toolUseId: args.toolUseID,
|
|
31310
|
+
content: isValidCall.message
|
|
31311
|
+
})
|
|
31312
|
+
]);
|
|
31313
|
+
return;
|
|
31314
|
+
}
|
|
31315
|
+
const hookOutcome = await runPreToolUseHooks({
|
|
31316
|
+
toolName: args.tool.name,
|
|
31317
|
+
toolInput: normalizedInput,
|
|
31318
|
+
toolUseId: args.toolUseID,
|
|
31319
|
+
...buildToolHookBaseArgs(args.context, args.toolUseID)
|
|
31320
|
+
});
|
|
31321
|
+
if (hookOutcome.kind === "block") {
|
|
31322
|
+
yield createUserMessageFromBlocks([
|
|
31323
|
+
createHookBlockedErrorBlock({
|
|
31324
|
+
toolUseId: args.toolUseID,
|
|
31325
|
+
content: hookOutcome.message
|
|
31326
|
+
})
|
|
31327
|
+
]);
|
|
31328
|
+
return;
|
|
31329
|
+
}
|
|
31330
|
+
const preWarningDispatchItems = buildWarningDispatchItems({
|
|
31331
|
+
warnings: hookOutcome.warnings,
|
|
31332
|
+
defaultTools: args.context.options?.tools ?? []
|
|
31333
|
+
});
|
|
31334
|
+
for (const dispatchItem of preWarningDispatchItems) {
|
|
31335
|
+
yield createProgressMessage(
|
|
31336
|
+
args.toolUseID,
|
|
31337
|
+
args.siblingToolUseIDs,
|
|
31338
|
+
createAssistantMessage(dispatchItem.warningText),
|
|
31339
|
+
[],
|
|
31340
|
+
dispatchItem.tools,
|
|
31341
|
+
{ progressState: "running" }
|
|
31342
|
+
);
|
|
31343
|
+
}
|
|
31344
|
+
applyHookOutcomeSideEffects(args.context, hookOutcome);
|
|
31345
|
+
const updatedInputResult = await resolveHookUpdatedInput({
|
|
31346
|
+
tool: args.tool,
|
|
31347
|
+
normalizedInput,
|
|
31348
|
+
updatedInput: hookOutcome.updatedInput,
|
|
31349
|
+
context: args.context
|
|
31350
|
+
});
|
|
31351
|
+
if (updatedInputResult.kind === "invalid") {
|
|
31352
|
+
yield createUserMessageFromBlocks([
|
|
31353
|
+
createInputValidationErrorBlock({
|
|
31354
|
+
toolUseId: args.toolUseID,
|
|
31355
|
+
content: updatedInputResult.message
|
|
31356
|
+
})
|
|
31357
|
+
]);
|
|
31358
|
+
return;
|
|
31359
|
+
}
|
|
31360
|
+
if (updatedInputResult.kind === "updated") {
|
|
31361
|
+
normalizedInput = normalizeToolInput(args.tool, updatedInputResult.normalizedInput);
|
|
31362
|
+
}
|
|
31363
|
+
const { permissionResult } = await resolvePermissionCheckOutcome({
|
|
31364
|
+
context: args.context,
|
|
31365
|
+
hookPermissionDecision: hookOutcome.kind === "allow" ? hookOutcome.permissionDecision : void 0,
|
|
31366
|
+
shouldSkipPermissionCheck: args.shouldSkipPermissionCheck,
|
|
31367
|
+
canUseTool: args.canUseTool,
|
|
31368
|
+
tool: args.tool,
|
|
31369
|
+
normalizedInput,
|
|
31370
|
+
toolUseId: args.toolUseID,
|
|
31371
|
+
assistantMessage: args.assistantMessage
|
|
31372
|
+
});
|
|
31373
|
+
if (permissionResult.result === false) {
|
|
31374
|
+
yield createUserMessageFromBlocks([
|
|
31375
|
+
createPermissionDeniedErrorBlock({
|
|
31376
|
+
toolUseId: args.toolUseID,
|
|
31377
|
+
content: permissionResult.message
|
|
31378
|
+
})
|
|
31379
|
+
]);
|
|
31380
|
+
return;
|
|
31381
|
+
}
|
|
31382
|
+
try {
|
|
31383
|
+
const generator = args.tool.call(normalizedInput, {
|
|
31384
|
+
...args.context,
|
|
31385
|
+
toolUseId: args.toolUseID
|
|
31386
|
+
});
|
|
31387
|
+
for await (const result of generator) {
|
|
31388
|
+
switch (result.type) {
|
|
31389
|
+
case "result": {
|
|
31390
|
+
const content = resolveToolResultAssistantContent({
|
|
31391
|
+
resultForAssistant: result.resultForAssistant,
|
|
31392
|
+
resultData: result.data,
|
|
31393
|
+
renderResultForAssistant: (data) => args.tool.renderResultForAssistant(data),
|
|
31394
|
+
permissionMode: args.context.options?.toolPermissionContext?.mode
|
|
31395
|
+
});
|
|
31396
|
+
const postOutcome = await runPostToolUseHooks({
|
|
31397
|
+
toolName: args.tool.name,
|
|
31398
|
+
toolInput: normalizedInput,
|
|
31399
|
+
toolResult: result.data,
|
|
31400
|
+
toolUseId: args.toolUseID,
|
|
31401
|
+
...buildToolHookBaseArgs(args.context, args.toolUseID)
|
|
31402
|
+
});
|
|
31403
|
+
applyHookOutcomeSideEffects(args.context, postOutcome);
|
|
31404
|
+
const dispatchItems = buildResultDispatchItems({
|
|
31405
|
+
toolUseId: args.toolUseID,
|
|
31406
|
+
content,
|
|
31407
|
+
resultData: result.data,
|
|
31408
|
+
newMessages: result.newMessages,
|
|
31409
|
+
contextModifier: result.contextModifier,
|
|
31410
|
+
defaultTools: args.context.options?.tools ?? [],
|
|
31411
|
+
postWarnings: postOutcome.warnings
|
|
31412
|
+
});
|
|
31413
|
+
for (const dispatchItem of dispatchItems) {
|
|
31414
|
+
if (dispatchItem.kind === "warning_progress") {
|
|
31415
|
+
yield createProgressMessage(
|
|
31416
|
+
args.toolUseID,
|
|
31417
|
+
args.siblingToolUseIDs,
|
|
31418
|
+
createAssistantMessage(dispatchItem.warningText),
|
|
31419
|
+
[],
|
|
31420
|
+
dispatchItem.tools,
|
|
31421
|
+
{ progressState: "running" }
|
|
31422
|
+
);
|
|
31423
|
+
continue;
|
|
31424
|
+
}
|
|
31425
|
+
if (dispatchItem.kind === "user_message") {
|
|
31426
|
+
yield createUserMessageFromBlocks(
|
|
31427
|
+
dispatchItem.blocks,
|
|
31428
|
+
dispatchItem.toolUseResult
|
|
31429
|
+
);
|
|
31430
|
+
continue;
|
|
31431
|
+
}
|
|
31432
|
+
yield dispatchItem.message;
|
|
31433
|
+
}
|
|
31434
|
+
return;
|
|
31435
|
+
}
|
|
31436
|
+
case "progress": {
|
|
31437
|
+
const progressPayload = buildRunningProgressPayload({
|
|
31438
|
+
content: result.content,
|
|
31439
|
+
normalizedMessages: result.normalizedMessages,
|
|
31440
|
+
tools: result.tools,
|
|
31441
|
+
defaultTools: args.context.options?.tools ?? []
|
|
31442
|
+
});
|
|
31443
|
+
yield createProgressMessage(
|
|
31444
|
+
args.toolUseID,
|
|
31445
|
+
args.siblingToolUseIDs,
|
|
31446
|
+
progressPayload.content,
|
|
31447
|
+
progressPayload.normalizedMessages,
|
|
31448
|
+
progressPayload.tools,
|
|
31449
|
+
{ progressState: "running" }
|
|
31450
|
+
);
|
|
31451
|
+
break;
|
|
31452
|
+
}
|
|
31453
|
+
}
|
|
31454
|
+
}
|
|
31455
|
+
} catch (error) {
|
|
31456
|
+
logError(error);
|
|
31457
|
+
yield createUserMessageFromBlocks([
|
|
31458
|
+
createToolExecutionErrorBlock({
|
|
31459
|
+
toolUseId: args.toolUseID,
|
|
31460
|
+
error,
|
|
31461
|
+
mode: "full"
|
|
31462
|
+
})
|
|
31463
|
+
]);
|
|
31464
|
+
}
|
|
31294
31465
|
}
|
|
31295
31466
|
|
|
31296
31467
|
// src/app/query.ts
|
|
@@ -31299,28 +31470,6 @@ function isToolUseLikeBlock(block) {
|
|
|
31299
31470
|
}
|
|
31300
31471
|
var __isToolUseLikeBlockForTests = isToolUseLikeBlock;
|
|
31301
31472
|
var reminderChannelRounds = [];
|
|
31302
|
-
function createSyntheticToolUseErrorMessage(args) {
|
|
31303
|
-
const { toolUseId, reason, rootToolUseId } = args;
|
|
31304
|
-
if (reason === "user_interrupted") {
|
|
31305
|
-
return createUserMessageFromBlocks([
|
|
31306
|
-
createErrorToolResultBlock({
|
|
31307
|
-
toolUseId,
|
|
31308
|
-
content: REJECT_MESSAGE,
|
|
31309
|
-
errorCode: "USER_INTERRUPTED",
|
|
31310
|
-
errorClass: "fatal"
|
|
31311
|
-
})
|
|
31312
|
-
]);
|
|
31313
|
-
}
|
|
31314
|
-
return createUserMessageFromBlocks([
|
|
31315
|
-
createErrorToolResultBlock({
|
|
31316
|
-
toolUseId,
|
|
31317
|
-
content: "<tool_use_error>Sibling tool call errored</tool_use_error>",
|
|
31318
|
-
errorCode: "SIBLING_ERROR",
|
|
31319
|
-
errorClass: "fatal",
|
|
31320
|
-
rootToolUseId
|
|
31321
|
-
})
|
|
31322
|
-
]);
|
|
31323
|
-
}
|
|
31324
31473
|
var ToolUseQueue = class {
|
|
31325
31474
|
toolDefinitions;
|
|
31326
31475
|
canUseTool;
|
|
@@ -31573,7 +31722,17 @@ async function* query(messages, systemPrompt, context, canUseTool, toolUseContex
|
|
|
31573
31722
|
requestId: context.requestId,
|
|
31574
31723
|
currentRequestId: getCurrentRequest()?.id,
|
|
31575
31724
|
isTestEnv: process.env.NODE_ENV === "test",
|
|
31576
|
-
hooks:
|
|
31725
|
+
hooks: {
|
|
31726
|
+
resolveModelWithInfo: (modelPointer) => getModelManager().resolveModelWithInfo(modelPointer),
|
|
31727
|
+
createStreamTypedProjector,
|
|
31728
|
+
normalizeMessagesForSingleFactLayer,
|
|
31729
|
+
projectLifecycleEventsToTypedParts,
|
|
31730
|
+
projectMessageToTypedParts,
|
|
31731
|
+
emitTypedPart,
|
|
31732
|
+
buildSkeletonBlocksFromTypedParts,
|
|
31733
|
+
flushTypedPartBuffer,
|
|
31734
|
+
consumeProjectorCompatibilityMetrics
|
|
31735
|
+
},
|
|
31577
31736
|
logUserFriendly,
|
|
31578
31737
|
stream: async function* (preparedMessages) {
|
|
31579
31738
|
yield* queryCore(
|
|
@@ -31790,23 +31949,7 @@ async function* queryCore(messages, systemPrompt, context, canUseTool, toolUseCo
|
|
|
31790
31949
|
}
|
|
31791
31950
|
updateHookTranscriptForMessages(toolUseContext, messages);
|
|
31792
31951
|
{
|
|
31793
|
-
const
|
|
31794
|
-
let userPromptText = null;
|
|
31795
|
-
if (last2 && typeof last2 === "object" && last2.type === "user") {
|
|
31796
|
-
const content = last2.message?.content;
|
|
31797
|
-
if (typeof content === "string") {
|
|
31798
|
-
userPromptText = content;
|
|
31799
|
-
} else if (Array.isArray(content)) {
|
|
31800
|
-
const hasToolResult = content.some(
|
|
31801
|
-
(b) => b && typeof b === "object" && b.type === "tool_result"
|
|
31802
|
-
);
|
|
31803
|
-
if (!hasToolResult) {
|
|
31804
|
-
userPromptText = content.filter(
|
|
31805
|
-
(b) => b && typeof b === "object" && b.type === "text"
|
|
31806
|
-
).map((b) => String(b.text ?? "")).join("");
|
|
31807
|
-
}
|
|
31808
|
-
}
|
|
31809
|
-
}
|
|
31952
|
+
const userPromptText = extractUserPromptTextFromMessages(messages);
|
|
31810
31953
|
if (userPromptText !== null) {
|
|
31811
31954
|
toolUseContext.options.lastUserPrompt = userPromptText;
|
|
31812
31955
|
const promptOutcome = await runUserPromptSubmitHooks({
|
|
@@ -32201,14 +32344,10 @@ async function* runToolUse(toolUse, siblingToolUseIDs, assistantMessage, canUseT
|
|
|
32201
32344
|
toolUseID: toolUse.id,
|
|
32202
32345
|
requestId: currentRequest?.id
|
|
32203
32346
|
});
|
|
32204
|
-
yield
|
|
32205
|
-
|
|
32206
|
-
|
|
32207
|
-
|
|
32208
|
-
errorCode: "TOOL_NOT_FOUND",
|
|
32209
|
-
errorClass: "soft"
|
|
32210
|
-
})
|
|
32211
|
-
]);
|
|
32347
|
+
yield createToolNotFoundErrorMessage({
|
|
32348
|
+
toolUseId: toolUse.id,
|
|
32349
|
+
toolName
|
|
32350
|
+
});
|
|
32212
32351
|
sessionContext?.finishTool(toolUse.id);
|
|
32213
32352
|
return;
|
|
32214
32353
|
}
|
|
@@ -32220,217 +32359,22 @@ async function* runToolUse(toolUse, siblingToolUseIDs, assistantMessage, canUseT
|
|
|
32220
32359
|
requestId: currentRequest?.id
|
|
32221
32360
|
});
|
|
32222
32361
|
try {
|
|
32223
|
-
for await (const message of checkPermissionsAndCallTool(
|
|
32362
|
+
for await (const message of checkPermissionsAndCallTool({
|
|
32224
32363
|
tool,
|
|
32225
|
-
toolUse.id,
|
|
32364
|
+
toolUseID: toolUse.id,
|
|
32226
32365
|
siblingToolUseIDs,
|
|
32227
|
-
toolInput,
|
|
32228
|
-
toolUseContext,
|
|
32366
|
+
input: toolInput,
|
|
32367
|
+
context: toolUseContext,
|
|
32229
32368
|
canUseTool,
|
|
32230
32369
|
assistantMessage,
|
|
32231
32370
|
shouldSkipPermissionCheck
|
|
32232
|
-
)) {
|
|
32371
|
+
})) {
|
|
32233
32372
|
yield message;
|
|
32234
32373
|
}
|
|
32235
|
-
} catch (e) {
|
|
32236
|
-
logError(e);
|
|
32237
|
-
const errorMessage = createUserMessageFromBlocks([
|
|
32238
|
-
createToolExecutionErrorBlock({
|
|
32239
|
-
toolUseId: toolUse.id,
|
|
32240
|
-
error: e,
|
|
32241
|
-
mode: "summary"
|
|
32242
|
-
})
|
|
32243
|
-
]);
|
|
32244
|
-
yield errorMessage;
|
|
32245
32374
|
} finally {
|
|
32246
32375
|
sessionContext?.finishTool(toolUse.id);
|
|
32247
32376
|
}
|
|
32248
32377
|
}
|
|
32249
|
-
async function* checkPermissionsAndCallTool(tool, toolUseID, siblingToolUseIDs, input, context, canUseTool, assistantMessage, shouldSkipPermissionCheck) {
|
|
32250
|
-
const preprocessedInput = preprocessToolInput(tool, input);
|
|
32251
|
-
const isValidInput = tool.inputSchema.safeParse(preprocessedInput);
|
|
32252
|
-
if (!isValidInput.success) {
|
|
32253
|
-
const errorMessage = resolveInitialInputValidationMessage({
|
|
32254
|
-
toolName: tool.name,
|
|
32255
|
-
preprocessedInput,
|
|
32256
|
-
validationMessage: isValidInput.error.message
|
|
32257
|
-
});
|
|
32258
|
-
yield createUserMessageFromBlocks([
|
|
32259
|
-
createInputValidationErrorBlock({
|
|
32260
|
-
toolUseId: toolUseID,
|
|
32261
|
-
content: errorMessage
|
|
32262
|
-
})
|
|
32263
|
-
]);
|
|
32264
|
-
return;
|
|
32265
|
-
}
|
|
32266
|
-
let normalizedInput = normalizeToolInput(tool, isValidInput.data);
|
|
32267
|
-
const isValidCall = await tool.validateInput?.(
|
|
32268
|
-
normalizedInput,
|
|
32269
|
-
context
|
|
32270
|
-
);
|
|
32271
|
-
if (isValidCall?.result === false) {
|
|
32272
|
-
yield createUserMessageFromBlocks([
|
|
32273
|
-
createInputValidationErrorBlock({
|
|
32274
|
-
toolUseId: toolUseID,
|
|
32275
|
-
content: isValidCall.message
|
|
32276
|
-
})
|
|
32277
|
-
]);
|
|
32278
|
-
return;
|
|
32279
|
-
}
|
|
32280
|
-
const hookOutcome = await runPreToolUseHooks({
|
|
32281
|
-
toolName: tool.name,
|
|
32282
|
-
toolInput: normalizedInput,
|
|
32283
|
-
toolUseId: toolUseID,
|
|
32284
|
-
...buildToolHookBaseArgs(context, toolUseID)
|
|
32285
|
-
});
|
|
32286
|
-
if (hookOutcome.kind === "block") {
|
|
32287
|
-
yield createUserMessageFromBlocks([
|
|
32288
|
-
createHookBlockedErrorBlock({
|
|
32289
|
-
toolUseId: toolUseID,
|
|
32290
|
-
content: hookOutcome.message
|
|
32291
|
-
})
|
|
32292
|
-
]);
|
|
32293
|
-
return;
|
|
32294
|
-
}
|
|
32295
|
-
const preWarningPayload = buildWarningProgressPayload({
|
|
32296
|
-
warnings: hookOutcome.warnings,
|
|
32297
|
-
defaultTools: context.options?.tools ?? []
|
|
32298
|
-
});
|
|
32299
|
-
if (preWarningPayload) {
|
|
32300
|
-
yield createProgressMessage(
|
|
32301
|
-
toolUseID,
|
|
32302
|
-
siblingToolUseIDs,
|
|
32303
|
-
createAssistantMessage(preWarningPayload.warningText),
|
|
32304
|
-
[],
|
|
32305
|
-
preWarningPayload.tools,
|
|
32306
|
-
{ progressState: "running" }
|
|
32307
|
-
);
|
|
32308
|
-
}
|
|
32309
|
-
applyHookOutcomeSideEffects(context, hookOutcome);
|
|
32310
|
-
const updatedInputResult = await resolveHookUpdatedInput({
|
|
32311
|
-
tool,
|
|
32312
|
-
normalizedInput,
|
|
32313
|
-
updatedInput: hookOutcome.updatedInput,
|
|
32314
|
-
context
|
|
32315
|
-
});
|
|
32316
|
-
if (updatedInputResult.kind === "invalid") {
|
|
32317
|
-
yield createUserMessageFromBlocks([
|
|
32318
|
-
createInputValidationErrorBlock({
|
|
32319
|
-
toolUseId: toolUseID,
|
|
32320
|
-
content: updatedInputResult.message
|
|
32321
|
-
})
|
|
32322
|
-
]);
|
|
32323
|
-
return;
|
|
32324
|
-
}
|
|
32325
|
-
if (updatedInputResult.kind === "updated") {
|
|
32326
|
-
normalizedInput = normalizeToolInput(tool, updatedInputResult.normalizedInput);
|
|
32327
|
-
}
|
|
32328
|
-
const hookPermissionDecision = hookOutcome.kind === "allow" ? hookOutcome.permissionDecision : void 0;
|
|
32329
|
-
const { effectiveShouldSkipPermissionCheck, permissionContextForCall } = resolvePermissionExecutionPlan({
|
|
32330
|
-
context,
|
|
32331
|
-
hookPermissionDecision,
|
|
32332
|
-
shouldSkipPermissionCheck
|
|
32333
|
-
});
|
|
32334
|
-
const permissionResult = await resolvePermissionResult({
|
|
32335
|
-
effectiveShouldSkipPermissionCheck,
|
|
32336
|
-
canUseTool,
|
|
32337
|
-
tool,
|
|
32338
|
-
normalizedInput,
|
|
32339
|
-
permissionContextForCall,
|
|
32340
|
-
toolUseId: toolUseID,
|
|
32341
|
-
assistantMessage
|
|
32342
|
-
});
|
|
32343
|
-
if (permissionResult.result === false) {
|
|
32344
|
-
yield createUserMessageFromBlocks([
|
|
32345
|
-
createPermissionDeniedErrorBlock({
|
|
32346
|
-
toolUseId: toolUseID,
|
|
32347
|
-
content: permissionResult.message
|
|
32348
|
-
})
|
|
32349
|
-
]);
|
|
32350
|
-
return;
|
|
32351
|
-
}
|
|
32352
|
-
try {
|
|
32353
|
-
const generator = tool.call(normalizedInput, {
|
|
32354
|
-
...context,
|
|
32355
|
-
toolUseId: toolUseID
|
|
32356
|
-
});
|
|
32357
|
-
for await (const result of generator) {
|
|
32358
|
-
switch (result.type) {
|
|
32359
|
-
case "result":
|
|
32360
|
-
{
|
|
32361
|
-
const content = resolveToolResultAssistantContent({
|
|
32362
|
-
resultForAssistant: result.resultForAssistant,
|
|
32363
|
-
resultData: result.data,
|
|
32364
|
-
renderResultForAssistant: (data) => tool.renderResultForAssistant(data),
|
|
32365
|
-
permissionMode: context.options?.toolPermissionContext?.mode
|
|
32366
|
-
});
|
|
32367
|
-
const postOutcome = await runPostToolUseHooks({
|
|
32368
|
-
toolName: tool.name,
|
|
32369
|
-
toolInput: normalizedInput,
|
|
32370
|
-
toolResult: result.data,
|
|
32371
|
-
toolUseId: toolUseID,
|
|
32372
|
-
...buildToolHookBaseArgs(context, toolUseID)
|
|
32373
|
-
});
|
|
32374
|
-
applyHookOutcomeSideEffects(context, postOutcome);
|
|
32375
|
-
const postResultHandling = buildPostToolResultHandling({
|
|
32376
|
-
toolUseId: toolUseID,
|
|
32377
|
-
content,
|
|
32378
|
-
resultData: result.data,
|
|
32379
|
-
newMessages: result.newMessages,
|
|
32380
|
-
contextModifier: result.contextModifier
|
|
32381
|
-
});
|
|
32382
|
-
const postWarningPayload = buildWarningProgressPayload({
|
|
32383
|
-
warnings: postOutcome.warnings,
|
|
32384
|
-
defaultTools: context.options?.tools ?? []
|
|
32385
|
-
});
|
|
32386
|
-
if (postWarningPayload) {
|
|
32387
|
-
yield createProgressMessage(
|
|
32388
|
-
toolUseID,
|
|
32389
|
-
siblingToolUseIDs,
|
|
32390
|
-
createAssistantMessage(postWarningPayload.warningText),
|
|
32391
|
-
[],
|
|
32392
|
-
postWarningPayload.tools,
|
|
32393
|
-
{ progressState: "running" }
|
|
32394
|
-
);
|
|
32395
|
-
}
|
|
32396
|
-
yield createUserMessageFromBlocks(
|
|
32397
|
-
postResultHandling.envelope.blocks,
|
|
32398
|
-
postResultHandling.envelope.toolUseResult
|
|
32399
|
-
);
|
|
32400
|
-
for (const message of postResultHandling.structuredMessages) {
|
|
32401
|
-
yield message;
|
|
32402
|
-
}
|
|
32403
|
-
}
|
|
32404
|
-
return;
|
|
32405
|
-
case "progress":
|
|
32406
|
-
const progressPayload = buildRunningProgressPayload({
|
|
32407
|
-
content: result.content,
|
|
32408
|
-
normalizedMessages: result.normalizedMessages,
|
|
32409
|
-
tools: result.tools,
|
|
32410
|
-
defaultTools: context.options?.tools ?? []
|
|
32411
|
-
});
|
|
32412
|
-
yield createProgressMessage(
|
|
32413
|
-
toolUseID,
|
|
32414
|
-
siblingToolUseIDs,
|
|
32415
|
-
progressPayload.content,
|
|
32416
|
-
progressPayload.normalizedMessages,
|
|
32417
|
-
progressPayload.tools,
|
|
32418
|
-
{ progressState: "running" }
|
|
32419
|
-
);
|
|
32420
|
-
break;
|
|
32421
|
-
}
|
|
32422
|
-
}
|
|
32423
|
-
} catch (error) {
|
|
32424
|
-
logError(error);
|
|
32425
|
-
yield createUserMessageFromBlocks([
|
|
32426
|
-
createToolExecutionErrorBlock({
|
|
32427
|
-
toolUseId: toolUseID,
|
|
32428
|
-
error,
|
|
32429
|
-
mode: "full"
|
|
32430
|
-
})
|
|
32431
|
-
]);
|
|
32432
|
-
}
|
|
32433
|
-
}
|
|
32434
32378
|
|
|
32435
32379
|
// src/ui/components/binary-feedback/BinaryFeedback.tsx
|
|
32436
32380
|
import { default as React96, useCallback as useCallback15 } from "react";
|
|
@@ -33606,7 +33550,7 @@ import { homedir as homedir8 } from "os";
|
|
|
33606
33550
|
// src/commands/agents/generation.ts
|
|
33607
33551
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
33608
33552
|
async function generateAgentWithClaude(prompt) {
|
|
33609
|
-
const { queryModel } = await import("./llm-
|
|
33553
|
+
const { queryModel } = await import("./llm-BPQNYHE3.js");
|
|
33610
33554
|
const systemPrompt = `You are an expert at creating AI agent configurations. Based on the user's description, generate a specialized agent configuration.
|
|
33611
33555
|
|
|
33612
33556
|
Return your response as a JSON object with exactly these fields:
|