@get-bb/plugin-sdk 0.6.90 → 0.6.94
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/bundled-types/bb-plugin-sdk-app.d.ts +105 -56
- package/bundled-types/bb-plugin-sdk-internal-plugin-app-collector.d.ts +14 -3
- package/bundled-types/bb-plugin-sdk-internal-rpc-query-host.d.ts +1 -1
- package/bundled-types/bb-plugin-sdk-testing-app.d.ts +13 -2
- package/bundled-types/bb-plugin-sdk.d.ts +103 -55
- package/dist/app.js +4 -0
- package/dist/host.js +93 -1
- package/dist/internal/plugin-app-collector.js +29 -10
- package/dist/internal/rpc-query-host.js +69 -41
- package/dist/process.js +100 -3
- package/dist/provider-bridge-acp-next.js +118 -19
- package/dist/provider-bridge-acp.js +118 -19
- package/dist/provider-bridge-testing.js +95 -5
- package/dist/provider-bridge-worker-entry.mjs +93 -1
- package/dist/provider-bridge.js +95 -5
- package/dist/testing/app.js +105 -54
- package/package.json +3 -3
|
@@ -3390,8 +3390,7 @@ var toolCallRequestParamsSchema = z28.object({
|
|
|
3390
3390
|
turnId: z28.union([z28.string().min(1), z28.null()]),
|
|
3391
3391
|
callId: z28.string().min(1),
|
|
3392
3392
|
tool: z28.string().min(1),
|
|
3393
|
-
arguments: z28.unknown()
|
|
3394
|
-
providerNativeIds: z28.boolean().optional()
|
|
3393
|
+
arguments: z28.unknown()
|
|
3395
3394
|
}).passthrough();
|
|
3396
3395
|
var toolCallResultSchema = z28.object({
|
|
3397
3396
|
success: z28.boolean(),
|
|
@@ -3409,8 +3408,7 @@ var interactionRequestParamsSchema = z28.object({
|
|
|
3409
3408
|
providerThreadId: z28.string().min(1),
|
|
3410
3409
|
threadId: z28.string().min(1).optional(),
|
|
3411
3410
|
turnId: z28.union([z28.string().min(1), z28.null()]),
|
|
3412
|
-
payload: pendingInteractionPayloadSchema
|
|
3413
|
-
providerNativeIds: z28.boolean().optional()
|
|
3411
|
+
payload: pendingInteractionPayloadSchema
|
|
3414
3412
|
}).passthrough();
|
|
3415
3413
|
|
|
3416
3414
|
// ../provider-bridge-protocol/src/thread-delta.ts
|
|
@@ -4501,6 +4499,97 @@ function whichCommandSync(command, options = {}) {
|
|
|
4501
4499
|
return void 0;
|
|
4502
4500
|
}
|
|
4503
4501
|
|
|
4502
|
+
// ../process-utils/src/node-network.ts
|
|
4503
|
+
var NODE_NETWORK_FLAGS = {
|
|
4504
|
+
"--use-system-ca": "NODE_USE_SYSTEM_CA",
|
|
4505
|
+
"--use-env-proxy": "NODE_USE_ENV_PROXY"
|
|
4506
|
+
};
|
|
4507
|
+
var ENV_PROXY_FLAG = "--use-env-proxy";
|
|
4508
|
+
var PROXY_KEYS = /* @__PURE__ */ new Set(["HTTP_PROXY", "HTTPS_PROXY"]);
|
|
4509
|
+
var NO_PROXY_KEY = "NO_PROXY";
|
|
4510
|
+
var LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "::1", "[::1]"];
|
|
4511
|
+
function isNodeNetworkFlag(arg) {
|
|
4512
|
+
return Object.hasOwn(NODE_NETWORK_FLAGS, arg);
|
|
4513
|
+
}
|
|
4514
|
+
function isHttpProxyUrl(value) {
|
|
4515
|
+
if (/[\r\n]/u.test(value)) return false;
|
|
4516
|
+
try {
|
|
4517
|
+
const url2 = new URL(value);
|
|
4518
|
+
return (url2.protocol === "http:" || url2.protocol === "https:") && url2.hostname !== "";
|
|
4519
|
+
} catch {
|
|
4520
|
+
return false;
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
function proxyEntries(env) {
|
|
4524
|
+
return Object.entries(env).filter(
|
|
4525
|
+
(entry) => PROXY_KEYS.has(entry[0].toUpperCase()) && entry[1] !== void 0 && entry[1] !== ""
|
|
4526
|
+
);
|
|
4527
|
+
}
|
|
4528
|
+
function appendLoopback(value) {
|
|
4529
|
+
const entries = value.split(/[\s,]+/u).filter(Boolean);
|
|
4530
|
+
if (entries.includes("*")) return value;
|
|
4531
|
+
const present = new Set(entries.map((entry) => entry.toLowerCase()));
|
|
4532
|
+
return [
|
|
4533
|
+
...entries,
|
|
4534
|
+
...LOOPBACK_HOSTS.filter((host) => !present.has(host))
|
|
4535
|
+
].join(",");
|
|
4536
|
+
}
|
|
4537
|
+
function withLoopbackNoProxy(env) {
|
|
4538
|
+
const result = { ...env };
|
|
4539
|
+
const keys = Object.keys(result).filter(
|
|
4540
|
+
(key) => key.toUpperCase() === NO_PROXY_KEY && result[key] !== void 0
|
|
4541
|
+
);
|
|
4542
|
+
for (const key of keys.length > 0 ? keys : [NO_PROXY_KEY])
|
|
4543
|
+
result[key] = appendLoopback(result[key] ?? "");
|
|
4544
|
+
return result;
|
|
4545
|
+
}
|
|
4546
|
+
function nodeNetworkLaunch(nodeArgs, env) {
|
|
4547
|
+
const enabled = nodeArgs.filter(
|
|
4548
|
+
(arg) => !isNodeNetworkFlag(arg) || env[NODE_NETWORK_FLAGS[arg]] !== "0"
|
|
4549
|
+
);
|
|
4550
|
+
if (!enabled.includes(ENV_PROXY_FLAG))
|
|
4551
|
+
return { nodeArgs: enabled, env, rejectedProxyKeys: [] };
|
|
4552
|
+
const proxies = proxyEntries(env);
|
|
4553
|
+
const rejectedProxyKeys = proxies.filter(([, value]) => !isHttpProxyUrl(value)).map(([key]) => key);
|
|
4554
|
+
if (rejectedProxyKeys.length > 0)
|
|
4555
|
+
return {
|
|
4556
|
+
nodeArgs: enabled.filter((arg) => arg !== ENV_PROXY_FLAG),
|
|
4557
|
+
env,
|
|
4558
|
+
rejectedProxyKeys
|
|
4559
|
+
};
|
|
4560
|
+
return {
|
|
4561
|
+
nodeArgs: enabled,
|
|
4562
|
+
env: proxies.length > 0 ? withLoopbackNoProxy(env) : env,
|
|
4563
|
+
rejectedProxyKeys: []
|
|
4564
|
+
};
|
|
4565
|
+
}
|
|
4566
|
+
var warnedProxyKeys = /* @__PURE__ */ new Set();
|
|
4567
|
+
function prepareNodeNetworkLaunch(nodeArgs, env) {
|
|
4568
|
+
const launch = nodeNetworkLaunch(nodeArgs, env);
|
|
4569
|
+
const unwarned = launch.rejectedProxyKeys.filter(
|
|
4570
|
+
(key) => !warnedProxyKeys.has(key)
|
|
4571
|
+
);
|
|
4572
|
+
if (unwarned.length > 0) {
|
|
4573
|
+
for (const key of unwarned) warnedProxyKeys.add(key);
|
|
4574
|
+
process.emitWarning(
|
|
4575
|
+
`bb started a Node process without --use-env-proxy because ${unwarned.join(", ")} is not an http:// or https:// URL. Add the scheme, for example http://proxy.example:3128, so bb uses the proxy.`,
|
|
4576
|
+
{ code: "BB_INVALID_PROXY_ENV" }
|
|
4577
|
+
);
|
|
4578
|
+
}
|
|
4579
|
+
return { nodeArgs: launch.nodeArgs, env: launch.env };
|
|
4580
|
+
}
|
|
4581
|
+
function prepareNodeNetworkCommand(args, env) {
|
|
4582
|
+
const scriptIndex = args.findIndex(
|
|
4583
|
+
(arg) => arg === "--" || !arg.startsWith("-")
|
|
4584
|
+
);
|
|
4585
|
+
const optionCount = scriptIndex < 0 ? args.length : scriptIndex;
|
|
4586
|
+
const launch = prepareNodeNetworkLaunch(args.slice(0, optionCount), env);
|
|
4587
|
+
return {
|
|
4588
|
+
args: [...launch.nodeArgs, ...args.slice(optionCount)],
|
|
4589
|
+
env: launch.env
|
|
4590
|
+
};
|
|
4591
|
+
}
|
|
4592
|
+
|
|
4504
4593
|
// ../process-utils/src/host-toolchain.ts
|
|
4505
4594
|
var NETWORK_KEYS = [
|
|
4506
4595
|
"HTTP_PROXY",
|
|
@@ -4861,7 +4950,8 @@ var HostToolchain = class {
|
|
|
4861
4950
|
if (/(?:^|[\\/])(?:npm|npx)-cli\.js$/u.test(args[0] ?? "")) {
|
|
4862
4951
|
env.PATH = mergePath(dirname(file), env.PATH);
|
|
4863
4952
|
}
|
|
4864
|
-
|
|
4953
|
+
const network = prepareNodeNetworkCommand(args, env);
|
|
4954
|
+
return { command: file, args: network.args, env: network.env };
|
|
4865
4955
|
}
|
|
4866
4956
|
};
|
|
4867
4957
|
var toolchainKey = /* @__PURE__ */ Symbol.for("@bb/process-utils/host-toolchain");
|
|
@@ -23612,7 +23702,9 @@ async function startAgentSession(request) {
|
|
|
23612
23702
|
providerThreadId: sessionId,
|
|
23613
23703
|
sessionRestorable: session.supportsLoadSession
|
|
23614
23704
|
});
|
|
23615
|
-
|
|
23705
|
+
if (request.kind !== "resume" || !request.continuesTurn) {
|
|
23706
|
+
sendThreadDeltas(bbThreadId, [{ kind: "session.reset" }]);
|
|
23707
|
+
}
|
|
23616
23708
|
publishSessionSnapshot(session);
|
|
23617
23709
|
if (createdFreshSession) {
|
|
23618
23710
|
emitGrokContextWindow(session, 0);
|
|
@@ -24017,12 +24109,7 @@ function runTurn(session, firstInput, turnAlreadyOpen = false) {
|
|
|
24017
24109
|
}
|
|
24018
24110
|
setActivePromptKind(session, "turn");
|
|
24019
24111
|
session.turnSettled = previousSession.turnSettled;
|
|
24020
|
-
|
|
24021
|
-
emitForSession(session, ACP_TURN_STARTED_METHOD, {
|
|
24022
|
-
threadId: session.bbThreadId
|
|
24023
|
-
});
|
|
24024
|
-
session.awaitingFirstPrompt = false;
|
|
24025
|
-
}
|
|
24112
|
+
session.awaitingFirstPrompt = false;
|
|
24026
24113
|
const prompt = buildPromptContentBlocks(session, pending.input);
|
|
24027
24114
|
let inputAccepted = false;
|
|
24028
24115
|
let busyRetries = 0;
|
|
@@ -24196,20 +24283,31 @@ async function rebuildAgentSession(session, construction) {
|
|
|
24196
24283
|
const reason = session.connection.exited ? "The ACP agent exited unexpectedly; its session was rebuilt before continuing." : session.restartAfterCancelError ? "The ACP agent failed during cancellation; its session was rebuilt before continuing." : "Execution settings changed; the ACP session was rebuilt to apply them.";
|
|
24197
24284
|
const queuedInputs = session.queuedInputs.splice(0);
|
|
24198
24285
|
const continuingTurn = session.activePromptKind === "turn";
|
|
24199
|
-
|
|
24286
|
+
if (continuingTurn) {
|
|
24287
|
+
emitForSession(session, ACP_PROMPT_INTERRUPTED_METHOD, {
|
|
24288
|
+
threadId: session.bbThreadId
|
|
24289
|
+
});
|
|
24290
|
+
for (const controller of session.pendingToolCalls) controller.abort();
|
|
24291
|
+
setActivePromptKind(session, null);
|
|
24292
|
+
session.promptRequestPending = false;
|
|
24293
|
+
session.cancelRequested = false;
|
|
24294
|
+
}
|
|
24200
24295
|
let replacement;
|
|
24201
24296
|
try {
|
|
24202
24297
|
replacement = await startAgentSession({
|
|
24203
24298
|
kind: "resume",
|
|
24204
24299
|
params: construction,
|
|
24205
|
-
resumeProviderThreadId: previousProviderThreadId
|
|
24300
|
+
resumeProviderThreadId: previousProviderThreadId,
|
|
24301
|
+
continuesTurn: continuingTurn
|
|
24206
24302
|
});
|
|
24207
24303
|
} catch (error) {
|
|
24208
24304
|
if (continuingTurn) {
|
|
24209
|
-
|
|
24210
|
-
|
|
24211
|
-
|
|
24212
|
-
|
|
24305
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
24306
|
+
emitForSession(session, "error", {
|
|
24307
|
+
threadId: session.bbThreadId,
|
|
24308
|
+
message
|
|
24309
|
+
});
|
|
24310
|
+
emitSessionError(session, message);
|
|
24213
24311
|
}
|
|
24214
24312
|
throw error;
|
|
24215
24313
|
}
|
|
@@ -24620,7 +24718,8 @@ async function handleRequest2(request) {
|
|
|
24620
24718
|
request.method === "thread/resume" ? {
|
|
24621
24719
|
kind: "resume",
|
|
24622
24720
|
params: sessionParams,
|
|
24623
|
-
resumeProviderThreadId: request.params.providerThreadId
|
|
24721
|
+
resumeProviderThreadId: request.params.providerThreadId,
|
|
24722
|
+
continuesTurn: false
|
|
24624
24723
|
} : request.method === "thread/fork" ? {
|
|
24625
24724
|
kind: "fork",
|
|
24626
24725
|
params: sessionParams,
|
|
@@ -4770,8 +4770,7 @@ var toolCallRequestParamsSchema = z29.object({
|
|
|
4770
4770
|
turnId: z29.union([z29.string().min(1), z29.null()]),
|
|
4771
4771
|
callId: z29.string().min(1),
|
|
4772
4772
|
tool: z29.string().min(1),
|
|
4773
|
-
arguments: z29.unknown()
|
|
4774
|
-
providerNativeIds: z29.boolean().optional()
|
|
4773
|
+
arguments: z29.unknown()
|
|
4775
4774
|
}).passthrough();
|
|
4776
4775
|
var toolCallResultSchema = z29.object({
|
|
4777
4776
|
success: z29.boolean(),
|
|
@@ -4789,8 +4788,7 @@ var interactionRequestParamsSchema = z29.object({
|
|
|
4789
4788
|
providerThreadId: z29.string().min(1),
|
|
4790
4789
|
threadId: z29.string().min(1).optional(),
|
|
4791
4790
|
turnId: z29.union([z29.string().min(1), z29.null()]),
|
|
4792
|
-
payload: pendingInteractionPayloadSchema
|
|
4793
|
-
providerNativeIds: z29.boolean().optional()
|
|
4791
|
+
payload: pendingInteractionPayloadSchema
|
|
4794
4792
|
}).passthrough();
|
|
4795
4793
|
|
|
4796
4794
|
// ../provider-bridge-protocol/src/thread-event-grammar.ts
|
|
@@ -6433,6 +6431,97 @@ function whichCommandSync(command, options = {}) {
|
|
|
6433
6431
|
return void 0;
|
|
6434
6432
|
}
|
|
6435
6433
|
|
|
6434
|
+
// ../process-utils/src/node-network.ts
|
|
6435
|
+
var NODE_NETWORK_FLAGS = {
|
|
6436
|
+
"--use-system-ca": "NODE_USE_SYSTEM_CA",
|
|
6437
|
+
"--use-env-proxy": "NODE_USE_ENV_PROXY"
|
|
6438
|
+
};
|
|
6439
|
+
var ENV_PROXY_FLAG = "--use-env-proxy";
|
|
6440
|
+
var PROXY_KEYS = /* @__PURE__ */ new Set(["HTTP_PROXY", "HTTPS_PROXY"]);
|
|
6441
|
+
var NO_PROXY_KEY = "NO_PROXY";
|
|
6442
|
+
var LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "::1", "[::1]"];
|
|
6443
|
+
function isNodeNetworkFlag(arg) {
|
|
6444
|
+
return Object.hasOwn(NODE_NETWORK_FLAGS, arg);
|
|
6445
|
+
}
|
|
6446
|
+
function isHttpProxyUrl(value) {
|
|
6447
|
+
if (/[\r\n]/u.test(value)) return false;
|
|
6448
|
+
try {
|
|
6449
|
+
const url = new URL(value);
|
|
6450
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.hostname !== "";
|
|
6451
|
+
} catch {
|
|
6452
|
+
return false;
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6455
|
+
function proxyEntries(env) {
|
|
6456
|
+
return Object.entries(env).filter(
|
|
6457
|
+
(entry) => PROXY_KEYS.has(entry[0].toUpperCase()) && entry[1] !== void 0 && entry[1] !== ""
|
|
6458
|
+
);
|
|
6459
|
+
}
|
|
6460
|
+
function appendLoopback(value) {
|
|
6461
|
+
const entries = value.split(/[\s,]+/u).filter(Boolean);
|
|
6462
|
+
if (entries.includes("*")) return value;
|
|
6463
|
+
const present = new Set(entries.map((entry) => entry.toLowerCase()));
|
|
6464
|
+
return [
|
|
6465
|
+
...entries,
|
|
6466
|
+
...LOOPBACK_HOSTS.filter((host) => !present.has(host))
|
|
6467
|
+
].join(",");
|
|
6468
|
+
}
|
|
6469
|
+
function withLoopbackNoProxy(env) {
|
|
6470
|
+
const result2 = { ...env };
|
|
6471
|
+
const keys = Object.keys(result2).filter(
|
|
6472
|
+
(key) => key.toUpperCase() === NO_PROXY_KEY && result2[key] !== void 0
|
|
6473
|
+
);
|
|
6474
|
+
for (const key of keys.length > 0 ? keys : [NO_PROXY_KEY])
|
|
6475
|
+
result2[key] = appendLoopback(result2[key] ?? "");
|
|
6476
|
+
return result2;
|
|
6477
|
+
}
|
|
6478
|
+
function nodeNetworkLaunch(nodeArgs, env) {
|
|
6479
|
+
const enabled = nodeArgs.filter(
|
|
6480
|
+
(arg) => !isNodeNetworkFlag(arg) || env[NODE_NETWORK_FLAGS[arg]] !== "0"
|
|
6481
|
+
);
|
|
6482
|
+
if (!enabled.includes(ENV_PROXY_FLAG))
|
|
6483
|
+
return { nodeArgs: enabled, env, rejectedProxyKeys: [] };
|
|
6484
|
+
const proxies = proxyEntries(env);
|
|
6485
|
+
const rejectedProxyKeys = proxies.filter(([, value]) => !isHttpProxyUrl(value)).map(([key]) => key);
|
|
6486
|
+
if (rejectedProxyKeys.length > 0)
|
|
6487
|
+
return {
|
|
6488
|
+
nodeArgs: enabled.filter((arg) => arg !== ENV_PROXY_FLAG),
|
|
6489
|
+
env,
|
|
6490
|
+
rejectedProxyKeys
|
|
6491
|
+
};
|
|
6492
|
+
return {
|
|
6493
|
+
nodeArgs: enabled,
|
|
6494
|
+
env: proxies.length > 0 ? withLoopbackNoProxy(env) : env,
|
|
6495
|
+
rejectedProxyKeys: []
|
|
6496
|
+
};
|
|
6497
|
+
}
|
|
6498
|
+
var warnedProxyKeys = /* @__PURE__ */ new Set();
|
|
6499
|
+
function prepareNodeNetworkLaunch(nodeArgs, env) {
|
|
6500
|
+
const launch = nodeNetworkLaunch(nodeArgs, env);
|
|
6501
|
+
const unwarned = launch.rejectedProxyKeys.filter(
|
|
6502
|
+
(key) => !warnedProxyKeys.has(key)
|
|
6503
|
+
);
|
|
6504
|
+
if (unwarned.length > 0) {
|
|
6505
|
+
for (const key of unwarned) warnedProxyKeys.add(key);
|
|
6506
|
+
process.emitWarning(
|
|
6507
|
+
`bb started a Node process without --use-env-proxy because ${unwarned.join(", ")} is not an http:// or https:// URL. Add the scheme, for example http://proxy.example:3128, so bb uses the proxy.`,
|
|
6508
|
+
{ code: "BB_INVALID_PROXY_ENV" }
|
|
6509
|
+
);
|
|
6510
|
+
}
|
|
6511
|
+
return { nodeArgs: launch.nodeArgs, env: launch.env };
|
|
6512
|
+
}
|
|
6513
|
+
function prepareNodeNetworkCommand(args, env) {
|
|
6514
|
+
const scriptIndex = args.findIndex(
|
|
6515
|
+
(arg) => arg === "--" || !arg.startsWith("-")
|
|
6516
|
+
);
|
|
6517
|
+
const optionCount = scriptIndex < 0 ? args.length : scriptIndex;
|
|
6518
|
+
const launch = prepareNodeNetworkLaunch(args.slice(0, optionCount), env);
|
|
6519
|
+
return {
|
|
6520
|
+
args: [...launch.nodeArgs, ...args.slice(optionCount)],
|
|
6521
|
+
env: launch.env
|
|
6522
|
+
};
|
|
6523
|
+
}
|
|
6524
|
+
|
|
6436
6525
|
// ../process-utils/src/host-toolchain.ts
|
|
6437
6526
|
var NETWORK_KEYS = [
|
|
6438
6527
|
"HTTP_PROXY",
|
|
@@ -6793,7 +6882,8 @@ var HostToolchain = class {
|
|
|
6793
6882
|
if (/(?:^|[\\/])(?:npm|npx)-cli\.js$/u.test(args[0] ?? "")) {
|
|
6794
6883
|
env.PATH = mergePath(dirname(file), env.PATH);
|
|
6795
6884
|
}
|
|
6796
|
-
|
|
6885
|
+
const network = prepareNodeNetworkCommand(args, env);
|
|
6886
|
+
return { command: file, args: network.args, env: network.env };
|
|
6797
6887
|
}
|
|
6798
6888
|
};
|
|
6799
6889
|
var toolchainKey = /* @__PURE__ */ Symbol.for("@bb/process-utils/host-toolchain");
|
|
@@ -651,6 +651,97 @@ function whichCommandSync(command, options = {}) {
|
|
|
651
651
|
return void 0;
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
+
// ../process-utils/src/node-network.ts
|
|
655
|
+
var NODE_NETWORK_FLAGS = {
|
|
656
|
+
"--use-system-ca": "NODE_USE_SYSTEM_CA",
|
|
657
|
+
"--use-env-proxy": "NODE_USE_ENV_PROXY"
|
|
658
|
+
};
|
|
659
|
+
var ENV_PROXY_FLAG = "--use-env-proxy";
|
|
660
|
+
var PROXY_KEYS = /* @__PURE__ */ new Set(["HTTP_PROXY", "HTTPS_PROXY"]);
|
|
661
|
+
var NO_PROXY_KEY = "NO_PROXY";
|
|
662
|
+
var LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "::1", "[::1]"];
|
|
663
|
+
function isNodeNetworkFlag(arg) {
|
|
664
|
+
return Object.hasOwn(NODE_NETWORK_FLAGS, arg);
|
|
665
|
+
}
|
|
666
|
+
function isHttpProxyUrl(value) {
|
|
667
|
+
if (/[\r\n]/u.test(value)) return false;
|
|
668
|
+
try {
|
|
669
|
+
const url = new URL(value);
|
|
670
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.hostname !== "";
|
|
671
|
+
} catch {
|
|
672
|
+
return false;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
function proxyEntries(env) {
|
|
676
|
+
return Object.entries(env).filter(
|
|
677
|
+
(entry2) => PROXY_KEYS.has(entry2[0].toUpperCase()) && entry2[1] !== void 0 && entry2[1] !== ""
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
function appendLoopback(value) {
|
|
681
|
+
const entries = value.split(/[\s,]+/u).filter(Boolean);
|
|
682
|
+
if (entries.includes("*")) return value;
|
|
683
|
+
const present = new Set(entries.map((entry2) => entry2.toLowerCase()));
|
|
684
|
+
return [
|
|
685
|
+
...entries,
|
|
686
|
+
...LOOPBACK_HOSTS.filter((host) => !present.has(host))
|
|
687
|
+
].join(",");
|
|
688
|
+
}
|
|
689
|
+
function withLoopbackNoProxy(env) {
|
|
690
|
+
const result = { ...env };
|
|
691
|
+
const keys = Object.keys(result).filter(
|
|
692
|
+
(key) => key.toUpperCase() === NO_PROXY_KEY && result[key] !== void 0
|
|
693
|
+
);
|
|
694
|
+
for (const key of keys.length > 0 ? keys : [NO_PROXY_KEY])
|
|
695
|
+
result[key] = appendLoopback(result[key] ?? "");
|
|
696
|
+
return result;
|
|
697
|
+
}
|
|
698
|
+
function nodeNetworkLaunch(nodeArgs, env) {
|
|
699
|
+
const enabled = nodeArgs.filter(
|
|
700
|
+
(arg) => !isNodeNetworkFlag(arg) || env[NODE_NETWORK_FLAGS[arg]] !== "0"
|
|
701
|
+
);
|
|
702
|
+
if (!enabled.includes(ENV_PROXY_FLAG))
|
|
703
|
+
return { nodeArgs: enabled, env, rejectedProxyKeys: [] };
|
|
704
|
+
const proxies = proxyEntries(env);
|
|
705
|
+
const rejectedProxyKeys = proxies.filter(([, value]) => !isHttpProxyUrl(value)).map(([key]) => key);
|
|
706
|
+
if (rejectedProxyKeys.length > 0)
|
|
707
|
+
return {
|
|
708
|
+
nodeArgs: enabled.filter((arg) => arg !== ENV_PROXY_FLAG),
|
|
709
|
+
env,
|
|
710
|
+
rejectedProxyKeys
|
|
711
|
+
};
|
|
712
|
+
return {
|
|
713
|
+
nodeArgs: enabled,
|
|
714
|
+
env: proxies.length > 0 ? withLoopbackNoProxy(env) : env,
|
|
715
|
+
rejectedProxyKeys: []
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
var warnedProxyKeys = /* @__PURE__ */ new Set();
|
|
719
|
+
function prepareNodeNetworkLaunch(nodeArgs, env) {
|
|
720
|
+
const launch = nodeNetworkLaunch(nodeArgs, env);
|
|
721
|
+
const unwarned = launch.rejectedProxyKeys.filter(
|
|
722
|
+
(key) => !warnedProxyKeys.has(key)
|
|
723
|
+
);
|
|
724
|
+
if (unwarned.length > 0) {
|
|
725
|
+
for (const key of unwarned) warnedProxyKeys.add(key);
|
|
726
|
+
process.emitWarning(
|
|
727
|
+
`bb started a Node process without --use-env-proxy because ${unwarned.join(", ")} is not an http:// or https:// URL. Add the scheme, for example http://proxy.example:3128, so bb uses the proxy.`,
|
|
728
|
+
{ code: "BB_INVALID_PROXY_ENV" }
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
return { nodeArgs: launch.nodeArgs, env: launch.env };
|
|
732
|
+
}
|
|
733
|
+
function prepareNodeNetworkCommand(args, env) {
|
|
734
|
+
const scriptIndex = args.findIndex(
|
|
735
|
+
(arg) => arg === "--" || !arg.startsWith("-")
|
|
736
|
+
);
|
|
737
|
+
const optionCount = scriptIndex < 0 ? args.length : scriptIndex;
|
|
738
|
+
const launch = prepareNodeNetworkLaunch(args.slice(0, optionCount), env);
|
|
739
|
+
return {
|
|
740
|
+
args: [...launch.nodeArgs, ...args.slice(optionCount)],
|
|
741
|
+
env: launch.env
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
|
|
654
745
|
// ../process-utils/src/host-toolchain.ts
|
|
655
746
|
var NETWORK_KEYS = [
|
|
656
747
|
"HTTP_PROXY",
|
|
@@ -1011,7 +1102,8 @@ var HostToolchain = class {
|
|
|
1011
1102
|
if (/(?:^|[\\/])(?:npm|npx)-cli\.js$/u.test(args[0] ?? "")) {
|
|
1012
1103
|
env.PATH = mergePath(dirname(file), env.PATH);
|
|
1013
1104
|
}
|
|
1014
|
-
|
|
1105
|
+
const network = prepareNodeNetworkCommand(args, env);
|
|
1106
|
+
return { command: file, args: network.args, env: network.env };
|
|
1015
1107
|
}
|
|
1016
1108
|
};
|
|
1017
1109
|
var toolchainKey = /* @__PURE__ */ Symbol.for("@bb/process-utils/host-toolchain");
|
package/dist/provider-bridge.js
CHANGED
|
@@ -3556,8 +3556,7 @@ var toolCallRequestParamsSchema = z23.object({
|
|
|
3556
3556
|
turnId: z23.union([z23.string().min(1), z23.null()]),
|
|
3557
3557
|
callId: z23.string().min(1),
|
|
3558
3558
|
tool: z23.string().min(1),
|
|
3559
|
-
arguments: z23.unknown()
|
|
3560
|
-
providerNativeIds: z23.boolean().optional()
|
|
3559
|
+
arguments: z23.unknown()
|
|
3561
3560
|
}).passthrough();
|
|
3562
3561
|
var toolCallResultSchema = z23.object({
|
|
3563
3562
|
success: z23.boolean(),
|
|
@@ -3575,8 +3574,7 @@ var interactionRequestParamsSchema = z23.object({
|
|
|
3575
3574
|
providerThreadId: z23.string().min(1),
|
|
3576
3575
|
threadId: z23.string().min(1).optional(),
|
|
3577
3576
|
turnId: z23.union([z23.string().min(1), z23.null()]),
|
|
3578
|
-
payload: pendingInteractionPayloadSchema
|
|
3579
|
-
providerNativeIds: z23.boolean().optional()
|
|
3577
|
+
payload: pendingInteractionPayloadSchema
|
|
3580
3578
|
}).passthrough();
|
|
3581
3579
|
|
|
3582
3580
|
// ../provider-bridge-protocol/src/bridge-kit/bridge-tool-calls.ts
|
|
@@ -4037,6 +4035,97 @@ function whichCommandSync(command, options = {}) {
|
|
|
4037
4035
|
return void 0;
|
|
4038
4036
|
}
|
|
4039
4037
|
|
|
4038
|
+
// ../process-utils/src/node-network.ts
|
|
4039
|
+
var NODE_NETWORK_FLAGS = {
|
|
4040
|
+
"--use-system-ca": "NODE_USE_SYSTEM_CA",
|
|
4041
|
+
"--use-env-proxy": "NODE_USE_ENV_PROXY"
|
|
4042
|
+
};
|
|
4043
|
+
var ENV_PROXY_FLAG = "--use-env-proxy";
|
|
4044
|
+
var PROXY_KEYS = /* @__PURE__ */ new Set(["HTTP_PROXY", "HTTPS_PROXY"]);
|
|
4045
|
+
var NO_PROXY_KEY = "NO_PROXY";
|
|
4046
|
+
var LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "::1", "[::1]"];
|
|
4047
|
+
function isNodeNetworkFlag(arg) {
|
|
4048
|
+
return Object.hasOwn(NODE_NETWORK_FLAGS, arg);
|
|
4049
|
+
}
|
|
4050
|
+
function isHttpProxyUrl(value) {
|
|
4051
|
+
if (/[\r\n]/u.test(value)) return false;
|
|
4052
|
+
try {
|
|
4053
|
+
const url = new URL(value);
|
|
4054
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.hostname !== "";
|
|
4055
|
+
} catch {
|
|
4056
|
+
return false;
|
|
4057
|
+
}
|
|
4058
|
+
}
|
|
4059
|
+
function proxyEntries(env) {
|
|
4060
|
+
return Object.entries(env).filter(
|
|
4061
|
+
(entry) => PROXY_KEYS.has(entry[0].toUpperCase()) && entry[1] !== void 0 && entry[1] !== ""
|
|
4062
|
+
);
|
|
4063
|
+
}
|
|
4064
|
+
function appendLoopback(value) {
|
|
4065
|
+
const entries = value.split(/[\s,]+/u).filter(Boolean);
|
|
4066
|
+
if (entries.includes("*")) return value;
|
|
4067
|
+
const present = new Set(entries.map((entry) => entry.toLowerCase()));
|
|
4068
|
+
return [
|
|
4069
|
+
...entries,
|
|
4070
|
+
...LOOPBACK_HOSTS.filter((host) => !present.has(host))
|
|
4071
|
+
].join(",");
|
|
4072
|
+
}
|
|
4073
|
+
function withLoopbackNoProxy(env) {
|
|
4074
|
+
const result = { ...env };
|
|
4075
|
+
const keys = Object.keys(result).filter(
|
|
4076
|
+
(key) => key.toUpperCase() === NO_PROXY_KEY && result[key] !== void 0
|
|
4077
|
+
);
|
|
4078
|
+
for (const key of keys.length > 0 ? keys : [NO_PROXY_KEY])
|
|
4079
|
+
result[key] = appendLoopback(result[key] ?? "");
|
|
4080
|
+
return result;
|
|
4081
|
+
}
|
|
4082
|
+
function nodeNetworkLaunch(nodeArgs, env) {
|
|
4083
|
+
const enabled = nodeArgs.filter(
|
|
4084
|
+
(arg) => !isNodeNetworkFlag(arg) || env[NODE_NETWORK_FLAGS[arg]] !== "0"
|
|
4085
|
+
);
|
|
4086
|
+
if (!enabled.includes(ENV_PROXY_FLAG))
|
|
4087
|
+
return { nodeArgs: enabled, env, rejectedProxyKeys: [] };
|
|
4088
|
+
const proxies = proxyEntries(env);
|
|
4089
|
+
const rejectedProxyKeys = proxies.filter(([, value]) => !isHttpProxyUrl(value)).map(([key]) => key);
|
|
4090
|
+
if (rejectedProxyKeys.length > 0)
|
|
4091
|
+
return {
|
|
4092
|
+
nodeArgs: enabled.filter((arg) => arg !== ENV_PROXY_FLAG),
|
|
4093
|
+
env,
|
|
4094
|
+
rejectedProxyKeys
|
|
4095
|
+
};
|
|
4096
|
+
return {
|
|
4097
|
+
nodeArgs: enabled,
|
|
4098
|
+
env: proxies.length > 0 ? withLoopbackNoProxy(env) : env,
|
|
4099
|
+
rejectedProxyKeys: []
|
|
4100
|
+
};
|
|
4101
|
+
}
|
|
4102
|
+
var warnedProxyKeys = /* @__PURE__ */ new Set();
|
|
4103
|
+
function prepareNodeNetworkLaunch(nodeArgs, env) {
|
|
4104
|
+
const launch = nodeNetworkLaunch(nodeArgs, env);
|
|
4105
|
+
const unwarned = launch.rejectedProxyKeys.filter(
|
|
4106
|
+
(key) => !warnedProxyKeys.has(key)
|
|
4107
|
+
);
|
|
4108
|
+
if (unwarned.length > 0) {
|
|
4109
|
+
for (const key of unwarned) warnedProxyKeys.add(key);
|
|
4110
|
+
process.emitWarning(
|
|
4111
|
+
`bb started a Node process without --use-env-proxy because ${unwarned.join(", ")} is not an http:// or https:// URL. Add the scheme, for example http://proxy.example:3128, so bb uses the proxy.`,
|
|
4112
|
+
{ code: "BB_INVALID_PROXY_ENV" }
|
|
4113
|
+
);
|
|
4114
|
+
}
|
|
4115
|
+
return { nodeArgs: launch.nodeArgs, env: launch.env };
|
|
4116
|
+
}
|
|
4117
|
+
function prepareNodeNetworkCommand(args, env) {
|
|
4118
|
+
const scriptIndex = args.findIndex(
|
|
4119
|
+
(arg) => arg === "--" || !arg.startsWith("-")
|
|
4120
|
+
);
|
|
4121
|
+
const optionCount = scriptIndex < 0 ? args.length : scriptIndex;
|
|
4122
|
+
const launch = prepareNodeNetworkLaunch(args.slice(0, optionCount), env);
|
|
4123
|
+
return {
|
|
4124
|
+
args: [...launch.nodeArgs, ...args.slice(optionCount)],
|
|
4125
|
+
env: launch.env
|
|
4126
|
+
};
|
|
4127
|
+
}
|
|
4128
|
+
|
|
4040
4129
|
// ../process-utils/src/host-toolchain.ts
|
|
4041
4130
|
var NETWORK_KEYS = [
|
|
4042
4131
|
"HTTP_PROXY",
|
|
@@ -4397,7 +4486,8 @@ var HostToolchain = class {
|
|
|
4397
4486
|
if (/(?:^|[\\/])(?:npm|npx)-cli\.js$/u.test(args[0] ?? "")) {
|
|
4398
4487
|
env.PATH = mergePath(dirname(file), env.PATH);
|
|
4399
4488
|
}
|
|
4400
|
-
|
|
4489
|
+
const network = prepareNodeNetworkCommand(args, env);
|
|
4490
|
+
return { command: file, args: network.args, env: network.env };
|
|
4401
4491
|
}
|
|
4402
4492
|
};
|
|
4403
4493
|
var toolchainKey = /* @__PURE__ */ Symbol.for("@bb/process-utils/host-toolchain");
|