@get-bb/plugin-sdk 0.6.60 → 0.6.65
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 +341 -83
- package/bundled-types/bb-plugin-sdk-host.d.ts +196 -214
- package/bundled-types/bb-plugin-sdk-internal-host-policy.d.ts +17 -7
- package/bundled-types/bb-plugin-sdk-internal-rpc-query-host.d.ts +192 -0
- package/bundled-types/bb-plugin-sdk-internal-rpc-tags.d.ts +23 -0
- package/bundled-types/bb-plugin-sdk-testing-app.d.ts +7 -2
- package/bundled-types/bb-plugin-sdk-testing.d.ts +12 -4
- package/bundled-types/bb-plugin-sdk.d.ts +392 -109
- package/dist/app.js +98 -0
- package/dist/host.js +12 -0
- package/dist/index.js +81 -0
- package/dist/internal/host-policy.js +33 -1
- package/dist/internal/plugin-app-collector.js +16 -0
- package/dist/internal/rpc-query-host.js +922 -0
- package/dist/internal/rpc-tags.js +18 -0
- package/dist/provider-bridge-acp-next.js +37 -26
- package/dist/provider-bridge-acp.js +37 -26
- package/dist/provider-bridge.js +21 -20
- package/dist/replay-provider-child.mjs +6 -2
- package/dist/testing/app.js +1128 -100
- package/dist/testing/index.js +247 -104
- package/package.json +16 -2
package/dist/app.js
CHANGED
|
@@ -1,3 +1,84 @@
|
|
|
1
|
+
// src/rpc-contract.ts
|
|
2
|
+
var rpcErrorCodes = [
|
|
3
|
+
"forbidden",
|
|
4
|
+
"not_found",
|
|
5
|
+
"conflict",
|
|
6
|
+
"invalid",
|
|
7
|
+
"invalid_json",
|
|
8
|
+
"invalid_input",
|
|
9
|
+
"handler_error",
|
|
10
|
+
"invalid_output",
|
|
11
|
+
"non_json_result",
|
|
12
|
+
"unknown_method",
|
|
13
|
+
"transport_error",
|
|
14
|
+
"invalid_response",
|
|
15
|
+
"unknown_error"
|
|
16
|
+
];
|
|
17
|
+
var callErrorBrand = /* @__PURE__ */ Symbol.for("@get-bb/plugin-sdk/rpc-call-error");
|
|
18
|
+
var experimental_PluginRpcCallError = class _experimental_PluginRpcCallError extends Error {
|
|
19
|
+
/** Recognizes errors across the packed SDK's separately bundled entries. */
|
|
20
|
+
static [Symbol.hasInstance](value) {
|
|
21
|
+
return typeof value === "object" && value !== null && Reflect.get(value, callErrorBrand) === true && rpcErrorCodes.some((code) => code === Reflect.get(value, "code")) && typeof Reflect.get(value, "message") === "string";
|
|
22
|
+
}
|
|
23
|
+
code;
|
|
24
|
+
issues;
|
|
25
|
+
status;
|
|
26
|
+
serverCode;
|
|
27
|
+
constructor(args) {
|
|
28
|
+
super(args.message);
|
|
29
|
+
this.name = "experimental_PluginRpcCallError";
|
|
30
|
+
Object.defineProperty(this, callErrorBrand, { value: true });
|
|
31
|
+
this.code = args.code;
|
|
32
|
+
this.issues = args.issues;
|
|
33
|
+
this.status = args.status;
|
|
34
|
+
this.serverCode = args.serverCode;
|
|
35
|
+
}
|
|
36
|
+
/** Normalize failures at the RPC boundary; preserves an existing client error. */
|
|
37
|
+
static from(error, fallback = "transport_error") {
|
|
38
|
+
if (error instanceof _experimental_PluginRpcCallError) return error;
|
|
39
|
+
const record = typeof error === "object" && error !== null ? error : {};
|
|
40
|
+
const rawCode = Reflect.get(record, "code");
|
|
41
|
+
const code = rpcErrorCodes.find((value) => value === rawCode);
|
|
42
|
+
const message = Reflect.get(record, "message");
|
|
43
|
+
const status = Reflect.get(record, "status");
|
|
44
|
+
const rawIssues = Reflect.get(record, "issues");
|
|
45
|
+
const issues = [];
|
|
46
|
+
if (Array.isArray(rawIssues))
|
|
47
|
+
for (const issue of rawIssues) {
|
|
48
|
+
if (typeof issue !== "object" || issue === null || typeof Reflect.get(issue, "message") !== "string")
|
|
49
|
+
continue;
|
|
50
|
+
const path = Reflect.get(issue, "path");
|
|
51
|
+
if (path !== void 0 && (!Array.isArray(path) || !path.every(
|
|
52
|
+
(part) => typeof part === "string" || typeof part === "number" && Number.isFinite(part)
|
|
53
|
+
)))
|
|
54
|
+
continue;
|
|
55
|
+
issues.push({
|
|
56
|
+
message: Reflect.get(issue, "message"),
|
|
57
|
+
...path === void 0 ? {} : { path }
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return new _experimental_PluginRpcCallError({
|
|
61
|
+
code: code ?? (typeof rawCode === "string" ? "unknown_error" : fallback),
|
|
62
|
+
message: typeof message === "string" ? message : typeof error === "string" ? error : "Plugin RPC request failed",
|
|
63
|
+
...issues.length === 0 ? {} : { issues },
|
|
64
|
+
...typeof status === "number" ? { status } : {},
|
|
65
|
+
...typeof rawCode === "string" && code === void 0 ? { serverCode: rawCode } : {}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var refusalBrand = /* @__PURE__ */ Symbol.for("@get-bb/plugin-sdk/rpc-refusal");
|
|
70
|
+
var experimental_PluginRpcRefusal = class extends Error {
|
|
71
|
+
[refusalBrand] = true;
|
|
72
|
+
code;
|
|
73
|
+
issues;
|
|
74
|
+
constructor(args) {
|
|
75
|
+
super(args.message);
|
|
76
|
+
this.name = "experimental_PluginRpcRefusal";
|
|
77
|
+
this.code = args.code;
|
|
78
|
+
this.issues = args.issues;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
1
82
|
// src/thread-action-groups.ts
|
|
2
83
|
var experimental_THREAD_ACTION_GROUPS = {
|
|
3
84
|
open: "1_open",
|
|
@@ -81,6 +162,18 @@ var experimental_SourceCode = runtimeComponent(
|
|
|
81
162
|
"experimental_SourceCode"
|
|
82
163
|
);
|
|
83
164
|
var experimental_Diff = runtimeComponent("experimental_Diff");
|
|
165
|
+
var experimental_useRpcQuery = runtimeFunction(
|
|
166
|
+
"experimental_useRpcQuery"
|
|
167
|
+
);
|
|
168
|
+
var experimental_useRpcKeyedQuery = runtimeFunction(
|
|
169
|
+
"experimental_useRpcKeyedQuery"
|
|
170
|
+
);
|
|
171
|
+
var experimental_useRpcMutation = runtimeFunction(
|
|
172
|
+
"experimental_useRpcMutation"
|
|
173
|
+
);
|
|
174
|
+
var experimental_useRpcRefresh = runtimeFunction(
|
|
175
|
+
"experimental_useRpcRefresh"
|
|
176
|
+
);
|
|
84
177
|
var useRpc = runtimeFunction("useRpc");
|
|
85
178
|
var useRealtime = runtimeFunction("useRealtime");
|
|
86
179
|
var useRealtimeConnectionState = runtimeFunction(
|
|
@@ -184,6 +277,7 @@ export {
|
|
|
184
277
|
experimental_Icon,
|
|
185
278
|
experimental_NewThreadComposer,
|
|
186
279
|
experimental_PermissionModePicker,
|
|
280
|
+
experimental_PluginRpcCallError,
|
|
187
281
|
experimental_ProviderIcon,
|
|
188
282
|
experimental_ProviderModelPicker,
|
|
189
283
|
experimental_SidebarNavigationIcon,
|
|
@@ -204,6 +298,10 @@ export {
|
|
|
204
298
|
experimental_usePluginId,
|
|
205
299
|
experimental_useProviders,
|
|
206
300
|
experimental_useQuestionFormHost,
|
|
301
|
+
experimental_useRpcKeyedQuery,
|
|
302
|
+
experimental_useRpcMutation,
|
|
303
|
+
experimental_useRpcQuery,
|
|
304
|
+
experimental_useRpcRefresh,
|
|
207
305
|
experimental_useSidebarNavigation,
|
|
208
306
|
experimental_useSidebarNavigationSplit,
|
|
209
307
|
experimental_useSidebarThreadActions,
|
package/dist/host.js
CHANGED
|
@@ -214,6 +214,18 @@ var providerNativeRootSetSchema = z.object({
|
|
|
214
214
|
}).strict();
|
|
215
215
|
|
|
216
216
|
// src/rpc-contract.ts
|
|
217
|
+
var refusalBrand = /* @__PURE__ */ Symbol.for("@get-bb/plugin-sdk/rpc-refusal");
|
|
218
|
+
var experimental_PluginRpcRefusal = class extends Error {
|
|
219
|
+
[refusalBrand] = true;
|
|
220
|
+
code;
|
|
221
|
+
issues;
|
|
222
|
+
constructor(args) {
|
|
223
|
+
super(args.message);
|
|
224
|
+
this.name = "experimental_PluginRpcRefusal";
|
|
225
|
+
this.code = args.code;
|
|
226
|
+
this.issues = args.issues;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
217
229
|
function defineRpcContract(contract) {
|
|
218
230
|
return contract;
|
|
219
231
|
}
|
package/dist/index.js
CHANGED
|
@@ -809,6 +809,85 @@ function experimental_defineHostEntry(args) {
|
|
|
809
809
|
}
|
|
810
810
|
|
|
811
811
|
// src/rpc-contract.ts
|
|
812
|
+
var rpcErrorCodes = [
|
|
813
|
+
"forbidden",
|
|
814
|
+
"not_found",
|
|
815
|
+
"conflict",
|
|
816
|
+
"invalid",
|
|
817
|
+
"invalid_json",
|
|
818
|
+
"invalid_input",
|
|
819
|
+
"handler_error",
|
|
820
|
+
"invalid_output",
|
|
821
|
+
"non_json_result",
|
|
822
|
+
"unknown_method",
|
|
823
|
+
"transport_error",
|
|
824
|
+
"invalid_response",
|
|
825
|
+
"unknown_error"
|
|
826
|
+
];
|
|
827
|
+
var callErrorBrand = /* @__PURE__ */ Symbol.for("@get-bb/plugin-sdk/rpc-call-error");
|
|
828
|
+
var experimental_PluginRpcCallError = class _experimental_PluginRpcCallError extends Error {
|
|
829
|
+
/** Recognizes errors across the packed SDK's separately bundled entries. */
|
|
830
|
+
static [Symbol.hasInstance](value) {
|
|
831
|
+
return typeof value === "object" && value !== null && Reflect.get(value, callErrorBrand) === true && rpcErrorCodes.some((code) => code === Reflect.get(value, "code")) && typeof Reflect.get(value, "message") === "string";
|
|
832
|
+
}
|
|
833
|
+
code;
|
|
834
|
+
issues;
|
|
835
|
+
status;
|
|
836
|
+
serverCode;
|
|
837
|
+
constructor(args) {
|
|
838
|
+
super(args.message);
|
|
839
|
+
this.name = "experimental_PluginRpcCallError";
|
|
840
|
+
Object.defineProperty(this, callErrorBrand, { value: true });
|
|
841
|
+
this.code = args.code;
|
|
842
|
+
this.issues = args.issues;
|
|
843
|
+
this.status = args.status;
|
|
844
|
+
this.serverCode = args.serverCode;
|
|
845
|
+
}
|
|
846
|
+
/** Normalize failures at the RPC boundary; preserves an existing client error. */
|
|
847
|
+
static from(error, fallback = "transport_error") {
|
|
848
|
+
if (error instanceof _experimental_PluginRpcCallError) return error;
|
|
849
|
+
const record = typeof error === "object" && error !== null ? error : {};
|
|
850
|
+
const rawCode = Reflect.get(record, "code");
|
|
851
|
+
const code = rpcErrorCodes.find((value) => value === rawCode);
|
|
852
|
+
const message = Reflect.get(record, "message");
|
|
853
|
+
const status = Reflect.get(record, "status");
|
|
854
|
+
const rawIssues = Reflect.get(record, "issues");
|
|
855
|
+
const issues = [];
|
|
856
|
+
if (Array.isArray(rawIssues))
|
|
857
|
+
for (const issue of rawIssues) {
|
|
858
|
+
if (typeof issue !== "object" || issue === null || typeof Reflect.get(issue, "message") !== "string")
|
|
859
|
+
continue;
|
|
860
|
+
const path = Reflect.get(issue, "path");
|
|
861
|
+
if (path !== void 0 && (!Array.isArray(path) || !path.every(
|
|
862
|
+
(part) => typeof part === "string" || typeof part === "number" && Number.isFinite(part)
|
|
863
|
+
)))
|
|
864
|
+
continue;
|
|
865
|
+
issues.push({
|
|
866
|
+
message: Reflect.get(issue, "message"),
|
|
867
|
+
...path === void 0 ? {} : { path }
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
return new _experimental_PluginRpcCallError({
|
|
871
|
+
code: code ?? (typeof rawCode === "string" ? "unknown_error" : fallback),
|
|
872
|
+
message: typeof message === "string" ? message : typeof error === "string" ? error : "Plugin RPC request failed",
|
|
873
|
+
...issues.length === 0 ? {} : { issues },
|
|
874
|
+
...typeof status === "number" ? { status } : {},
|
|
875
|
+
...typeof rawCode === "string" && code === void 0 ? { serverCode: rawCode } : {}
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
var refusalBrand = /* @__PURE__ */ Symbol.for("@get-bb/plugin-sdk/rpc-refusal");
|
|
880
|
+
var experimental_PluginRpcRefusal = class extends Error {
|
|
881
|
+
[refusalBrand] = true;
|
|
882
|
+
code;
|
|
883
|
+
issues;
|
|
884
|
+
constructor(args) {
|
|
885
|
+
super(args.message);
|
|
886
|
+
this.name = "experimental_PluginRpcRefusal";
|
|
887
|
+
this.code = args.code;
|
|
888
|
+
this.issues = args.issues;
|
|
889
|
+
}
|
|
890
|
+
};
|
|
812
891
|
function defineRpcContract(contract) {
|
|
813
892
|
return contract;
|
|
814
893
|
}
|
|
@@ -827,6 +906,8 @@ export {
|
|
|
827
906
|
cliCommand,
|
|
828
907
|
defineCli,
|
|
829
908
|
defineRpcContract,
|
|
909
|
+
experimental_PluginRpcCallError,
|
|
910
|
+
experimental_PluginRpcRefusal,
|
|
830
911
|
experimental_THREAD_ACTION_GROUPS,
|
|
831
912
|
experimental_defineHostEntry
|
|
832
913
|
};
|
|
@@ -1444,7 +1444,21 @@ function readRpcMethodContract(method, value) {
|
|
|
1444
1444
|
const description = rpcDescriptionSchema.parse(
|
|
1445
1445
|
Reflect.get(value, "experimental_description")
|
|
1446
1446
|
);
|
|
1447
|
-
|
|
1447
|
+
const declarations = {};
|
|
1448
|
+
for (const name of ["tags", "keyTags", "invalidates"]) {
|
|
1449
|
+
const declaration = Reflect.get(value, name);
|
|
1450
|
+
if (declaration !== void 0) {
|
|
1451
|
+
if (typeof declaration !== "function")
|
|
1452
|
+
throw new Error(`rpc ${method} ${name} must be a function`);
|
|
1453
|
+
Reflect.set(declarations, name, declaration);
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
return {
|
|
1457
|
+
input,
|
|
1458
|
+
output,
|
|
1459
|
+
...declarations,
|
|
1460
|
+
...description === null ? {} : { experimental_description: description }
|
|
1461
|
+
};
|
|
1448
1462
|
}
|
|
1449
1463
|
function readRpcPublicationOptions(value) {
|
|
1450
1464
|
return rpcPublicationOptionsSchema.parse(value ?? {});
|
|
@@ -2215,6 +2229,7 @@ function normalizeRpcRegistration(contract, handlers, registered, options) {
|
|
|
2215
2229
|
name,
|
|
2216
2230
|
{
|
|
2217
2231
|
publication: publishRpcMethod(name, methodContract, publicationOptions),
|
|
2232
|
+
declarations: methodContract,
|
|
2218
2233
|
inputSchema: methodContract.input,
|
|
2219
2234
|
outputSchema: methodContract.output,
|
|
2220
2235
|
handler
|
|
@@ -2684,6 +2699,22 @@ function normalizeRpcIssues(issues) {
|
|
|
2684
2699
|
};
|
|
2685
2700
|
});
|
|
2686
2701
|
}
|
|
2702
|
+
var rpcRefusalSchema = z5.object({
|
|
2703
|
+
code: z5.enum(["forbidden", "not_found", "conflict", "invalid"]),
|
|
2704
|
+
message: z5.string(),
|
|
2705
|
+
issues: z5.array(
|
|
2706
|
+
z5.object({
|
|
2707
|
+
message: z5.string(),
|
|
2708
|
+
path: z5.array(z5.union([z5.string(), z5.number()])).optional()
|
|
2709
|
+
})
|
|
2710
|
+
).optional()
|
|
2711
|
+
});
|
|
2712
|
+
function readPluginRpcRefusal(error) {
|
|
2713
|
+
if (typeof error !== "object" || error === null || Reflect.get(error, /* @__PURE__ */ Symbol.for("@get-bb/plugin-sdk/rpc-refusal")) !== true)
|
|
2714
|
+
return null;
|
|
2715
|
+
const parsed = rpcRefusalSchema.safeParse(error);
|
|
2716
|
+
return parsed.success ? parsed.data : null;
|
|
2717
|
+
}
|
|
2687
2718
|
async function validateRpcValue(schema, value, phase, fail) {
|
|
2688
2719
|
let result;
|
|
2689
2720
|
try {
|
|
@@ -2806,6 +2837,7 @@ export {
|
|
|
2806
2837
|
providerIconRefusalMessage,
|
|
2807
2838
|
providerWithoutBridgeMessage,
|
|
2808
2839
|
publishRpcMethod,
|
|
2840
|
+
readPluginRpcRefusal,
|
|
2809
2841
|
readRpcPublicationOptions,
|
|
2810
2842
|
registerSettingDescriptors,
|
|
2811
2843
|
runPluginStorageMigrations,
|
|
@@ -379,6 +379,8 @@ var NAV_PANEL_REGISTRATION_KEYS = new Set(
|
|
|
379
379
|
component: true,
|
|
380
380
|
fixedTabs: true,
|
|
381
381
|
experimental_useBadge: true,
|
|
382
|
+
experimental_usePageTitle: true,
|
|
383
|
+
experimental_sidebar: true,
|
|
382
384
|
headerContent: true
|
|
383
385
|
})
|
|
384
386
|
);
|
|
@@ -641,6 +643,16 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
641
643
|
`${kind}: "experimental_useBadge" must be a React hook function when set`
|
|
642
644
|
);
|
|
643
645
|
}
|
|
646
|
+
if (registration.experimental_sidebar !== void 0 && typeof registration.experimental_sidebar !== "function") {
|
|
647
|
+
throw new Error(
|
|
648
|
+
`${kind}: "experimental_sidebar" must be a React component function when set`
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
if (registration.experimental_usePageTitle !== void 0 && typeof registration.experimental_usePageTitle !== "function") {
|
|
652
|
+
throw new Error(
|
|
653
|
+
`${kind}: "experimental_usePageTitle" must be a React hook function when set`
|
|
654
|
+
);
|
|
655
|
+
}
|
|
644
656
|
const fixedTabs = (() => {
|
|
645
657
|
if (registration.fixedTabs === void 0) return [];
|
|
646
658
|
if (!Array.isArray(registration.fixedTabs)) {
|
|
@@ -701,6 +713,10 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
701
713
|
...registration.experimental_useBadge !== void 0 ? {
|
|
702
714
|
experimental_useBadge: registration.experimental_useBadge
|
|
703
715
|
} : {},
|
|
716
|
+
...registration.experimental_usePageTitle !== void 0 ? {
|
|
717
|
+
experimental_usePageTitle: registration.experimental_usePageTitle
|
|
718
|
+
} : {},
|
|
719
|
+
...registration.experimental_sidebar !== void 0 ? { experimental_sidebar: registration.experimental_sidebar } : {},
|
|
704
720
|
...registration.headerContent !== void 0 ? { headerContent: registration.headerContent } : {}
|
|
705
721
|
});
|
|
706
722
|
},
|