@get-bb/plugin-sdk 0.6.142 → 0.6.146
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 +1 -0
- package/bundled-types/bb-plugin-sdk-testing.d.ts +1 -0
- package/bundled-types/bb-plugin-sdk.d.ts +1 -0
- package/dist/host.js +23 -1
- package/dist/internal/rpc-query-host.js +41 -18
- package/dist/testing/app.js +60 -29
- package/dist/testing/index.js +2 -1
- package/package.json +1 -1
|
@@ -13323,6 +13323,7 @@ type SendMessageRequest = z$1.infer<typeof sendMessageRequestSchema>;
|
|
|
13323
13323
|
*/
|
|
13324
13324
|
declare const sendMessageResponseSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
|
|
13325
13325
|
delivery: z$1.ZodLiteral<"sent">;
|
|
13326
|
+
messageSequence: z$1.ZodNullable<z$1.ZodNumber>;
|
|
13326
13327
|
ok: z$1.ZodLiteral<true>;
|
|
13327
13328
|
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
13328
13329
|
delivery: z$1.ZodLiteral<"queued">;
|
|
@@ -1220,6 +1220,7 @@ interface ExperimentalFakeHostRpcCall {
|
|
|
1220
1220
|
input: unknown;
|
|
1221
1221
|
hostId: string;
|
|
1222
1222
|
signal?: AbortSignal;
|
|
1223
|
+
timeoutMs?: number;
|
|
1223
1224
|
}
|
|
1224
1225
|
/** Everything the plugin registered, exposed raw for assertions. */
|
|
1225
1226
|
interface FakePluginRegistrations {
|
|
@@ -13539,6 +13539,7 @@ type SendMessageRequest = z$1.infer<typeof sendMessageRequestSchema>;
|
|
|
13539
13539
|
*/
|
|
13540
13540
|
declare const sendMessageResponseSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
|
|
13541
13541
|
delivery: z$1.ZodLiteral<"sent">;
|
|
13542
|
+
messageSequence: z$1.ZodNullable<z$1.ZodNumber>;
|
|
13542
13543
|
ok: z$1.ZodLiteral<true>;
|
|
13543
13544
|
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
13544
13545
|
delivery: z$1.ZodLiteral<"queued">;
|
package/dist/host.js
CHANGED
|
@@ -1656,6 +1656,28 @@ async function listLsofProcessCwds() {
|
|
|
1656
1656
|
}
|
|
1657
1657
|
return results;
|
|
1658
1658
|
}
|
|
1659
|
+
var runningProcessCwdScan = null;
|
|
1660
|
+
var queuedProcessCwdScan = null;
|
|
1661
|
+
function startProcessCwdScan() {
|
|
1662
|
+
const scan = (process.platform === "linux" ? listLinuxProcessCwds() : listLsofProcessCwds()).finally(() => {
|
|
1663
|
+
if (runningProcessCwdScan === scan) runningProcessCwdScan = null;
|
|
1664
|
+
});
|
|
1665
|
+
runningProcessCwdScan = scan;
|
|
1666
|
+
return scan;
|
|
1667
|
+
}
|
|
1668
|
+
function scanProcessCwds() {
|
|
1669
|
+
if (queuedProcessCwdScan !== null) return queuedProcessCwdScan;
|
|
1670
|
+
if (runningProcessCwdScan === null) return startProcessCwdScan();
|
|
1671
|
+
const queued = runningProcessCwdScan.then(
|
|
1672
|
+
() => void 0,
|
|
1673
|
+
() => void 0
|
|
1674
|
+
).then(() => {
|
|
1675
|
+
queuedProcessCwdScan = null;
|
|
1676
|
+
return startProcessCwdScan();
|
|
1677
|
+
});
|
|
1678
|
+
queuedProcessCwdScan = queued;
|
|
1679
|
+
return queued;
|
|
1680
|
+
}
|
|
1659
1681
|
async function resolveSweepDirectory(directory) {
|
|
1660
1682
|
const resolved = resolve(directory);
|
|
1661
1683
|
let ancestor = dirname2(resolved);
|
|
@@ -1690,7 +1712,7 @@ async function listProcessesWithCwdUnder(args) {
|
|
|
1690
1712
|
if (directories.length === 0) {
|
|
1691
1713
|
return [];
|
|
1692
1714
|
}
|
|
1693
|
-
const all =
|
|
1715
|
+
const all = await scanProcessCwds();
|
|
1694
1716
|
return all.filter(
|
|
1695
1717
|
(entry) => entry.pid !== process.pid && directories.some(
|
|
1696
1718
|
(directory) => isPathUnderDirectory(entry.cwd, directory)
|
|
@@ -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, useRef as useRef2 } from "react";
|
|
83
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
84
84
|
import { useIsFetching } from "@tanstack/react-query";
|
|
85
85
|
|
|
86
86
|
// ../query-tags/src/index.ts
|
|
@@ -2378,6 +2378,17 @@ var tagsOf = (data) => [
|
|
|
2378
2378
|
...data.tags,
|
|
2379
2379
|
...Object.values(data.keyTags).flat()
|
|
2380
2380
|
];
|
|
2381
|
+
function useParsedRpcInput(input) {
|
|
2382
|
+
const identity = JSON.stringify(input ?? null);
|
|
2383
|
+
const [parsed, setParsed] = useState2(() => ({
|
|
2384
|
+
identity,
|
|
2385
|
+
value: jsonValueSchema.parse(input ?? null)
|
|
2386
|
+
}));
|
|
2387
|
+
if (parsed.identity === identity) return parsed.value;
|
|
2388
|
+
const next = { identity, value: jsonValueSchema.parse(input ?? null) };
|
|
2389
|
+
setParsed(next);
|
|
2390
|
+
return next.value;
|
|
2391
|
+
}
|
|
2381
2392
|
var owners = /* @__PURE__ */ new WeakMap();
|
|
2382
2393
|
function createRpcQueryHooks(useHost) {
|
|
2383
2394
|
function useSubscription(host, pluginId, enabled) {
|
|
@@ -2389,8 +2400,11 @@ function createRpcQueryHooks(useHost) {
|
|
|
2389
2400
|
const experimental_useRpcQuery = (options) => {
|
|
2390
2401
|
const host = useHost();
|
|
2391
2402
|
const pluginId = resolvePluginId(host, options.pluginId);
|
|
2392
|
-
const input =
|
|
2393
|
-
const queryKey =
|
|
2403
|
+
const input = useParsedRpcInput(options.input);
|
|
2404
|
+
const queryKey = useMemo2(
|
|
2405
|
+
() => rpcQueryKey(pluginId, options.method, input),
|
|
2406
|
+
[input, options.method, pluginId]
|
|
2407
|
+
);
|
|
2394
2408
|
useSubscription(host, pluginId, options.enabled ?? true);
|
|
2395
2409
|
const watchIdentity = canonicalPluginReadInput(input);
|
|
2396
2410
|
useEffect2(() => {
|
|
@@ -2415,18 +2429,24 @@ function createRpcQueryHooks(useHost) {
|
|
|
2415
2429
|
},
|
|
2416
2430
|
host.queryClient
|
|
2417
2431
|
);
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2432
|
+
const { refetch: refetchQuery, error: queryError } = query;
|
|
2433
|
+
const refetch = useCallback2(async () => {
|
|
2434
|
+
await refetchQuery();
|
|
2435
|
+
}, [refetchQuery]);
|
|
2436
|
+
const error = useMemo2(
|
|
2437
|
+
() => queryError === null ? null : experimental_PluginRpcCallError.from(
|
|
2438
|
+
queryError,
|
|
2422
2439
|
"invalid_response"
|
|
2423
2440
|
),
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2441
|
+
[queryError]
|
|
2442
|
+
);
|
|
2443
|
+
const data = query.data?.result;
|
|
2444
|
+
const isLoading = (options.enabled ?? true) && query.isLoading;
|
|
2445
|
+
const isFetching = query.isFetching;
|
|
2446
|
+
return useMemo2(
|
|
2447
|
+
() => ({ data, error, isLoading, isFetching, refetch }),
|
|
2448
|
+
[data, error, isFetching, isLoading, refetch]
|
|
2449
|
+
);
|
|
2430
2450
|
};
|
|
2431
2451
|
function experimental_useRpcKeyedQuery(options) {
|
|
2432
2452
|
const host = useHost();
|
|
@@ -2532,11 +2552,14 @@ function createRpcQueryHooks(useHost) {
|
|
|
2532
2552
|
},
|
|
2533
2553
|
[current, keys]
|
|
2534
2554
|
);
|
|
2535
|
-
return
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2555
|
+
return useMemo2(
|
|
2556
|
+
() => ({
|
|
2557
|
+
...query,
|
|
2558
|
+
refetch,
|
|
2559
|
+
refetchKeys
|
|
2560
|
+
}),
|
|
2561
|
+
[query, refetch, refetchKeys]
|
|
2562
|
+
);
|
|
2540
2563
|
}
|
|
2541
2564
|
function experimental_useRpcMutation(options) {
|
|
2542
2565
|
const host = useHost();
|
package/dist/testing/app.js
CHANGED
|
@@ -1278,7 +1278,7 @@ function useQuerySelection(subscribe, getSnapshot, select) {
|
|
|
1278
1278
|
import { QueryClient } from "@tanstack/react-query";
|
|
1279
1279
|
|
|
1280
1280
|
// src/internal/rpc-query-host.ts
|
|
1281
|
-
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
1281
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
1282
1282
|
import { useIsFetching } from "@tanstack/react-query";
|
|
1283
1283
|
|
|
1284
1284
|
// ../domain/src/shared-types.ts
|
|
@@ -2381,6 +2381,17 @@ var tagsOf = (data) => [
|
|
|
2381
2381
|
...data.tags,
|
|
2382
2382
|
...Object.values(data.keyTags).flat()
|
|
2383
2383
|
];
|
|
2384
|
+
function useParsedRpcInput(input) {
|
|
2385
|
+
const identity = JSON.stringify(input ?? null);
|
|
2386
|
+
const [parsed, setParsed] = useState2(() => ({
|
|
2387
|
+
identity,
|
|
2388
|
+
value: jsonValueSchema.parse(input ?? null)
|
|
2389
|
+
}));
|
|
2390
|
+
if (parsed.identity === identity) return parsed.value;
|
|
2391
|
+
const next = { identity, value: jsonValueSchema.parse(input ?? null) };
|
|
2392
|
+
setParsed(next);
|
|
2393
|
+
return next.value;
|
|
2394
|
+
}
|
|
2384
2395
|
var owners = /* @__PURE__ */ new WeakMap();
|
|
2385
2396
|
function createRpcQueryHooks(useHost) {
|
|
2386
2397
|
function useSubscription(host, pluginId, enabled) {
|
|
@@ -2392,8 +2403,11 @@ function createRpcQueryHooks(useHost) {
|
|
|
2392
2403
|
const experimental_useRpcQuery = (options) => {
|
|
2393
2404
|
const host = useHost();
|
|
2394
2405
|
const pluginId = resolvePluginId(host, options.pluginId);
|
|
2395
|
-
const input =
|
|
2396
|
-
const queryKey =
|
|
2406
|
+
const input = useParsedRpcInput(options.input);
|
|
2407
|
+
const queryKey = useMemo2(
|
|
2408
|
+
() => rpcQueryKey(pluginId, options.method, input),
|
|
2409
|
+
[input, options.method, pluginId]
|
|
2410
|
+
);
|
|
2397
2411
|
useSubscription(host, pluginId, options.enabled ?? true);
|
|
2398
2412
|
const watchIdentity = canonicalPluginReadInput(input);
|
|
2399
2413
|
useEffect2(() => {
|
|
@@ -2418,18 +2432,24 @@ function createRpcQueryHooks(useHost) {
|
|
|
2418
2432
|
},
|
|
2419
2433
|
host.queryClient
|
|
2420
2434
|
);
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2435
|
+
const { refetch: refetchQuery, error: queryError } = query;
|
|
2436
|
+
const refetch = useCallback2(async () => {
|
|
2437
|
+
await refetchQuery();
|
|
2438
|
+
}, [refetchQuery]);
|
|
2439
|
+
const error = useMemo2(
|
|
2440
|
+
() => queryError === null ? null : experimental_PluginRpcCallError.from(
|
|
2441
|
+
queryError,
|
|
2425
2442
|
"invalid_response"
|
|
2426
2443
|
),
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2444
|
+
[queryError]
|
|
2445
|
+
);
|
|
2446
|
+
const data = query.data?.result;
|
|
2447
|
+
const isLoading = (options.enabled ?? true) && query.isLoading;
|
|
2448
|
+
const isFetching = query.isFetching;
|
|
2449
|
+
return useMemo2(
|
|
2450
|
+
() => ({ data, error, isLoading, isFetching, refetch }),
|
|
2451
|
+
[data, error, isFetching, isLoading, refetch]
|
|
2452
|
+
);
|
|
2433
2453
|
};
|
|
2434
2454
|
function experimental_useRpcKeyedQuery(options) {
|
|
2435
2455
|
const host = useHost();
|
|
@@ -2535,11 +2555,14 @@ function createRpcQueryHooks(useHost) {
|
|
|
2535
2555
|
},
|
|
2536
2556
|
[current, keys]
|
|
2537
2557
|
);
|
|
2538
|
-
return
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2558
|
+
return useMemo2(
|
|
2559
|
+
() => ({
|
|
2560
|
+
...query,
|
|
2561
|
+
refetch,
|
|
2562
|
+
refetchKeys
|
|
2563
|
+
}),
|
|
2564
|
+
[query, refetch, refetchKeys]
|
|
2565
|
+
);
|
|
2543
2566
|
}
|
|
2544
2567
|
function experimental_useRpcMutation(options) {
|
|
2545
2568
|
const host = useHost();
|
|
@@ -2621,7 +2644,7 @@ import {
|
|
|
2621
2644
|
useEffect as useEffect3,
|
|
2622
2645
|
useMemo as useMemo3,
|
|
2623
2646
|
useRef as useRef3,
|
|
2624
|
-
useState as
|
|
2647
|
+
useState as useState3,
|
|
2625
2648
|
useSyncExternalStore as useSyncExternalStore2
|
|
2626
2649
|
} from "react";
|
|
2627
2650
|
import { act, render } from "@testing-library/react";
|
|
@@ -4969,7 +4992,7 @@ function useTestMenuOpenState({
|
|
|
4969
4992
|
onOpenChange,
|
|
4970
4993
|
onCloseAutoFocus
|
|
4971
4994
|
}) {
|
|
4972
|
-
const [open, setOpen] =
|
|
4995
|
+
const [open, setOpen] = useState3(false);
|
|
4973
4996
|
return {
|
|
4974
4997
|
open,
|
|
4975
4998
|
show: () => {
|
|
@@ -5237,7 +5260,7 @@ function TestNewThreadComposer({
|
|
|
5237
5260
|
draftKey,
|
|
5238
5261
|
onSubmit
|
|
5239
5262
|
}) {
|
|
5240
|
-
const [text, setText] =
|
|
5263
|
+
const [text, setText] = useState3(initialPrompt ?? "");
|
|
5241
5264
|
return /* @__PURE__ */ jsxs(
|
|
5242
5265
|
"div",
|
|
5243
5266
|
{
|
|
@@ -5297,7 +5320,7 @@ function TestProviderModelPicker({
|
|
|
5297
5320
|
disabled,
|
|
5298
5321
|
className
|
|
5299
5322
|
}) {
|
|
5300
|
-
const [draft, setDraft] =
|
|
5323
|
+
const [draft, setDraft] = useState3(value);
|
|
5301
5324
|
const { providerId, model, reasoningLevel, serviceTier } = value;
|
|
5302
5325
|
useEffect3(
|
|
5303
5326
|
() => setDraft({
|
|
@@ -5574,7 +5597,10 @@ function TestVoiceInputTextarea({
|
|
|
5574
5597
|
}
|
|
5575
5598
|
);
|
|
5576
5599
|
}
|
|
5577
|
-
function TestFilePreview({
|
|
5600
|
+
function TestFilePreview({
|
|
5601
|
+
target,
|
|
5602
|
+
renderPreview
|
|
5603
|
+
}) {
|
|
5578
5604
|
const file = useSlotEnv("experimental_FilePreview").filePreview(target);
|
|
5579
5605
|
return /* @__PURE__ */ jsx("div", { "data-testid": "bb-file-preview", "data-path": target.path, children: file === null ? null : renderPreview(file) });
|
|
5580
5606
|
}
|
|
@@ -5991,18 +6017,23 @@ var testPluginSdkApp = {
|
|
|
5991
6017
|
experimental_SidebarNavigationIcon: TestSidebarNavigationIcon,
|
|
5992
6018
|
experimental_useSidebarThreadSplit(threadId) {
|
|
5993
6019
|
const env = useSlotEnv("experimental_useSidebarThreadSplit");
|
|
5994
|
-
return useMemo3(
|
|
5995
|
-
() => ({
|
|
6020
|
+
return useMemo3(() => {
|
|
6021
|
+
const panes = env.sidebarSplitLayout?.panes.map((pane) => ({
|
|
6022
|
+
paneId: pane.paneId,
|
|
6023
|
+
rect: pane.rect,
|
|
6024
|
+
isMe: pane.threadId === threadId,
|
|
6025
|
+
isFocused: pane.isFocused
|
|
6026
|
+
})) ?? [];
|
|
6027
|
+
return {
|
|
5996
6028
|
splitProps: {
|
|
5997
6029
|
onPointerDown: () => {
|
|
5998
6030
|
env.sidebarActionCalls.push({ method: "open", threadId });
|
|
5999
6031
|
}
|
|
6000
6032
|
},
|
|
6001
6033
|
isAvailable: true,
|
|
6002
|
-
layout: null
|
|
6003
|
-
}
|
|
6004
|
-
|
|
6005
|
-
);
|
|
6034
|
+
layout: panes.some((pane) => pane.isMe) ? { panes } : null
|
|
6035
|
+
};
|
|
6036
|
+
}, [env, threadId]);
|
|
6006
6037
|
},
|
|
6007
6038
|
useSidebarThreadDraft(threadId) {
|
|
6008
6039
|
const env = useSlotEnv("useSidebarThreadDraft");
|
package/dist/testing/index.js
CHANGED
|
@@ -3641,7 +3641,8 @@ function createFakePluginHostInternal(options, sharedState) {
|
|
|
3641
3641
|
method: String(method),
|
|
3642
3642
|
input: validatedInput,
|
|
3643
3643
|
hostId: callOptions.hostId,
|
|
3644
|
-
...callOptions.signal === void 0 ? {} : { signal: callOptions.signal }
|
|
3644
|
+
...callOptions.signal === void 0 ? {} : { signal: callOptions.signal },
|
|
3645
|
+
...callOptions.timeoutMs === void 0 ? {} : { timeoutMs: callOptions.timeoutMs }
|
|
3645
3646
|
};
|
|
3646
3647
|
hostRpcCalls.push(call);
|
|
3647
3648
|
if (options.experimental_callHostRpc === void 0) {
|