@pstdio/sdk 0.11.0 → 0.12.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.
Files changed (35) hide show
  1. package/dist/api/index.d.ts +0 -1
  2. package/dist/client/agents.d.ts +2 -7
  3. package/dist/client/index.js +1 -6
  4. package/dist/extensions/command-outcome.d.ts +1 -1
  5. package/dist/extensions/define-command.d.ts +1 -3
  6. package/dist/extensions/define-extension-view.d.ts +2 -2
  7. package/dist/extensions/define-extension.d.ts +1 -4
  8. package/dist/extensions/index.d.ts +3 -8
  9. package/dist/extensions/index.js +131 -130
  10. package/dist/extensions/params.d.ts +1 -1
  11. package/dist/extensions/refs.d.ts +2 -14
  12. package/dist/extensions/when.d.ts +1 -1
  13. package/dist/resources/agent.d.ts +1 -1
  14. package/dist/resources/index.d.ts +2 -2
  15. package/dist/resources/index.js +3 -1
  16. package/dist/resources/known-agents.d.ts +2 -0
  17. package/package.json +2 -2
  18. package/dist/api/agents.d.ts +0 -1
  19. package/dist/extensions/kernel-slots.d.ts +0 -112
  20. package/dist/extensions/l10n.d.ts +0 -10
  21. package/dist/extensions/package-asset.d.ts +0 -10
  22. package/dist/extensions/slots.d.ts +0 -6
  23. package/dist/extensions/types/commands.d.ts +0 -125
  24. package/dist/extensions/types/context.d.ts +0 -258
  25. package/dist/extensions/types/contributions.d.ts +0 -374
  26. package/dist/extensions/types/events.d.ts +0 -10
  27. package/dist/extensions/types/extension.d.ts +0 -183
  28. package/dist/extensions/types/index.d.ts +0 -11
  29. package/dist/extensions/types/json.d.ts +0 -7
  30. package/dist/extensions/types/params.d.ts +0 -83
  31. package/dist/extensions/types/resources.d.ts +0 -25
  32. package/dist/extensions/types/slots.d.ts +0 -22
  33. package/dist/extensions/types/tree-renderer.d.ts +0 -89
  34. package/dist/extensions/types/webview-capabilities.d.ts +0 -93
  35. package/dist/extensions/workbench-targets.d.ts +0 -124
@@ -1,4 +1,3 @@
1
- export type { SetupAgentInput, SetupAvailableAgentsInput, UpdateAgentInput } from "./agents";
2
1
  export type { CommandExecuteRequest, CommandExecuteResponse, ExtensionCommandPaletteContribution, ExtensionCommandPaletteResourceRecord, ExtensionCommandRecord, ExtensionDataRendererRecord, ExtensionDiagnostic, ExtensionKeybindingRecord, ExtensionMenuContribution, ExtensionModeRecord, ExtensionNavigationRecord, ExtensionRecord, ExtensionRouteRecord, ExtensionSettingDefinitionRecord, ExtensionSettingsPanelRecord, ExtensionSettingValueRecord, ExtensionTreeItemContribution, ExtensionTreeRendererRecord, ExtensionViewRecord, ListExtensionAppearanceResponse, ListExtensionCommandsResponse, ListExtensionSettingsResponse, ListProjectExtensionsResponse, LocalizableString, ProjectExtensionInstance, UpdateExtensionSettingRequest, UpdateInstalledExtensionTemplateInput, UpdateInstalledExtensionTemplateResponse, WorkbenchExtensionCommandPaletteResourceRecord, WorkbenchExtensionDataRendererRecord, WorkbenchExtensionMetadata, WorkbenchExtensionTreeRendererRecord, } from "./extensions";
3
2
  export type { CreateProjectInput, RegisterRepoInput } from "./projects";
4
3
  export type { ApprovalInput, CreateSessionInput, FollowUpInput, ResolveSessionIdInput, ResolveSessionIdResponse, SessionConversationResponse, } from "./sessions";
@@ -1,13 +1,8 @@
1
- import type { AgentModel, SetupAgentInput, SetupAvailableAgentsInput, UpdateAgentInput } from "pstdio-api-contracts";
2
- import type { AgentConfig, AgentInfo } from "../resources";
1
+ import type { AgentModel } from "pstdio-api-contracts";
2
+ import type { AgentInfo } from "../resources";
3
3
  import type { RequestFn } from "./request";
4
4
  export type AgentClient = {
5
- list(): Promise<AgentConfig[]>;
6
5
  info(): Promise<AgentInfo[]>;
7
6
  models(agentId: string): Promise<AgentModel[]>;
8
- setup(input: SetupAgentInput): Promise<AgentConfig>;
9
- setupAvailable(input: SetupAvailableAgentsInput): Promise<AgentConfig[]>;
10
- update(agentId: string, input: UpdateAgentInput): Promise<AgentConfig>;
11
- delete(agentId: string): Promise<void>;
12
7
  };
