@pstdio/sdk 0.19.0 → 0.21.0

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.
@@ -13,9 +13,51 @@ var __export = (target, all) => {
13
13
  });
14
14
  };
15
15
 
16
+ // ../pstdio-api-contracts/src/extension-kernel/builtin-refs.ts
17
+ var hostRef = (kind, id) => ({ extensionId: "pstdio", kind, id });
18
+ var workbenchCommands = {
19
+ switchMode: hostRef("command", "workbench.action.switchMode")
20
+ };
21
+ var workbenchModes = {
22
+ project: hostRef("mode", "project"),
23
+ settings: hostRef("mode", "settings")
24
+ };
25
+ var hostResourceKind = (id, label, menuSlots) => ({
26
+ id,
27
+ ref: hostRef("resource-kind", id),
28
+ surface: "primary",
29
+ label,
30
+ menuSlots
31
+ });
32
+ var headerMenuSlots = [
33
+ { id: "headerPrimary", placement: "header-primary", access: "public" },
34
+ { id: "headerOverflow", placement: "header-overflow", access: "public" }
35
+ ];
36
+ var workbenchResourceKindDefinitions = {
37
+ project: hostResourceKind("project", "Extension", headerMenuSlots),
38
+ session: hostResourceKind("session", "Session", headerMenuSlots),
39
+ workspace: hostResourceKind("workspace", "Workspace", headerMenuSlots)
40
+ };
41
+ var workbenchResourceKinds = {
42
+ project: workbenchResourceKindDefinitions.project.ref,
43
+ session: workbenchResourceKindDefinitions.session.ref,
44
+ workspace: workbenchResourceKindDefinitions.workspace.ref
45
+ };
46
+ var workbenchSlots = {
47
+ projectNavigation: hostRef("navigation-item", "project.navigation"),
48
+ projectSettings: hostRef("settings-panel", "project.settings"),
49
+ statusBarLeading: hostRef("status-bar-item", "status-bar.leading"),
50
+ statusBarTrailing: hostRef("status-bar-item", "status-bar.trailing")
51
+ };
16
52
  // ../pstdio-api-contracts/src/extension-kernel/refs.ts
17
- var commandRef = (id) => ({ id });
18
- var eventRef = (id) => ({ id });
53
+ var createCommandRef = (input) => ({ ...input, kind: "command" });
54
+ var commandRef = Object.assign(createCommandRef, {
55
+ forExtension: (owner) => (id) => createCommandRef({ extensionId: `${owner.publisher}.${owner.name}`, id })
56
+ });
57
+ var eventRef = (input) => ({
58
+ ...input,
59
+ kind: "event"
60
+ });
19
61
 
20
62
  // ../pstdio-api-contracts/src/extension-kernel/slots.ts
