@pstdio/sdk 0.17.0 → 0.19.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.
@@ -1,6 +1,12 @@
1
- import type { CreateWorkspaceInput as ContractCreateWorkspaceInput, ListWorkspaceActivityInput as ContractListWorkspaceActivityInput, ListWorkspaceActivityResponse as ContractListWorkspaceActivityResponse, RemoveWorktreeResponse as ContractRemoveWorktreeResponse, RenameWorkspaceInput as ContractRenameWorkspaceInput } from "pstdio-api-contracts";
1
+ import type { CreateWorkspaceInput as ContractCreateWorkspaceInput, ListWorkspaceActivityInput as ContractListWorkspaceActivityInput, ListWorkspaceActivityResponse as ContractListWorkspaceActivityResponse, ListWorkspaceFilesInput as ContractListWorkspaceFilesInput, MoveWorkspaceEntryInput as ContractMoveWorkspaceEntryInput, RemoveWorktreeResponse as ContractRemoveWorktreeResponse, RenameWorkspaceInput as ContractRenameWorkspaceInput, WorkspaceFileContent as ContractWorkspaceFileContent, WorkspaceFileEntry as ContractWorkspaceFileEntry, WorkspaceFilesResponse as ContractWorkspaceFilesResponse, WriteWorkspaceFileInput as ContractWriteWorkspaceFileInput } from "pstdio-api-contracts";
2
2
  export type CreateWorkspaceInput = ContractCreateWorkspaceInput;
3
3
  export type ListWorkspaceActivityInput = ContractListWorkspaceActivityInput;
4
4
  export type ListWorkspaceActivityResponse = ContractListWorkspaceActivityResponse;
5
5
  export type RemoveWorktreeResponse = ContractRemoveWorktreeResponse;
6
6
  export type RenameWorkspaceInput = ContractRenameWorkspaceInput;
