@get-bb/plugin-sdk 0.6.178 → 0.6.189
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 +382 -77
- package/bundled-types/bb-plugin-sdk-environment-provider.d.ts +34 -1
- package/bundled-types/bb-plugin-sdk-internal-composer-handle.d.ts +21 -6
- package/bundled-types/bb-plugin-sdk-internal-host-policy.d.ts +98 -9
- package/bundled-types/bb-plugin-sdk-internal-thread-event-gate.d.ts +10 -0
- package/bundled-types/bb-plugin-sdk-internal-thread-status.d.ts +7 -0
- package/bundled-types/bb-plugin-sdk-testing-app.d.ts +19 -1
- package/bundled-types/bb-plugin-sdk-testing.d.ts +48 -4
- package/bundled-types/bb-plugin-sdk.d.ts +474 -85
- package/dist/app.js +8 -0
- package/dist/internal/composer-handle.js +13 -4
- package/dist/internal/host-policy.js +14 -2
- package/dist/internal/plugin-app-collector.js +24 -8
- package/dist/internal/rpc-query-host.js +7 -1
- package/dist/provider-bridge-acp-next.js +5 -1
- package/dist/provider-bridge-acp.js +5 -1
- package/dist/testing/app.js +139 -16
- package/dist/testing/index.js +81 -8
- package/package.json +1 -1
package/dist/app.js
CHANGED
|
@@ -390,6 +390,9 @@ var experimental_ImageLightbox = runtimeComponent(
|
|
|
390
390
|
var experimental_PromptMentionIcon = runtimeComponent(
|
|
391
391
|
"experimental_PromptMentionIcon"
|
|
392
392
|
);
|
|
393
|
+
var experimental_useCommandShortcut = runtimeFunction(
|
|
394
|
+
"experimental_useCommandShortcut"
|
|
395
|
+
);
|
|
393
396
|
var experimental_matchesShortcutKey = runtimeFunction(
|
|
394
397
|
"experimental_matchesShortcutKey"
|
|
395
398
|
);
|
|
@@ -494,6 +497,9 @@ var experimental_useCodeTheme = runtimeFunction(
|
|
|
494
497
|
var experimental_copyToClipboard = runtimeFunction(
|
|
495
498
|
"experimental_copyToClipboard"
|
|
496
499
|
);
|
|
500
|
+
var experimental_showErrorToast = runtimeFunction(
|
|
501
|
+
"experimental_showErrorToast"
|
|
502
|
+
);
|
|
497
503
|
var experimental_saveFile = runtimeFunction("experimental_saveFile");
|
|
498
504
|
var experimental_getApplicationLinkApprovals = runtimeFunction(
|
|
499
505
|
"experimental_getApplicationLinkApprovals"
|
|
@@ -554,6 +560,7 @@ export {
|
|
|
554
560
|
experimental_resolveThreadStatus,
|
|
555
561
|
experimental_revokeApplicationLinkApproval,
|
|
556
562
|
experimental_saveFile,
|
|
563
|
+
experimental_showErrorToast,
|
|
557
564
|
experimental_sliceUtf16Head,
|
|
558
565
|
experimental_useActiveComposer,
|
|
559
566
|
experimental_useAppPanel,
|
|
@@ -562,6 +569,7 @@ export {
|
|
|
562
569
|
experimental_useCanOpenFileExternally,
|
|
563
570
|
experimental_useCheckoutState,
|
|
564
571
|
experimental_useCodeTheme,
|
|
572
|
+
experimental_useCommandShortcut,
|
|
565
573
|
experimental_useComposerCommandSearch,
|
|
566
574
|
experimental_useComposerContributions,
|
|
567
575
|
experimental_useComposerMentionSearch,
|
|
@@ -222,7 +222,7 @@ function validProviderId(provider) {
|
|
|
222
222
|
const trimmed = provider.trim();
|
|
223
223
|
return trimmed.length === 0 || trimmed.includes(":") ? null : trimmed;
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function composerDraftFromInsertParts(parts, context) {
|
|
226
226
|
const list = Array.isArray(parts) ? parts : [parts];
|
|
227
227
|
let text = "";
|
|
228
228
|
const mentions = [];
|
|
@@ -235,22 +235,30 @@ function insertValue(parts, controller) {
|
|
|
235
235
|
if ("kind" in part) {
|
|
236
236
|
mention = part;
|
|
237
237
|
} else {
|
|
238
|
+
if (context.pluginId === null) {
|
|
239
|
+
throw new Error(
|
|
240
|
+
`Mention "${part.label}" has no kind and no plugin to resolve it.`
|
|
241
|
+
);
|
|
242
|
+
}
|
|
238
243
|
const provider = validProviderId(part.provider);
|
|
239
244
|
if (provider === null) {
|
|
240
245
|
throw new Error(`Invalid mention provider id "${part.provider}".`);
|
|
241
246
|
}
|
|
247
|
+
if (part.id.length === 0) {
|
|
248
|
+
throw new Error(`Mention "${part.label}" has an empty id.`);
|
|
249
|
+
}
|
|
242
250
|
mention = {
|
|
243
251
|
from: 0,
|
|
244
252
|
to: 0,
|
|
245
253
|
label: part.label.trim() || part.id,
|
|
246
254
|
kind: "plugin",
|
|
247
|
-
pluginId:
|
|
255
|
+
pluginId: context.pluginId,
|
|
248
256
|
provider,
|
|
249
257
|
id: part.id,
|
|
250
258
|
icon: null
|
|
251
259
|
};
|
|
252
260
|
}
|
|
253
|
-
const serialized =
|
|
261
|
+
const serialized = context.mentionText(mention);
|
|
254
262
|
mentions.push({
|
|
255
263
|
...mention,
|
|
256
264
|
from: text.length,
|
|
@@ -355,7 +363,7 @@ function createComposerHandleBinding(key, initial) {
|
|
|
355
363
|
};
|
|
356
364
|
const insert = (parts, options = {}) => {
|
|
357
365
|
requireAvailable();
|
|
358
|
-
const value =
|
|
366
|
+
const value = composerDraftFromInsertParts(parts, controller);
|
|
359
367
|
const block = options.block === true;
|
|
360
368
|
if ((options.at ?? "cursor") === "cursor") {
|
|
361
369
|
if (!target().insertAtCursor(value, block)) {
|
|
@@ -539,6 +547,7 @@ function createComposerHandleBinding(key, initial) {
|
|
|
539
547
|
export {
|
|
540
548
|
OFF_SCREEN_EDITOR_STATE,
|
|
541
549
|
appendComposerDraft,
|
|
550
|
+
composerDraftFromInsertParts,
|
|
542
551
|
createComposerDraftActions,
|
|
543
552
|
createComposerHandleBinding,
|
|
544
553
|
reconcileComposerMentions
|
|
@@ -2186,11 +2186,23 @@ function validatePluginMachineProviderDeclaration(declaration) {
|
|
|
2186
2186
|
function validateServerAccessProviderDeclaration(declaration) {
|
|
2187
2187
|
if (typeof declaration !== "object" || declaration === null)
|
|
2188
2188
|
throw new Error("Invalid server access provider declaration");
|
|
2189
|
-
if (typeof declaration.id !== "string" || !/^[a-z][a-z0-9-]*$/u.test(declaration.id) || declaration.id === "direct")
|
|
2189
|
+
if (typeof declaration.id !== "string" || !/^[a-z][a-z0-9-]*$/u.test(declaration.id) || declaration.id === "direct" || declaration.id === "local-network")
|
|
2190
2190
|
throw new Error("Invalid or reserved server access provider id");
|
|
2191
|
+
if (declaration.routeKind !== void 0 && !["local-network", "private-overlay", "relay", "custom"].includes(
|
|
2192
|
+
declaration.routeKind
|
|
2193
|
+
))
|
|
2194
|
+
throw new Error("Invalid server access route kind");
|
|
2191
2195
|
if (typeof declaration.displayName !== "string" || !declaration.displayName.trim() || typeof declaration.description !== "string" || !declaration.description.trim() || typeof declaration.availability !== "function" || typeof declaration.acquire !== "function" || typeof declaration.release !== "function")
|
|
2192
2196
|
throw new Error("Invalid server access provider declaration");
|
|
2193
|
-
return
|
|
2197
|
+
return {
|
|
2198
|
+
id: declaration.id,
|
|
2199
|
+
displayName: declaration.displayName,
|
|
2200
|
+
description: declaration.description,
|
|
2201
|
+
routeKind: declaration.routeKind ?? "custom",
|
|
2202
|
+
availability: () => declaration.availability(),
|
|
2203
|
+
acquire: (context) => declaration.acquire(context),
|
|
2204
|
+
release: (context) => declaration.release(context)
|
|
2205
|
+
};
|
|
2194
2206
|
}
|
|
2195
2207
|
var LEGACY_UNKNOWN_MIGRATION_HASH = "legacy-unknown";
|
|
2196
2208
|
function migrationStatementHash(statement) {
|
|
@@ -424,6 +424,7 @@ function readLegacyCardSectionTitle(kind, registration, onWarning) {
|
|
|
424
424
|
);
|
|
425
425
|
return title;
|
|
426
426
|
}
|
|
427
|
+
var BARE_KEY_SHORTCUT_MESSAGE = 'Use Command, Control, or Alt with a key, or a function key; bare keys need experimental_keyScope: "pluginPage"';
|
|
427
428
|
function createCommandShortcutSchema() {
|
|
428
429
|
return z.object({
|
|
429
430
|
key: z.string().min(1).max(32).refine(
|
|
@@ -442,10 +443,10 @@ function createCommandShortcutSchema() {
|
|
|
442
443
|
control: z.boolean().default(false),
|
|
443
444
|
alt: z.boolean().default(false),
|
|
444
445
|
shift: z.boolean().default(false)
|
|
445
|
-
}).strict()
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
);
|
|
446
|
+
}).strict();
|
|
447
|
+
}
|
|
448
|
+
function isBareKeyShortcut(shortcut) {
|
|
449
|
+
return !(shortcut.mod || shortcut.meta || shortcut.control || shortcut.alt || /^F(?:[1-9]|1[0-9]|2[0-4])$/u.test(shortcut.key));
|
|
449
450
|
}
|
|
450
451
|
var MESSAGE_ACTION_SURFACES = [
|
|
451
452
|
"thread-view",
|
|
@@ -643,27 +644,38 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
643
644
|
};
|
|
644
645
|
collected.tabs.push(validated);
|
|
645
646
|
}
|
|
646
|
-
function collectCommand(kind, registration) {
|
|
647
|
+
function collectCommand(kind, registration, keyScope) {
|
|
647
648
|
const id = requireSlotId(kind, registration?.id);
|
|
648
649
|
requireUniqueId(kind, seenIds.command, id);
|
|
649
650
|
if (typeof registration.run !== "function") {
|
|
650
651
|
throw new Error(`${kind}: "run" must be a function`);
|
|
651
652
|
}
|
|
653
|
+
const defaultShortcut = registration.defaultShortcut === void 0 ? null : commandShortcutSchema.parse(registration.defaultShortcut);
|
|
654
|
+
if (defaultShortcut !== null && keyScope !== "pluginPage" && isBareKeyShortcut(defaultShortcut)) {
|
|
655
|
+
throw new Error(`${kind}: ${BARE_KEY_SHORTCUT_MESSAGE}`);
|
|
656
|
+
}
|
|
652
657
|
return {
|
|
653
658
|
id,
|
|
654
|
-
defaultShortcut
|
|
659
|
+
defaultShortcut,
|
|
655
660
|
title: requireNonEmptyString(kind, "title", registration.title)
|
|
656
661
|
};
|
|
657
662
|
}
|
|
658
663
|
function registerCommand(registration) {
|
|
659
664
|
const kind = "commands.register";
|
|
660
|
-
const
|
|
665
|
+
const keyScope = registration?.experimental_keyScope;
|
|
666
|
+
if (keyScope !== void 0 && keyScope !== "pluginPage") {
|
|
667
|
+
throw new Error(
|
|
668
|
+
`${kind}: "experimental_keyScope" must be "pluginPage" or omitted`
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
const command = collectCommand(kind, registration, keyScope);
|
|
661
672
|
if (registration.isAvailable !== void 0 && typeof registration.isAvailable !== "function") {
|
|
662
673
|
throw new Error(`${kind}: "isAvailable" must be a function`);
|
|
663
674
|
}
|
|
664
675
|
collected.commandPaletteActions.push({
|
|
665
676
|
target: "app",
|
|
666
677
|
...command,
|
|
678
|
+
...keyScope !== void 0 ? { experimental_keyScope: keyScope } : {},
|
|
667
679
|
...registration.isAvailable !== void 0 ? { isAvailable: registration.isAvailable } : {},
|
|
668
680
|
run: registration.run
|
|
669
681
|
});
|
|
@@ -671,7 +683,11 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
671
683
|
function registerComposerCommand(registration) {
|
|
672
684
|
collected.commandPaletteActions.push({
|
|
673
685
|
target: "composer",
|
|
674
|
-
...collectCommand(
|
|
686
|
+
...collectCommand(
|
|
687
|
+
"composer.experimental_registerCommand",
|
|
688
|
+
registration,
|
|
689
|
+
void 0
|
|
690
|
+
),
|
|
675
691
|
run: registration.run
|
|
676
692
|
});
|
|
677
693
|
}
|
|
@@ -1619,7 +1619,10 @@ var threadCreateOriginSchema = z5.enum(threadCreateOriginValues);
|
|
|
1619
1619
|
|
|
1620
1620
|
// ../domain/src/environment.ts
|
|
1621
1621
|
import { z as z6 } from "zod";
|
|
1622
|
-
var environmentHolderSchema = z6.
|
|
1622
|
+
var environmentHolderSchema = z6.union([
|
|
1623
|
+
z6.literal("user"),
|
|
1624
|
+
z6.templateLiteral(["plugin:", pluginIdSchema])
|
|
1625
|
+
]);
|
|
1623
1626
|
var environmentMachineSelectionSchema = z6.discriminatedUnion("type", [
|
|
1624
1627
|
z6.object({ type: z6.literal("existing"), hostId: z6.string().min(1) }),
|
|
1625
1628
|
z6.object({
|
|
@@ -1686,6 +1689,7 @@ var environmentSchema = z6.object({
|
|
|
1686
1689
|
projectId: z6.string(),
|
|
1687
1690
|
hostId: z6.string(),
|
|
1688
1691
|
path: z6.string().nullable(),
|
|
1692
|
+
additionalPaths: z6.array(z6.string()),
|
|
1689
1693
|
isGitRepo: z6.boolean(),
|
|
1690
1694
|
isWorktree: z6.boolean(),
|
|
1691
1695
|
branchName: z6.string().nullable(),
|
|
@@ -2000,6 +2004,7 @@ var threadWithRuntimeSchema = threadSchema.extend({
|
|
|
2000
2004
|
var threadQueuedWorkValues = ["none", "waiting", "failed"];
|
|
2001
2005
|
var threadQueuedWorkSchema = z16.enum(threadQueuedWorkValues);
|
|
2002
2006
|
var threadListEntrySchema = threadWithRuntimeSchema.extend({
|
|
2007
|
+
statusChangedAt: z16.number(),
|
|
2003
2008
|
activity: threadActivityStateSchema,
|
|
2004
2009
|
queuedWork: threadQueuedWorkSchema,
|
|
2005
2010
|
pinSortKey: z16.string().nullable(),
|
|
@@ -2182,6 +2187,7 @@ var threadStatusChangeMetadataSchema = z17.object({
|
|
|
2182
2187
|
runtime: threadRuntimeStateSchema,
|
|
2183
2188
|
activity: threadActivityStateSchema,
|
|
2184
2189
|
latestAttentionAt: z17.number(),
|
|
2190
|
+
statusChangedAt: z17.number(),
|
|
2185
2191
|
updatedAt: z17.number()
|
|
2186
2192
|
}).strict();
|
|
2187
2193
|
var threadChangeMetadataSchema = z17.object({
|
|
@@ -24696,7 +24696,11 @@ function reconcileExecutionSettings(session, options) {
|
|
|
24696
24696
|
dialectLaunchEnv(session.dialect.id, session.construction.permissionMode),
|
|
24697
24697
|
dialectLaunchEnv(session.dialect.id, construction.permissionMode)
|
|
24698
24698
|
) || launchModelChanged;
|
|
24699
|
-
const
|
|
24699
|
+
const additionalDirectoriesChanged = session.capabilities !== void 0 && session.supportsLoadSession && !isDeepStrictEqual2(
|
|
24700
|
+
additionalSessionDirectories(session.construction, session.capabilities),
|
|
24701
|
+
additionalSessionDirectories(construction, session.capabilities)
|
|
24702
|
+
);
|
|
24703
|
+
const restart = session.connection.exited || session.rebuildBeforeNextPrompt !== null || launchArgsChanged || additionalDirectoriesChanged || !isDeepStrictEqual2(envVars ?? {}, session.construction.envVars ?? {});
|
|
24700
24704
|
withdrawPendingQuestions(session, "a new prompt started before you answered");
|
|
24701
24705
|
session.policy = {
|
|
24702
24706
|
permissionMode: options.permissionMode,
|
|
@@ -24696,7 +24696,11 @@ function reconcileExecutionSettings(session, options) {
|
|
|
24696
24696
|
dialectLaunchEnv(session.dialect.id, session.construction.permissionMode),
|
|
24697
24697
|
dialectLaunchEnv(session.dialect.id, construction.permissionMode)
|
|
24698
24698
|
) || launchModelChanged;
|
|
24699
|
-
const
|
|
24699
|
+
const additionalDirectoriesChanged = session.capabilities !== void 0 && session.supportsLoadSession && !isDeepStrictEqual2(
|
|
24700
|
+
additionalSessionDirectories(session.construction, session.capabilities),
|
|
24701
|
+
additionalSessionDirectories(construction, session.capabilities)
|
|
24702
|
+
);
|
|
24703
|
+
const restart = session.connection.exited || session.rebuildBeforeNextPrompt !== null || launchArgsChanged || additionalDirectoriesChanged || !isDeepStrictEqual2(envVars ?? {}, session.construction.envVars ?? {});
|
|
24700
24704
|
withdrawPendingQuestions(session, "a new prompt started before you answered");
|
|
24701
24705
|
session.policy = {
|
|
24702
24706
|
permissionMode: options.permissionMode,
|
package/dist/testing/app.js
CHANGED
|
@@ -1616,6 +1616,7 @@ var APP_COMMAND_IDS = [
|
|
|
1616
1616
|
"app.back",
|
|
1617
1617
|
"settings.open",
|
|
1618
1618
|
"settings.openServers",
|
|
1619
|
+
"settings.search",
|
|
1619
1620
|
"sidebar.toggle",
|
|
1620
1621
|
"panel.previousTab",
|
|
1621
1622
|
"panel.nextTab",
|
|
@@ -1669,6 +1670,8 @@ var APP_COMMAND_CONTEXT_KEYS = [
|
|
|
1669
1670
|
"questionOpen",
|
|
1670
1671
|
"questionFocus",
|
|
1671
1672
|
"promptAvailable",
|
|
1673
|
+
"pluginPage",
|
|
1674
|
+
"settingsPage",
|
|
1672
1675
|
"splitActive",
|
|
1673
1676
|
"webSurface",
|
|
1674
1677
|
"macPlatform",
|
|
@@ -1864,7 +1867,10 @@ var threadCreateOriginSchema = z6.enum(threadCreateOriginValues);
|
|
|
1864
1867
|
|
|
1865
1868
|
// ../domain/src/environment.ts
|
|
1866
1869
|
import { z as z7 } from "zod";
|
|
1867
|
-
var environmentHolderSchema = z7.
|
|
1870
|
+
var environmentHolderSchema = z7.union([
|
|
1871
|
+
z7.literal("user"),
|
|
1872
|
+
z7.templateLiteral(["plugin:", pluginIdSchema])
|
|
1873
|
+
]);
|
|
1868
1874
|
var environmentMachineSelectionSchema = z7.discriminatedUnion("type", [
|
|
1869
1875
|
z7.object({ type: z7.literal("existing"), hostId: z7.string().min(1) }),
|
|
1870
1876
|
z7.object({
|
|
@@ -1931,6 +1937,7 @@ var environmentSchema = z7.object({
|
|
|
1931
1937
|
projectId: z7.string(),
|
|
1932
1938
|
hostId: z7.string(),
|
|
1933
1939
|
path: z7.string().nullable(),
|
|
1940
|
+
additionalPaths: z7.array(z7.string()),
|
|
1934
1941
|
isGitRepo: z7.boolean(),
|
|
1935
1942
|
isWorktree: z7.boolean(),
|
|
1936
1943
|
branchName: z7.string().nullable(),
|
|
@@ -2245,6 +2252,7 @@ var threadWithRuntimeSchema = threadSchema.extend({
|
|
|
2245
2252
|
var threadQueuedWorkValues = ["none", "waiting", "failed"];
|
|
2246
2253
|
var threadQueuedWorkSchema = z17.enum(threadQueuedWorkValues);
|
|
2247
2254
|
var threadListEntrySchema = threadWithRuntimeSchema.extend({
|
|
2255
|
+
statusChangedAt: z17.number(),
|
|
2248
2256
|
activity: threadActivityStateSchema,
|
|
2249
2257
|
queuedWork: threadQueuedWorkSchema,
|
|
2250
2258
|
pinSortKey: z17.string().nullable(),
|
|
@@ -2427,6 +2435,7 @@ var threadStatusChangeMetadataSchema = z18.object({
|
|
|
2427
2435
|
runtime: threadRuntimeStateSchema,
|
|
2428
2436
|
activity: threadActivityStateSchema,
|
|
2429
2437
|
latestAttentionAt: z18.number(),
|
|
2438
|
+
statusChangedAt: z18.number(),
|
|
2430
2439
|
updatedAt: z18.number()
|
|
2431
2440
|
}).strict();
|
|
2432
2441
|
var threadChangeMetadataSchema = z18.object({
|
|
@@ -2930,6 +2939,54 @@ import {
|
|
|
2930
2939
|
} from "react";
|
|
2931
2940
|
import { act, render } from "@testing-library/react";
|
|
2932
2941
|
|
|
2942
|
+
// src/testing/navigation-hrefs.ts
|
|
2943
|
+
var SETTINGS_SECTIONS = {
|
|
2944
|
+
general: true,
|
|
2945
|
+
providers: true,
|
|
2946
|
+
"ai-services": true,
|
|
2947
|
+
appearance: true,
|
|
2948
|
+
keyboard: true,
|
|
2949
|
+
browser: true,
|
|
2950
|
+
files: true,
|
|
2951
|
+
projects: true,
|
|
2952
|
+
machines: true,
|
|
2953
|
+
mobile: true,
|
|
2954
|
+
"environment-variables": true,
|
|
2955
|
+
updates: true,
|
|
2956
|
+
plugins: true,
|
|
2957
|
+
marketplaces: true,
|
|
2958
|
+
experiments: true,
|
|
2959
|
+
community: true,
|
|
2960
|
+
archived: true
|
|
2961
|
+
};
|
|
2962
|
+
function assertTestSettingsTarget(target) {
|
|
2963
|
+
if (target !== void 0 && !Object.hasOwn(SETTINGS_SECTIONS, target.section)) {
|
|
2964
|
+
throw new RangeError(
|
|
2965
|
+
`Unknown settings section "${String(target.section)}"`
|
|
2966
|
+
);
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
function assertTestMessageSeq(messageSeq) {
|
|
2970
|
+
if (messageSeq !== void 0 && (!Number.isSafeInteger(messageSeq) || messageSeq < 0)) {
|
|
2971
|
+
throw new RangeError(
|
|
2972
|
+
`messageSeq must be a non-negative integer, got ${messageSeq}`
|
|
2973
|
+
);
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
function testThreadHref(threadId, options) {
|
|
2977
|
+
const messageSeq = options?.messageSeq;
|
|
2978
|
+
assertTestMessageSeq(messageSeq);
|
|
2979
|
+
const path = `/threads/${threadId}`;
|
|
2980
|
+
return messageSeq === void 0 ? path : `${path}#msg=${messageSeq}`;
|
|
2981
|
+
}
|
|
2982
|
+
function testSettingsHref(target, pluginId) {
|
|
2983
|
+
assertTestSettingsTarget(target);
|
|
2984
|
+
if (target === void 0) {
|
|
2985
|
+
return `/settings/plugins/${encodeURIComponent(pluginId)}`;
|
|
2986
|
+
}
|
|
2987
|
+
return target.section === "general" ? "/settings" : `/settings/${target.section}`;
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2933
2990
|
// src/internal/composer-view.ts
|
|
2934
2991
|
function isComposerDraftEmpty(text, attachmentCount) {
|
|
2935
2992
|
return text.trim().length === 0 && attachmentCount === 0;
|
|
@@ -3150,7 +3207,7 @@ function validProviderId(provider) {
|
|
|
3150
3207
|
const trimmed = provider.trim();
|
|
3151
3208
|
return trimmed.length === 0 || trimmed.includes(":") ? null : trimmed;
|
|
3152
3209
|
}
|
|
3153
|
-
function
|
|
3210
|
+
function composerDraftFromInsertParts(parts, context) {
|
|
3154
3211
|
const list = Array.isArray(parts) ? parts : [parts];
|
|
3155
3212
|
let text = "";
|
|
3156
3213
|
const mentions = [];
|
|
@@ -3163,22 +3220,30 @@ function insertValue(parts, controller) {
|
|
|
3163
3220
|
if ("kind" in part) {
|
|
3164
3221
|
mention = part;
|
|
3165
3222
|
} else {
|
|
3223
|
+
if (context.pluginId === null) {
|
|
3224
|
+
throw new Error(
|
|
3225
|
+
`Mention "${part.label}" has no kind and no plugin to resolve it.`
|
|
3226
|
+
);
|
|
3227
|
+
}
|
|
3166
3228
|
const provider = validProviderId(part.provider);
|
|
3167
3229
|
if (provider === null) {
|
|
3168
3230
|
throw new Error(`Invalid mention provider id "${part.provider}".`);
|
|
3169
3231
|
}
|
|
3232
|
+
if (part.id.length === 0) {
|
|
3233
|
+
throw new Error(`Mention "${part.label}" has an empty id.`);
|
|
3234
|
+
}
|
|
3170
3235
|
mention = {
|
|
3171
3236
|
from: 0,
|
|
3172
3237
|
to: 0,
|
|
3173
3238
|
label: part.label.trim() || part.id,
|
|
3174
3239
|
kind: "plugin",
|
|
3175
|
-
pluginId:
|
|
3240
|
+
pluginId: context.pluginId,
|
|
3176
3241
|
provider,
|
|
3177
3242
|
id: part.id,
|
|
3178
3243
|
icon: null
|
|
3179
3244
|
};
|
|
3180
3245
|
}
|
|
3181
|
-
const serialized =
|
|
3246
|
+
const serialized = context.mentionText(mention);
|
|
3182
3247
|
mentions.push({
|
|
3183
3248
|
...mention,
|
|
3184
3249
|
from: text.length,
|
|
@@ -3283,7 +3348,7 @@ function createComposerHandleBinding(key, initial) {
|
|
|
3283
3348
|
};
|
|
3284
3349
|
const insert = (parts, options = {}) => {
|
|
3285
3350
|
requireAvailable();
|
|
3286
|
-
const value =
|
|
3351
|
+
const value = composerDraftFromInsertParts(parts, controller);
|
|
3287
3352
|
const block = options.block === true;
|
|
3288
3353
|
if ((options.at ?? "cursor") === "cursor") {
|
|
3289
3354
|
if (!target().insertAtCursor(value, block)) {
|
|
@@ -4189,6 +4254,7 @@ function readLegacyCardSectionTitle(kind, registration, onWarning) {
|
|
|
4189
4254
|
);
|
|
4190
4255
|
return title;
|
|
4191
4256
|
}
|
|
4257
|
+
var BARE_KEY_SHORTCUT_MESSAGE = 'Use Command, Control, or Alt with a key, or a function key; bare keys need experimental_keyScope: "pluginPage"';
|
|
4192
4258
|
function createCommandShortcutSchema() {
|
|
4193
4259
|
return z22.object({
|
|
4194
4260
|
key: z22.string().min(1).max(32).refine(
|
|
@@ -4207,10 +4273,10 @@ function createCommandShortcutSchema() {
|
|
|
4207
4273
|
control: z22.boolean().default(false),
|
|
4208
4274
|
alt: z22.boolean().default(false),
|
|
4209
4275
|
shift: z22.boolean().default(false)
|
|
4210
|
-
}).strict()
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
);
|
|
4276
|
+
}).strict();
|
|
4277
|
+
}
|
|
4278
|
+
function isBareKeyShortcut(shortcut) {
|
|
4279
|
+
return !(shortcut.mod || shortcut.meta || shortcut.control || shortcut.alt || /^F(?:[1-9]|1[0-9]|2[0-4])$/u.test(shortcut.key));
|
|
4214
4280
|
}
|
|
4215
4281
|
var MESSAGE_ACTION_SURFACES = [
|
|
4216
4282
|
"thread-view",
|
|
@@ -4408,27 +4474,38 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
4408
4474
|
};
|
|
4409
4475
|
collected.tabs.push(validated);
|
|
4410
4476
|
}
|
|
4411
|
-
function collectCommand(kind, registration) {
|
|
4477
|
+
function collectCommand(kind, registration, keyScope) {
|
|
4412
4478
|
const id = requireSlotId(kind, registration?.id);
|
|
4413
4479
|
requireUniqueId(kind, seenIds.command, id);
|
|
4414
4480
|
if (typeof registration.run !== "function") {
|
|
4415
4481
|
throw new Error(`${kind}: "run" must be a function`);
|
|
4416
4482
|
}
|
|
4483
|
+
const defaultShortcut = registration.defaultShortcut === void 0 ? null : commandShortcutSchema.parse(registration.defaultShortcut);
|
|
4484
|
+
if (defaultShortcut !== null && keyScope !== "pluginPage" && isBareKeyShortcut(defaultShortcut)) {
|
|
4485
|
+
throw new Error(`${kind}: ${BARE_KEY_SHORTCUT_MESSAGE}`);
|
|
4486
|
+
}
|
|
4417
4487
|
return {
|
|
4418
4488
|
id,
|
|
4419
|
-
defaultShortcut
|
|
4489
|
+
defaultShortcut,
|
|
4420
4490
|
title: requireNonEmptyString(kind, "title", registration.title)
|
|
4421
4491
|
};
|
|
4422
4492
|
}
|
|
4423
4493
|
function registerCommand(registration) {
|
|
4424
4494
|
const kind = "commands.register";
|
|
4425
|
-
const
|
|
4495
|
+
const keyScope = registration?.experimental_keyScope;
|
|
4496
|
+
if (keyScope !== void 0 && keyScope !== "pluginPage") {
|
|
4497
|
+
throw new Error(
|
|
4498
|
+
`${kind}: "experimental_keyScope" must be "pluginPage" or omitted`
|
|
4499
|
+
);
|
|
4500
|
+
}
|
|
4501
|
+
const command = collectCommand(kind, registration, keyScope);
|
|
4426
4502
|
if (registration.isAvailable !== void 0 && typeof registration.isAvailable !== "function") {
|
|
4427
4503
|
throw new Error(`${kind}: "isAvailable" must be a function`);
|
|
4428
4504
|
}
|
|
4429
4505
|
collected.commandPaletteActions.push({
|
|
4430
4506
|
target: "app",
|
|
4431
4507
|
...command,
|
|
4508
|
+
...keyScope !== void 0 ? { experimental_keyScope: keyScope } : {},
|
|
4432
4509
|
...registration.isAvailable !== void 0 ? { isAvailable: registration.isAvailable } : {},
|
|
4433
4510
|
run: registration.run
|
|
4434
4511
|
});
|
|
@@ -4436,7 +4513,11 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
4436
4513
|
function registerComposerCommand(registration) {
|
|
4437
4514
|
collected.commandPaletteActions.push({
|
|
4438
4515
|
target: "composer",
|
|
4439
|
-
...collectCommand(
|
|
4516
|
+
...collectCommand(
|
|
4517
|
+
"composer.experimental_registerCommand",
|
|
4518
|
+
registration,
|
|
4519
|
+
void 0
|
|
4520
|
+
),
|
|
4440
4521
|
run: registration.run
|
|
4441
4522
|
});
|
|
4442
4523
|
}
|
|
@@ -5573,7 +5654,12 @@ function TestNewThreadComposer({
|
|
|
5573
5654
|
draftKey,
|
|
5574
5655
|
onSubmit
|
|
5575
5656
|
}) {
|
|
5576
|
-
const [text, setText] = useState3(
|
|
5657
|
+
const [text, setText] = useState3(
|
|
5658
|
+
() => typeof initialPrompt === "string" || initialPrompt === void 0 ? initialPrompt ?? "" : composerDraftFromInsertParts(initialPrompt, {
|
|
5659
|
+
pluginId: "test-plugin",
|
|
5660
|
+
mentionText: testComposerMentionText
|
|
5661
|
+
}).text
|
|
5662
|
+
);
|
|
5577
5663
|
return /* @__PURE__ */ jsxs(
|
|
5578
5664
|
"div",
|
|
5579
5665
|
{
|
|
@@ -6069,6 +6155,7 @@ function TestInfoListRow({
|
|
|
6069
6155
|
] });
|
|
6070
6156
|
}
|
|
6071
6157
|
var activeClipboard = null;
|
|
6158
|
+
var activeErrorToasts = null;
|
|
6072
6159
|
var loadingWithServers = false;
|
|
6073
6160
|
function captureClipboardWrites(result) {
|
|
6074
6161
|
const writes = [];
|
|
@@ -6078,6 +6165,11 @@ function captureClipboardWrites(result) {
|
|
|
6078
6165
|
};
|
|
6079
6166
|
return writes;
|
|
6080
6167
|
}
|
|
6168
|
+
function captureErrorToasts() {
|
|
6169
|
+
const toasts = [];
|
|
6170
|
+
activeErrorToasts = toasts;
|
|
6171
|
+
return toasts;
|
|
6172
|
+
}
|
|
6081
6173
|
var testPluginSdkApp = {
|
|
6082
6174
|
experimental_getApplicationLinkApprovals: async () => [],
|
|
6083
6175
|
experimental_revokeApplicationLinkApproval: async (_scheme) => [],
|
|
@@ -6222,6 +6314,9 @@ var testPluginSdkApp = {
|
|
|
6222
6314
|
experimental_VoiceRecordingBar: TestVoiceRecordingBar,
|
|
6223
6315
|
experimental_FailedVoiceRecordings: TestFailedVoiceRecordings,
|
|
6224
6316
|
experimental_ShortcutHint: TestShortcutHint,
|
|
6317
|
+
experimental_useCommandShortcut(commandId) {
|
|
6318
|
+
return useSlotEnv("experimental_useCommandShortcut").commandShortcuts[commandId] ?? null;
|
|
6319
|
+
},
|
|
6225
6320
|
experimental_matchesShortcutKey: matchesAppShortcutKey,
|
|
6226
6321
|
experimental_sliceUtf16Head: sliceUtf16Head,
|
|
6227
6322
|
experimental_ImageLightbox: TestImageLightbox,
|
|
@@ -6285,6 +6380,9 @@ var testPluginSdkApp = {
|
|
|
6285
6380
|
experimental_copyToClipboard(content) {
|
|
6286
6381
|
return activeClipboard?.(content) ?? Promise.resolve(true);
|
|
6287
6382
|
},
|
|
6383
|
+
experimental_showErrorToast(options) {
|
|
6384
|
+
activeErrorToasts?.push({ ...options });
|
|
6385
|
+
},
|
|
6288
6386
|
experimental_saveFile() {
|
|
6289
6387
|
return Promise.resolve("started");
|
|
6290
6388
|
},
|
|
@@ -6494,6 +6592,7 @@ async function mountPluginContentScripts(app, options) {
|
|
|
6494
6592
|
const experimental_clipboardWrites = captureClipboardWrites(
|
|
6495
6593
|
options.experimental_copyToClipboard
|
|
6496
6594
|
);
|
|
6595
|
+
const experimental_errorToasts = captureErrorToasts();
|
|
6497
6596
|
let disposed = false;
|
|
6498
6597
|
const setThreadRowStatus = (threadId, status) => {
|
|
6499
6598
|
if (controller.signal.aborted) return;
|
|
@@ -6574,7 +6673,8 @@ async function mountPluginContentScripts(app, options) {
|
|
|
6574
6673
|
const status = threadRowStatuses.get(threadId);
|
|
6575
6674
|
return status === void 0 ? null : { ...status };
|
|
6576
6675
|
},
|
|
6577
|
-
experimental_clipboardWrites
|
|
6676
|
+
experimental_clipboardWrites,
|
|
6677
|
+
experimental_errorToasts
|
|
6578
6678
|
},
|
|
6579
6679
|
lifecycle: { dispose }
|
|
6580
6680
|
};
|
|
@@ -6911,6 +7011,7 @@ function renderSlot(registration, props, options = {}) {
|
|
|
6911
7011
|
const experimental_clipboardWrites = captureClipboardWrites(
|
|
6912
7012
|
options.experimental_copyToClipboard
|
|
6913
7013
|
);
|
|
7014
|
+
const experimental_errorToasts = captureErrorToasts();
|
|
6914
7015
|
const sidebarActions = {
|
|
6915
7016
|
open(threadId2, openOptions) {
|
|
6916
7017
|
sidebarActionCalls.push({
|
|
@@ -6949,6 +7050,7 @@ function renderSlot(registration, props, options = {}) {
|
|
|
6949
7050
|
};
|
|
6950
7051
|
const navigate = {
|
|
6951
7052
|
toThread(threadId2, threadOptions) {
|
|
7053
|
+
assertTestMessageSeq(threadOptions?.messageSeq);
|
|
6952
7054
|
navigateCalls.push({
|
|
6953
7055
|
method: "toThread",
|
|
6954
7056
|
threadId: threadId2,
|
|
@@ -7006,11 +7108,29 @@ function renderSlot(registration, props, options = {}) {
|
|
|
7006
7108
|
options: terminalOptions
|
|
7007
7109
|
});
|
|
7008
7110
|
return options.openTerminal?.(terminalOptions) ?? false;
|
|
7111
|
+
},
|
|
7112
|
+
experimental_toSettings(target) {
|
|
7113
|
+
assertTestSettingsTarget(target);
|
|
7114
|
+
navigateCalls.push({
|
|
7115
|
+
method: "experimental_toSettings",
|
|
7116
|
+
...target !== void 0 ? { target } : {}
|
|
7117
|
+
});
|
|
7118
|
+
},
|
|
7119
|
+
experimental_threadHref(threadId2, hrefOptions) {
|
|
7120
|
+
return testThreadHref(threadId2, hrefOptions);
|
|
7121
|
+
},
|
|
7122
|
+
experimental_settingsHref(target) {
|
|
7123
|
+
return testSettingsHref(target, options.pluginId ?? "test-plugin");
|
|
7009
7124
|
}
|
|
7010
7125
|
};
|
|
7011
7126
|
const projectId = options.context?.projectId ?? null;
|
|
7012
7127
|
const threadId = options.context?.threadId ?? null;
|
|
7013
|
-
let composerScope = options.composer?.scope ?? (threadId !== null ? {
|
|
7128
|
+
let composerScope = options.composer?.scope ?? (threadId !== null ? {
|
|
7129
|
+
kind: "thread",
|
|
7130
|
+
threadId,
|
|
7131
|
+
projectId: projectId ?? "project-test",
|
|
7132
|
+
environmentId: null
|
|
7133
|
+
} : { kind: "new-thread", projectId });
|
|
7014
7134
|
let composerSelection = composerScope.kind === "queued-message" ? null : {
|
|
7015
7135
|
...composerScope.kind === "new-thread" && projectId !== null ? { projectId } : {},
|
|
7016
7136
|
...options.composer?.selection
|
|
@@ -7276,6 +7396,7 @@ ${block}
|
|
|
7276
7396
|
navigateCalls,
|
|
7277
7397
|
appPanel,
|
|
7278
7398
|
panelTabs: options.experimental_panelTabs ?? NO_PANEL_TABS,
|
|
7399
|
+
commandShortcuts: options.experimental_commandShortcuts ?? {},
|
|
7279
7400
|
fixedTabTarget,
|
|
7280
7401
|
composer,
|
|
7281
7402
|
composerLog,
|
|
@@ -7408,6 +7529,7 @@ ${block}
|
|
|
7408
7529
|
experimental_threadRequestCalls: threadRequestCalls,
|
|
7409
7530
|
sdkCalls,
|
|
7410
7531
|
experimental_clipboardWrites,
|
|
7532
|
+
experimental_errorToasts,
|
|
7411
7533
|
composer: composerLog,
|
|
7412
7534
|
behavior: {
|
|
7413
7535
|
experimental_invalidateRpc,
|
|
@@ -7430,6 +7552,7 @@ ${block}
|
|
|
7430
7552
|
experimental_threadRequestCalls: threadRequestCalls,
|
|
7431
7553
|
sdkCalls,
|
|
7432
7554
|
experimental_clipboardWrites,
|
|
7555
|
+
experimental_errorToasts,
|
|
7433
7556
|
composer: composerLog
|
|
7434
7557
|
},
|
|
7435
7558
|
get experimental_pageTitle() {
|