@get-bb/plugin-sdk 0.4.14 → 0.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/bundled-types/bb-plugin-sdk-ai-services.d.ts +141 -0
- package/bundled-types/bb-plugin-sdk-app.d.ts +144 -21
- package/bundled-types/bb-plugin-sdk-host.d.ts +479 -2
- package/bundled-types/bb-plugin-sdk-internal-composer-customization-validation.d.ts +10 -1
- package/bundled-types/bb-plugin-sdk-internal-host-policy.d.ts +339 -32
- package/bundled-types/bb-plugin-sdk-internal-plugin-app-collector.d.ts +2 -1
- package/bundled-types/bb-plugin-sdk-provider-bridge-acp.d.ts +807 -0
- package/bundled-types/bb-plugin-sdk-provider-bridge-testing.d.ts +1742 -211
- package/bundled-types/bb-plugin-sdk-provider-bridge.d.ts +2985 -2442
- package/bundled-types/bb-plugin-sdk-testing-app.d.ts +4 -3
- package/bundled-types/bb-plugin-sdk-testing.d.ts +551 -9
- package/bundled-types/bb-plugin-sdk.d.ts +1335 -1350
- package/dist/ai-services.js +91 -0
- package/dist/app.js +2 -2
- package/dist/host.js +14547 -1
- package/dist/internal/composer-customization-validation.js +11 -0
- package/dist/internal/host-policy.js +656 -91
- package/dist/internal/plugin-app-collector.js +58 -14
- package/dist/provider-bridge-acp.js +9753 -0
- package/dist/provider-bridge-testing.js +3355 -1771
- package/dist/provider-bridge-worker-entry.mjs +917 -0
- package/dist/provider-bridge.js +2255 -3718
- package/dist/replay-provider-child.mjs +650 -0
- package/dist/testing/app.js +63 -19
- package/dist/testing/index.js +803 -115
- package/package.json +14 -1
package/dist/testing/app.js
CHANGED
|
@@ -65,6 +65,15 @@ function requireProviderId(kind, value) {
|
|
|
65
65
|
}
|
|
66
66
|
return value;
|
|
67
67
|
}
|
|
68
|
+
var PLUGIN_TIMELINE_RENDERER_KIND_PATTERN = /^(tool|[a-z0-9-]+\/[a-z0-9-]+)$/u;
|
|
69
|
+
function requireTimelineRendererKind(kind, value) {
|
|
70
|
+
if (typeof value !== "string" || !PLUGIN_TIMELINE_RENDERER_KIND_PATTERN.test(value)) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`${kind}: "kind" must be "tool" or "<pluginId>/<name>" (lowercase letters, digits, "-"), got ${JSON.stringify(value)}`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
68
77
|
function requireMessageDirectiveId(kind, value) {
|
|
69
78
|
if (typeof value !== "string" || !PLUGIN_MESSAGE_DIRECTIVE_ID_PATTERN.test(value)) {
|
|
70
79
|
throw new Error(
|
|
@@ -383,6 +392,35 @@ function normalizeExperimentalFileOpenOptions(value) {
|
|
|
383
392
|
}
|
|
384
393
|
|
|
385
394
|
// src/internal/plugin-app-collector.ts
|
|
395
|
+
var NAV_PANEL_REGISTRATION_KEYS = new Set(
|
|
396
|
+
Object.keys({
|
|
397
|
+
id: true,
|
|
398
|
+
title: true,
|
|
399
|
+
icon: true,
|
|
400
|
+
path: true,
|
|
401
|
+
component: true,
|
|
402
|
+
fixedTabs: true,
|
|
403
|
+
experimental_sidebarAccessory: true,
|
|
404
|
+
headerContent: true
|
|
405
|
+
})
|
|
406
|
+
);
|
|
407
|
+
var RENAMED_NAV_PANEL_KEYS = /* @__PURE__ */ new Map([
|
|
408
|
+
["experimental_fixedTabs", "fixedTabs"]
|
|
409
|
+
]);
|
|
410
|
+
function rejectStaleNavPanelKeys(kind, registration) {
|
|
411
|
+
for (const key of Object.keys(registration)) {
|
|
412
|
+
if (NAV_PANEL_REGISTRATION_KEYS.has(key)) continue;
|
|
413
|
+
const renamedTo = RENAMED_NAV_PANEL_KEYS.get(key);
|
|
414
|
+
if (renamedTo !== void 0) {
|
|
415
|
+
throw new Error(
|
|
416
|
+
`${kind}: "${key}" was renamed to "${renamedTo}" in SDK 0.4.16`
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
if (key.startsWith("experimental_")) {
|
|
420
|
+
throw new Error(`${kind}: unknown field "${key}"`);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
386
424
|
function collectPluginAppRegistrations(definition, onComposerCustomizationRejected = (reason) => console.warn(reason)) {
|
|
387
425
|
const collected = {
|
|
388
426
|
homepageSections: [],
|
|
@@ -402,6 +440,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
|
|
|
402
440
|
messageActions: [],
|
|
403
441
|
commandPaletteActions: [],
|
|
404
442
|
providerIcons: [],
|
|
443
|
+
timelineRenderers: [],
|
|
405
444
|
contentScripts: []
|
|
406
445
|
};
|
|
407
446
|
const seenIds = {
|
|
@@ -422,6 +461,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
|
|
|
422
461
|
messageAction: /* @__PURE__ */ new Set(),
|
|
423
462
|
commandPaletteAction: /* @__PURE__ */ new Set(),
|
|
424
463
|
providerIcon: /* @__PURE__ */ new Set(),
|
|
464
|
+
timelineRenderer: /* @__PURE__ */ new Set(),
|
|
425
465
|
contentScript: /* @__PURE__ */ new Set()
|
|
426
466
|
};
|
|
427
467
|
definition.setup({
|
|
@@ -457,6 +497,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
|
|
|
457
497
|
const kind = "slots.navPanel";
|
|
458
498
|
const id = requireSlotId(kind, registration?.id);
|
|
459
499
|
requireUniqueId(kind, seenIds.navPanel, id);
|
|
500
|
+
rejectStaleNavPanelKeys(kind, registration);
|
|
460
501
|
const panelId = id;
|
|
461
502
|
const path = requireNonEmptyString(kind, "path", registration.path);
|
|
462
503
|
if (!PLUGIN_SLOT_ID_PATTERN.test(path)) {
|
|
@@ -474,16 +515,14 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
|
|
|
474
515
|
`${kind}: "experimental_sidebarAccessory" must be a React component function when set`
|
|
475
516
|
);
|
|
476
517
|
}
|
|
477
|
-
const
|
|
478
|
-
if (registration.
|
|
479
|
-
if (!Array.isArray(registration.
|
|
480
|
-
throw new Error(
|
|
481
|
-
`${kind}: "experimental_fixedTabs" must be an array when set`
|
|
482
|
-
);
|
|
518
|
+
const fixedTabs = (() => {
|
|
519
|
+
if (registration.fixedTabs === void 0) return [];
|
|
520
|
+
if (!Array.isArray(registration.fixedTabs)) {
|
|
521
|
+
throw new Error(`${kind}: "fixedTabs" must be an array when set`);
|
|
483
522
|
}
|
|
484
523
|
const seenFixedTabIds = /* @__PURE__ */ new Set();
|
|
485
|
-
return registration.
|
|
486
|
-
const fixedTabKind = `${kind}.
|
|
524
|
+
return registration.fixedTabs.map((value, index) => {
|
|
525
|
+
const fixedTabKind = `${kind}.fixedTabs[${index}]`;
|
|
487
526
|
const fixedTab = value;
|
|
488
527
|
const id2 = requireSlotId(fixedTabKind, fixedTab?.id);
|
|
489
528
|
requireUniqueId(fixedTabKind, seenFixedTabIds, id2);
|
|
@@ -517,11 +556,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
|
|
|
517
556
|
"title",
|
|
518
557
|
fixedTab?.title
|
|
519
558
|
),
|
|
520
|
-
icon: requireNonEmptyString(
|
|
521
|
-
fixedTabKind,
|
|
522
|
-
"icon",
|
|
523
|
-
fixedTab?.icon
|
|
524
|
-
),
|
|
559
|
+
icon: requireNonEmptyString(fixedTabKind, "icon", fixedTab?.icon),
|
|
525
560
|
component: requireComponent(fixedTabKind, fixedTab?.component),
|
|
526
561
|
...layout === void 0 ? {} : { layout },
|
|
527
562
|
...experimentalTarget === void 0 ? {} : {
|
|
@@ -536,7 +571,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
|
|
|
536
571
|
icon: requireNonEmptyString(kind, "icon", registration.icon),
|
|
537
572
|
path,
|
|
538
573
|
component: requireComponent(kind, registration.component),
|
|
539
|
-
...
|
|
574
|
+
...fixedTabs.length > 0 ? { fixedTabs } : {},
|
|
540
575
|
...registration.experimental_sidebarAccessory !== void 0 ? {
|
|
541
576
|
experimental_sidebarAccessory: registration.experimental_sidebarAccessory
|
|
542
577
|
} : {},
|
|
@@ -741,6 +776,15 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
|
|
|
741
776
|
providerId,
|
|
742
777
|
icon: requireComponent(kind, registration.icon)
|
|
743
778
|
});
|
|
779
|
+
},
|
|
780
|
+
experimental_timelineRenderer(registration) {
|
|
781
|
+
const kind = "slots.experimental_timelineRenderer";
|
|
782
|
+
const itemKind = requireTimelineRendererKind(kind, registration?.kind);
|
|
783
|
+
requireUniqueId(kind, seenIds.timelineRenderer, itemKind);
|
|
784
|
+
collected.timelineRenderers.push({
|
|
785
|
+
kind: itemKind,
|
|
786
|
+
component: requireComponent(kind, registration.component)
|
|
787
|
+
});
|
|
744
788
|
}
|
|
745
789
|
},
|
|
746
790
|
composer: {
|
|
@@ -857,7 +901,7 @@ function TestUrlLink({
|
|
|
857
901
|
target,
|
|
858
902
|
...anchorProps
|
|
859
903
|
}) {
|
|
860
|
-
const navigate = useSlotEnv("
|
|
904
|
+
const navigate = useSlotEnv("UrlLink").navigate;
|
|
861
905
|
const normalizedTarget = target?.toLowerCase();
|
|
862
906
|
const opensNewBrowsingContext = normalizedTarget !== void 0 && normalizedTarget !== "" && normalizedTarget !== "_self" && normalizedTarget !== "_parent" && normalizedTarget !== "_top" && normalizedTarget !== "_unfencedtop";
|
|
863
907
|
const relTokens = rel?.split(/\s+/u).filter(Boolean) ?? [];
|
|
@@ -879,7 +923,7 @@ function TestUrlLink({
|
|
|
879
923
|
if (event.defaultPrevented || event.button !== 0 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || event.currentTarget.hasAttribute("download") || event.currentTarget.hasAttribute("target")) {
|
|
880
924
|
return;
|
|
881
925
|
}
|
|
882
|
-
if (navigate.
|
|
926
|
+
if (navigate.openUrl(href)) event.preventDefault();
|
|
883
927
|
}
|
|
884
928
|
}
|
|
885
929
|
);
|
|
@@ -1231,7 +1275,7 @@ var testPluginSdkApp = {
|
|
|
1231
1275
|
ThreadChat: TestThreadChat,
|
|
1232
1276
|
Markdown: TestMarkdown,
|
|
1233
1277
|
experimental_FileLink: TestFileLink,
|
|
1234
|
-
|
|
1278
|
+
UrlLink: TestUrlLink,
|
|
1235
1279
|
experimental_NewThreadComposer: TestNewThreadComposer,
|
|
1236
1280
|
experimental_ProviderModelPicker: TestProviderModelPicker,
|
|
1237
1281
|
experimental_PermissionModePicker: TestPermissionModePicker,
|
|
@@ -1610,8 +1654,8 @@ function renderSlot(registration, props, options = {}) {
|
|
|
1610
1654
|
});
|
|
1611
1655
|
return options.openThreadPanel?.(panelOptions) ?? false;
|
|
1612
1656
|
},
|
|
1613
|
-
|
|
1614
|
-
navigateCalls.push({ method: "
|
|
1657
|
+
openUrl(url) {
|
|
1658
|
+
navigateCalls.push({ method: "openUrl", url });
|
|
1615
1659
|
return options.openUrl?.(url) ?? false;
|
|
1616
1660
|
},
|
|
1617
1661
|
experimental_openFilePreview(fileOptions) {
|