pybao-cli 1.5.13 → 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-6D6QDJQY.js → acp-AT5V4HJH.js} +31 -31
- package/dist/{agentsValidate-XFP3HZ4H.js → agentsValidate-RAMCNNGN.js} +7 -7
- package/dist/{ask-6CZRJCSZ.js → ask-MSHFKMOM.js} +30 -30
- package/dist/{autoUpdater-VCCPGPDD.js → autoUpdater-SKKUYQGP.js} +3 -3
- package/dist/{chunk-R5KHOF4Q.js → chunk-2UWY74V2.js} +1 -1
- package/dist/{chunk-62DRY4WE.js → chunk-3I7K6SG5.js} +4 -4
- package/dist/{chunk-CLDFSJRX.js → chunk-3O5DLN4S.js} +3 -3
- package/dist/{chunk-2YIYRACC.js → chunk-5GJVTQ6Z.js} +1 -1
- package/dist/{chunk-FEEOL2BF.js → chunk-633CKZ4H.js} +2 -2
- package/dist/{chunk-DYRNDVME.js → chunk-656DI2PZ.js} +3 -3
- package/dist/{chunk-V6HDC2AS.js → chunk-6GFXJLN3.js} +4 -4
- package/dist/{chunk-HBFOODQT.js → chunk-7RAZGTUT.js} +1 -1
- package/dist/{chunk-PH2OZGKF.js → chunk-BLPZN5F3.js} +1 -1
- package/dist/{chunk-VLE3RIPA.js → chunk-CCGXQSUZ.js} +3 -3
- package/dist/{chunk-GKLF5SMX.js → chunk-DPM2NLYC.js} +4 -4
- package/dist/{chunk-SQZQF7FX.js → chunk-DY2JCWQE.js} +1 -1
- package/dist/{chunk-IKZOQVSC.js → chunk-EL45JJXX.js} +3 -3
- package/dist/{chunk-KDWAOC2Y.js → chunk-EOZR4EWJ.js} +2 -2
- package/dist/{chunk-LHETO2A7.js → chunk-G2NQTS2X.js} +2 -2
- package/dist/{chunk-UYEP4HDV.js → chunk-G4URT4VU.js} +1 -1
- package/dist/{chunk-5SB6YYVT.js → chunk-GP4PJUZ5.js} +1 -1
- package/dist/{chunk-EN3EFAIN.js → chunk-GWIJUNRO.js} +667 -764
- package/dist/{chunk-EN3EFAIN.js.map → chunk-GWIJUNRO.js.map} +4 -4
- package/dist/{chunk-PF2W6HQJ.js → chunk-HWG2BWLL.js} +3 -3
- package/dist/{chunk-LXKU7CVC.js → chunk-JWJC3DE2.js} +1 -1
- package/dist/{chunk-4V637EWT.js → chunk-KROM73XA.js} +15 -15
- package/dist/{chunk-PMBP2S7T.js → chunk-LFCRI4XF.js} +2 -2
- package/dist/{chunk-NMV2Y2OE.js → chunk-P6GUR3BQ.js} +2 -2
- package/dist/{chunk-6Z7VRZE3.js → chunk-PD3UXMJI.js} +2 -2
- package/dist/{chunk-5AZPIB3O.js → chunk-RAT3UGPD.js} +3 -3
- package/dist/{chunk-KHCVAV26.js → chunk-RAWU5JAN.js} +1 -1
- package/dist/{chunk-DFQUXY7J.js → chunk-RE4W2ZJB.js} +1 -1
- package/dist/{chunk-IZKGIVR5.js → chunk-W2IIXSKF.js} +4 -4
- package/dist/{chunk-USAN2W2G.js → chunk-WGK3XBGW.js} +1 -1
- package/dist/{chunk-MP2Z2WPA.js → chunk-WSYTRNNY.js} +3 -3
- package/dist/{chunk-4CTIJSGF.js → chunk-XFCLMIVU.js} +1 -1
- package/dist/{chunk-2L7XKUEG.js → chunk-YDZG5W4V.js} +1 -1
- package/dist/{chunk-2L7XKUEG.js.map → chunk-YDZG5W4V.js.map} +1 -1
- package/dist/{cli-2YA4LC5A.js → cli-BOWVY6R3.js} +91 -91
- package/dist/commands-5TSQH2YJ.js +54 -0
- package/dist/{config-NLO656A6.js → config-I2D37MAO.js} +4 -4
- package/dist/{context-B5OAVYCB.js → context-VABSOXYH.js} +6 -6
- package/dist/{conversationPersistence-U3JD7OG2.js → conversationPersistence-5VZYNRKZ.js} +3 -3
- package/dist/{conversationTracker-XMFEBWHY.js → conversationTracker-GLBFPNV5.js} +4 -4
- package/dist/{customCommands-MP2IC4VW.js → customCommands-XDBZLSTQ.js} +4 -4
- package/dist/{env-IWFZNFTP.js → env-LQC4XU2Q.js} +2 -2
- package/dist/{file-NKAAAB74.js → file-GG4AHH6L.js} +4 -4
- package/dist/index.js +3 -3
- package/dist/{llm-VL7SVIXR.js → llm-BPQNYHE3.js} +31 -31
- package/dist/{llmLazy-JXN5R32R.js → llmLazy-ERIDXKJP.js} +1 -1
- package/dist/{loader-QO3E224E.js → loader-4PJMU2RQ.js} +4 -4
- package/dist/{lsp-3KQLSDLC.js → lsp-TTHCC6GK.js} +6 -6
- package/dist/{lspAnchor-56RDVJJK.js → lspAnchor-GVGHDYX4.js} +6 -6
- package/dist/{mcp-QYGOVXNU.js → mcp-7UXI2HGT.js} +7 -7
- package/dist/{mentionProcessor-M5UL6TT6.js → mentionProcessor-MJMQGTMD.js} +5 -5
- package/dist/{messages-IR7NEQMR.js → messages-BGURJH5A.js} +1 -1
- package/dist/{model-JVW7GWZF.js → model-73TIVV4A.js} +5 -5
- package/dist/{openai-JJWBAQ7K.js → openai-AKBW3O3B.js} +5 -5
- package/dist/{outputStyles-NNT6NWAK.js → outputStyles-3OQCURTS.js} +4 -4
- package/dist/{pluginRuntime-5ZYXGIUZ.js → pluginRuntime-QWYITTNV.js} +6 -6
- package/dist/{pluginValidation-6OLPIUNW.js → pluginValidation-6KF6BNI3.js} +6 -6
- package/dist/prompts-MOJ3I4T4.js +56 -0
- package/dist/{pybAgentSessionLoad-HN6WOHQP.js → pybAgentSessionLoad-O6E64X5A.js} +4 -4
- package/dist/{pybAgentSessionResume-KEUXFVVT.js → pybAgentSessionResume-AQOFIWCM.js} +4 -4
- package/dist/{pybAgentStreamJsonSession-V24MOW3E.js → pybAgentStreamJsonSession-IFBVOQOE.js} +1 -1
- package/dist/{pybHooks-OEASV3O6.js → pybHooks-WDSZDXUD.js} +4 -4
- package/dist/query-OC3TMXBW.js +56 -0
- package/dist/{registry-WDNZOTS2.js → registry-MPFGTVV6.js} +5 -5
- package/dist/{ripgrep-YEEECTEY.js → ripgrep-JAKZKDZN.js} +3 -3
- package/dist/{skillMarketplace-N2W7WTS3.js → skillMarketplace-OGHKQY7N.js} +3 -3
- package/dist/{state-IB4ZDFMG.js → state-KCGPU2FP.js} +2 -2
- package/dist/{theme-5AY4LKLW.js → theme-LMMG2NKE.js} +5 -5
- package/dist/{toolPermissionSettings-J5VPVYUK.js → toolPermissionSettings-HVQSSP7C.js} +6 -6
- package/dist/tools-NE4ZQ7RG.js +55 -0
- package/dist/{userInput-YJI6VWIU.js → userInput-WGDHQIMP.js} +32 -32
- package/package.json +1 -1
- package/scripts/session-behavior-invariant-gate.mjs +3 -1
- package/dist/REPL-4ET7DK5F.js +0 -50
- package/dist/commands-GZ2R547K.js +0 -54
- package/dist/prompts-ITAM2QAA.js +0 -56
- package/dist/query-4YMUBJ3B.js +0 -56
- package/dist/tools-VLTX3RMF.js +0 -55
- /package/dist/{REPL-4ET7DK5F.js.map → REPL-BZ3IK37X.js.map} +0 -0
- /package/dist/{acp-6D6QDJQY.js.map → acp-AT5V4HJH.js.map} +0 -0
- /package/dist/{agentsValidate-XFP3HZ4H.js.map → agentsValidate-RAMCNNGN.js.map} +0 -0
- /package/dist/{ask-6CZRJCSZ.js.map → ask-MSHFKMOM.js.map} +0 -0
- /package/dist/{autoUpdater-VCCPGPDD.js.map → autoUpdater-SKKUYQGP.js.map} +0 -0
- /package/dist/{chunk-R5KHOF4Q.js.map → chunk-2UWY74V2.js.map} +0 -0
- /package/dist/{chunk-62DRY4WE.js.map → chunk-3I7K6SG5.js.map} +0 -0
- /package/dist/{chunk-CLDFSJRX.js.map → chunk-3O5DLN4S.js.map} +0 -0
- /package/dist/{chunk-2YIYRACC.js.map → chunk-5GJVTQ6Z.js.map} +0 -0
- /package/dist/{chunk-FEEOL2BF.js.map → chunk-633CKZ4H.js.map} +0 -0
- /package/dist/{chunk-DYRNDVME.js.map → chunk-656DI2PZ.js.map} +0 -0
- /package/dist/{chunk-V6HDC2AS.js.map → chunk-6GFXJLN3.js.map} +0 -0
- /package/dist/{chunk-HBFOODQT.js.map → chunk-7RAZGTUT.js.map} +0 -0
- /package/dist/{chunk-PH2OZGKF.js.map → chunk-BLPZN5F3.js.map} +0 -0
- /package/dist/{chunk-VLE3RIPA.js.map → chunk-CCGXQSUZ.js.map} +0 -0
- /package/dist/{chunk-GKLF5SMX.js.map → chunk-DPM2NLYC.js.map} +0 -0
- /package/dist/{chunk-SQZQF7FX.js.map → chunk-DY2JCWQE.js.map} +0 -0
- /package/dist/{chunk-IKZOQVSC.js.map → chunk-EL45JJXX.js.map} +0 -0
- /package/dist/{chunk-KDWAOC2Y.js.map → chunk-EOZR4EWJ.js.map} +0 -0
- /package/dist/{chunk-LHETO2A7.js.map → chunk-G2NQTS2X.js.map} +0 -0
- /package/dist/{chunk-UYEP4HDV.js.map → chunk-G4URT4VU.js.map} +0 -0
- /package/dist/{chunk-5SB6YYVT.js.map → chunk-GP4PJUZ5.js.map} +0 -0
- /package/dist/{chunk-PF2W6HQJ.js.map → chunk-HWG2BWLL.js.map} +0 -0
- /package/dist/{chunk-LXKU7CVC.js.map → chunk-JWJC3DE2.js.map} +0 -0
- /package/dist/{chunk-4V637EWT.js.map → chunk-KROM73XA.js.map} +0 -0
- /package/dist/{chunk-PMBP2S7T.js.map → chunk-LFCRI4XF.js.map} +0 -0
- /package/dist/{chunk-NMV2Y2OE.js.map → chunk-P6GUR3BQ.js.map} +0 -0
- /package/dist/{chunk-6Z7VRZE3.js.map → chunk-PD3UXMJI.js.map} +0 -0
- /package/dist/{chunk-5AZPIB3O.js.map → chunk-RAT3UGPD.js.map} +0 -0
- /package/dist/{chunk-KHCVAV26.js.map → chunk-RAWU5JAN.js.map} +0 -0
- /package/dist/{chunk-DFQUXY7J.js.map → chunk-RE4W2ZJB.js.map} +0 -0
- /package/dist/{chunk-IZKGIVR5.js.map → chunk-W2IIXSKF.js.map} +0 -0
- /package/dist/{chunk-USAN2W2G.js.map → chunk-WGK3XBGW.js.map} +0 -0
- /package/dist/{chunk-MP2Z2WPA.js.map → chunk-WSYTRNNY.js.map} +0 -0
- /package/dist/{chunk-4CTIJSGF.js.map → chunk-XFCLMIVU.js.map} +0 -0
- /package/dist/{cli-2YA4LC5A.js.map → cli-BOWVY6R3.js.map} +0 -0
- /package/dist/{commands-GZ2R547K.js.map → commands-5TSQH2YJ.js.map} +0 -0
- /package/dist/{config-NLO656A6.js.map → config-I2D37MAO.js.map} +0 -0
- /package/dist/{context-B5OAVYCB.js.map → context-VABSOXYH.js.map} +0 -0
- /package/dist/{conversationPersistence-U3JD7OG2.js.map → conversationPersistence-5VZYNRKZ.js.map} +0 -0
- /package/dist/{conversationTracker-XMFEBWHY.js.map → conversationTracker-GLBFPNV5.js.map} +0 -0
- /package/dist/{customCommands-MP2IC4VW.js.map → customCommands-XDBZLSTQ.js.map} +0 -0
- /package/dist/{env-IWFZNFTP.js.map → env-LQC4XU2Q.js.map} +0 -0
- /package/dist/{file-NKAAAB74.js.map → file-GG4AHH6L.js.map} +0 -0
- /package/dist/{llm-VL7SVIXR.js.map → llm-BPQNYHE3.js.map} +0 -0
- /package/dist/{llmLazy-JXN5R32R.js.map → llmLazy-ERIDXKJP.js.map} +0 -0
- /package/dist/{loader-QO3E224E.js.map → loader-4PJMU2RQ.js.map} +0 -0
- /package/dist/{lsp-3KQLSDLC.js.map → lsp-TTHCC6GK.js.map} +0 -0
- /package/dist/{lspAnchor-56RDVJJK.js.map → lspAnchor-GVGHDYX4.js.map} +0 -0
- /package/dist/{mcp-QYGOVXNU.js.map → mcp-7UXI2HGT.js.map} +0 -0
- /package/dist/{mentionProcessor-M5UL6TT6.js.map → mentionProcessor-MJMQGTMD.js.map} +0 -0
- /package/dist/{messages-IR7NEQMR.js.map → messages-BGURJH5A.js.map} +0 -0
- /package/dist/{model-JVW7GWZF.js.map → model-73TIVV4A.js.map} +0 -0
- /package/dist/{openai-JJWBAQ7K.js.map → openai-AKBW3O3B.js.map} +0 -0
- /package/dist/{outputStyles-NNT6NWAK.js.map → outputStyles-3OQCURTS.js.map} +0 -0
- /package/dist/{pluginRuntime-5ZYXGIUZ.js.map → pluginRuntime-QWYITTNV.js.map} +0 -0
- /package/dist/{pluginValidation-6OLPIUNW.js.map → pluginValidation-6KF6BNI3.js.map} +0 -0
- /package/dist/{prompts-ITAM2QAA.js.map → prompts-MOJ3I4T4.js.map} +0 -0
- /package/dist/{pybAgentSessionLoad-HN6WOHQP.js.map → pybAgentSessionLoad-O6E64X5A.js.map} +0 -0
- /package/dist/{pybAgentSessionResume-KEUXFVVT.js.map → pybAgentSessionResume-AQOFIWCM.js.map} +0 -0
- /package/dist/{pybAgentStreamJsonSession-V24MOW3E.js.map → pybAgentStreamJsonSession-IFBVOQOE.js.map} +0 -0
- /package/dist/{pybHooks-OEASV3O6.js.map → pybHooks-WDSZDXUD.js.map} +0 -0
- /package/dist/{query-4YMUBJ3B.js.map → query-OC3TMXBW.js.map} +0 -0
- /package/dist/{registry-WDNZOTS2.js.map → registry-MPFGTVV6.js.map} +0 -0
- /package/dist/{ripgrep-YEEECTEY.js.map → ripgrep-JAKZKDZN.js.map} +0 -0
- /package/dist/{skillMarketplace-N2W7WTS3.js.map → skillMarketplace-OGHKQY7N.js.map} +0 -0
- /package/dist/{state-IB4ZDFMG.js.map → state-KCGPU2FP.js.map} +0 -0
- /package/dist/{theme-5AY4LKLW.js.map → theme-LMMG2NKE.js.map} +0 -0
- /package/dist/{toolPermissionSettings-J5VPVYUK.js.map → toolPermissionSettings-HVQSSP7C.js.map} +0 -0
- /package/dist/{tools-VLTX3RMF.js.map → tools-NE4ZQ7RG.js.map} +0 -0
- /package/dist/{userInput-YJI6VWIU.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;
|
|
@@ -31258,19 +31210,25 @@ function buildResultDispatchItems(args) {
|
|
|
31258
31210
|
tools: args.defaultTools
|
|
31259
31211
|
});
|
|
31260
31212
|
}
|
|
31261
|
-
const userMessage = buildToolResultEnvelope({
|
|
31262
|
-
toolUseId: args.toolUseId,
|
|
31263
|
-
content: args.content,
|
|
31264
|
-
resultData: args.resultData,
|
|
31265
|
-
newMessages: args.newMessages,
|
|
31266
|
-
contextModifier: args.contextModifier
|
|
31267
|
-
});
|
|
31268
31213
|
items.push({
|
|
31269
31214
|
kind: "user_message",
|
|
31270
|
-
blocks:
|
|
31271
|
-
|
|
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
|
+
}
|
|
31272
31228
|
});
|
|
31273
|
-
const structuredMessages =
|
|
31229
|
+
const structuredMessages = Array.isArray(args.newMessages) ? args.newMessages.filter(
|
|
31230
|
+
(message) => Boolean(message) && typeof message === "object" && "type" in message
|
|
31231
|
+
) : [];
|
|
31274
31232
|
for (const message of structuredMessages) {
|
|
31275
31233
|
items.push({
|
|
31276
31234
|
kind: "structured_message",
|
|
@@ -31303,37 +31261,207 @@ function buildWarningDispatchItems(args) {
|
|
|
31303
31261
|
}
|
|
31304
31262
|
];
|
|
31305
31263
|
}
|
|
31306
|
-
async function
|
|
31307
|
-
|
|
31308
|
-
|
|
31309
|
-
|
|
31310
|
-
|
|
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(
|
|
31311
31277
|
args.tool,
|
|
31312
31278
|
args.normalizedInput,
|
|
31313
|
-
{ ...
|
|
31279
|
+
{ ...permissionContextForCall, toolUseId: args.toolUseId },
|
|
31314
31280
|
args.assistantMessage
|
|
31315
31281
|
);
|
|
31282
|
+
return { permissionResult };
|
|
31316
31283
|
}
|
|
31317
|
-
async function
|
|
31318
|
-
const
|
|
31319
|
-
|
|
31320
|
-
|
|
31321
|
-
|
|
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 ?? []
|
|
31322
31333
|
});
|
|
31323
|
-
const
|
|
31324
|
-
|
|
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,
|
|
31325
31367
|
canUseTool: args.canUseTool,
|
|
31326
31368
|
tool: args.tool,
|
|
31327
|
-
normalizedInput
|
|
31328
|
-
|
|
31329
|
-
toolUseId: args.toolUseId,
|
|
31369
|
+
normalizedInput,
|
|
31370
|
+
toolUseId: args.toolUseID,
|
|
31330
31371
|
assistantMessage: args.assistantMessage
|
|
31331
31372
|
});
|
|
31332
|
-
|
|
31333
|
-
|
|
31334
|
-
|
|
31335
|
-
|
|
31336
|
-
|
|
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
|
+
}
|
|
31337
31465
|
}
|
|
31338
31466
|
|
|
31339
31467
|
// src/app/query.ts
|
|
@@ -31342,28 +31470,6 @@ function isToolUseLikeBlock(block) {
|
|
|
31342
31470
|
}
|
|
31343
31471
|
var __isToolUseLikeBlockForTests = isToolUseLikeBlock;
|
|
31344
31472
|
var reminderChannelRounds = [];
|
|
31345
|
-
function createSyntheticToolUseErrorMessage(args) {
|
|
31346
|
-
const { toolUseId, reason, rootToolUseId } = args;
|
|
31347
|
-
if (reason === "user_interrupted") {
|
|
31348
|
-
return createUserMessageFromBlocks([
|
|
31349
|
-
createErrorToolResultBlock({
|
|
31350
|
-
toolUseId,
|
|
31351
|
-
content: REJECT_MESSAGE,
|
|
31352
|
-
errorCode: "USER_INTERRUPTED",
|
|
31353
|
-
errorClass: "fatal"
|
|
31354
|
-
})
|
|
31355
|
-
]);
|
|
31356
|
-
}
|
|
31357
|
-
return createUserMessageFromBlocks([
|
|
31358
|
-
createErrorToolResultBlock({
|
|
31359
|
-
toolUseId,
|
|
31360
|
-
content: "<tool_use_error>Sibling tool call errored</tool_use_error>",
|
|
31361
|
-
errorCode: "SIBLING_ERROR",
|
|
31362
|
-
errorClass: "fatal",
|
|
31363
|
-
rootToolUseId
|
|
31364
|
-
})
|
|
31365
|
-
]);
|
|
31366
|
-
}
|
|
31367
31473
|
var ToolUseQueue = class {
|
|
31368
31474
|
toolDefinitions;
|
|
31369
31475
|
canUseTool;
|
|
@@ -31616,7 +31722,17 @@ async function* query(messages, systemPrompt, context, canUseTool, toolUseContex
|
|
|
31616
31722
|
requestId: context.requestId,
|
|
31617
31723
|
currentRequestId: getCurrentRequest()?.id,
|
|
31618
31724
|
isTestEnv: process.env.NODE_ENV === "test",
|
|
31619
|
-
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
|
+
},
|
|
31620
31736
|
logUserFriendly,
|
|
31621
31737
|
stream: async function* (preparedMessages) {
|
|
31622
31738
|
yield* queryCore(
|
|
@@ -31833,23 +31949,7 @@ async function* queryCore(messages, systemPrompt, context, canUseTool, toolUseCo
|
|
|
31833
31949
|
}
|
|
31834
31950
|
updateHookTranscriptForMessages(toolUseContext, messages);
|
|
31835
31951
|
{
|
|
31836
|
-
const
|
|
31837
|
-
let userPromptText = null;
|
|
31838
|
-
if (last2 && typeof last2 === "object" && last2.type === "user") {
|
|
31839
|
-
const content = last2.message?.content;
|
|
31840
|
-
if (typeof content === "string") {
|
|
31841
|
-
userPromptText = content;
|
|
31842
|
-
} else if (Array.isArray(content)) {
|
|
31843
|
-
const hasToolResult = content.some(
|
|
31844
|
-
(b) => b && typeof b === "object" && b.type === "tool_result"
|
|
31845
|
-
);
|
|
31846
|
-
if (!hasToolResult) {
|
|
31847
|
-
userPromptText = content.filter(
|
|
31848
|
-
(b) => b && typeof b === "object" && b.type === "text"
|
|
31849
|
-
).map((b) => String(b.text ?? "")).join("");
|
|
31850
|
-
}
|
|
31851
|
-
}
|
|
31852
|
-
}
|
|
31952
|
+
const userPromptText = extractUserPromptTextFromMessages(messages);
|
|
31853
31953
|
if (userPromptText !== null) {
|
|
31854
31954
|
toolUseContext.options.lastUserPrompt = userPromptText;
|
|
31855
31955
|
const promptOutcome = await runUserPromptSubmitHooks({
|
|
@@ -32244,14 +32344,10 @@ async function* runToolUse(toolUse, siblingToolUseIDs, assistantMessage, canUseT
|
|
|
32244
32344
|
toolUseID: toolUse.id,
|
|
32245
32345
|
requestId: currentRequest?.id
|
|
32246
32346
|
});
|
|
32247
|
-
yield
|
|
32248
|
-
|
|
32249
|
-
|
|
32250
|
-
|
|
32251
|
-
errorCode: "TOOL_NOT_FOUND",
|
|
32252
|
-
errorClass: "soft"
|
|
32253
|
-
})
|
|
32254
|
-
]);
|
|
32347
|
+
yield createToolNotFoundErrorMessage({
|
|
32348
|
+
toolUseId: toolUse.id,
|
|
32349
|
+
toolName
|
|
32350
|
+
});
|
|
32255
32351
|
sessionContext?.finishTool(toolUse.id);
|
|
32256
32352
|
return;
|
|
32257
32353
|
}
|
|
@@ -32263,215 +32359,22 @@ async function* runToolUse(toolUse, siblingToolUseIDs, assistantMessage, canUseT
|
|
|
32263
32359
|
requestId: currentRequest?.id
|
|
32264
32360
|
});
|
|
32265
32361
|
try {
|
|
32266
|
-
for await (const message of checkPermissionsAndCallTool(
|
|
32362
|
+
for await (const message of checkPermissionsAndCallTool({
|
|
32267
32363
|
tool,
|
|
32268
|
-
toolUse.id,
|
|
32364
|
+
toolUseID: toolUse.id,
|
|
32269
32365
|
siblingToolUseIDs,
|
|
32270
|
-
toolInput,
|
|
32271
|
-
toolUseContext,
|
|
32366
|
+
input: toolInput,
|
|
32367
|
+
context: toolUseContext,
|
|
32272
32368
|
canUseTool,
|
|
32273
32369
|
assistantMessage,
|
|
32274
32370
|
shouldSkipPermissionCheck
|
|
32275
|
-
)) {
|
|
32371
|
+
})) {
|
|
32276
32372
|
yield message;
|
|
32277
32373
|
}
|
|
32278
|
-
} catch (e) {
|
|
32279
|
-
logError(e);
|
|
32280
|
-
const errorMessage = createUserMessageFromBlocks([
|
|
32281
|
-
createToolExecutionErrorBlock({
|
|
32282
|
-
toolUseId: toolUse.id,
|
|
32283
|
-
error: e,
|
|
32284
|
-
mode: "summary"
|
|
32285
|
-
})
|
|
32286
|
-
]);
|
|
32287
|
-
yield errorMessage;
|
|
32288
32374
|
} finally {
|
|
32289
32375
|
sessionContext?.finishTool(toolUse.id);
|
|
32290
32376
|
}
|
|
32291
32377
|
}
|
|
32292
|
-
async function* checkPermissionsAndCallTool(tool, toolUseID, siblingToolUseIDs, input, context, canUseTool, assistantMessage, shouldSkipPermissionCheck) {
|
|
32293
|
-
const preprocessedInput = preprocessToolInput(tool, input);
|
|
32294
|
-
const isValidInput = tool.inputSchema.safeParse(preprocessedInput);
|
|
32295
|
-
if (!isValidInput.success) {
|
|
32296
|
-
const errorMessage = resolveInitialInputValidationMessage({
|
|
32297
|
-
toolName: tool.name,
|
|
32298
|
-
preprocessedInput,
|
|
32299
|
-
validationMessage: isValidInput.error.message
|
|
32300
|
-
});
|
|
32301
|
-
yield createUserMessageFromBlocks([
|
|
32302
|
-
createInputValidationErrorBlock({
|
|
32303
|
-
toolUseId: toolUseID,
|
|
32304
|
-
content: errorMessage
|
|
32305
|
-
})
|
|
32306
|
-
]);
|
|
32307
|
-
return;
|
|
32308
|
-
}
|
|
32309
|
-
let normalizedInput = normalizeToolInput(tool, isValidInput.data);
|
|
32310
|
-
const isValidCall = await tool.validateInput?.(
|
|
32311
|
-
normalizedInput,
|
|
32312
|
-
context
|
|
32313
|
-
);
|
|
32314
|
-
if (isValidCall?.result === false) {
|
|
32315
|
-
yield createUserMessageFromBlocks([
|
|
32316
|
-
createInputValidationErrorBlock({
|
|
32317
|
-
toolUseId: toolUseID,
|
|
32318
|
-
content: isValidCall.message
|
|
32319
|
-
})
|
|
32320
|
-
]);
|
|
32321
|
-
return;
|
|
32322
|
-
}
|
|
32323
|
-
const hookOutcome = await runPreToolUseHooks({
|
|
32324
|
-
toolName: tool.name,
|
|
32325
|
-
toolInput: normalizedInput,
|
|
32326
|
-
toolUseId: toolUseID,
|
|
32327
|
-
...buildToolHookBaseArgs(context, toolUseID)
|
|
32328
|
-
});
|
|
32329
|
-
if (hookOutcome.kind === "block") {
|
|
32330
|
-
yield createUserMessageFromBlocks([
|
|
32331
|
-
createHookBlockedErrorBlock({
|
|
32332
|
-
toolUseId: toolUseID,
|
|
32333
|
-
content: hookOutcome.message
|
|
32334
|
-
})
|
|
32335
|
-
]);
|
|
32336
|
-
return;
|
|
32337
|
-
}
|
|
32338
|
-
const preWarningDispatchItems = buildWarningDispatchItems({
|
|
32339
|
-
warnings: hookOutcome.warnings,
|
|
32340
|
-
defaultTools: context.options?.tools ?? []
|
|
32341
|
-
});
|
|
32342
|
-
for (const dispatchItem of preWarningDispatchItems) {
|
|
32343
|
-
yield createProgressMessage(
|
|
32344
|
-
toolUseID,
|
|
32345
|
-
siblingToolUseIDs,
|
|
32346
|
-
createAssistantMessage(dispatchItem.warningText),
|
|
32347
|
-
[],
|
|
32348
|
-
dispatchItem.tools,
|
|
32349
|
-
{ progressState: "running" }
|
|
32350
|
-
);
|
|
32351
|
-
}
|
|
32352
|
-
applyHookOutcomeSideEffects(context, hookOutcome);
|
|
32353
|
-
const updatedInputResult = await resolveHookUpdatedInput({
|
|
32354
|
-
tool,
|
|
32355
|
-
normalizedInput,
|
|
32356
|
-
updatedInput: hookOutcome.updatedInput,
|
|
32357
|
-
context
|
|
32358
|
-
});
|
|
32359
|
-
if (updatedInputResult.kind === "invalid") {
|
|
32360
|
-
yield createUserMessageFromBlocks([
|
|
32361
|
-
createInputValidationErrorBlock({
|
|
32362
|
-
toolUseId: toolUseID,
|
|
32363
|
-
content: updatedInputResult.message
|
|
32364
|
-
})
|
|
32365
|
-
]);
|
|
32366
|
-
return;
|
|
32367
|
-
}
|
|
32368
|
-
if (updatedInputResult.kind === "updated") {
|
|
32369
|
-
normalizedInput = normalizeToolInput(tool, updatedInputResult.normalizedInput);
|
|
32370
|
-
}
|
|
32371
|
-
const hookPermissionDecision = hookOutcome.kind === "allow" ? hookOutcome.permissionDecision : void 0;
|
|
32372
|
-
const { permissionResult } = await resolvePermissionCheckOutcome({
|
|
32373
|
-
context,
|
|
32374
|
-
hookPermissionDecision,
|
|
32375
|
-
shouldSkipPermissionCheck,
|
|
32376
|
-
canUseTool,
|
|
32377
|
-
tool,
|
|
32378
|
-
normalizedInput,
|
|
32379
|
-
toolUseId: toolUseID,
|
|
32380
|
-
assistantMessage
|
|
32381
|
-
});
|
|
32382
|
-
if (permissionResult.result === false) {
|
|
32383
|
-
yield createUserMessageFromBlocks([
|
|
32384
|
-
createPermissionDeniedErrorBlock({
|
|
32385
|
-
toolUseId: toolUseID,
|
|
32386
|
-
content: permissionResult.message
|
|
32387
|
-
})
|
|
32388
|
-
]);
|
|
32389
|
-
return;
|
|
32390
|
-
}
|
|
32391
|
-
try {
|
|
32392
|
-
const generator = tool.call(normalizedInput, {
|
|
32393
|
-
...context,
|
|
32394
|
-
toolUseId: toolUseID
|
|
32395
|
-
});
|
|
32396
|
-
for await (const result of generator) {
|
|
32397
|
-
switch (result.type) {
|
|
32398
|
-
case "result":
|
|
32399
|
-
{
|
|
32400
|
-
const content = resolveToolResultAssistantContent({
|
|
32401
|
-
resultForAssistant: result.resultForAssistant,
|
|
32402
|
-
resultData: result.data,
|
|
32403
|
-
renderResultForAssistant: (data) => tool.renderResultForAssistant(data),
|
|
32404
|
-
permissionMode: context.options?.toolPermissionContext?.mode
|
|
32405
|
-
});
|
|
32406
|
-
const postOutcome = await runPostToolUseHooks({
|
|
32407
|
-
toolName: tool.name,
|
|
32408
|
-
toolInput: normalizedInput,
|
|
32409
|
-
toolResult: result.data,
|
|
32410
|
-
toolUseId: toolUseID,
|
|
32411
|
-
...buildToolHookBaseArgs(context, toolUseID)
|
|
32412
|
-
});
|
|
32413
|
-
applyHookOutcomeSideEffects(context, postOutcome);
|
|
32414
|
-
const dispatchItems = buildResultDispatchItems({
|
|
32415
|
-
toolUseId: toolUseID,
|
|
32416
|
-
content,
|
|
32417
|
-
resultData: result.data,
|
|
32418
|
-
newMessages: result.newMessages,
|
|
32419
|
-
contextModifier: result.contextModifier,
|
|
32420
|
-
defaultTools: context.options?.tools ?? [],
|
|
32421
|
-
postWarnings: postOutcome.warnings
|
|
32422
|
-
});
|
|
32423
|
-
for (const dispatchItem of dispatchItems) {
|
|
32424
|
-
if (dispatchItem.kind === "warning_progress") {
|
|
32425
|
-
yield createProgressMessage(
|
|
32426
|
-
toolUseID,
|
|
32427
|
-
siblingToolUseIDs,
|
|
32428
|
-
createAssistantMessage(dispatchItem.warningText),
|
|
32429
|
-
[],
|
|
32430
|
-
dispatchItem.tools,
|
|
32431
|
-
{ progressState: "running" }
|
|
32432
|
-
);
|
|
32433
|
-
continue;
|
|
32434
|
-
}
|
|
32435
|
-
if (dispatchItem.kind === "user_message") {
|
|
32436
|
-
yield createUserMessageFromBlocks(
|
|
32437
|
-
dispatchItem.blocks,
|
|
32438
|
-
dispatchItem.toolUseResult
|
|
32439
|
-
);
|
|
32440
|
-
continue;
|
|
32441
|
-
}
|
|
32442
|
-
yield dispatchItem.message;
|
|
32443
|
-
}
|
|
32444
|
-
}
|
|
32445
|
-
return;
|
|
32446
|
-
case "progress":
|
|
32447
|
-
const progressPayload = buildRunningProgressPayload({
|
|
32448
|
-
content: result.content,
|
|
32449
|
-
normalizedMessages: result.normalizedMessages,
|
|
32450
|
-
tools: result.tools,
|
|
32451
|
-
defaultTools: context.options?.tools ?? []
|
|
32452
|
-
});
|
|
32453
|
-
yield createProgressMessage(
|
|
32454
|
-
toolUseID,
|
|
32455
|
-
siblingToolUseIDs,
|
|
32456
|
-
progressPayload.content,
|
|
32457
|
-
progressPayload.normalizedMessages,
|
|
32458
|
-
progressPayload.tools,
|
|
32459
|
-
{ progressState: "running" }
|
|
32460
|
-
);
|
|
32461
|
-
break;
|
|
32462
|
-
}
|
|
32463
|
-
}
|
|
32464
|
-
} catch (error) {
|
|
32465
|
-
logError(error);
|
|
32466
|
-
yield createUserMessageFromBlocks([
|
|
32467
|
-
createToolExecutionErrorBlock({
|
|
32468
|
-
toolUseId: toolUseID,
|
|
32469
|
-
error,
|
|
32470
|
-
mode: "full"
|
|
32471
|
-
})
|
|
32472
|
-
]);
|
|
32473
|
-
}
|
|
32474
|
-
}
|
|
32475
32378
|
|
|
32476
32379
|
// src/ui/components/binary-feedback/BinaryFeedback.tsx
|
|
32477
32380
|
import { default as React96, useCallback as useCallback15 } from "react";
|
|
@@ -33647,7 +33550,7 @@ import { homedir as homedir8 } from "os";
|
|
|
33647
33550
|
// src/commands/agents/generation.ts
|
|
33648
33551
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
33649
33552
|
async function generateAgentWithClaude(prompt) {
|
|
33650
|
-
const { queryModel } = await import("./llm-
|
|
33553
|
+
const { queryModel } = await import("./llm-BPQNYHE3.js");
|
|
33651
33554
|
const systemPrompt = `You are an expert at creating AI agent configurations. Based on the user's description, generate a specialized agent configuration.
|
|
33652
33555
|
|
|
33653
33556
|
Return your response as a JSON object with exactly these fields:
|