21
63
  var defineSlot = (id, options) => ({
@@ -27,48 +69,49 @@ var defineSlot = (id, options) => ({
27
69
  });
28
70
 
29
71
  // ../pstdio-api-contracts/src/extension-kernel/kernel-slots.ts
72
+ var hostEventRef = (id) => eventRef({ extensionId: "pstdio", id });
73
+ var resourceMenuSlotRef = (resourceKind, id) => defineSlot(`${resourceKind.id}.${id}`, { kind: "menu" });
30
74
  var projectSlots = {
31
75
  sidenav: defineSlot("project.sidenav", { kind: "panel" }),
32
- headerPrimary: defineSlot("project.headerPrimary", { kind: "menu" }),
33
- headerOverflow: defineSlot("project.headerOverflow", { kind: "menu" }),
76
+ headerPrimary: resourceMenuSlotRef(workbenchResourceKinds.project, "headerPrimary"),
77
+ headerOverflow: resourceMenuSlotRef(workbenchResourceKinds.project, "headerOverflow"),
34
78
  settingsPanels: defineSlot("project.settingsPanels", { kind: "settings" })
35
79
  };
36
80
  var sessionSlots = {
37
- headerPrimary: defineSlot("session.headerPrimary", { kind: "menu" }),
38
- headerOverflow: defineSlot("session.headerOverflow", { kind: "menu" }),
39
- transcriptActions: defineSlot("session.transcriptActions", { kind: "menu" })
81
+ headerPrimary: resourceMenuSlotRef(workbenchResourceKinds.session, "headerPrimary"),
82
+ headerOverflow: resourceMenuSlotRef(workbenchResourceKinds.session, "headerOverflow")
40
83
  };
41
84
  var workspaceSlots = {
42
- headerPrimary: defineSlot("workspace.headerPrimary", { kind: "menu" }),
43
- headerOverflow: defineSlot("workspace.headerOverflow", { kind: "menu" }),
85
+ headerPrimary: resourceMenuSlotRef(workbenchResourceKinds.workspace, "headerPrimary"),
86
+ headerOverflow: resourceMenuSlotRef(workbenchResourceKinds.workspace, "headerOverflow"),
44
87
  sidenav: defineSlot("workspace.sidenav", { kind: "panel" })
45
88
  };
46
89
  var projectEvents = {
47
- opened: eventRef("project.opened")
90
+ opened: hostEventRef("project.opened")
48
91
  };
49
92
  var sessionEvents = {
50
- started: eventRef("session.started"),
51
- resumed: eventRef("session.resumed"),
52
- awaitingInput: eventRef("session.awaitingInput"),
53
- succeeded: eventRef("session.succeeded"),
54
- failed: eventRef("session.failed"),
55
- completed: eventRef("session.completed")
93
+ started: hostEventRef("session.started"),
94
+ resumed: hostEventRef("session.resumed"),
95
+ awaitingInput: hostEventRef("session.awaitingInput"),
96
+ succeeded: hostEventRef("session.succeeded"),
97
+ failed: hostEventRef("session.failed"),
98
+ completed: hostEventRef("session.completed")
56
99
  };
57
100
  var workspaceEvents = {
58
- created: eventRef("workspace.created"),
59
- provision: eventRef("workspace.provision"),
60
- ready: eventRef("workspace.ready"),
61
- archived: eventRef("workspace.archived"),
62
- deleted: eventRef("workspace.deleted")
101
+ created: hostEventRef("workspace.created"),
102
+ provision: hostEventRef("workspace.provision"),
103
+ ready: hostEventRef("workspace.ready"),
104
+ archived: hostEventRef("workspace.archived"),
105
+ deleted: hostEventRef("workspace.deleted")
63
106
  };
64
107
  var worktreeEvents = {
65
- removed: eventRef("worktree.removed")
108
+ removed: hostEventRef("worktree.removed")
66
109
  };
67
110
  var gitEvents = {
68
- committed: eventRef("git.committed"),
69
- rebased: eventRef("git.rebased"),
70
- merged: eventRef("git.merged"),
71
- conflicted: eventRef("git.conflicted")
111
+ committed: hostEventRef("git.committed"),
112
+ rebased: hostEventRef("git.rebased"),
113
+ merged: hostEventRef("git.merged"),
114
+ conflicted: hostEventRef("git.conflicted")
72
115
  };
73
116
  // ../pstdio-api-contracts/src/extension-kernel/l10n.ts
74
117
  var l10n = (key, defaultValue) => ({
@@ -85,7 +128,7 @@ var packageAsset = (path, baseUrl) => ({
85
128
  // ../pstdio-api-contracts/src/extension-kernel/types/composition.ts
86
129
  var dockedWorkbenchRegions = ["sidenav", "main", "secondary", "side"];
87
130
  // ../pstdio-api-contracts/src/extension-kernel/types/extension.ts
88
- var EXTENSION_API_VERSION = "1.0.0-alpha.2";
131
+ var EXTENSION_API_VERSION = "1.0.0-alpha.5";
89
132
  // ../pstdio-api-contracts/src/extension-kernel/types/webview-capabilities.ts
90
133
  var WEBVIEW_HOST_CAPABILITY_VERSION = 1;
91
134
  var WEBVIEW_DECLARABLE_CAPABILITIES = [
@@ -111,90 +154,6 @@ var WEBVIEW_HOST_CAPABILITIES = [
111
154
  ...WEBVIEW_DECLARABLE_CAPABILITIES,
112
155
  ...ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES
113
156
  ];
114
- // ../pstdio-api-contracts/src/extension-kernel/workbench-targets.ts
115
- var workbenchMenuTargets = ["workbench.nav.actions", "workbench.nav.overflow"];
116
- var workbenchTreeTargets = [
117
- "workbench.left.tree",
118
- "workbench.main.left.tree",
119
- "workbench.main.right.tree"
120
- ];
121
- var workbenchRegions = [
122
- "nav",
123
- "activity",
124
- "sidenav-header",
125
- "sidenav",
126
- "main-header",
127
- "main",
128
- "secondary-header",
129
- "secondary",
130
- "side-header",
131
- "side",
132
- "status",
133
- "overlay"
134
- ];
135
- var workbenchViewTargets = [
136
- "workbench.main",
137
- "workbench.main.left",
138
- "workbench.main.right",
139
- "workbench.secondary"
140
- ];
141
- var workbenchSettingsTargets = ["workbench.settings"];
142
- var workbenchSettingsScopes = ["project", "global"];
143
- var workbenchModePanels = ["main", "secondary", "side"];
144
- var workbenchModeLayoutTargets = [
145
- "workbench.left",
146
- "workbench.main.left",
147
- "workbench.main",
148
- "workbench.main.right",
149
- "workbench.secondary"
150
- ];
151
- var workbenchModeLayoutTargetPanels = {
152
- "workbench.left": undefined,
153
- "workbench.main.left": "main",
154
- "workbench.main": "main",
155
- "workbench.main.right": "main",
156
- "workbench.secondary": "secondary"
157
- };
158
- var getWorkbenchModeLayoutTargetPanel = (target) => workbenchModeLayoutTargetPanels[target];
159
- var workbenchTargets = [
160
- {
161
- id: "workbench.nav.actions",
162
- allowedKinds: ["menu"],
163
- granularity: "surface",
164
- rationale: "Primary command surface in the host-owned nav (top) workbench chrome."
165
- },
166
- {
167
- id: "workbench.nav.overflow",
168
- allowedKinds: ["menu"],
169
- granularity: "surface",
170
- rationale: "Secondary command surface in the host-owned nav (top) workbench chrome."
171
- },
172
- {
173
- id: "workbench.left.tree",
174
- allowedKinds: ["treeItem"],
175
- granularity: "areaTree",
176
- rationale: "Tree entries for the active tree renderer mounted in the left area."
177
- },
178
- {
179
- id: "workbench.main.left.tree",
180
- allowedKinds: ["treeItem"],
181
- granularity: "areaTree",
182
- rationale: "Tree entries for the active tree renderer mounted in the main-left area."
183
- },
184
- {
185
- id: "workbench.main.right.tree",
186
- allowedKinds: ["treeItem"],
187
- granularity: "areaTree",
188
- rationale: "Tree entries for the active tree renderer mounted in the main-right area."
189
- },
190
- {
191
- id: "workbench.settings",
192
- allowedKinds: ["settings"],
193
- granularity: "surface",
194
- rationale: "Settings panel placement in host-owned settings navigation."
195
- }
196
- ];
197
- var getWorkbenchTargetDefinition = (id) => workbenchTargets.find((target) => target.id === id);
198
157
  // src/extensions/command-outcome.ts
199
158
  var unwrapCommandOutcome = (response, fallbackReason = "Command failed.") => {
200
159
  const { outcome } = response;
@@ -204,9 +163,55 @@ var unwrapCommandOutcome = (response, fallbackReason = "Command failed.") => {
204
163
  return outcome.value;
205
164
  };
206
165
  // src/extensions/define-command.ts
207
- var defineCommand = (definition) => definition;
208
- var defineMiddleware = (definition) => definition;
209
- var defineHook = (definition) => definition;
166
+ function defineCommand(definition) {
167
+ return { ...definition, ref: { kind: "command", id: definition.id } };
168
+ }
169
+ var defineMiddleware = (definition) => ({
170
+ ...definition,
171
+ ref: { kind: "middleware", id: definition.id }
172
+ });
173
+ var defineHook = (definition) => ({
174
+ ...definition,
175
+ ref: { kind: "hook", id: definition.id }
176
+ });
177
+ // src/extensions/define-contribution.ts
178
+ var defineContribution = (_kind) => (definition) => ({
179
+ ...definition,
180
+ ref: { kind: _kind, id: definition.id }
181
+ });
182
+ var defineView = defineContribution("view");
183
+ var defineViewMenu = defineContribution("view-menu");
184
+ var definePlacement = defineContribution("placement");
185
+ var defineResourceKind = defineContribution("resource-kind");
186
+ var resourceSlotRef = (resourceKind, id) => ({
187
+ resourceKind,
188
+ id
189
+ });
190
+ var resourceMenuSlotRef2 = (resourceKind, id) => defineSlot(`${resourceKind.id}.${id}`, { kind: "menu" });
191
+ var defineResourceView = defineContribution("resource-view");
192
+ var defineNavigationItem = defineContribution("navigation-item");
193
+ var defineMode = defineContribution("mode");
194
+ var defineStatusBarItem = defineContribution("status-bar-item");
195
+ var defineStatuses = defineContribution("status");
196
+ var defineSettingsPanel = defineContribution("settings-panel");
197
+ var defineActivityItem = defineContribution("activity-item");
198
+ var defineSettingsSection = defineContribution("settings-section");
199
+ var defineCommandPaletteResource = defineContribution("command-palette-resource");
200
+ var defineKeybinding = defineContribution("keybinding");
201
+ var defineSchedule = defineContribution("schedule");
202
+ var defineArtifactMount = defineContribution("artifact-mount");
203
+ var defineTemplateType = defineContribution("template-type");
204
+ var defineTemplate = defineContribution("template");
205
+ var defineSkill = defineContribution("skill");
206
+ var defineTheme = defineContribution("theme");
207
+ var defineFileIconTheme = defineContribution("file-icon-theme");
208
+ var defineWorkspaceType = defineContribution("workspace-type");
209
+ var defineHarness = defineContribution("harness");
210
+ var defineConnection = defineContribution("connection");
211
+ var defineResourceHierarchyProvider = (definition) => ({
212
+ ...definition,
213
+ ref: { kind: "resource-hierarchy-provider", id: definition.id }
214
+ });
210
215
  // src/extensions/define-extension.ts
211
216
  var defineExtension = (extension) => extension;
212
217
  // src/extensions/define-extension-view.ts
@@ -288,21 +293,14 @@ var params = {
288
293
  }),
289
294
  repo: (options) => ({ type: "repo", ...options }),
290
295
  harness: (options) => ({ type: "harness", ...options }),
291
- template: (options) => ({
292
- label: options.label,
293
- description: options.description,
294
- required: options.required,
295
- defaultValue: options.defaultValue,
296
- metadata: options.metadata,
297
- type: "template",
298
- templateType: options.type
299
- }),
300
296
  resource: (options) => ({ type: "resource", ...options }),
301
297
  json: (options) => ({ type: "json", ...options }),
302
298
  list: (options) => ({ type: "list", ...options })
303
299
  };
304
300
  // src/extensions/refs.ts
305
301
  var commandEvent = (command, phase) => ({
302
+ ...command.extensionId ? { extensionId: command.extensionId } : {},
303
+ kind: "event",
306
304
  id: `command.${phase}:${command.id}`
307
305
  });
308
306
  // src/extensions/terminal-session-bridge.ts
@@ -377,28 +375,56 @@ var createTerminalSessionBridge = (host) => ({
377
375
  };
378
376
  }
379
377
  });
378
+ // src/extensions/webview-client.ts
379
+ var createWebviewClient = (host, options) => {
380
+ const extensionId = options?.extensionId ?? host.extensionId;
381
+ if (!extensionId) {
382
+ throw new Error("The host bridge did not provide an extension id. Pass { extensionId } to createWebviewClient.");
383
+ }
384
+ const runCommand = async (commandKey, params2) => {
385
+ const response = await host.call("commands.execute", {
386
+ commandId: `${extensionId}.command.${commandKey}`,
387
+ params: params2
388
+ });
389
+ return unwrapCommandOutcome(response);
390
+ };
391
+ const commands = new Proxy({}, {
392
+ get: (_target, commandKey) => {
393
+ if (typeof commandKey !== "string")
394
+ return;
395
+ return (params2) => runCommand(commandKey, params2);
396
+ }
397
+ });
398
+ const settings = {
399
+ all: async () => await host.call("extension.settings.all", {}) ?? {},
400
+ get: (key) => host.call("extension.settings.get", { key }),
401
+ set: async (key, value) => {
402
+ await host.call("extension.settings.set", { key, value });
403
+ }
404
+ };
405
+ return { commands, settings };
406
+ };
380
407
  // src/extensions/when.ts
381
408
  var matchesResourceWhen = (when, resourceType) => {
382
409
  const resourceTypes = when?.resourceType;
383
410
  if (!resourceTypes?.length)
384
411
  return true;
385
- return resourceType ? resourceTypes.includes(resourceType) : false;
412
+ return resourceType ? resourceTypes.some((candidate) => (typeof candidate === "string" ? candidate : candidate.id) === resourceType) : false;
386
413
  };
387
414
  export {
388
415
  worktreeEvents,
389
416
  workspaceSlots,
390
417
  workspaceEvents,
391
- workbenchViewTargets,
392
- workbenchTreeTargets,
393
- workbenchTargets,
394
- workbenchSettingsTargets,
395
- workbenchSettingsScopes,
396
- workbenchModePanels,
397
- workbenchModeLayoutTargets,
398
- workbenchMenuTargets,
418
+ workbenchSlots,
419
+ workbenchResourceKinds,
420
+ workbenchResourceKindDefinitions,
421
+ workbenchModes,
422
+ workbenchCommands,
399
423
  unwrapCommandOutcome,
400
424
  sessionSlots,
401
425
  sessionEvents,
426
+ resourceSlotRef,
427
+ resourceMenuSlotRef2 as resourceMenuSlotRef,
402
428
  projectSlots,
403
429
  projectEvents,
404
430
  params,
@@ -407,15 +433,40 @@ export {
407
433
  l10n,
408
434
  isLocalizedString,
409
435
  gitEvents,
410
- getWorkbenchTargetDefinition,
411
- getWorkbenchModeLayoutTargetPanel,
412
436
  eventRef,
413
437
  dockedWorkbenchRegions,
438
+ defineWorkspaceType,
439
+ defineViewMenu,
440
+ defineView,
441
+ defineTheme,
442
+ defineTemplateType,
443
+ defineTemplate,
444
+ defineStatuses,
445
+ defineStatusBarItem,
446
+ defineSlot,
447
+ defineSkill,
448
+ defineSettingsSection,
449
+ defineSettingsPanel,
450
+ defineSchedule,
451
+ defineResourceView,
452
+ defineResourceKind,
453
+ defineResourceHierarchyProvider,
454
+ definePlacement,
455
+ defineNavigationItem,
456
+ defineMode,
414
457
  defineMiddleware,
458
+ defineKeybinding,
415
459
  defineHook,
460
+ defineHarness,
461
+ defineFileIconTheme,
416
462
  defineExtensionView,
417
463
  defineExtension,
464
+ defineConnection,
465
+ defineCommandPaletteResource,
418
466
  defineCommand,
467
+ defineArtifactMount,
468
+ defineActivityItem,
469
+ createWebviewClient,
419
470
  createTerminalSessionBridge,
420
471
  commandRef,
421
472
  commandEvent,
@@ -1,4 +1,4 @@
1
- import type { BooleanParam, FilesParam, HarnessParam, JsonParam, ListParam, LongTextParam, MarkdownParam, MultiSelectParam, NumberParam, RepoParam, ResourceParam, SelectParam, TemplateParam, TextParam } from "pstdio-api-contracts/extension-kernel";
1
+ import type { BooleanParam, FilesParam, HarnessParam, JsonParam, ListParam, LongTextParam, MarkdownParam, MultiSelectParam, NumberParam, RepoParam, ResourceParam, SelectParam, TextParam } from "pstdio-api-contracts/extension-kernel";
2
2
  type RequiredOf<TOptions> = TOptions extends {
3
3
  required: infer TRequired extends boolean;
4
4
  } ? TRequired : undefined;
@@ -26,9 +26,6 @@ export declare const params: {
26
26
  multiSelect: <const TOptions extends ParamOptions<MultiSelectParam>>(options: TOptions) => MultiSelectParam<RequiredOf<TOptions>>;
27
27
  repo: <const TOptions extends ParamOptions<RepoParam> | undefined = undefined>(options?: TOptions) => RepoParam<RequiredOf<TOptions>>;
28
28
  harness: <const TOptions extends ParamOptions<HarnessParam> | undefined = undefined>(options?: TOptions) => HarnessParam<RequiredOf<TOptions>>;
29
- template: <const TOptions extends Omit<TemplateParam, "type" | "templateType"> & {
30
- type: string;
31
- }>(options: TOptions) => TemplateParam<RequiredOf<TOptions>>;
32
29
  resource: <const TOptions extends ParamOptions<ResourceParam>>(options: TOptions) => ResourceParam<RequiredOf<TOptions>>;
33
30
  json: <T = unknown, const TOptions extends ParamOptions<JsonParam<T>> | undefined = undefined>(options?: TOptions) => JsonParam<T, RequiredOf<TOptions>>;
34
31
  list: <const TOptions extends ParamOptions<ListParam> | undefined = undefined>(options?: TOptions) => ListParam<RequiredOf<TOptions>>;
@@ -0,0 +1,16 @@
1
+ import { type QueryKey } from "@tanstack/react-query";
2
+ interface CommandQueryInput<TResult> {
3
+ queryKey: QueryKey;
4
+ command: () => Promise<TResult>;
5
+ enabled?: boolean;
6
+ staleTime?: number;
7
+ }
8
+ /** Reads server state via a typed client command, cached and deduped by react-query. */
9
+ export declare const useCommandQuery: <TResult>(input: CommandQueryInput<TResult>) => import("@tanstack/react-query").UseQueryResult<import("@tanstack/react-query").NoInfer<TResult>, Error>;
10
+ interface CommandMutationInput<TParams, TResult> {
11
+ command: (params: TParams) => Promise<TResult>;
12
+ invalidate?: QueryKey[];
13
+ }
14
+ /** Writes server state via a typed client command and refreshes affected queries on success. */
15
+ export declare const useCommandMutation: <TParams, TResult>(input: CommandMutationInput<TParams, TResult>) => import("@tanstack/react-query").UseMutationResult<TResult, Error, TParams, unknown>;
16
+ export {};
@@ -0,0 +1,38 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __returnValue = (v) => v;
3
+ function __exportSetter(name, newValue) {
4
+ this[name] = __returnValue.bind(null, newValue);
5
+ }
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true,
11
+ configurable: true,
12
+ set: __exportSetter.bind(all, name)
13
+ });
14
+ };
15
+
16
+ // src/extensions/react/index.ts
17
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
18
+ var useCommandQuery = (input) => {
19
+ const { command, enabled, queryKey, staleTime } = input;
20
+ return useQuery({
21
+ queryKey,
22
+ enabled,
23
+ staleTime,
24
+ queryFn: () => command()
25
+ });
26
+ };
27
+ var useCommandMutation = (input) => {
28
+ const { command, invalidate } = input;
29
+ const queryClient = useQueryClient();
30
+ return useMutation({
31
+ mutationFn: (params) => command(params),
32
+ onSuccess: () => invalidate?.forEach((queryKey) => void queryClient.invalidateQueries({ queryKey }))
33
+ });
34
+ };
35
+ export {
36
+ useCommandQuery,
37
+ useCommandMutation
38
+ };
@@ -0,0 +1,41 @@
1
+ import type { CommandDefinition, ParamObjectSchema, ParamsOf } from "pstdio-api-contracts/extension-kernel";
2
+ import type { SettingsMap } from "./define-extension";
3
+ import type { GuestHost } from "./define-extension-view";
4
+ type CommandFn<TDefinition> = TDefinition extends CommandDefinition<infer TSchema, infer TResult, infer _TSettings> ? TSchema extends ParamObjectSchema ? Partial<ParamsOf<TSchema>> extends ParamsOf<TSchema> ? (params?: ParamsOf<TSchema>) => Promise<TResult> : (params: ParamsOf<TSchema>) => Promise<TResult> : () => Promise<TResult> : never;
5
+ export type WebviewCommandsClient<TCommands> = {
6
+ [K in keyof TCommands & string]: CommandFn<TCommands[K]>;
7
+ };
8
+ export type WebviewSettingsClient<TSettings> = {
9
+ all: () => Promise<Partial<TSettings>>;
10
+ get: <K extends keyof TSettings & string>(key: K) => Promise<TSettings[K] | undefined>;
11
+ set: <K extends keyof TSettings & string>(key: K, value: TSettings[K]) => Promise<void>;
12
+ };
13
+ type ClientSettingsMap<TSettings> = TSettings extends {
14
+ properties: unknown;
15
+ } ? SettingsMap<TSettings> : Record<never, never>;
16
+ export type WebviewClient<TCommands, TSettings = undefined> = {
17
+ commands: WebviewCommandsClient<TCommands>;
18
+ settings: WebviewSettingsClient<ClientSettingsMap<TSettings>>;
19
+ };
20
+ export interface WebviewClientOptions {
21
+ /** Overrides the extension id provided by the host bridge (e.g. in tests). */
22
+ extensionId?: string;
23
+ }
24
+ /**
25
+ * Typed guest-side client over the host bridge. Command params and results come from
26
+ * the extension's exported commands record (`defineCommand` values); settings come
27
+ * from its exported settings contribution. Command outcomes are unwrapped, so
28
+ * failures throw.
29
+ *
30
+ * Import both as types only, so no server code enters the webview bundle:
31
+ *
32
+ * @example
33
+ * import type { commands } from "../commands";
34
+ * import type { settings } from "../settings";
35
+ *
36
+ * const client = createWebviewClient<typeof commands, typeof settings>(host);
37
+ * const { statuses } = await client.commands["ticketStatus.read"]();
38
+ * const enabled = await client.settings.get("counter.enabled");
39
+ */
40
+ export declare const createWebviewClient: <TCommands extends object, TSettings = undefined>(host: GuestHost, options?: WebviewClientOptions) => WebviewClient<TCommands, TSettings>;
41
+ export {};
@@ -6,4 +6,6 @@ import type { WhenExpression } from "pstdio-api-contracts/extension-kernel";
6
6
  * resolve from the active resource alone (`mode`/`source`/`metadata` require execution context the
7
7
  * palette does not have).
8
8
  */
9
- export declare const matchesResourceWhen: (when: Pick<WhenExpression, "resourceType"> | undefined, resourceType: string | undefined) => boolean;
9
+ export declare const matchesResourceWhen: (when: Pick<WhenExpression, "resourceType"> | {
10
+ resourceType?: readonly string[];
11
+ } | undefined, resourceType: string | undefined) => boolean;
@@ -6,5 +6,4 @@ export type { Project } from "./project";
6
6
  export type { Session, SessionStatus } from "./session";
7
7
  export type { Settings } from "./settings";
8
8
  export type { Skill, SkillFile, SkillWithContent } from "./skill";
9
- export type { Template, TemplateType, TemplateWithContent } from "./template";
10
9
  export type { Workspace, WorkspaceListItem } from "./workspace";