@get-bb/plugin-sdk 0.6.90 → 0.6.99
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 +312 -173
- package/bundled-types/bb-plugin-sdk-host.d.ts +64 -64
- package/bundled-types/bb-plugin-sdk-internal-host-policy.d.ts +18 -8
- package/bundled-types/bb-plugin-sdk-internal-plugin-app-collector.d.ts +15 -3
- package/bundled-types/bb-plugin-sdk-internal-rpc-query-host.d.ts +7 -7
- package/bundled-types/bb-plugin-sdk-internal-rpc-tags.d.ts +1 -1
- package/bundled-types/bb-plugin-sdk-provider-bridge-acp-next.d.ts +4 -0
- package/bundled-types/bb-plugin-sdk-provider-bridge-acp.d.ts +4 -0
- package/bundled-types/bb-plugin-sdk-provider-bridge-testing.d.ts +2 -0
- package/bundled-types/bb-plugin-sdk-provider-bridge.d.ts +12 -1
- package/bundled-types/bb-plugin-sdk-testing-app.d.ts +20 -2
- package/bundled-types/bb-plugin-sdk-testing.d.ts +11 -8
- package/bundled-types/bb-plugin-sdk.d.ts +386 -235
- package/dist/app.js +8 -0
- package/dist/host.js +93 -1
- package/dist/internal/host-policy.js +1 -3
- package/dist/internal/plugin-app-collector.js +47 -10
- package/dist/internal/rpc-query-host.js +73 -51
- package/dist/process.js +100 -3
- package/dist/provider-bridge-acp-next.js +2275 -2034
- package/dist/provider-bridge-acp.js +2275 -2034
- package/dist/provider-bridge-testing.js +207 -132
- package/dist/provider-bridge-worker-entry.mjs +93 -1
- package/dist/provider-bridge.js +702 -596
- package/dist/testing/app.js +131 -64
- package/dist/testing/index.js +5 -4
- package/package.json +3 -3
package/dist/app.js
CHANGED
|
@@ -222,6 +222,9 @@ var experimental_useCanOpenFileExternally = runtimeFunction(
|
|
|
222
222
|
var experimental_useTabVisible = runtimeFunction(
|
|
223
223
|
"experimental_useTabVisible"
|
|
224
224
|
);
|
|
225
|
+
var experimental_useServers = runtimeFunction(
|
|
226
|
+
"experimental_useServers"
|
|
227
|
+
);
|
|
225
228
|
var experimental_useAppPanel = runtimeFunction(
|
|
226
229
|
"experimental_useAppPanel"
|
|
227
230
|
);
|
|
@@ -336,6 +339,9 @@ var ThreadTitle = runtimeComponent("ThreadTitle");
|
|
|
336
339
|
var experimental_ThreadStatusGlyph = runtimeComponent(
|
|
337
340
|
"experimental_ThreadStatusGlyph"
|
|
338
341
|
);
|
|
342
|
+
var experimental_ThreadRowMetadata = runtimeComponent(
|
|
343
|
+
"experimental_ThreadRowMetadata"
|
|
344
|
+
);
|
|
339
345
|
var useEnvironmentProviders = runtimeFunction(
|
|
340
346
|
"useEnvironmentProviders"
|
|
341
347
|
);
|
|
@@ -389,6 +395,7 @@ export {
|
|
|
389
395
|
experimental_THREAD_INFO_SECTION_GROUPS,
|
|
390
396
|
experimental_ThreadActionsContextMenu,
|
|
391
397
|
experimental_ThreadActionsMenu,
|
|
398
|
+
experimental_ThreadRowMetadata,
|
|
392
399
|
experimental_ThreadStatusGlyph,
|
|
393
400
|
experimental_ThreadTitleText,
|
|
394
401
|
experimental_VoiceInputButton,
|
|
@@ -420,6 +427,7 @@ export {
|
|
|
420
427
|
experimental_useRpcMutation,
|
|
421
428
|
experimental_useRpcQuery,
|
|
422
429
|
experimental_useRpcRefresh,
|
|
430
|
+
experimental_useServers,
|
|
423
431
|
experimental_useSidebarNavigation,
|
|
424
432
|
experimental_useSidebarNavigationSplit,
|
|
425
433
|
experimental_useSidebarThreadActions,
|
package/dist/host.js
CHANGED
|
@@ -906,6 +906,97 @@ function whichCommandSync(command, options = {}) {
|
|
|
906
906
|
return void 0;
|
|
907
907
|
}
|
|
908
908
|
|
|
909
|
+
// ../process-utils/src/node-network.ts
|
|
910
|
+
var NODE_NETWORK_FLAGS = {
|
|
911
|
+
"--use-system-ca": "NODE_USE_SYSTEM_CA",
|
|
912
|
+
"--use-env-proxy": "NODE_USE_ENV_PROXY"
|
|
913
|
+
};
|
|
914
|
+
var ENV_PROXY_FLAG = "--use-env-proxy";
|
|
915
|
+
var PROXY_KEYS = /* @__PURE__ */ new Set(["HTTP_PROXY", "HTTPS_PROXY"]);
|
|
916
|
+
var NO_PROXY_KEY = "NO_PROXY";
|
|
917
|
+
var LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "::1", "[::1]"];
|
|
918
|
+
function isNodeNetworkFlag(arg) {
|
|
919
|
+
return Object.hasOwn(NODE_NETWORK_FLAGS, arg);
|
|
920
|
+
}
|
|
921
|
+
function isHttpProxyUrl(value) {
|
|
922
|
+
if (/[\r\n]/u.test(value)) return false;
|
|
923
|
+
try {
|
|
924
|
+
const url = new URL(value);
|
|
925
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.hostname !== "";
|
|
926
|
+
} catch {
|
|
927
|
+
return false;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
function proxyEntries(env) {
|
|
931
|
+
return Object.entries(env).filter(
|
|
932
|
+
(entry) => PROXY_KEYS.has(entry[0].toUpperCase()) && entry[1] !== void 0 && entry[1] !== ""
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
function appendLoopback(value) {
|
|
936
|
+
const entries = value.split(/[\s,]+/u).filter(Boolean);
|
|
937
|
+
if (entries.includes("*")) return value;
|
|
938
|
+
const present = new Set(entries.map((entry) => entry.toLowerCase()));
|
|
939
|
+
return [
|
|
940
|
+
...entries,
|
|
941
|
+
...LOOPBACK_HOSTS.filter((host) => !present.has(host))
|
|
942
|
+
].join(",");
|
|
943
|
+
}
|
|
944
|
+
function withLoopbackNoProxy(env) {
|
|
945
|
+
const result = { ...env };
|
|
946
|
+
const keys = Object.keys(result).filter(
|
|
947
|
+
(key) => key.toUpperCase() === NO_PROXY_KEY && result[key] !== void 0
|
|
948
|
+
);
|
|
949
|
+
for (const key of keys.length > 0 ? keys : [NO_PROXY_KEY])
|
|
950
|
+
result[key] = appendLoopback(result[key] ?? "");
|
|
951
|
+
return result;
|
|
952
|
+
}
|
|
953
|
+
function nodeNetworkLaunch(nodeArgs, env) {
|
|
954
|
+
const enabled = nodeArgs.filter(
|
|
955
|
+
(arg) => !isNodeNetworkFlag(arg) || env[NODE_NETWORK_FLAGS[arg]] !== "0"
|
|
956
|
+
);
|
|
957
|
+
if (!enabled.includes(ENV_PROXY_FLAG))
|
|
958
|
+
return { nodeArgs: enabled, env, rejectedProxyKeys: [] };
|
|
959
|
+
const proxies = proxyEntries(env);
|
|
960
|
+
const rejectedProxyKeys = proxies.filter(([, value]) => !isHttpProxyUrl(value)).map(([key]) => key);
|
|
961
|
+
if (rejectedProxyKeys.length > 0)
|
|
962
|
+
return {
|
|
963
|
+
nodeArgs: enabled.filter((arg) => arg !== ENV_PROXY_FLAG),
|
|
964
|
+
env,
|
|
965
|
+
rejectedProxyKeys
|
|
966
|
+
};
|
|
967
|
+
return {
|
|
968
|
+
nodeArgs: enabled,
|
|
969
|
+
env: proxies.length > 0 ? withLoopbackNoProxy(env) : env,
|
|
970
|
+
rejectedProxyKeys: []
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
var warnedProxyKeys = /* @__PURE__ */ new Set();
|
|
974
|
+
function prepareNodeNetworkLaunch(nodeArgs, env) {
|
|
975
|
+
const launch = nodeNetworkLaunch(nodeArgs, env);
|
|
976
|
+
const unwarned = launch.rejectedProxyKeys.filter(
|
|
977
|
+
(key) => !warnedProxyKeys.has(key)
|
|
978
|
+
);
|
|
979
|
+
if (unwarned.length > 0) {
|
|
980
|
+
for (const key of unwarned) warnedProxyKeys.add(key);
|
|
981
|
+
process.emitWarning(
|
|
982
|
+
`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.`,
|
|
983
|
+
{ code: "BB_INVALID_PROXY_ENV" }
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
return { nodeArgs: launch.nodeArgs, env: launch.env };
|
|
987
|
+
}
|
|
988
|
+
function prepareNodeNetworkCommand(args, env) {
|
|
989
|
+
const scriptIndex = args.findIndex(
|
|
990
|
+
(arg) => arg === "--" || !arg.startsWith("-")
|
|
991
|
+
);
|
|
992
|
+
const optionCount = scriptIndex < 0 ? args.length : scriptIndex;
|
|
993
|
+
const launch = prepareNodeNetworkLaunch(args.slice(0, optionCount), env);
|
|
994
|
+
return {
|
|
995
|
+
args: [...launch.nodeArgs, ...args.slice(optionCount)],
|
|
996
|
+
env: launch.env
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
|
|
909
1000
|
// ../process-utils/src/host-toolchain.ts
|
|
910
1001
|
var NETWORK_KEYS = [
|
|
911
1002
|
"HTTP_PROXY",
|
|
@@ -1266,7 +1357,8 @@ var HostToolchain = class {
|
|
|
1266
1357
|
if (/(?:^|[\\/])(?:npm|npx)-cli\.js$/u.test(args[0] ?? "")) {
|
|
1267
1358
|
env.PATH = mergePath(dirname(file), env.PATH);
|
|
1268
1359
|
}
|
|
1269
|
-
|
|
1360
|
+
const network = prepareNodeNetworkCommand(args, env);
|
|
1361
|
+
return { command: file, args: network.args, env: network.env };
|
|
1270
1362
|
}
|
|
1271
1363
|
};
|
|
1272
1364
|
var toolchainKey = /* @__PURE__ */ Symbol.for("@bb/process-utils/host-toolchain");
|
|
@@ -2134,9 +2134,7 @@ function runPluginStorageMigrations(database, statements) {
|
|
|
2134
2134
|
if (!migrationColumns.some((column) => column.name === "statement_hash")) {
|
|
2135
2135
|
database.exec("ALTER TABLE _bb_migrations ADD COLUMN statement_hash TEXT");
|
|
2136
2136
|
}
|
|
2137
|
-
const rows = database.prepare(
|
|
2138
|
-
"SELECT id, statement_hash FROM _bb_migrations ORDER BY id"
|
|
2139
|
-
).all();
|
|
2137
|
+
const rows = database.prepare("SELECT id, statement_hash FROM _bb_migrations ORDER BY id").all();
|
|
2140
2138
|
const applied = /* @__PURE__ */ new Map();
|
|
2141
2139
|
for (const row of rows) applied.set(row.id, row.statement_hash);
|
|
2142
2140
|
const statementHashes = statements.map(migrationStatementHash);
|
|
@@ -501,6 +501,7 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
501
501
|
threadHeaderActions: [],
|
|
502
502
|
threadContextSegments: [],
|
|
503
503
|
threadInfoRows: [],
|
|
504
|
+
threadRowMetadata: [],
|
|
504
505
|
threadInfoSections: [],
|
|
505
506
|
threadActions: [],
|
|
506
507
|
browserToolbarActions: [],
|
|
@@ -511,6 +512,7 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
511
512
|
messageDirectives: [],
|
|
512
513
|
codeFenceRenderers: [],
|
|
513
514
|
messageActions: [],
|
|
515
|
+
messageMetadata: [],
|
|
514
516
|
commandPaletteActions: [],
|
|
515
517
|
providerIcons: [],
|
|
516
518
|
icons: [],
|
|
@@ -537,6 +539,7 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
537
539
|
threadHeaderAction: /* @__PURE__ */ new Set(),
|
|
538
540
|
threadContextSegment: /* @__PURE__ */ new Set(),
|
|
539
541
|
threadInfoRow: /* @__PURE__ */ new Set(),
|
|
542
|
+
threadRowMetadata: /* @__PURE__ */ new Set(),
|
|
540
543
|
threadInfoSection: /* @__PURE__ */ new Set(),
|
|
541
544
|
threadAction: /* @__PURE__ */ new Set(),
|
|
542
545
|
browserToolbarAction: /* @__PURE__ */ new Set(),
|
|
@@ -548,6 +551,7 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
548
551
|
codeFenceRenderer: /* @__PURE__ */ new Set(),
|
|
549
552
|
codeFenceLanguage: /* @__PURE__ */ new Set(),
|
|
550
553
|
messageAction: /* @__PURE__ */ new Set(),
|
|
554
|
+
messageMetadata: /* @__PURE__ */ new Set(),
|
|
551
555
|
command: /* @__PURE__ */ new Set(),
|
|
552
556
|
providerIcon: /* @__PURE__ */ new Set(),
|
|
553
557
|
timelineRenderer: /* @__PURE__ */ new Set(),
|
|
@@ -657,6 +661,16 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
657
661
|
onWarning(`Legacy threadPanelAction ignored: ${String(error)}`);
|
|
658
662
|
}
|
|
659
663
|
},
|
|
664
|
+
experimental_threadHeaderAction(registration) {
|
|
665
|
+
const kind = "slots.experimental_threadHeaderAction";
|
|
666
|
+
const id = requireSlotId(kind, registration?.id);
|
|
667
|
+
requireUniqueId(kind, seenIds.threadHeaderAction, id);
|
|
668
|
+
collected.threadHeaderActions.push({
|
|
669
|
+
id,
|
|
670
|
+
title: requireNonEmptyString(kind, "title", registration.title),
|
|
671
|
+
component: requireComponent(kind, registration.component)
|
|
672
|
+
});
|
|
673
|
+
},
|
|
660
674
|
experimental_sidebarHeader(registration) {
|
|
661
675
|
legacySidebarHeaders.push(
|
|
662
676
|
collectTitledComponent(
|
|
@@ -862,16 +876,6 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
862
876
|
...headerComponent !== void 0 ? { headerComponent } : {}
|
|
863
877
|
});
|
|
864
878
|
},
|
|
865
|
-
experimental_threadHeaderAction(registration) {
|
|
866
|
-
const kind = "slots.experimental_threadHeaderAction";
|
|
867
|
-
const id = requireSlotId(kind, registration?.id);
|
|
868
|
-
requireUniqueId(kind, seenIds.threadHeaderAction, id);
|
|
869
|
-
collected.threadHeaderActions.push({
|
|
870
|
-
id,
|
|
871
|
-
title: requireNonEmptyString(kind, "title", registration.title),
|
|
872
|
-
component: requireComponent(kind, registration.component)
|
|
873
|
-
});
|
|
874
|
-
},
|
|
875
879
|
experimental_threadContextSegment(registration) {
|
|
876
880
|
const kind = "slots.experimental_threadContextSegment";
|
|
877
881
|
const id = requireSlotId(kind, registration?.id);
|
|
@@ -905,6 +909,19 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
905
909
|
...registration.useVisible !== void 0 ? { useVisible: registration.useVisible } : {}
|
|
906
910
|
});
|
|
907
911
|
},
|
|
912
|
+
experimental_threadRowMetadata(registration) {
|
|
913
|
+
const kind = "slots.experimental_threadRowMetadata";
|
|
914
|
+
const id = requireSlotId(kind, registration?.id);
|
|
915
|
+
requireUniqueId(kind, seenIds.threadRowMetadata, id);
|
|
916
|
+
if (registration.useData !== void 0 && typeof registration.useData !== "function")
|
|
917
|
+
throw new Error(`${kind}: "useData" must be a function`);
|
|
918
|
+
collected.threadRowMetadata.push({
|
|
919
|
+
id,
|
|
920
|
+
...requireOptionalOrder(kind, registration.order),
|
|
921
|
+
...registration.useData !== void 0 ? { useData: registration.useData } : {},
|
|
922
|
+
component: requireComponent(kind, registration.component)
|
|
923
|
+
});
|
|
924
|
+
},
|
|
908
925
|
experimental_threadInfoRow(registration) {
|
|
909
926
|
const kind = "slots.experimental_threadInfoRow";
|
|
910
927
|
const id = requireSlotId(kind, registration?.id);
|
|
@@ -942,12 +959,16 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
942
959
|
`${kind}: "experimental_bulkItem" must be a function`
|
|
943
960
|
);
|
|
944
961
|
}
|
|
962
|
+
if (registration.placement !== void 0 && registration.placement !== "menu" && registration.placement !== "header") {
|
|
963
|
+
throw new Error(`${kind}: "placement" must be "menu" or "header"`);
|
|
964
|
+
}
|
|
945
965
|
collected.threadActions.push({
|
|
946
966
|
id,
|
|
947
967
|
title: requireNonEmptyString(kind, "title", registration.title),
|
|
948
968
|
icon: requireNonEmptyString(kind, "icon", registration.icon),
|
|
949
969
|
group: requireNonEmptyString(kind, "group", registration.group),
|
|
950
970
|
...requireOptionalOrder(kind, registration.order),
|
|
971
|
+
...registration.placement !== void 0 ? { placement: registration.placement } : {},
|
|
951
972
|
...registration.useData !== void 0 ? { useData: registration.useData } : {},
|
|
952
973
|
item: registration.item,
|
|
953
974
|
...registration.experimental_bulkItem !== void 0 ? {
|
|
@@ -1070,6 +1091,22 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
1070
1091
|
run: registration.run
|
|
1071
1092
|
});
|
|
1072
1093
|
},
|
|
1094
|
+
experimental_messageMetadata(registration) {
|
|
1095
|
+
const kind = "slots.experimental_messageMetadata";
|
|
1096
|
+
const id = requireSlotId(kind, registration?.id);
|
|
1097
|
+
requireUniqueId(kind, seenIds.messageMetadata, id);
|
|
1098
|
+
const placement = registration.placement ?? "above";
|
|
1099
|
+
if (placement !== "above" && placement !== "actionRow") {
|
|
1100
|
+
throw new Error(
|
|
1101
|
+
`${kind}: "placement" must be "above" or "actionRow"`
|
|
1102
|
+
);
|
|
1103
|
+
}
|
|
1104
|
+
collected.messageMetadata.push({
|
|
1105
|
+
id,
|
|
1106
|
+
placement,
|
|
1107
|
+
component: requireComponent(kind, registration.component)
|
|
1108
|
+
});
|
|
1109
|
+
},
|
|
1073
1110
|
commandPaletteAction(registration) {
|
|
1074
1111
|
registerCommand(registration);
|
|
1075
1112
|
},
|
|
@@ -80,7 +80,7 @@ var experimental_PluginRpcRefusal = class extends Error {
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
// src/internal/rpc-query-host.ts
|
|
83
|
-
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2 } from "react";
|
|
83
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
84
84
|
import { useIsFetching } from "@tanstack/react-query";
|
|
85
85
|
|
|
86
86
|
// ../query-tags/src/index.ts
|
|
@@ -991,13 +991,13 @@ async function invalidateTags(client, scope, tags) {
|
|
|
991
991
|
}
|
|
992
992
|
async function executeTaggedMutation(invalidate, call, prediction) {
|
|
993
993
|
const { result, invalidated } = await call();
|
|
994
|
-
prediction
|
|
994
|
+
prediction.accept(result);
|
|
995
995
|
const refresh = async () => {
|
|
996
996
|
try {
|
|
997
997
|
if (invalidate !== void 0 && invalidated.length > 0)
|
|
998
998
|
await invalidate(invalidated);
|
|
999
999
|
} finally {
|
|
1000
|
-
prediction
|
|
1000
|
+
prediction.settle();
|
|
1001
1001
|
}
|
|
1002
1002
|
};
|
|
1003
1003
|
void refresh().catch(() => {
|
|
@@ -1089,11 +1089,16 @@ function createTaggedKeyedQueryOwner(options) {
|
|
|
1089
1089
|
registerKeyedView(client, queryKey, keyedRowsView(collection));
|
|
1090
1090
|
const keys = /* @__PURE__ */ new Map();
|
|
1091
1091
|
let readingKeys = /* @__PURE__ */ new Set();
|
|
1092
|
+
let collecting = false;
|
|
1092
1093
|
let missingOnly = false;
|
|
1093
1094
|
let refreshAll = false;
|
|
1094
1095
|
const dirtyKeys = /* @__PURE__ */ new Set();
|
|
1095
|
-
const
|
|
1096
|
-
queueMicrotask(() =>
|
|
1096
|
+
const takeSubscribedKeys = (take) => new Promise((resolve) => {
|
|
1097
|
+
queueMicrotask(() => {
|
|
1098
|
+
readingKeys = new Set(take([...keys.keys()]));
|
|
1099
|
+
collecting = false;
|
|
1100
|
+
resolve([...readingKeys]);
|
|
1101
|
+
});
|
|
1097
1102
|
});
|
|
1098
1103
|
const observer = new QueryObserver(client, {
|
|
1099
1104
|
queryKey,
|
|
@@ -1120,23 +1125,26 @@ function createTaggedKeyedQueryOwner(options) {
|
|
|
1120
1125
|
const refreshedKeys = /* @__PURE__ */ new Set();
|
|
1121
1126
|
let refreshedAll = false;
|
|
1122
1127
|
return runTaggedRead(client, queryKey, async () => {
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1128
|
+
collecting = true;
|
|
1129
|
+
let all = false;
|
|
1130
|
+
const requested = await takeSubscribedKeys((subscribed) => {
|
|
1131
|
+
all = refreshAll || refresh;
|
|
1132
|
+
refresh = false;
|
|
1133
|
+
const dirty = new Set(dirtyKeys);
|
|
1134
|
+
refreshedAll ||= all;
|
|
1135
|
+
if (all)
|
|
1136
|
+
for (const key of Object.keys(previous?.result ?? {}))
|
|
1137
|
+
dirtyKeys.add(key);
|
|
1138
|
+
refreshAll = false;
|
|
1139
|
+
const taken = subscribed.filter(
|
|
1140
|
+
(key) => all || dirty.has(key) || !Object.hasOwn(previous?.result ?? {}, key)
|
|
1141
|
+
);
|
|
1142
|
+
for (const key of taken) {
|
|
1143
|
+
refreshedKeys.add(key);
|
|
1144
|
+
dirtyKeys.delete(key);
|
|
1145
|
+
}
|
|
1146
|
+
return taken;
|
|
1147
|
+
});
|
|
1140
1148
|
const started = tick();
|
|
1141
1149
|
try {
|
|
1142
1150
|
const results = await Promise.all(
|
|
@@ -1192,13 +1200,15 @@ function createTaggedKeyedQueryOwner(options) {
|
|
|
1192
1200
|
let stop;
|
|
1193
1201
|
return {
|
|
1194
1202
|
observer,
|
|
1195
|
-
async
|
|
1203
|
+
async refresh(requested) {
|
|
1196
1204
|
const subscribed = requested.filter((key) => keys.has(key));
|
|
1197
1205
|
if (subscribed.length === 0) return;
|
|
1198
|
-
|
|
1199
|
-
|
|
1206
|
+
const fetching = observer.getCurrentQuery().state.fetchStatus === "fetching";
|
|
1207
|
+
const unread = fetching && !collecting ? subscribed.filter((key) => !readingKeys.has(key)) : subscribed;
|
|
1208
|
+
if (unread.length === 0) return;
|
|
1209
|
+
for (const key of unread) dirtyKeys.add(key);
|
|
1210
|
+
if (fetching && !collecting)
|
|
1200
1211
|
restartTaggedRead(observer.getCurrentQuery());
|
|
1201
|
-
}
|
|
1202
1212
|
await observer.refetch({ cancelRefetch: false });
|
|
1203
1213
|
},
|
|
1204
1214
|
subscribe(requested, listener) {
|
|
@@ -1220,7 +1230,7 @@ function createTaggedKeyedQueryOwner(options) {
|
|
|
1220
1230
|
}
|
|
1221
1231
|
if (added && pending.length > 0) {
|
|
1222
1232
|
if (observer.getCurrentResult().isFetching) {
|
|
1223
|
-
if (
|
|
1233
|
+
if (!collecting && pending.some((key) => !readingKeys.has(key)))
|
|
1224
1234
|
restartTaggedRead(observer.getCurrentQuery());
|
|
1225
1235
|
} else {
|
|
1226
1236
|
missingOnly = true;
|
|
@@ -1495,7 +1505,7 @@ var sessionOptionSelectionsSchema = z2.record(
|
|
|
1495
1505
|
var runtimeThreadExecutionBaseOptionsSchema = z2.object({
|
|
1496
1506
|
model: z2.string().min(1),
|
|
1497
1507
|
serviceTier: serviceTierSchema,
|
|
1498
|
-
reasoningLevel: reasoningLevelSchema,
|
|
1508
|
+
reasoningLevel: reasoningLevelSchema.optional(),
|
|
1499
1509
|
promptMode: promptModeSchema.optional(),
|
|
1500
1510
|
sessionOptions: sessionOptionSelectionsSchema.optional(),
|
|
1501
1511
|
providerOptions: jsonObjectSchema
|
|
@@ -2021,6 +2031,7 @@ var SYSTEM_CHANGE_KINDS = [
|
|
|
2021
2031
|
"plugin-install-jobs-changed",
|
|
2022
2032
|
"plugin-update-jobs-changed",
|
|
2023
2033
|
"provider-registrations-changed",
|
|
2034
|
+
"ui-preferences-changed",
|
|
2024
2035
|
"environment-availability-changed",
|
|
2025
2036
|
"server-move-changed",
|
|
2026
2037
|
"app-update-changed"
|
|
@@ -2178,11 +2189,6 @@ var systemChangedMessageSchema = z17.object({
|
|
|
2178
2189
|
entity: z17.literal("system"),
|
|
2179
2190
|
changes: z17.array(systemChangeKindSchema).readonly()
|
|
2180
2191
|
}).strict();
|
|
2181
|
-
var tagsChangedMessageSchema = z17.object({
|
|
2182
|
-
type: z17.literal("changed"),
|
|
2183
|
-
entity: z17.literal("tags"),
|
|
2184
|
-
tags: z17.array(z17.string().min(1)).min(1)
|
|
2185
|
-
}).strict();
|
|
2186
2192
|
var pluginChangedMessageSchema = z17.object({
|
|
2187
2193
|
type: z17.literal("changed"),
|
|
2188
2194
|
entity: z17.literal("plugin"),
|
|
@@ -2195,7 +2201,6 @@ var changedMessageSchema = z17.discriminatedUnion("entity", [
|
|
|
2195
2201
|
environmentChangedMessageSchema,
|
|
2196
2202
|
hostChangedMessageSchema,
|
|
2197
2203
|
systemChangedMessageSchema,
|
|
2198
|
-
tagsChangedMessageSchema,
|
|
2199
2204
|
pluginChangedMessageSchema
|
|
2200
2205
|
]);
|
|
2201
2206
|
function lenientKinds(kinds) {
|
|
@@ -2255,7 +2260,6 @@ var changedMessageLenientSchema = z17.discriminatedUnion("entity", [
|
|
|
2255
2260
|
environmentChangedMessageLenientSchema,
|
|
2256
2261
|
hostChangedMessageLenientSchema,
|
|
2257
2262
|
systemChangedMessageLenientSchema,
|
|
2258
|
-
tagsChangedMessageSchema.strip(),
|
|
2259
2263
|
pluginChangedMessageSchema.strip()
|
|
2260
2264
|
]);
|
|
2261
2265
|
|
|
@@ -2283,6 +2287,8 @@ var rpcQueryKey = (pluginId, method, input) => [
|
|
|
2283
2287
|
input
|
|
2284
2288
|
];
|
|
2285
2289
|
var keyedQueryKey = (pluginId, method) => rpcQueryKey(pluginId, method, { keyed: true });
|
|
2290
|
+
var keyListSchema = z19.array(z19.string());
|
|
2291
|
+
var jsonRecordSchema = z19.record(z19.string(), jsonValueSchema);
|
|
2286
2292
|
var keyedCollections = /* @__PURE__ */ new Map();
|
|
2287
2293
|
function keyedCollection(pluginId, method) {
|
|
2288
2294
|
const name = JSON.stringify([pluginId, method]);
|
|
@@ -2417,7 +2423,7 @@ function createRpcQueryHooks(useHost) {
|
|
|
2417
2423
|
const enabled = options.enabled ?? true;
|
|
2418
2424
|
const identity = JSON.stringify([...new Set(options.keys)].sort());
|
|
2419
2425
|
const keys = useMemo2(
|
|
2420
|
-
() =>
|
|
2426
|
+
() => keyListSchema.parse(JSON.parse(identity)),
|
|
2421
2427
|
[identity]
|
|
2422
2428
|
);
|
|
2423
2429
|
let cache = owners.get(host.queryClient);
|
|
@@ -2443,7 +2449,7 @@ function createRpcQueryHooks(useHost) {
|
|
|
2443
2449
|
);
|
|
2444
2450
|
return {
|
|
2445
2451
|
...response,
|
|
2446
|
-
result:
|
|
2452
|
+
result: jsonRecordSchema.parse(response.result)
|
|
2447
2453
|
};
|
|
2448
2454
|
}
|
|
2449
2455
|
});
|
|
@@ -2452,8 +2458,7 @@ function createRpcQueryHooks(useHost) {
|
|
|
2452
2458
|
const current = owner;
|
|
2453
2459
|
useSubscription(host, pluginId, enabled && keys.length > 0);
|
|
2454
2460
|
const subscribe = useCallback2(
|
|
2455
|
-
(listener) => enabled
|
|
2456
|
-
},
|
|
2461
|
+
(listener) => current.subscribe(enabled ? keys : [], listener),
|
|
2457
2462
|
[current, keys, enabled]
|
|
2458
2463
|
);
|
|
2459
2464
|
const getSnapshot = useCallback2(
|
|
@@ -2480,23 +2485,39 @@ function createRpcQueryHooks(useHost) {
|
|
|
2480
2485
|
[keys, enabled, selectRows]
|
|
2481
2486
|
);
|
|
2482
2487
|
const query = useQuerySelection(subscribe, getSnapshot, select);
|
|
2488
|
+
const watches = useMemo2(
|
|
2489
|
+
() => /* @__PURE__ */ new Map(),
|
|
2490
|
+
[host, pluginId, options.method]
|
|
2491
|
+
);
|
|
2492
|
+
useEffect2(
|
|
2493
|
+
() => () => {
|
|
2494
|
+
for (const release of watches.values()) release?.();
|
|
2495
|
+
watches.clear();
|
|
2496
|
+
},
|
|
2497
|
+
[watches]
|
|
2498
|
+
);
|
|
2483
2499
|
useEffect2(() => {
|
|
2484
|
-
|
|
2485
|
-
const
|
|
2486
|
-
(
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2500
|
+
const wanted = new Set(enabled ? keys : []);
|
|
2501
|
+
for (const [key, release] of watches) {
|
|
2502
|
+
if (wanted.has(key)) continue;
|
|
2503
|
+
release?.();
|
|
2504
|
+
watches.delete(key);
|
|
2505
|
+
}
|
|
2506
|
+
for (const key of wanted) {
|
|
2507
|
+
if (!watches.has(key))
|
|
2508
|
+
watches.set(key, host.watch?.(pluginId, options.method, { key }));
|
|
2509
|
+
}
|
|
2510
|
+
}, [host, pluginId, options.method, keys, enabled, watches]);
|
|
2511
|
+
const heldKeys = useRef2(keys);
|
|
2512
|
+
useEffect2(() => {
|
|
2513
|
+
heldKeys.current = keys;
|
|
2514
|
+
}, [keys]);
|
|
2492
2515
|
const refetch = useCallback2(async () => {
|
|
2493
|
-
await current.
|
|
2516
|
+
await current.refresh(heldKeys.current);
|
|
2494
2517
|
}, [current]);
|
|
2495
2518
|
const refetchKeys = useCallback2(
|
|
2496
2519
|
async (requested) => {
|
|
2497
|
-
await current.
|
|
2498
|
-
requested.filter((key) => keys.includes(key))
|
|
2499
|
-
);
|
|
2520
|
+
await current.refresh(requested.filter((key) => keys.includes(key)));
|
|
2500
2521
|
},
|
|
2501
2522
|
[current, keys]
|
|
2502
2523
|
);
|
|
@@ -2511,6 +2532,7 @@ function createRpcQueryHooks(useHost) {
|
|
|
2511
2532
|
const pluginId = resolvePluginId(host, options.pluginId);
|
|
2512
2533
|
const mutation = useTaggedMutation({
|
|
2513
2534
|
client: host.queryClient,
|
|
2535
|
+
meta: { showErrorToast: false },
|
|
2514
2536
|
invalidate: (tags) => invalidateTags(host.queryClient, pluginTagScope(pluginId), tags),
|
|
2515
2537
|
call: async (input) => {
|
|
2516
2538
|
const response = await callRpc(
|
package/dist/process.js
CHANGED
|
@@ -112,6 +112,97 @@ function whichCommandSync(command, options = {}) {
|
|
|
112
112
|
return void 0;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
// ../process-utils/src/node-network.ts
|
|
116
|
+
var NODE_NETWORK_FLAGS = {
|
|
117
|
+
"--use-system-ca": "NODE_USE_SYSTEM_CA",
|
|
118
|
+
"--use-env-proxy": "NODE_USE_ENV_PROXY"
|
|
119
|
+
};
|
|
120
|
+
var ENV_PROXY_FLAG = "--use-env-proxy";
|
|
121
|
+
var PROXY_KEYS = /* @__PURE__ */ new Set(["HTTP_PROXY", "HTTPS_PROXY"]);
|
|
122
|
+
var NO_PROXY_KEY = "NO_PROXY";
|
|
123
|
+
var LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "::1", "[::1]"];
|
|
124
|
+
function isNodeNetworkFlag(arg) {
|
|
125
|
+
return Object.hasOwn(NODE_NETWORK_FLAGS, arg);
|
|
126
|
+
}
|
|
127
|
+
function isHttpProxyUrl(value) {
|
|
128
|
+
if (/[\r\n]/u.test(value)) return false;
|
|
129
|
+
try {
|
|
130
|
+
const url = new URL(value);
|
|
131
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.hostname !== "";
|
|
132
|
+
} catch {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function proxyEntries(env) {
|
|
137
|
+
return Object.entries(env).filter(
|
|
138
|
+
(entry) => PROXY_KEYS.has(entry[0].toUpperCase()) && entry[1] !== void 0 && entry[1] !== ""
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
function appendLoopback(value) {
|
|
142
|
+
const entries = value.split(/[\s,]+/u).filter(Boolean);
|
|
143
|
+
if (entries.includes("*")) return value;
|
|
144
|
+
const present = new Set(entries.map((entry) => entry.toLowerCase()));
|
|
145
|
+
return [
|
|
146
|
+
...entries,
|
|
147
|
+
...LOOPBACK_HOSTS.filter((host) => !present.has(host))
|
|
148
|
+
].join(",");
|
|
149
|
+
}
|
|
150
|
+
function withLoopbackNoProxy(env) {
|
|
151
|
+
const result = { ...env };
|
|
152
|
+
const keys = Object.keys(result).filter(
|
|
153
|
+
(key) => key.toUpperCase() === NO_PROXY_KEY && result[key] !== void 0
|
|
154
|
+
);
|
|
155
|
+
for (const key of keys.length > 0 ? keys : [NO_PROXY_KEY])
|
|
156
|
+
result[key] = appendLoopback(result[key] ?? "");
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
function nodeNetworkLaunch(nodeArgs, env) {
|
|
160
|
+
const enabled = nodeArgs.filter(
|
|
161
|
+
(arg) => !isNodeNetworkFlag(arg) || env[NODE_NETWORK_FLAGS[arg]] !== "0"
|
|
162
|
+
);
|
|
163
|
+
if (!enabled.includes(ENV_PROXY_FLAG))
|
|
164
|
+
return { nodeArgs: enabled, env, rejectedProxyKeys: [] };
|
|
165
|
+
const proxies = proxyEntries(env);
|
|
166
|
+
const rejectedProxyKeys = proxies.filter(([, value]) => !isHttpProxyUrl(value)).map(([key]) => key);
|
|
167
|
+
if (rejectedProxyKeys.length > 0)
|
|
168
|
+
return {
|
|
169
|
+
nodeArgs: enabled.filter((arg) => arg !== ENV_PROXY_FLAG),
|
|
170
|
+
env,
|
|
171
|
+
rejectedProxyKeys
|
|
172
|
+
};
|
|
173
|
+
return {
|
|
174
|
+
nodeArgs: enabled,
|
|
175
|
+
env: proxies.length > 0 ? withLoopbackNoProxy(env) : env,
|
|
176
|
+
rejectedProxyKeys: []
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
var warnedProxyKeys = /* @__PURE__ */ new Set();
|
|
180
|
+
function prepareNodeNetworkLaunch(nodeArgs, env) {
|
|
181
|
+
const launch = nodeNetworkLaunch(nodeArgs, env);
|
|
182
|
+
const unwarned = launch.rejectedProxyKeys.filter(
|
|
183
|
+
(key) => !warnedProxyKeys.has(key)
|
|
184
|
+
);
|
|
185
|
+
if (unwarned.length > 0) {
|
|
186
|
+
for (const key of unwarned) warnedProxyKeys.add(key);
|
|
187
|
+
process.emitWarning(
|
|
188
|
+
`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.`,
|
|
189
|
+
{ code: "BB_INVALID_PROXY_ENV" }
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
return { nodeArgs: launch.nodeArgs, env: launch.env };
|
|
193
|
+
}
|
|
194
|
+
function prepareNodeNetworkCommand(args, env) {
|
|
195
|
+
const scriptIndex = args.findIndex(
|
|
196
|
+
(arg) => arg === "--" || !arg.startsWith("-")
|
|
197
|
+
);
|
|
198
|
+
const optionCount = scriptIndex < 0 ? args.length : scriptIndex;
|
|
199
|
+
const launch = prepareNodeNetworkLaunch(args.slice(0, optionCount), env);
|
|
200
|
+
return {
|
|
201
|
+
args: [...launch.nodeArgs, ...args.slice(optionCount)],
|
|
202
|
+
env: launch.env
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
115
206
|
// ../process-utils/src/host-toolchain.ts
|
|
116
207
|
var NETWORK_KEYS = [
|
|
117
208
|
"HTTP_PROXY",
|
|
@@ -472,7 +563,8 @@ var HostToolchain = class {
|
|
|
472
563
|
if (/(?:^|[\\/])(?:npm|npx)-cli\.js$/u.test(args[0] ?? "")) {
|
|
473
564
|
env.PATH = mergePath(dirname(file), env.PATH);
|
|
474
565
|
}
|
|
475
|
-
|
|
566
|
+
const network = prepareNodeNetworkCommand(args, env);
|
|
567
|
+
return { command: file, args: network.args, env: network.env };
|
|
476
568
|
}
|
|
477
569
|
};
|
|
478
570
|
var toolchainKey = /* @__PURE__ */ Symbol.for("@bb/process-utils/host-toolchain");
|
|
@@ -497,9 +589,14 @@ function spawnHostProcess(command, args = [], options = {}) {
|
|
|
497
589
|
);
|
|
498
590
|
}
|
|
499
591
|
function forkHostProcess(modulePath, args = [], options = {}) {
|
|
500
|
-
const env =
|
|
592
|
+
const { nodeArgs: execArgv, env } = prepareNodeNetworkLaunch(
|
|
593
|
+
options.execArgv ?? process.execArgv,
|
|
594
|
+
hostToolchain.environment(options.env)
|
|
595
|
+
);
|
|
501
596
|
const execPath = options.execPath === void 0 || options.execPath === process.execPath ? hostToolchain.node({ env, cwd: options.cwd }) : options.execPath;
|
|
502
|
-
return observe(
|
|
597
|
+
return observe(
|
|
598
|
+
nodeFork(modulePath, args, { ...options, env, execArgv, execPath })
|
|
599
|
+
);
|
|
503
600
|
}
|
|
504
601
|
function prepareExecFile(command, args, options) {
|
|
505
602
|
const launch = hostToolchain.command(command, args, options);
|