@pstdio/sdk 0.21.0 → 0.22.1

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 (62) hide show
  1. package/README.md +22 -192
  2. package/dist/api/index.js +419 -298
  3. package/dist/api.d.ts +3767 -0
  4. package/dist/client/index.js +1 -0
  5. package/dist/client.d.ts +1714 -0
  6. package/dist/extensions/index.js +126 -19
  7. package/dist/extensions/react/index.js +2 -1
  8. package/dist/{extensions/react/index.d.ts → extensions-react.d.ts} +23 -16
  9. package/dist/extensions.d.ts +3833 -0
  10. package/dist/hooks.d.ts +1775 -0
  11. package/dist/{prompts/render-prompt.d.ts → prompts.d.ts} +3 -1
  12. package/dist/resources/index.js +419 -298
  13. package/dist/resources.d.ts +422 -0
  14. package/package.json +12 -31
  15. package/dist/api/extensions.d.ts +0 -1
  16. package/dist/api/index.d.ts +0 -9
  17. package/dist/api/projects.d.ts +0 -1
  18. package/dist/api/sessions.d.ts +0 -2
  19. package/dist/api/settings.d.ts +0 -1
  20. package/dist/api/skills.d.ts +0 -1
  21. package/dist/api/terminal.d.ts +0 -49
  22. package/dist/api/workspaces.d.ts +0 -12
  23. package/dist/client/agents.d.ts +0 -10
  24. package/dist/client/automation.d.ts +0 -12
  25. package/dist/client/client.d.ts +0 -26
  26. package/dist/client/extensions.d.ts +0 -15
  27. package/dist/client/index.d.ts +0 -14
  28. package/dist/client/notifications.d.ts +0 -23
  29. package/dist/client/projects.d.ts +0 -14
  30. package/dist/client/request.d.ts +0 -25
  31. package/dist/client/runtime.d.ts +0 -5
  32. package/dist/client/sessions.d.ts +0 -45
  33. package/dist/client/settings.d.ts +0 -7
  34. package/dist/client/skills.d.ts +0 -9
  35. package/dist/client/sse.d.ts +0 -15
  36. package/dist/client/sync.d.ts +0 -35
  37. package/dist/client/workspaces.d.ts +0 -20
  38. package/dist/extensions/command-outcome.d.ts +0 -5
  39. package/dist/extensions/define-command.d.ts +0 -28
  40. package/dist/extensions/define-contribution.d.ts +0 -36
  41. package/dist/extensions/define-extension-view.d.ts +0 -58
  42. package/dist/extensions/define-extension.d.ts +0 -24
  43. package/dist/extensions/index.d.ts +0 -14
  44. package/dist/extensions/params.d.ts +0 -33
  45. package/dist/extensions/refs.d.ts +0 -8
  46. package/dist/extensions/terminal-session-bridge.d.ts +0 -32
  47. package/dist/extensions/webview-client.d.ts +0 -41
  48. package/dist/extensions/when.d.ts +0 -11
  49. package/dist/hooks/base.d.ts +0 -17
  50. package/dist/hooks/entities.d.ts +0 -8
  51. package/dist/hooks/index.d.ts +0 -3
  52. package/dist/hooks/session.d.ts +0 -12
  53. package/dist/hooks/worktree.d.ts +0 -53
  54. package/dist/prompts/index.d.ts +0 -1
  55. package/dist/resources/agent.d.ts +0 -2
  56. package/dist/resources/file.d.ts +0 -1
  57. package/dist/resources/index.d.ts +0 -9
  58. package/dist/resources/project.d.ts +0 -1
  59. package/dist/resources/session.d.ts +0 -1
  60. package/dist/resources/settings.d.ts +0 -1
  61. package/dist/resources/skill.d.ts +0 -1
  62. package/dist/resources/workspace.d.ts +0 -3
@@ -13,19 +13,25 @@ var __export = (target, all) => {
13
13
  });
