@probelabs/probe 0.6.0-rc159 → 0.6.0-rc161
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/README.md +80 -1
- package/build/agent/FallbackManager.d.ts +176 -0
- package/build/agent/FallbackManager.js +545 -0
- package/build/agent/ProbeAgent.d.ts +7 -1
- package/build/agent/ProbeAgent.js +199 -7
- package/build/agent/RetryManager.d.ts +157 -0
- package/build/agent/RetryManager.js +334 -0
- package/build/agent/acp/tools.js +6 -2
- package/build/agent/index.js +1379 -168
- package/build/agent/probeTool.js +20 -2
- package/build/agent/tools.js +16 -0
- package/build/index.js +13 -0
- package/build/tools/common.js +5 -3
- package/build/tools/edit.js +409 -0
- package/build/tools/index.js +11 -0
- package/cjs/agent/ProbeAgent.cjs +1822 -497
- package/cjs/index.cjs +1784 -454
- package/package.json +2 -2
- package/src/agent/FallbackManager.d.ts +176 -0
- package/src/agent/FallbackManager.js +545 -0
- package/src/agent/ProbeAgent.d.ts +7 -1
- package/src/agent/ProbeAgent.js +199 -7
- package/src/agent/RetryManager.d.ts +157 -0
- package/src/agent/RetryManager.js +334 -0
- package/src/agent/acp/tools.js +6 -2
- package/src/agent/probeTool.js +20 -2
- package/src/agent/tools.js +16 -0
- package/src/index.js +13 -0
- package/src/tools/common.js +5 -3
- package/src/tools/edit.js +409 -0
- package/src/tools/index.js +11 -0
- package/bin/binaries/probe-v0.6.0-rc159-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc159-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc159-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc159-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc159-x86_64-unknown-linux-musl.tar.gz +0 -0
package/cjs/index.cjs
CHANGED
|
@@ -104,7 +104,7 @@ var require_package = __commonJS({
|
|
|
104
104
|
// node_modules/dotenv/lib/main.js
|
|
105
105
|
var require_main = __commonJS({
|
|
106
106
|
"node_modules/dotenv/lib/main.js"(exports2, module2) {
|
|
107
|
-
var
|
|
107
|
+
var fs7 = require("fs");
|
|
108
108
|
var path7 = require("path");
|
|
109
109
|
var os3 = require("os");
|
|
110
110
|
var crypto2 = require("crypto");
|
|
@@ -213,7 +213,7 @@ var require_main = __commonJS({
|
|
|
213
213
|
if (options && options.path && options.path.length > 0) {
|
|
214
214
|
if (Array.isArray(options.path)) {
|
|
215
215
|
for (const filepath of options.path) {
|
|
216
|
-
if (
|
|
216
|
+
if (fs7.existsSync(filepath)) {
|
|
217
217
|
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
218
218
|
}
|
|
219
219
|
}
|
|
@@ -223,7 +223,7 @@ var require_main = __commonJS({
|
|
|
223
223
|
} else {
|
|
224
224
|
possibleVaultPath = path7.resolve(process.cwd(), ".env.vault");
|
|
225
225
|
}
|
|
226
|
-
if (
|
|
226
|
+
if (fs7.existsSync(possibleVaultPath)) {
|
|
227
227
|
return possibleVaultPath;
|
|
228
228
|
}
|
|
229
229
|
return null;
|
|
@@ -272,7 +272,7 @@ var require_main = __commonJS({
|
|
|
272
272
|
const parsedAll = {};
|
|
273
273
|
for (const path8 of optionPaths) {
|
|
274
274
|
try {
|
|
275
|
-
const parsed = DotenvModule.parse(
|
|
275
|
+
const parsed = DotenvModule.parse(fs7.readFileSync(path8, { encoding }));
|
|
276
276
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
277
277
|
} catch (e3) {
|
|
278
278
|
if (debug) {
|
|
@@ -678,7 +678,7 @@ async function waitForFileLock(lockPath, binaryPath) {
|
|
|
678
678
|
}
|
|
679
679
|
} catch {
|
|
680
680
|
}
|
|
681
|
-
await new Promise((
|
|
681
|
+
await new Promise((resolve5) => setTimeout(resolve5, LOCK_POLL_INTERVAL_MS));
|
|
682
682
|
}
|
|
683
683
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
684
684
|
console.log(`Timeout waiting for file lock`);
|
|
@@ -1662,7 +1662,7 @@ Command: ${command}`;
|
|
|
1662
1662
|
}
|
|
1663
1663
|
}
|
|
1664
1664
|
function extractWithStdin(binaryPath, cliArgs, content, options) {
|
|
1665
|
-
return new Promise((
|
|
1665
|
+
return new Promise((resolve5, reject2) => {
|
|
1666
1666
|
const childProcess = (0, import_child_process4.spawn)(binaryPath, ["extract", ...cliArgs], {
|
|
1667
1667
|
stdio: ["pipe", "pipe", "pipe"]
|
|
1668
1668
|
});
|
|
@@ -1684,7 +1684,7 @@ function extractWithStdin(binaryPath, cliArgs, content, options) {
|
|
|
1684
1684
|
}
|
|
1685
1685
|
try {
|
|
1686
1686
|
const result = processExtractOutput(stdout, options);
|
|
1687
|
-
|
|
1687
|
+
resolve5(result);
|
|
1688
1688
|
} catch (error2) {
|
|
1689
1689
|
reject2(error2);
|
|
1690
1690
|
}
|
|
@@ -2570,48 +2570,37 @@ var require_dist_cjs5 = __commonJS({
|
|
|
2570
2570
|
}
|
|
2571
2571
|
});
|
|
2572
2572
|
|
|
2573
|
-
// node_modules/@aws/lambda-invoke-store/dist/invoke-store.js
|
|
2574
|
-
var
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2573
|
+
// node_modules/@aws/lambda-invoke-store/dist-es/invoke-store.js
|
|
2574
|
+
var invoke_store_exports = {};
|
|
2575
|
+
__export(invoke_store_exports, {
|
|
2576
|
+
InvokeStore: () => InvokeStore
|
|
2577
|
+
});
|
|
2578
|
+
var import_async_hooks, noGlobalAwsLambda, PROTECTED_KEYS, InvokeStoreImpl, instance, InvokeStore;
|
|
2579
|
+
var init_invoke_store = __esm({
|
|
2580
|
+
"node_modules/@aws/lambda-invoke-store/dist-es/invoke-store.js"() {
|
|
2581
|
+
import_async_hooks = require("async_hooks");
|
|
2582
|
+
noGlobalAwsLambda = process.env["AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA"] === "1" || process.env["AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA"] === "true";
|
|
2581
2583
|
if (!noGlobalAwsLambda) {
|
|
2582
2584
|
globalThis.awslambda = globalThis.awslambda || {};
|
|
2583
2585
|
}
|
|
2584
|
-
|
|
2586
|
+
PROTECTED_KEYS = {
|
|
2585
2587
|
REQUEST_ID: Symbol("_AWS_LAMBDA_REQUEST_ID"),
|
|
2586
|
-
X_RAY_TRACE_ID: Symbol("_AWS_LAMBDA_X_RAY_TRACE_ID")
|
|
2588
|
+
X_RAY_TRACE_ID: Symbol("_AWS_LAMBDA_X_RAY_TRACE_ID"),
|
|
2589
|
+
TENANT_ID: Symbol("_AWS_LAMBDA_TENANT_ID")
|
|
2587
2590
|
};
|
|
2588
|
-
|
|
2589
|
-
static storage = new
|
|
2590
|
-
// Protected keys for Lambda context fields
|
|
2591
|
+
InvokeStoreImpl = class {
|
|
2592
|
+
static storage = new import_async_hooks.AsyncLocalStorage();
|
|
2591
2593
|
static PROTECTED_KEYS = PROTECTED_KEYS;
|
|
2592
|
-
/**
|
|
2593
|
-
* Initialize and run code within an invoke context
|
|
2594
|
-
*/
|
|
2595
2594
|
static run(context, fn) {
|
|
2596
2595
|
return this.storage.run({ ...context }, fn);
|
|
2597
2596
|
}
|
|
2598
|
-
/**
|
|
2599
|
-
* Get the complete current context
|
|
2600
|
-
*/
|
|
2601
2597
|
static getContext() {
|
|
2602
2598
|
return this.storage.getStore();
|
|
2603
2599
|
}
|
|
2604
|
-
/**
|
|
2605
|
-
* Get a specific value from the context by key
|
|
2606
|
-
*/
|
|
2607
2600
|
static get(key) {
|
|
2608
2601
|
const context = this.storage.getStore();
|
|
2609
2602
|
return context?.[key];
|
|
2610
2603
|
}
|
|
2611
|
-
/**
|
|
2612
|
-
* Set a custom value in the current context
|
|
2613
|
-
* Protected Lambda context fields cannot be overwritten
|
|
2614
|
-
*/
|
|
2615
2604
|
static set(key, value) {
|
|
2616
2605
|
if (this.isProtectedKey(key)) {
|
|
2617
2606
|
throw new Error(`Cannot modify protected Lambda context field`);
|
|
@@ -2621,32 +2610,22 @@ var require_invoke_store = __commonJS({
|
|
|
2621
2610
|
context[key] = value;
|
|
2622
2611
|
}
|
|
2623
2612
|
}
|
|
2624
|
-
/**
|
|
2625
|
-
* Get the current request ID
|
|
2626
|
-
*/
|
|
2627
2613
|
static getRequestId() {
|
|
2628
2614
|
return this.get(this.PROTECTED_KEYS.REQUEST_ID) ?? "-";
|
|
2629
2615
|
}
|
|
2630
|
-
/**
|
|
2631
|
-
* Get the current X-ray trace ID
|
|
2632
|
-
*/
|
|
2633
2616
|
static getXRayTraceId() {
|
|
2634
2617
|
return this.get(this.PROTECTED_KEYS.X_RAY_TRACE_ID);
|
|
2635
2618
|
}
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2619
|
+
static getTenantId() {
|
|
2620
|
+
return this.get(this.PROTECTED_KEYS.TENANT_ID);
|
|
2621
|
+
}
|
|
2639
2622
|
static hasContext() {
|
|
2640
2623
|
return this.storage.getStore() !== void 0;
|
|
2641
2624
|
}
|
|
2642
|
-
/**
|
|
2643
|
-
* Check if a key is protected (readonly Lambda context field)
|
|
2644
|
-
*/
|
|
2645
2625
|
static isProtectedKey(key) {
|
|
2646
2626
|
return key === this.PROTECTED_KEYS.REQUEST_ID || key === this.PROTECTED_KEYS.X_RAY_TRACE_ID;
|
|
2647
2627
|
}
|
|
2648
2628
|
};
|
|
2649
|
-
var instance;
|
|
2650
2629
|
if (!noGlobalAwsLambda && globalThis.awslambda?.InvokeStore) {
|
|
2651
2630
|
instance = globalThis.awslambda.InvokeStore;
|
|
2652
2631
|
} else {
|
|
@@ -2655,7 +2634,7 @@ var require_invoke_store = __commonJS({
|
|
|
2655
2634
|
globalThis.awslambda.InvokeStore = instance;
|
|
2656
2635
|
}
|
|
2657
2636
|
}
|
|
2658
|
-
|
|
2637
|
+
InvokeStore = instance;
|
|
2659
2638
|
}
|
|
2660
2639
|
});
|
|
2661
2640
|
|
|
@@ -2665,7 +2644,7 @@ var require_recursionDetectionMiddleware = __commonJS({
|
|
|
2665
2644
|
"use strict";
|
|
2666
2645
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2667
2646
|
exports2.recursionDetectionMiddleware = void 0;
|
|
2668
|
-
var lambda_invoke_store_1 =
|
|
2647
|
+
var lambda_invoke_store_1 = (init_invoke_store(), __toCommonJS(invoke_store_exports));
|
|
2669
2648
|
var protocol_http_1 = require_dist_cjs2();
|
|
2670
2649
|
var TRACE_ID_HEADER_NAME = "X-Amzn-Trace-Id";
|
|
2671
2650
|
var ENV_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME";
|
|
@@ -3688,7 +3667,7 @@ var require_headStream = __commonJS({
|
|
|
3688
3667
|
if ((0, stream_type_check_1.isReadableStream)(stream2)) {
|
|
3689
3668
|
return (0, headStream_browser_1.headStream)(stream2, bytes);
|
|
3690
3669
|
}
|
|
3691
|
-
return new Promise((
|
|
3670
|
+
return new Promise((resolve5, reject2) => {
|
|
3692
3671
|
const collector = new Collector();
|
|
3693
3672
|
collector.limit = bytes;
|
|
3694
3673
|
stream2.pipe(collector);
|
|
@@ -3699,7 +3678,7 @@ var require_headStream = __commonJS({
|
|
|
3699
3678
|
collector.on("error", reject2);
|
|
3700
3679
|
collector.on("finish", function() {
|
|
3701
3680
|
const bytes2 = new Uint8Array(Buffer.concat(this.buffers));
|
|
3702
|
-
|
|
3681
|
+
resolve5(bytes2);
|
|
3703
3682
|
});
|
|
3704
3683
|
});
|
|
3705
3684
|
};
|
|
@@ -3880,28 +3859,28 @@ var require_dist_cjs15 = __commonJS({
|
|
|
3880
3859
|
return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
3881
3860
|
};
|
|
3882
3861
|
var MIN_WAIT_TIME = 6e3;
|
|
3883
|
-
async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME) {
|
|
3862
|
+
async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME, externalAgent = false) {
|
|
3884
3863
|
const headers = request.headers ?? {};
|
|
3885
3864
|
const expect = headers.Expect || headers.expect;
|
|
3886
3865
|
let timeoutId = -1;
|
|
3887
3866
|
let sendBody = true;
|
|
3888
|
-
if (expect === "100-continue") {
|
|
3867
|
+
if (!externalAgent && expect === "100-continue") {
|
|
3889
3868
|
sendBody = await Promise.race([
|
|
3890
|
-
new Promise((
|
|
3891
|
-
timeoutId = Number(timing.setTimeout(() =>
|
|
3869
|
+
new Promise((resolve5) => {
|
|
3870
|
+
timeoutId = Number(timing.setTimeout(() => resolve5(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
3892
3871
|
}),
|
|
3893
|
-
new Promise((
|
|
3872
|
+
new Promise((resolve5) => {
|
|
3894
3873
|
httpRequest.on("continue", () => {
|
|
3895
3874
|
timing.clearTimeout(timeoutId);
|
|
3896
|
-
|
|
3875
|
+
resolve5(true);
|
|
3897
3876
|
});
|
|
3898
3877
|
httpRequest.on("response", () => {
|
|
3899
3878
|
timing.clearTimeout(timeoutId);
|
|
3900
|
-
|
|
3879
|
+
resolve5(false);
|
|
3901
3880
|
});
|
|
3902
3881
|
httpRequest.on("error", () => {
|
|
3903
3882
|
timing.clearTimeout(timeoutId);
|
|
3904
|
-
|
|
3883
|
+
resolve5(false);
|
|
3905
3884
|
});
|
|
3906
3885
|
})
|
|
3907
3886
|
]);
|
|
@@ -3935,6 +3914,7 @@ var require_dist_cjs15 = __commonJS({
|
|
|
3935
3914
|
config;
|
|
3936
3915
|
configProvider;
|
|
3937
3916
|
socketWarningTimestamp = 0;
|
|
3917
|
+
externalAgent = false;
|
|
3938
3918
|
metadata = { handlerProtocol: "http/1.1" };
|
|
3939
3919
|
static create(instanceOrOptions) {
|
|
3940
3920
|
if (typeof instanceOrOptions?.handle === "function") {
|
|
@@ -3966,13 +3946,13 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
3966
3946
|
return socketWarningTimestamp;
|
|
3967
3947
|
}
|
|
3968
3948
|
constructor(options) {
|
|
3969
|
-
this.configProvider = new Promise((
|
|
3949
|
+
this.configProvider = new Promise((resolve5, reject2) => {
|
|
3970
3950
|
if (typeof options === "function") {
|
|
3971
3951
|
options().then((_options) => {
|
|
3972
|
-
|
|
3952
|
+
resolve5(this.resolveDefaultConfig(_options));
|
|
3973
3953
|
}).catch(reject2);
|
|
3974
3954
|
} else {
|
|
3975
|
-
|
|
3955
|
+
resolve5(this.resolveDefaultConfig(options));
|
|
3976
3956
|
}
|
|
3977
3957
|
});
|
|
3978
3958
|
}
|
|
@@ -3988,12 +3968,14 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
3988
3968
|
throwOnRequestTimeout,
|
|
3989
3969
|
httpAgent: (() => {
|
|
3990
3970
|
if (httpAgent instanceof http.Agent || typeof httpAgent?.destroy === "function") {
|
|
3971
|
+
this.externalAgent = true;
|
|
3991
3972
|
return httpAgent;
|
|
3992
3973
|
}
|
|
3993
3974
|
return new http.Agent({ keepAlive, maxSockets, ...httpAgent });
|
|
3994
3975
|
})(),
|
|
3995
3976
|
httpsAgent: (() => {
|
|
3996
3977
|
if (httpsAgent instanceof https.Agent || typeof httpsAgent?.destroy === "function") {
|
|
3978
|
+
this.externalAgent = true;
|
|
3997
3979
|
return httpsAgent;
|
|
3998
3980
|
}
|
|
3999
3981
|
return new https.Agent({ keepAlive, maxSockets, ...httpsAgent });
|
|
@@ -4013,7 +3995,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
4013
3995
|
const config = this.config;
|
|
4014
3996
|
let writeRequestBodyPromise = void 0;
|
|
4015
3997
|
const timeouts = [];
|
|
4016
|
-
const
|
|
3998
|
+
const resolve5 = async (arg) => {
|
|
4017
3999
|
await writeRequestBodyPromise;
|
|
4018
4000
|
timeouts.forEach(timing.clearTimeout);
|
|
4019
4001
|
_resolve(arg);
|
|
@@ -4033,7 +4015,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
4033
4015
|
const headers = request.headers ?? {};
|
|
4034
4016
|
const expectContinue = (headers.Expect ?? headers.expect) === "100-continue";
|
|
4035
4017
|
let agent = isSSL ? config.httpsAgent : config.httpAgent;
|
|
4036
|
-
if (expectContinue) {
|
|
4018
|
+
if (expectContinue && !this.externalAgent) {
|
|
4037
4019
|
agent = new (isSSL ? https.Agent : http.Agent)({
|
|
4038
4020
|
keepAlive: false,
|
|
4039
4021
|
maxSockets: Infinity
|
|
@@ -4079,7 +4061,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
4079
4061
|
headers: getTransformedHeaders(res.headers),
|
|
4080
4062
|
body: res
|
|
4081
4063
|
});
|
|
4082
|
-
|
|
4064
|
+
resolve5({ response: httpResponse });
|
|
4083
4065
|
});
|
|
4084
4066
|
req.on("error", (err) => {
|
|
4085
4067
|
if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
|
|
@@ -4114,7 +4096,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
4114
4096
|
keepAliveMsecs: httpAgent.keepAliveMsecs
|
|
4115
4097
|
}));
|
|
4116
4098
|
}
|
|
4117
|
-
writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout).catch((e3) => {
|
|
4099
|
+
writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout, this.externalAgent).catch((e3) => {
|
|
4118
4100
|
timeouts.forEach(timing.clearTimeout);
|
|
4119
4101
|
return _reject(e3);
|
|
4120
4102
|
});
|
|
@@ -4259,13 +4241,13 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
4259
4241
|
return new _NodeHttp2Handler(instanceOrOptions);
|
|
4260
4242
|
}
|
|
4261
4243
|
constructor(options) {
|
|
4262
|
-
this.configProvider = new Promise((
|
|
4244
|
+
this.configProvider = new Promise((resolve5, reject2) => {
|
|
4263
4245
|
if (typeof options === "function") {
|
|
4264
4246
|
options().then((opts) => {
|
|
4265
|
-
|
|
4247
|
+
resolve5(opts || {});
|
|
4266
4248
|
}).catch(reject2);
|
|
4267
4249
|
} else {
|
|
4268
|
-
|
|
4250
|
+
resolve5(options || {});
|
|
4269
4251
|
}
|
|
4270
4252
|
});
|
|
4271
4253
|
}
|
|
@@ -4285,7 +4267,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
4285
4267
|
return new Promise((_resolve, _reject) => {
|
|
4286
4268
|
let fulfilled = false;
|
|
4287
4269
|
let writeRequestBodyPromise = void 0;
|
|
4288
|
-
const
|
|
4270
|
+
const resolve5 = async (arg) => {
|
|
4289
4271
|
await writeRequestBodyPromise;
|
|
4290
4272
|
_resolve(arg);
|
|
4291
4273
|
};
|
|
@@ -4341,7 +4323,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
4341
4323
|
body: req
|
|
4342
4324
|
});
|
|
4343
4325
|
fulfilled = true;
|
|
4344
|
-
|
|
4326
|
+
resolve5({ response: httpResponse });
|
|
4345
4327
|
if (disableConcurrentStreams) {
|
|
4346
4328
|
session.close();
|
|
4347
4329
|
this.connectionManager.deleteSession(authority, session);
|
|
@@ -4418,7 +4400,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
4418
4400
|
if (isReadableStreamInstance(stream3)) {
|
|
4419
4401
|
return collectReadableStream(stream3);
|
|
4420
4402
|
}
|
|
4421
|
-
return new Promise((
|
|
4403
|
+
return new Promise((resolve5, reject2) => {
|
|
4422
4404
|
const collector = new Collector();
|
|
4423
4405
|
stream3.pipe(collector);
|
|
4424
4406
|
stream3.on("error", (err) => {
|
|
@@ -4428,7 +4410,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
4428
4410
|
collector.on("error", reject2);
|
|
4429
4411
|
collector.on("finish", function() {
|
|
4430
4412
|
const bytes = new Uint8Array(Buffer.concat(this.bufferedBytes));
|
|
4431
|
-
|
|
4413
|
+
resolve5(bytes);
|
|
4432
4414
|
});
|
|
4433
4415
|
});
|
|
4434
4416
|
};
|
|
@@ -4472,7 +4454,7 @@ var require_dist_cjs16 = __commonJS({
|
|
|
4472
4454
|
return new Request(url, requestOptions);
|
|
4473
4455
|
}
|
|
4474
4456
|
function requestTimeout(timeoutInMs = 0) {
|
|
4475
|
-
return new Promise((
|
|
4457
|
+
return new Promise((resolve5, reject2) => {
|
|
4476
4458
|
if (timeoutInMs) {
|
|
4477
4459
|
setTimeout(() => {
|
|
4478
4460
|
const timeoutError = new Error(`Request did not complete within ${timeoutInMs} ms`);
|
|
@@ -4590,7 +4572,7 @@ var require_dist_cjs16 = __commonJS({
|
|
|
4590
4572
|
requestTimeout(requestTimeoutInMs)
|
|
4591
4573
|
];
|
|
4592
4574
|
if (abortSignal) {
|
|
4593
|
-
raceOfPromises.push(new Promise((
|
|
4575
|
+
raceOfPromises.push(new Promise((resolve5, reject2) => {
|
|
4594
4576
|
const onAbort = () => {
|
|
4595
4577
|
const abortError = new Error("Request aborted");
|
|
4596
4578
|
abortError.name = "AbortError";
|
|
@@ -4654,7 +4636,7 @@ var require_dist_cjs16 = __commonJS({
|
|
|
4654
4636
|
return collected;
|
|
4655
4637
|
}
|
|
4656
4638
|
function readToBase64(blob) {
|
|
4657
|
-
return new Promise((
|
|
4639
|
+
return new Promise((resolve5, reject2) => {
|
|
4658
4640
|
const reader = new FileReader();
|
|
4659
4641
|
reader.onloadend = () => {
|
|
4660
4642
|
if (reader.readyState !== 2) {
|
|
@@ -4663,7 +4645,7 @@ var require_dist_cjs16 = __commonJS({
|
|
|
4663
4645
|
const result = reader.result ?? "";
|
|
4664
4646
|
const commaIndex = result.indexOf(",");
|
|
4665
4647
|
const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length;
|
|
4666
|
-
|
|
4648
|
+
resolve5(result.substring(dataOffset));
|
|
4667
4649
|
};
|
|
4668
4650
|
reader.onabort = () => reject2(new Error("Read aborted"));
|
|
4669
4651
|
reader.onerror = () => reject2(reader.error);
|
|
@@ -5165,8 +5147,8 @@ var init_Schema = __esm({
|
|
|
5165
5147
|
name;
|
|
5166
5148
|
namespace;
|
|
5167
5149
|
traits;
|
|
5168
|
-
static assign(
|
|
5169
|
-
const schema = Object.assign(
|
|
5150
|
+
static assign(instance2, values2) {
|
|
5151
|
+
const schema = Object.assign(instance2, values2);
|
|
5170
5152
|
return schema;
|
|
5171
5153
|
}
|
|
5172
5154
|
static [Symbol.hasInstance](lhs) {
|
|
@@ -6283,11 +6265,11 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
6283
6265
|
}
|
|
6284
6266
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
6285
6267
|
function adopt(value) {
|
|
6286
|
-
return value instanceof P ? value : new P(function(
|
|
6287
|
-
|
|
6268
|
+
return value instanceof P ? value : new P(function(resolve5) {
|
|
6269
|
+
resolve5(value);
|
|
6288
6270
|
});
|
|
6289
6271
|
}
|
|
6290
|
-
return new (P || (P = Promise))(function(
|
|
6272
|
+
return new (P || (P = Promise))(function(resolve5, reject2) {
|
|
6291
6273
|
function fulfilled(value) {
|
|
6292
6274
|
try {
|
|
6293
6275
|
step(generator.next(value));
|
|
@@ -6303,7 +6285,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
6303
6285
|
}
|
|
6304
6286
|
}
|
|
6305
6287
|
function step(result) {
|
|
6306
|
-
result.done ?
|
|
6288
|
+
result.done ? resolve5(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
6307
6289
|
}
|
|
6308
6290
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
6309
6291
|
});
|
|
@@ -6494,14 +6476,14 @@ function __asyncValues(o3) {
|
|
|
6494
6476
|
}, i3);
|
|
6495
6477
|
function verb(n3) {
|
|
6496
6478
|
i3[n3] = o3[n3] && function(v3) {
|
|
6497
|
-
return new Promise(function(
|
|
6498
|
-
v3 = o3[n3](v3), settle(
|
|
6479
|
+
return new Promise(function(resolve5, reject2) {
|
|
6480
|
+
v3 = o3[n3](v3), settle(resolve5, reject2, v3.done, v3.value);
|
|
6499
6481
|
});
|
|
6500
6482
|
};
|
|
6501
6483
|
}
|
|
6502
|
-
function settle(
|
|
6484
|
+
function settle(resolve5, reject2, d3, v3) {
|
|
6503
6485
|
Promise.resolve(v3).then(function(v4) {
|
|
6504
|
-
|
|
6486
|
+
resolve5({ value: v4, done: d3 });
|
|
6505
6487
|
}, reject2);
|
|
6506
6488
|
}
|
|
6507
6489
|
}
|
|
@@ -6828,12 +6810,8 @@ var init_schema_date_utils = __esm({
|
|
|
6828
6810
|
range(hours, 0, 23);
|
|
6829
6811
|
range(minutes, 0, 59);
|
|
6830
6812
|
range(seconds, 0, 60);
|
|
6831
|
-
const date2 =
|
|
6832
|
-
date2.setUTCFullYear(Number(yearStr)
|
|
6833
|
-
date2.setUTCHours(Number(hours));
|
|
6834
|
-
date2.setUTCMinutes(Number(minutes));
|
|
6835
|
-
date2.setUTCSeconds(Number(seconds));
|
|
6836
|
-
date2.setUTCMilliseconds(Number(ms) ? Math.round(parseFloat(`0.${ms}`) * 1e3) : 0);
|
|
6813
|
+
const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes), Number(seconds), Number(ms) ? Math.round(parseFloat(`0.${ms}`) * 1e3) : 0));
|
|
6814
|
+
date2.setUTCFullYear(Number(yearStr));
|
|
6837
6815
|
if (offsetStr.toUpperCase() != "Z") {
|
|
6838
6816
|
const [, sign, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [void 0, "+", 0, 0];
|
|
6839
6817
|
const scalar = sign === "-" ? 1 : -1;
|
|
@@ -6865,18 +6843,13 @@ var init_schema_date_utils = __esm({
|
|
|
6865
6843
|
[, month, day, hour, minute, second, fraction, year2] = matches;
|
|
6866
6844
|
}
|
|
6867
6845
|
if (year2 && second) {
|
|
6868
|
-
const
|
|
6869
|
-
date2.setUTCFullYear(Number(year2));
|
|
6870
|
-
date2.setUTCMonth(months.indexOf(month));
|
|
6846
|
+
const timestamp = Date.UTC(Number(year2), months.indexOf(month), Number(day), Number(hour), Number(minute), Number(second), fraction ? Math.round(parseFloat(`0.${fraction}`) * 1e3) : 0);
|
|
6871
6847
|
range(day, 1, 31);
|
|
6872
|
-
date2.setUTCDate(Number(day));
|
|
6873
6848
|
range(hour, 0, 23);
|
|
6874
|
-
date2.setUTCHours(Number(hour));
|
|
6875
6849
|
range(minute, 0, 59);
|
|
6876
|
-
date2.setUTCMinutes(Number(minute));
|
|
6877
6850
|
range(second, 0, 60);
|
|
6878
|
-
date2
|
|
6879
|
-
date2.
|
|
6851
|
+
const date2 = new Date(timestamp);
|
|
6852
|
+
date2.setUTCFullYear(Number(year2));
|
|
6880
6853
|
return date2;
|
|
6881
6854
|
}
|
|
6882
6855
|
throw new TypeError(`Invalid RFC7231 date-time value ${value}.`);
|
|
@@ -9110,6 +9083,9 @@ var require_dist_cjs23 = __commonJS({
|
|
|
9110
9083
|
},
|
|
9111
9084
|
"us-isob-east-1": {
|
|
9112
9085
|
description: "US ISOB East (Ohio)"
|
|
9086
|
+
},
|
|
9087
|
+
"us-isob-west-1": {
|
|
9088
|
+
description: "US ISOB West"
|
|
9113
9089
|
}
|
|
9114
9090
|
}
|
|
9115
9091
|
},
|
|
@@ -12114,18 +12090,18 @@ var require_dist_cjs27 = __commonJS({
|
|
|
12114
12090
|
const candidate = value;
|
|
12115
12091
|
return _ServiceException.prototype.isPrototypeOf(candidate) || Boolean(candidate.$fault) && Boolean(candidate.$metadata) && (candidate.$fault === "client" || candidate.$fault === "server");
|
|
12116
12092
|
}
|
|
12117
|
-
static [Symbol.hasInstance](
|
|
12118
|
-
if (!
|
|
12093
|
+
static [Symbol.hasInstance](instance2) {
|
|
12094
|
+
if (!instance2)
|
|
12119
12095
|
return false;
|
|
12120
|
-
const candidate =
|
|
12096
|
+
const candidate = instance2;
|
|
12121
12097
|
if (this === _ServiceException) {
|
|
12122
|
-
return _ServiceException.isInstance(
|
|
12098
|
+
return _ServiceException.isInstance(instance2);
|
|
12123
12099
|
}
|
|
12124
|
-
if (_ServiceException.isInstance(
|
|
12100
|
+
if (_ServiceException.isInstance(instance2)) {
|
|
12125
12101
|
if (candidate.name && this.name) {
|
|
12126
|
-
return this.prototype.isPrototypeOf(
|
|
12102
|
+
return this.prototype.isPrototypeOf(instance2) || candidate.name === this.name;
|
|
12127
12103
|
}
|
|
12128
|
-
return this.prototype.isPrototypeOf(
|
|
12104
|
+
return this.prototype.isPrototypeOf(instance2);
|
|
12129
12105
|
}
|
|
12130
12106
|
return false;
|
|
12131
12107
|
}
|
|
@@ -15051,8 +15027,8 @@ var require_dist_cjs29 = __commonJS({
|
|
|
15051
15027
|
var X_AMZ_USER_AGENT = "x-amz-user-agent";
|
|
15052
15028
|
var SPACE = " ";
|
|
15053
15029
|
var UA_NAME_SEPARATOR = "/";
|
|
15054
|
-
var UA_NAME_ESCAPE_REGEX = /[
|
|
15055
|
-
var UA_VALUE_ESCAPE_REGEX = /[
|
|
15030
|
+
var UA_NAME_ESCAPE_REGEX = /[^!$%&'*+\-.^_`|~\w]/g;
|
|
15031
|
+
var UA_VALUE_ESCAPE_REGEX = /[^!$%&'*+\-.^_`|~\w#]/g;
|
|
15056
15032
|
var UA_ESCAPE_CHAR = "-";
|
|
15057
15033
|
var BYTE_LIMIT = 1024;
|
|
15058
15034
|
function encodeFeatures(features) {
|
|
@@ -15085,7 +15061,7 @@ var require_dist_cjs29 = __commonJS({
|
|
|
15085
15061
|
const customUserAgent = options?.customUserAgent?.map(escapeUserAgent) || [];
|
|
15086
15062
|
const appId = await options.userAgentAppId();
|
|
15087
15063
|
if (appId) {
|
|
15088
|
-
defaultUserAgent.push(escapeUserAgent([`app
|
|
15064
|
+
defaultUserAgent.push(escapeUserAgent([`app`, `${appId}`]));
|
|
15089
15065
|
}
|
|
15090
15066
|
const prefix = utilEndpoints.getUserAgentPrefix();
|
|
15091
15067
|
const sdkUserAgentValue = (prefix ? [prefix] : []).concat([...defaultUserAgent, ...userAgent, ...customUserAgent]).join(SPACE);
|
|
@@ -16575,7 +16551,7 @@ var require_dist_cjs37 = __commonJS({
|
|
|
16575
16551
|
this.sockets[url] = (this.sockets[url] ?? []).filter((socket) => ![WebSocket.CLOSING, WebSocket.CLOSED].includes(socket.readyState));
|
|
16576
16552
|
}
|
|
16577
16553
|
waitForReady(socket, connectionTimeout) {
|
|
16578
|
-
return new Promise((
|
|
16554
|
+
return new Promise((resolve5, reject2) => {
|
|
16579
16555
|
const timeout = setTimeout(() => {
|
|
16580
16556
|
this.removeNotUsableSockets(socket.url);
|
|
16581
16557
|
reject2({
|
|
@@ -16586,7 +16562,7 @@ var require_dist_cjs37 = __commonJS({
|
|
|
16586
16562
|
}, connectionTimeout);
|
|
16587
16563
|
socket.onopen = () => {
|
|
16588
16564
|
clearTimeout(timeout);
|
|
16589
|
-
|
|
16565
|
+
resolve5();
|
|
16590
16566
|
};
|
|
16591
16567
|
});
|
|
16592
16568
|
}
|
|
@@ -16595,10 +16571,10 @@ var require_dist_cjs37 = __commonJS({
|
|
|
16595
16571
|
let socketErrorOccurred = false;
|
|
16596
16572
|
let reject2 = () => {
|
|
16597
16573
|
};
|
|
16598
|
-
let
|
|
16574
|
+
let resolve5 = () => {
|
|
16599
16575
|
};
|
|
16600
16576
|
socket.onmessage = (event) => {
|
|
16601
|
-
|
|
16577
|
+
resolve5({
|
|
16602
16578
|
done: false,
|
|
16603
16579
|
value: new Uint8Array(event.data)
|
|
16604
16580
|
});
|
|
@@ -16615,7 +16591,7 @@ var require_dist_cjs37 = __commonJS({
|
|
|
16615
16591
|
if (streamError) {
|
|
16616
16592
|
reject2(streamError);
|
|
16617
16593
|
} else {
|
|
16618
|
-
|
|
16594
|
+
resolve5({
|
|
16619
16595
|
done: true,
|
|
16620
16596
|
value: void 0
|
|
16621
16597
|
});
|
|
@@ -16625,7 +16601,7 @@ var require_dist_cjs37 = __commonJS({
|
|
|
16625
16601
|
[Symbol.asyncIterator]: () => ({
|
|
16626
16602
|
next: () => {
|
|
16627
16603
|
return new Promise((_resolve, _reject) => {
|
|
16628
|
-
|
|
16604
|
+
resolve5 = _resolve;
|
|
16629
16605
|
reject2 = _reject;
|
|
16630
16606
|
});
|
|
16631
16607
|
}
|
|
@@ -17648,7 +17624,7 @@ var require_dist_cjs46 = __commonJS({
|
|
|
17648
17624
|
this.refillTokenBucket();
|
|
17649
17625
|
if (amount > this.currentCapacity) {
|
|
17650
17626
|
const delay = (amount - this.currentCapacity) / this.fillRate * 1e3;
|
|
17651
|
-
await new Promise((
|
|
17627
|
+
await new Promise((resolve5) => _DefaultRateLimiter.setTimeoutFn(resolve5, delay));
|
|
17652
17628
|
}
|
|
17653
17629
|
this.currentCapacity = this.currentCapacity - amount;
|
|
17654
17630
|
}
|
|
@@ -17983,7 +17959,7 @@ var require_dist_cjs47 = __commonJS({
|
|
|
17983
17959
|
const delayFromResponse = getDelayFromRetryAfterHeader(err.$response);
|
|
17984
17960
|
const delay = Math.max(delayFromResponse || 0, delayFromDecider);
|
|
17985
17961
|
totalDelay += delay;
|
|
17986
|
-
await new Promise((
|
|
17962
|
+
await new Promise((resolve5) => setTimeout(resolve5, delay));
|
|
17987
17963
|
continue;
|
|
17988
17964
|
}
|
|
17989
17965
|
if (!err.$metadata) {
|
|
@@ -18141,7 +18117,7 @@ var require_dist_cjs47 = __commonJS({
|
|
|
18141
18117
|
attempts = retryToken.getRetryCount();
|
|
18142
18118
|
const delay = retryToken.getRetryDelay();
|
|
18143
18119
|
totalRetryDelay += delay;
|
|
18144
|
-
await new Promise((
|
|
18120
|
+
await new Promise((resolve5) => setTimeout(resolve5, delay));
|
|
18145
18121
|
}
|
|
18146
18122
|
}
|
|
18147
18123
|
} else {
|
|
@@ -18293,7 +18269,7 @@ var require_package2 = __commonJS({
|
|
|
18293
18269
|
module2.exports = {
|
|
18294
18270
|
name: "@aws-sdk/client-bedrock-runtime",
|
|
18295
18271
|
description: "AWS SDK for JavaScript Bedrock Runtime Client for Node.js, Browser and React Native",
|
|
18296
|
-
version: "3.
|
|
18272
|
+
version: "3.922.0",
|
|
18297
18273
|
scripts: {
|
|
18298
18274
|
build: "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
18299
18275
|
"build:cjs": "node ../../scripts/compilation/inline client-bedrock-runtime",
|
|
@@ -18312,49 +18288,49 @@ var require_package2 = __commonJS({
|
|
|
18312
18288
|
dependencies: {
|
|
18313
18289
|
"@aws-crypto/sha256-browser": "5.2.0",
|
|
18314
18290
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
18315
|
-
"@aws-sdk/core": "3.
|
|
18316
|
-
"@aws-sdk/credential-provider-node": "3.
|
|
18317
|
-
"@aws-sdk/eventstream-handler-node": "3.
|
|
18318
|
-
"@aws-sdk/middleware-eventstream": "3.
|
|
18319
|
-
"@aws-sdk/middleware-host-header": "3.
|
|
18320
|
-
"@aws-sdk/middleware-logger": "3.
|
|
18321
|
-
"@aws-sdk/middleware-recursion-detection": "3.
|
|
18322
|
-
"@aws-sdk/middleware-user-agent": "3.
|
|
18323
|
-
"@aws-sdk/middleware-websocket": "3.
|
|
18324
|
-
"@aws-sdk/region-config-resolver": "3.
|
|
18325
|
-
"@aws-sdk/token-providers": "3.
|
|
18326
|
-
"@aws-sdk/types": "3.
|
|
18327
|
-
"@aws-sdk/util-endpoints": "3.
|
|
18328
|
-
"@aws-sdk/util-user-agent-browser": "3.
|
|
18329
|
-
"@aws-sdk/util-user-agent-node": "3.
|
|
18330
|
-
"@smithy/config-resolver": "^4.4.
|
|
18331
|
-
"@smithy/core": "^3.17.
|
|
18332
|
-
"@smithy/eventstream-serde-browser": "^4.2.
|
|
18333
|
-
"@smithy/eventstream-serde-config-resolver": "^4.3.
|
|
18334
|
-
"@smithy/eventstream-serde-node": "^4.2.
|
|
18335
|
-
"@smithy/fetch-http-handler": "^5.3.
|
|
18336
|
-
"@smithy/hash-node": "^4.2.
|
|
18337
|
-
"@smithy/invalid-dependency": "^4.2.
|
|
18338
|
-
"@smithy/middleware-content-length": "^4.2.
|
|
18339
|
-
"@smithy/middleware-endpoint": "^4.3.
|
|
18340
|
-
"@smithy/middleware-retry": "^4.4.
|
|
18341
|
-
"@smithy/middleware-serde": "^4.2.
|
|
18342
|
-
"@smithy/middleware-stack": "^4.2.
|
|
18343
|
-
"@smithy/node-config-provider": "^4.3.
|
|
18344
|
-
"@smithy/node-http-handler": "^4.4.
|
|
18345
|
-
"@smithy/protocol-http": "^5.3.
|
|
18346
|
-
"@smithy/smithy-client": "^4.9.
|
|
18347
|
-
"@smithy/types": "^4.8.
|
|
18348
|
-
"@smithy/url-parser": "^4.2.
|
|
18291
|
+
"@aws-sdk/core": "3.922.0",
|
|
18292
|
+
"@aws-sdk/credential-provider-node": "3.922.0",
|
|
18293
|
+
"@aws-sdk/eventstream-handler-node": "3.922.0",
|
|
18294
|
+
"@aws-sdk/middleware-eventstream": "3.922.0",
|
|
18295
|
+
"@aws-sdk/middleware-host-header": "3.922.0",
|
|
18296
|
+
"@aws-sdk/middleware-logger": "3.922.0",
|
|
18297
|
+
"@aws-sdk/middleware-recursion-detection": "3.922.0",
|
|
18298
|
+
"@aws-sdk/middleware-user-agent": "3.922.0",
|
|
18299
|
+
"@aws-sdk/middleware-websocket": "3.922.0",
|
|
18300
|
+
"@aws-sdk/region-config-resolver": "3.922.0",
|
|
18301
|
+
"@aws-sdk/token-providers": "3.922.0",
|
|
18302
|
+
"@aws-sdk/types": "3.922.0",
|
|
18303
|
+
"@aws-sdk/util-endpoints": "3.922.0",
|
|
18304
|
+
"@aws-sdk/util-user-agent-browser": "3.922.0",
|
|
18305
|
+
"@aws-sdk/util-user-agent-node": "3.922.0",
|
|
18306
|
+
"@smithy/config-resolver": "^4.4.1",
|
|
18307
|
+
"@smithy/core": "^3.17.2",
|
|
18308
|
+
"@smithy/eventstream-serde-browser": "^4.2.4",
|
|
18309
|
+
"@smithy/eventstream-serde-config-resolver": "^4.3.4",
|
|
18310
|
+
"@smithy/eventstream-serde-node": "^4.2.4",
|
|
18311
|
+
"@smithy/fetch-http-handler": "^5.3.5",
|
|
18312
|
+
"@smithy/hash-node": "^4.2.4",
|
|
18313
|
+
"@smithy/invalid-dependency": "^4.2.4",
|
|
18314
|
+
"@smithy/middleware-content-length": "^4.2.4",
|
|
18315
|
+
"@smithy/middleware-endpoint": "^4.3.6",
|
|
18316
|
+
"@smithy/middleware-retry": "^4.4.6",
|
|
18317
|
+
"@smithy/middleware-serde": "^4.2.4",
|
|
18318
|
+
"@smithy/middleware-stack": "^4.2.4",
|
|
18319
|
+
"@smithy/node-config-provider": "^4.3.4",
|
|
18320
|
+
"@smithy/node-http-handler": "^4.4.4",
|
|
18321
|
+
"@smithy/protocol-http": "^5.3.4",
|
|
18322
|
+
"@smithy/smithy-client": "^4.9.2",
|
|
18323
|
+
"@smithy/types": "^4.8.1",
|
|
18324
|
+
"@smithy/url-parser": "^4.2.4",
|
|
18349
18325
|
"@smithy/util-base64": "^4.3.0",
|
|
18350
18326
|
"@smithy/util-body-length-browser": "^4.2.0",
|
|
18351
18327
|
"@smithy/util-body-length-node": "^4.2.1",
|
|
18352
|
-
"@smithy/util-defaults-mode-browser": "^4.3.
|
|
18353
|
-
"@smithy/util-defaults-mode-node": "^4.2.
|
|
18354
|
-
"@smithy/util-endpoints": "^3.2.
|
|
18355
|
-
"@smithy/util-middleware": "^4.2.
|
|
18356
|
-
"@smithy/util-retry": "^4.2.
|
|
18357
|
-
"@smithy/util-stream": "^4.5.
|
|
18328
|
+
"@smithy/util-defaults-mode-browser": "^4.3.5",
|
|
18329
|
+
"@smithy/util-defaults-mode-node": "^4.2.7",
|
|
18330
|
+
"@smithy/util-endpoints": "^3.2.4",
|
|
18331
|
+
"@smithy/util-middleware": "^4.2.4",
|
|
18332
|
+
"@smithy/util-retry": "^4.2.4",
|
|
18333
|
+
"@smithy/util-stream": "^4.5.5",
|
|
18358
18334
|
"@smithy/util-utf8": "^4.2.0",
|
|
18359
18335
|
"@smithy/uuid": "^1.1.0",
|
|
18360
18336
|
tslib: "^2.6.2"
|
|
@@ -18456,7 +18432,7 @@ var require_dist_cjs49 = __commonJS({
|
|
|
18456
18432
|
var nodeConfigProvider = require_dist_cjs43();
|
|
18457
18433
|
var urlParser = require_dist_cjs22();
|
|
18458
18434
|
function httpRequest(options) {
|
|
18459
|
-
return new Promise((
|
|
18435
|
+
return new Promise((resolve5, reject2) => {
|
|
18460
18436
|
const req = http.request({
|
|
18461
18437
|
method: "GET",
|
|
18462
18438
|
...options,
|
|
@@ -18481,7 +18457,7 @@ var require_dist_cjs49 = __commonJS({
|
|
|
18481
18457
|
chunks.push(chunk);
|
|
18482
18458
|
});
|
|
18483
18459
|
res.on("end", () => {
|
|
18484
|
-
|
|
18460
|
+
resolve5(buffer.Buffer.concat(chunks));
|
|
18485
18461
|
req.destroy();
|
|
18486
18462
|
});
|
|
18487
18463
|
});
|
|
@@ -18901,7 +18877,7 @@ var require_retry_wrapper = __commonJS({
|
|
|
18901
18877
|
try {
|
|
18902
18878
|
return await toRetry();
|
|
18903
18879
|
} catch (e3) {
|
|
18904
|
-
await new Promise((
|
|
18880
|
+
await new Promise((resolve5) => setTimeout(resolve5, delayMs));
|
|
18905
18881
|
}
|
|
18906
18882
|
}
|
|
18907
18883
|
return await toRetry();
|
|
@@ -19074,7 +19050,7 @@ var init_package = __esm({
|
|
|
19074
19050
|
"node_modules/@aws-sdk/nested-clients/package.json"() {
|
|
19075
19051
|
package_default = {
|
|
19076
19052
|
name: "@aws-sdk/nested-clients",
|
|
19077
|
-
version: "3.
|
|
19053
|
+
version: "3.922.0",
|
|
19078
19054
|
description: "Nested clients for AWS SDK packages.",
|
|
19079
19055
|
main: "./dist-cjs/index.js",
|
|
19080
19056
|
module: "./dist-es/index.js",
|
|
@@ -19103,40 +19079,40 @@ var init_package = __esm({
|
|
|
19103
19079
|
dependencies: {
|
|
19104
19080
|
"@aws-crypto/sha256-browser": "5.2.0",
|
|
19105
19081
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
19106
|
-
"@aws-sdk/core": "3.
|
|
19107
|
-
"@aws-sdk/middleware-host-header": "3.
|
|
19108
|
-
"@aws-sdk/middleware-logger": "3.
|
|
19109
|
-
"@aws-sdk/middleware-recursion-detection": "3.
|
|
19110
|
-
"@aws-sdk/middleware-user-agent": "3.
|
|
19111
|
-
"@aws-sdk/region-config-resolver": "3.
|
|
19112
|
-
"@aws-sdk/types": "3.
|
|
19113
|
-
"@aws-sdk/util-endpoints": "3.
|
|
19114
|
-
"@aws-sdk/util-user-agent-browser": "3.
|
|
19115
|
-
"@aws-sdk/util-user-agent-node": "3.
|
|
19116
|
-
"@smithy/config-resolver": "^4.4.
|
|
19117
|
-
"@smithy/core": "^3.17.
|
|
19118
|
-
"@smithy/fetch-http-handler": "^5.3.
|
|
19119
|
-
"@smithy/hash-node": "^4.2.
|
|
19120
|
-
"@smithy/invalid-dependency": "^4.2.
|
|
19121
|
-
"@smithy/middleware-content-length": "^4.2.
|
|
19122
|
-
"@smithy/middleware-endpoint": "^4.3.
|
|
19123
|
-
"@smithy/middleware-retry": "^4.4.
|
|
19124
|
-
"@smithy/middleware-serde": "^4.2.
|
|
19125
|
-
"@smithy/middleware-stack": "^4.2.
|
|
19126
|
-
"@smithy/node-config-provider": "^4.3.
|
|
19127
|
-
"@smithy/node-http-handler": "^4.4.
|
|
19128
|
-
"@smithy/protocol-http": "^5.3.
|
|
19129
|
-
"@smithy/smithy-client": "^4.9.
|
|
19130
|
-
"@smithy/types": "^4.8.
|
|
19131
|
-
"@smithy/url-parser": "^4.2.
|
|
19082
|
+
"@aws-sdk/core": "3.922.0",
|
|
19083
|
+
"@aws-sdk/middleware-host-header": "3.922.0",
|
|
19084
|
+
"@aws-sdk/middleware-logger": "3.922.0",
|
|
19085
|
+
"@aws-sdk/middleware-recursion-detection": "3.922.0",
|
|
19086
|
+
"@aws-sdk/middleware-user-agent": "3.922.0",
|
|
19087
|
+
"@aws-sdk/region-config-resolver": "3.922.0",
|
|
19088
|
+
"@aws-sdk/types": "3.922.0",
|
|
19089
|
+
"@aws-sdk/util-endpoints": "3.922.0",
|
|
19090
|
+
"@aws-sdk/util-user-agent-browser": "3.922.0",
|
|
19091
|
+
"@aws-sdk/util-user-agent-node": "3.922.0",
|
|
19092
|
+
"@smithy/config-resolver": "^4.4.1",
|
|
19093
|
+
"@smithy/core": "^3.17.2",
|
|
19094
|
+
"@smithy/fetch-http-handler": "^5.3.5",
|
|
19095
|
+
"@smithy/hash-node": "^4.2.4",
|
|
19096
|
+
"@smithy/invalid-dependency": "^4.2.4",
|
|
19097
|
+
"@smithy/middleware-content-length": "^4.2.4",
|
|
19098
|
+
"@smithy/middleware-endpoint": "^4.3.6",
|
|
19099
|
+
"@smithy/middleware-retry": "^4.4.6",
|
|
19100
|
+
"@smithy/middleware-serde": "^4.2.4",
|
|
19101
|
+
"@smithy/middleware-stack": "^4.2.4",
|
|
19102
|
+
"@smithy/node-config-provider": "^4.3.4",
|
|
19103
|
+
"@smithy/node-http-handler": "^4.4.4",
|
|
19104
|
+
"@smithy/protocol-http": "^5.3.4",
|
|
19105
|
+
"@smithy/smithy-client": "^4.9.2",
|
|
19106
|
+
"@smithy/types": "^4.8.1",
|
|
19107
|
+
"@smithy/url-parser": "^4.2.4",
|
|
19132
19108
|
"@smithy/util-base64": "^4.3.0",
|
|
19133
19109
|
"@smithy/util-body-length-browser": "^4.2.0",
|
|
19134
19110
|
"@smithy/util-body-length-node": "^4.2.1",
|
|
19135
|
-
"@smithy/util-defaults-mode-browser": "^4.3.
|
|
19136
|
-
"@smithy/util-defaults-mode-node": "^4.2.
|
|
19137
|
-
"@smithy/util-endpoints": "^3.2.
|
|
19138
|
-
"@smithy/util-middleware": "^4.2.
|
|
19139
|
-
"@smithy/util-retry": "^4.2.
|
|
19111
|
+
"@smithy/util-defaults-mode-browser": "^4.3.5",
|
|
19112
|
+
"@smithy/util-defaults-mode-node": "^4.2.7",
|
|
19113
|
+
"@smithy/util-endpoints": "^3.2.4",
|
|
19114
|
+
"@smithy/util-middleware": "^4.2.4",
|
|
19115
|
+
"@smithy/util-retry": "^4.2.4",
|
|
19140
19116
|
"@smithy/util-utf8": "^4.2.0",
|
|
19141
19117
|
tslib: "^2.6.2"
|
|
19142
19118
|
},
|
|
@@ -19338,8 +19314,8 @@ var init_ruleset = __esm({
|
|
|
19338
19314
|
f = "tree";
|
|
19339
19315
|
g = "PartitionResult";
|
|
19340
19316
|
h = "getAttr";
|
|
19341
|
-
i = { [u]: false, "type": "
|
|
19342
|
-
j = { [u]: true, "default": false, "type": "
|
|
19317
|
+
i = { [u]: false, "type": "string" };
|
|
19318
|
+
j = { [u]: true, "default": false, "type": "boolean" };
|
|
19343
19319
|
k = { [x]: "Endpoint" };
|
|
19344
19320
|
l = { [v]: c, [w]: [{ [x]: "UseFIPS" }, true] };
|
|
19345
19321
|
m = { [v]: c, [w]: [{ [x]: "UseDualStack" }, true] };
|
|
@@ -19545,11 +19521,38 @@ var init_runtimeConfig = __esm({
|
|
|
19545
19521
|
}
|
|
19546
19522
|
});
|
|
19547
19523
|
|
|
19524
|
+
// node_modules/@aws-sdk/region-config-resolver/dist-cjs/regionConfig/stsRegionDefaultResolver.js
|
|
19525
|
+
var require_stsRegionDefaultResolver = __commonJS({
|
|
19526
|
+
"node_modules/@aws-sdk/region-config-resolver/dist-cjs/regionConfig/stsRegionDefaultResolver.js"(exports2) {
|
|
19527
|
+
"use strict";
|
|
19528
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
19529
|
+
exports2.warning = void 0;
|
|
19530
|
+
exports2.stsRegionDefaultResolver = stsRegionDefaultResolver2;
|
|
19531
|
+
var config_resolver_1 = require_dist_cjs39();
|
|
19532
|
+
var node_config_provider_1 = require_dist_cjs43();
|
|
19533
|
+
function stsRegionDefaultResolver2(loaderConfig = {}) {
|
|
19534
|
+
return (0, node_config_provider_1.loadConfig)({
|
|
19535
|
+
...config_resolver_1.NODE_REGION_CONFIG_OPTIONS,
|
|
19536
|
+
async default() {
|
|
19537
|
+
if (!exports2.warning.silence) {
|
|
19538
|
+
console.warn("@aws-sdk - WARN - default STS region of us-east-1 used. See @aws-sdk/credential-providers README and set a region explicitly.");
|
|
19539
|
+
}
|
|
19540
|
+
return "us-east-1";
|
|
19541
|
+
}
|
|
19542
|
+
}, { ...config_resolver_1.NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig });
|
|
19543
|
+
}
|
|
19544
|
+
exports2.warning = {
|
|
19545
|
+
silence: false
|
|
19546
|
+
};
|
|
19547
|
+
}
|
|
19548
|
+
});
|
|
19549
|
+
|
|
19548
19550
|
// node_modules/@aws-sdk/region-config-resolver/dist-cjs/index.js
|
|
19549
19551
|
var require_dist_cjs55 = __commonJS({
|
|
19550
19552
|
"node_modules/@aws-sdk/region-config-resolver/dist-cjs/index.js"(exports2) {
|
|
19551
19553
|
"use strict";
|
|
19552
19554
|
var configResolver = require_dist_cjs39();
|
|
19555
|
+
var stsRegionDefaultResolver2 = require_stsRegionDefaultResolver();
|
|
19553
19556
|
var getAwsRegionExtensionConfiguration3 = (runtimeConfig) => {
|
|
19554
19557
|
return {
|
|
19555
19558
|
setRegion(region) {
|
|
@@ -19597,6 +19600,14 @@ var require_dist_cjs55 = __commonJS({
|
|
|
19597
19600
|
});
|
|
19598
19601
|
exports2.getAwsRegionExtensionConfiguration = getAwsRegionExtensionConfiguration3;
|
|
19599
19602
|
exports2.resolveAwsRegionExtensionConfiguration = resolveAwsRegionExtensionConfiguration3;
|
|
19603
|
+
Object.keys(stsRegionDefaultResolver2).forEach(function(k3) {
|
|
19604
|
+
if (k3 !== "default" && !Object.prototype.hasOwnProperty.call(exports2, k3)) Object.defineProperty(exports2, k3, {
|
|
19605
|
+
enumerable: true,
|
|
19606
|
+
get: function() {
|
|
19607
|
+
return stsRegionDefaultResolver2[k3];
|
|
19608
|
+
}
|
|
19609
|
+
});
|
|
19610
|
+
});
|
|
19600
19611
|
}
|
|
19601
19612
|
});
|
|
19602
19613
|
|
|
@@ -20294,7 +20305,7 @@ var require_dist_cjs56 = __commonJS({
|
|
|
20294
20305
|
var httpAuthSchemes = (init_httpAuthSchemes2(), __toCommonJS(httpAuthSchemes_exports));
|
|
20295
20306
|
var propertyProvider = require_dist_cjs24();
|
|
20296
20307
|
var sharedIniFileLoader = require_dist_cjs42();
|
|
20297
|
-
var
|
|
20308
|
+
var fs7 = require("fs");
|
|
20298
20309
|
var fromEnvSigningName = ({ logger: logger2, signingName } = {}) => async () => {
|
|
20299
20310
|
logger2?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
|
|
20300
20311
|
if (!signingName) {
|
|
@@ -20312,9 +20323,11 @@ var require_dist_cjs56 = __commonJS({
|
|
|
20312
20323
|
var REFRESH_MESSAGE = `To refresh this SSO session run 'aws sso login' with the corresponding profile.`;
|
|
20313
20324
|
var getSsoOidcClient = async (ssoRegion, init = {}) => {
|
|
20314
20325
|
const { SSOOIDCClient: SSOOIDCClient2 } = await Promise.resolve().then(() => (init_sso_oidc(), sso_oidc_exports));
|
|
20326
|
+
const coalesce = (prop) => init.clientConfig?.[prop] ?? init.parentClientConfig?.[prop];
|
|
20315
20327
|
const ssoOidcClient = new SSOOIDCClient2(Object.assign({}, init.clientConfig ?? {}, {
|
|
20316
20328
|
region: ssoRegion ?? init.clientConfig?.region,
|
|
20317
|
-
logger:
|
|
20329
|
+
logger: coalesce("logger"),
|
|
20330
|
+
userAgentAppId: coalesce("userAgentAppId")
|
|
20318
20331
|
}));
|
|
20319
20332
|
return ssoOidcClient;
|
|
20320
20333
|
};
|
|
@@ -20338,7 +20351,7 @@ var require_dist_cjs56 = __commonJS({
|
|
|
20338
20351
|
throw new propertyProvider.TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
|
|
20339
20352
|
}
|
|
20340
20353
|
};
|
|
20341
|
-
var { writeFile } =
|
|
20354
|
+
var { writeFile } = fs7.promises;
|
|
20342
20355
|
var writeSSOTokenToFile = (id, ssoToken) => {
|
|
20343
20356
|
const tokenFilepath = sharedIniFileLoader.getSSOTokenFilepath(id);
|
|
20344
20357
|
const tokenString = JSON.stringify(ssoToken, null, 2);
|
|
@@ -20517,7 +20530,7 @@ var require_package3 = __commonJS({
|
|
|
20517
20530
|
module2.exports = {
|
|
20518
20531
|
name: "@aws-sdk/client-sso",
|
|
20519
20532
|
description: "AWS SDK for JavaScript Sso Client for Node.js, Browser and React Native",
|
|
20520
|
-
version: "3.
|
|
20533
|
+
version: "3.922.0",
|
|
20521
20534
|
scripts: {
|
|
20522
20535
|
build: "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
20523
20536
|
"build:cjs": "node ../../scripts/compilation/inline client-sso",
|
|
@@ -20536,40 +20549,40 @@ var require_package3 = __commonJS({
|
|
|
20536
20549
|
dependencies: {
|
|
20537
20550
|
"@aws-crypto/sha256-browser": "5.2.0",
|
|
20538
20551
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
20539
|
-
"@aws-sdk/core": "3.
|
|
20540
|
-
"@aws-sdk/middleware-host-header": "3.
|
|
20541
|
-
"@aws-sdk/middleware-logger": "3.
|
|
20542
|
-
"@aws-sdk/middleware-recursion-detection": "3.
|
|
20543
|
-
"@aws-sdk/middleware-user-agent": "3.
|
|
20544
|
-
"@aws-sdk/region-config-resolver": "3.
|
|
20545
|
-
"@aws-sdk/types": "3.
|
|
20546
|
-
"@aws-sdk/util-endpoints": "3.
|
|
20547
|
-
"@aws-sdk/util-user-agent-browser": "3.
|
|
20548
|
-
"@aws-sdk/util-user-agent-node": "3.
|
|
20549
|
-
"@smithy/config-resolver": "^4.4.
|
|
20550
|
-
"@smithy/core": "^3.17.
|
|
20551
|
-
"@smithy/fetch-http-handler": "^5.3.
|
|
20552
|
-
"@smithy/hash-node": "^4.2.
|
|
20553
|
-
"@smithy/invalid-dependency": "^4.2.
|
|
20554
|
-
"@smithy/middleware-content-length": "^4.2.
|
|
20555
|
-
"@smithy/middleware-endpoint": "^4.3.
|
|
20556
|
-
"@smithy/middleware-retry": "^4.4.
|
|
20557
|
-
"@smithy/middleware-serde": "^4.2.
|
|
20558
|
-
"@smithy/middleware-stack": "^4.2.
|
|
20559
|
-
"@smithy/node-config-provider": "^4.3.
|
|
20560
|
-
"@smithy/node-http-handler": "^4.4.
|
|
20561
|
-
"@smithy/protocol-http": "^5.3.
|
|
20562
|
-
"@smithy/smithy-client": "^4.9.
|
|
20563
|
-
"@smithy/types": "^4.8.
|
|
20564
|
-
"@smithy/url-parser": "^4.2.
|
|
20552
|
+
"@aws-sdk/core": "3.922.0",
|
|
20553
|
+
"@aws-sdk/middleware-host-header": "3.922.0",
|
|
20554
|
+
"@aws-sdk/middleware-logger": "3.922.0",
|
|
20555
|
+
"@aws-sdk/middleware-recursion-detection": "3.922.0",
|
|
20556
|
+
"@aws-sdk/middleware-user-agent": "3.922.0",
|
|
20557
|
+
"@aws-sdk/region-config-resolver": "3.922.0",
|
|
20558
|
+
"@aws-sdk/types": "3.922.0",
|
|
20559
|
+
"@aws-sdk/util-endpoints": "3.922.0",
|
|
20560
|
+
"@aws-sdk/util-user-agent-browser": "3.922.0",
|
|
20561
|
+
"@aws-sdk/util-user-agent-node": "3.922.0",
|
|
20562
|
+
"@smithy/config-resolver": "^4.4.1",
|
|
20563
|
+
"@smithy/core": "^3.17.2",
|
|
20564
|
+
"@smithy/fetch-http-handler": "^5.3.5",
|
|
20565
|
+
"@smithy/hash-node": "^4.2.4",
|
|
20566
|
+
"@smithy/invalid-dependency": "^4.2.4",
|
|
20567
|
+
"@smithy/middleware-content-length": "^4.2.4",
|
|
20568
|
+
"@smithy/middleware-endpoint": "^4.3.6",
|
|
20569
|
+
"@smithy/middleware-retry": "^4.4.6",
|
|
20570
|
+
"@smithy/middleware-serde": "^4.2.4",
|
|
20571
|
+
"@smithy/middleware-stack": "^4.2.4",
|
|
20572
|
+
"@smithy/node-config-provider": "^4.3.4",
|
|
20573
|
+
"@smithy/node-http-handler": "^4.4.4",
|
|
20574
|
+
"@smithy/protocol-http": "^5.3.4",
|
|
20575
|
+
"@smithy/smithy-client": "^4.9.2",
|
|
20576
|
+
"@smithy/types": "^4.8.1",
|
|
20577
|
+
"@smithy/url-parser": "^4.2.4",
|
|
20565
20578
|
"@smithy/util-base64": "^4.3.0",
|
|
20566
20579
|
"@smithy/util-body-length-browser": "^4.2.0",
|
|
20567
20580
|
"@smithy/util-body-length-node": "^4.2.1",
|
|
20568
|
-
"@smithy/util-defaults-mode-browser": "^4.3.
|
|
20569
|
-
"@smithy/util-defaults-mode-node": "^4.2.
|
|
20570
|
-
"@smithy/util-endpoints": "^3.2.
|
|
20571
|
-
"@smithy/util-middleware": "^4.2.
|
|
20572
|
-
"@smithy/util-retry": "^4.2.
|
|
20581
|
+
"@smithy/util-defaults-mode-browser": "^4.3.5",
|
|
20582
|
+
"@smithy/util-defaults-mode-node": "^4.2.7",
|
|
20583
|
+
"@smithy/util-endpoints": "^3.2.4",
|
|
20584
|
+
"@smithy/util-middleware": "^4.2.4",
|
|
20585
|
+
"@smithy/util-retry": "^4.2.4",
|
|
20573
20586
|
"@smithy/util-utf8": "^4.2.0",
|
|
20574
20587
|
tslib: "^2.6.2"
|
|
20575
20588
|
},
|
|
@@ -20633,8 +20646,8 @@ var require_ruleset = __commonJS({
|
|
|
20633
20646
|
var f3 = "tree";
|
|
20634
20647
|
var g3 = "PartitionResult";
|
|
20635
20648
|
var h3 = "getAttr";
|
|
20636
|
-
var i3 = { [u3]: false, "type": "
|
|
20637
|
-
var j3 = { [u3]: true, "default": false, "type": "
|
|
20649
|
+
var i3 = { [u3]: false, "type": "string" };
|
|
20650
|
+
var j3 = { [u3]: true, "default": false, "type": "boolean" };
|
|
20638
20651
|
var k3 = { [x3]: "Endpoint" };
|
|
20639
20652
|
var l3 = { [v3]: c3, [w3]: [{ [x3]: "UseFIPS" }, true] };
|
|
20640
20653
|
var m3 = { [v3]: c3, [w3]: [{ [x3]: "UseDualStack" }, true] };
|
|
@@ -21314,7 +21327,8 @@ var require_dist_cjs58 = __commonJS({
|
|
|
21314
21327
|
});
|
|
21315
21328
|
const sso = ssoClient || new SSOClient(Object.assign({}, clientConfig ?? {}, {
|
|
21316
21329
|
logger: clientConfig?.logger ?? parentClientConfig?.logger,
|
|
21317
|
-
region: clientConfig?.region ?? ssoRegion
|
|
21330
|
+
region: clientConfig?.region ?? ssoRegion,
|
|
21331
|
+
userAgentAppId: clientConfig?.userAgentAppId ?? parentClientConfig?.userAgentAppId
|
|
21318
21332
|
}));
|
|
21319
21333
|
let ssoResp;
|
|
21320
21334
|
try {
|
|
@@ -21542,8 +21556,8 @@ var init_ruleset2 = __esm({
|
|
|
21542
21556
|
j2 = "tree";
|
|
21543
21557
|
k2 = "error";
|
|
21544
21558
|
l2 = "getAttr";
|
|
21545
|
-
m2 = { [F]: false, [G]: "
|
|
21546
|
-
n2 = { [F]: true, "default": false, [G]: "
|
|
21559
|
+
m2 = { [F]: false, [G]: "string" };
|
|
21560
|
+
n2 = { [F]: true, "default": false, [G]: "boolean" };
|
|
21547
21561
|
o2 = { [J]: "Endpoint" };
|
|
21548
21562
|
p2 = { [H]: "isSet", [I]: [{ [J]: "Region" }] };
|
|
21549
21563
|
q2 = { [J]: "Region" };
|
|
@@ -22539,13 +22553,13 @@ var init_models2 = __esm({
|
|
|
22539
22553
|
});
|
|
22540
22554
|
|
|
22541
22555
|
// node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/defaultStsRoleAssumers.js
|
|
22542
|
-
var
|
|
22556
|
+
var import_region_config_resolver3, getAccountIdFromAssumedRoleUser, resolveRegion, getDefaultRoleAssumer, getDefaultRoleAssumerWithWebIdentity, isH2;
|
|
22543
22557
|
var init_defaultStsRoleAssumers = __esm({
|
|
22544
22558
|
"node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/defaultStsRoleAssumers.js"() {
|
|
22545
22559
|
init_client();
|
|
22560
|
+
import_region_config_resolver3 = __toESM(require_dist_cjs55());
|
|
22546
22561
|
init_AssumeRoleCommand();
|
|
22547
22562
|
init_AssumeRoleWithWebIdentityCommand();
|
|
22548
|
-
ASSUME_ROLE_DEFAULT_REGION = "us-east-1";
|
|
22549
22563
|
getAccountIdFromAssumedRoleUser = (assumedRoleUser) => {
|
|
22550
22564
|
if (typeof assumedRoleUser?.Arn === "string") {
|
|
22551
22565
|
const arnComponents = assumedRoleUser.Arn.split(":");
|
|
@@ -22555,11 +22569,12 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
22555
22569
|
}
|
|
22556
22570
|
return void 0;
|
|
22557
22571
|
};
|
|
22558
|
-
resolveRegion = async (_region, _parentRegion, credentialProviderLogger) => {
|
|
22572
|
+
resolveRegion = async (_region, _parentRegion, credentialProviderLogger, loaderConfig = {}) => {
|
|
22559
22573
|
const region = typeof _region === "function" ? await _region() : _region;
|
|
22560
22574
|
const parentRegion = typeof _parentRegion === "function" ? await _parentRegion() : _parentRegion;
|
|
22561
|
-
|
|
22562
|
-
|
|
22575
|
+
const stsDefaultRegion = await (0, import_region_config_resolver3.stsRegionDefaultResolver)(loaderConfig)();
|
|
22576
|
+
credentialProviderLogger?.debug?.("@aws-sdk/client-sts::resolveRegion", "accepting first of:", `${region} (credential provider clientConfig)`, `${parentRegion} (contextual client)`, `${stsDefaultRegion} (STS default: AWS_REGION, profile region, or us-east-1)`);
|
|
22577
|
+
return region ?? parentRegion ?? stsDefaultRegion;
|
|
22563
22578
|
};
|
|
22564
22579
|
getDefaultRoleAssumer = (stsOptions, STSClient2) => {
|
|
22565
22580
|
let stsClient;
|
|
@@ -22567,11 +22582,15 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
22567
22582
|
return async (sourceCreds, params) => {
|
|
22568
22583
|
closureSourceCreds = sourceCreds;
|
|
22569
22584
|
if (!stsClient) {
|
|
22570
|
-
const { logger: logger2 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger } = stsOptions;
|
|
22571
|
-
const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger
|
|
22585
|
+
const { logger: logger2 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
|
|
22586
|
+
const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
|
|
22587
|
+
logger: logger2,
|
|
22588
|
+
profile
|
|
22589
|
+
});
|
|
22572
22590
|
const isCompatibleRequestHandler = !isH2(requestHandler);
|
|
22573
22591
|
stsClient = new STSClient2({
|
|
22574
22592
|
...stsOptions,
|
|
22593
|
+
userAgentAppId,
|
|
22575
22594
|
profile,
|
|
22576
22595
|
credentialDefaultProvider: () => async () => closureSourceCreds,
|
|
22577
22596
|
region: resolvedRegion,
|
|
@@ -22600,11 +22619,15 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
22600
22619
|
let stsClient;
|
|
22601
22620
|
return async (params) => {
|
|
22602
22621
|
if (!stsClient) {
|
|
22603
|
-
const { logger: logger2 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger } = stsOptions;
|
|
22604
|
-
const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger
|
|
22622
|
+
const { logger: logger2 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
|
|
22623
|
+
const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
|
|
22624
|
+
logger: logger2,
|
|
22625
|
+
profile
|
|
22626
|
+
});
|
|
22605
22627
|
const isCompatibleRequestHandler = !isH2(requestHandler);
|
|
22606
22628
|
stsClient = new STSClient2({
|
|
22607
22629
|
...stsOptions,
|
|
22630
|
+
userAgentAppId,
|
|
22608
22631
|
profile,
|
|
22609
22632
|
region: resolvedRegion,
|
|
22610
22633
|
requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
|
|
@@ -22863,7 +22886,7 @@ var require_fromTokenFile = __commonJS({
|
|
|
22863
22886
|
var ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE";
|
|
22864
22887
|
var ENV_ROLE_ARN = "AWS_ROLE_ARN";
|
|
22865
22888
|
var ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME";
|
|
22866
|
-
var fromTokenFile = (init = {}) => async () => {
|
|
22889
|
+
var fromTokenFile = (init = {}) => async (awsIdentityProperties) => {
|
|
22867
22890
|
init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
|
|
22868
22891
|
const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE];
|
|
22869
22892
|
const roleArn = init?.roleArn ?? process.env[ENV_ROLE_ARN];
|
|
@@ -22878,7 +22901,7 @@ var require_fromTokenFile = __commonJS({
|
|
|
22878
22901
|
webIdentityToken: shared_ini_file_loader_1.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ?? (0, fs_1.readFileSync)(webIdentityTokenFile, { encoding: "ascii" }),
|
|
22879
22902
|
roleArn,
|
|
22880
22903
|
roleSessionName
|
|
22881
|
-
})();
|
|
22904
|
+
})(awsIdentityProperties);
|
|
22882
22905
|
if (webIdentityTokenFile === process.env[ENV_TOKEN_FILE]) {
|
|
22883
22906
|
(0, client_1.setCredentialFeature)(credentials, "CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN", "h");
|
|
22884
22907
|
}
|
|
@@ -23115,15 +23138,67 @@ var require_dist_cjs62 = __commonJS({
|
|
|
23115
23138
|
init.logger?.debug("@aws-sdk/credential-provider-node - remoteProvider::fromInstanceMetadata");
|
|
23116
23139
|
return fromInstanceMetadata(init);
|
|
23117
23140
|
};
|
|
23141
|
+
function memoizeChain(providers, treatAsExpired) {
|
|
23142
|
+
const chain = internalCreateChain(providers);
|
|
23143
|
+
let activeLock;
|
|
23144
|
+
let passiveLock;
|
|
23145
|
+
let credentials;
|
|
23146
|
+
const provider = async (options) => {
|
|
23147
|
+
if (options?.forceRefresh) {
|
|
23148
|
+
return await chain(options);
|
|
23149
|
+
}
|
|
23150
|
+
if (credentials?.expiration) {
|
|
23151
|
+
if (credentials?.expiration?.getTime() < Date.now()) {
|
|
23152
|
+
credentials = void 0;
|
|
23153
|
+
}
|
|
23154
|
+
}
|
|
23155
|
+
if (activeLock) {
|
|
23156
|
+
await activeLock;
|
|
23157
|
+
} else if (!credentials || treatAsExpired?.(credentials)) {
|
|
23158
|
+
if (credentials) {
|
|
23159
|
+
if (!passiveLock) {
|
|
23160
|
+
passiveLock = chain(options).then((c3) => {
|
|
23161
|
+
credentials = c3;
|
|
23162
|
+
passiveLock = void 0;
|
|
23163
|
+
});
|
|
23164
|
+
}
|
|
23165
|
+
} else {
|
|
23166
|
+
activeLock = chain(options).then((c3) => {
|
|
23167
|
+
credentials = c3;
|
|
23168
|
+
activeLock = void 0;
|
|
23169
|
+
});
|
|
23170
|
+
return provider(options);
|
|
23171
|
+
}
|
|
23172
|
+
}
|
|
23173
|
+
return credentials;
|
|
23174
|
+
};
|
|
23175
|
+
return provider;
|
|
23176
|
+
}
|
|
23177
|
+
var internalCreateChain = (providers) => async (awsIdentityProperties) => {
|
|
23178
|
+
let lastProviderError;
|
|
23179
|
+
for (const provider of providers) {
|
|
23180
|
+
try {
|
|
23181
|
+
return await provider(awsIdentityProperties);
|
|
23182
|
+
} catch (err) {
|
|
23183
|
+
lastProviderError = err;
|
|
23184
|
+
if (err?.tryNextLink) {
|
|
23185
|
+
continue;
|
|
23186
|
+
}
|
|
23187
|
+
throw err;
|
|
23188
|
+
}
|
|
23189
|
+
}
|
|
23190
|
+
throw lastProviderError;
|
|
23191
|
+
};
|
|
23118
23192
|
var multipleCredentialSourceWarningEmitted = false;
|
|
23119
|
-
var defaultProvider = (init = {}) =>
|
|
23120
|
-
|
|
23121
|
-
|
|
23122
|
-
|
|
23123
|
-
|
|
23124
|
-
if (
|
|
23125
|
-
|
|
23126
|
-
|
|
23193
|
+
var defaultProvider = (init = {}) => memoizeChain([
|
|
23194
|
+
async () => {
|
|
23195
|
+
const profile = init.profile ?? process.env[sharedIniFileLoader.ENV_PROFILE];
|
|
23196
|
+
if (profile) {
|
|
23197
|
+
const envStaticCredentialsAreSet = process.env[credentialProviderEnv.ENV_KEY] && process.env[credentialProviderEnv.ENV_SECRET];
|
|
23198
|
+
if (envStaticCredentialsAreSet) {
|
|
23199
|
+
if (!multipleCredentialSourceWarningEmitted) {
|
|
23200
|
+
const warnFn = init.logger?.warn && init.logger?.constructor?.name !== "NoOpLogger" ? init.logger.warn.bind(init.logger) : console.warn;
|
|
23201
|
+
warnFn(`@aws-sdk/credential-provider-node - defaultProvider::fromEnv WARNING:
|
|
23127
23202
|
Multiple credential sources detected:
|
|
23128
23203
|
Both AWS_PROFILE and the pair AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY static credentials are set.
|
|
23129
23204
|
This SDK will proceed with the AWS_PROFILE value.
|
|
@@ -23132,45 +23207,52 @@ var require_dist_cjs62 = __commonJS({
|
|
|
23132
23207
|
Please ensure that your environment only sets either the AWS_PROFILE or the
|
|
23133
23208
|
AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY pair.
|
|
23134
23209
|
`);
|
|
23135
|
-
|
|
23210
|
+
multipleCredentialSourceWarningEmitted = true;
|
|
23211
|
+
}
|
|
23136
23212
|
}
|
|
23213
|
+
throw new propertyProvider.CredentialsProviderError("AWS_PROFILE is set, skipping fromEnv provider.", {
|
|
23214
|
+
logger: init.logger,
|
|
23215
|
+
tryNextLink: true
|
|
23216
|
+
});
|
|
23137
23217
|
}
|
|
23138
|
-
|
|
23139
|
-
|
|
23140
|
-
|
|
23218
|
+
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromEnv");
|
|
23219
|
+
return credentialProviderEnv.fromEnv(init)();
|
|
23220
|
+
},
|
|
23221
|
+
async (awsIdentityProperties) => {
|
|
23222
|
+
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromSSO");
|
|
23223
|
+
const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
|
|
23224
|
+
if (!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession) {
|
|
23225
|
+
throw new propertyProvider.CredentialsProviderError("Skipping SSO provider in default chain (inputs do not include SSO fields).", { logger: init.logger });
|
|
23226
|
+
}
|
|
23227
|
+
const { fromSSO } = await Promise.resolve().then(() => __toESM(require_dist_cjs58()));
|
|
23228
|
+
return fromSSO(init)(awsIdentityProperties);
|
|
23229
|
+
},
|
|
23230
|
+
async (awsIdentityProperties) => {
|
|
23231
|
+
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromIni");
|
|
23232
|
+
const { fromIni } = await Promise.resolve().then(() => __toESM(require_dist_cjs61()));
|
|
23233
|
+
return fromIni(init)(awsIdentityProperties);
|
|
23234
|
+
},
|
|
23235
|
+
async (awsIdentityProperties) => {
|
|
23236
|
+
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromProcess");
|
|
23237
|
+
const { fromProcess } = await Promise.resolve().then(() => __toESM(require_dist_cjs59()));
|
|
23238
|
+
return fromProcess(init)(awsIdentityProperties);
|
|
23239
|
+
},
|
|
23240
|
+
async (awsIdentityProperties) => {
|
|
23241
|
+
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromTokenFile");
|
|
23242
|
+
const { fromTokenFile } = await Promise.resolve().then(() => __toESM(require_dist_cjs60()));
|
|
23243
|
+
return fromTokenFile(init)(awsIdentityProperties);
|
|
23244
|
+
},
|
|
23245
|
+
async () => {
|
|
23246
|
+
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::remoteProvider");
|
|
23247
|
+
return (await remoteProvider(init))();
|
|
23248
|
+
},
|
|
23249
|
+
async () => {
|
|
23250
|
+
throw new propertyProvider.CredentialsProviderError("Could not load credentials from any providers", {
|
|
23251
|
+
tryNextLink: false,
|
|
23252
|
+
logger: init.logger
|
|
23141
23253
|
});
|
|
23142
23254
|
}
|
|
23143
|
-
|
|
23144
|
-
return credentialProviderEnv.fromEnv(init)();
|
|
23145
|
-
}, async () => {
|
|
23146
|
-
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromSSO");
|
|
23147
|
-
const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
|
|
23148
|
-
if (!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession) {
|
|
23149
|
-
throw new propertyProvider.CredentialsProviderError("Skipping SSO provider in default chain (inputs do not include SSO fields).", { logger: init.logger });
|
|
23150
|
-
}
|
|
23151
|
-
const { fromSSO } = await Promise.resolve().then(() => __toESM(require_dist_cjs58()));
|
|
23152
|
-
return fromSSO(init)();
|
|
23153
|
-
}, async () => {
|
|
23154
|
-
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromIni");
|
|
23155
|
-
const { fromIni } = await Promise.resolve().then(() => __toESM(require_dist_cjs61()));
|
|
23156
|
-
return fromIni(init)();
|
|
23157
|
-
}, async () => {
|
|
23158
|
-
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromProcess");
|
|
23159
|
-
const { fromProcess } = await Promise.resolve().then(() => __toESM(require_dist_cjs59()));
|
|
23160
|
-
return fromProcess(init)();
|
|
23161
|
-
}, async () => {
|
|
23162
|
-
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromTokenFile");
|
|
23163
|
-
const { fromTokenFile } = await Promise.resolve().then(() => __toESM(require_dist_cjs60()));
|
|
23164
|
-
return fromTokenFile(init)();
|
|
23165
|
-
}, async () => {
|
|
23166
|
-
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::remoteProvider");
|
|
23167
|
-
return (await remoteProvider(init))();
|
|
23168
|
-
}, async () => {
|
|
23169
|
-
throw new propertyProvider.CredentialsProviderError("Could not load credentials from any providers", {
|
|
23170
|
-
tryNextLink: false,
|
|
23171
|
-
logger: init.logger
|
|
23172
|
-
});
|
|
23173
|
-
}), credentialsTreatedAsExpired, credentialsWillNeedRefresh);
|
|
23255
|
+
], credentialsTreatedAsExpired);
|
|
23174
23256
|
var credentialsWillNeedRefresh = (credentials) => credentials?.expiration !== void 0;
|
|
23175
23257
|
var credentialsTreatedAsExpired = (credentials) => credentials?.expiration !== void 0 && credentials.expiration.getTime() - Date.now() < 3e5;
|
|
23176
23258
|
exports2.credentialsTreatedAsExpired = credentialsTreatedAsExpired;
|
|
@@ -23311,7 +23393,7 @@ var require_dist_cjs64 = __commonJS({
|
|
|
23311
23393
|
streamEnded = true;
|
|
23312
23394
|
});
|
|
23313
23395
|
while (!generationEnded) {
|
|
23314
|
-
const value = await new Promise((
|
|
23396
|
+
const value = await new Promise((resolve5) => setTimeout(() => resolve5(records.shift()), 0));
|
|
23315
23397
|
if (value) {
|
|
23316
23398
|
yield value;
|
|
23317
23399
|
}
|
|
@@ -23357,8 +23439,8 @@ var require_ruleset2 = __commonJS({
|
|
|
23357
23439
|
var e3 = "endpoint";
|
|
23358
23440
|
var f3 = "tree";
|
|
23359
23441
|
var g3 = "PartitionResult";
|
|
23360
|
-
var h3 = { [s3]: false, "type": "
|
|
23361
|
-
var i3 = { [s3]: true, "default": false, "type": "
|
|
23442
|
+
var h3 = { [s3]: false, "type": "string" };
|
|
23443
|
+
var i3 = { [s3]: true, "default": false, "type": "boolean" };
|
|
23362
23444
|
var j3 = { [v3]: "Endpoint" };
|
|
23363
23445
|
var k3 = { [t3]: c3, [u3]: [{ [v3]: "UseFIPS" }, true] };
|
|
23364
23446
|
var l3 = { [t3]: c3, [u3]: [{ [v3]: "UseDualStack" }, true] };
|
|
@@ -23931,6 +24013,8 @@ var require_dist_cjs65 = __commonJS({
|
|
|
23931
24013
|
exports2.CitationLocation = void 0;
|
|
23932
24014
|
(function(CitationLocation) {
|
|
23933
24015
|
CitationLocation.visit = (value, visitor) => {
|
|
24016
|
+
if (value.web !== void 0)
|
|
24017
|
+
return visitor.web(value.web);
|
|
23934
24018
|
if (value.documentChar !== void 0)
|
|
23935
24019
|
return visitor.documentChar(value.documentChar);
|
|
23936
24020
|
if (value.documentPage !== void 0)
|
|
@@ -24083,6 +24167,9 @@ var require_dist_cjs65 = __commonJS({
|
|
|
24083
24167
|
ERROR: "error",
|
|
24084
24168
|
SUCCESS: "success"
|
|
24085
24169
|
};
|
|
24170
|
+
var ToolUseType = {
|
|
24171
|
+
SERVER_TOOL_USE: "server_tool_use"
|
|
24172
|
+
};
|
|
24086
24173
|
exports2.ContentBlock = void 0;
|
|
24087
24174
|
(function(ContentBlock) {
|
|
24088
24175
|
ContentBlock.visit = (value, visitor) => {
|
|
@@ -24162,6 +24249,8 @@ var require_dist_cjs65 = __commonJS({
|
|
|
24162
24249
|
Tool.visit = (value, visitor) => {
|
|
24163
24250
|
if (value.toolSpec !== void 0)
|
|
24164
24251
|
return visitor.toolSpec(value.toolSpec);
|
|
24252
|
+
if (value.systemTool !== void 0)
|
|
24253
|
+
return visitor.systemTool(value.systemTool);
|
|
24165
24254
|
if (value.cachePoint !== void 0)
|
|
24166
24255
|
return visitor.cachePoint(value.cachePoint);
|
|
24167
24256
|
return visitor._(value.$unknown[0], value.$unknown[1]);
|
|
@@ -24241,6 +24330,14 @@ var require_dist_cjs65 = __commonJS({
|
|
|
24241
24330
|
return visitor._(value.$unknown[0], value.$unknown[1]);
|
|
24242
24331
|
};
|
|
24243
24332
|
})(exports2.ReasoningContentBlockDelta || (exports2.ReasoningContentBlockDelta = {}));
|
|
24333
|
+
exports2.ToolResultBlockDelta = void 0;
|
|
24334
|
+
(function(ToolResultBlockDelta) {
|
|
24335
|
+
ToolResultBlockDelta.visit = (value, visitor) => {
|
|
24336
|
+
if (value.text !== void 0)
|
|
24337
|
+
return visitor.text(value.text);
|
|
24338
|
+
return visitor._(value.$unknown[0], value.$unknown[1]);
|
|
24339
|
+
};
|
|
24340
|
+
})(exports2.ToolResultBlockDelta || (exports2.ToolResultBlockDelta = {}));
|
|
24244
24341
|
exports2.ContentBlockDelta = void 0;
|
|
24245
24342
|
(function(ContentBlockDelta) {
|
|
24246
24343
|
ContentBlockDelta.visit = (value, visitor) => {
|
|
@@ -24248,6 +24345,8 @@ var require_dist_cjs65 = __commonJS({
|
|
|
24248
24345
|
return visitor.text(value.text);
|
|
24249
24346
|
if (value.toolUse !== void 0)
|
|
24250
24347
|
return visitor.toolUse(value.toolUse);
|
|
24348
|
+
if (value.toolResult !== void 0)
|
|
24349
|
+
return visitor.toolResult(value.toolResult);
|
|
24251
24350
|
if (value.reasoningContent !== void 0)
|
|
24252
24351
|
return visitor.reasoningContent(value.reasoningContent);
|
|
24253
24352
|
if (value.citation !== void 0)
|
|
@@ -24260,6 +24359,8 @@ var require_dist_cjs65 = __commonJS({
|
|
|
24260
24359
|
ContentBlockStart.visit = (value, visitor) => {
|
|
24261
24360
|
if (value.toolUse !== void 0)
|
|
24262
24361
|
return visitor.toolUse(value.toolUse);
|
|
24362
|
+
if (value.toolResult !== void 0)
|
|
24363
|
+
return visitor.toolResult(value.toolResult);
|
|
24263
24364
|
return visitor._(value.$unknown[0], value.$unknown[1]);
|
|
24264
24365
|
};
|
|
24265
24366
|
})(exports2.ContentBlockStart || (exports2.ContentBlockStart = {}));
|
|
@@ -24649,6 +24750,8 @@ var require_dist_cjs65 = __commonJS({
|
|
|
24649
24750
|
return { text: obj.text };
|
|
24650
24751
|
if (obj.toolUse !== void 0)
|
|
24651
24752
|
return { toolUse: obj.toolUse };
|
|
24753
|
+
if (obj.toolResult !== void 0)
|
|
24754
|
+
return { toolResult: obj.toolResult.map((item) => item) };
|
|
24652
24755
|
if (obj.reasoningContent !== void 0)
|
|
24653
24756
|
return { reasoningContent: smithyClient.SENSITIVE_STRING };
|
|
24654
24757
|
if (obj.citation !== void 0)
|
|
@@ -25744,6 +25847,7 @@ var require_dist_cjs65 = __commonJS({
|
|
|
25744
25847
|
var se_Tool = (input, context) => {
|
|
25745
25848
|
return exports2.Tool.visit(input, {
|
|
25746
25849
|
cachePoint: (value) => ({ cachePoint: smithyClient._json(value) }),
|
|
25850
|
+
systemTool: (value) => ({ systemTool: smithyClient._json(value) }),
|
|
25747
25851
|
toolSpec: (value) => ({ toolSpec: se_ToolSpecification(value) }),
|
|
25748
25852
|
_: (name14, value) => ({ [name14]: value })
|
|
25749
25853
|
});
|
|
@@ -25764,7 +25868,8 @@ var require_dist_cjs65 = __commonJS({
|
|
|
25764
25868
|
return smithyClient.take(input, {
|
|
25765
25869
|
content: (_2) => se_ToolResultContentBlocks(_2, context),
|
|
25766
25870
|
status: [],
|
|
25767
|
-
toolUseId: []
|
|
25871
|
+
toolUseId: [],
|
|
25872
|
+
type: []
|
|
25768
25873
|
});
|
|
25769
25874
|
};
|
|
25770
25875
|
var se_ToolResultContentBlock = (input, context) => {
|
|
@@ -25798,7 +25903,8 @@ var require_dist_cjs65 = __commonJS({
|
|
|
25798
25903
|
return smithyClient.take(input, {
|
|
25799
25904
|
input: (_2) => se_Document(_2),
|
|
25800
25905
|
name: [],
|
|
25801
|
-
toolUseId: []
|
|
25906
|
+
toolUseId: [],
|
|
25907
|
+
type: []
|
|
25802
25908
|
});
|
|
25803
25909
|
};
|
|
25804
25910
|
var se_VideoBlock = (input, context) => {
|
|
@@ -25906,6 +26012,11 @@ var require_dist_cjs65 = __commonJS({
|
|
|
25906
26012
|
if (smithyClient.expectString(output.text) !== void 0) {
|
|
25907
26013
|
return { text: smithyClient.expectString(output.text) };
|
|
25908
26014
|
}
|
|
26015
|
+
if (output.toolResult != null) {
|
|
26016
|
+
return {
|
|
26017
|
+
toolResult: smithyClient._json(output.toolResult)
|
|
26018
|
+
};
|
|
26019
|
+
}
|
|
25909
26020
|
if (output.toolUse != null) {
|
|
25910
26021
|
return {
|
|
25911
26022
|
toolUse: smithyClient._json(output.toolUse)
|
|
@@ -26251,7 +26362,8 @@ var require_dist_cjs65 = __commonJS({
|
|
|
26251
26362
|
return smithyClient.take(output, {
|
|
26252
26363
|
content: (_2) => de_ToolResultContentBlocks(_2, context),
|
|
26253
26364
|
status: smithyClient.expectString,
|
|
26254
|
-
toolUseId: smithyClient.expectString
|
|
26365
|
+
toolUseId: smithyClient.expectString,
|
|
26366
|
+
type: smithyClient.expectString
|
|
26255
26367
|
});
|
|
26256
26368
|
};
|
|
26257
26369
|
var de_ToolResultContentBlock = (output, context) => {
|
|
@@ -26290,7 +26402,8 @@ var require_dist_cjs65 = __commonJS({
|
|
|
26290
26402
|
return smithyClient.take(output, {
|
|
26291
26403
|
input: (_2) => de_Document(_2),
|
|
26292
26404
|
name: smithyClient.expectString,
|
|
26293
|
-
toolUseId: smithyClient.expectString
|
|
26405
|
+
toolUseId: smithyClient.expectString,
|
|
26406
|
+
type: smithyClient.expectString
|
|
26294
26407
|
});
|
|
26295
26408
|
};
|
|
26296
26409
|
var de_VideoBlock = (output, context) => {
|
|
@@ -26572,6 +26685,7 @@ var require_dist_cjs65 = __commonJS({
|
|
|
26572
26685
|
exports2.SystemContentBlockFilterSensitiveLog = SystemContentBlockFilterSensitiveLog;
|
|
26573
26686
|
exports2.ThrottlingException = ThrottlingException;
|
|
26574
26687
|
exports2.ToolResultStatus = ToolResultStatus;
|
|
26688
|
+
exports2.ToolUseType = ToolUseType;
|
|
26575
26689
|
exports2.Trace = Trace;
|
|
26576
26690
|
exports2.ValidationException = ValidationException;
|
|
26577
26691
|
exports2.VideoFormat = VideoFormat;
|
|
@@ -26591,16 +26705,16 @@ function prepareTools(mode) {
|
|
|
26591
26705
|
}
|
|
26592
26706
|
const toolWarnings = [];
|
|
26593
26707
|
const bedrockTools = [];
|
|
26594
|
-
for (const
|
|
26595
|
-
if (
|
|
26596
|
-
toolWarnings.push({ type: "unsupported-tool", tool:
|
|
26708
|
+
for (const tool4 of tools2) {
|
|
26709
|
+
if (tool4.type === "provider-defined") {
|
|
26710
|
+
toolWarnings.push({ type: "unsupported-tool", tool: tool4 });
|
|
26597
26711
|
} else {
|
|
26598
26712
|
bedrockTools.push({
|
|
26599
26713
|
toolSpec: {
|
|
26600
|
-
name:
|
|
26601
|
-
description:
|
|
26714
|
+
name: tool4.name,
|
|
26715
|
+
description: tool4.description,
|
|
26602
26716
|
inputSchema: {
|
|
26603
|
-
json:
|
|
26717
|
+
json: tool4.parameters
|
|
26604
26718
|
}
|
|
26605
26719
|
}
|
|
26606
26720
|
});
|
|
@@ -28990,8 +29104,8 @@ function checkAttemptCompleteRecovery(cleanedXmlString, validTools = []) {
|
|
|
28990
29104
|
function hasOtherToolTags(xmlString, validTools = []) {
|
|
28991
29105
|
const defaultTools = ["search", "query", "extract", "listFiles", "searchFiles", "implement", "attempt_completion"];
|
|
28992
29106
|
const toolsToCheck = validTools.length > 0 ? validTools : defaultTools;
|
|
28993
|
-
for (const
|
|
28994
|
-
if (
|
|
29107
|
+
for (const tool4 of toolsToCheck) {
|
|
29108
|
+
if (tool4 !== "attempt_completion" && xmlString.includes(`<${tool4}`)) {
|
|
28995
29109
|
return true;
|
|
28996
29110
|
}
|
|
28997
29111
|
}
|
|
@@ -29028,6 +29142,10 @@ function createTools(configOptions) {
|
|
|
29028
29142
|
if (configOptions.enableBash) {
|
|
29029
29143
|
tools2.bashTool = bashTool(configOptions);
|
|
29030
29144
|
}
|
|
29145
|
+
if (configOptions.allowEdit) {
|
|
29146
|
+
tools2.editTool = editTool(configOptions);
|
|
29147
|
+
tools2.createTool = createTool(configOptions);
|
|
29148
|
+
}
|
|
29031
29149
|
return tools2;
|
|
29032
29150
|
}
|
|
29033
29151
|
function parseXmlToolCallWithThinking(xmlString, validTools) {
|
|
@@ -33347,11 +33465,12 @@ var init_common2 = __esm({
|
|
|
33347
33465
|
pattern: external_exports.string().describe("AST pattern to search for. Use $NAME for variable names, $$$PARAMS for parameter lists, etc."),
|
|
33348
33466
|
path: external_exports.string().optional().default(".").describe("Path to search in"),
|
|
33349
33467
|
language: external_exports.string().optional().default("rust").describe("Programming language to use for parsing"),
|
|
33350
|
-
allow_tests: external_exports.boolean().optional().default(
|
|
33468
|
+
allow_tests: external_exports.boolean().optional().default(true).describe("Allow test files in search results")
|
|
33351
33469
|
});
|
|
33352
33470
|
extractSchema = external_exports.object({
|
|
33353
33471
|
targets: external_exports.string().optional().describe('File paths or symbols to extract from. Formats: "file.js" (whole file), "file.js:42" (line 42), "file.js:10-20" (lines 10-20), "file.js#funcName" (symbol). Multiple targets separated by spaces.'),
|
|
33354
|
-
input_content: external_exports.string().optional().describe("Text content to extract file paths from (alternative to targets)")
|
|
33472
|
+
input_content: external_exports.string().optional().describe("Text content to extract file paths from (alternative to targets)"),
|
|
33473
|
+
allow_tests: external_exports.boolean().optional().default(true).describe("Include test files in extraction results")
|
|
33355
33474
|
});
|
|
33356
33475
|
delegateSchema = external_exports.object({
|
|
33357
33476
|
task: external_exports.string().describe("The task to delegate to a subagent. Be specific about what needs to be accomplished.")
|
|
@@ -33478,7 +33597,7 @@ Parameters:
|
|
|
33478
33597
|
- pattern: (required) AST pattern to search for. Use $NAME for variable names, $$$PARAMS for parameter lists, etc.
|
|
33479
33598
|
- path: (optional, default: '.') Path to search in.
|
|
33480
33599
|
- language: (optional, default: 'rust') Programming language to use for parsing.
|
|
33481
|
-
- allow_tests: (optional, default:
|
|
33600
|
+
- allow_tests: (optional, default: true) Allow test files in search results (true/false).
|
|
33482
33601
|
Usage Example:
|
|
33483
33602
|
|
|
33484
33603
|
<examples>
|
|
@@ -33503,6 +33622,7 @@ Full file extraction should be the LAST RESORT! Always prefer search.
|
|
|
33503
33622
|
Parameters:
|
|
33504
33623
|
- targets: (required) File paths or symbols to extract from. Formats: "file.js" (whole file), "file.js:42" (code block at line 42), "file.js:10-20" (lines 10-20), "file.js#funcName" (specific symbol). Multiple targets separated by spaces.
|
|
33505
33624
|
- input_content: (optional) Text content to extract file paths from (alternative to targets for processing diffs/logs).
|
|
33625
|
+
- allow_tests: (optional, default: true) Include test files in extraction results.
|
|
33506
33626
|
|
|
33507
33627
|
Usage Example:
|
|
33508
33628
|
|
|
@@ -37324,10 +37444,10 @@ var init_esm3 = __esm({
|
|
|
37324
37444
|
* Return a void Promise that resolves once the stream ends.
|
|
37325
37445
|
*/
|
|
37326
37446
|
async promise() {
|
|
37327
|
-
return new Promise((
|
|
37447
|
+
return new Promise((resolve5, reject2) => {
|
|
37328
37448
|
this.on(DESTROYED, () => reject2(new Error("stream destroyed")));
|
|
37329
37449
|
this.on("error", (er) => reject2(er));
|
|
37330
|
-
this.on("end", () =>
|
|
37450
|
+
this.on("end", () => resolve5());
|
|
37331
37451
|
});
|
|
37332
37452
|
}
|
|
37333
37453
|
/**
|
|
@@ -37351,7 +37471,7 @@ var init_esm3 = __esm({
|
|
|
37351
37471
|
return Promise.resolve({ done: false, value: res });
|
|
37352
37472
|
if (this[EOF])
|
|
37353
37473
|
return stop();
|
|
37354
|
-
let
|
|
37474
|
+
let resolve5;
|
|
37355
37475
|
let reject2;
|
|
37356
37476
|
const onerr = (er) => {
|
|
37357
37477
|
this.off("data", ondata);
|
|
@@ -37365,19 +37485,19 @@ var init_esm3 = __esm({
|
|
|
37365
37485
|
this.off("end", onend);
|
|
37366
37486
|
this.off(DESTROYED, ondestroy);
|
|
37367
37487
|
this.pause();
|
|
37368
|
-
|
|
37488
|
+
resolve5({ value, done: !!this[EOF] });
|
|
37369
37489
|
};
|
|
37370
37490
|
const onend = () => {
|
|
37371
37491
|
this.off("error", onerr);
|
|
37372
37492
|
this.off("data", ondata);
|
|
37373
37493
|
this.off(DESTROYED, ondestroy);
|
|
37374
37494
|
stop();
|
|
37375
|
-
|
|
37495
|
+
resolve5({ done: true, value: void 0 });
|
|
37376
37496
|
};
|
|
37377
37497
|
const ondestroy = () => onerr(new Error("stream destroyed"));
|
|
37378
37498
|
return new Promise((res2, rej) => {
|
|
37379
37499
|
reject2 = rej;
|
|
37380
|
-
|
|
37500
|
+
resolve5 = res2;
|
|
37381
37501
|
this.once(DESTROYED, ondestroy);
|
|
37382
37502
|
this.once("error", onerr);
|
|
37383
37503
|
this.once("end", onend);
|
|
@@ -38357,9 +38477,9 @@ var init_esm4 = __esm({
|
|
|
38357
38477
|
if (this.#asyncReaddirInFlight) {
|
|
38358
38478
|
await this.#asyncReaddirInFlight;
|
|
38359
38479
|
} else {
|
|
38360
|
-
let
|
|
38480
|
+
let resolve5 = () => {
|
|
38361
38481
|
};
|
|
38362
|
-
this.#asyncReaddirInFlight = new Promise((res) =>
|
|
38482
|
+
this.#asyncReaddirInFlight = new Promise((res) => resolve5 = res);
|
|
38363
38483
|
try {
|
|
38364
38484
|
for (const e3 of await this.#fs.promises.readdir(fullpath, {
|
|
38365
38485
|
withFileTypes: true
|
|
@@ -38372,7 +38492,7 @@ var init_esm4 = __esm({
|
|
|
38372
38492
|
children.provisional = 0;
|
|
38373
38493
|
}
|
|
38374
38494
|
this.#asyncReaddirInFlight = void 0;
|
|
38375
|
-
|
|
38495
|
+
resolve5();
|
|
38376
38496
|
}
|
|
38377
38497
|
return children.slice(0, children.provisional);
|
|
38378
38498
|
}
|
|
@@ -38602,8 +38722,8 @@ var init_esm4 = __esm({
|
|
|
38602
38722
|
*
|
|
38603
38723
|
* @internal
|
|
38604
38724
|
*/
|
|
38605
|
-
constructor(cwd = process.cwd(), pathImpl,
|
|
38606
|
-
this.#fs = fsFromOption(
|
|
38725
|
+
constructor(cwd = process.cwd(), pathImpl, sep3, { nocase, childrenCacheSize = 16 * 1024, fs: fs7 = defaultFS } = {}) {
|
|
38726
|
+
this.#fs = fsFromOption(fs7);
|
|
38607
38727
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
38608
38728
|
cwd = (0, import_node_url.fileURLToPath)(cwd);
|
|
38609
38729
|
}
|
|
@@ -38613,7 +38733,7 @@ var init_esm4 = __esm({
|
|
|
38613
38733
|
this.#resolveCache = new ResolveCache();
|
|
38614
38734
|
this.#resolvePosixCache = new ResolveCache();
|
|
38615
38735
|
this.#children = new ChildrenCache(childrenCacheSize);
|
|
38616
|
-
const split = cwdPath.substring(this.rootPath.length).split(
|
|
38736
|
+
const split = cwdPath.substring(this.rootPath.length).split(sep3);
|
|
38617
38737
|
if (split.length === 1 && !split[0]) {
|
|
38618
38738
|
split.pop();
|
|
38619
38739
|
}
|
|
@@ -39161,8 +39281,8 @@ var init_esm4 = __esm({
|
|
|
39161
39281
|
/**
|
|
39162
39282
|
* @internal
|
|
39163
39283
|
*/
|
|
39164
|
-
newRoot(
|
|
39165
|
-
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
39284
|
+
newRoot(fs7) {
|
|
39285
|
+
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs7 });
|
|
39166
39286
|
}
|
|
39167
39287
|
/**
|
|
39168
39288
|
* Return true if the provided path string is an absolute path
|
|
@@ -39190,8 +39310,8 @@ var init_esm4 = __esm({
|
|
|
39190
39310
|
/**
|
|
39191
39311
|
* @internal
|
|
39192
39312
|
*/
|
|
39193
|
-
newRoot(
|
|
39194
|
-
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
39313
|
+
newRoot(fs7) {
|
|
39314
|
+
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs7 });
|
|
39195
39315
|
}
|
|
39196
39316
|
/**
|
|
39197
39317
|
* Return true if the provided path string is an absolute path
|
|
@@ -40384,6 +40504,20 @@ function createWrappedTools(baseTools) {
|
|
|
40384
40504
|
baseTools.bashTool.execute
|
|
40385
40505
|
);
|
|
40386
40506
|
}
|
|
40507
|
+
if (baseTools.editTool) {
|
|
40508
|
+
wrappedTools.editToolInstance = wrapToolWithEmitter(
|
|
40509
|
+
baseTools.editTool,
|
|
40510
|
+
"edit",
|
|
40511
|
+
baseTools.editTool.execute
|
|
40512
|
+
);
|
|
40513
|
+
}
|
|
40514
|
+
if (baseTools.createTool) {
|
|
40515
|
+
wrappedTools.createToolInstance = wrapToolWithEmitter(
|
|
40516
|
+
baseTools.createTool,
|
|
40517
|
+
"create",
|
|
40518
|
+
baseTools.createTool.execute
|
|
40519
|
+
);
|
|
40520
|
+
}
|
|
40387
40521
|
return wrappedTools;
|
|
40388
40522
|
}
|
|
40389
40523
|
var import_child_process6, import_util11, import_crypto3, import_events, import_fs2, import_fs3, import_path4, toolCallEmitter, activeToolExecutions, wrapToolWithEmitter, listFilesTool, searchFilesTool, listFilesToolInstance, searchFilesToolInstance;
|
|
@@ -40401,9 +40535,9 @@ var init_probeTool = __esm({
|
|
|
40401
40535
|
init_esm5();
|
|
40402
40536
|
toolCallEmitter = new import_events.EventEmitter();
|
|
40403
40537
|
activeToolExecutions = /* @__PURE__ */ new Map();
|
|
40404
|
-
wrapToolWithEmitter = (
|
|
40538
|
+
wrapToolWithEmitter = (tool4, toolName, baseExecute) => {
|
|
40405
40539
|
return {
|
|
40406
|
-
...
|
|
40540
|
+
...tool4,
|
|
40407
40541
|
// Spread schema, description etc.
|
|
40408
40542
|
execute: async (params) => {
|
|
40409
40543
|
const debug = process.env.DEBUG === "1";
|
|
@@ -40614,7 +40748,7 @@ function createMockProvider() {
|
|
|
40614
40748
|
provider: "mock",
|
|
40615
40749
|
// Mock the doGenerate method used by Vercel AI SDK
|
|
40616
40750
|
doGenerate: async ({ messages, tools: tools2 }) => {
|
|
40617
|
-
await new Promise((
|
|
40751
|
+
await new Promise((resolve5) => setTimeout(resolve5, 10));
|
|
40618
40752
|
return {
|
|
40619
40753
|
text: "This is a mock response for testing",
|
|
40620
40754
|
toolCalls: [],
|
|
@@ -52601,16 +52735,6 @@ var init_parser2 = __esm({
|
|
|
52601
52735
|
this.subgraph = this.RULE("subgraph", () => {
|
|
52602
52736
|
this.CONSUME(SubgraphKeyword);
|
|
52603
52737
|
this.OR([
|
|
52604
|
-
{
|
|
52605
|
-
ALT: () => {
|
|
52606
|
-
this.CONSUME(Identifier, { LABEL: "subgraphId" });
|
|
52607
|
-
this.OPTION(() => {
|
|
52608
|
-
this.CONSUME1(SquareOpen);
|
|
52609
|
-
this.SUBRULE(this.nodeContent);
|
|
52610
|
-
this.CONSUME1(SquareClose);
|
|
52611
|
-
});
|
|
52612
|
-
}
|
|
52613
|
-
},
|
|
52614
52738
|
{
|
|
52615
52739
|
ALT: () => {
|
|
52616
52740
|
this.CONSUME(QuotedString, { LABEL: "subgraphTitleQ" });
|
|
@@ -52622,6 +52746,33 @@ var init_parser2 = __esm({
|
|
|
52622
52746
|
this.SUBRULE2(this.nodeContent);
|
|
52623
52747
|
this.CONSUME2(SquareClose);
|
|
52624
52748
|
}
|
|
52749
|
+
},
|
|
52750
|
+
{
|
|
52751
|
+
ALT: () => {
|
|
52752
|
+
this.CONSUME1(Identifier, { LABEL: "subgraphIdOrFirstWord" });
|
|
52753
|
+
this.OPTION(() => {
|
|
52754
|
+
this.OR1([
|
|
52755
|
+
{
|
|
52756
|
+
ALT: () => {
|
|
52757
|
+
this.CONSUME1(SquareOpen);
|
|
52758
|
+
this.SUBRULE(this.nodeContent);
|
|
52759
|
+
this.CONSUME1(SquareClose);
|
|
52760
|
+
}
|
|
52761
|
+
},
|
|
52762
|
+
{
|
|
52763
|
+
ALT: () => {
|
|
52764
|
+
this.AT_LEAST_ONE(() => {
|
|
52765
|
+
this.OR2([
|
|
52766
|
+
{ ALT: () => this.CONSUME2(Identifier) },
|
|
52767
|
+
{ ALT: () => this.CONSUME(Text) },
|
|
52768
|
+
{ ALT: () => this.CONSUME(NumberLiteral) }
|
|
52769
|
+
]);
|
|
52770
|
+
});
|
|
52771
|
+
}
|
|
52772
|
+
}
|
|
52773
|
+
]);
|
|
52774
|
+
});
|
|
52775
|
+
}
|
|
52625
52776
|
}
|
|
52626
52777
|
]);
|
|
52627
52778
|
this.CONSUME(Newline);
|
|
@@ -53225,7 +53376,6 @@ var init_semantics = __esm({
|
|
|
53225
53376
|
const last2 = allChildren[allChildren.length - 1];
|
|
53226
53377
|
const isSlash = (t3) => t3.image === "/" || t3.image === "\\";
|
|
53227
53378
|
if (isSlash(first2) && isSlash(last2)) {
|
|
53228
|
-
continue;
|
|
53229
53379
|
}
|
|
53230
53380
|
}
|
|
53231
53381
|
const opens = ch.RoundOpen || [];
|
|
@@ -54019,16 +54169,19 @@ function mapFlowchartParserError(err, text) {
|
|
|
54019
54169
|
const subgraphIdx = lineStr.indexOf("subgraph");
|
|
54020
54170
|
if (subgraphIdx !== -1) {
|
|
54021
54171
|
const afterSubgraph = lineStr.slice(subgraphIdx + 8).trim();
|
|
54022
|
-
if (afterSubgraph && !afterSubgraph.startsWith('"') && !afterSubgraph.startsWith("'")
|
|
54023
|
-
|
|
54024
|
-
|
|
54025
|
-
|
|
54026
|
-
|
|
54027
|
-
|
|
54028
|
-
|
|
54029
|
-
|
|
54030
|
-
|
|
54031
|
-
|
|
54172
|
+
if (afterSubgraph && !afterSubgraph.startsWith('"') && !afterSubgraph.startsWith("'")) {
|
|
54173
|
+
const hasHazard = /[\[\](){}/:|"'\\]/.test(afterSubgraph);
|
|
54174
|
+
if (hasHazard) {
|
|
54175
|
+
return {
|
|
54176
|
+
line,
|
|
54177
|
+
column,
|
|
54178
|
+
severity: "error",
|
|
54179
|
+
code: "FL-SUBGRAPH-UNQUOTED-TITLE",
|
|
54180
|
+
message: "Subgraph title contains special characters; wrap it in quotes.",
|
|
54181
|
+
hint: 'Example: subgraph "Streams (inside Gateway)"',
|
|
54182
|
+
length: afterSubgraph.length
|
|
54183
|
+
};
|
|
54184
|
+
}
|
|
54032
54185
|
}
|
|
54033
54186
|
}
|
|
54034
54187
|
}
|
|
@@ -54726,11 +54879,11 @@ function validateFlowchart(text, options = {}) {
|
|
|
54726
54879
|
const byLine = /* @__PURE__ */ new Map();
|
|
54727
54880
|
const collect = (arr) => {
|
|
54728
54881
|
for (const e3 of arr || []) {
|
|
54729
|
-
if (e3 && e3.code === "FL-LABEL-PARENS-UNQUOTED") {
|
|
54882
|
+
if (e3 && (e3.code === "FL-LABEL-PARENS-UNQUOTED" || e3.code === "FL-LABEL-AT-IN-UNQUOTED")) {
|
|
54730
54883
|
const ln = e3.line ?? 0;
|
|
54731
54884
|
const col = e3.column ?? 1;
|
|
54732
54885
|
const list2 = byLine.get(ln) || [];
|
|
54733
|
-
list2.push(col);
|
|
54886
|
+
list2.push({ start: col, end: col });
|
|
54734
54887
|
byLine.set(ln, list2);
|
|
54735
54888
|
}
|
|
54736
54889
|
}
|
|
@@ -54739,33 +54892,91 @@ function validateFlowchart(text, options = {}) {
|
|
|
54739
54892
|
collect(errs);
|
|
54740
54893
|
const lines2 = text2.split(/\r?\n/);
|
|
54741
54894
|
for (let ii = 0; ii < lines2.length; ii++) {
|
|
54742
|
-
const
|
|
54743
|
-
if (!
|
|
54895
|
+
const raw = lines2[ii] || "";
|
|
54896
|
+
if (!raw.includes("[") || !raw.includes("]"))
|
|
54744
54897
|
continue;
|
|
54745
|
-
let
|
|
54746
|
-
|
|
54747
|
-
|
|
54748
|
-
|
|
54749
|
-
|
|
54750
|
-
const
|
|
54751
|
-
if (
|
|
54752
|
-
|
|
54753
|
-
|
|
54754
|
-
|
|
54755
|
-
|
|
54756
|
-
|
|
54757
|
-
|
|
54758
|
-
|
|
54759
|
-
|
|
54760
|
-
|
|
54761
|
-
const segEndCol = close2 + 1;
|
|
54762
|
-
const existing = byLine.get(ln2) || [];
|
|
54763
|
-
const covered = existing.some((c3) => c3 >= segStartCol && c3 <= segEndCol);
|
|
54764
|
-
if (!covered && !/^".*"$/.test(trimmed2) && (seg2.includes("(") || seg2.includes(")")) && !isSlashPair && !isParenWrapped) {
|
|
54765
|
-
errs.push({ line: ln2, column: segStartCol, severity: "error", code: "FL-LABEL-PARENS-UNQUOTED", message: "Parentheses inside an unquoted label are not supported by Mermaid.", hint: 'Wrap the label in quotes, e.g., A["Mark (X)"] \u2014 or replace ( and ) with HTML entities: ( and ).' });
|
|
54766
|
-
byLine.set(ln2, existing.concat([segStartCol]));
|
|
54898
|
+
let i3 = 0;
|
|
54899
|
+
const n3 = raw.length;
|
|
54900
|
+
let inQuote = false;
|
|
54901
|
+
let esc = false;
|
|
54902
|
+
while (i3 < n3) {
|
|
54903
|
+
const ch = raw[i3];
|
|
54904
|
+
if (inQuote) {
|
|
54905
|
+
if (esc) {
|
|
54906
|
+
esc = false;
|
|
54907
|
+
} else if (ch === "\\") {
|
|
54908
|
+
esc = true;
|
|
54909
|
+
} else if (ch === '"') {
|
|
54910
|
+
inQuote = false;
|
|
54911
|
+
}
|
|
54912
|
+
i3++;
|
|
54913
|
+
continue;
|
|
54767
54914
|
}
|
|
54768
|
-
|
|
54915
|
+
if (ch === '"') {
|
|
54916
|
+
inQuote = true;
|
|
54917
|
+
i3++;
|
|
54918
|
+
continue;
|
|
54919
|
+
}
|
|
54920
|
+
if (ch === "[") {
|
|
54921
|
+
let j3 = i3 + 1;
|
|
54922
|
+
let inQ = false;
|
|
54923
|
+
let esc2 = false;
|
|
54924
|
+
let depth = 1;
|
|
54925
|
+
while (j3 < n3 && depth > 0) {
|
|
54926
|
+
const cj = raw[j3];
|
|
54927
|
+
if (inQ) {
|
|
54928
|
+
if (esc2) {
|
|
54929
|
+
esc2 = false;
|
|
54930
|
+
} else if (cj === "\\") {
|
|
54931
|
+
esc2 = true;
|
|
54932
|
+
} else if (cj === '"') {
|
|
54933
|
+
inQ = false;
|
|
54934
|
+
}
|
|
54935
|
+
j3++;
|
|
54936
|
+
continue;
|
|
54937
|
+
}
|
|
54938
|
+
if (cj === '"') {
|
|
54939
|
+
inQ = true;
|
|
54940
|
+
j3++;
|
|
54941
|
+
continue;
|
|
54942
|
+
}
|
|
54943
|
+
if (cj === "[")
|
|
54944
|
+
depth++;
|
|
54945
|
+
else if (cj === "]")
|
|
54946
|
+
depth--;
|
|
54947
|
+
j3++;
|
|
54948
|
+
}
|
|
54949
|
+
if (depth === 0) {
|
|
54950
|
+
const startCol = i3 + 2;
|
|
54951
|
+
const endCol = j3;
|
|
54952
|
+
const seg = raw.slice(i3 + 1, j3 - 1);
|
|
54953
|
+
const trimmed = seg.trim();
|
|
54954
|
+
const ln = ii + 1;
|
|
54955
|
+
const lsp = trimmed.slice(0, 1), rsp = trimmed.slice(-1);
|
|
54956
|
+
const isSlashPair = (lsp === "/" || lsp === "\\") && (rsp === "/" || rsp === "\\");
|
|
54957
|
+
const isParenWrapped = lsp === "(" && rsp === ")";
|
|
54958
|
+
const isQuoted = /^"[\s\S]*"$/.test(trimmed);
|
|
54959
|
+
const existing = byLine.get(ln) || [];
|
|
54960
|
+
const covered = existing.some((r3) => !(endCol < r3.start || startCol > r3.end));
|
|
54961
|
+
const hasParens = seg.includes("(") || seg.includes(")");
|
|
54962
|
+
const hasAt = seg.includes("@");
|
|
54963
|
+
if (!covered && !isQuoted && !isParenWrapped && hasParens) {
|
|
54964
|
+
errs.push({ line: ln, column: startCol, severity: "error", code: "FL-LABEL-PARENS-UNQUOTED", message: "Parentheses inside an unquoted label are not supported by Mermaid.", hint: 'Wrap the label in quotes, e.g., A["Mark (X)"] \u2014 or replace ( and ) with HTML entities: ( and ).' });
|
|
54965
|
+
existing.push({ start: startCol, end: endCol });
|
|
54966
|
+
byLine.set(ln, existing);
|
|
54967
|
+
}
|
|
54968
|
+
if (!covered && !isQuoted && !isSlashPair && hasAt) {
|
|
54969
|
+
errs.push({ line: ln, column: startCol, severity: "error", code: "FL-LABEL-AT-IN-UNQUOTED", message: "'@' inside an unquoted label can be misparsed by Mermaid.", hint: 'Wrap the label in quotes, e.g., B["@probelabs/probe v0.6.0-rc149"]' });
|
|
54970
|
+
existing.push({ start: startCol, end: endCol });
|
|
54971
|
+
byLine.set(ln, existing);
|
|
54972
|
+
}
|
|
54973
|
+
i3 = j3;
|
|
54974
|
+
continue;
|
|
54975
|
+
} else {
|
|
54976
|
+
break;
|
|
54977
|
+
}
|
|
54978
|
+
}
|
|
54979
|
+
i3++;
|
|
54769
54980
|
}
|
|
54770
54981
|
}
|
|
54771
54982
|
}
|
|
@@ -66251,7 +66462,7 @@ var require_bk = __commonJS({
|
|
|
66251
66462
|
return xs;
|
|
66252
66463
|
}
|
|
66253
66464
|
function buildBlockGraph(g3, layering, root2, reverseSep) {
|
|
66254
|
-
var blockGraph = new Graph(), graphLabel = g3.graph(), sepFn =
|
|
66465
|
+
var blockGraph = new Graph(), graphLabel = g3.graph(), sepFn = sep3(graphLabel.nodesep, graphLabel.edgesep, reverseSep);
|
|
66255
66466
|
_2.forEach(layering, function(layer) {
|
|
66256
66467
|
var u3;
|
|
66257
66468
|
_2.forEach(layer, function(v3) {
|
|
@@ -66341,7 +66552,7 @@ var require_bk = __commonJS({
|
|
|
66341
66552
|
alignCoordinates(xss, smallestWidth);
|
|
66342
66553
|
return balance(xss, g3.graph().align);
|
|
66343
66554
|
}
|
|
66344
|
-
function
|
|
66555
|
+
function sep3(nodeSep, edgeSep, reverseSep) {
|
|
66345
66556
|
return function(g3, v3, w3) {
|
|
66346
66557
|
var vLabel = g3.node(v3);
|
|
66347
66558
|
var wLabel = g3.node(w3);
|
|
@@ -73635,7 +73846,7 @@ var require_compile = __commonJS({
|
|
|
73635
73846
|
const schOrFunc = root2.refs[ref];
|
|
73636
73847
|
if (schOrFunc)
|
|
73637
73848
|
return schOrFunc;
|
|
73638
|
-
let _sch =
|
|
73849
|
+
let _sch = resolve5.call(this, root2, ref);
|
|
73639
73850
|
if (_sch === void 0) {
|
|
73640
73851
|
const schema = (_a16 = root2.localRefs) === null || _a16 === void 0 ? void 0 : _a16[ref];
|
|
73641
73852
|
const { schemaId } = this.opts;
|
|
@@ -73662,7 +73873,7 @@ var require_compile = __commonJS({
|
|
|
73662
73873
|
function sameSchemaEnv(s1, s22) {
|
|
73663
73874
|
return s1.schema === s22.schema && s1.root === s22.root && s1.baseId === s22.baseId;
|
|
73664
73875
|
}
|
|
73665
|
-
function
|
|
73876
|
+
function resolve5(root2, ref) {
|
|
73666
73877
|
let sch;
|
|
73667
73878
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
73668
73879
|
ref = sch;
|
|
@@ -74237,7 +74448,7 @@ var require_fast_uri = __commonJS({
|
|
|
74237
74448
|
}
|
|
74238
74449
|
return uri;
|
|
74239
74450
|
}
|
|
74240
|
-
function
|
|
74451
|
+
function resolve5(baseURI, relativeURI, options) {
|
|
74241
74452
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
74242
74453
|
const resolved = resolveComponent(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
74243
74454
|
schemelessOptions.skipEscape = true;
|
|
@@ -74464,7 +74675,7 @@ var require_fast_uri = __commonJS({
|
|
|
74464
74675
|
var fastUri = {
|
|
74465
74676
|
SCHEMES,
|
|
74466
74677
|
normalize: normalize2,
|
|
74467
|
-
resolve:
|
|
74678
|
+
resolve: resolve5,
|
|
74468
74679
|
resolveComponent,
|
|
74469
74680
|
equal,
|
|
74470
74681
|
serialize,
|
|
@@ -78811,12 +79022,12 @@ var init_client2 = __esm({
|
|
|
78811
79022
|
const toolsResponse = await client.listTools();
|
|
78812
79023
|
const toolCount = toolsResponse?.tools?.length || 0;
|
|
78813
79024
|
if (toolsResponse && toolsResponse.tools) {
|
|
78814
|
-
for (const
|
|
78815
|
-
const qualifiedName = `${name14}_${
|
|
79025
|
+
for (const tool4 of toolsResponse.tools) {
|
|
79026
|
+
const qualifiedName = `${name14}_${tool4.name}`;
|
|
78816
79027
|
this.tools.set(qualifiedName, {
|
|
78817
|
-
...
|
|
79028
|
+
...tool4,
|
|
78818
79029
|
serverName: name14,
|
|
78819
|
-
originalName:
|
|
79030
|
+
originalName: tool4.name
|
|
78820
79031
|
});
|
|
78821
79032
|
if (this.debug) {
|
|
78822
79033
|
console.error(`[MCP DEBUG] Registered tool: ${qualifiedName}`);
|
|
@@ -78839,13 +79050,13 @@ var init_client2 = __esm({
|
|
|
78839
79050
|
* @param {Object} args - Tool arguments
|
|
78840
79051
|
*/
|
|
78841
79052
|
async callTool(toolName, args) {
|
|
78842
|
-
const
|
|
78843
|
-
if (!
|
|
79053
|
+
const tool4 = this.tools.get(toolName);
|
|
79054
|
+
if (!tool4) {
|
|
78844
79055
|
throw new Error(`Unknown tool: ${toolName}`);
|
|
78845
79056
|
}
|
|
78846
|
-
const clientInfo = this.clients.get(
|
|
79057
|
+
const clientInfo = this.clients.get(tool4.serverName);
|
|
78847
79058
|
if (!clientInfo) {
|
|
78848
|
-
throw new Error(`Server ${
|
|
79059
|
+
throw new Error(`Server ${tool4.serverName} not connected`);
|
|
78849
79060
|
}
|
|
78850
79061
|
try {
|
|
78851
79062
|
if (this.debug) {
|
|
@@ -78859,7 +79070,7 @@ var init_client2 = __esm({
|
|
|
78859
79070
|
});
|
|
78860
79071
|
const result = await Promise.race([
|
|
78861
79072
|
clientInfo.client.callTool({
|
|
78862
|
-
name:
|
|
79073
|
+
name: tool4.originalName,
|
|
78863
79074
|
arguments: args
|
|
78864
79075
|
}),
|
|
78865
79076
|
timeoutPromise
|
|
@@ -78882,11 +79093,11 @@ var init_client2 = __esm({
|
|
|
78882
79093
|
*/
|
|
78883
79094
|
getTools() {
|
|
78884
79095
|
const tools2 = {};
|
|
78885
|
-
for (const [name14,
|
|
79096
|
+
for (const [name14, tool4] of this.tools.entries()) {
|
|
78886
79097
|
tools2[name14] = {
|
|
78887
|
-
description:
|
|
78888
|
-
inputSchema:
|
|
78889
|
-
serverName:
|
|
79098
|
+
description: tool4.description,
|
|
79099
|
+
inputSchema: tool4.inputSchema,
|
|
79100
|
+
serverName: tool4.serverName
|
|
78890
79101
|
};
|
|
78891
79102
|
}
|
|
78892
79103
|
return tools2;
|
|
@@ -78897,10 +79108,10 @@ var init_client2 = __esm({
|
|
|
78897
79108
|
*/
|
|
78898
79109
|
getVercelTools() {
|
|
78899
79110
|
const tools2 = {};
|
|
78900
|
-
for (const [name14,
|
|
79111
|
+
for (const [name14, tool4] of this.tools.entries()) {
|
|
78901
79112
|
tools2[name14] = {
|
|
78902
|
-
description:
|
|
78903
|
-
inputSchema:
|
|
79113
|
+
description: tool4.description,
|
|
79114
|
+
inputSchema: tool4.inputSchema,
|
|
78904
79115
|
execute: async (args) => {
|
|
78905
79116
|
const result = await this.callTool(name14, args);
|
|
78906
79117
|
if (result.content && result.content[0]) {
|
|
@@ -78949,9 +79160,9 @@ var init_client2 = __esm({
|
|
|
78949
79160
|
});
|
|
78950
79161
|
|
|
78951
79162
|
// src/agent/mcp/xmlBridge.js
|
|
78952
|
-
function mcpToolToXmlDefinition(name14,
|
|
78953
|
-
const description =
|
|
78954
|
-
const inputSchema =
|
|
79163
|
+
function mcpToolToXmlDefinition(name14, tool4) {
|
|
79164
|
+
const description = tool4.description || "MCP tool";
|
|
79165
|
+
const inputSchema = tool4.inputSchema || tool4.parameters || {};
|
|
78955
79166
|
let paramDocs = "";
|
|
78956
79167
|
if (inputSchema.properties) {
|
|
78957
79168
|
paramDocs = "\n\nParameters (provide as JSON object):";
|
|
@@ -79130,8 +79341,8 @@ var init_xmlBridge = __esm({
|
|
|
79130
79341
|
const vercelTools = this.mcpManager.getVercelTools();
|
|
79131
79342
|
this.mcpTools = vercelTools;
|
|
79132
79343
|
const toolCount = Object.keys(vercelTools).length;
|
|
79133
|
-
for (const [name14,
|
|
79134
|
-
this.xmlDefinitions[name14] = mcpToolToXmlDefinition(name14,
|
|
79344
|
+
for (const [name14, tool4] of Object.entries(vercelTools)) {
|
|
79345
|
+
this.xmlDefinitions[name14] = mcpToolToXmlDefinition(name14, tool4);
|
|
79135
79346
|
}
|
|
79136
79347
|
if (toolCount === 0) {
|
|
79137
79348
|
console.error("[MCP INFO] MCP initialization complete: 0 tools loaded");
|
|
@@ -79178,14 +79389,14 @@ var init_xmlBridge = __esm({
|
|
|
79178
79389
|
console.error(`[MCP DEBUG] Executing MCP tool: ${toolName}`);
|
|
79179
79390
|
console.error(`[MCP DEBUG] Parameters:`, JSON.stringify(params, null, 2));
|
|
79180
79391
|
}
|
|
79181
|
-
const
|
|
79182
|
-
if (!
|
|
79392
|
+
const tool4 = this.mcpTools[toolName];
|
|
79393
|
+
if (!tool4) {
|
|
79183
79394
|
console.error(`[MCP ERROR] Unknown MCP tool: ${toolName}`);
|
|
79184
79395
|
console.error(`[MCP ERROR] Available tools: ${this.getToolNames().join(", ")}`);
|
|
79185
79396
|
throw new Error(`Unknown MCP tool: ${toolName}`);
|
|
79186
79397
|
}
|
|
79187
79398
|
try {
|
|
79188
|
-
const result = await
|
|
79399
|
+
const result = await tool4.execute(params);
|
|
79189
79400
|
if (this.debug) {
|
|
79190
79401
|
console.error(`[MCP DEBUG] Tool ${toolName} executed successfully`);
|
|
79191
79402
|
}
|
|
@@ -79239,19 +79450,633 @@ var init_mcp = __esm({
|
|
|
79239
79450
|
}
|
|
79240
79451
|
});
|
|
79241
79452
|
|
|
79453
|
+
// src/agent/RetryManager.js
|
|
79454
|
+
function isRetryableError(error2, retryableErrors = DEFAULT_RETRYABLE_ERRORS) {
|
|
79455
|
+
if (!error2) return false;
|
|
79456
|
+
const errorString = error2.toString().toLowerCase();
|
|
79457
|
+
const errorMessage = (error2.message || "").toLowerCase();
|
|
79458
|
+
const errorCode = (error2.code || "").toLowerCase();
|
|
79459
|
+
const errorType = (error2.type || "").toLowerCase();
|
|
79460
|
+
const statusCode = error2.statusCode || error2.status;
|
|
79461
|
+
for (const pattern of retryableErrors) {
|
|
79462
|
+
const lowerPattern = pattern.toLowerCase();
|
|
79463
|
+
if (errorString.includes(lowerPattern) || errorMessage.includes(lowerPattern) || errorCode.includes(lowerPattern) || errorType.includes(lowerPattern) || statusCode?.toString() === pattern) {
|
|
79464
|
+
return true;
|
|
79465
|
+
}
|
|
79466
|
+
}
|
|
79467
|
+
return false;
|
|
79468
|
+
}
|
|
79469
|
+
function extractErrorInfo(error2) {
|
|
79470
|
+
return {
|
|
79471
|
+
message: error2.message || error2.toString(),
|
|
79472
|
+
type: error2.type || error2.constructor.name,
|
|
79473
|
+
code: error2.code,
|
|
79474
|
+
statusCode: error2.statusCode || error2.status,
|
|
79475
|
+
provider: error2.provider,
|
|
79476
|
+
isRetryable: isRetryableError(error2)
|
|
79477
|
+
};
|
|
79478
|
+
}
|
|
79479
|
+
function sleep(ms) {
|
|
79480
|
+
return new Promise((resolve5) => setTimeout(resolve5, ms));
|
|
79481
|
+
}
|
|
79482
|
+
var DEFAULT_RETRYABLE_ERRORS, RetryManager;
|
|
79483
|
+
var init_RetryManager = __esm({
|
|
79484
|
+
"src/agent/RetryManager.js"() {
|
|
79485
|
+
"use strict";
|
|
79486
|
+
DEFAULT_RETRYABLE_ERRORS = [
|
|
79487
|
+
"Overloaded",
|
|
79488
|
+
"overloaded",
|
|
79489
|
+
"rate_limit",
|
|
79490
|
+
"rate limit",
|
|
79491
|
+
"429",
|
|
79492
|
+
"500",
|
|
79493
|
+
"502",
|
|
79494
|
+
"503",
|
|
79495
|
+
"504",
|
|
79496
|
+
"timeout",
|
|
79497
|
+
"ECONNRESET",
|
|
79498
|
+
"ETIMEDOUT",
|
|
79499
|
+
"ENOTFOUND",
|
|
79500
|
+
"api_error"
|
|
79501
|
+
];
|
|
79502
|
+
RetryManager = class {
|
|
79503
|
+
/**
|
|
79504
|
+
* Create a new RetryManager
|
|
79505
|
+
* @param {Object} options - Configuration options
|
|
79506
|
+
* @param {number} [options.maxRetries=3] - Maximum retry attempts
|
|
79507
|
+
* @param {number} [options.initialDelay=1000] - Initial delay in ms (1 second)
|
|
79508
|
+
* @param {number} [options.maxDelay=30000] - Maximum delay in ms (30 seconds)
|
|
79509
|
+
* @param {number} [options.backoffFactor=2] - Exponential backoff multiplier
|
|
79510
|
+
* @param {Array<string>} [options.retryableErrors] - List of retryable error patterns
|
|
79511
|
+
* @param {boolean} [options.debug=false] - Enable debug logging
|
|
79512
|
+
*/
|
|
79513
|
+
constructor(options = {}) {
|
|
79514
|
+
this.maxRetries = this._validateNumber(options.maxRetries, 3, "maxRetries", 0, 100);
|
|
79515
|
+
this.initialDelay = this._validateNumber(options.initialDelay, 1e3, "initialDelay", 0, 6e4);
|
|
79516
|
+
this.maxDelay = this._validateNumber(options.maxDelay, 3e4, "maxDelay", 0, 3e5);
|
|
79517
|
+
this.backoffFactor = this._validateNumber(options.backoffFactor, 2, "backoffFactor", 1, 10);
|
|
79518
|
+
this.retryableErrors = options.retryableErrors || DEFAULT_RETRYABLE_ERRORS;
|
|
79519
|
+
this.debug = options.debug ?? false;
|
|
79520
|
+
this.jitter = options.jitter ?? true;
|
|
79521
|
+
if (this.maxDelay < this.initialDelay) {
|
|
79522
|
+
throw new Error("maxDelay must be greater than or equal to initialDelay");
|
|
79523
|
+
}
|
|
79524
|
+
this.stats = {
|
|
79525
|
+
totalAttempts: 0,
|
|
79526
|
+
totalRetries: 0,
|
|
79527
|
+
successfulRetries: 0,
|
|
79528
|
+
failedRetries: 0
|
|
79529
|
+
};
|
|
79530
|
+
}
|
|
79531
|
+
/**
|
|
79532
|
+
* Validate a numeric parameter
|
|
79533
|
+
* @param {*} value - Value to validate
|
|
79534
|
+
* @param {number} defaultValue - Default if undefined
|
|
79535
|
+
* @param {string} name - Parameter name for error messages
|
|
79536
|
+
* @param {number} min - Minimum allowed value
|
|
79537
|
+
* @param {number} max - Maximum allowed value
|
|
79538
|
+
* @returns {number} - Validated number
|
|
79539
|
+
* @private
|
|
79540
|
+
*/
|
|
79541
|
+
_validateNumber(value, defaultValue, name14, min, max) {
|
|
79542
|
+
if (value === void 0 || value === null) {
|
|
79543
|
+
return defaultValue;
|
|
79544
|
+
}
|
|
79545
|
+
const num = Number(value);
|
|
79546
|
+
if (isNaN(num)) {
|
|
79547
|
+
throw new Error(`${name14} must be a number, got: ${value}`);
|
|
79548
|
+
}
|
|
79549
|
+
if (num < min || num > max) {
|
|
79550
|
+
throw new Error(`${name14} must be between ${min} and ${max}, got: ${num}`);
|
|
79551
|
+
}
|
|
79552
|
+
return num;
|
|
79553
|
+
}
|
|
79554
|
+
/**
|
|
79555
|
+
* Execute a function with retry logic
|
|
79556
|
+
* @param {Function} fn - Async function to execute
|
|
79557
|
+
* @param {Object} [context={}] - Context information for logging
|
|
79558
|
+
* @param {AbortSignal} [context.signal] - Optional abort signal for cancellation
|
|
79559
|
+
* @returns {Promise<*>} - Result from the function
|
|
79560
|
+
* @throws {Error} - If all retries are exhausted or operation is aborted
|
|
79561
|
+
*/
|
|
79562
|
+
async executeWithRetry(fn, context = {}) {
|
|
79563
|
+
let lastError = null;
|
|
79564
|
+
let currentDelay = this.initialDelay;
|
|
79565
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
79566
|
+
if (context.signal?.aborted) {
|
|
79567
|
+
const abortError = new Error("Operation aborted");
|
|
79568
|
+
abortError.name = "AbortError";
|
|
79569
|
+
throw abortError;
|
|
79570
|
+
}
|
|
79571
|
+
this.stats.totalAttempts++;
|
|
79572
|
+
try {
|
|
79573
|
+
if (this.debug && attempt > 0) {
|
|
79574
|
+
console.log(`[RetryManager] Retry attempt ${attempt}/${this.maxRetries}`, context);
|
|
79575
|
+
}
|
|
79576
|
+
const result = await fn();
|
|
79577
|
+
if (attempt > 0) {
|
|
79578
|
+
this.stats.successfulRetries++;
|
|
79579
|
+
if (this.debug) {
|
|
79580
|
+
console.log(`[RetryManager] \u2705 Retry successful on attempt ${attempt + 1}`, context);
|
|
79581
|
+
}
|
|
79582
|
+
}
|
|
79583
|
+
return result;
|
|
79584
|
+
} catch (error2) {
|
|
79585
|
+
lastError = error2;
|
|
79586
|
+
const errorInfo = extractErrorInfo(error2);
|
|
79587
|
+
const shouldRetry = isRetryableError(error2, this.retryableErrors);
|
|
79588
|
+
const hasRetriesLeft = attempt < this.maxRetries;
|
|
79589
|
+
if (this.debug) {
|
|
79590
|
+
console.log(`[RetryManager] \u274C Attempt ${attempt + 1}/${this.maxRetries + 1} failed:`, {
|
|
79591
|
+
...context,
|
|
79592
|
+
error: errorInfo,
|
|
79593
|
+
shouldRetry,
|
|
79594
|
+
hasRetriesLeft
|
|
79595
|
+
});
|
|
79596
|
+
}
|
|
79597
|
+
if (!shouldRetry) {
|
|
79598
|
+
if (this.debug) {
|
|
79599
|
+
console.log(`[RetryManager] Error is not retryable, failing immediately`, errorInfo);
|
|
79600
|
+
}
|
|
79601
|
+
throw error2;
|
|
79602
|
+
}
|
|
79603
|
+
if (!hasRetriesLeft) {
|
|
79604
|
+
this.stats.failedRetries++;
|
|
79605
|
+
if (this.debug) {
|
|
79606
|
+
console.log(`[RetryManager] Max retries (${this.maxRetries}) exhausted`, context);
|
|
79607
|
+
}
|
|
79608
|
+
throw error2;
|
|
79609
|
+
}
|
|
79610
|
+
this.stats.totalRetries++;
|
|
79611
|
+
let delayWithJitter = currentDelay;
|
|
79612
|
+
if (this.jitter) {
|
|
79613
|
+
const jitterAmount = currentDelay * 0.25;
|
|
79614
|
+
delayWithJitter = currentDelay + (Math.random() * jitterAmount * 2 - jitterAmount);
|
|
79615
|
+
}
|
|
79616
|
+
if (this.debug) {
|
|
79617
|
+
console.log(`[RetryManager] Waiting ${Math.round(delayWithJitter)}ms before retry...`);
|
|
79618
|
+
}
|
|
79619
|
+
await sleep(delayWithJitter);
|
|
79620
|
+
currentDelay = Math.min(currentDelay * this.backoffFactor, this.maxDelay);
|
|
79621
|
+
}
|
|
79622
|
+
}
|
|
79623
|
+
throw lastError;
|
|
79624
|
+
}
|
|
79625
|
+
/**
|
|
79626
|
+
* Check if an error is retryable
|
|
79627
|
+
* @param {Error} error - The error to check
|
|
79628
|
+
* @returns {boolean} - True if error should be retried
|
|
79629
|
+
*/
|
|
79630
|
+
isRetryable(error2) {
|
|
79631
|
+
return isRetryableError(error2, this.retryableErrors);
|
|
79632
|
+
}
|
|
79633
|
+
/**
|
|
79634
|
+
* Get retry statistics
|
|
79635
|
+
* @returns {Object} - Statistics object
|
|
79636
|
+
*/
|
|
79637
|
+
getStats() {
|
|
79638
|
+
return { ...this.stats };
|
|
79639
|
+
}
|
|
79640
|
+
/**
|
|
79641
|
+
* Reset statistics
|
|
79642
|
+
*/
|
|
79643
|
+
resetStats() {
|
|
79644
|
+
this.stats = {
|
|
79645
|
+
totalAttempts: 0,
|
|
79646
|
+
totalRetries: 0,
|
|
79647
|
+
successfulRetries: 0,
|
|
79648
|
+
failedRetries: 0
|
|
79649
|
+
};
|
|
79650
|
+
}
|
|
79651
|
+
};
|
|
79652
|
+
}
|
|
79653
|
+
});
|
|
79654
|
+
|
|
79655
|
+
// src/agent/FallbackManager.js
|
|
79656
|
+
function createFallbackManagerFromEnv(debug = false) {
|
|
79657
|
+
const fallbackProvidersEnv = process.env.FALLBACK_PROVIDERS;
|
|
79658
|
+
const fallbackModelsEnv = process.env.FALLBACK_MODELS;
|
|
79659
|
+
if (!fallbackProvidersEnv && !fallbackModelsEnv) {
|
|
79660
|
+
return null;
|
|
79661
|
+
}
|
|
79662
|
+
let providers = [];
|
|
79663
|
+
let models = [];
|
|
79664
|
+
let strategy = FALLBACK_STRATEGIES.ANY;
|
|
79665
|
+
if (fallbackProvidersEnv) {
|
|
79666
|
+
try {
|
|
79667
|
+
if (typeof fallbackProvidersEnv !== "string" || fallbackProvidersEnv.length > 1e4) {
|
|
79668
|
+
console.error("[FallbackManager] FALLBACK_PROVIDERS must be a valid JSON string under 10KB");
|
|
79669
|
+
return null;
|
|
79670
|
+
}
|
|
79671
|
+
const parsed = JSON.parse(fallbackProvidersEnv);
|
|
79672
|
+
if (!Array.isArray(parsed)) {
|
|
79673
|
+
console.error("[FallbackManager] FALLBACK_PROVIDERS must be a JSON array");
|
|
79674
|
+
return null;
|
|
79675
|
+
}
|
|
79676
|
+
providers = parsed;
|
|
79677
|
+
strategy = FALLBACK_STRATEGIES.CUSTOM;
|
|
79678
|
+
} catch (error2) {
|
|
79679
|
+
console.error("[FallbackManager] Failed to parse FALLBACK_PROVIDERS:", error2.message);
|
|
79680
|
+
return null;
|
|
79681
|
+
}
|
|
79682
|
+
}
|
|
79683
|
+
if (fallbackModelsEnv) {
|
|
79684
|
+
try {
|
|
79685
|
+
if (typeof fallbackModelsEnv !== "string" || fallbackModelsEnv.length > 1e4) {
|
|
79686
|
+
console.error("[FallbackManager] FALLBACK_MODELS must be a valid JSON string under 10KB");
|
|
79687
|
+
return null;
|
|
79688
|
+
}
|
|
79689
|
+
const parsed = JSON.parse(fallbackModelsEnv);
|
|
79690
|
+
if (!Array.isArray(parsed)) {
|
|
79691
|
+
console.error("[FallbackManager] FALLBACK_MODELS must be a JSON array");
|
|
79692
|
+
return null;
|
|
79693
|
+
}
|
|
79694
|
+
models = parsed;
|
|
79695
|
+
strategy = FALLBACK_STRATEGIES.SAME_PROVIDER;
|
|
79696
|
+
} catch (error2) {
|
|
79697
|
+
console.error("[FallbackManager] Failed to parse FALLBACK_MODELS:", error2.message);
|
|
79698
|
+
return null;
|
|
79699
|
+
}
|
|
79700
|
+
}
|
|
79701
|
+
const maxTotalAttempts = process.env.FALLBACK_MAX_TOTAL_ATTEMPTS ? (() => {
|
|
79702
|
+
const val = parseInt(process.env.FALLBACK_MAX_TOTAL_ATTEMPTS, 10);
|
|
79703
|
+
if (isNaN(val) || val < 1 || val > 100) {
|
|
79704
|
+
console.warn("[FallbackManager] FALLBACK_MAX_TOTAL_ATTEMPTS must be between 1 and 100, using default: 10");
|
|
79705
|
+
return 10;
|
|
79706
|
+
}
|
|
79707
|
+
return val;
|
|
79708
|
+
})() : 10;
|
|
79709
|
+
return new FallbackManager({
|
|
79710
|
+
strategy,
|
|
79711
|
+
providers,
|
|
79712
|
+
models,
|
|
79713
|
+
maxTotalAttempts,
|
|
79714
|
+
debug
|
|
79715
|
+
});
|
|
79716
|
+
}
|
|
79717
|
+
function buildFallbackProvidersFromEnv(options = {}) {
|
|
79718
|
+
const providers = [];
|
|
79719
|
+
const anthropicApiKey = process.env.ANTHROPIC_API_KEY || process.env.ANTHROPIC_AUTH_TOKEN;
|
|
79720
|
+
const openaiApiKey = process.env.OPENAI_API_KEY;
|
|
79721
|
+
const googleApiKey = process.env.GOOGLE_GENERATIVE_AI_API_KEY || process.env.GOOGLE_API_KEY;
|
|
79722
|
+
const awsAccessKeyId = process.env.AWS_ACCESS_KEY_ID;
|
|
79723
|
+
const awsSecretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
|
|
79724
|
+
const awsRegion = process.env.AWS_REGION;
|
|
79725
|
+
const awsApiKey = process.env.AWS_BEDROCK_API_KEY;
|
|
79726
|
+
const llmBaseUrl = process.env.LLM_BASE_URL;
|
|
79727
|
+
const anthropicApiUrl = process.env.ANTHROPIC_API_URL || process.env.ANTHROPIC_BASE_URL || llmBaseUrl;
|
|
79728
|
+
const openaiApiUrl = process.env.OPENAI_API_URL || llmBaseUrl;
|
|
79729
|
+
const googleApiUrl = process.env.GOOGLE_API_URL || llmBaseUrl;
|
|
79730
|
+
const awsBedrockBaseUrl = process.env.AWS_BEDROCK_BASE_URL || llmBaseUrl;
|
|
79731
|
+
const primaryProvider = options.primaryProvider?.toLowerCase();
|
|
79732
|
+
const primaryModel = options.primaryModel;
|
|
79733
|
+
if (primaryProvider === "anthropic" && anthropicApiKey) {
|
|
79734
|
+
providers.push({
|
|
79735
|
+
provider: "anthropic",
|
|
79736
|
+
apiKey: anthropicApiKey,
|
|
79737
|
+
...anthropicApiUrl && { baseURL: anthropicApiUrl },
|
|
79738
|
+
...primaryModel && { model: primaryModel }
|
|
79739
|
+
});
|
|
79740
|
+
} else if (primaryProvider === "openai" && openaiApiKey) {
|
|
79741
|
+
providers.push({
|
|
79742
|
+
provider: "openai",
|
|
79743
|
+
apiKey: openaiApiKey,
|
|
79744
|
+
...openaiApiUrl && { baseURL: openaiApiUrl },
|
|
79745
|
+
...primaryModel && { model: primaryModel }
|
|
79746
|
+
});
|
|
79747
|
+
} else if (primaryProvider === "google" && googleApiKey) {
|
|
79748
|
+
providers.push({
|
|
79749
|
+
provider: "google",
|
|
79750
|
+
apiKey: googleApiKey,
|
|
79751
|
+
...googleApiUrl && { baseURL: googleApiUrl },
|
|
79752
|
+
...primaryModel && { model: primaryModel }
|
|
79753
|
+
});
|
|
79754
|
+
} else if (primaryProvider === "bedrock" && (awsAccessKeyId && awsSecretAccessKey && awsRegion || awsApiKey)) {
|
|
79755
|
+
const config = { provider: "bedrock" };
|
|
79756
|
+
if (awsApiKey) {
|
|
79757
|
+
config.apiKey = awsApiKey;
|
|
79758
|
+
} else {
|
|
79759
|
+
config.accessKeyId = awsAccessKeyId;
|
|
79760
|
+
config.secretAccessKey = awsSecretAccessKey;
|
|
79761
|
+
config.region = awsRegion;
|
|
79762
|
+
if (process.env.AWS_SESSION_TOKEN) {
|
|
79763
|
+
config.sessionToken = process.env.AWS_SESSION_TOKEN;
|
|
79764
|
+
}
|
|
79765
|
+
}
|
|
79766
|
+
if (awsBedrockBaseUrl) config.baseURL = awsBedrockBaseUrl;
|
|
79767
|
+
if (primaryModel) config.model = primaryModel;
|
|
79768
|
+
providers.push(config);
|
|
79769
|
+
}
|
|
79770
|
+
if (anthropicApiKey && primaryProvider !== "anthropic") {
|
|
79771
|
+
providers.push({
|
|
79772
|
+
provider: "anthropic",
|
|
79773
|
+
apiKey: anthropicApiKey,
|
|
79774
|
+
...anthropicApiUrl && { baseURL: anthropicApiUrl }
|
|
79775
|
+
});
|
|
79776
|
+
}
|
|
79777
|
+
if (openaiApiKey && primaryProvider !== "openai") {
|
|
79778
|
+
providers.push({
|
|
79779
|
+
provider: "openai",
|
|
79780
|
+
apiKey: openaiApiKey,
|
|
79781
|
+
...openaiApiUrl && { baseURL: openaiApiUrl }
|
|
79782
|
+
});
|
|
79783
|
+
}
|
|
79784
|
+
if (googleApiKey && primaryProvider !== "google") {
|
|
79785
|
+
providers.push({
|
|
79786
|
+
provider: "google",
|
|
79787
|
+
apiKey: googleApiKey,
|
|
79788
|
+
...googleApiUrl && { baseURL: googleApiUrl }
|
|
79789
|
+
});
|
|
79790
|
+
}
|
|
79791
|
+
if ((awsAccessKeyId && awsSecretAccessKey && awsRegion || awsApiKey) && primaryProvider !== "bedrock") {
|
|
79792
|
+
const config = { provider: "bedrock" };
|
|
79793
|
+
if (awsApiKey) {
|
|
79794
|
+
config.apiKey = awsApiKey;
|
|
79795
|
+
} else {
|
|
79796
|
+
config.accessKeyId = awsAccessKeyId;
|
|
79797
|
+
config.secretAccessKey = awsSecretAccessKey;
|
|
79798
|
+
config.region = awsRegion;
|
|
79799
|
+
if (process.env.AWS_SESSION_TOKEN) {
|
|
79800
|
+
config.sessionToken = process.env.AWS_SESSION_TOKEN;
|
|
79801
|
+
}
|
|
79802
|
+
}
|
|
79803
|
+
if (awsBedrockBaseUrl) config.baseURL = awsBedrockBaseUrl;
|
|
79804
|
+
providers.push(config);
|
|
79805
|
+
}
|
|
79806
|
+
return providers;
|
|
79807
|
+
}
|
|
79808
|
+
var import_anthropic, import_openai, import_google, FALLBACK_STRATEGIES, DEFAULT_MODELS, FallbackManager;
|
|
79809
|
+
var init_FallbackManager = __esm({
|
|
79810
|
+
"src/agent/FallbackManager.js"() {
|
|
79811
|
+
"use strict";
|
|
79812
|
+
import_anthropic = require("@ai-sdk/anthropic");
|
|
79813
|
+
import_openai = require("@ai-sdk/openai");
|
|
79814
|
+
import_google = require("@ai-sdk/google");
|
|
79815
|
+
init_dist3();
|
|
79816
|
+
FALLBACK_STRATEGIES = {
|
|
79817
|
+
SAME_MODEL: "same-model",
|
|
79818
|
+
// Try same model on different providers
|
|
79819
|
+
SAME_PROVIDER: "same-provider",
|
|
79820
|
+
// Try different models on same provider
|
|
79821
|
+
ANY: "any",
|
|
79822
|
+
// Try any available provider/model
|
|
79823
|
+
CUSTOM: "custom"
|
|
79824
|
+
// Use custom provider list
|
|
79825
|
+
};
|
|
79826
|
+
DEFAULT_MODELS = {
|
|
79827
|
+
anthropic: "claude-sonnet-4-5-20250929",
|
|
79828
|
+
openai: "gpt-4o",
|
|
79829
|
+
google: "gemini-2.0-flash-exp",
|
|
79830
|
+
bedrock: "anthropic.claude-sonnet-4-20250514-v1:0"
|
|
79831
|
+
};
|
|
79832
|
+
FallbackManager = class {
|
|
79833
|
+
/**
|
|
79834
|
+
* Create a new FallbackManager
|
|
79835
|
+
* @param {Object} options - Configuration options
|
|
79836
|
+
* @param {string} [options.strategy='any'] - Fallback strategy
|
|
79837
|
+
* @param {Array<string>} [options.models] - List of models for same-provider fallback
|
|
79838
|
+
* @param {Array<ProviderConfig>} [options.providers] - List of provider configurations
|
|
79839
|
+
* @param {boolean} [options.stopOnSuccess=true] - Stop on first success
|
|
79840
|
+
* @param {boolean} [options.continueOnNonRetryableError=false] - Continue to fallback on non-retryable errors
|
|
79841
|
+
* @param {number} [options.maxTotalAttempts=10] - Maximum total attempts across all providers
|
|
79842
|
+
* @param {boolean} [options.debug=false] - Enable debug logging
|
|
79843
|
+
*/
|
|
79844
|
+
constructor(options = {}) {
|
|
79845
|
+
this.strategy = options.strategy || FALLBACK_STRATEGIES.ANY;
|
|
79846
|
+
this.models = Array.isArray(options.models) ? options.models : [];
|
|
79847
|
+
this.providers = Array.isArray(options.providers) ? options.providers : [];
|
|
79848
|
+
this.stopOnSuccess = options.stopOnSuccess ?? true;
|
|
79849
|
+
this.continueOnNonRetryableError = options.continueOnNonRetryableError ?? false;
|
|
79850
|
+
this.debug = options.debug ?? false;
|
|
79851
|
+
const maxAttempts = options.maxTotalAttempts ?? 10;
|
|
79852
|
+
if (typeof maxAttempts !== "number" || isNaN(maxAttempts) || maxAttempts < 1 || maxAttempts > 100) {
|
|
79853
|
+
throw new Error(`FallbackManager: maxTotalAttempts must be a number between 1 and 100, got: ${maxAttempts}`);
|
|
79854
|
+
}
|
|
79855
|
+
this.maxTotalAttempts = maxAttempts;
|
|
79856
|
+
this.stats = {
|
|
79857
|
+
totalAttempts: 0,
|
|
79858
|
+
providerAttempts: {},
|
|
79859
|
+
successfulProvider: null,
|
|
79860
|
+
failedProviders: []
|
|
79861
|
+
};
|
|
79862
|
+
this._validateConfiguration();
|
|
79863
|
+
}
|
|
79864
|
+
/**
|
|
79865
|
+
* Validate the fallback configuration
|
|
79866
|
+
* @private
|
|
79867
|
+
*/
|
|
79868
|
+
_validateConfiguration() {
|
|
79869
|
+
if (this.strategy === FALLBACK_STRATEGIES.SAME_PROVIDER && this.models.length === 0) {
|
|
79870
|
+
throw new Error('FallbackManager: strategy "same-provider" requires models list');
|
|
79871
|
+
}
|
|
79872
|
+
if (this.strategy === FALLBACK_STRATEGIES.CUSTOM && this.providers.length === 0) {
|
|
79873
|
+
throw new Error('FallbackManager: strategy "custom" requires providers list');
|
|
79874
|
+
}
|
|
79875
|
+
for (const config of this.providers) {
|
|
79876
|
+
if (!config.provider) {
|
|
79877
|
+
throw new Error('FallbackManager: Each provider config must have a "provider" field');
|
|
79878
|
+
}
|
|
79879
|
+
if (!["anthropic", "openai", "google", "bedrock"].includes(config.provider)) {
|
|
79880
|
+
throw new Error(`FallbackManager: Invalid provider "${config.provider}". Must be: anthropic, openai, google, or bedrock`);
|
|
79881
|
+
}
|
|
79882
|
+
if (config.provider === "bedrock") {
|
|
79883
|
+
const hasCredentials = config.accessKeyId && config.secretAccessKey && config.region;
|
|
79884
|
+
const hasApiKey = config.apiKey;
|
|
79885
|
+
if (!hasCredentials && !hasApiKey) {
|
|
79886
|
+
throw new Error("FallbackManager: Bedrock provider requires either (accessKeyId, secretAccessKey, region) or apiKey");
|
|
79887
|
+
}
|
|
79888
|
+
} else {
|
|
79889
|
+
if (!config.apiKey) {
|
|
79890
|
+
throw new Error(`FallbackManager: Provider "${config.provider}" requires apiKey`);
|
|
79891
|
+
}
|
|
79892
|
+
}
|
|
79893
|
+
}
|
|
79894
|
+
}
|
|
79895
|
+
/**
|
|
79896
|
+
* Create a provider instance from configuration
|
|
79897
|
+
* @param {ProviderConfig} config - Provider configuration
|
|
79898
|
+
* @returns {Object} - Provider instance
|
|
79899
|
+
* @throws {Error} - If provider creation fails
|
|
79900
|
+
* @private
|
|
79901
|
+
*/
|
|
79902
|
+
_createProviderInstance(config) {
|
|
79903
|
+
try {
|
|
79904
|
+
switch (config.provider) {
|
|
79905
|
+
case "anthropic":
|
|
79906
|
+
return (0, import_anthropic.createAnthropic)({
|
|
79907
|
+
apiKey: config.apiKey,
|
|
79908
|
+
...config.baseURL && { baseURL: config.baseURL }
|
|
79909
|
+
});
|
|
79910
|
+
case "openai":
|
|
79911
|
+
return (0, import_openai.createOpenAI)({
|
|
79912
|
+
compatibility: "strict",
|
|
79913
|
+
apiKey: config.apiKey,
|
|
79914
|
+
...config.baseURL && { baseURL: config.baseURL }
|
|
79915
|
+
});
|
|
79916
|
+
case "google":
|
|
79917
|
+
return (0, import_google.createGoogleGenerativeAI)({
|
|
79918
|
+
apiKey: config.apiKey,
|
|
79919
|
+
...config.baseURL && { baseURL: config.baseURL }
|
|
79920
|
+
});
|
|
79921
|
+
case "bedrock": {
|
|
79922
|
+
const bedrockConfig = {};
|
|
79923
|
+
if (config.apiKey) {
|
|
79924
|
+
bedrockConfig.apiKey = config.apiKey;
|
|
79925
|
+
} else if (config.accessKeyId && config.secretAccessKey) {
|
|
79926
|
+
bedrockConfig.accessKeyId = config.accessKeyId;
|
|
79927
|
+
bedrockConfig.secretAccessKey = config.secretAccessKey;
|
|
79928
|
+
if (config.sessionToken) {
|
|
79929
|
+
bedrockConfig.sessionToken = config.sessionToken;
|
|
79930
|
+
}
|
|
79931
|
+
}
|
|
79932
|
+
if (config.region) {
|
|
79933
|
+
bedrockConfig.region = config.region;
|
|
79934
|
+
}
|
|
79935
|
+
if (config.baseURL) {
|
|
79936
|
+
bedrockConfig.baseURL = config.baseURL;
|
|
79937
|
+
}
|
|
79938
|
+
return createAmazonBedrock(bedrockConfig);
|
|
79939
|
+
}
|
|
79940
|
+
default:
|
|
79941
|
+
throw new Error(`FallbackManager: Unknown provider "${config.provider}"`);
|
|
79942
|
+
}
|
|
79943
|
+
} catch (error2) {
|
|
79944
|
+
const providerName = this._getProviderDisplayName(config);
|
|
79945
|
+
throw new Error(`Failed to create provider instance for ${providerName}: ${error2.message}`);
|
|
79946
|
+
}
|
|
79947
|
+
}
|
|
79948
|
+
/**
|
|
79949
|
+
* Get the model name for a provider configuration
|
|
79950
|
+
* @param {ProviderConfig} config - Provider configuration
|
|
79951
|
+
* @returns {string} - Model name
|
|
79952
|
+
* @private
|
|
79953
|
+
*/
|
|
79954
|
+
_getModelName(config) {
|
|
79955
|
+
return config.model || DEFAULT_MODELS[config.provider];
|
|
79956
|
+
}
|
|
79957
|
+
/**
|
|
79958
|
+
* Get provider display name for logging
|
|
79959
|
+
* @param {ProviderConfig} config - Provider configuration
|
|
79960
|
+
* @returns {string} - Display name
|
|
79961
|
+
* @private
|
|
79962
|
+
*/
|
|
79963
|
+
_getProviderDisplayName(config) {
|
|
79964
|
+
const model = this._getModelName(config);
|
|
79965
|
+
const provider = config.provider;
|
|
79966
|
+
const url = config.baseURL ? ` (${config.baseURL})` : "";
|
|
79967
|
+
return `${provider}/${model}${url}`;
|
|
79968
|
+
}
|
|
79969
|
+
/**
|
|
79970
|
+
* Execute a function with fallback support
|
|
79971
|
+
* @param {Function} fn - Function that takes (provider, model, config) and returns a Promise
|
|
79972
|
+
* @returns {Promise<*>} - Result from the function
|
|
79973
|
+
* @throws {Error} - If all fallbacks are exhausted
|
|
79974
|
+
*/
|
|
79975
|
+
async executeWithFallback(fn) {
|
|
79976
|
+
if (this.providers.length === 0) {
|
|
79977
|
+
throw new Error("FallbackManager: No providers configured for fallback");
|
|
79978
|
+
}
|
|
79979
|
+
let lastError = null;
|
|
79980
|
+
let totalAttempts = 0;
|
|
79981
|
+
for (const config of this.providers) {
|
|
79982
|
+
if (totalAttempts >= this.maxTotalAttempts) {
|
|
79983
|
+
if (this.debug) {
|
|
79984
|
+
console.log(`[FallbackManager] \u26A0\uFE0F Max total attempts (${this.maxTotalAttempts}) reached`);
|
|
79985
|
+
}
|
|
79986
|
+
break;
|
|
79987
|
+
}
|
|
79988
|
+
totalAttempts++;
|
|
79989
|
+
this.stats.totalAttempts++;
|
|
79990
|
+
const providerName = this._getProviderDisplayName(config);
|
|
79991
|
+
this.stats.providerAttempts[providerName] = (this.stats.providerAttempts[providerName] || 0) + 1;
|
|
79992
|
+
try {
|
|
79993
|
+
if (this.debug) {
|
|
79994
|
+
console.log(`[FallbackManager] Attempting provider: ${providerName} (attempt ${totalAttempts}/${this.maxTotalAttempts})`);
|
|
79995
|
+
}
|
|
79996
|
+
const provider = this._createProviderInstance(config);
|
|
79997
|
+
const model = this._getModelName(config);
|
|
79998
|
+
const result = await fn(provider, model, config);
|
|
79999
|
+
this.stats.successfulProvider = providerName;
|
|
80000
|
+
if (this.debug) {
|
|
80001
|
+
console.log(`[FallbackManager] \u2705 Success with provider: ${providerName}`);
|
|
80002
|
+
}
|
|
80003
|
+
return result;
|
|
80004
|
+
} catch (error2) {
|
|
80005
|
+
lastError = error2;
|
|
80006
|
+
const errorInfo = {
|
|
80007
|
+
message: error2.message || error2.toString(),
|
|
80008
|
+
type: error2.type || error2.constructor.name,
|
|
80009
|
+
statusCode: error2.statusCode || error2.status
|
|
80010
|
+
};
|
|
80011
|
+
this.stats.failedProviders.push({
|
|
80012
|
+
provider: providerName,
|
|
80013
|
+
error: errorInfo
|
|
80014
|
+
});
|
|
80015
|
+
if (this.debug) {
|
|
80016
|
+
console.log(`[FallbackManager] \u274C Failed with provider: ${providerName}`, errorInfo);
|
|
80017
|
+
}
|
|
80018
|
+
if (!this.continueOnNonRetryableError && error2.nonRetryable) {
|
|
80019
|
+
if (this.debug) {
|
|
80020
|
+
console.log(`[FallbackManager] Non-retryable error, stopping fallback chain`);
|
|
80021
|
+
}
|
|
80022
|
+
throw error2;
|
|
80023
|
+
}
|
|
80024
|
+
if (this.debug) {
|
|
80025
|
+
const remaining = this.providers.length - (this.providers.indexOf(config) + 1);
|
|
80026
|
+
console.log(`[FallbackManager] Trying next provider (${remaining} remaining)...`);
|
|
80027
|
+
}
|
|
80028
|
+
}
|
|
80029
|
+
}
|
|
80030
|
+
if (this.debug) {
|
|
80031
|
+
console.log(`[FallbackManager] \u274C All providers exhausted. Total attempts: ${totalAttempts}`);
|
|
80032
|
+
}
|
|
80033
|
+
const fallbackError = new Error(
|
|
80034
|
+
`All provider fallbacks exhausted after ${totalAttempts} attempts. Last error: ${lastError?.message || "Unknown error"}`
|
|
80035
|
+
);
|
|
80036
|
+
fallbackError.cause = lastError;
|
|
80037
|
+
fallbackError.stats = this.getStats();
|
|
80038
|
+
fallbackError.allProvidersFailed = true;
|
|
80039
|
+
throw fallbackError;
|
|
80040
|
+
}
|
|
80041
|
+
/**
|
|
80042
|
+
* Get fallback statistics
|
|
80043
|
+
* @returns {Object} - Statistics object
|
|
80044
|
+
*/
|
|
80045
|
+
getStats() {
|
|
80046
|
+
return {
|
|
80047
|
+
...this.stats,
|
|
80048
|
+
providerAttempts: { ...this.stats.providerAttempts },
|
|
80049
|
+
failedProviders: [...this.stats.failedProviders]
|
|
80050
|
+
};
|
|
80051
|
+
}
|
|
80052
|
+
/**
|
|
80053
|
+
* Reset statistics
|
|
80054
|
+
*/
|
|
80055
|
+
resetStats() {
|
|
80056
|
+
this.stats = {
|
|
80057
|
+
totalAttempts: 0,
|
|
80058
|
+
providerAttempts: {},
|
|
80059
|
+
successfulProvider: null,
|
|
80060
|
+
failedProviders: []
|
|
80061
|
+
};
|
|
80062
|
+
}
|
|
80063
|
+
};
|
|
80064
|
+
}
|
|
80065
|
+
});
|
|
80066
|
+
|
|
79242
80067
|
// src/agent/ProbeAgent.js
|
|
79243
80068
|
var ProbeAgent_exports = {};
|
|
79244
80069
|
__export(ProbeAgent_exports, {
|
|
79245
80070
|
ProbeAgent: () => ProbeAgent
|
|
79246
80071
|
});
|
|
79247
|
-
var import_dotenv,
|
|
80072
|
+
var import_dotenv, import_anthropic2, import_openai2, import_google2, import_ai, import_crypto4, import_events2, import_fs5, import_promises2, import_path6, MAX_TOOL_ITERATIONS, MAX_HISTORY_MESSAGES, MAX_IMAGE_FILE_SIZE, ProbeAgent;
|
|
79248
80073
|
var init_ProbeAgent = __esm({
|
|
79249
80074
|
"src/agent/ProbeAgent.js"() {
|
|
79250
80075
|
"use strict";
|
|
79251
80076
|
import_dotenv = __toESM(require_main(), 1);
|
|
79252
|
-
|
|
79253
|
-
|
|
79254
|
-
|
|
80077
|
+
import_anthropic2 = require("@ai-sdk/anthropic");
|
|
80078
|
+
import_openai2 = require("@ai-sdk/openai");
|
|
80079
|
+
import_google2 = require("@ai-sdk/google");
|
|
79255
80080
|
init_dist3();
|
|
79256
80081
|
import_ai = require("ai");
|
|
79257
80082
|
import_crypto4 = require("crypto");
|
|
@@ -79271,8 +80096,17 @@ var init_ProbeAgent = __esm({
|
|
|
79271
80096
|
init_schemaUtils();
|
|
79272
80097
|
init_xmlParsingUtils();
|
|
79273
80098
|
init_mcp();
|
|
80099
|
+
init_RetryManager();
|
|
80100
|
+
init_FallbackManager();
|
|
79274
80101
|
import_dotenv.default.config();
|
|
79275
|
-
MAX_TOOL_ITERATIONS =
|
|
80102
|
+
MAX_TOOL_ITERATIONS = (() => {
|
|
80103
|
+
const val = parseInt(process.env.MAX_TOOL_ITERATIONS || "30", 10);
|
|
80104
|
+
if (isNaN(val) || val < 1 || val > 200) {
|
|
80105
|
+
console.warn("[ProbeAgent] MAX_TOOL_ITERATIONS must be between 1 and 200, using default: 30");
|
|
80106
|
+
return 30;
|
|
80107
|
+
}
|
|
80108
|
+
return val;
|
|
80109
|
+
})();
|
|
79276
80110
|
MAX_HISTORY_MESSAGES = 100;
|
|
79277
80111
|
MAX_IMAGE_FILE_SIZE = 20 * 1024 * 1024;
|
|
79278
80112
|
ProbeAgent = class _ProbeAgent {
|
|
@@ -79299,6 +80133,18 @@ var init_ProbeAgent = __esm({
|
|
|
79299
80133
|
* @param {Array} [options.mcpServers] - Deprecated, use mcpConfig instead
|
|
79300
80134
|
* @param {Object} [options.storageAdapter] - Custom storage adapter for history management
|
|
79301
80135
|
* @param {Object} [options.hooks] - Hook callbacks for events (e.g., {'tool:start': callback})
|
|
80136
|
+
* @param {Object} [options.retry] - Retry configuration
|
|
80137
|
+
* @param {number} [options.retry.maxRetries=3] - Maximum retry attempts per provider
|
|
80138
|
+
* @param {number} [options.retry.initialDelay=1000] - Initial delay in ms
|
|
80139
|
+
* @param {number} [options.retry.maxDelay=30000] - Maximum delay in ms
|
|
80140
|
+
* @param {number} [options.retry.backoffFactor=2] - Exponential backoff multiplier
|
|
80141
|
+
* @param {Array<string>} [options.retry.retryableErrors] - List of retryable error patterns
|
|
80142
|
+
* @param {Object} [options.fallback] - Fallback configuration
|
|
80143
|
+
* @param {string} [options.fallback.strategy] - Fallback strategy: 'same-model', 'same-provider', 'any', 'custom'
|
|
80144
|
+
* @param {Array<string>} [options.fallback.models] - List of models for same-provider fallback
|
|
80145
|
+
* @param {Array<Object>} [options.fallback.providers] - List of provider configurations for custom fallback
|
|
80146
|
+
* @param {boolean} [options.fallback.stopOnSuccess=true] - Stop on first success
|
|
80147
|
+
* @param {number} [options.fallback.maxTotalAttempts=10] - Maximum total attempts across all providers
|
|
79302
80148
|
*/
|
|
79303
80149
|
constructor(options = {}) {
|
|
79304
80150
|
this.sessionId = options.sessionId || (0, import_crypto4.randomUUID)();
|
|
@@ -79310,7 +80156,13 @@ var init_ProbeAgent = __esm({
|
|
|
79310
80156
|
this.cancelled = false;
|
|
79311
80157
|
this.tracer = options.tracer || null;
|
|
79312
80158
|
this.outline = !!options.outline;
|
|
79313
|
-
this.maxResponseTokens = options.maxResponseTokens ||
|
|
80159
|
+
this.maxResponseTokens = options.maxResponseTokens || (() => {
|
|
80160
|
+
const val = parseInt(process.env.MAX_RESPONSE_TOKENS || "0", 10);
|
|
80161
|
+
if (isNaN(val) || val < 0 || val > 2e5) {
|
|
80162
|
+
return null;
|
|
80163
|
+
}
|
|
80164
|
+
return val || null;
|
|
80165
|
+
})();
|
|
79314
80166
|
this.maxIterations = options.maxIterations || null;
|
|
79315
80167
|
this.disableMermaidValidation = !!options.disableMermaidValidation;
|
|
79316
80168
|
this.disableJsonValidation = !!options.disableJsonValidation;
|
|
@@ -79351,6 +80203,10 @@ var init_ProbeAgent = __esm({
|
|
|
79351
80203
|
this.mcpServers = options.mcpServers || null;
|
|
79352
80204
|
this.mcpBridge = null;
|
|
79353
80205
|
this._mcpInitialized = false;
|
|
80206
|
+
this.retryConfig = options.retry || {};
|
|
80207
|
+
this.retryManager = null;
|
|
80208
|
+
this.fallbackConfig = options.fallback || null;
|
|
80209
|
+
this.fallbackManager = null;
|
|
79354
80210
|
this.initializeModel();
|
|
79355
80211
|
}
|
|
79356
80212
|
/**
|
|
@@ -79435,6 +80291,14 @@ var init_ProbeAgent = __esm({
|
|
|
79435
80291
|
if (this.enableBash && wrappedTools.bashToolInstance) {
|
|
79436
80292
|
this.toolImplementations.bash = wrappedTools.bashToolInstance;
|
|
79437
80293
|
}
|
|
80294
|
+
if (this.allowEdit) {
|
|
80295
|
+
if (wrappedTools.editToolInstance) {
|
|
80296
|
+
this.toolImplementations.edit = wrappedTools.editToolInstance;
|
|
80297
|
+
}
|
|
80298
|
+
if (wrappedTools.createToolInstance) {
|
|
80299
|
+
this.toolImplementations.create = wrappedTools.createToolInstance;
|
|
80300
|
+
}
|
|
80301
|
+
}
|
|
79438
80302
|
this.wrappedTools = wrappedTools;
|
|
79439
80303
|
if (this.debug) {
|
|
79440
80304
|
console.error("\n[DEBUG] ========================================");
|
|
@@ -79485,36 +80349,147 @@ var init_ProbeAgent = __esm({
|
|
|
79485
80349
|
if (forceProvider) {
|
|
79486
80350
|
if (forceProvider === "anthropic" && anthropicApiKey) {
|
|
79487
80351
|
this.initializeAnthropicModel(anthropicApiKey, anthropicApiUrl, modelName);
|
|
80352
|
+
this.initializeFallbackManager(forceProvider, modelName);
|
|
79488
80353
|
return;
|
|
79489
80354
|
} else if (forceProvider === "openai" && openaiApiKey) {
|
|
79490
80355
|
this.initializeOpenAIModel(openaiApiKey, openaiApiUrl, modelName);
|
|
80356
|
+
this.initializeFallbackManager(forceProvider, modelName);
|
|
79491
80357
|
return;
|
|
79492
80358
|
} else if (forceProvider === "google" && googleApiKey) {
|
|
79493
80359
|
this.initializeGoogleModel(googleApiKey, googleApiUrl, modelName);
|
|
80360
|
+
this.initializeFallbackManager(forceProvider, modelName);
|
|
79494
80361
|
return;
|
|
79495
80362
|
} else if (forceProvider === "bedrock" && (awsAccessKeyId && awsSecretAccessKey && awsRegion || awsApiKey)) {
|
|
79496
80363
|
this.initializeBedrockModel(awsAccessKeyId, awsSecretAccessKey, awsRegion, awsSessionToken, awsApiKey, awsBedrockBaseUrl, modelName);
|
|
80364
|
+
this.initializeFallbackManager(forceProvider, modelName);
|
|
79497
80365
|
return;
|
|
79498
80366
|
}
|
|
79499
80367
|
console.warn(`WARNING: Forced provider "${forceProvider}" selected but required API key is missing or invalid! Falling back to auto-detection.`);
|
|
79500
80368
|
}
|
|
79501
80369
|
if (anthropicApiKey) {
|
|
79502
80370
|
this.initializeAnthropicModel(anthropicApiKey, anthropicApiUrl, modelName);
|
|
80371
|
+
this.initializeFallbackManager("anthropic", modelName);
|
|
79503
80372
|
} else if (openaiApiKey) {
|
|
79504
80373
|
this.initializeOpenAIModel(openaiApiKey, openaiApiUrl, modelName);
|
|
80374
|
+
this.initializeFallbackManager("openai", modelName);
|
|
79505
80375
|
} else if (googleApiKey) {
|
|
79506
80376
|
this.initializeGoogleModel(googleApiKey, googleApiUrl, modelName);
|
|
80377
|
+
this.initializeFallbackManager("google", modelName);
|
|
79507
80378
|
} else if (awsAccessKeyId && awsSecretAccessKey && awsRegion || awsApiKey) {
|
|
79508
80379
|
this.initializeBedrockModel(awsAccessKeyId, awsSecretAccessKey, awsRegion, awsSessionToken, awsApiKey, awsBedrockBaseUrl, modelName);
|
|
80380
|
+
this.initializeFallbackManager("bedrock", modelName);
|
|
79509
80381
|
} else {
|
|
79510
80382
|
throw new Error("No API key provided. Please set ANTHROPIC_API_KEY (or ANTHROPIC_AUTH_TOKEN), OPENAI_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY (or GOOGLE_API_KEY), AWS credentials (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION), or AWS_BEDROCK_API_KEY environment variables.");
|
|
79511
80383
|
}
|
|
79512
80384
|
}
|
|
80385
|
+
/**
|
|
80386
|
+
* Initialize fallback manager based on configuration
|
|
80387
|
+
* @param {string} primaryProvider - The primary provider being used
|
|
80388
|
+
* @param {string} primaryModel - The primary model being used
|
|
80389
|
+
* @private
|
|
80390
|
+
*/
|
|
80391
|
+
initializeFallbackManager(primaryProvider, primaryModel) {
|
|
80392
|
+
if (this.fallbackConfig === false || process.env.DISABLE_FALLBACK === "1") {
|
|
80393
|
+
return;
|
|
80394
|
+
}
|
|
80395
|
+
if (this.fallbackConfig && this.fallbackConfig.providers) {
|
|
80396
|
+
try {
|
|
80397
|
+
this.fallbackManager = new FallbackManager({
|
|
80398
|
+
...this.fallbackConfig,
|
|
80399
|
+
debug: this.debug
|
|
80400
|
+
});
|
|
80401
|
+
if (this.debug) {
|
|
80402
|
+
console.log(`[DEBUG] Fallback manager initialized with ${this.fallbackManager.providers.length} providers`);
|
|
80403
|
+
}
|
|
80404
|
+
} catch (error2) {
|
|
80405
|
+
console.error("[WARNING] Failed to initialize fallback manager:", error2.message);
|
|
80406
|
+
}
|
|
80407
|
+
return;
|
|
80408
|
+
}
|
|
80409
|
+
const envFallbackManager = createFallbackManagerFromEnv(this.debug);
|
|
80410
|
+
if (envFallbackManager) {
|
|
80411
|
+
this.fallbackManager = envFallbackManager;
|
|
80412
|
+
if (this.debug) {
|
|
80413
|
+
console.log(`[DEBUG] Fallback manager initialized from environment variables`);
|
|
80414
|
+
}
|
|
80415
|
+
return;
|
|
80416
|
+
}
|
|
80417
|
+
if (process.env.AUTO_FALLBACK === "1" || this.fallbackConfig?.auto) {
|
|
80418
|
+
const providers = buildFallbackProvidersFromEnv({
|
|
80419
|
+
primaryProvider,
|
|
80420
|
+
primaryModel
|
|
80421
|
+
});
|
|
80422
|
+
if (providers.length > 1) {
|
|
80423
|
+
try {
|
|
80424
|
+
this.fallbackManager = new FallbackManager({
|
|
80425
|
+
strategy: "custom",
|
|
80426
|
+
providers,
|
|
80427
|
+
debug: this.debug
|
|
80428
|
+
});
|
|
80429
|
+
if (this.debug) {
|
|
80430
|
+
console.log(`[DEBUG] Auto-fallback enabled with ${providers.length} providers`);
|
|
80431
|
+
}
|
|
80432
|
+
} catch (error2) {
|
|
80433
|
+
console.error("[WARNING] Failed to initialize auto-fallback:", error2.message);
|
|
80434
|
+
}
|
|
80435
|
+
}
|
|
80436
|
+
}
|
|
80437
|
+
}
|
|
80438
|
+
/**
|
|
80439
|
+
* Execute streamText with retry and fallback support
|
|
80440
|
+
* @param {Object} options - streamText options
|
|
80441
|
+
* @returns {Promise<Object>} - streamText result
|
|
80442
|
+
* @private
|
|
80443
|
+
*/
|
|
80444
|
+
async streamTextWithRetryAndFallback(options) {
|
|
80445
|
+
if (!this.retryManager) {
|
|
80446
|
+
this.retryManager = new RetryManager({
|
|
80447
|
+
maxRetries: this.retryConfig.maxRetries ?? 3,
|
|
80448
|
+
initialDelay: this.retryConfig.initialDelay ?? 1e3,
|
|
80449
|
+
maxDelay: this.retryConfig.maxDelay ?? 3e4,
|
|
80450
|
+
backoffFactor: this.retryConfig.backoffFactor ?? 2,
|
|
80451
|
+
retryableErrors: this.retryConfig.retryableErrors,
|
|
80452
|
+
debug: this.debug
|
|
80453
|
+
});
|
|
80454
|
+
}
|
|
80455
|
+
if (!this.fallbackManager) {
|
|
80456
|
+
return await this.retryManager.executeWithRetry(
|
|
80457
|
+
() => (0, import_ai.streamText)(options),
|
|
80458
|
+
{
|
|
80459
|
+
provider: this.apiType,
|
|
80460
|
+
model: this.model
|
|
80461
|
+
}
|
|
80462
|
+
);
|
|
80463
|
+
}
|
|
80464
|
+
return await this.fallbackManager.executeWithFallback(
|
|
80465
|
+
async (provider, model, config) => {
|
|
80466
|
+
const fallbackOptions = {
|
|
80467
|
+
...options,
|
|
80468
|
+
model: provider(model)
|
|
80469
|
+
};
|
|
80470
|
+
const providerRetryManager = new RetryManager({
|
|
80471
|
+
maxRetries: config.maxRetries ?? this.retryConfig.maxRetries ?? 3,
|
|
80472
|
+
initialDelay: this.retryConfig.initialDelay ?? 1e3,
|
|
80473
|
+
maxDelay: this.retryConfig.maxDelay ?? 3e4,
|
|
80474
|
+
backoffFactor: this.retryConfig.backoffFactor ?? 2,
|
|
80475
|
+
retryableErrors: this.retryConfig.retryableErrors,
|
|
80476
|
+
debug: this.debug
|
|
80477
|
+
});
|
|
80478
|
+
return await providerRetryManager.executeWithRetry(
|
|
80479
|
+
() => (0, import_ai.streamText)(fallbackOptions),
|
|
80480
|
+
{
|
|
80481
|
+
provider: config.provider,
|
|
80482
|
+
model
|
|
80483
|
+
}
|
|
80484
|
+
);
|
|
80485
|
+
}
|
|
80486
|
+
);
|
|
80487
|
+
}
|
|
79513
80488
|
/**
|
|
79514
80489
|
* Initialize Anthropic model
|
|
79515
80490
|
*/
|
|
79516
80491
|
initializeAnthropicModel(apiKey, apiUrl, modelName) {
|
|
79517
|
-
this.provider = (0,
|
|
80492
|
+
this.provider = (0, import_anthropic2.createAnthropic)({
|
|
79518
80493
|
apiKey,
|
|
79519
80494
|
...apiUrl && { baseURL: apiUrl }
|
|
79520
80495
|
});
|
|
@@ -79528,7 +80503,7 @@ var init_ProbeAgent = __esm({
|
|
|
79528
80503
|
* Initialize OpenAI model
|
|
79529
80504
|
*/
|
|
79530
80505
|
initializeOpenAIModel(apiKey, apiUrl, modelName) {
|
|
79531
|
-
this.provider = (0,
|
|
80506
|
+
this.provider = (0, import_openai2.createOpenAI)({
|
|
79532
80507
|
compatibility: "strict",
|
|
79533
80508
|
apiKey,
|
|
79534
80509
|
...apiUrl && { baseURL: apiUrl }
|
|
@@ -79543,7 +80518,7 @@ var init_ProbeAgent = __esm({
|
|
|
79543
80518
|
* Initialize Google model
|
|
79544
80519
|
*/
|
|
79545
80520
|
initializeGoogleModel(apiKey, apiUrl, modelName) {
|
|
79546
|
-
this.provider = (0,
|
|
80521
|
+
this.provider = (0, import_google2.createGoogleGenerativeAI)({
|
|
79547
80522
|
apiKey,
|
|
79548
80523
|
...apiUrl && { baseURL: apiUrl }
|
|
79549
80524
|
});
|
|
@@ -79687,21 +80662,21 @@ var init_ProbeAgent = __esm({
|
|
|
79687
80662
|
}
|
|
79688
80663
|
const allowedDirs = this.allowedFolders && this.allowedFolders.length > 0 ? this.allowedFolders : [process.cwd()];
|
|
79689
80664
|
let absolutePath;
|
|
79690
|
-
let
|
|
80665
|
+
let isPathAllowed2 = false;
|
|
79691
80666
|
if ((0, import_path6.isAbsolute)(imagePath)) {
|
|
79692
80667
|
absolutePath = imagePath;
|
|
79693
|
-
|
|
80668
|
+
isPathAllowed2 = allowedDirs.some((dir) => absolutePath.startsWith((0, import_path6.resolve)(dir)));
|
|
79694
80669
|
} else {
|
|
79695
80670
|
for (const dir of allowedDirs) {
|
|
79696
80671
|
const resolvedPath2 = (0, import_path6.resolve)(dir, imagePath);
|
|
79697
80672
|
if (resolvedPath2.startsWith((0, import_path6.resolve)(dir))) {
|
|
79698
80673
|
absolutePath = resolvedPath2;
|
|
79699
|
-
|
|
80674
|
+
isPathAllowed2 = true;
|
|
79700
80675
|
break;
|
|
79701
80676
|
}
|
|
79702
80677
|
}
|
|
79703
80678
|
}
|
|
79704
|
-
if (!
|
|
80679
|
+
if (!isPathAllowed2) {
|
|
79705
80680
|
if (this.debug) {
|
|
79706
80681
|
console.log(`[DEBUG] Image path outside allowed directories: ${imagePath}`);
|
|
79707
80682
|
}
|
|
@@ -79900,6 +80875,14 @@ ${attemptCompletionToolDefinition}
|
|
|
79900
80875
|
`;
|
|
79901
80876
|
if (this.allowEdit) {
|
|
79902
80877
|
toolDefinitions += `${implementToolDefinition}
|
|
80878
|
+
`;
|
|
80879
|
+
toolDefinitions += `${editToolDefinition}
|
|
80880
|
+
`;
|
|
80881
|
+
toolDefinitions += `${createToolDefinition}
|
|
80882
|
+
`;
|
|
80883
|
+
}
|
|
80884
|
+
if (this.enableBash) {
|
|
80885
|
+
toolDefinitions += `${bashToolDefinition}
|
|
79903
80886
|
`;
|
|
79904
80887
|
}
|
|
79905
80888
|
if (this.enableDelegate) {
|
|
@@ -79967,7 +80950,7 @@ Available Tools:
|
|
|
79967
80950
|
- extract: Extract specific code blocks or lines from files.
|
|
79968
80951
|
- listFiles: List files and directories in a specified location.
|
|
79969
80952
|
- searchFiles: Find files matching a glob pattern with recursive search capability.
|
|
79970
|
-
${this.allowEdit ? "- implement: Implement a feature or fix a bug using aider.\n" : ""}${this.enableDelegate ? "- delegate: Delegate big distinct tasks to specialized probe subagents.\n" : ""}
|
|
80953
|
+
${this.allowEdit ? "- implement: Implement a feature or fix a bug using aider.\n- edit: Edit files using exact string replacement.\n- create: Create new files with specified content.\n" : ""}${this.enableDelegate ? "- delegate: Delegate big distinct tasks to specialized probe subagents.\n" : ""}${this.enableBash ? "- bash: Execute bash commands for system operations.\n" : ""}
|
|
79971
80954
|
- attempt_completion: Finalize the task and provide the result to the user.
|
|
79972
80955
|
- attempt_complete: Quick completion using previous response (shorthand).
|
|
79973
80956
|
`;
|
|
@@ -79981,7 +80964,10 @@ Follow these instructions carefully:
|
|
|
79981
80964
|
6. You MUST respond with exactly ONE tool call per message, using the specified XML format, until the task is complete.
|
|
79982
80965
|
7. Wait for the tool execution result (provided in the next user message in a <tool_result> block) before proceeding to the next step.
|
|
79983
80966
|
8. Once the task is fully completed, use the '<attempt_completion>' tool to provide the final result. This is the ONLY way to signal completion.
|
|
79984
|
-
9. Prefer concise and focused search queries. Use specific keywords and phrases to narrow down results.
|
|
80967
|
+
9. Prefer concise and focused search queries. Use specific keywords and phrases to narrow down results.${this.allowEdit ? `
|
|
80968
|
+
10. When modifying files, choose the appropriate tool:
|
|
80969
|
+
- Use 'edit' for precise changes to existing files (requires exact string match)
|
|
80970
|
+
- Use 'create' for new files or complete file rewrites` : ""}
|
|
79985
80971
|
</instructions>
|
|
79986
80972
|
`;
|
|
79987
80973
|
const predefinedPrompts = {
|
|
@@ -80233,7 +81219,7 @@ You are working with a repository located at: ${searchDirectory}
|
|
|
80233
81219
|
try {
|
|
80234
81220
|
const executeAIRequest = async () => {
|
|
80235
81221
|
const messagesForAI = this.prepareMessagesWithImages(currentMessages);
|
|
80236
|
-
const result = await
|
|
81222
|
+
const result = await this.streamTextWithRetryAndFallback({
|
|
80237
81223
|
model: this.provider(this.model),
|
|
80238
81224
|
messages: messagesForAI,
|
|
80239
81225
|
maxTokens: maxResponseTokens,
|
|
@@ -80285,7 +81271,10 @@ You are working with a repository located at: ${searchDirectory}
|
|
|
80285
81271
|
"attempt_completion"
|
|
80286
81272
|
];
|
|
80287
81273
|
if (this.allowEdit) {
|
|
80288
|
-
validTools.push("implement");
|
|
81274
|
+
validTools.push("implement", "edit", "create");
|
|
81275
|
+
}
|
|
81276
|
+
if (this.enableBash) {
|
|
81277
|
+
validTools.push("bash");
|
|
80289
81278
|
}
|
|
80290
81279
|
if (this.enableDelegate) {
|
|
80291
81280
|
validTools.push("delegate");
|
|
@@ -82519,14 +83508,14 @@ async function executeBashCommand(command, options = {}) {
|
|
|
82519
83508
|
console.log(`[BashExecutor] Working directory: "${cwd}"`);
|
|
82520
83509
|
console.log(`[BashExecutor] Timeout: ${timeout}ms`);
|
|
82521
83510
|
}
|
|
82522
|
-
return new Promise((
|
|
83511
|
+
return new Promise((resolve5, reject2) => {
|
|
82523
83512
|
const processEnv = {
|
|
82524
83513
|
...process.env,
|
|
82525
83514
|
...env
|
|
82526
83515
|
};
|
|
82527
83516
|
const args = parseCommandForExecution(command);
|
|
82528
83517
|
if (!args || args.length === 0) {
|
|
82529
|
-
|
|
83518
|
+
resolve5({
|
|
82530
83519
|
success: false,
|
|
82531
83520
|
error: "Failed to parse command",
|
|
82532
83521
|
stdout: "",
|
|
@@ -82609,7 +83598,7 @@ async function executeBashCommand(command, options = {}) {
|
|
|
82609
83598
|
success = false;
|
|
82610
83599
|
error2 = `Command exited with code ${code}`;
|
|
82611
83600
|
}
|
|
82612
|
-
|
|
83601
|
+
resolve5({
|
|
82613
83602
|
success,
|
|
82614
83603
|
error: error2,
|
|
82615
83604
|
stdout: stdout.trim(),
|
|
@@ -82629,7 +83618,7 @@ async function executeBashCommand(command, options = {}) {
|
|
|
82629
83618
|
if (debug) {
|
|
82630
83619
|
console.log(`[BashExecutor] Spawn error:`, error2);
|
|
82631
83620
|
}
|
|
82632
|
-
|
|
83621
|
+
resolve5({
|
|
82633
83622
|
success: false,
|
|
82634
83623
|
error: `Failed to execute command: ${error2.message}`,
|
|
82635
83624
|
stdout: "",
|
|
@@ -82905,6 +83894,323 @@ Command failed with exit code ${result.exitCode}`;
|
|
|
82905
83894
|
}
|
|
82906
83895
|
});
|
|
82907
83896
|
|
|
83897
|
+
// src/tools/edit.js
|
|
83898
|
+
function isPathAllowed(filePath, allowedFolders) {
|
|
83899
|
+
if (!allowedFolders || allowedFolders.length === 0) {
|
|
83900
|
+
const resolvedPath3 = (0, import_path9.resolve)(filePath);
|
|
83901
|
+
const cwd = (0, import_path9.resolve)(process.cwd());
|
|
83902
|
+
return resolvedPath3 === cwd || resolvedPath3.startsWith(cwd + import_path9.sep);
|
|
83903
|
+
}
|
|
83904
|
+
const resolvedPath2 = (0, import_path9.resolve)(filePath);
|
|
83905
|
+
return allowedFolders.some((folder) => {
|
|
83906
|
+
const allowedPath = (0, import_path9.resolve)(folder);
|
|
83907
|
+
return resolvedPath2 === allowedPath || resolvedPath2.startsWith(allowedPath + import_path9.sep);
|
|
83908
|
+
});
|
|
83909
|
+
}
|
|
83910
|
+
function parseFileToolOptions(options = {}) {
|
|
83911
|
+
return {
|
|
83912
|
+
debug: options.debug || false,
|
|
83913
|
+
allowedFolders: options.allowedFolders || [],
|
|
83914
|
+
defaultPath: options.defaultPath
|
|
83915
|
+
};
|
|
83916
|
+
}
|
|
83917
|
+
var import_ai4, import_fs7, import_path9, import_fs8, editTool, createTool, editSchema, createSchema, editDescription, createDescription, editToolDefinition, createToolDefinition;
|
|
83918
|
+
var init_edit = __esm({
|
|
83919
|
+
"src/tools/edit.js"() {
|
|
83920
|
+
"use strict";
|
|
83921
|
+
import_ai4 = require("ai");
|
|
83922
|
+
import_fs7 = require("fs");
|
|
83923
|
+
import_path9 = require("path");
|
|
83924
|
+
import_fs8 = require("fs");
|
|
83925
|
+
editTool = (options = {}) => {
|
|
83926
|
+
const { debug, allowedFolders, defaultPath } = parseFileToolOptions(options);
|
|
83927
|
+
return (0, import_ai4.tool)({
|
|
83928
|
+
name: "edit",
|
|
83929
|
+
description: `Edit files using exact string replacement (Claude Code style).
|
|
83930
|
+
|
|
83931
|
+
This tool performs exact string replacements in files. It requires the old_string to match exactly what's in the file, including all whitespace and indentation.
|
|
83932
|
+
|
|
83933
|
+
Parameters:
|
|
83934
|
+
- file_path: Path to the file to edit (absolute or relative)
|
|
83935
|
+
- old_string: Exact text to find and replace (must be unique in the file unless replace_all is true)
|
|
83936
|
+
- new_string: Text to replace with
|
|
83937
|
+
- replace_all: (optional) Replace all occurrences instead of requiring uniqueness
|
|
83938
|
+
|
|
83939
|
+
Important:
|
|
83940
|
+
- The old_string must match EXACTLY including whitespace
|
|
83941
|
+
- If old_string appears multiple times and replace_all is false, the edit will fail
|
|
83942
|
+
- Use larger context around the string to ensure uniqueness when needed`,
|
|
83943
|
+
inputSchema: {
|
|
83944
|
+
type: "object",
|
|
83945
|
+
properties: {
|
|
83946
|
+
file_path: {
|
|
83947
|
+
type: "string",
|
|
83948
|
+
description: "Path to the file to edit"
|
|
83949
|
+
},
|
|
83950
|
+
old_string: {
|
|
83951
|
+
type: "string",
|
|
83952
|
+
description: "Exact text to find and replace"
|
|
83953
|
+
},
|
|
83954
|
+
new_string: {
|
|
83955
|
+
type: "string",
|
|
83956
|
+
description: "Text to replace with"
|
|
83957
|
+
},
|
|
83958
|
+
replace_all: {
|
|
83959
|
+
type: "boolean",
|
|
83960
|
+
description: "Replace all occurrences (default: false)",
|
|
83961
|
+
default: false
|
|
83962
|
+
}
|
|
83963
|
+
},
|
|
83964
|
+
required: ["file_path", "old_string", "new_string"]
|
|
83965
|
+
},
|
|
83966
|
+
execute: async ({ file_path, old_string, new_string, replace_all = false }) => {
|
|
83967
|
+
try {
|
|
83968
|
+
if (!file_path || typeof file_path !== "string" || file_path.trim() === "") {
|
|
83969
|
+
return `Error editing file: Invalid file_path - must be a non-empty string`;
|
|
83970
|
+
}
|
|
83971
|
+
if (old_string === void 0 || old_string === null || typeof old_string !== "string") {
|
|
83972
|
+
return `Error editing file: Invalid old_string - must be a string`;
|
|
83973
|
+
}
|
|
83974
|
+
if (new_string === void 0 || new_string === null || typeof new_string !== "string") {
|
|
83975
|
+
return `Error editing file: Invalid new_string - must be a string`;
|
|
83976
|
+
}
|
|
83977
|
+
const resolvedPath2 = (0, import_path9.isAbsolute)(file_path) ? file_path : (0, import_path9.resolve)(defaultPath || process.cwd(), file_path);
|
|
83978
|
+
if (debug) {
|
|
83979
|
+
console.error(`[Edit] Attempting to edit file: ${resolvedPath2}`);
|
|
83980
|
+
}
|
|
83981
|
+
if (!isPathAllowed(resolvedPath2, allowedFolders)) {
|
|
83982
|
+
return `Error editing file: Permission denied - ${file_path} is outside allowed directories`;
|
|
83983
|
+
}
|
|
83984
|
+
if (!(0, import_fs8.existsSync)(resolvedPath2)) {
|
|
83985
|
+
return `Error editing file: File not found - ${file_path}`;
|
|
83986
|
+
}
|
|
83987
|
+
const content = await import_fs7.promises.readFile(resolvedPath2, "utf-8");
|
|
83988
|
+
if (!content.includes(old_string)) {
|
|
83989
|
+
return `Error editing file: String not found - the specified old_string was not found in ${file_path}`;
|
|
83990
|
+
}
|
|
83991
|
+
const occurrences = content.split(old_string).length - 1;
|
|
83992
|
+
if (!replace_all && occurrences > 1) {
|
|
83993
|
+
return `Error editing file: Multiple occurrences found - the old_string appears ${occurrences} times. Use replace_all: true to replace all occurrences, or provide more context to make the string unique.`;
|
|
83994
|
+
}
|
|
83995
|
+
let newContent;
|
|
83996
|
+
if (replace_all) {
|
|
83997
|
+
newContent = content.replaceAll(old_string, new_string);
|
|
83998
|
+
} else {
|
|
83999
|
+
newContent = content.replace(old_string, new_string);
|
|
84000
|
+
}
|
|
84001
|
+
if (newContent === content) {
|
|
84002
|
+
return `Error editing file: No changes made - old_string and new_string might be the same`;
|
|
84003
|
+
}
|
|
84004
|
+
await import_fs7.promises.writeFile(resolvedPath2, newContent, "utf-8");
|
|
84005
|
+
const replacedCount = replace_all ? occurrences : 1;
|
|
84006
|
+
if (debug) {
|
|
84007
|
+
console.error(`[Edit] Successfully edited ${resolvedPath2}, replaced ${replacedCount} occurrence(s)`);
|
|
84008
|
+
}
|
|
84009
|
+
return `Successfully edited ${file_path} (${replacedCount} replacement${replacedCount !== 1 ? "s" : ""})`;
|
|
84010
|
+
} catch (error2) {
|
|
84011
|
+
console.error("[Edit] Error:", error2);
|
|
84012
|
+
return `Error editing file: ${error2.message}`;
|
|
84013
|
+
}
|
|
84014
|
+
}
|
|
84015
|
+
});
|
|
84016
|
+
};
|
|
84017
|
+
createTool = (options = {}) => {
|
|
84018
|
+
const { debug, allowedFolders, defaultPath } = parseFileToolOptions(options);
|
|
84019
|
+
return (0, import_ai4.tool)({
|
|
84020
|
+
name: "create",
|
|
84021
|
+
description: `Create new files with specified content.
|
|
84022
|
+
|
|
84023
|
+
This tool creates new files in the filesystem. It will create parent directories if they don't exist.
|
|
84024
|
+
|
|
84025
|
+
Parameters:
|
|
84026
|
+
- file_path: Path where the file should be created (absolute or relative)
|
|
84027
|
+
- content: Content to write to the file
|
|
84028
|
+
- overwrite: (optional) Whether to overwrite if file exists (default: false)
|
|
84029
|
+
|
|
84030
|
+
Important:
|
|
84031
|
+
- By default, will fail if the file already exists
|
|
84032
|
+
- Set overwrite: true to replace existing files
|
|
84033
|
+
- Parent directories will be created automatically if needed`,
|
|
84034
|
+
inputSchema: {
|
|
84035
|
+
type: "object",
|
|
84036
|
+
properties: {
|
|
84037
|
+
file_path: {
|
|
84038
|
+
type: "string",
|
|
84039
|
+
description: "Path where the file should be created"
|
|
84040
|
+
},
|
|
84041
|
+
content: {
|
|
84042
|
+
type: "string",
|
|
84043
|
+
description: "Content to write to the file"
|
|
84044
|
+
},
|
|
84045
|
+
overwrite: {
|
|
84046
|
+
type: "boolean",
|
|
84047
|
+
description: "Overwrite if file exists (default: false)",
|
|
84048
|
+
default: false
|
|
84049
|
+
}
|
|
84050
|
+
},
|
|
84051
|
+
required: ["file_path", "content"]
|
|
84052
|
+
},
|
|
84053
|
+
execute: async ({ file_path, content, overwrite = false }) => {
|
|
84054
|
+
try {
|
|
84055
|
+
if (!file_path || typeof file_path !== "string" || file_path.trim() === "") {
|
|
84056
|
+
return `Error creating file: Invalid file_path - must be a non-empty string`;
|
|
84057
|
+
}
|
|
84058
|
+
if (content === void 0 || content === null || typeof content !== "string") {
|
|
84059
|
+
return `Error creating file: Invalid content - must be a string`;
|
|
84060
|
+
}
|
|
84061
|
+
const resolvedPath2 = (0, import_path9.isAbsolute)(file_path) ? file_path : (0, import_path9.resolve)(defaultPath || process.cwd(), file_path);
|
|
84062
|
+
if (debug) {
|
|
84063
|
+
console.error(`[Create] Attempting to create file: ${resolvedPath2}`);
|
|
84064
|
+
}
|
|
84065
|
+
if (!isPathAllowed(resolvedPath2, allowedFolders)) {
|
|
84066
|
+
return `Error creating file: Permission denied - ${file_path} is outside allowed directories`;
|
|
84067
|
+
}
|
|
84068
|
+
if ((0, import_fs8.existsSync)(resolvedPath2) && !overwrite) {
|
|
84069
|
+
return `Error creating file: File already exists - ${file_path}. Use overwrite: true to replace it.`;
|
|
84070
|
+
}
|
|
84071
|
+
const dir = (0, import_path9.dirname)(resolvedPath2);
|
|
84072
|
+
await import_fs7.promises.mkdir(dir, { recursive: true });
|
|
84073
|
+
await import_fs7.promises.writeFile(resolvedPath2, content, "utf-8");
|
|
84074
|
+
const action = (0, import_fs8.existsSync)(resolvedPath2) && overwrite ? "overwrote" : "created";
|
|
84075
|
+
const bytes = Buffer.byteLength(content, "utf-8");
|
|
84076
|
+
if (debug) {
|
|
84077
|
+
console.error(`[Create] Successfully ${action} ${resolvedPath2}`);
|
|
84078
|
+
}
|
|
84079
|
+
return `Successfully ${action} ${file_path} (${bytes} bytes)`;
|
|
84080
|
+
} catch (error2) {
|
|
84081
|
+
console.error("[Create] Error:", error2);
|
|
84082
|
+
return `Error creating file: ${error2.message}`;
|
|
84083
|
+
}
|
|
84084
|
+
}
|
|
84085
|
+
});
|
|
84086
|
+
};
|
|
84087
|
+
editSchema = {
|
|
84088
|
+
type: "object",
|
|
84089
|
+
properties: {
|
|
84090
|
+
file_path: {
|
|
84091
|
+
type: "string",
|
|
84092
|
+
description: "Path to the file to edit"
|
|
84093
|
+
},
|
|
84094
|
+
old_string: {
|
|
84095
|
+
type: "string",
|
|
84096
|
+
description: "Exact text to find and replace"
|
|
84097
|
+
},
|
|
84098
|
+
new_string: {
|
|
84099
|
+
type: "string",
|
|
84100
|
+
description: "Text to replace with"
|
|
84101
|
+
},
|
|
84102
|
+
replace_all: {
|
|
84103
|
+
type: "boolean",
|
|
84104
|
+
description: "Replace all occurrences (default: false)"
|
|
84105
|
+
}
|
|
84106
|
+
},
|
|
84107
|
+
required: ["file_path", "old_string", "new_string"]
|
|
84108
|
+
};
|
|
84109
|
+
createSchema = {
|
|
84110
|
+
type: "object",
|
|
84111
|
+
properties: {
|
|
84112
|
+
file_path: {
|
|
84113
|
+
type: "string",
|
|
84114
|
+
description: "Path where the file should be created"
|
|
84115
|
+
},
|
|
84116
|
+
content: {
|
|
84117
|
+
type: "string",
|
|
84118
|
+
description: "Content to write to the file"
|
|
84119
|
+
},
|
|
84120
|
+
overwrite: {
|
|
84121
|
+
type: "boolean",
|
|
84122
|
+
description: "Overwrite if file exists (default: false)"
|
|
84123
|
+
}
|
|
84124
|
+
},
|
|
84125
|
+
required: ["file_path", "content"]
|
|
84126
|
+
};
|
|
84127
|
+
editDescription = "Edit files using exact string replacement. Requires exact match including whitespace.";
|
|
84128
|
+
createDescription = "Create new files with specified content. Will create parent directories if needed.";
|
|
84129
|
+
editToolDefinition = `
|
|
84130
|
+
## edit
|
|
84131
|
+
Description: ${editDescription}
|
|
84132
|
+
|
|
84133
|
+
When to use:
|
|
84134
|
+
- For precise, surgical edits to existing files
|
|
84135
|
+
- When you need to change specific lines or blocks of code
|
|
84136
|
+
- For renaming functions, variables, or updating configuration values
|
|
84137
|
+
- When the exact text to replace is known and unique (or use replace_all for multiple occurrences)
|
|
84138
|
+
|
|
84139
|
+
When NOT to use:
|
|
84140
|
+
- For creating new files (use 'create' tool instead)
|
|
84141
|
+
- When you cannot determine the exact text to replace
|
|
84142
|
+
- When changes span multiple locations that would be better handled together
|
|
84143
|
+
|
|
84144
|
+
Parameters:
|
|
84145
|
+
- file_path: (required) Path to the file to edit
|
|
84146
|
+
- old_string: (required) Exact text to find and replace (must match including whitespace, newlines, and indentation)
|
|
84147
|
+
- new_string: (required) Text to replace with
|
|
84148
|
+
- replace_all: (optional, default: false) Replace all occurrences if the string appears multiple times
|
|
84149
|
+
|
|
84150
|
+
Important notes:
|
|
84151
|
+
- The old_string MUST match EXACTLY, including all whitespace, indentation, and line breaks
|
|
84152
|
+
- If old_string appears multiple times and replace_all is false, the tool will fail
|
|
84153
|
+
- Always verify the exact formatting of the text you want to replace
|
|
84154
|
+
|
|
84155
|
+
Examples:
|
|
84156
|
+
<edit>
|
|
84157
|
+
<file_path>src/main.js</file_path>
|
|
84158
|
+
<old_string>function oldName() {
|
|
84159
|
+
return 42;
|
|
84160
|
+
}</old_string>
|
|
84161
|
+
<new_string>function newName() {
|
|
84162
|
+
return 42;
|
|
84163
|
+
}</new_string>
|
|
84164
|
+
</edit>
|
|
84165
|
+
|
|
84166
|
+
<edit>
|
|
84167
|
+
<file_path>config.json</file_path>
|
|
84168
|
+
<old_string>"debug": false</old_string>
|
|
84169
|
+
<new_string>"debug": true</new_string>
|
|
84170
|
+
<replace_all>true</replace_all>
|
|
84171
|
+
</edit>`;
|
|
84172
|
+
createToolDefinition = `
|
|
84173
|
+
## create
|
|
84174
|
+
Description: ${createDescription}
|
|
84175
|
+
|
|
84176
|
+
When to use:
|
|
84177
|
+
- For creating brand new files from scratch
|
|
84178
|
+
- When you need to add configuration files, documentation, or new modules
|
|
84179
|
+
- For generating boilerplate code or templates
|
|
84180
|
+
- When you have the complete content ready to write
|
|
84181
|
+
|
|
84182
|
+
When NOT to use:
|
|
84183
|
+
- For editing existing files (use 'edit' tool instead)
|
|
84184
|
+
- When a file already exists unless you explicitly want to overwrite it
|
|
84185
|
+
|
|
84186
|
+
Parameters:
|
|
84187
|
+
- file_path: (required) Path where the file should be created
|
|
84188
|
+
- content: (required) Complete content to write to the file
|
|
84189
|
+
- overwrite: (optional, default: false) Whether to overwrite if file already exists
|
|
84190
|
+
|
|
84191
|
+
Important notes:
|
|
84192
|
+
- Parent directories will be created automatically if they don't exist
|
|
84193
|
+
- The tool will fail if the file already exists and overwrite is false
|
|
84194
|
+
- Be careful with the overwrite option as it completely replaces existing files
|
|
84195
|
+
|
|
84196
|
+
Examples:
|
|
84197
|
+
<create>
|
|
84198
|
+
<file_path>src/newFile.js</file_path>
|
|
84199
|
+
<content>export function hello() {
|
|
84200
|
+
return "Hello, world!";
|
|
84201
|
+
}</content>
|
|
84202
|
+
</create>
|
|
84203
|
+
|
|
84204
|
+
<create>
|
|
84205
|
+
<file_path>README.md</file_path>
|
|
84206
|
+
<content># My Project
|
|
84207
|
+
|
|
84208
|
+
This is a new project.</content>
|
|
84209
|
+
<overwrite>true</overwrite>
|
|
84210
|
+
</create>`;
|
|
84211
|
+
}
|
|
84212
|
+
});
|
|
84213
|
+
|
|
82908
84214
|
// src/tools/langchain.js
|
|
82909
84215
|
function createSearchTool() {
|
|
82910
84216
|
return {
|
|
@@ -83126,13 +84432,21 @@ __export(tools_exports, {
|
|
|
83126
84432
|
bashSchema: () => bashSchema,
|
|
83127
84433
|
bashTool: () => bashTool,
|
|
83128
84434
|
bashToolDefinition: () => bashToolDefinition,
|
|
84435
|
+
createDescription: () => createDescription,
|
|
83129
84436
|
createExtractTool: () => createExtractTool,
|
|
83130
84437
|
createQueryTool: () => createQueryTool,
|
|
84438
|
+
createSchema: () => createSchema,
|
|
83131
84439
|
createSearchTool: () => createSearchTool,
|
|
84440
|
+
createTool: () => createTool,
|
|
84441
|
+
createToolDefinition: () => createToolDefinition,
|
|
83132
84442
|
delegateDescription: () => delegateDescription,
|
|
83133
84443
|
delegateSchema: () => delegateSchema,
|
|
83134
84444
|
delegateTool: () => delegateTool,
|
|
83135
84445
|
delegateToolDefinition: () => delegateToolDefinition,
|
|
84446
|
+
editDescription: () => editDescription,
|
|
84447
|
+
editSchema: () => editSchema,
|
|
84448
|
+
editTool: () => editTool,
|
|
84449
|
+
editToolDefinition: () => editToolDefinition,
|
|
83136
84450
|
extractSchema: () => extractSchema,
|
|
83137
84451
|
extractTool: () => extractTool,
|
|
83138
84452
|
querySchema: () => querySchema,
|
|
@@ -83147,8 +84461,10 @@ var init_tools2 = __esm({
|
|
|
83147
84461
|
"use strict";
|
|
83148
84462
|
init_vercel();
|
|
83149
84463
|
init_bash();
|
|
84464
|
+
init_edit();
|
|
83150
84465
|
init_langchain();
|
|
83151
84466
|
init_common2();
|
|
84467
|
+
init_edit();
|
|
83152
84468
|
init_system_message();
|
|
83153
84469
|
init_vercel();
|
|
83154
84470
|
init_bash();
|
|
@@ -83171,10 +84487,10 @@ async function listFilesByLevel(options) {
|
|
|
83171
84487
|
maxFiles = 100,
|
|
83172
84488
|
respectGitignore = true
|
|
83173
84489
|
} = options;
|
|
83174
|
-
if (!
|
|
84490
|
+
if (!import_fs9.default.existsSync(directory)) {
|
|
83175
84491
|
throw new Error(`Directory does not exist: ${directory}`);
|
|
83176
84492
|
}
|
|
83177
|
-
const gitDirExists =
|
|
84493
|
+
const gitDirExists = import_fs9.default.existsSync(import_path10.default.join(directory, ".git"));
|
|
83178
84494
|
if (gitDirExists && respectGitignore) {
|
|
83179
84495
|
try {
|
|
83180
84496
|
return await listFilesUsingGit(directory, maxFiles);
|
|
@@ -83189,8 +84505,8 @@ async function listFilesUsingGit(directory, maxFiles) {
|
|
|
83189
84505
|
const { stdout } = await execAsync3("git ls-files", { cwd: directory });
|
|
83190
84506
|
const files = stdout.split("\n").filter(Boolean);
|
|
83191
84507
|
const sortedFiles = files.sort((a3, b3) => {
|
|
83192
|
-
const depthA = a3.split(
|
|
83193
|
-
const depthB = b3.split(
|
|
84508
|
+
const depthA = a3.split(import_path10.default.sep).length;
|
|
84509
|
+
const depthB = b3.split(import_path10.default.sep).length;
|
|
83194
84510
|
return depthA - depthB;
|
|
83195
84511
|
});
|
|
83196
84512
|
return sortedFiles.slice(0, maxFiles);
|
|
@@ -83205,19 +84521,19 @@ async function listFilesByLevelManually(directory, maxFiles, respectGitignore) {
|
|
|
83205
84521
|
while (queue.length > 0 && result.length < maxFiles) {
|
|
83206
84522
|
const { dir, level } = queue.shift();
|
|
83207
84523
|
try {
|
|
83208
|
-
const entries =
|
|
84524
|
+
const entries = import_fs9.default.readdirSync(dir, { withFileTypes: true });
|
|
83209
84525
|
const files = entries.filter((entry) => entry.isFile());
|
|
83210
84526
|
for (const file of files) {
|
|
83211
84527
|
if (result.length >= maxFiles) break;
|
|
83212
|
-
const filePath =
|
|
83213
|
-
const relativePath =
|
|
84528
|
+
const filePath = import_path10.default.join(dir, file.name);
|
|
84529
|
+
const relativePath = import_path10.default.relative(directory, filePath);
|
|
83214
84530
|
if (shouldIgnore(relativePath, ignorePatterns)) continue;
|
|
83215
84531
|
result.push(relativePath);
|
|
83216
84532
|
}
|
|
83217
84533
|
const dirs = entries.filter((entry) => entry.isDirectory());
|
|
83218
84534
|
for (const subdir of dirs) {
|
|
83219
|
-
const subdirPath =
|
|
83220
|
-
const relativeSubdirPath =
|
|
84535
|
+
const subdirPath = import_path10.default.join(dir, subdir.name);
|
|
84536
|
+
const relativeSubdirPath = import_path10.default.relative(directory, subdirPath);
|
|
83221
84537
|
if (shouldIgnore(relativeSubdirPath, ignorePatterns)) continue;
|
|
83222
84538
|
if (subdir.name === "node_modules" || subdir.name === ".git") continue;
|
|
83223
84539
|
queue.push({ dir: subdirPath, level: level + 1 });
|
|
@@ -83229,12 +84545,12 @@ async function listFilesByLevelManually(directory, maxFiles, respectGitignore) {
|
|
|
83229
84545
|
return result;
|
|
83230
84546
|
}
|
|
83231
84547
|
function loadGitignorePatterns(directory) {
|
|
83232
|
-
const gitignorePath =
|
|
83233
|
-
if (!
|
|
84548
|
+
const gitignorePath = import_path10.default.join(directory, ".gitignore");
|
|
84549
|
+
if (!import_fs9.default.existsSync(gitignorePath)) {
|
|
83234
84550
|
return [];
|
|
83235
84551
|
}
|
|
83236
84552
|
try {
|
|
83237
|
-
const content =
|
|
84553
|
+
const content = import_fs9.default.readFileSync(gitignorePath, "utf8");
|
|
83238
84554
|
return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
83239
84555
|
} catch (error2) {
|
|
83240
84556
|
console.error(`Warning: Could not read .gitignore: ${error2.message}`);
|
|
@@ -83252,12 +84568,12 @@ function shouldIgnore(filePath, ignorePatterns) {
|
|
|
83252
84568
|
}
|
|
83253
84569
|
return false;
|
|
83254
84570
|
}
|
|
83255
|
-
var
|
|
84571
|
+
var import_fs9, import_path10, import_util12, import_child_process8, execAsync3;
|
|
83256
84572
|
var init_file_lister = __esm({
|
|
83257
84573
|
"src/utils/file-lister.js"() {
|
|
83258
84574
|
"use strict";
|
|
83259
|
-
|
|
83260
|
-
|
|
84575
|
+
import_fs9 = __toESM(require("fs"), 1);
|
|
84576
|
+
import_path10 = __toESM(require("path"), 1);
|
|
83261
84577
|
import_util12 = require("util");
|
|
83262
84578
|
import_child_process8 = require("child_process");
|
|
83263
84579
|
execAsync3 = (0, import_util12.promisify)(import_child_process8.exec);
|
|
@@ -83274,12 +84590,12 @@ function initializeSimpleTelemetryFromOptions(options) {
|
|
|
83274
84590
|
});
|
|
83275
84591
|
return telemetry;
|
|
83276
84592
|
}
|
|
83277
|
-
var
|
|
84593
|
+
var import_fs10, import_path11, SimpleTelemetry, SimpleAppTracer;
|
|
83278
84594
|
var init_simpleTelemetry = __esm({
|
|
83279
84595
|
"src/agent/simpleTelemetry.js"() {
|
|
83280
84596
|
"use strict";
|
|
83281
|
-
|
|
83282
|
-
|
|
84597
|
+
import_fs10 = require("fs");
|
|
84598
|
+
import_path11 = require("path");
|
|
83283
84599
|
SimpleTelemetry = class {
|
|
83284
84600
|
constructor(options = {}) {
|
|
83285
84601
|
this.serviceName = options.serviceName || "probe-agent";
|
|
@@ -83293,11 +84609,11 @@ var init_simpleTelemetry = __esm({
|
|
|
83293
84609
|
}
|
|
83294
84610
|
initializeFileExporter() {
|
|
83295
84611
|
try {
|
|
83296
|
-
const dir = (0,
|
|
83297
|
-
if (!(0,
|
|
83298
|
-
(0,
|
|
84612
|
+
const dir = (0, import_path11.dirname)(this.filePath);
|
|
84613
|
+
if (!(0, import_fs10.existsSync)(dir)) {
|
|
84614
|
+
(0, import_fs10.mkdirSync)(dir, { recursive: true });
|
|
83299
84615
|
}
|
|
83300
|
-
this.stream = (0,
|
|
84616
|
+
this.stream = (0, import_fs10.createWriteStream)(this.filePath, { flags: "a" });
|
|
83301
84617
|
this.stream.on("error", (error2) => {
|
|
83302
84618
|
console.error(`[SimpleTelemetry] Stream error: ${error2.message}`);
|
|
83303
84619
|
});
|
|
@@ -83358,20 +84674,20 @@ var init_simpleTelemetry = __esm({
|
|
|
83358
84674
|
}
|
|
83359
84675
|
async flush() {
|
|
83360
84676
|
if (this.stream) {
|
|
83361
|
-
return new Promise((
|
|
83362
|
-
this.stream.once("drain",
|
|
84677
|
+
return new Promise((resolve5) => {
|
|
84678
|
+
this.stream.once("drain", resolve5);
|
|
83363
84679
|
if (!this.stream.writableNeedDrain) {
|
|
83364
|
-
|
|
84680
|
+
resolve5();
|
|
83365
84681
|
}
|
|
83366
84682
|
});
|
|
83367
84683
|
}
|
|
83368
84684
|
}
|
|
83369
84685
|
async shutdown() {
|
|
83370
84686
|
if (this.stream) {
|
|
83371
|
-
return new Promise((
|
|
84687
|
+
return new Promise((resolve5) => {
|
|
83372
84688
|
this.stream.end(() => {
|
|
83373
84689
|
console.log(`[SimpleTelemetry] File stream closed: ${this.filePath}`);
|
|
83374
|
-
|
|
84690
|
+
resolve5();
|
|
83375
84691
|
});
|
|
83376
84692
|
});
|
|
83377
84693
|
}
|
|
@@ -83522,10 +84838,16 @@ __export(index_exports, {
|
|
|
83522
84838
|
bashSchema: () => bashSchema,
|
|
83523
84839
|
bashTool: () => bashTool,
|
|
83524
84840
|
bashToolDefinition: () => bashToolDefinition,
|
|
84841
|
+
createSchema: () => createSchema,
|
|
84842
|
+
createTool: () => createTool,
|
|
84843
|
+
createToolDefinition: () => createToolDefinition,
|
|
83525
84844
|
delegate: () => delegate,
|
|
83526
84845
|
delegateSchema: () => delegateSchema,
|
|
83527
84846
|
delegateTool: () => delegateTool,
|
|
83528
84847
|
delegateToolDefinition: () => delegateToolDefinition,
|
|
84848
|
+
editSchema: () => editSchema,
|
|
84849
|
+
editTool: () => editTool,
|
|
84850
|
+
editToolDefinition: () => editToolDefinition,
|
|
83529
84851
|
extract: () => extract,
|
|
83530
84852
|
extractSchema: () => extractSchema,
|
|
83531
84853
|
extractTool: () => extractTool,
|
|
@@ -83563,8 +84885,10 @@ var init_index = __esm({
|
|
|
83563
84885
|
init_file_lister();
|
|
83564
84886
|
init_system_message();
|
|
83565
84887
|
init_common2();
|
|
84888
|
+
init_edit();
|
|
83566
84889
|
init_vercel();
|
|
83567
84890
|
init_bash();
|
|
84891
|
+
init_edit();
|
|
83568
84892
|
init_ProbeAgent();
|
|
83569
84893
|
init_simpleTelemetry();
|
|
83570
84894
|
init_probeTool();
|
|
@@ -83589,10 +84913,16 @@ init_index();
|
|
|
83589
84913
|
bashSchema,
|
|
83590
84914
|
bashTool,
|
|
83591
84915
|
bashToolDefinition,
|
|
84916
|
+
createSchema,
|
|
84917
|
+
createTool,
|
|
84918
|
+
createToolDefinition,
|
|
83592
84919
|
delegate,
|
|
83593
84920
|
delegateSchema,
|
|
83594
84921
|
delegateTool,
|
|
83595
84922
|
delegateToolDefinition,
|
|
84923
|
+
editSchema,
|
|
84924
|
+
editTool,
|
|
84925
|
+
editToolDefinition,
|
|
83596
84926
|
extract,
|
|
83597
84927
|
extractSchema,
|
|
83598
84928
|
extractTool,
|