7
+ export type ListWorkspaceFilesInput = ContractListWorkspaceFilesInput;
8
+ export type MoveWorkspaceEntryInput = ContractMoveWorkspaceEntryInput;
9
+ export type WorkspaceFileContent = ContractWorkspaceFileContent;
10
+ export type WorkspaceFileEntry = ContractWorkspaceFileEntry;
11
+ export type WorkspaceFilesResponse = ContractWorkspaceFilesResponse;
12
+ export type WriteWorkspaceFileInput = ContractWriteWorkspaceFileInput;
@@ -281,6 +281,8 @@ var buildSessionsQuery = (projectId, input = {}) => {
281
281
  params.append("status", input.status);
282
282
  if (input.agent)
283
283
  params.append("agent", input.agent);
284
+ if (input.workspaceId)
285
+ params.append("workspace_id", input.workspaceId);
284
286
  if (input.archived)
285
287
  params.append("archived", "true");
286
288
  return params.toString();
@@ -530,6 +532,55 @@ var createTemplateClient = (request) => ({
530
532
 
531
533
  // src/client/workspaces.ts
532
534
  var createWorkspaceClient = (request) => ({
535
+ listFiles: (workspaceId, input = {}) => {
536
+ const params = new URLSearchParams;
537
+ if (input.path !== undefined)
538
+ params.append("path", input.path);
539
+ if (input.query !== undefined)
540
+ params.append("query", input.query);
541
+ if (input.limit !== undefined)
542
+ params.append("limit", String(input.limit));
543
+ const query = params.toString();
544
+ return request(`/v1/workspaces/${encodeURIComponent(workspaceId)}/files${query ? `?${query}` : ""}`);
545
+ },
546
+ readFile: (workspaceId, path) => {
547
+ const params = new URLSearchParams({ path });
548
+ return request(`/v1/workspaces/${encodeURIComponent(workspaceId)}/file?${params.toString()}`);
549
+ },
550
+ createDirectory: (workspaceId, path) => {
551
+ const params = new URLSearchParams({ path });
552
+ return request(`/v1/workspaces/${encodeURIComponent(workspaceId)}/directory?${params.toString()}`, {
553
+ method: "POST"
554
+ });
555
+ },
556
+ createFile: (workspaceId, path, input) => {
557
+ const params = new URLSearchParams({ path });
558
+ return request(`/v1/workspaces/${encodeURIComponent(workspaceId)}/file?${params.toString()}`, {
559
+ method: "POST",
560
+ body: input
561
+ });
562
+ },
563
+ writeFile: (workspaceId, path, input) => {
564
+ const params = new URLSearchParams({ path });
565
+ return request(`/v1/workspaces/${encodeURIComponent(workspaceId)}/file?${params.toString()}`, {
566
+ method: "PUT",
567
+ body: input
568
+ });
569
+ },
570
+ moveEntry: (workspaceId, path, destinationPath) => {
571
+ const params = new URLSearchParams({ path });
572
+ const body = { destination_path: destinationPath };
573
+ return request(`/v1/workspaces/${encodeURIComponent(workspaceId)}/entry?${params.toString()}`, {
574
+ method: "PATCH",
575
+ body
576
+ });
577
+ },
578
+ deleteEntry: (workspaceId, path) => {
579
+ const params = new URLSearchParams({ path });
580
+ return request(`/v1/workspaces/${encodeURIComponent(workspaceId)}/entry?${params.toString()}`, {
581
+ method: "DELETE"
582
+ });
583
+ },
533
584
  listActivity: (workspaceId, input = {}) => {
534
585
  const params = new URLSearchParams;
535
586
  if (input.event_type)
@@ -5,6 +5,7 @@ import { type SseEvent } from "./sse";
5
5
  export type ListSessionsInput = {
6
6
  status?: string;
7
7
  agent?: string;
8
+ workspaceId?: string;
8
9
  archived?: boolean;
9
10
  };
10
11
  export type SessionClient = {
@@ -1,4 +1,4 @@
1
- import type { CreateWorkspaceInput, ListWorkspaceActivityInput, ListWorkspaceActivityResponse, RemoveWorktreeResponse, RenameWorkspaceInput } from "pstdio-api-contracts";
1
+ import type { CreateWorkspaceInput, ListWorkspaceActivityInput, ListWorkspaceActivityResponse, ListWorkspaceFilesInput, RemoveWorktreeResponse, RenameWorkspaceInput, WorkspaceFileContent, WorkspaceFileEntry, WorkspaceFilesResponse, WriteWorkspaceFileInput } from "pstdio-api-contracts";
2
2
  import type { Workspace, WorkspaceListItem } from "../resources";
3
3
  import type { RequestFn } from "./request";
4
4
  export type WorkspaceClient = {
@@ -7,6 +7,13 @@ export type WorkspaceClient = {
7
7
  create(input: CreateWorkspaceInput): Promise<Workspace>;
8
8
  rename(workspaceId: string, input: RenameWorkspaceInput): Promise<Workspace>;
9
9
  listActivity(workspaceId: string, input?: ListWorkspaceActivityInput): Promise<ListWorkspaceActivityResponse>;
10
+ listFiles(workspaceId: string, input?: ListWorkspaceFilesInput): Promise<WorkspaceFilesResponse>;
11
+ createDirectory(workspaceId: string, path: string): Promise<WorkspaceFileEntry>;
12
+ createFile(workspaceId: string, path: string, input: WriteWorkspaceFileInput): Promise<WorkspaceFileContent>;
13
+ readFile(workspaceId: string, path: string): Promise<WorkspaceFileContent>;
14
+ writeFile(workspaceId: string, path: string, input: WriteWorkspaceFileInput): Promise<WorkspaceFileContent>;
15
+ moveEntry(workspaceId: string, path: string, destinationPath: string): Promise<void>;
16
+ deleteEntry(workspaceId: string, path: string): Promise<void>;
10
17
  removeWorktree(workspaceId: string): Promise<RemoveWorktreeResponse>;
11
18
  delete(workspaceId: string): Promise<void>;
12
19
  };
@@ -42,8 +42,7 @@ type ExtensionAuthoringDefinition<TCommandSchemas extends CommandSchemas, TMiddl
42
42
  };
43
43
  /**
44
44
  * Identity helper that types the passed contributions. Authors get autocomplete on
45
- * contributions, and `commandsOf(packageName, ext)` can derive typed refs from the
46
- * returned definition. Extension identity (id, name, version, description, publisher,
45
+ * contributions. Extension identity (id, name, version, description, publisher,
47
46
  * engines.pstdio) lives in package.json.
48
47
  *
49
48
  * @example
@@ -1,12 +1,12 @@
1
1
  export type { CreateNotificationInput, ListNotificationsQuery, ListNotificationsResponse, Notification, NotificationAction, NotificationActionResult, NotificationActorType, NotificationKind, NotificationOrigin, NotificationPriority, NotificationStatus, UpdateNotificationInput, } from "pstdio-api-contracts";
2
2
  export type * from "pstdio-api-contracts/extension-kernel";
3
3
  export type { CommitPayload, ConflictPayload, MergePayload, RebasePayload, SessionLifecyclePayload, WorkspaceProvisionPayload, WorkspaceType, WorktreeRemovedPayload, } from "pstdio-api-contracts/extension-kernel";
4
- export { ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES, EXTENSION_API_VERSION, getWorkbenchModeLayoutTargetPanel, 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 WorkbenchModePanel, type WorkbenchSettingsScope, type WorkbenchSettingsTarget, type WorkbenchTargetDefinition, type WorkbenchTargetGranularity, type WorkbenchTreeTarget, type WorkbenchViewTarget, workbenchMenuTargets, workbenchModeLayoutTargets, workbenchModePanels, workbenchSettingsScopes, workbenchSettingsTargets, workbenchTargets, workbenchTreeTargets, workbenchViewTargets, workspaceEvents, workspaceSlots, worktreeEvents, } from "pstdio-api-contracts/extension-kernel";
4
+ export { ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES, dockedWorkbenchRegions, EXTENSION_API_VERSION, getWorkbenchModeLayoutTargetPanel, 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 WorkbenchModePanel, type WorkbenchSettingsScope, type WorkbenchSettingsTarget, type WorkbenchTargetDefinition, type WorkbenchTargetGranularity, type WorkbenchTreeTarget, type WorkbenchViewTarget, workbenchMenuTargets, workbenchModeLayoutTargets, workbenchModePanels, workbenchSettingsScopes, workbenchSettingsTargets, workbenchTargets, workbenchTreeTargets, workbenchViewTargets, workspaceEvents, workspaceSlots, worktreeEvents, } from "pstdio-api-contracts/extension-kernel";
5
5
  export { type CommandResponse, unwrapCommandOutcome } from "./command-outcome";
6
6
  export { defineCommand, defineHook, defineMiddleware } from "./define-command";
7
7
  export { defineExtension } from "./define-extension";
8
8
  export { defineExtensionView, type ExtensionViewModule, type ExtensionViewRender, type ExtensionViewRenderContext, type GuestHost, type PropsStore, type WebviewFilesClient, } from "./define-extension-view";
9
9
  export { params } from "./params";
10
- export { commandEvent, commandRef, commandsOf, eventRef } from "./refs";
10
+ export { commandEvent, commandRef, eventRef } from "./refs";
11
11
  export { createTerminalSessionBridge, type TerminalSessionAdapter, type TerminalSessionBridge, type TerminalSessionExit, } from "./terminal-session-bridge";
12
12
  export { matchesResourceWhen } from "./when";
@@ -82,8 +82,10 @@ var packageAsset = (path, baseUrl) => ({
82
82
  path,
83
83
  baseUrl
84
84
  });
85
+ // ../pstdio-api-contracts/src/extension-kernel/types/composition.ts
86
+ var dockedWorkbenchRegions = ["sidenav", "main", "secondary", "side"];
85
87
  // ../pstdio-api-contracts/src/extension-kernel/types/extension.ts
86
- var EXTENSION_API_VERSION = "1.0.0";
88
+ var EXTENSION_API_VERSION = "1.0.0-alpha.2";
87
89
  // ../pstdio-api-contracts/src/extension-kernel/types/webview-capabilities.ts
88
90
  var WEBVIEW_HOST_CAPABILITY_VERSION = 1;
89
91
  var WEBVIEW_DECLARABLE_CAPABILITIES = [
@@ -303,14 +305,6 @@ var params = {
303
305
  var commandEvent = (command, phase) => ({
304
306
  id: `command.${phase}:${command.id}`
305
307
  });
306
- var commandsOf = (packageName, extension) => {
307
- const refs = {};
308
- const commands = extension.commands ?? {};
309
- for (const key of Object.keys(commands)) {
310
- refs[key] = { id: `${packageName}.${key}` };
311
- }
312
- return refs;
313
- };
314
308
  // src/extensions/terminal-session-bridge.ts
315
309
  var TERMINAL_SESSION_CAPABILITY = "terminal.session";
316
310
  var createTerminalSessionBridge = (host) => ({
@@ -416,13 +410,13 @@ export {
416
410
  getWorkbenchTargetDefinition,
417
411
  getWorkbenchModeLayoutTargetPanel,
418
412
  eventRef,
413
+ dockedWorkbenchRegions,
419
414
  defineMiddleware,
420
415
  defineHook,
421
416
  defineExtensionView,
422
417
  defineExtension,
423
418
  defineCommand,
424
419
  createTerminalSessionBridge,
425
- commandsOf,
426
420
  commandRef,
427
421
  commandEvent,
428
422
  WEBVIEW_HOST_CAPABILITY_VERSION,
@@ -1,4 +1,4 @@
1
- import type { CommandDefinition, CommandLifecycleEventPayload, CommandLifecyclePhase, CommandRef, EventRef, ParamObjectSchema, ParamsOf, Struct } from "pstdio-api-contracts/extension-kernel";
1
+ import type { CommandLifecycleEventPayload, CommandLifecyclePhase, CommandRef, EventRef, Struct } from "pstdio-api-contracts/extension-kernel";
2
2
  export { commandRef, eventRef } from "pstdio-api-contracts/extension-kernel";
3
3
  /**
4
4
  * Build an `EventRef` for a command lifecycle phase (`requested`, `started`, `completed`,
@@ -6,23 +6,3 @@ export { commandRef, eventRef } from "pstdio-api-contracts/extension-kernel";
6
6
  * the correct shape.
7
7
  */
8
8
  export declare const commandEvent: <TPhase extends CommandLifecyclePhase, TParams extends Struct = Struct, TResult = unknown>(command: CommandRef<TParams, TResult>, phase: TPhase) => EventRef<CommandLifecycleEventPayload<TPhase, TParams, TResult>>;
9
- type CommandsRecord = Record<string, CommandDefinition<any, any, any>>;
10
- type CommandRefFromDefinition<TDefinition> = TDefinition extends CommandDefinition<infer TSchema, infer TResult, infer _TSettings> ? CommandRef<TSchema extends ParamObjectSchema ? ParamsOf<TSchema> : Struct, TResult> : never;
11
- type CommandsRefMap<TCommands extends CommandsRecord> = {
12
- [K in keyof TCommands]: CommandRefFromDefinition<TCommands[K]>;
13
- };
14
- /**
15
- * Derive typed `CommandRef`s from an extension contribution object. Renaming a
16
- * command in the definition surfaces as a type error wherever the ref is used.
17
- *
18
- * The package name is explicit because identity now lives in package.json, not in
19
- * `defineExtension()`.
20
- *
21
- * @example
22
- * const ext = defineExtension({ commands: { ... } });
23
- * const labCommands = commandsOf("extension-lab", ext);
24
- * labCommands.awaken; // CommandRef<{ title?: string }, ...>
25
- */
26
- export declare const commandsOf: <TExtension extends {
27
- commands?: CommandsRecord;
28
- }>(packageName: string, extension: TExtension) => CommandsRefMap<NonNullable<TExtension["commands"]>>;