14
14
  };
15
15
 
16
+ // ../pstdio-api-contracts/src/extension-kernel/types/composition.ts
17
+ var dockedWorkbenchRegions = ["sidenav", "main", "secondary", "side"];
18
+ var extensionPanelRegions = ["main", "secondary", "side"];
19
+
16
20
  // ../pstdio-api-contracts/src/extension-kernel/builtin-refs.ts
17
21
  var hostRef = (kind, id) => ({ extensionId: "pstdio", kind, id });
18
- var workbenchCommands = {
19
- switchMode: hostRef("command", "workbench.action.switchMode")
20
- };
21
22
  var workbenchModes = {
22
23
  project: hostRef("mode", "project"),
24
+ sessions: hostRef("mode", "sessions"),
23
25
  settings: hostRef("mode", "settings")
24
26
  };
27
+ var workbenchModeDefinitions = {
28
+ project: { ref: workbenchModes.project, regions: dockedWorkbenchRegions },
29
+ sessions: { ref: workbenchModes.sessions, regions: dockedWorkbenchRegions },
30
+ settings: { ref: workbenchModes.settings, regions: dockedWorkbenchRegions }
31
+ };
25
32
  var hostResourceKind = (id, label, menuSlots) => ({
26
33
  id,
27
34
  ref: hostRef("resource-kind", id),
28
- surface: "primary",
29
35
  label,
30
36
  menuSlots
31
37
  });
@@ -43,12 +49,65 @@ var workbenchResourceKinds = {
43
49
  session: workbenchResourceKindDefinitions.session.ref,
44
50
  workspace: workbenchResourceKindDefinitions.workspace.ref
45
51
  };
52
+ var workbenchPages = {
53
+ start: hostRef("page", "start"),
54
+ sessions: hostRef("page", "sessions"),
55
+ session: hostRef("page", "session"),
56
+ workspaces: hostRef("page", "workspaces"),
57
+ workspace: hostRef("page", "workspace")
58
+ };
59
+ var workbenchPageDefinitions = {
60
+ start: {
61
+ ref: workbenchPages.start,
62
+ mode: workbenchModes.project,
63
+ path: "",
64
+ primary: { cardinality: "one", resourceKinds: [] }
65
+ },
66
+ sessions: {
67
+ ref: workbenchPages.sessions,
68
+ mode: workbenchModes.sessions,
69
+ path: "sessions",
70
+ primary: { cardinality: "one", resourceKinds: [] }
71
+ },
72
+ session: {
73
+ ref: workbenchPages.session,
74
+ mode: workbenchModes.sessions,
75
+ path: "session",
76
+ primary: { cardinality: "one", resourceKinds: ["session", "session-draft"] }
77
+ },
78
+ workspaces: {
79
+ ref: workbenchPages.workspaces,
80
+ mode: workbenchModes.project,
81
+ path: "workspaces",
82
+ primary: { cardinality: "one", resourceKinds: [] }
83
+ },
84
+ workspace: {
85
+ ref: workbenchPages.workspace,
86
+ mode: workbenchModes.project,
87
+ path: "workspace",
88
+ primary: { cardinality: "many", resourceKinds: ["workspace"] }
89
+ }
90
+ };
91
+ var workbenchPanels = {
92
+ projectSession: hostRef("placement", "project-session")
93
+ };
94
+ var workbenchPanelDefinitions = {
95
+ projectSession: {
96
+ ref: workbenchPanels.projectSession,
97
+ mode: workbenchModes.project,
98
+ cardinality: "many",
99
+ resourceKinds: ["session", "session-draft"]
100
+ }
101
+ };
46
102
  var workbenchSlots = {
47
- projectNavigation: hostRef("navigation-item", "project.navigation"),
48
103
  projectSettings: hostRef("settings-panel", "project.settings"),
49
104
  statusBarLeading: hostRef("status-bar-item", "status-bar.leading"),
50
105
  statusBarTrailing: hostRef("status-bar-item", "status-bar.trailing")
51
106
  };