13
8
  export declare const createAgentClient: (request: RequestFn) => AgentClient;
@@ -1,12 +1,7 @@
1
1
  // src/client/agents.ts
2
2
  var createAgentClient = (request) => ({
3
- list: () => request("/v1/agents"),
4
3
  info: () => request("/v1/agents/info"),
5
- models: (agentId) => request(`/v1/agents/${agentId}/models`),
6
- setup: (input) => request("/v1/agents", { method: "POST", body: input }),
7
- setupAvailable: (input) => request("/v1/agents/setup-available", { method: "POST", body: input }),
8
- update: (agentId, input) => request(`/v1/agents/${agentId}`, { method: "PATCH", body: input }),
9
- delete: (agentId) => request(`/v1/agents/${agentId}`, { method: "DELETE" })
4
+ models: (agentId) => request(`/v1/agents/${agentId}/models`)
10
5
  });
11
6
 
12
7
  // src/client/extensions.ts
@@ -1,4 +1,4 @@
1
- import type { CommandOutcome } from "./types";
1
+ import type { CommandOutcome } from "pstdio-api-contracts/extension-kernel";
2
2
  export type CommandResponse<TResult = unknown> = {
3
3
  outcome: CommandOutcome<TResult>;
4
4
  };
@@ -1,6 +1,4 @@
1
- import type { CommandDefinition, HookDefinition, MiddlewareDefinition } from "./types/extension";
2
- import type { Struct } from "./types/json";
3
- import type { ParamObjectSchema } from "./types/params";
1
+ import type { CommandDefinition, HookDefinition, MiddlewareDefinition, ParamObjectSchema, Struct } from "pstdio-api-contracts/extension-kernel";
4
2
  /**
5
3
  * Define a single command outside an extension's object literal. Use this when commands
6
4
  * grow large enough to split into separate files, or when you need to share a command
@@ -28,13 +28,13 @@ export interface WebviewFilesClient {
28
28
  type: string;
29
29
  id?: string;
30
30
  };
31
- }): Promise<import("./types/webview-capabilities").ExtensionBlobRef>;
31
+ }): Promise<import("pstdio-api-contracts/extension-kernel").ExtensionBlobRef>;
32
32
  list(input?: {
33
33
  scope?: {
34
34
  type: string;
35
35
  id?: string;
36
36
  };
37
- }): Promise<import("./types/webview-capabilities").ExtensionBlobRef[]>;
37
+ }): Promise<import("pstdio-api-contracts/extension-kernel").ExtensionBlobRef[]>;
38
38
  delete(id: string): Promise<void>;
39
39
  }
40
40
  export type ExtensionViewRenderContext<TProps = unknown> = {
@@ -1,7 +1,4 @@
1
- import type { ExtensionSettingProperty, ExtensionSettingsContribution } from "./types/contributions";
2
- import type { CommandDefinition, ExtensionDefinition, HookDefinition, MiddlewareDefinition, ScheduleContribution } from "./types/extension";
3
- import type { Struct } from "./types/json";
4
- import type { ParamObjectSchema } from "./types/params";
1
+ import type { CommandDefinition, ExtensionDefinition, ExtensionSettingProperty, ExtensionSettingsContribution, HookDefinition, MiddlewareDefinition, ParamObjectSchema, ScheduleContribution, Struct } from "pstdio-api-contracts/extension-kernel";
5
2
  type CommandSchemas = Record<string, ParamObjectSchema | undefined>;
6
3
  type MiddlewareParams = Record<string, Struct>;
7
4
  type MiddlewareResults = Record<string, unknown>;
@@ -1,15 +1,10 @@
1
+ export type * from "pstdio-api-contracts/extension-kernel";
2
+ export type { CommitPayload, ConflictPayload, MergePayload, RebasePayload, SessionLifecyclePayload, WorktreeCreatedEventPayload, WorktreeRemovedPayload, } from "pstdio-api-contracts/extension-kernel";
3
+ export { ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES, EXTENSION_API_VERSION, getWorkbenchTargetDefinition, gitEvents, isLocalizedString, type Localizable, type LocalizedString, l10n, packageAsset, projectEvents, projectSlots, sessionEvents, sessionSlots, WEBVIEW_DECLARABLE_CAPABILITIES, WEBVIEW_HOST_CAPABILITIES, WEBVIEW_HOST_CAPABILITY_VERSION, type WorkbenchAttachmentTarget, type WorkbenchContributionKind, type WorkbenchLayoutTarget, type WorkbenchMenuTarget, type WorkbenchModeLayoutTarget, type WorkbenchSettingsScope, type WorkbenchSettingsTarget, type WorkbenchTargetDefinition, type WorkbenchTargetGranularity, type WorkbenchTreeTarget, type WorkbenchViewTarget, workbenchMenuTargets, workbenchModeLayoutTargets, workbenchSettingsScopes, workbenchSettingsTargets, workbenchTargets, workbenchTreeTargets, workbenchViewTargets, workspaceEvents, workspaceSlots, worktreeEvents, } from "pstdio-api-contracts/extension-kernel";
1
4
  export { type CommandResponse, unwrapCommandOutcome } from "./command-outcome";
2
5
  export { defineCommand, defineHook, defineMiddleware } from "./define-command";
3
6
  export { defineExtension } from "./define-extension";
4
7
  export { defineExtensionView, type ExtensionViewModule, type ExtensionViewRender, type ExtensionViewRenderContext, type GuestHost, type PropsStore, type WebviewFilesClient, } from "./define-extension-view";
5
- export type { CommitPayload, ConflictPayload, MergePayload, RebasePayload, SessionLifecyclePayload, WorktreeCreatedEventPayload, WorktreeRemovedPayload, } from "./kernel-slots";
6
- export { gitEvents, projectEvents, projectSlots, sessionEvents, sessionSlots, workspaceEvents, workspaceSlots, worktreeEvents, } from "./kernel-slots";
7
- export { isLocalizedString, type Localizable, type LocalizedString, l10n } from "./l10n";
8
- export { packageAsset } from "./package-asset";
9
8
  export { params } from "./params";
10
9
  export { commandEvent, commandRef, commandsOf, eventRef } from "./refs";
11
- export type * from "./types";
12
- export { EXTENSION_API_VERSION } from "./types/extension";
13
- export { ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES, WEBVIEW_DECLARABLE_CAPABILITIES, WEBVIEW_HOST_CAPABILITIES, WEBVIEW_HOST_CAPABILITY_VERSION, } from "./types/webview-capabilities";
14
10
  export { matchesResourceWhen } from "./when";
15
- export { getWorkbenchTargetDefinition, type WorkbenchAttachmentTarget, type WorkbenchContributionKind, type WorkbenchLayoutTarget, type WorkbenchMenuTarget, type WorkbenchModeLayoutTarget, type WorkbenchSettingsScope, type WorkbenchSettingsTarget, type WorkbenchTargetDefinition, type WorkbenchTargetGranularity, type WorkbenchTreeTarget, type WorkbenchViewTarget, workbenchMenuTargets, workbenchModeLayoutTargets, workbenchSettingsScopes, workbenchSettingsTargets, workbenchTargets, workbenchTreeTargets, workbenchViewTargets, } from "./workbench-targets";
@@ -1,97 +1,8 @@
1
- // src/extensions/command-outcome.ts
2
- var unwrapCommandOutcome = (response, fallbackReason = "Command failed.") => {
3
- const { outcome } = response;
4
- if (outcome.status !== "success") {
5
- throw new Error(outcome.reason || fallbackReason);
6
- }
7
- return outcome.value;
8
- };
9
- // src/extensions/define-command.ts
10
- var defineCommand = (definition) => definition;
11
- var defineMiddleware = (definition) => definition;
12
- var defineHook = (definition) => definition;
13
- // src/extensions/define-extension.ts
14
- var defineExtension = (extension) => extension;
15
- // src/extensions/define-extension-view.ts
16
- var pickFiles = (opts = {}) => new Promise((resolve, reject) => {
17
- const input = document.createElement("input");
18
- input.type = "file";
19
- input.accept = opts.accept ?? "";
20
- input.multiple = opts.multiple ?? false;
21
- input.style.display = "none";
22
- input.addEventListener("change", () => {
23
- const files = input.files ? Array.from(input.files) : [];
24
- input.remove();
25
- resolve(files);
26
- });
27
- input.addEventListener("cancel", () => {
28
- input.remove();
29
- resolve([]);
30
- });
31
- input.addEventListener("error", () => {
32
- input.remove();
33
- reject(new Error("Could not pick files."));
34
- });
35
- document.body.appendChild(input);
36
- input.click();
37
- });
38
- var createFilesClient = (host) => ({
39
- pick: pickFiles,
40
- upload: (input) => host.call("files.upload", input),
41
- list: async (input) => {
42
- const response = await host.call("files.list", input ?? {});
43
- return response.files ?? [];
44
- },
45
- delete: (id) => host.call("files.delete", { id })
46
- });
47
- var readTranslationProps = (props) => {
48
- const translations = typeof props === "object" && props !== null && "translations" in props ? props.translations : undefined;
49
- if (typeof translations !== "object" || translations === null)
50
- return null;
51
- return translations;
52
- };
53
- var interpolate = (value, args) => Object.entries(args ?? {}).reduce((next, [key, replacement]) => next.replaceAll(`{{${key}}}`, String(replacement)), value);
54
- var createTranslationApi = (propsStore) => {
55
- const locale = () => readTranslationProps(propsStore.get())?.locale ?? "en";
56
- const t = (key, defaultValue, args) => {
57
- const translations = readTranslationProps(propsStore.get());
58
- const value = translations?.bundle?.[key] ?? translations?.defaultBundle?.[key] ?? defaultValue ?? key;
59
- return interpolate(value, args);
60
- };
61
- return { locale, t };
62
- };
63
- var defineExtensionView = (definition) => ({
64
- mount: async (mount, host, propsStore) => {
65
- const translations = createTranslationApi(propsStore);
66
- const cleanup = await definition.render({
67
- mount,
68
- host,
69
- files: createFilesClient(host),
70
- propsStore,
71
- get locale() {
72
- return translations.locale();
73
- },
74
- t: translations.t
75
- });
76
- return typeof cleanup === "function" ? cleanup : () => {};
77
- }
78
- });
79
- // src/extensions/refs.ts
1
+ // ../pstdio-api-contracts/src/extension-kernel/refs.ts
80
2
  var commandRef = (id) => ({ id });
81
3
  var eventRef = (id) => ({ id });
82
- var commandEvent = (command, phase) => ({
83
- id: `command.${phase}:${command.id}`
84
- });
85
- var commandsOf = (packageName, extension) => {
86
- const refs = {};
87
- const commands = extension.commands ?? {};
88
- for (const key of Object.keys(commands)) {
89
- refs[key] = { id: `${packageName}.${key}` };
90
- }
91
- return refs;
92
- };
93
4
 
94
- // src/extensions/slots.ts
5
+ // ../pstdio-api-contracts/src/extension-kernel/slots.ts
95
6
  var defineSlot = (id, options) => ({
96
7
  id,
97
8
  kind: options.kind,
@@ -100,7 +11,7 @@ var defineSlot = (id, options) => ({
100
11
  metadata: options.metadata
101
12
  });
102
13
 
103
- // src/extensions/kernel-slots.ts
14
+ // ../pstdio-api-contracts/src/extension-kernel/kernel-slots.ts
104
15
  var projectSlots = {
105
16
  sidebar: defineSlot("project.sidebar", { kind: "view" }),
106
17
  headerPrimary: defineSlot("project.headerPrimary", { kind: "menu" }),
@@ -143,47 +54,21 @@ var gitEvents = {
143
54
  merged: eventRef("git.merged"),
144
55
  conflicted: eventRef("git.conflicted")
145
56
  };
146
- // src/extensions/l10n.ts
57
+ // ../pstdio-api-contracts/src/extension-kernel/l10n.ts
147
58
  var l10n = (key, defaultValue) => ({
148
59
  $l10n: key,
149
60
  ...defaultValue === undefined ? {} : { default: defaultValue }
150
61
  });
151
62
  var isLocalizedString = (value) => typeof value === "object" && value !== null && ("$l10n" in value) && typeof value.$l10n === "string";
152
- // src/extensions/package-asset.ts
63
+ // ../pstdio-api-contracts/src/extension-kernel/package-asset.ts
153
64
  var packageAsset = (path, baseUrl) => ({
154
65
  kind: "package-asset",
155
66
  path,
156
67
  baseUrl
157
68
  });
158
- // src/extensions/params.ts
159
- var params = {
160
- text: (options) => ({ type: "text", ...options }),
161
- longText: (options) => ({ type: "longtext", ...options }),
162
- number: (options) => ({ type: "number", ...options }),
163
- boolean: (options) => ({ type: "boolean", ...options }),
164
- select: (options) => ({ type: "select", ...options }),
165
- multiSelect: (options) => ({
166
- type: "multi-select",
167
- ...options
168
- }),
169
- repo: (options) => ({ type: "repo", ...options }),
170
- harness: (options) => ({ type: "harness", ...options }),
171
- template: (options) => ({
172
- label: options.label,
173
- description: options.description,
174
- required: options.required,
175
- defaultValue: options.defaultValue,
176
- metadata: options.metadata,
177
- type: "template",
178
- templateType: options.type
179
- }),
180
- resource: (options) => ({ type: "resource", ...options }),
181
- json: (options) => ({ type: "json", ...options }),
182
- list: (options) => ({ type: "list", ...options })
183
- };
184
- // src/extensions/types/extension.ts
69
+ // ../pstdio-api-contracts/src/extension-kernel/types/extension.ts
185
70
  var EXTENSION_API_VERSION = "1.0.0";
186
- // src/extensions/types/webview-capabilities.ts
71
+ // ../pstdio-api-contracts/src/extension-kernel/types/webview-capabilities.ts
187
72
  var WEBVIEW_HOST_CAPABILITY_VERSION = 1;
188
73
  var WEBVIEW_DECLARABLE_CAPABILITIES = [
189
74
  "commands.execute",
@@ -204,14 +89,7 @@ var WEBVIEW_HOST_CAPABILITIES = [
204
89
  ...WEBVIEW_DECLARABLE_CAPABILITIES,
205
90
  ...ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES
206
91
  ];
207
- // src/extensions/when.ts
208
- var matchesResourceWhen = (when, resourceType) => {
209
- const resourceTypes = when?.resourceType;
210
- if (!resourceTypes?.length)
211
- return true;
212
- return resourceType ? resourceTypes.includes(resourceType) : false;
213
- };
214
- // src/extensions/workbench-targets.ts
92
+ // ../pstdio-api-contracts/src/extension-kernel/workbench-targets.ts
215
93
  var workbenchMenuTargets = ["workbench.nav.actions", "workbench.nav.overflow"];
216
94
  var workbenchTreeTargets = [
217
95
  "workbench.left.tree",
@@ -296,6 +174,129 @@ var workbenchTargets = [
296
174
  }
297
175
  ];
298
176
  var getWorkbenchTargetDefinition = (id) => workbenchTargets.find((target) => target.id === id);
177
+ // src/extensions/command-outcome.ts
178
+ var unwrapCommandOutcome = (response, fallbackReason = "Command failed.") => {
179
+ const { outcome } = response;
180
+ if (outcome.status !== "success") {
181
+ throw new Error(outcome.reason || fallbackReason);
182
+ }
183
+ return outcome.value;
184
+ };
185
+ // src/extensions/define-command.ts
186
+ var defineCommand = (definition) => definition;
187
+ var defineMiddleware = (definition) => definition;
188
+ var defineHook = (definition) => definition;
189
+ // src/extensions/define-extension.ts
190
+ var defineExtension = (extension) => extension;
191
+ // src/extensions/define-extension-view.ts
192
+ var pickFiles = (opts = {}) => new Promise((resolve, reject) => {
193
+ const input = document.createElement("input");
194
+ input.type = "file";
195
+ input.accept = opts.accept ?? "";
196
+ input.multiple = opts.multiple ?? false;
197
+ input.style.display = "none";
198
+ input.addEventListener("change", () => {
199
+ const files = input.files ? Array.from(input.files) : [];
200
+ input.remove();
201
+ resolve(files);
202
+ });
203
+ input.addEventListener("cancel", () => {
204
+ input.remove();
205
+ resolve([]);
206
+ });
207
+ input.addEventListener("error", () => {
208
+ input.remove();
209
+ reject(new Error("Could not pick files."));
210
+ });
211
+ document.body.appendChild(input);
212
+ input.click();
213
+ });
214
+ var createFilesClient = (host) => ({
215
+ pick: pickFiles,
216
+ upload: (input) => host.call("files.upload", input),
217
+ list: async (input) => {
218
+ const response = await host.call("files.list", input ?? {});
219
+ return response.files ?? [];
220
+ },
221
+ delete: (id) => host.call("files.delete", { id })
222
+ });
223
+ var readTranslationProps = (props) => {
224
+ const translations = typeof props === "object" && props !== null && "translations" in props ? props.translations : undefined;
225
+ if (typeof translations !== "object" || translations === null)
226
+ return null;
227
+ return translations;
228
+ };
229
+ var interpolate = (value, args) => Object.entries(args ?? {}).reduce((next, [key, replacement]) => next.replaceAll(`{{${key}}}`, String(replacement)), value);
230
+ var createTranslationApi = (propsStore) => {
231
+ const locale = () => readTranslationProps(propsStore.get())?.locale ?? "en";
232
+ const t = (key, defaultValue, args) => {
233
+ const translations = readTranslationProps(propsStore.get());
234
+ const value = translations?.bundle?.[key] ?? translations?.defaultBundle?.[key] ?? defaultValue ?? key;
235
+ return interpolate(value, args);
236
+ };
237
+ return { locale, t };
238
+ };
239
+ var defineExtensionView = (definition) => ({
240
+ mount: async (mount, host, propsStore) => {
241
+ const translations = createTranslationApi(propsStore);
242
+ const cleanup = await definition.render({
243
+ mount,
244
+ host,
245
+ files: createFilesClient(host),
246
+ propsStore,
247
+ get locale() {
248
+ return translations.locale();
249
+ },
250
+ t: translations.t
251
+ });
252
+ return typeof cleanup === "function" ? cleanup : () => {};
253
+ }
254
+ });
255
+ // src/extensions/params.ts
256
+ var params = {
257
+ text: (options) => ({ type: "text", ...options }),
258
+ longText: (options) => ({ type: "longtext", ...options }),
259
+ number: (options) => ({ type: "number", ...options }),
260
+ boolean: (options) => ({ type: "boolean", ...options }),
261
+ select: (options) => ({ type: "select", ...options }),
262
+ multiSelect: (options) => ({
263
+ type: "multi-select",
264
+ ...options
265
+ }),
266
+ repo: (options) => ({ type: "repo", ...options }),
267
+ harness: (options) => ({ type: "harness", ...options }),
268
+ template: (options) => ({
269
+ label: options.label,
270
+ description: options.description,
271
+ required: options.required,
272
+ defaultValue: options.defaultValue,
273
+ metadata: options.metadata,
274
+ type: "template",
275
+ templateType: options.type
276
+ }),
277
+ resource: (options) => ({ type: "resource", ...options }),
278
+ json: (options) => ({ type: "json", ...options }),
279
+ list: (options) => ({ type: "list", ...options })
280
+ };
281
+ // src/extensions/refs.ts
282
+ var commandEvent = (command, phase) => ({
283
+ id: `command.${phase}:${command.id}`
284
+ });
285
+ var commandsOf = (packageName, extension) => {
286
+ const refs = {};
287
+ const commands = extension.commands ?? {};
288
+ for (const key of Object.keys(commands)) {
289
+ refs[key] = { id: `${packageName}.${key}` };
290
+ }
291
+ return refs;
292
+ };
293
+ // src/extensions/when.ts
294
+ var matchesResourceWhen = (when, resourceType) => {
295
+ const resourceTypes = when?.resourceType;
296
+ if (!resourceTypes?.length)
297
+ return true;
298
+ return resourceType ? resourceTypes.includes(resourceType) : false;
299
+ };
299
300
  export {
300
301
  worktreeEvents,
301
302
  workspaceSlots,
@@ -1,4 +1,4 @@
1
- import type { BooleanParam, HarnessParam, JsonParam, ListParam, LongTextParam, MultiSelectParam, NumberParam, RepoParam, ResourceParam, SelectParam, TemplateParam, TextParam } from "./types/params";
1
+ import type { BooleanParam, HarnessParam, JsonParam, ListParam, LongTextParam, MultiSelectParam, NumberParam, RepoParam, ResourceParam, SelectParam, TemplateParam, 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;
@@ -1,16 +1,5 @@
1
- import type { CommandLifecycleEventPayload, CommandLifecyclePhase, CommandRef } from "./types/commands";
2
- import type { EventRef } from "./types/events";
3
- import type { CommandDefinition } from "./types/extension";
4
- import type { Struct } from "./types/json";
5
- import type { ParamObjectSchema, ParamsOf } from "./types/params";
6
- /**
7
- * Build a typed reference to a command by id. Authors generally prefer
8
- * `commandsOf(packageName, ext)`, which derives refs from the extension definition
9
- * so a renamed command becomes a type error at every call site.
10
- */
11
- export declare const commandRef: <TParams extends Struct = Struct, TResult = unknown>(id: string) => CommandRef<TParams, TResult>;
12
- /** Build a typed reference to an event by id. */
13
- export declare const eventRef: <TPayload extends Struct = Struct>(id: string) => EventRef<TPayload>;
1
+ import type { CommandDefinition, CommandLifecycleEventPayload, CommandLifecyclePhase, CommandRef, EventRef, ParamObjectSchema, ParamsOf, Struct } from "pstdio-api-contracts/extension-kernel";
2
+ export { commandRef, eventRef } from "pstdio-api-contracts/extension-kernel";
14
3
  /**
15
4
  * Build an `EventRef` for a command lifecycle phase (`requested`, `started`, `completed`,
16
5
  * `rejected`, `failed`). The payload type is inferred from the command ref so hooks see
@@ -37,4 +26,3 @@ type CommandsRefMap<TCommands extends CommandsRecord> = {
37
26
  export declare const commandsOf: <TExtension extends {
38
27
  commands?: CommandsRecord;
39
28
  }>(packageName: string, extension: TExtension) => CommandsRefMap<NonNullable<TExtension["commands"]>>;
40
- export {};
@@ -1,4 +1,4 @@
1
- import type { WhenExpression } from "./types/contributions";
1
+ import type { WhenExpression } from "pstdio-api-contracts/extension-kernel";
2
2
  /**
3
3
  * Resource-scoped visibility for command-palette contributions. Both the workbench host and the
4
4
  * dashboard palette gate the same way, so the rule lives here once instead of being re-derived per
@@ -1 +1 @@
1
- export type { AgentAvailabilityType, AgentConfig, AgentInfo, AgentModel } from "pstdio-api-contracts";
1
+ export type { AgentAvailabilityType, AgentInfo, AgentModel } from "pstdio-api-contracts";
@@ -1,8 +1,8 @@
1
1
  export type { Repo } from "pstdio-api-contracts";
2
- export type { AgentAvailabilityType, AgentConfig, AgentInfo, AgentModel } from "./agent";
2
+ export type { AgentAvailabilityType, AgentInfo, AgentModel } from "./agent";
3
3
  export type { FileRecord } from "./file";
4
4
  export type { KnownAgent, KnownAgentId } from "./known-agents";
5
- export { findAgent, isKnownAgentId, KNOWN_AGENT_IDS, KNOWN_AGENTS } from "./known-agents";
5
+ export { findAgent, harnessLocalId, isKnownAgentId, KNOWN_AGENT_IDS, KNOWN_AGENTS } from "./known-agents";
6
6
  export type { Project } from "./project";
7
7
  export type { Session, SessionStatus } from "./session";
8
8
  export type { Settings } from "./settings";
@@ -16,10 +16,12 @@ var KNOWN_AGENTS = [
16
16
  }
17
17
  ];
18
18
  var KNOWN_AGENT_IDS = KNOWN_AGENTS.map((agent) => agent.id);
19
- var findAgent = (id) => KNOWN_AGENTS.find((agent) => agent.id === id) ?? null;
19
+ var harnessLocalId = (id) => id.slice(id.lastIndexOf(".") + 1);
20
+ var findAgent = (id) => KNOWN_AGENTS.find((agent) => agent.id === harnessLocalId(id)) ?? null;
20
21
  var isKnownAgentId = (id) => KNOWN_AGENT_IDS.includes(id);
21
22
  export {
22
23
  isKnownAgentId,
24
+ harnessLocalId,
23
25
  findAgent,
24
26
  KNOWN_AGENT_IDS,
25
27
  KNOWN_AGENTS
@@ -8,5 +8,7 @@ export type KnownAgent = {
8
8
  };
9
9
  export declare const KNOWN_AGENTS: KnownAgent[];
10
10
  export declare const KNOWN_AGENT_IDS: KnownAgentId[];
11
+ /** Bare provider id of a (possibly namespaced) harness id, e.g. "pstdio.harness-claude-code.claude-code" -> "claude-code". */
12
+ export declare const harnessLocalId: (id: string) => string;
11
13
  export declare const findAgent: (id: string) => KnownAgent | null;
