@probelabs/probe 0.6.0-rc107 → 0.6.0-rc109
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/build/agent/index.js +92 -47
- package/build/agent/xmlParsingUtils.js +54 -2
- package/build/tools/common.js +30 -15
- package/cjs/agent/ProbeAgent.cjs +92 -47
- package/cjs/index.cjs +92 -47
- package/package.json +1 -9
- package/src/agent/xmlParsingUtils.js +54 -2
- package/src/tools/common.js +30 -15
package/build/agent/index.js
CHANGED
|
@@ -10242,9 +10242,10 @@ var init_ProtocolLib = __esm({
|
|
|
10242
10242
|
return { errorSchema, errorMetadata };
|
|
10243
10243
|
} catch (e3) {
|
|
10244
10244
|
dataObject.message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
|
10245
|
-
const
|
|
10245
|
+
const synthetic = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
|
|
10246
|
+
const baseExceptionSchema = synthetic.getBaseException();
|
|
10246
10247
|
if (baseExceptionSchema) {
|
|
10247
|
-
const ErrorCtor = baseExceptionSchema
|
|
10248
|
+
const ErrorCtor = synthetic.getErrorCtor(baseExceptionSchema) ?? Error;
|
|
10248
10249
|
throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
|
|
10249
10250
|
}
|
|
10250
10251
|
throw Object.assign(new Error(errorName), errorMetadata, dataObject);
|
|
@@ -10311,7 +10312,8 @@ var init_AwsSmithyRpcV2CborProtocol = __esm({
|
|
|
10311
10312
|
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata);
|
|
10312
10313
|
const ns = NormalizedSchema.of(errorSchema);
|
|
10313
10314
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
10314
|
-
const
|
|
10315
|
+
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
10316
|
+
const exception = new ErrorCtor(message);
|
|
10315
10317
|
const output = {};
|
|
10316
10318
|
for (const [name14, member] of ns.structIterator()) {
|
|
10317
10319
|
output[name14] = this.deserializer.readValue(member, dataObject[name14]);
|
|
@@ -11853,7 +11855,8 @@ var init_AwsJsonRpcProtocol = __esm({
|
|
|
11853
11855
|
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
|
11854
11856
|
const ns = NormalizedSchema.of(errorSchema);
|
|
11855
11857
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
11856
|
-
const
|
|
11858
|
+
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
11859
|
+
const exception = new ErrorCtor(message);
|
|
11857
11860
|
const output = {};
|
|
11858
11861
|
for (const [name14, member] of ns.structIterator()) {
|
|
11859
11862
|
const target = member.getMergedTraits().jsonName ?? name14;
|
|
@@ -11982,7 +11985,8 @@ var init_AwsRestJsonProtocol = __esm({
|
|
|
11982
11985
|
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
|
11983
11986
|
const ns = NormalizedSchema.of(errorSchema);
|
|
11984
11987
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
11985
|
-
const
|
|
11988
|
+
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
11989
|
+
const exception = new ErrorCtor(message);
|
|
11986
11990
|
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
11987
11991
|
const output = {};
|
|
11988
11992
|
for (const [name14, member] of ns.structIterator()) {
|
|
@@ -13394,7 +13398,8 @@ var init_AwsQueryProtocol = __esm({
|
|
|
13394
13398
|
};
|
|
13395
13399
|
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, (registry, errorName) => registry.find((schema) => NormalizedSchema.of(schema).getMergedTraits().awsQueryError?.[0] === errorName));
|
|
13396
13400
|
const ns = NormalizedSchema.of(errorSchema);
|
|
13397
|
-
const
|
|
13401
|
+
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
13402
|
+
const exception = new ErrorCtor(message);
|
|
13398
13403
|
const output = {
|
|
13399
13404
|
Error: errorData.Error
|
|
13400
13405
|
};
|
|
@@ -13856,7 +13861,8 @@ var init_AwsRestXmlProtocol = __esm({
|
|
|
13856
13861
|
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
|
13857
13862
|
const ns = NormalizedSchema.of(errorSchema);
|
|
13858
13863
|
const message = dataObject.Error?.message ?? dataObject.Error?.Message ?? dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
13859
|
-
const
|
|
13864
|
+
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
13865
|
+
const exception = new ErrorCtor(message);
|
|
13860
13866
|
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
13861
13867
|
const output = {};
|
|
13862
13868
|
for (const [name14, member] of ns.structIterator()) {
|
|
@@ -17807,7 +17813,7 @@ var require_package = __commonJS({
|
|
|
17807
17813
|
module.exports = {
|
|
17808
17814
|
name: "@aws-sdk/client-bedrock-runtime",
|
|
17809
17815
|
description: "AWS SDK for JavaScript Bedrock Runtime Client for Node.js, Browser and React Native",
|
|
17810
|
-
version: "3.
|
|
17816
|
+
version: "3.899.0",
|
|
17811
17817
|
scripts: {
|
|
17812
17818
|
build: "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
17813
17819
|
"build:cjs": "node ../../scripts/compilation/inline client-bedrock-runtime",
|
|
@@ -17826,23 +17832,23 @@ var require_package = __commonJS({
|
|
|
17826
17832
|
dependencies: {
|
|
17827
17833
|
"@aws-crypto/sha256-browser": "5.2.0",
|
|
17828
17834
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
17829
|
-
"@aws-sdk/core": "3.
|
|
17830
|
-
"@aws-sdk/credential-provider-node": "3.
|
|
17835
|
+
"@aws-sdk/core": "3.899.0",
|
|
17836
|
+
"@aws-sdk/credential-provider-node": "3.899.0",
|
|
17831
17837
|
"@aws-sdk/eventstream-handler-node": "3.893.0",
|
|
17832
17838
|
"@aws-sdk/middleware-eventstream": "3.893.0",
|
|
17833
17839
|
"@aws-sdk/middleware-host-header": "3.893.0",
|
|
17834
17840
|
"@aws-sdk/middleware-logger": "3.893.0",
|
|
17835
17841
|
"@aws-sdk/middleware-recursion-detection": "3.893.0",
|
|
17836
|
-
"@aws-sdk/middleware-user-agent": "3.
|
|
17842
|
+
"@aws-sdk/middleware-user-agent": "3.899.0",
|
|
17837
17843
|
"@aws-sdk/middleware-websocket": "3.893.0",
|
|
17838
17844
|
"@aws-sdk/region-config-resolver": "3.893.0",
|
|
17839
|
-
"@aws-sdk/token-providers": "3.
|
|
17845
|
+
"@aws-sdk/token-providers": "3.899.0",
|
|
17840
17846
|
"@aws-sdk/types": "3.893.0",
|
|
17841
17847
|
"@aws-sdk/util-endpoints": "3.895.0",
|
|
17842
17848
|
"@aws-sdk/util-user-agent-browser": "3.893.0",
|
|
17843
|
-
"@aws-sdk/util-user-agent-node": "3.
|
|
17849
|
+
"@aws-sdk/util-user-agent-node": "3.899.0",
|
|
17844
17850
|
"@smithy/config-resolver": "^4.2.2",
|
|
17845
|
-
"@smithy/core": "^3.
|
|
17851
|
+
"@smithy/core": "^3.13.0",
|
|
17846
17852
|
"@smithy/eventstream-serde-browser": "^4.1.1",
|
|
17847
17853
|
"@smithy/eventstream-serde-config-resolver": "^4.2.1",
|
|
17848
17854
|
"@smithy/eventstream-serde-node": "^4.1.1",
|
|
@@ -17850,21 +17856,21 @@ var require_package = __commonJS({
|
|
|
17850
17856
|
"@smithy/hash-node": "^4.1.1",
|
|
17851
17857
|
"@smithy/invalid-dependency": "^4.1.1",
|
|
17852
17858
|
"@smithy/middleware-content-length": "^4.1.1",
|
|
17853
|
-
"@smithy/middleware-endpoint": "^4.2.
|
|
17854
|
-
"@smithy/middleware-retry": "^4.3.
|
|
17859
|
+
"@smithy/middleware-endpoint": "^4.2.5",
|
|
17860
|
+
"@smithy/middleware-retry": "^4.3.1",
|
|
17855
17861
|
"@smithy/middleware-serde": "^4.1.1",
|
|
17856
17862
|
"@smithy/middleware-stack": "^4.1.1",
|
|
17857
17863
|
"@smithy/node-config-provider": "^4.2.2",
|
|
17858
17864
|
"@smithy/node-http-handler": "^4.2.1",
|
|
17859
17865
|
"@smithy/protocol-http": "^5.2.1",
|
|
17860
|
-
"@smithy/smithy-client": "^4.6.
|
|
17866
|
+
"@smithy/smithy-client": "^4.6.5",
|
|
17861
17867
|
"@smithy/types": "^4.5.0",
|
|
17862
17868
|
"@smithy/url-parser": "^4.1.1",
|
|
17863
17869
|
"@smithy/util-base64": "^4.1.0",
|
|
17864
17870
|
"@smithy/util-body-length-browser": "^4.1.0",
|
|
17865
17871
|
"@smithy/util-body-length-node": "^4.1.0",
|
|
17866
|
-
"@smithy/util-defaults-mode-browser": "^4.1.
|
|
17867
|
-
"@smithy/util-defaults-mode-node": "^4.1.
|
|
17872
|
+
"@smithy/util-defaults-mode-browser": "^4.1.5",
|
|
17873
|
+
"@smithy/util-defaults-mode-node": "^4.1.5",
|
|
17868
17874
|
"@smithy/util-endpoints": "^3.1.2",
|
|
17869
17875
|
"@smithy/util-middleware": "^4.1.1",
|
|
17870
17876
|
"@smithy/util-retry": "^4.1.2",
|
|
@@ -18656,7 +18662,7 @@ var require_package2 = __commonJS({
|
|
|
18656
18662
|
module.exports = {
|
|
18657
18663
|
name: "@aws-sdk/client-sso",
|
|
18658
18664
|
description: "AWS SDK for JavaScript Sso Client for Node.js, Browser and React Native",
|
|
18659
|
-
version: "3.
|
|
18665
|
+
version: "3.899.0",
|
|
18660
18666
|
scripts: {
|
|
18661
18667
|
build: "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
18662
18668
|
"build:cjs": "node ../../scripts/compilation/inline client-sso",
|
|
@@ -18675,37 +18681,37 @@ var require_package2 = __commonJS({
|
|
|
18675
18681
|
dependencies: {
|
|
18676
18682
|
"@aws-crypto/sha256-browser": "5.2.0",
|
|
18677
18683
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
18678
|
-
"@aws-sdk/core": "3.
|
|
18684
|
+
"@aws-sdk/core": "3.899.0",
|
|
18679
18685
|
"@aws-sdk/middleware-host-header": "3.893.0",
|
|
18680
18686
|
"@aws-sdk/middleware-logger": "3.893.0",
|
|
18681
18687
|
"@aws-sdk/middleware-recursion-detection": "3.893.0",
|
|
18682
|
-
"@aws-sdk/middleware-user-agent": "3.
|
|
18688
|
+
"@aws-sdk/middleware-user-agent": "3.899.0",
|
|
18683
18689
|
"@aws-sdk/region-config-resolver": "3.893.0",
|
|
18684
18690
|
"@aws-sdk/types": "3.893.0",
|
|
18685
18691
|
"@aws-sdk/util-endpoints": "3.895.0",
|
|
18686
18692
|
"@aws-sdk/util-user-agent-browser": "3.893.0",
|
|
18687
|
-
"@aws-sdk/util-user-agent-node": "3.
|
|
18693
|
+
"@aws-sdk/util-user-agent-node": "3.899.0",
|
|
18688
18694
|
"@smithy/config-resolver": "^4.2.2",
|
|
18689
|
-
"@smithy/core": "^3.
|
|
18695
|
+
"@smithy/core": "^3.13.0",
|
|
18690
18696
|
"@smithy/fetch-http-handler": "^5.2.1",
|
|
18691
18697
|
"@smithy/hash-node": "^4.1.1",
|
|
18692
18698
|
"@smithy/invalid-dependency": "^4.1.1",
|
|
18693
18699
|
"@smithy/middleware-content-length": "^4.1.1",
|
|
18694
|
-
"@smithy/middleware-endpoint": "^4.2.
|
|
18695
|
-
"@smithy/middleware-retry": "^4.3.
|
|
18700
|
+
"@smithy/middleware-endpoint": "^4.2.5",
|
|
18701
|
+
"@smithy/middleware-retry": "^4.3.1",
|
|
18696
18702
|
"@smithy/middleware-serde": "^4.1.1",
|
|
18697
18703
|
"@smithy/middleware-stack": "^4.1.1",
|
|
18698
18704
|
"@smithy/node-config-provider": "^4.2.2",
|
|
18699
18705
|
"@smithy/node-http-handler": "^4.2.1",
|
|
18700
18706
|
"@smithy/protocol-http": "^5.2.1",
|
|
18701
|
-
"@smithy/smithy-client": "^4.6.
|
|
18707
|
+
"@smithy/smithy-client": "^4.6.5",
|
|
18702
18708
|
"@smithy/types": "^4.5.0",
|
|
18703
18709
|
"@smithy/url-parser": "^4.1.1",
|
|
18704
18710
|
"@smithy/util-base64": "^4.1.0",
|
|
18705
18711
|
"@smithy/util-body-length-browser": "^4.1.0",
|
|
18706
18712
|
"@smithy/util-body-length-node": "^4.1.0",
|
|
18707
|
-
"@smithy/util-defaults-mode-browser": "^4.1.
|
|
18708
|
-
"@smithy/util-defaults-mode-node": "^4.1.
|
|
18713
|
+
"@smithy/util-defaults-mode-browser": "^4.1.5",
|
|
18714
|
+
"@smithy/util-defaults-mode-node": "^4.1.5",
|
|
18709
18715
|
"@smithy/util-endpoints": "^3.1.2",
|
|
18710
18716
|
"@smithy/util-middleware": "^4.1.1",
|
|
18711
18717
|
"@smithy/util-retry": "^4.1.2",
|
|
@@ -19937,7 +19943,7 @@ var init_package = __esm({
|
|
|
19937
19943
|
"node_modules/@aws-sdk/nested-clients/package.json"() {
|
|
19938
19944
|
package_default = {
|
|
19939
19945
|
name: "@aws-sdk/nested-clients",
|
|
19940
|
-
version: "3.
|
|
19946
|
+
version: "3.899.0",
|
|
19941
19947
|
description: "Nested clients for AWS SDK packages.",
|
|
19942
19948
|
main: "./dist-cjs/index.js",
|
|
19943
19949
|
module: "./dist-es/index.js",
|
|
@@ -19966,37 +19972,37 @@ var init_package = __esm({
|
|
|
19966
19972
|
dependencies: {
|
|
19967
19973
|
"@aws-crypto/sha256-browser": "5.2.0",
|
|
19968
19974
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
19969
|
-
"@aws-sdk/core": "3.
|
|
19975
|
+
"@aws-sdk/core": "3.899.0",
|
|
19970
19976
|
"@aws-sdk/middleware-host-header": "3.893.0",
|
|
19971
19977
|
"@aws-sdk/middleware-logger": "3.893.0",
|
|
19972
19978
|
"@aws-sdk/middleware-recursion-detection": "3.893.0",
|
|
19973
|
-
"@aws-sdk/middleware-user-agent": "3.
|
|
19979
|
+
"@aws-sdk/middleware-user-agent": "3.899.0",
|
|
19974
19980
|
"@aws-sdk/region-config-resolver": "3.893.0",
|
|
19975
19981
|
"@aws-sdk/types": "3.893.0",
|
|
19976
19982
|
"@aws-sdk/util-endpoints": "3.895.0",
|
|
19977
19983
|
"@aws-sdk/util-user-agent-browser": "3.893.0",
|
|
19978
|
-
"@aws-sdk/util-user-agent-node": "3.
|
|
19984
|
+
"@aws-sdk/util-user-agent-node": "3.899.0",
|
|
19979
19985
|
"@smithy/config-resolver": "^4.2.2",
|
|
19980
|
-
"@smithy/core": "^3.
|
|
19986
|
+
"@smithy/core": "^3.13.0",
|
|
19981
19987
|
"@smithy/fetch-http-handler": "^5.2.1",
|
|
19982
19988
|
"@smithy/hash-node": "^4.1.1",
|
|
19983
19989
|
"@smithy/invalid-dependency": "^4.1.1",
|
|
19984
19990
|
"@smithy/middleware-content-length": "^4.1.1",
|
|
19985
|
-
"@smithy/middleware-endpoint": "^4.2.
|
|
19986
|
-
"@smithy/middleware-retry": "^4.3.
|
|
19991
|
+
"@smithy/middleware-endpoint": "^4.2.5",
|
|
19992
|
+
"@smithy/middleware-retry": "^4.3.1",
|
|
19987
19993
|
"@smithy/middleware-serde": "^4.1.1",
|
|
19988
19994
|
"@smithy/middleware-stack": "^4.1.1",
|
|
19989
19995
|
"@smithy/node-config-provider": "^4.2.2",
|
|
19990
19996
|
"@smithy/node-http-handler": "^4.2.1",
|
|
19991
19997
|
"@smithy/protocol-http": "^5.2.1",
|
|
19992
|
-
"@smithy/smithy-client": "^4.6.
|
|
19998
|
+
"@smithy/smithy-client": "^4.6.5",
|
|
19993
19999
|
"@smithy/types": "^4.5.0",
|
|
19994
20000
|
"@smithy/url-parser": "^4.1.1",
|
|
19995
20001
|
"@smithy/util-base64": "^4.1.0",
|
|
19996
20002
|
"@smithy/util-body-length-browser": "^4.1.0",
|
|
19997
20003
|
"@smithy/util-body-length-node": "^4.1.0",
|
|
19998
|
-
"@smithy/util-defaults-mode-browser": "^4.1.
|
|
19999
|
-
"@smithy/util-defaults-mode-node": "^4.1.
|
|
20004
|
+
"@smithy/util-defaults-mode-browser": "^4.1.5",
|
|
20005
|
+
"@smithy/util-defaults-mode-node": "^4.1.5",
|
|
20000
20006
|
"@smithy/util-endpoints": "^3.1.2",
|
|
20001
20007
|
"@smithy/util-middleware": "^4.1.1",
|
|
20002
20008
|
"@smithy/util-retry": "^4.1.2",
|
|
@@ -24466,6 +24472,7 @@ var require_dist_cjs65 = __commonJS({
|
|
|
24466
24472
|
END_TURN: "end_turn",
|
|
24467
24473
|
GUARDRAIL_INTERVENED: "guardrail_intervened",
|
|
24468
24474
|
MAX_TOKENS: "max_tokens",
|
|
24475
|
+
MODEL_CONTEXT_WINDOW_EXCEEDED: "model_context_window_exceeded",
|
|
24469
24476
|
STOP_SEQUENCE: "stop_sequence",
|
|
24470
24477
|
TOOL_USE: "tool_use"
|
|
24471
24478
|
};
|
|
@@ -25395,6 +25402,9 @@ var require_dist_cjs65 = __commonJS({
|
|
|
25395
25402
|
case "ServiceQuotaExceededException":
|
|
25396
25403
|
case "com.amazonaws.bedrockruntime#ServiceQuotaExceededException":
|
|
25397
25404
|
throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context);
|
|
25405
|
+
case "ServiceUnavailableException":
|
|
25406
|
+
case "com.amazonaws.bedrockruntime#ServiceUnavailableException":
|
|
25407
|
+
throw await de_ServiceUnavailableExceptionRes(parsedOutput, context);
|
|
25398
25408
|
case "ThrottlingException":
|
|
25399
25409
|
case "com.amazonaws.bedrockruntime#ThrottlingException":
|
|
25400
25410
|
throw await de_ThrottlingExceptionRes(parsedOutput, context);
|
|
@@ -25410,9 +25420,6 @@ var require_dist_cjs65 = __commonJS({
|
|
|
25410
25420
|
case "ModelTimeoutException":
|
|
25411
25421
|
case "com.amazonaws.bedrockruntime#ModelTimeoutException":
|
|
25412
25422
|
throw await de_ModelTimeoutExceptionRes(parsedOutput, context);
|
|
25413
|
-
case "ServiceUnavailableException":
|
|
25414
|
-
case "com.amazonaws.bedrockruntime#ServiceUnavailableException":
|
|
25415
|
-
throw await de_ServiceUnavailableExceptionRes(parsedOutput, context);
|
|
25416
25423
|
case "ModelStreamErrorException":
|
|
25417
25424
|
case "com.amazonaws.bedrockruntime#ModelStreamErrorException":
|
|
25418
25425
|
throw await de_ModelStreamErrorExceptionRes(parsedOutput, context);
|
|
@@ -28864,9 +28871,10 @@ function parseXmlToolCall(xmlString, validTools = DEFAULT_VALID_TOOLS) {
|
|
|
28864
28871
|
if (openIndex === -1) {
|
|
28865
28872
|
continue;
|
|
28866
28873
|
}
|
|
28867
|
-
|
|
28874
|
+
let closeIndex = xmlString.indexOf(closeTag, openIndex + openTag.length);
|
|
28875
|
+
let hasClosingTag = closeIndex !== -1;
|
|
28868
28876
|
if (closeIndex === -1) {
|
|
28869
|
-
|
|
28877
|
+
closeIndex = xmlString.length;
|
|
28870
28878
|
}
|
|
28871
28879
|
const innerContent = xmlString.substring(
|
|
28872
28880
|
openIndex + openTag.length,
|
|
@@ -28908,9 +28916,17 @@ function parseXmlToolCall(xmlString, validTools = DEFAULT_VALID_TOOLS) {
|
|
|
28908
28916
|
if (paramOpenIndex === -1) {
|
|
28909
28917
|
continue;
|
|
28910
28918
|
}
|
|
28911
|
-
|
|
28919
|
+
let paramCloseIndex = innerContent.indexOf(paramCloseTag, paramOpenIndex + paramOpenTag.length);
|
|
28912
28920
|
if (paramCloseIndex === -1) {
|
|
28913
|
-
|
|
28921
|
+
let nextTagIndex = innerContent.length;
|
|
28922
|
+
for (const nextParam of commonParams3) {
|
|
28923
|
+
const nextOpenTag = `<${nextParam}>`;
|
|
28924
|
+
const nextIndex = innerContent.indexOf(nextOpenTag, paramOpenIndex + paramOpenTag.length);
|
|
28925
|
+
if (nextIndex !== -1 && nextIndex < nextTagIndex) {
|
|
28926
|
+
nextTagIndex = nextIndex;
|
|
28927
|
+
}
|
|
28928
|
+
}
|
|
28929
|
+
paramCloseIndex = nextTagIndex;
|
|
28914
28930
|
}
|
|
28915
28931
|
let paramValue = innerContent.substring(
|
|
28916
28932
|
paramOpenIndex + paramOpenTag.length,
|
|
@@ -31344,13 +31360,42 @@ var init_index = __esm({
|
|
|
31344
31360
|
|
|
31345
31361
|
// src/agent/xmlParsingUtils.js
|
|
31346
31362
|
function removeThinkingTags(xmlString) {
|
|
31347
|
-
|
|
31363
|
+
let result = xmlString;
|
|
31364
|
+
result = result.replace(/<thinking>[\s\S]*?<\/thinking>/g, "");
|
|
31365
|
+
const thinkingIndex = result.indexOf("<thinking>");
|
|
31366
|
+
if (thinkingIndex !== -1) {
|
|
31367
|
+
const afterThinking = result.substring(thinkingIndex + "<thinking>".length);
|
|
31368
|
+
const toolPattern = /<(search|query|extract|listFiles|searchFiles|implement|attempt_completion|attempt_complete)>/;
|
|
31369
|
+
const toolMatch = afterThinking.match(toolPattern);
|
|
31370
|
+
if (toolMatch) {
|
|
31371
|
+
const toolStart = thinkingIndex + "<thinking>".length + toolMatch.index;
|
|
31372
|
+
result = result.substring(0, thinkingIndex) + result.substring(toolStart);
|
|
31373
|
+
} else {
|
|
31374
|
+
result = result.substring(0, thinkingIndex);
|
|
31375
|
+
}
|
|
31376
|
+
}
|
|
31377
|
+
return result.trim();
|
|
31348
31378
|
}
|
|
31349
31379
|
function extractThinkingContent(xmlString) {
|
|
31350
31380
|
const thinkingMatch = xmlString.match(/<thinking>([\s\S]*?)<\/thinking>/);
|
|
31351
31381
|
return thinkingMatch ? thinkingMatch[1].trim() : null;
|
|
31352
31382
|
}
|
|
31353
31383
|
function checkAttemptCompleteRecovery(cleanedXmlString, validTools = []) {
|
|
31384
|
+
const attemptCompletionMatch = cleanedXmlString.match(/<attempt_completion>([\s\S]*?)(?:<\/attempt_completion>|$)/);
|
|
31385
|
+
if (attemptCompletionMatch) {
|
|
31386
|
+
const content = attemptCompletionMatch[1].trim();
|
|
31387
|
+
const hasClosingTag = cleanedXmlString.includes("</attempt_completion>");
|
|
31388
|
+
if (content) {
|
|
31389
|
+
return {
|
|
31390
|
+
toolName: "attempt_completion",
|
|
31391
|
+
params: { result: content }
|
|
31392
|
+
};
|
|
31393
|
+
}
|
|
31394
|
+
return {
|
|
31395
|
+
toolName: "attempt_completion",
|
|
31396
|
+
params: { result: hasClosingTag ? "" : "__PREVIOUS_RESPONSE__" }
|
|
31397
|
+
};
|
|
31398
|
+
}
|
|
31354
31399
|
const attemptCompletePatterns = [
|
|
31355
31400
|
// Standard shorthand with optional whitespace
|
|
31356
31401
|
/^<attempt_complete>\s*$/,
|
|
@@ -5,11 +5,39 @@
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Remove thinking tags and their content from XML string
|
|
8
|
+
* Handles both closed and unclosed thinking tags
|
|
8
9
|
* @param {string} xmlString - The XML string to clean
|
|
9
10
|
* @returns {string} - Cleaned XML string without thinking tags
|
|
10
11
|
*/
|
|
11
12
|
export function removeThinkingTags(xmlString) {
|
|
12
|
-
|
|
13
|
+
let result = xmlString;
|
|
14
|
+
|
|
15
|
+
// Remove all properly closed thinking tags first
|
|
16
|
+
result = result.replace(/<thinking>[\s\S]*?<\/thinking>/g, '');
|
|
17
|
+
|
|
18
|
+
// Handle unclosed thinking tags
|
|
19
|
+
// Find any remaining <thinking> tag (which means it's unclosed)
|
|
20
|
+
const thinkingIndex = result.indexOf('<thinking>');
|
|
21
|
+
if (thinkingIndex !== -1) {
|
|
22
|
+
// Check if there's a tool tag after the thinking tag
|
|
23
|
+
// We want to preserve tool tags even if they're after unclosed thinking
|
|
24
|
+
const afterThinking = result.substring(thinkingIndex + '<thinking>'.length);
|
|
25
|
+
|
|
26
|
+
// Look for any tool tags in the remaining content
|
|
27
|
+
const toolPattern = /<(search|query|extract|listFiles|searchFiles|implement|attempt_completion|attempt_complete)>/;
|
|
28
|
+
const toolMatch = afterThinking.match(toolPattern);
|
|
29
|
+
|
|
30
|
+
if (toolMatch) {
|
|
31
|
+
// Found a tool tag - remove thinking tag and its content up to the tool tag
|
|
32
|
+
const toolStart = thinkingIndex + '<thinking>'.length + toolMatch.index;
|
|
33
|
+
result = result.substring(0, thinkingIndex) + result.substring(toolStart);
|
|
34
|
+
} else {
|
|
35
|
+
// No tool tag found - remove everything from <thinking> onwards
|
|
36
|
+
result = result.substring(0, thinkingIndex);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return result.trim();
|
|
13
41
|
}
|
|
14
42
|
|
|
15
43
|
/**
|
|
@@ -29,6 +57,30 @@ export function extractThinkingContent(xmlString) {
|
|
|
29
57
|
* @returns {Object|null} - Standardized attempt_completion result or null
|
|
30
58
|
*/
|
|
31
59
|
export function checkAttemptCompleteRecovery(cleanedXmlString, validTools = []) {
|
|
60
|
+
// Check for <attempt_completion> with content (with or without closing tag)
|
|
61
|
+
// This handles: "<attempt_completion>content" or "<attempt_completion>content</attempt_completion>"
|
|
62
|
+
const attemptCompletionMatch = cleanedXmlString.match(/<attempt_completion>([\s\S]*?)(?:<\/attempt_completion>|$)/);
|
|
63
|
+
if (attemptCompletionMatch) {
|
|
64
|
+
const content = attemptCompletionMatch[1].trim();
|
|
65
|
+
const hasClosingTag = cleanedXmlString.includes('</attempt_completion>');
|
|
66
|
+
|
|
67
|
+
if (content) {
|
|
68
|
+
// If there's content after the tag, use it as the result
|
|
69
|
+
return {
|
|
70
|
+
toolName: 'attempt_completion',
|
|
71
|
+
params: { result: content }
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// If the tag exists but is empty:
|
|
76
|
+
// - With closing tag (e.g., "<attempt_completion></attempt_completion>"): use empty string
|
|
77
|
+
// - Without closing tag (e.g., "<attempt_completion>"): use previous response
|
|
78
|
+
return {
|
|
79
|
+
toolName: 'attempt_completion',
|
|
80
|
+
params: { result: hasClosingTag ? '' : '__PREVIOUS_RESPONSE__' }
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
32
84
|
// Enhanced recovery logic for attempt_complete shorthand
|
|
33
85
|
const attemptCompletePatterns = [
|
|
34
86
|
// Standard shorthand with optional whitespace
|
|
@@ -61,7 +113,7 @@ export function checkAttemptCompleteRecovery(cleanedXmlString, validTools = [])
|
|
|
61
113
|
if (cleanedXmlString.includes('<attempt_complete') && !hasOtherToolTags(cleanedXmlString, validTools)) {
|
|
62
114
|
// This handles malformed cases where attempt_complete appears but is broken
|
|
63
115
|
return {
|
|
64
|
-
toolName: 'attempt_completion',
|
|
116
|
+
toolName: 'attempt_completion',
|
|
65
117
|
params: { result: '__PREVIOUS_RESPONSE__' }
|
|
66
118
|
};
|
|
67
119
|
}
|
package/build/tools/common.js
CHANGED
|
@@ -364,47 +364,62 @@ export function parseXmlToolCall(xmlString, validTools = DEFAULT_VALID_TOOLS) {
|
|
|
364
364
|
for (const toolName of validTools) {
|
|
365
365
|
const openTag = `<${toolName}>`;
|
|
366
366
|
const closeTag = `</${toolName}>`;
|
|
367
|
-
|
|
367
|
+
|
|
368
368
|
const openIndex = xmlString.indexOf(openTag);
|
|
369
369
|
if (openIndex === -1) {
|
|
370
370
|
continue; // Tool not found, try next tool
|
|
371
371
|
}
|
|
372
|
-
|
|
373
|
-
|
|
372
|
+
|
|
373
|
+
let closeIndex = xmlString.indexOf(closeTag, openIndex + openTag.length);
|
|
374
|
+
let hasClosingTag = closeIndex !== -1;
|
|
375
|
+
|
|
376
|
+
// If no closing tag found, use content until end of string
|
|
377
|
+
// This makes the parser more resilient to AI formatting errors
|
|
374
378
|
if (closeIndex === -1) {
|
|
375
|
-
|
|
379
|
+
closeIndex = xmlString.length;
|
|
376
380
|
}
|
|
377
|
-
|
|
378
|
-
// Extract the content between tags
|
|
381
|
+
|
|
382
|
+
// Extract the content between tags (or until end if no closing tag)
|
|
379
383
|
const innerContent = xmlString.substring(
|
|
380
|
-
openIndex + openTag.length,
|
|
384
|
+
openIndex + openTag.length,
|
|
381
385
|
closeIndex
|
|
382
386
|
);
|
|
383
|
-
|
|
387
|
+
|
|
384
388
|
const params = {};
|
|
385
389
|
|
|
386
390
|
// Parse parameters using string-based approach for better safety
|
|
387
391
|
// Common parameter names to look for (can be extended as needed)
|
|
388
392
|
// Note: includes both camelCase and underscore_case variants to handle inconsistencies
|
|
389
|
-
const commonParams = ['query', 'file_path', 'line', 'end_line', 'path', 'recursive', 'includeHidden',
|
|
393
|
+
const commonParams = ['query', 'file_path', 'line', 'end_line', 'path', 'recursive', 'includeHidden',
|
|
390
394
|
'max_results', 'maxResults', 'result', 'command', 'description', 'task', 'param', 'pattern',
|
|
391
395
|
'allow_tests', 'exact', 'maxTokens', 'language', 'input_content',
|
|
392
396
|
'context_lines', 'format', 'directory', 'autoCommits', 'files', 'targets'];
|
|
393
|
-
|
|
397
|
+
|
|
394
398
|
for (const paramName of commonParams) {
|
|
395
399
|
const paramOpenTag = `<${paramName}>`;
|
|
396
400
|
const paramCloseTag = `</${paramName}>`;
|
|
397
|
-
|
|
401
|
+
|
|
398
402
|
const paramOpenIndex = innerContent.indexOf(paramOpenTag);
|
|
399
403
|
if (paramOpenIndex === -1) {
|
|
400
404
|
continue; // Parameter not found
|
|
401
405
|
}
|
|
402
|
-
|
|
403
|
-
|
|
406
|
+
|
|
407
|
+
let paramCloseIndex = innerContent.indexOf(paramCloseTag, paramOpenIndex + paramOpenTag.length);
|
|
408
|
+
|
|
409
|
+
// Handle unclosed parameter tags - use content until next tag or end of content
|
|
404
410
|
if (paramCloseIndex === -1) {
|
|
405
|
-
|
|
411
|
+
// Find the next opening tag after this parameter
|
|
412
|
+
let nextTagIndex = innerContent.length;
|
|
413
|
+
for (const nextParam of commonParams) {
|
|
414
|
+
const nextOpenTag = `<${nextParam}>`;
|
|
415
|
+
const nextIndex = innerContent.indexOf(nextOpenTag, paramOpenIndex + paramOpenTag.length);
|
|
416
|
+
if (nextIndex !== -1 && nextIndex < nextTagIndex) {
|
|
417
|
+
nextTagIndex = nextIndex;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
paramCloseIndex = nextTagIndex;
|
|
406
421
|
}
|
|
407
|
-
|
|
422
|
+
|
|
408
423
|
let paramValue = innerContent.substring(
|
|
409
424
|
paramOpenIndex + paramOpenTag.length,
|
|
410
425
|
paramCloseIndex
|