107
+ // ../pstdio-api-contracts/src/extension-kernel/contribution-id.ts
108
+ var localContributionIdPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)*$/;
109
+ var isValidLocalContributionId = (id) => localContributionIdPattern.test(id);
110
+ var localContributionIdGrammar = 'lowercase kebab-case segments separated by dots, such as "ticket-status.create"';
52
111
  // ../pstdio-api-contracts/src/extension-kernel/refs.ts
53
112
  var createCommandRef = (input) => ({ ...input, kind: "command" });
54
113
  var commandRef = Object.assign(createCommandRef, {
@@ -125,15 +184,14 @@ var packageAsset = (path, baseUrl) => ({
125
184
  path,
126
185
  baseUrl
127
186
  });
128
- // ../pstdio-api-contracts/src/extension-kernel/types/composition.ts
129
- var dockedWorkbenchRegions = ["sidenav", "main", "secondary", "side"];
130
187
  // ../pstdio-api-contracts/src/extension-kernel/types/extension.ts
131
- var EXTENSION_API_VERSION = "1.0.0-alpha.5";
188
+ var EXTENSION_API_VERSION = "1.0.0-alpha.10";
132
189
  // ../pstdio-api-contracts/src/extension-kernel/types/webview-capabilities.ts
133
190
  var WEBVIEW_HOST_CAPABILITY_VERSION = 1;
134
191
  var WEBVIEW_DECLARABLE_CAPABILITIES = [
135
192
  "commands.execute",
136
- "resource.open",
193
+ "navigation.open",
194
+ "placement.close",
137
195
  "notification.show",
138
196
  "notification.action",
139
197
  "notification.resolve",
@@ -149,11 +207,18 @@ var WEBVIEW_DECLARABLE_CAPABILITIES = [
149
207
  "files.list",
150
208
  "files.delete"
151
209
  ];
210
+ var WEBVIEW_SCOPED_DECLARABLE_CAPABILITIES = ["artifacts.read"];
152
211
  var ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES = ["host.dispatchKeyboardEvent"];
153
212
  var WEBVIEW_HOST_CAPABILITIES = [
154
213
  ...WEBVIEW_DECLARABLE_CAPABILITIES,
214
+ ...WEBVIEW_SCOPED_DECLARABLE_CAPABILITIES,
155
215
  ...ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES
156
216
  ];
217
+ // package.json
218
+ var version = "0.22.1";
219
+
220
+ // src/version.ts
221
+ var SDK_VERSION = version;
157
222
  // src/extensions/command-outcome.ts
158
223
  var unwrapCommandOutcome = (response, fallbackReason = "Command failed.") => {
159
224
  const { outcome } = response;
@@ -183,14 +248,16 @@ var defineView = defineContribution("view");
183
248
  var defineViewMenu = defineContribution("view-menu");
184
249
  var definePlacement = defineContribution("placement");
185
250
  var defineResourceKind = defineContribution("resource-kind");
186
- var resourceSlotRef = (resourceKind, id) => ({
187
- resourceKind,
188
- id
189
- });
190
251
  var resourceMenuSlotRef2 = (resourceKind, id) => defineSlot(`${resourceKind.id}.${id}`, { kind: "menu" });
191
- var defineResourceView = defineContribution("resource-view");
192
252
  var defineNavigationItem = defineContribution("navigation-item");
253
+ var defineNavigationTree = defineContribution("navigation-tree");
193
254
  var defineMode = defineContribution("mode");
255
+ var createPage = (definition) => {
256
+ const ref = { kind: "page", id: definition.id };
257
+ const panels = Object.fromEntries(definition.slots.map((slot) => [slot.id, { kind: "page-slot", page: ref, id: slot.id }]));
258
+ return { ...definition, ref, panels };
259
+ };
260
+ var definePage = createPage;
194
261
  var defineStatusBarItem = defineContribution("status-bar-item");
195
262
  var defineStatuses = defineContribution("status");
196
263
  var defineSettingsPanel = defineContribution("settings-panel");
@@ -242,7 +309,7 @@ var createFilesClient = (host) => ({
242
309
  upload: (input) => host.call("files.upload", input),
243
310
  list: async (input) => {
244
311
  const response = await host.call("files.list", input ?? {});
245
- return response.files ?? [];
312
+ return response.files;
246
313
  },
247
314
  delete: (id) => host.call("files.delete", { id })
248
315
  });
@@ -293,16 +360,30 @@ var params = {
293
360
  }),
294
361
  repo: (options) => ({ type: "repo", ...options }),
295
362
  harness: (options) => ({ type: "harness", ...options }),
363
+ template: (options) => {
364
+ const { type: templateType, ...rest } = options;
365
+ return { type: "template", templateType, ...rest };
366
+ },
296
367
  resource: (options) => ({ type: "resource", ...options }),
297
368
  json: (options) => ({ type: "json", ...options }),
298
369
  list: (options) => ({ type: "list", ...options })
299
370
  };
371
+ // src/extensions/qualify-ref.ts
372
+ function qualifyRef(owner, ref) {
373
+ if (ref.kind === "page-slot")
374
+ return { ...ref, page: qualifyRef(owner, ref.page) };
375
+ return { ...ref, extensionId: owner };
376
+ }
300
377
  // src/extensions/refs.ts
301
378
  var commandEvent = (command, phase) => ({
302
379
  ...command.extensionId ? { extensionId: command.extensionId } : {},
303
380
  kind: "event",
304
381
  id: `command.${phase}:${command.id}`
305
382
  });
383
+ // src/extensions/resource-key.ts
384
+ function resourceKey(resource) {
385
+ return resource && JSON.stringify([resource.extensionId ?? "", resource.projectId ?? "", resource.type, resource.id]);
386
+ }
306
387
  // src/extensions/terminal-session-bridge.ts
307
388
  var TERMINAL_SESSION_CAPABILITY = "terminal.session";
308
389
  var createTerminalSessionBridge = (host) => ({
@@ -375,6 +456,9 @@ var createTerminalSessionBridge = (host) => ({
375
456
  };
376
457
  }
377
458
  });
459
+ // src/extensions/webview-capabilities.ts
460
+ var artifactMountId = (mount) => typeof mount === "string" ? mount : mount.id;
461
+ var artifactsRead = (mount) => `artifacts.read:${artifactMountId(mount)}`;
378
462
  // src/extensions/webview-client.ts
379
463
  var createWebviewClient = (host, options) => {
380
464
  const extensionId = options?.extensionId ?? host.extensionId;
@@ -402,7 +486,16 @@ var createWebviewClient = (host, options) => {
402
486
  await host.call("extension.settings.set", { key, value });
403
487
  }
404
488
  };
405
- return { commands, settings };
489
+ const artifacts = {
490
+ list: (mount, prefix) => host.call("artifacts.read", {
491
+ op: "list",
492
+ mount: artifactMountId(mount),
493
+ ...prefix === undefined ? {} : { prefix }
494
+ }),
495
+ readText: (mount, path) => host.call("artifacts.read", { op: "readText", mount: artifactMountId(mount), path }),
496
+ imageUrl: (mount, path) => host.call("artifacts.read", { op: "imageUrl", mount: artifactMountId(mount), path })
497
+ };
498
+ return { artifacts, commands, settings };
406
499
  };
407
500
  // src/extensions/when.ts
408
501
  var matchesResourceWhen = (when, resourceType) => {
@@ -418,21 +511,30 @@ export {
418
511
  workbenchSlots,
419
512
  workbenchResourceKinds,
420
513
  workbenchResourceKindDefinitions,
514
+ workbenchPanels,
515
+ workbenchPanelDefinitions,
516
+ workbenchPages,
517
+ workbenchPageDefinitions,
421
518
  workbenchModes,
422
- workbenchCommands,
519
+ workbenchModeDefinitions,
423
520
  unwrapCommandOutcome,
424
521
  sessionSlots,
425
522
  sessionEvents,
426
- resourceSlotRef,
427
523
  resourceMenuSlotRef2 as resourceMenuSlotRef,
524
+ resourceKey,
525
+ qualifyRef,
428
526
  projectSlots,
429
527
  projectEvents,
430
528
  params,
431
529
  packageAsset,
432
530
  matchesResourceWhen,
531
+ localContributionIdPattern,
532
+ localContributionIdGrammar,
433
533
  l10n,
534
+ isValidLocalContributionId,
434
535
  isLocalizedString,
435
536
  gitEvents,
537
+ extensionPanelRegions,
436
538
  eventRef,
437
539
  dockedWorkbenchRegions,
438
540
  defineWorkspaceType,
@@ -448,10 +550,11 @@ export {
448
550
  defineSettingsSection,
449
551
  defineSettingsPanel,
450
552
  defineSchedule,
451
- defineResourceView,
452
553
  defineResourceKind,
453
554
  defineResourceHierarchyProvider,
454
555
  definePlacement,
556
+ definePage,
557
+ defineNavigationTree,
455
558
  defineNavigationItem,
456
559
  defineMode,
457
560
  defineMiddleware,
@@ -470,9 +573,13 @@ export {
470
573
  createTerminalSessionBridge,
471
574
  commandRef,
472
575
  commandEvent,
576
+ artifactsRead,
577
+ artifactMountId,
578
+ WEBVIEW_SCOPED_DECLARABLE_CAPABILITIES,
473
579
  WEBVIEW_HOST_CAPABILITY_VERSION,
474
580
  WEBVIEW_HOST_CAPABILITIES,
475
581
  WEBVIEW_DECLARABLE_CAPABILITIES,
582
+ SDK_VERSION,
476
583
  EXTENSION_API_VERSION,
477
584
  ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES
478
585
  };
@@ -17,12 +17,13 @@ var __export = (target, all) => {
17
17
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
18
18
  var useCommandQuery = (input) => {
19
19
  const { command, enabled, queryKey, staleTime } = input;
20
- return useQuery({
20
+ const query = useQuery({
21
21
  queryKey,
22
22
  enabled,
23
23
  staleTime,
24
24
  queryFn: () => command()
25
25
  });
26
+ return query;
26
27
  };
27
28
  var useCommandMutation = (input) => {
28
29
  const { command, invalidate } = input;
@@ -1,16 +1,23 @@
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 {};
1
+ import { QueryKey } from '@tanstack/react-query';
2
+ import { UseMutationResult } from '@tanstack/react-query';
3
+ import { UseQueryResult } from '@tanstack/react-query';
4
+
5
+ declare interface CommandMutationInput<TParams, TResult> {
6
+ command: (params: TParams) => Promise<TResult>;
7
+ invalidate?: QueryKey[];
8
+ }
9
+
10
+ declare interface CommandQueryInput<TResult> {
11
+ queryKey: QueryKey;
12
+ command: () => Promise<TResult>;
13
+ enabled?: boolean;
14
+ staleTime?: number;
15
+ }
16
+
17
+ /** Writes server state via a typed client command and refreshes affected queries on success. */
18
+ export declare const useCommandMutation: <TParams, TResult>(input: CommandMutationInput<TParams, TResult>) => UseMutationResult<TResult, Error, TParams, unknown>;
19
+
20
+ /** Reads server state via a typed client command, cached and deduped by react-query. */
21
+ export declare const useCommandQuery: <TResult>(input: CommandQueryInput<TResult>) => UseQueryResult<TResult>;
22
+
23
+ export { }