12
14
  export declare const isKnownAgentId: (id: string) => id is KnownAgentId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pstdio/sdk",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/pufflyai/prompt-studio"
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "scripts": {
42
42
  "build": "rm -rf ./dist && bun run build:js && bun run build:types",
43
- "build:js": "bun build ./src/api/index.ts ./src/client/index.ts ./src/extensions/index.ts ./src/prompts/index.ts ./src/hooks/index.ts ./src/resources/index.ts --outdir ./dist --root ./src --target node --format esm --packages external",
43
+ "build:js": "bun build ./src/api/index.ts ./src/client/index.ts ./src/extensions/index.ts ./src/prompts/index.ts ./src/hooks/index.ts ./src/resources/index.ts --outdir ./dist --root ./src --target node --format esm --external mustache",
44
44
  "build:types": "tsc --project ./tsconfig.build.json",
45
45
  "prepack": "bun run build",
46
46
  "typecheck": "tsc --noEmit",
@@ -1 +0,0 @@
1
- export type { SetupAgentInput, SetupAvailableAgentsInput, UpdateAgentInput } from "pstdio-api-contracts";
@@ -1,112 +0,0 @@
1
- import type { ExtensionWorkspace } from "./types/context";
2
- import type { ResourceAnchor } from "./types/resources";
3
- export interface WorktreeCreatedEventPayload {
4
- projectId: string;
5
- repoPath: string;
6
- worktreePath: string;
7
- branch: string;
8
- workspace: string;
9
- workspaceId: string;
10
- anchors?: ResourceAnchor[];
11
- }
12
- export interface SessionLifecyclePayload {
13
- projectId: string;
14
- sessionId: string;
15
- sessionStatus?: string;
16
- originalSessionId?: string;
17
- workspace?: ExtensionWorkspace;
18
- workspaceId?: string;
19
- worktreePath?: string;
20
- branch?: string;
21
- anchors?: ResourceAnchor[];
22
- }
23
- export interface WorktreeRemovedPayload {
24
- projectId: string;
25
- repoPath?: string;
26
- worktreePath: string;
27
- workspace?: ExtensionWorkspace;
28
- workspaceId?: string;
29
- anchors?: ResourceAnchor[];
30
- }
31
- export interface CommitPayload {
32
- projectId: string;
33
- repoPath?: string;
34
- worktreePath?: string;
35
- branch?: string;
36
- commitSha?: string;
37
- workspace?: ExtensionWorkspace;
38
- anchors?: ResourceAnchor[];
39
- }
40
- export interface RebasePayload {
41
- projectId: string;
42
- repoPath?: string;
43
- worktreePath?: string;
44
- branch?: string;
45
- workspace?: ExtensionWorkspace;
46
- anchors?: ResourceAnchor[];
47
- }
48
- export interface MergePayload extends CommitPayload {
49
- }
50
- export interface ConflictPayload {
51
- projectId: string;
52
- operation: "rebase" | "merge";
53
- repoPath?: string;
54
- worktreePath?: string;
55
- branch?: string;
56
- workspace?: ExtensionWorkspace;
57
- anchors?: ResourceAnchor[];
58
- }
59
- export declare const projectSlots: {
60
- sidebar: import("./types").SlotRef<object, "view">;
61
- headerPrimary: import("./types").SlotRef<object, "menu">;
62
- headerOverflow: import("./types").SlotRef<object, "menu">;
63
- settingsPanels: import("./types").SlotRef<object, "settings">;
64
- };
65
- export declare const sessionSlots: {
66
- headerPrimary: import("./types").SlotRef<object, "menu">;
67
- headerOverflow: import("./types").SlotRef<object, "menu">;
68
- transcriptActions: import("./types").SlotRef<object, "menu">;
69
- };
70
- export declare const workspaceSlots: {
71
- headerPrimary: import("./types").SlotRef<object, "menu">;
72
- headerOverflow: import("./types").SlotRef<object, "menu">;
73
- sidebar: import("./types").SlotRef<object, "view">;
74
- };
75
- export declare const projectEvents: {
76
- opened: import("./types").EventRef<{
77
- projectId: string;
78
- }>;
79
- };
80
- export declare const sessionEvents: {
81
- started: import("./types").EventRef<SessionLifecyclePayload & {
82
- anchors?: ResourceAnchor[];
83
- }>;
84
- resumed: import("./types").EventRef<SessionLifecyclePayload>;
85
- awaitingInput: import("./types").EventRef<SessionLifecyclePayload>;
86
- succeeded: import("./types").EventRef<SessionLifecyclePayload>;
87
- failed: import("./types").EventRef<SessionLifecyclePayload>;
88
- completed: import("./types").EventRef<SessionLifecyclePayload & {
89
- anchors?: ResourceAnchor[];
90
- }>;
91
- };
92
- export declare const workspaceEvents: {
93
- created: import("./types").EventRef<{
94
- workspace: ExtensionWorkspace;
95
- }>;
96
- archived: import("./types").EventRef<{
97
- workspace: ExtensionWorkspace;
98
- }>;
99
- deleted: import("./types").EventRef<{
100
- workspace: ExtensionWorkspace;
101
- }>;
102
- };
103
- export declare const worktreeEvents: {
104
- created: import("./types").EventRef<WorktreeCreatedEventPayload>;
105
- removed: import("./types").EventRef<WorktreeRemovedPayload>;
106
- };
107
- export declare const gitEvents: {
108
- committed: import("./types").EventRef<CommitPayload>;
109
- rebased: import("./types").EventRef<RebasePayload>;
110
- merged: import("./types").EventRef<MergePayload>;
111
- conflicted: import("./types").EventRef<ConflictPayload>;
112
- };
@@ -1,10 +0,0 @@
1
- export interface LocalizedString {
2
- readonly $l10n: string;
3
- readonly default?: string;
4
- }
5
- export type Localizable<T extends string = string> = T | LocalizedString;
6
- export declare const l10n: (key: string, defaultValue?: string) => {
7
- default?: string | undefined;
8
- $l10n: string;
9
- };
10
- export declare const isLocalizedString: (value: unknown) => value is LocalizedString;
@@ -1,10 +0,0 @@
1
- import type { PackageAssetDescriptor } from "./types/resources";
2
- /**
3
- * Reference an asset shipped alongside the extension's compiled output. `path` is
4
- * resolved relative to `baseUrl`; in practice authors always pass `import.meta.url`
5
- * so the runtime can locate the file no matter where the extension is installed.
6
- *
7
- * @example
8
- * webview: { entry: packageAsset("./src/page.tsx", import.meta.url) }
9
- */
10
- export declare const packageAsset: (path: string, baseUrl: string) => PackageAssetDescriptor;
@@ -1,6 +0,0 @@
1
- import type { Struct } from "./types/json";
2
- import type { SlotOptions, SlotRef, UiSlotKind } from "./types/slots";
3
- /**
4
- * Define a host-owned UI slot that extension contributions can target.
5
- */
6
- export declare const defineSlot: <TContext extends Struct = Struct, TKind extends UiSlotKind = UiSlotKind>(id: string, options: SlotOptions<TKind>) => SlotRef<TContext, TKind>;