@probelabs/probe 0.6.0-rc255 → 0.6.0-rc256
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/bin/binaries/probe-v0.6.0-rc256-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc256-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc256-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc256-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc256-x86_64-unknown-linux-musl.tar.gz +0 -0
- package/build/agent/ProbeAgent.js +15 -7
- package/build/agent/bashDefaults.js +75 -6
- package/build/agent/index.js +327 -16
- package/build/agent/mcp/xmlBridge.js +3 -2
- package/build/agent/schemaUtils.js +127 -0
- package/build/tools/common.js +20 -3
- package/cjs/agent/ProbeAgent.cjs +335 -14
- package/cjs/index.cjs +335 -14
- package/package.json +1 -1
- package/src/agent/ProbeAgent.js +15 -7
- package/src/agent/bashDefaults.js +75 -6
- package/src/agent/index.js +4 -4
- package/src/agent/mcp/xmlBridge.js +3 -2
- package/src/agent/schemaUtils.js +127 -0
- package/src/tools/common.js +20 -3
- package/bin/binaries/probe-v0.6.0-rc255-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc255-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc255-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc255-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc255-x86_64-unknown-linux-musl.tar.gz +0 -0
package/cjs/agent/ProbeAgent.cjs
CHANGED
|
@@ -1844,6 +1844,7 @@ var require_ChecksumStream = __commonJS({
|
|
|
1844
1844
|
checksum;
|
|
1845
1845
|
source;
|
|
1846
1846
|
base64Encoder;
|
|
1847
|
+
pendingCallback = null;
|
|
1847
1848
|
constructor({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder }) {
|
|
1848
1849
|
super();
|
|
1849
1850
|
if (typeof source.pipe === "function") {
|
|
@@ -1858,11 +1859,20 @@ var require_ChecksumStream = __commonJS({
|
|
|
1858
1859
|
this.source.pipe(this);
|
|
1859
1860
|
}
|
|
1860
1861
|
_read(size) {
|
|
1862
|
+
if (this.pendingCallback) {
|
|
1863
|
+
const callback = this.pendingCallback;
|
|
1864
|
+
this.pendingCallback = null;
|
|
1865
|
+
callback();
|
|
1866
|
+
}
|
|
1861
1867
|
}
|
|
1862
1868
|
_write(chunk, encoding, callback) {
|
|
1863
1869
|
try {
|
|
1864
1870
|
this.checksum.update(chunk);
|
|
1865
|
-
this.push(chunk);
|
|
1871
|
+
const canPushMore = this.push(chunk);
|
|
1872
|
+
if (!canPushMore) {
|
|
1873
|
+
this.pendingCallback = callback;
|
|
1874
|
+
return;
|
|
1875
|
+
}
|
|
1866
1876
|
} catch (e5) {
|
|
1867
1877
|
return callback(e5);
|
|
1868
1878
|
}
|
|
@@ -39852,6 +39862,10 @@ function getValidParamsForTool(toolName) {
|
|
|
39852
39862
|
}
|
|
39853
39863
|
return [];
|
|
39854
39864
|
}
|
|
39865
|
+
function unescapeXmlEntities(str) {
|
|
39866
|
+
if (typeof str !== "string") return str;
|
|
39867
|
+
return str.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
39868
|
+
}
|
|
39855
39869
|
function parseXmlToolCall(xmlString, validTools = DEFAULT_VALID_TOOLS) {
|
|
39856
39870
|
let earliestToolName = null;
|
|
39857
39871
|
let earliestOpenIndex = Infinity;
|
|
@@ -39908,10 +39922,10 @@ function parseXmlToolCall(xmlString, validTools = DEFAULT_VALID_TOOLS) {
|
|
|
39908
39922
|
}
|
|
39909
39923
|
paramCloseIndex = nextTagIndex;
|
|
39910
39924
|
}
|
|
39911
|
-
let paramValue = innerContent.substring(
|
|
39925
|
+
let paramValue = unescapeXmlEntities(innerContent.substring(
|
|
39912
39926
|
paramOpenIndex + paramOpenTag.length,
|
|
39913
39927
|
paramCloseIndex
|
|
39914
|
-
).trim();
|
|
39928
|
+
).trim());
|
|
39915
39929
|
if (paramValue.toLowerCase() === "true") {
|
|
39916
39930
|
paramValue = true;
|
|
39917
39931
|
} else if (paramValue.toLowerCase() === "false") {
|
|
@@ -39925,7 +39939,7 @@ function parseXmlToolCall(xmlString, validTools = DEFAULT_VALID_TOOLS) {
|
|
|
39925
39939
|
params[paramName] = paramValue;
|
|
39926
39940
|
}
|
|
39927
39941
|
if (toolName === "attempt_completion") {
|
|
39928
|
-
params["result"] = innerContent.trim();
|
|
39942
|
+
params["result"] = unescapeXmlEntities(innerContent.trim());
|
|
39929
39943
|
if (params.command) {
|
|
39930
39944
|
delete params.command;
|
|
39931
39945
|
}
|
|
@@ -41098,6 +41112,7 @@ var init_bashDefaults = __esm({
|
|
|
41098
41112
|
"tree:*",
|
|
41099
41113
|
// Git read-only operations
|
|
41100
41114
|
"git:status",
|
|
41115
|
+
"git:status:*",
|
|
41101
41116
|
"git:log",
|
|
41102
41117
|
"git:log:*",
|
|
41103
41118
|
"git:diff",
|
|
@@ -41116,14 +41131,109 @@ var init_bashDefaults = __esm({
|
|
|
41116
41131
|
"git:blame",
|
|
41117
41132
|
"git:blame:*",
|
|
41118
41133
|
"git:shortlog",
|
|
41134
|
+
"git:shortlog:*",
|
|
41119
41135
|
"git:reflog",
|
|
41136
|
+
"git:reflog:*",
|
|
41120
41137
|
"git:ls-files",
|
|
41138
|
+
"git:ls-files:*",
|
|
41121
41139
|
"git:ls-tree",
|
|
41140
|
+
"git:ls-tree:*",
|
|
41141
|
+
"git:ls-remote",
|
|
41142
|
+
"git:ls-remote:*",
|
|
41122
41143
|
"git:rev-parse",
|
|
41144
|
+
"git:rev-parse:*",
|
|
41123
41145
|
"git:rev-list",
|
|
41146
|
+
"git:rev-list:*",
|
|
41147
|
+
"git:cat-file",
|
|
41148
|
+
"git:cat-file:*",
|
|
41149
|
+
"git:diff-tree",
|
|
41150
|
+
"git:diff-tree:*",
|
|
41151
|
+
"git:diff-files",
|
|
41152
|
+
"git:diff-files:*",
|
|
41153
|
+
"git:diff-index",
|
|
41154
|
+
"git:diff-index:*",
|
|
41155
|
+
"git:for-each-ref",
|
|
41156
|
+
"git:for-each-ref:*",
|
|
41157
|
+
"git:merge-base",
|
|
41158
|
+
"git:merge-base:*",
|
|
41159
|
+
"git:name-rev",
|
|
41160
|
+
"git:name-rev:*",
|
|
41161
|
+
"git:count-objects",
|
|
41162
|
+
"git:count-objects:*",
|
|
41163
|
+
"git:verify-commit",
|
|
41164
|
+
"git:verify-commit:*",
|
|
41165
|
+
"git:verify-tag",
|
|
41166
|
+
"git:verify-tag:*",
|
|
41167
|
+
"git:check-ignore",
|
|
41168
|
+
"git:check-ignore:*",
|
|
41169
|
+
"git:check-attr",
|
|
41170
|
+
"git:check-attr:*",
|
|
41171
|
+
"git:stash:list",
|
|
41172
|
+
"git:stash:show",
|
|
41173
|
+
"git:stash:show:*",
|
|
41174
|
+
"git:worktree:list",
|
|
41175
|
+
"git:worktree:list:*",
|
|
41176
|
+
"git:notes:list",
|
|
41177
|
+
"git:notes:show",
|
|
41178
|
+
"git:notes:show:*",
|
|
41124
41179
|
"git:--version",
|
|
41125
41180
|
"git:help",
|
|
41126
41181
|
"git:help:*",
|
|
41182
|
+
// GitHub CLI (gh) read-only operations
|
|
41183
|
+
"gh:--version",
|
|
41184
|
+
"gh:help",
|
|
41185
|
+
"gh:help:*",
|
|
41186
|
+
"gh:status",
|
|
41187
|
+
"gh:auth:status",
|
|
41188
|
+
"gh:auth:status:*",
|
|
41189
|
+
"gh:issue:list",
|
|
41190
|
+
"gh:issue:list:*",
|
|
41191
|
+
"gh:issue:view",
|
|
41192
|
+
"gh:issue:view:*",
|
|
41193
|
+
"gh:issue:status",
|
|
41194
|
+
"gh:issue:status:*",
|
|
41195
|
+
"gh:pr:list",
|
|
41196
|
+
"gh:pr:list:*",
|
|
41197
|
+
"gh:pr:view",
|
|
41198
|
+
"gh:pr:view:*",
|
|
41199
|
+
"gh:pr:status",
|
|
41200
|
+
"gh:pr:status:*",
|
|
41201
|
+
"gh:pr:diff",
|
|
41202
|
+
"gh:pr:diff:*",
|
|
41203
|
+
"gh:pr:checks",
|
|
41204
|
+
"gh:pr:checks:*",
|
|
41205
|
+
"gh:repo:list",
|
|
41206
|
+
"gh:repo:list:*",
|
|
41207
|
+
"gh:repo:view",
|
|
41208
|
+
"gh:repo:view:*",
|
|
41209
|
+
"gh:release:list",
|
|
41210
|
+
"gh:release:list:*",
|
|
41211
|
+
"gh:release:view",
|
|
41212
|
+
"gh:release:view:*",
|
|
41213
|
+
"gh:run:list",
|
|
41214
|
+
"gh:run:list:*",
|
|
41215
|
+
"gh:run:view",
|
|
41216
|
+
"gh:run:view:*",
|
|
41217
|
+
"gh:workflow:list",
|
|
41218
|
+
"gh:workflow:list:*",
|
|
41219
|
+
"gh:workflow:view",
|
|
41220
|
+
"gh:workflow:view:*",
|
|
41221
|
+
"gh:gist:list",
|
|
41222
|
+
"gh:gist:list:*",
|
|
41223
|
+
"gh:gist:view",
|
|
41224
|
+
"gh:gist:view:*",
|
|
41225
|
+
"gh:search:issues",
|
|
41226
|
+
"gh:search:issues:*",
|
|
41227
|
+
"gh:search:prs",
|
|
41228
|
+
"gh:search:prs:*",
|
|
41229
|
+
"gh:search:repos",
|
|
41230
|
+
"gh:search:repos:*",
|
|
41231
|
+
"gh:search:code",
|
|
41232
|
+
"gh:search:code:*",
|
|
41233
|
+
"gh:search:commits",
|
|
41234
|
+
"gh:search:commits:*",
|
|
41235
|
+
"gh:api",
|
|
41236
|
+
"gh:api:*",
|
|
41127
41237
|
// Package managers (information only)
|
|
41128
41238
|
"npm:list",
|
|
41129
41239
|
"npm:ls",
|
|
@@ -41434,14 +41544,132 @@ var init_bashDefaults = __esm({
|
|
|
41434
41544
|
"git:push",
|
|
41435
41545
|
"git:push:*",
|
|
41436
41546
|
"git:force",
|
|
41437
|
-
"git:reset
|
|
41438
|
-
"git:
|
|
41547
|
+
"git:reset",
|
|
41548
|
+
"git:reset:*",
|
|
41549
|
+
"git:clean",
|
|
41550
|
+
"git:clean:*",
|
|
41551
|
+
"git:rm",
|
|
41439
41552
|
"git:rm:*",
|
|
41440
41553
|
"git:commit",
|
|
41554
|
+
"git:commit:*",
|
|
41441
41555
|
"git:merge",
|
|
41556
|
+
"git:merge:*",
|
|
41442
41557
|
"git:rebase",
|
|
41558
|
+
"git:rebase:*",
|
|
41443
41559
|
"git:cherry-pick",
|
|
41560
|
+
"git:cherry-pick:*",
|
|
41444
41561
|
"git:stash:drop",
|
|
41562
|
+
"git:stash:drop:*",
|
|
41563
|
+
"git:stash:pop",
|
|
41564
|
+
"git:stash:pop:*",
|
|
41565
|
+
"git:stash:push",
|
|
41566
|
+
"git:stash:push:*",
|
|
41567
|
+
"git:stash:clear",
|
|
41568
|
+
"git:branch:-d",
|
|
41569
|
+
"git:branch:-d:*",
|
|
41570
|
+
"git:branch:-D",
|
|
41571
|
+
"git:branch:-D:*",
|
|
41572
|
+
"git:branch:--delete",
|
|
41573
|
+
"git:branch:--delete:*",
|
|
41574
|
+
"git:tag:-d",
|
|
41575
|
+
"git:tag:-d:*",
|
|
41576
|
+
"git:tag:--delete",
|
|
41577
|
+
"git:tag:--delete:*",
|
|
41578
|
+
"git:remote:remove",
|
|
41579
|
+
"git:remote:remove:*",
|
|
41580
|
+
"git:remote:rm",
|
|
41581
|
+
"git:remote:rm:*",
|
|
41582
|
+
"git:checkout:--force",
|
|
41583
|
+
"git:checkout:--force:*",
|
|
41584
|
+
"git:checkout:-f",
|
|
41585
|
+
"git:checkout:-f:*",
|
|
41586
|
+
"git:submodule:deinit",
|
|
41587
|
+
"git:submodule:deinit:*",
|
|
41588
|
+
"git:notes:add",
|
|
41589
|
+
"git:notes:add:*",
|
|
41590
|
+
"git:notes:remove",
|
|
41591
|
+
"git:notes:remove:*",
|
|
41592
|
+
"git:worktree:add",
|
|
41593
|
+
"git:worktree:add:*",
|
|
41594
|
+
"git:worktree:remove",
|
|
41595
|
+
"git:worktree:remove:*",
|
|
41596
|
+
// Dangerous GitHub CLI (gh) write operations
|
|
41597
|
+
"gh:issue:create",
|
|
41598
|
+
"gh:issue:create:*",
|
|
41599
|
+
"gh:issue:close",
|
|
41600
|
+
"gh:issue:close:*",
|
|
41601
|
+
"gh:issue:delete",
|
|
41602
|
+
"gh:issue:delete:*",
|
|
41603
|
+
"gh:issue:edit",
|
|
41604
|
+
"gh:issue:edit:*",
|
|
41605
|
+
"gh:issue:reopen",
|
|
41606
|
+
"gh:issue:reopen:*",
|
|
41607
|
+
"gh:issue:comment",
|
|
41608
|
+
"gh:issue:comment:*",
|
|
41609
|
+
"gh:pr:create",
|
|
41610
|
+
"gh:pr:create:*",
|
|
41611
|
+
"gh:pr:close",
|
|
41612
|
+
"gh:pr:close:*",
|
|
41613
|
+
"gh:pr:merge",
|
|
41614
|
+
"gh:pr:merge:*",
|
|
41615
|
+
"gh:pr:edit",
|
|
41616
|
+
"gh:pr:edit:*",
|
|
41617
|
+
"gh:pr:reopen",
|
|
41618
|
+
"gh:pr:reopen:*",
|
|
41619
|
+
"gh:pr:review",
|
|
41620
|
+
"gh:pr:review:*",
|
|
41621
|
+
"gh:pr:comment",
|
|
41622
|
+
"gh:pr:comment:*",
|
|
41623
|
+
"gh:repo:create",
|
|
41624
|
+
"gh:repo:create:*",
|
|
41625
|
+
"gh:repo:delete",
|
|
41626
|
+
"gh:repo:delete:*",
|
|
41627
|
+
"gh:repo:fork",
|
|
41628
|
+
"gh:repo:fork:*",
|
|
41629
|
+
"gh:repo:rename",
|
|
41630
|
+
"gh:repo:rename:*",
|
|
41631
|
+
"gh:repo:archive",
|
|
41632
|
+
"gh:repo:archive:*",
|
|
41633
|
+
"gh:repo:clone",
|
|
41634
|
+
"gh:repo:clone:*",
|
|
41635
|
+
"gh:release:create",
|
|
41636
|
+
"gh:release:create:*",
|
|
41637
|
+
"gh:release:delete",
|
|
41638
|
+
"gh:release:delete:*",
|
|
41639
|
+
"gh:release:edit",
|
|
41640
|
+
"gh:release:edit:*",
|
|
41641
|
+
"gh:run:cancel",
|
|
41642
|
+
"gh:run:cancel:*",
|
|
41643
|
+
"gh:run:rerun",
|
|
41644
|
+
"gh:run:rerun:*",
|
|
41645
|
+
"gh:workflow:run",
|
|
41646
|
+
"gh:workflow:run:*",
|
|
41647
|
+
"gh:workflow:enable",
|
|
41648
|
+
"gh:workflow:enable:*",
|
|
41649
|
+
"gh:workflow:disable",
|
|
41650
|
+
"gh:workflow:disable:*",
|
|
41651
|
+
"gh:gist:create",
|
|
41652
|
+
"gh:gist:create:*",
|
|
41653
|
+
"gh:gist:delete",
|
|
41654
|
+
"gh:gist:delete:*",
|
|
41655
|
+
"gh:gist:edit",
|
|
41656
|
+
"gh:gist:edit:*",
|
|
41657
|
+
"gh:secret:set",
|
|
41658
|
+
"gh:secret:set:*",
|
|
41659
|
+
"gh:secret:delete",
|
|
41660
|
+
"gh:secret:delete:*",
|
|
41661
|
+
"gh:variable:set",
|
|
41662
|
+
"gh:variable:set:*",
|
|
41663
|
+
"gh:variable:delete",
|
|
41664
|
+
"gh:variable:delete:*",
|
|
41665
|
+
"gh:label:create",
|
|
41666
|
+
"gh:label:create:*",
|
|
41667
|
+
"gh:label:delete",
|
|
41668
|
+
"gh:label:delete:*",
|
|
41669
|
+
"gh:ssh-key:add",
|
|
41670
|
+
"gh:ssh-key:add:*",
|
|
41671
|
+
"gh:ssh-key:delete",
|
|
41672
|
+
"gh:ssh-key:delete:*",
|
|
41445
41673
|
// File system mounting and partitioning
|
|
41446
41674
|
"mount",
|
|
41447
41675
|
"mount:*",
|
|
@@ -98623,6 +98851,7 @@ __export(schemaUtils_exports, {
|
|
|
98623
98851
|
replaceMermaidDiagramsInMarkdown: () => replaceMermaidDiagramsInMarkdown,
|
|
98624
98852
|
sanitizeMarkdownEscapesInJson: () => sanitizeMarkdownEscapesInJson,
|
|
98625
98853
|
tryAutoWrapForSimpleSchema: () => tryAutoWrapForSimpleSchema,
|
|
98854
|
+
tryExtractValidJsonPrefix: () => tryExtractValidJsonPrefix,
|
|
98626
98855
|
tryMaidAutoFix: () => tryMaidAutoFix,
|
|
98627
98856
|
validateAndFixMermaidResponse: () => validateAndFixMermaidResponse,
|
|
98628
98857
|
validateJsonResponse: () => validateJsonResponse,
|
|
@@ -99009,6 +99238,13 @@ function validateJsonResponse(response, options = {}) {
|
|
|
99009
99238
|
errorPosition = response.indexOf(problematicToken);
|
|
99010
99239
|
}
|
|
99011
99240
|
}
|
|
99241
|
+
const prefixResult = tryExtractValidJsonPrefix(responseToValidate, { schema, debug });
|
|
99242
|
+
if (prefixResult && prefixResult.isValid) {
|
|
99243
|
+
if (debug) {
|
|
99244
|
+
console.log(`[DEBUG] JSON validation: Recovered valid JSON prefix (${prefixResult.extracted.length} chars) from response with trailing content`);
|
|
99245
|
+
}
|
|
99246
|
+
return { isValid: true, parsed: prefixResult.parsed };
|
|
99247
|
+
}
|
|
99012
99248
|
let enhancedError = error2.message;
|
|
99013
99249
|
let errorContext = null;
|
|
99014
99250
|
if (errorPosition !== null && errorPosition >= 0 && response && response.length > 0) {
|
|
@@ -99059,6 +99295,84 @@ ${errorContext.pointer}`);
|
|
|
99059
99295
|
};
|
|
99060
99296
|
}
|
|
99061
99297
|
}
|
|
99298
|
+
function tryExtractValidJsonPrefix(response, options = {}) {
|
|
99299
|
+
const { schema = null, debug = false } = options;
|
|
99300
|
+
if (!response || typeof response !== "string") {
|
|
99301
|
+
return null;
|
|
99302
|
+
}
|
|
99303
|
+
const trimmed = response.trim();
|
|
99304
|
+
if (trimmed.length === 0) {
|
|
99305
|
+
return null;
|
|
99306
|
+
}
|
|
99307
|
+
const firstChar = trimmed[0];
|
|
99308
|
+
if (firstChar !== "{" && firstChar !== "[") {
|
|
99309
|
+
return null;
|
|
99310
|
+
}
|
|
99311
|
+
try {
|
|
99312
|
+
JSON.parse(trimmed);
|
|
99313
|
+
return null;
|
|
99314
|
+
} catch {
|
|
99315
|
+
}
|
|
99316
|
+
const openChar = firstChar;
|
|
99317
|
+
const closeChar = openChar === "{" ? "}" : "]";
|
|
99318
|
+
let depth = 0;
|
|
99319
|
+
let inString = false;
|
|
99320
|
+
let escapeNext = false;
|
|
99321
|
+
let endPos = -1;
|
|
99322
|
+
for (let i5 = 0; i5 < trimmed.length; i5++) {
|
|
99323
|
+
const char = trimmed[i5];
|
|
99324
|
+
if (escapeNext) {
|
|
99325
|
+
escapeNext = false;
|
|
99326
|
+
continue;
|
|
99327
|
+
}
|
|
99328
|
+
if (char === "\\" && inString) {
|
|
99329
|
+
escapeNext = true;
|
|
99330
|
+
continue;
|
|
99331
|
+
}
|
|
99332
|
+
if (char === '"') {
|
|
99333
|
+
inString = !inString;
|
|
99334
|
+
continue;
|
|
99335
|
+
}
|
|
99336
|
+
if (inString) {
|
|
99337
|
+
continue;
|
|
99338
|
+
}
|
|
99339
|
+
if (char === openChar) {
|
|
99340
|
+
depth++;
|
|
99341
|
+
} else if (char === closeChar) {
|
|
99342
|
+
depth--;
|
|
99343
|
+
if (depth === 0) {
|
|
99344
|
+
endPos = i5 + 1;
|
|
99345
|
+
break;
|
|
99346
|
+
}
|
|
99347
|
+
}
|
|
99348
|
+
}
|
|
99349
|
+
if (endPos <= 0 || endPos >= trimmed.length) {
|
|
99350
|
+
return null;
|
|
99351
|
+
}
|
|
99352
|
+
const remainder = trimmed.substring(endPos).trim();
|
|
99353
|
+
if (remainder.length === 0) {
|
|
99354
|
+
return null;
|
|
99355
|
+
}
|
|
99356
|
+
const prefix = trimmed.substring(0, endPos);
|
|
99357
|
+
try {
|
|
99358
|
+
const parsed = JSON.parse(prefix);
|
|
99359
|
+
if (debug) {
|
|
99360
|
+
console.log(`[DEBUG] tryExtractValidJsonPrefix: Extracted valid JSON prefix (${prefix.length} chars), stripped trailing content (${remainder.length} chars)`);
|
|
99361
|
+
}
|
|
99362
|
+
if (schema) {
|
|
99363
|
+
const schemaValidation = validateJsonResponse(prefix, { debug, schema });
|
|
99364
|
+
if (!schemaValidation.isValid) {
|
|
99365
|
+
if (debug) {
|
|
99366
|
+
console.log(`[DEBUG] tryExtractValidJsonPrefix: Prefix is valid JSON but fails schema validation: ${schemaValidation.error}`);
|
|
99367
|
+
}
|
|
99368
|
+
return null;
|
|
99369
|
+
}
|
|
99370
|
+
}
|
|
99371
|
+
return { isValid: true, parsed, extracted: prefix };
|
|
99372
|
+
} catch {
|
|
99373
|
+
return null;
|
|
99374
|
+
}
|
|
99375
|
+
}
|
|
99062
99376
|
function validateXmlResponse(response) {
|
|
99063
99377
|
const xmlPattern = /<\/?[\w\s="'.-]+>/g;
|
|
99064
99378
|
const tags = response.match(xmlPattern);
|
|
@@ -101160,7 +101474,7 @@ function parseXmlMcpToolCall(xmlString, mcpToolNames = []) {
|
|
|
101160
101474
|
let match2;
|
|
101161
101475
|
while ((match2 = paramPattern.exec(content)) !== null) {
|
|
101162
101476
|
const [, paramName, paramValue] = match2;
|
|
101163
|
-
params[paramName] = paramValue.trim();
|
|
101477
|
+
params[paramName] = unescapeXmlEntities(paramValue.trim());
|
|
101164
101478
|
}
|
|
101165
101479
|
}
|
|
101166
101480
|
return { toolName, params };
|
|
@@ -101210,7 +101524,7 @@ function parseNativeXmlTool(xmlString, toolName) {
|
|
|
101210
101524
|
while ((match2 = paramPattern.exec(content)) !== null) {
|
|
101211
101525
|
const [, paramName, paramValue] = match2;
|
|
101212
101526
|
if (paramName !== "params") {
|
|
101213
|
-
params[paramName] = paramValue.trim();
|
|
101527
|
+
params[paramName] = unescapeXmlEntities(paramValue.trim());
|
|
101214
101528
|
}
|
|
101215
101529
|
}
|
|
101216
101530
|
if (Object.keys(params).length > 0) {
|
|
@@ -101225,6 +101539,7 @@ var init_xmlBridge = __esm({
|
|
|
101225
101539
|
init_client2();
|
|
101226
101540
|
init_config();
|
|
101227
101541
|
init_xmlParsingUtils();
|
|
101542
|
+
init_common2();
|
|
101228
101543
|
MCPXmlBridge = class {
|
|
101229
101544
|
constructor(options = {}) {
|
|
101230
101545
|
this.debug = options.debug || false;
|
|
@@ -113848,8 +114163,8 @@ You are working with a workspace. Available paths: ${workspaceDesc}
|
|
|
113848
114163
|
let currentIteration = 0;
|
|
113849
114164
|
let completionAttempted = false;
|
|
113850
114165
|
let finalResult = "I was unable to complete your request due to reaching the maximum number of tool iterations.";
|
|
113851
|
-
const baseMaxIterations = this.maxIterations || MAX_TOOL_ITERATIONS;
|
|
113852
|
-
const maxIterations = options.schema ? baseMaxIterations + 4 : baseMaxIterations;
|
|
114166
|
+
const baseMaxIterations = options._maxIterationsOverride || this.maxIterations || MAX_TOOL_ITERATIONS;
|
|
114167
|
+
const maxIterations = options._maxIterationsOverride ? baseMaxIterations : options.schema ? baseMaxIterations + 4 : baseMaxIterations;
|
|
113853
114168
|
const isClaudeCode = this.clientApiProvider === "claude-code" || process.env.USE_CLAUDE_CODE === "true";
|
|
113854
114169
|
const isCodex = this.clientApiProvider === "codex" || process.env.USE_CODEX === "true";
|
|
113855
114170
|
if (isClaudeCode) {
|
|
@@ -115086,13 +115401,16 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
115086
115401
|
options.schema,
|
|
115087
115402
|
0
|
|
115088
115403
|
);
|
|
115404
|
+
const { schema: _unusedSchema1, ...schemaDefCorrectionOptions } = options;
|
|
115089
115405
|
finalResult = await this.answer(schemaDefinitionPrompt, [], {
|
|
115090
|
-
...
|
|
115406
|
+
...schemaDefCorrectionOptions,
|
|
115091
115407
|
_schemaFormatted: true,
|
|
115092
115408
|
_skipValidation: true,
|
|
115093
115409
|
// Skip validation in recursive correction calls to prevent loops
|
|
115094
|
-
_completionPromptProcessed: true
|
|
115410
|
+
_completionPromptProcessed: true,
|
|
115095
115411
|
// Prevent cascading completion prompts in retry calls
|
|
115412
|
+
_maxIterationsOverride: 3
|
|
115413
|
+
// Correction should complete in 1-2 iterations (issue #447)
|
|
115096
115414
|
});
|
|
115097
115415
|
finalResult = cleanSchemaResponse(finalResult);
|
|
115098
115416
|
validation = validateJsonResponse(finalResult);
|
|
@@ -115140,15 +115458,18 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
115140
115458
|
retryCount
|
|
115141
115459
|
);
|
|
115142
115460
|
}
|
|
115461
|
+
const { schema: _unusedSchema2, ...correctionOptions } = options;
|
|
115143
115462
|
finalResult = await this.answer(correctionPrompt, [], {
|
|
115144
|
-
...
|
|
115463
|
+
...correctionOptions,
|
|
115145
115464
|
_schemaFormatted: true,
|
|
115146
115465
|
_skipValidation: true,
|
|
115147
115466
|
// Skip validation in recursive correction calls to prevent loops
|
|
115148
115467
|
_disableTools: true,
|
|
115149
115468
|
// Only allow attempt_completion - prevent AI from using search/query tools
|
|
115150
|
-
_completionPromptProcessed: true
|
|
115469
|
+
_completionPromptProcessed: true,
|
|
115151
115470
|
// Prevent cascading completion prompts in retry calls
|
|
115471
|
+
_maxIterationsOverride: 3
|
|
115472
|
+
// Correction should complete in 1-2 iterations (issue #447)
|
|
115152
115473
|
});
|
|
115153
115474
|
finalResult = cleanSchemaResponse(finalResult);
|
|
115154
115475
|
validation = validateJsonResponse(finalResult, { debug: this.debug });
|