@pstdio/sdk 0.18.0 → 0.20.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.
- package/dist/api/extensions.d.ts +1 -1
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.js +53 -1
- package/dist/api/workspaces.d.ts +7 -1
- package/dist/client/index.js +49 -0
- package/dist/client/workspaces.d.ts +8 -1
- package/dist/extensions/define-extension-view.d.ts +2 -0
- package/dist/extensions/define-extension.d.ts +1 -1
- package/dist/extensions/index.d.ts +1 -0
- package/dist/extensions/index.js +30 -0
- package/dist/extensions/react/index.d.ts +16 -0
- package/dist/extensions/react/index.js +38 -0
- package/dist/extensions/webview-client.d.ts +41 -0
- package/dist/resources/index.js +53 -1
- package/package.json +22 -3
package/dist/api/extensions.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { AttemptExtensionFixResponse, CommandExecuteRequest, CommandExecuteResponse, ExtensionCommandPaletteContribution, ExtensionCommandPaletteResourceRecord, ExtensionCommandRecord, ExtensionControlsRendererRecord, ExtensionDataTableRendererRecord, ExtensionDiagnostic, ExtensionKanbanRendererRecord, ExtensionKeybindingRecord, ExtensionMenuContribution, ExtensionModeRecord, ExtensionPanelRecord, ExtensionRecord, ExtensionRouteRecord, ExtensionSettingDefinitionRecord, ExtensionSettingsPanelRecord, ExtensionSettingValueRecord, ExtensionTreeItemContribution, ExtensionTreeRendererRecord, ListExtensionAppearanceResponse, ListExtensionCommandsResponse, ListExtensionSettingsResponse, ListProjectExtensionsResponse, LocalizableString, ProjectExtensionInstance, UpdateExtensionSettingRequest, UpdateInstalledExtensionTemplateInput, UpdateInstalledExtensionTemplateResponse, WorkbenchExtensionAutomationRecord, WorkbenchExtensionCommandPaletteResourceRecord, WorkbenchExtensionControlsRendererRecord, WorkbenchExtensionDataTableRendererRecord, WorkbenchExtensionHarnessRecord, WorkbenchExtensionKanbanRendererRecord, WorkbenchExtensionMetadata, WorkbenchExtensionPanelRecord, WorkbenchExtensionTreeRendererRecord, WorkbenchExtensionViewRecord, } from "pstdio-api-contracts";
|
|
1
|
+
export type { AttemptExtensionFixResponse, CommandExecuteRequest, CommandExecuteResponse, ExtensionCommandPaletteContribution, ExtensionCommandPaletteResourceRecord, ExtensionCommandRecord, ExtensionControlsRendererRecord, ExtensionDataTableRendererRecord, ExtensionDiagnostic, ExtensionKanbanRendererRecord, ExtensionKeybindingRecord, ExtensionMenuContribution, ExtensionModeRecord, ExtensionPanelRecord, ExtensionRecord, ExtensionRouteRecord, ExtensionSettingDefinitionRecord, ExtensionSettingsPanelRecord, ExtensionSettingValueRecord, ExtensionTreeItemContribution, ExtensionTreeRendererRecord, InstallMarketplaceExtensionResponse, ListExtensionAppearanceResponse, ListExtensionCommandsResponse, ListExtensionSettingsResponse, ListProjectExtensionsResponse, LocalizableString, MarketplaceExtension, ProjectExtensionInstance, UpdateExtensionSettingRequest, UpdateInstalledExtensionTemplateInput, UpdateInstalledExtensionTemplateResponse, UpgradeProjectExtensionResponse, WorkbenchExtensionAutomationRecord, WorkbenchExtensionCommandPaletteResourceRecord, WorkbenchExtensionControlsRendererRecord, WorkbenchExtensionDataTableRendererRecord, WorkbenchExtensionHarnessRecord, WorkbenchExtensionKanbanRendererRecord, WorkbenchExtensionMetadata, WorkbenchExtensionPanelRecord, WorkbenchExtensionTreeRendererRecord, WorkbenchExtensionViewRecord, } from "pstdio-api-contracts";
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { CreateNotificationInput, ListNotificationsQuery, ListNotificationsResponse, Notification, NotificationAction, NotificationActionResult, NotificationActorType, NotificationKind, NotificationOrigin, NotificationPriority, NotificationStatus, ResourceRef, UpdateNotificationInput, } from "pstdio-api-contracts";
|
|
2
|
-
export type { AttemptExtensionFixResponse, CommandExecuteRequest, CommandExecuteResponse, ExtensionCommandPaletteContribution, ExtensionCommandPaletteResourceRecord, ExtensionCommandRecord, ExtensionControlsRendererRecord, ExtensionDataTableRendererRecord, ExtensionDiagnostic, ExtensionKanbanRendererRecord, ExtensionKeybindingRecord, ExtensionMenuContribution, ExtensionModeRecord, ExtensionPanelRecord, ExtensionRecord, ExtensionRouteRecord, ExtensionSettingDefinitionRecord, ExtensionSettingsPanelRecord, ExtensionSettingValueRecord, ExtensionTreeItemContribution, ExtensionTreeRendererRecord, ListExtensionAppearanceResponse, ListExtensionCommandsResponse, ListExtensionSettingsResponse, ListProjectExtensionsResponse, LocalizableString, ProjectExtensionInstance, UpdateExtensionSettingRequest, UpdateInstalledExtensionTemplateInput, UpdateInstalledExtensionTemplateResponse, WorkbenchExtensionAutomationRecord, WorkbenchExtensionCommandPaletteResourceRecord, WorkbenchExtensionControlsRendererRecord, WorkbenchExtensionDataTableRendererRecord, WorkbenchExtensionHarnessRecord, WorkbenchExtensionKanbanRendererRecord, WorkbenchExtensionMetadata, WorkbenchExtensionPanelRecord, WorkbenchExtensionTreeRendererRecord, WorkbenchExtensionViewRecord, } from "./extensions";
|
|
2
|
+
export type { AttemptExtensionFixResponse, CommandExecuteRequest, CommandExecuteResponse, ExtensionCommandPaletteContribution, ExtensionCommandPaletteResourceRecord, ExtensionCommandRecord, ExtensionControlsRendererRecord, ExtensionDataTableRendererRecord, ExtensionDiagnostic, ExtensionKanbanRendererRecord, ExtensionKeybindingRecord, ExtensionMenuContribution, ExtensionModeRecord, ExtensionPanelRecord, ExtensionRecord, ExtensionRouteRecord, ExtensionSettingDefinitionRecord, ExtensionSettingsPanelRecord, ExtensionSettingValueRecord, ExtensionTreeItemContribution, ExtensionTreeRendererRecord, InstallMarketplaceExtensionResponse, ListExtensionAppearanceResponse, ListExtensionCommandsResponse, ListExtensionSettingsResponse, ListProjectExtensionsResponse, LocalizableString, MarketplaceExtension, ProjectExtensionInstance, UpdateExtensionSettingRequest, UpdateInstalledExtensionTemplateInput, UpdateInstalledExtensionTemplateResponse, UpgradeProjectExtensionResponse, WorkbenchExtensionAutomationRecord, WorkbenchExtensionCommandPaletteResourceRecord, WorkbenchExtensionControlsRendererRecord, WorkbenchExtensionDataTableRendererRecord, WorkbenchExtensionHarnessRecord, WorkbenchExtensionKanbanRendererRecord, WorkbenchExtensionMetadata, WorkbenchExtensionPanelRecord, WorkbenchExtensionTreeRendererRecord, WorkbenchExtensionViewRecord, } from "./extensions";
|
|
3
3
|
export type { CreateProjectInput, RegisterRepoInput } from "./projects";
|
|
4
4
|
export type { ApprovalInput, CreateSessionInput, FollowUpInput, ResolveSessionIdInput, ResolveSessionIdResponse, SessionAttachment, SessionAttachmentRef, SessionConversationResponse, } from "./sessions";
|
|
5
5
|
export { sessionAttachmentMimeTypesByExtension } from "./sessions";
|
|
@@ -7,4 +7,4 @@ export type { Settings, UpdateSettingsInput } from "./settings";
|
|
|
7
7
|
export type { UpdateSkillInput } from "./skills";
|
|
8
8
|
export type { CreateTemplateInput, UpdateTemplateInput } from "./templates";
|
|
9
9
|
export type { TerminalHostEvent, TerminalSessionOperation, TerminalSessionRequest, TerminalSessionResult, } from "./terminal";
|
|
10
|
-
export type { CreateWorkspaceInput, RemoveWorktreeResponse, RenameWorkspaceInput } from "./workspaces";
|
|
10
|
+
export type { CreateWorkspaceInput, ListWorkspaceFilesInput, RemoveWorktreeResponse, RenameWorkspaceInput, WorkspaceFileContent, WorkspaceFileEntry, WorkspaceFilesResponse, WriteWorkspaceFileInput, } from "./workspaces";
|
package/dist/api/index.js
CHANGED
|
@@ -14168,6 +14168,8 @@ var extensionRendererRecordBaseSchema = exports_external.object({
|
|
|
14168
14168
|
emptyDescription: localizableStringSchema.optional()
|
|
14169
14169
|
});
|
|
14170
14170
|
var extensionTreeRendererRecordSchema = extensionRendererRecordBaseSchema.extend({
|
|
14171
|
+
searchable: exports_external.boolean().optional(),
|
|
14172
|
+
searchPlaceholder: localizableStringSchema.optional(),
|
|
14171
14173
|
bodyHandlerId: exports_external.string(),
|
|
14172
14174
|
childrenHandlerId: exports_external.string().optional(),
|
|
14173
14175
|
footerHandlerId: exports_external.string().optional(),
|
|
@@ -14664,10 +14666,18 @@ var projectExtensionInstanceSchema = exports_external.object({
|
|
|
14664
14666
|
lastError: jsonObjectSchema.nullable().optional(),
|
|
14665
14667
|
enabled: exports_external.boolean(),
|
|
14666
14668
|
config: exports_external.record(exports_external.string(), exports_external.unknown()),
|
|
14669
|
+
canUpgrade: exports_external.boolean(),
|
|
14667
14670
|
updateAvailable: exports_external.boolean()
|
|
14668
14671
|
});
|
|
14672
|
+
var marketplaceExtensionSchema = exports_external.object({
|
|
14673
|
+
installName: exports_external.string(),
|
|
14674
|
+
displayName: exports_external.string(),
|
|
14675
|
+
description: exports_external.string(),
|
|
14676
|
+
installed: exports_external.boolean()
|
|
14677
|
+
});
|
|
14669
14678
|
var listProjectExtensionsResponseSchema = exports_external.object({
|
|
14670
|
-
extensions: exports_external.array(projectExtensionInstanceSchema)
|
|
14679
|
+
extensions: exports_external.array(projectExtensionInstanceSchema),
|
|
14680
|
+
marketplace: exports_external.array(marketplaceExtensionSchema)
|
|
14671
14681
|
});
|
|
14672
14682
|
var setProjectExtensionEnabledRequestSchema = exports_external.object({
|
|
14673
14683
|
enabled: exports_external.boolean()
|
|
@@ -14679,6 +14689,13 @@ var attemptExtensionFixResponseSchema = exports_external.object({
|
|
|
14679
14689
|
sessionId: exports_external.string(),
|
|
14680
14690
|
title: exports_external.string()
|
|
14681
14691
|
});
|
|
14692
|
+
var upgradeProjectExtensionResponseSchema = exports_external.object({
|
|
14693
|
+
changed: exports_external.boolean(),
|
|
14694
|
+
extension: projectExtensionInstanceSchema
|
|
14695
|
+
});
|
|
14696
|
+
var installMarketplaceExtensionResponseSchema = exports_external.object({
|
|
14697
|
+
extension: projectExtensionInstanceSchema
|
|
14698
|
+
});
|
|
14682
14699
|
var updateInstalledExtensionTemplateInputSchema = exports_external.object({
|
|
14683
14700
|
content: exports_external.string().min(1)
|
|
14684
14701
|
});
|
|
@@ -15110,6 +15127,41 @@ var renameWorkspaceInputSchema = exports_external.object({
|
|
|
15110
15127
|
var removeWorktreeResponseSchema = exports_external.object({
|
|
15111
15128
|
removed: exports_external.boolean()
|
|
15112
15129
|
});
|
|
15130
|
+
var workspaceFileEntrySchema = exports_external.object({
|
|
15131
|
+
path: exports_external.string(),
|
|
15132
|
+
name: exports_external.string(),
|
|
15133
|
+
type: exports_external.enum(["file", "directory"]),
|
|
15134
|
+
size: exports_external.number().int().nonnegative().optional(),
|
|
15135
|
+
modified_at: exports_external.string().optional()
|
|
15136
|
+
});
|
|
15137
|
+
var workspaceFilesResponseSchema = exports_external.object({
|
|
15138
|
+
workspace_id: exports_external.string(),
|
|
15139
|
+
path: exports_external.string(),
|
|
15140
|
+
entries: exports_external.array(workspaceFileEntrySchema),
|
|
15141
|
+
truncated: exports_external.boolean()
|
|
15142
|
+
});
|
|
15143
|
+
var workspaceFileContentSchema = exports_external.object({
|
|
15144
|
+
workspace_id: exports_external.string(),
|
|
15145
|
+
path: exports_external.string(),
|
|
15146
|
+
file_name: exports_external.string(),
|
|
15147
|
+
mime_type: exports_external.string().optional(),
|
|
15148
|
+
size: exports_external.number().int().nonnegative(),
|
|
15149
|
+
encoding: exports_external.enum(["utf8", "base64"]),
|
|
15150
|
+
content: exports_external.string().optional(),
|
|
15151
|
+
data_url: exports_external.string().optional(),
|
|
15152
|
+
editable: exports_external.boolean()
|
|
15153
|
+
});
|
|
15154
|
+
var writeWorkspaceFileInputSchema = exports_external.object({
|
|
15155
|
+
content: exports_external.string()
|
|
15156
|
+
});
|
|
15157
|
+
var moveWorkspaceEntryInputSchema = exports_external.object({
|
|
15158
|
+
destination_path: exports_external.string().min(1)
|
|
15159
|
+
});
|
|
15160
|
+
var listWorkspaceFilesInputSchema = exports_external.object({
|
|
15161
|
+
path: exports_external.string().optional(),
|
|
15162
|
+
query: exports_external.string().optional(),
|
|
15163
|
+
limit: exports_external.number().int().positive().max(500).optional()
|
|
15164
|
+
});
|
|
15113
15165
|
export {
|
|
15114
15166
|
sessionAttachmentMimeTypesByExtension
|
|
15115
15167
|
};
|
package/dist/api/workspaces.d.ts
CHANGED
|
@@ -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;
|
package/dist/client/index.js
CHANGED
|
@@ -532,6 +532,55 @@ var createTemplateClient = (request) => ({
|
|
|
532
532
|
|
|
533
533
|
// src/client/workspaces.ts
|
|
534
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
|
+
},
|
|
535
584
|
listActivity: (workspaceId, input = {}) => {
|
|
536
585
|
const params = new URLSearchParams;
|
|
537
586
|
if (input.event_type)
|
|
@@ -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
|
};
|
|
@@ -12,6 +12,8 @@ export type GuestHost = {
|
|
|
12
12
|
call: <TResult = unknown>(method: string, params?: unknown) => Promise<TResult>;
|
|
13
13
|
/** Subscribe to host-pushed events for a capability scope (e.g. "terminal.session"). */
|
|
14
14
|
onEvent: (scope: string, handler: (payload: unknown) => void) => () => void;
|
|
15
|
+
/** Id of the extension that owns this webview. Missing only on hosts older than the bridge that sends it. */
|
|
16
|
+
extensionId?: string;
|
|
15
17
|
};
|
|
16
18
|
export type PropsStore<TProps = unknown> = {
|
|
17
19
|
get: () => TProps;
|
|
@@ -17,7 +17,7 @@ type SettingValue<TProperty> = TProperty extends {
|
|
|
17
17
|
} ? unknown[] : TProperty extends {
|
|
18
18
|
type: "object";
|
|
19
19
|
} ? Record<string, unknown> : unknown;
|
|
20
|
-
type SettingsMap<TSettings> = TSettings extends {
|
|
20
|
+
export type SettingsMap<TSettings> = TSettings extends {
|
|
21
21
|
properties: infer TProperties;
|
|
22
22
|
} ? {
|
|
23
23
|
[K in keyof TProperties & string]: SettingValue<TProperties[K]>;
|
|
@@ -9,4 +9,5 @@ export { defineExtensionView, type ExtensionViewModule, type ExtensionViewRender
|
|
|
9
9
|
export { params } from "./params";
|
|
10
10
|
export { commandEvent, commandRef, eventRef } from "./refs";
|
|
11
11
|
export { createTerminalSessionBridge, type TerminalSessionAdapter, type TerminalSessionBridge, type TerminalSessionExit, } from "./terminal-session-bridge";
|
|
12
|
+
export { createWebviewClient, type WebviewClient, type WebviewClientOptions, type WebviewCommandsClient, type WebviewSettingsClient, } from "./webview-client";
|
|
12
13
|
export { matchesResourceWhen } from "./when";
|
package/dist/extensions/index.js
CHANGED
|
@@ -377,6 +377,35 @@ var createTerminalSessionBridge = (host) => ({
|
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
379
|
});
|
|
380
|
+
// src/extensions/webview-client.ts
|
|
381
|
+
var createWebviewClient = (host, options) => {
|
|
382
|
+
const extensionId = options?.extensionId ?? host.extensionId;
|
|
383
|
+
if (!extensionId) {
|
|
384
|
+
throw new Error("The host bridge did not provide an extension id. Pass { extensionId } to createWebviewClient.");
|
|
385
|
+
}
|
|
386
|
+
const runCommand = async (commandKey, params2) => {
|
|
387
|
+
const response = await host.call("commands.execute", {
|
|
388
|
+
commandId: `${extensionId}.${commandKey}`,
|
|
389
|
+
params: params2
|
|
390
|
+
});
|
|
391
|
+
return unwrapCommandOutcome(response);
|
|
392
|
+
};
|
|
393
|
+
const commands = new Proxy({}, {
|
|
394
|
+
get: (_target, commandKey) => {
|
|
395
|
+
if (typeof commandKey !== "string")
|
|
396
|
+
return;
|
|
397
|
+
return (params2) => runCommand(commandKey, params2);
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
const settings = {
|
|
401
|
+
all: async () => await host.call("extension.settings.all", {}) ?? {},
|
|
402
|
+
get: (key) => host.call("extension.settings.get", { key }),
|
|
403
|
+
set: async (key, value) => {
|
|
404
|
+
await host.call("extension.settings.set", { key, value });
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
return { commands, settings };
|
|
408
|
+
};
|
|
380
409
|
// src/extensions/when.ts
|
|
381
410
|
var matchesResourceWhen = (when, resourceType) => {
|
|
382
411
|
const resourceTypes = when?.resourceType;
|
|
@@ -416,6 +445,7 @@ export {
|
|
|
416
445
|
defineExtensionView,
|
|
417
446
|
defineExtension,
|
|
418
447
|
defineCommand,
|
|
448
|
+
createWebviewClient,
|
|
419
449
|
createTerminalSessionBridge,
|
|
420
450
|
commandRef,
|
|
421
451
|
commandEvent,
|
|
@@ -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 {};
|
package/dist/resources/index.js
CHANGED
|
@@ -14168,6 +14168,8 @@ var extensionRendererRecordBaseSchema = exports_external.object({
|
|
|
14168
14168
|
emptyDescription: localizableStringSchema.optional()
|
|
14169
14169
|
});
|
|
14170
14170
|
var extensionTreeRendererRecordSchema = extensionRendererRecordBaseSchema.extend({
|
|
14171
|
+
searchable: exports_external.boolean().optional(),
|
|
14172
|
+
searchPlaceholder: localizableStringSchema.optional(),
|
|
14171
14173
|
bodyHandlerId: exports_external.string(),
|
|
14172
14174
|
childrenHandlerId: exports_external.string().optional(),
|
|
14173
14175
|
footerHandlerId: exports_external.string().optional(),
|
|
@@ -14664,10 +14666,18 @@ var projectExtensionInstanceSchema = exports_external.object({
|
|
|
14664
14666
|
lastError: jsonObjectSchema.nullable().optional(),
|
|
14665
14667
|
enabled: exports_external.boolean(),
|
|
14666
14668
|
config: exports_external.record(exports_external.string(), exports_external.unknown()),
|
|
14669
|
+
canUpgrade: exports_external.boolean(),
|
|
14667
14670
|
updateAvailable: exports_external.boolean()
|
|
14668
14671
|
});
|
|
14672
|
+
var marketplaceExtensionSchema = exports_external.object({
|
|
14673
|
+
installName: exports_external.string(),
|
|
14674
|
+
displayName: exports_external.string(),
|
|
14675
|
+
description: exports_external.string(),
|
|
14676
|
+
installed: exports_external.boolean()
|
|
14677
|
+
});
|
|
14669
14678
|
var listProjectExtensionsResponseSchema = exports_external.object({
|
|
14670
|
-
extensions: exports_external.array(projectExtensionInstanceSchema)
|
|
14679
|
+
extensions: exports_external.array(projectExtensionInstanceSchema),
|
|
14680
|
+
marketplace: exports_external.array(marketplaceExtensionSchema)
|
|
14671
14681
|
});
|
|
14672
14682
|
var setProjectExtensionEnabledRequestSchema = exports_external.object({
|
|
14673
14683
|
enabled: exports_external.boolean()
|
|
@@ -14679,6 +14689,13 @@ var attemptExtensionFixResponseSchema = exports_external.object({
|
|
|
14679
14689
|
sessionId: exports_external.string(),
|
|
14680
14690
|
title: exports_external.string()
|
|
14681
14691
|
});
|
|
14692
|
+
var upgradeProjectExtensionResponseSchema = exports_external.object({
|
|
14693
|
+
changed: exports_external.boolean(),
|
|
14694
|
+
extension: projectExtensionInstanceSchema
|
|
14695
|
+
});
|
|
14696
|
+
var installMarketplaceExtensionResponseSchema = exports_external.object({
|
|
14697
|
+
extension: projectExtensionInstanceSchema
|
|
14698
|
+
});
|
|
14682
14699
|
var updateInstalledExtensionTemplateInputSchema = exports_external.object({
|
|
14683
14700
|
content: exports_external.string().min(1)
|
|
14684
14701
|
});
|
|
@@ -15110,6 +15127,41 @@ var renameWorkspaceInputSchema = exports_external.object({
|
|
|
15110
15127
|
var removeWorktreeResponseSchema = exports_external.object({
|
|
15111
15128
|
removed: exports_external.boolean()
|
|
15112
15129
|
});
|
|
15130
|
+
var workspaceFileEntrySchema = exports_external.object({
|
|
15131
|
+
path: exports_external.string(),
|
|
15132
|
+
name: exports_external.string(),
|
|
15133
|
+
type: exports_external.enum(["file", "directory"]),
|
|
15134
|
+
size: exports_external.number().int().nonnegative().optional(),
|
|
15135
|
+
modified_at: exports_external.string().optional()
|
|
15136
|
+
});
|
|
15137
|
+
var workspaceFilesResponseSchema = exports_external.object({
|
|
15138
|
+
workspace_id: exports_external.string(),
|
|
15139
|
+
path: exports_external.string(),
|
|
15140
|
+
entries: exports_external.array(workspaceFileEntrySchema),
|
|
15141
|
+
truncated: exports_external.boolean()
|
|
15142
|
+
});
|
|
15143
|
+
var workspaceFileContentSchema = exports_external.object({
|
|
15144
|
+
workspace_id: exports_external.string(),
|
|
15145
|
+
path: exports_external.string(),
|
|
15146
|
+
file_name: exports_external.string(),
|
|
15147
|
+
mime_type: exports_external.string().optional(),
|
|
15148
|
+
size: exports_external.number().int().nonnegative(),
|
|
15149
|
+
encoding: exports_external.enum(["utf8", "base64"]),
|
|
15150
|
+
content: exports_external.string().optional(),
|
|
15151
|
+
data_url: exports_external.string().optional(),
|
|
15152
|
+
editable: exports_external.boolean()
|
|
15153
|
+
});
|
|
15154
|
+
var writeWorkspaceFileInputSchema = exports_external.object({
|
|
15155
|
+
content: exports_external.string()
|
|
15156
|
+
});
|
|
15157
|
+
var moveWorkspaceEntryInputSchema = exports_external.object({
|
|
15158
|
+
destination_path: exports_external.string().min(1)
|
|
15159
|
+
});
|
|
15160
|
+
var listWorkspaceFilesInputSchema = exports_external.object({
|
|
15161
|
+
path: exports_external.string().optional(),
|
|
15162
|
+
query: exports_external.string().optional(),
|
|
15163
|
+
limit: exports_external.number().int().positive().max(500).optional()
|
|
15164
|
+
});
|
|
15113
15165
|
export {
|
|
15114
15166
|
harnessLocalId
|
|
15115
15167
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pstdio/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/pufflyai/prompt-studio"
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
"types": "./dist/extensions/index.d.ts",
|
|
30
30
|
"import": "./dist/extensions/index.js"
|
|
31
31
|
},
|
|
32
|
+
"./extensions/react": {
|
|
33
|
+
"types": "./dist/extensions/react/index.d.ts",
|
|
34
|
+
"import": "./dist/extensions/react/index.js"
|
|
35
|
+
},
|
|
32
36
|
"./prompts": {
|
|
33
37
|
"types": "./dist/prompts/index.d.ts",
|
|
34
38
|
"import": "./dist/prompts/index.js"
|
|
@@ -40,7 +44,7 @@
|
|
|
40
44
|
},
|
|
41
45
|
"scripts": {
|
|
42
46
|
"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 --external mustache",
|
|
47
|
+
"build:js": "bun build ./src/api/index.ts ./src/client/index.ts ./src/extensions/index.ts ./src/extensions/react/index.ts ./src/prompts/index.ts ./src/hooks/index.ts ./src/resources/index.ts --outdir ./dist --root ./src --target node --format esm --external mustache --external react --external @tanstack/react-query",
|
|
44
48
|
"build:types": "tsc --project ./tsconfig.build.json",
|
|
45
49
|
"prepack": "bun run build",
|
|
46
50
|
"typecheck": "tsc --noEmit",
|
|
@@ -52,10 +56,25 @@
|
|
|
52
56
|
"dependencies": {
|
|
53
57
|
"mustache": "^4.2.0"
|
|
54
58
|
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@tanstack/react-query": "^5.0.0",
|
|
61
|
+
"react": "^19.0.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@tanstack/react-query": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"react": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
55
71
|
"devDependencies": {
|
|
56
|
-
"@
|
|
72
|
+
"@tanstack/react-query": "^5.90.21",
|
|
73
|
+
"@types/bun": "1.3.13",
|
|
57
74
|
"@types/mustache": "^4.2.6",
|
|
75
|
+
"@types/react": "^19.2.0",
|
|
58
76
|
"pstdio-api-contracts": "workspace:*",
|
|
77
|
+
"react": "^19.0.0",
|
|
59
78
|
"typescript": "6.0.2"
|
|
60
79
|
}
|
|
61
80
|
}
|