@pstdio/sdk 0.20.0 → 0.22.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 (63) hide show
  1. package/README.md +22 -192
  2. package/dist/api/index.js +932 -483
  3. package/dist/api.d.ts +3767 -0
  4. package/dist/client/index.js +21 -14
  5. package/dist/client.d.ts +1714 -0
  6. package/dist/extensions/index.js +262 -140
  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 +3826 -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 +932 -483
  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 -10
  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/templates.d.ts +0 -1
  22. package/dist/api/terminal.d.ts +0 -49
  23. package/dist/api/workspaces.d.ts +0 -12
  24. package/dist/client/agents.d.ts +0 -10
  25. package/dist/client/client.d.ts +0 -26
  26. package/dist/client/extensions.d.ts +0 -12
  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/templates.d.ts +0 -11
  38. package/dist/client/workspaces.d.ts +0 -20
  39. package/dist/extensions/command-outcome.d.ts +0 -5
  40. package/dist/extensions/define-command.d.ts +0 -26
  41. package/dist/extensions/define-extension-view.d.ts +0 -58
  42. package/dist/extensions/define-extension.d.ts +0 -54
  43. package/dist/extensions/index.d.ts +0 -13
  44. package/dist/extensions/params.d.ts +0 -36
  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 -9
  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 -10
  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/template.d.ts +0 -1
  63. package/dist/resources/workspace.d.ts +0 -3
@@ -1,14 +0,0 @@
1
- export type { AgentClient } from "./agents";
2
- export { createClient, type PstdioClient } from "./client";
3
- export type { ExtensionClient } from "./extensions";
4
- export type { NotificationsClient } from "./notifications";
5
- export type { ProjectClient } from "./projects";
6
- export { type ClientOptions, createRequest, PstdioApiError, type RequestFn, type RequestOptions, } from "./request";
7
- export { createRuntimeClient, type RuntimeClient } from "./runtime";
8
- export type { ListSessionsInput, SessionClient, SessionStreamConnection, SessionStreamHandlers } from "./sessions";
9
- export type { SettingsClient } from "./settings";
10
- export type { SkillClient } from "./skills";
11
- export type { SseEvent } from "./sse";
12
- export { applySyncEvent, parseSyncDeleteEvent, type StartSyncInput, type SyncClient, type SyncConnection, type SyncRow, type SyncWriter, type SyncWriterProvider, } from "./sync";
13
- export type { TemplateClient } from "./templates";
14
- export type { WorkspaceClient } from "./workspaces";
@@ -1,23 +0,0 @@
1
- import type { CreateNotificationInput, ListNotificationsQuery, ListNotificationsResponse, Notification, NotificationStatus, UpdateNotificationInput } from "pstdio-api-contracts";
2
- import type { RequestFn } from "./request";
3
- export type NotificationsClient = {
4
- list(projectId: string, query?: ListNotificationsQuery): Promise<ListNotificationsResponse>;
5
- count(projectId: string, query?: Pick<ListNotificationsQuery, "status" | "priority" | "sourceExtensionId">): Promise<{
6
- count: number;
7
- }>;
8
- get(projectId: string, id: string): Promise<Notification>;
9
- create(input: CreateNotificationInput): Promise<Notification>;
10
- update(projectId: string, id: string, input: UpdateNotificationInput): Promise<Notification>;
11
- markRead(projectId: string, id: string): Promise<Notification>;
12
- dismiss(projectId: string, id: string): Promise<Notification>;
13
- markDone(projectId: string, id: string): Promise<Notification>;
14
- snooze(projectId: string, id: string, until: string): Promise<Notification>;
15
- resolveByDedupeKey(projectId: string, input: {
16
- dedupeKey: string;
17
- status?: Extract<NotificationStatus, "done" | "dismissed" | "expired">;
18
- }): Promise<{
19
- resolved: number;
20
- notifications: Notification[];
21
- }>;
22
- };
23
- export declare const createNotificationsClient: (request: RequestFn) => NotificationsClient;
@@ -1,14 +0,0 @@
1
- import type { CreateProjectInput, ListActivityResponse, ListProjectActivityInput, RegisterRepoInput, Repo } from "pstdio-api-contracts";
2
- import type { Project } from "../resources";
3
- import type { RequestFn } from "./request";
4
- export type ProjectClient = {
5
- list(): Promise<Project[]>;
6
- get(projectId: string): Promise<Project>;
7
- create(input: CreateProjectInput): Promise<Project>;
8
- delete(projectId: string): Promise<void>;
9
- listActivity(projectId: string, input?: ListProjectActivityInput): Promise<ListActivityResponse>;
10
- listRepos(projectId: string): Promise<Repo[]>;
11
- registerRepo(projectId: string, input: RegisterRepoInput): Promise<Repo>;
12
- removeRepo(projectId: string, repoId: string): Promise<void>;
13
- };
14
- export declare const createProjectClient: (request: RequestFn) => ProjectClient;
@@ -1,25 +0,0 @@
1
- export type ClientOptions = {
2
- baseUrl?: string;
3
- token?: string;
4
- fetch?: typeof fetch;
5
- };
6
- export declare class PstdioApiError extends Error {
7
- status: number;
8
- constructor(message: string, status: number);
9
- }
10
- export type RequestOptions = {
11
- method?: string;
12
- body?: unknown;
13
- signal?: AbortSignal;
14
- headers?: HeadersInit;
15
- cache?: RequestCache;
16
- };
17
- export type RequestFn = <T>(path: string, options?: RequestOptions) => Promise<T>;
18
- export declare const resolveBaseUrl: (options: ClientOptions) => string;
19
- export declare const resolveClientUrl: (baseUrl: string, path: string) => string;
20
- export declare const resolveFetch: (options: ClientOptions) => typeof fetch;
21
- export declare const createRequestHeaders: (options: ClientOptions, reqOpts?: {
22
- headers?: HeadersInit;
23
- hasJsonBody?: boolean;
24
- }) => Headers;
25
- export declare const createRequest: (options: ClientOptions) => RequestFn;
@@ -1,5 +0,0 @@
1
- import type { RequestFn } from "./request";
2
- export type RuntimeClient = {
3
- provisionBrowserSession: () => Promise<void>;
4
- };
5
- export declare const createRuntimeClient: (request: RequestFn) => RuntimeClient;
@@ -1,45 +0,0 @@
1
- import type { ApprovalInput, CreateSessionInput, FollowUpInput, FollowUpResponse, ListSessionActivityInput, ListSessionActivityResponse, ResolveSessionIdInput, ResolveSessionIdResponse, SessionAttachment, SessionConversationResponse } from "pstdio-api-contracts";
2
- import type { Session } from "../resources";
3
- import { type ClientOptions, type RequestFn } from "./request";
4
- import { type SseEvent } from "./sse";
5
- export type ListSessionsInput = {
6
- status?: string;
7
- agent?: string;
8
- workspaceId?: string;
9
- archived?: boolean;
10
- };
11
- export type SessionClient = {
12
- list(projectId: string, input?: ListSessionsInput): Promise<Session[]>;
13
- get(sessionId: string): Promise<Session>;
14
- uploadAttachment(projectId: string, input: {
15
- name: string;
16
- data: Uint8Array | ArrayBuffer;
17
- mimeType?: string | null;
18
- }): Promise<SessionAttachment>;
19
- deleteAttachment(projectId: string, fileId: string): Promise<void>;
20
- create(input: CreateSessionInput): Promise<Session>;
21
- archive(sessionId: string): Promise<void>;
22
- followUp(sessionId: string, input: FollowUpInput): Promise<FollowUpResponse>;
23
- approve(sessionId: string, input: ApprovalInput): Promise<void>;
24
- getConversation(sessionId: string): Promise<SessionConversationResponse>;
25
- resolveSessionId(input: ResolveSessionIdInput): Promise<ResolveSessionIdResponse>;
26
- updateStatus(sessionId: string, status: string): Promise<Session>;
27
- listActivity(sessionId: string, input?: ListSessionActivityInput): Promise<ListSessionActivityResponse>;
28
- stream(sessionId: string, onEvent: (event: SseEvent) => void, options?: {
29
- signal?: AbortSignal;
30
- }): Promise<void>;
31
- connectStream(sessionId: string, handlers: SessionStreamHandlers, options?: {
32
- attempt?: number;
33
- }): SessionStreamConnection;
34
- };
35
- export type SessionStreamHandlers = {
36
- onReady?: (data: unknown) => void;
37
- onPatch?: (data: unknown) => void;
38
- onApprovalRequest?: (data: unknown) => void;
39
- onEnd?: (data: unknown) => void;
40
- onError?: (error: unknown) => void;
41
- };
42
- export type SessionStreamConnection = {
43
- close: () => void;
44
- };
45
- export declare const createSessionClient: (request: RequestFn, clientOptions: ClientOptions) => SessionClient;
@@ -1,7 +0,0 @@
1
- import type { Settings, UpdateSettingsInput } from "../api/settings";
2
- import type { RequestFn } from "./request";
3
- export type SettingsClient = {
4
- get(): Promise<Settings>;
5
- update(input: UpdateSettingsInput): Promise<Settings>;
6
- };
7
- export declare const createSettingsClient: (request: RequestFn) => SettingsClient;
@@ -1,9 +0,0 @@
1
- import type { UpdateSkillInput } from "../api/skills";
2
- import type { Skill, SkillWithContent } from "../resources";
3
- import type { RequestFn } from "./request";
4
- export type SkillClient = {
5
- list(projectId: string): Promise<Skill[]>;
6
- get(projectId: string, skillId: string): Promise<SkillWithContent>;
7
- updatePreferences(projectId: string, skillName: string, input: UpdateSkillInput): Promise<Skill>;
8
- };
9
- export declare const createSkillClient: (request: RequestFn) => SkillClient;
@@ -1,15 +0,0 @@
1
- export type SseEvent = {
2
- event: string;
3
- data: string;
4
- };
5
- export declare const parseSseEvent: (part: string) => {
6
- event: string;
7
- data: string;
8
- } | null;
9
- export declare const consumeSseBuffer: (buffer: string) => {
10
- remainder: string;
11
- events: SseEvent[];
12
- };
13
- export declare const readSseStream: (body: ReadableStream<Uint8Array>, onEvent: (event: SseEvent) => void, options?: {
14
- signal?: AbortSignal;
15
- }) => Promise<void>;
@@ -1,35 +0,0 @@
1
- import { type ClientOptions } from "./request";
2
- export type SyncRow = {
3
- id: string;
4
- [key: string]: unknown;
5
- };
6
- export type SyncWriter = {
7
- truncateAndWrite: (rows: SyncRow[]) => void;
8
- upsert: (row: SyncRow) => void;
9
- remove: (id: string) => void;
10
- };
11
- export type SyncWriterProvider = {
12
- getWriter: (table: string) => SyncWriter | undefined;
13
- };
14
- export type SyncConnection = {
15
- close: () => void;
16
- connected: boolean;
17
- };
18
- export type StartSyncInput = SyncWriterProvider & {
19
- onConnected?: () => void;
20
- onDisconnected?: () => void;
21
- onConnectionLost?: () => void;
22
- heartbeatIntervalMs?: number;
23
- heartbeatThreshold?: number;
24
- reconnectDelayMs?: number;
25
- };
26
- export type SyncClient = {
27
- start: (input: StartSyncInput) => SyncConnection;
28
- };
29
- export declare const parseSyncDeleteEvent: (data: string) => {
30
- table: string;
31
- id: string;
32
- seq: number;
33
- };
34
- export declare const applySyncEvent: (event: string, data: string, writers: SyncWriterProvider) => number | null;
35
- export declare const createSyncClient: (clientOptions: ClientOptions) => SyncClient;
@@ -1,11 +0,0 @@
1
- import type { CreateTemplateInput, UpdateTemplateInput } from "../api/templates";
2
- import type { Template, TemplateWithContent } from "../resources";
3
- import type { RequestFn } from "./request";
4
- export type TemplateClient = {
5
- list(projectId: string): Promise<Template[]>;
6
- get(projectId: string, templateId: string): Promise<TemplateWithContent>;
7
- create(projectId: string, input: CreateTemplateInput): Promise<Template>;
8
- update(projectId: string, templateId: string, input: UpdateTemplateInput): Promise<Template>;
9
- delete(projectId: string, templateId: string): Promise<void>;
10
- };
11
- export declare const createTemplateClient: (request: RequestFn) => TemplateClient;
@@ -1,20 +0,0 @@
1
- import type { CreateWorkspaceInput, ListWorkspaceActivityInput, ListWorkspaceActivityResponse, ListWorkspaceFilesInput, RemoveWorktreeResponse, RenameWorkspaceInput, WorkspaceFileContent, WorkspaceFileEntry, WorkspaceFilesResponse, WriteWorkspaceFileInput } from "pstdio-api-contracts";
2
- import type { Workspace, WorkspaceListItem } from "../resources";
3
- import type { RequestFn } from "./request";
4
- export type WorkspaceClient = {
5
- list(projectId: string): Promise<WorkspaceListItem[]>;
6
- getByShorthand(projectId: string, shorthand: string): Promise<Workspace>;
7
- create(input: CreateWorkspaceInput): Promise<Workspace>;
8
- rename(workspaceId: string, input: RenameWorkspaceInput): Promise<Workspace>;
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>;
17
- removeWorktree(workspaceId: string): Promise<RemoveWorktreeResponse>;
18
- delete(workspaceId: string): Promise<void>;
19
- };
20
- export declare const createWorkspaceClient: (request: RequestFn) => WorkspaceClient;
@@ -1,5 +0,0 @@
1
- import type { CommandOutcome } from "pstdio-api-contracts/extension-kernel";
2
- export type CommandResponse<TResult = unknown> = {
3
- outcome: CommandOutcome<TResult>;
4
- };
5
- export declare const unwrapCommandOutcome: <TResult>(response: CommandResponse<TResult>, fallbackReason?: string) => TResult;
@@ -1,26 +0,0 @@
1
- import type { CommandDefinition, HookDefinition, MiddlewareDefinition, ParamObjectSchema, Struct } from "pstdio-api-contracts/extension-kernel";
2
- /**
3
- * Define a single command outside an extension's object literal. Use this when commands
4
- * grow large enough to split into separate files, or when you need to share a command
5
- * shape across extensions. The `params` schema drives the inferred shape of `ctx.params`.
6
- *
7
- * @example
8
- * export const sayHello = defineCommand({
9
- * title: "Say hello",
10
- * params: { name: params.text({ required: true }) },
11
- * async run(ctx) {
12
- * ctx.params.name; // string
13
- * },
14
- * });
15
- */
16
- export declare const defineCommand: <const TSchema extends ParamObjectSchema | undefined, TResult = unknown>(definition: CommandDefinition<TSchema, TResult>) => CommandDefinition<TSchema, TResult>;
17
- /**
18
- * Define middleware for a command. Pass the typed `command` ref (preferred) or
19
- * `commandId` for cross-extension references where the typed ref isn't importable.
20
- */
21
- export declare const defineMiddleware: <TParams extends Struct = Struct, TResult = unknown>(definition: MiddlewareDefinition<TParams, TResult>) => MiddlewareDefinition<TParams, TResult>;
22
- /**
23
- * Define a hook for an event. Pass the typed `event` ref (preferred) or `eventId` for
24
- * cross-extension references where the typed ref isn't importable.
25
- */
26
- export declare const defineHook: <TPayload extends Struct = Struct>(definition: HookDefinition<TPayload>) => HookDefinition<TPayload>;
@@ -1,58 +0,0 @@
1
- /**
2
- * Guest-side contract for extension webviews. The host (dashboard) loads a small bridge
3
- * runtime in an iframe, applies theme variables onto the iframe document, then dynamically
4
- * imports the extension's bundled module and calls `view.mount(mount, host, propsStore)`.
5
- *
6
- * Extensions export `defineExtensionView({ render })` as the default export of their entry
7
- * module. `render` receives the mount element, an RPC handle for invoking host capabilities
8
- * (e.g. `host.call("commands.execute", …)`), and a subscribable `propsStore` that the host
9
- * can push updates into.
10
- */
11
- export type GuestHost = {
12
- call: <TResult = unknown>(method: string, params?: unknown) => Promise<TResult>;
13
- /** Subscribe to host-pushed events for a capability scope (e.g. "terminal.session"). */
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;
17
- };
18
- export type PropsStore<TProps = unknown> = {
19
- get: () => TProps;
20
- subscribe: (listener: (props: TProps) => void) => () => void;
21
- };
22
- export interface WebviewFilesClient {
23
- pick(opts?: {
24
- accept?: string;
25
- multiple?: boolean;
26
- }): Promise<File[]>;
27
- upload(input: {
28
- name: string;
29
- data: Uint8Array | ArrayBuffer;
30
- mimeType?: string;
31
- scope?: {
32
- type: string;
33
- id?: string;
34
- };
35
- }): Promise<import("pstdio-api-contracts/extension-kernel").ExtensionBlobRef>;
36
- list(input?: {
37
- scope?: {
38
- type: string;
39
- id?: string;
40
- };
41
- }): Promise<import("pstdio-api-contracts/extension-kernel").ExtensionBlobRef[]>;
42
- delete(id: string): Promise<void>;
43
- }
44
- export type ExtensionViewRenderContext<TProps = unknown> = {
45
- mount: HTMLElement;
46
- host: GuestHost;
47
- files: WebviewFilesClient;
48
- propsStore: PropsStore<TProps>;
49
- locale: string;
50
- t: (key: string, defaultValue?: string, args?: Record<string, unknown>) => string;
51
- };
52
- export type ExtensionViewRender<TProps = unknown> = (context: ExtensionViewRenderContext<TProps>) => void | (() => void) | Promise<void | (() => void)>;
53
- export type ExtensionViewModule<TProps = unknown> = {
54
- mount: (mount: HTMLElement, host: GuestHost, propsStore: PropsStore<TProps>) => Promise<() => void> | (() => void) | void;
55
- };
56
- export declare const defineExtensionView: <TProps = unknown>(definition: {
57
- render: ExtensionViewRender<TProps>;
58
- }) => ExtensionViewModule<TProps>;
@@ -1,54 +0,0 @@
1
- import type { CommandDefinition, ExtensionDefinition, ExtensionSettingProperty, ExtensionSettingsContribution, HookDefinition, MiddlewareDefinition, ParamObjectSchema, ScheduleContribution, Struct } from "pstdio-api-contracts/extension-kernel";
2
- type CommandSchemas = Record<string, ParamObjectSchema | undefined>;
3
- type MiddlewareParams = Record<string, Struct>;
4
- type MiddlewareResults = Record<string, unknown>;
5
- type HookPayloads = Record<string, Struct>;
6
- type EmptyMap = Record<string, never>;
7
- type SettingProperties = Record<string, ExtensionSettingProperty>;
8
- type EmptySettings = Record<string, never>;
9
- type SettingValue<TProperty> = TProperty extends {
10
- type: "boolean";
11
- } ? boolean : TProperty extends {
12
- type: "number";
13
- } ? number : TProperty extends {
14
- type: "string";
15
- } ? string : TProperty extends {
16
- type: "array";
17
- } ? unknown[] : TProperty extends {
18
- type: "object";
19
- } ? Record<string, unknown> : unknown;
20
- export type SettingsMap<TSettings> = TSettings extends {
21
- properties: infer TProperties;
22
- } ? {
23
- [K in keyof TProperties & string]: SettingValue<TProperties[K]>;
24
- } : EmptySettings;
25
- type CommandDefinitions<TSchemas extends CommandSchemas, TSettings extends Record<string, unknown>> = {
26
- [K in keyof TSchemas]: CommandDefinition<TSchemas[K], unknown, TSettings>;
27
- };
28
- type MiddlewareDefinitions<TParams extends MiddlewareParams, TResults extends MiddlewareResults> = {
29
- [K in keyof TParams]: MiddlewareDefinition<TParams[K], K extends keyof TResults ? TResults[K] : unknown>;
30
- };
31
- type HookDefinitions<TPayloads extends HookPayloads> = {
32
- [K in keyof TPayloads]: HookDefinition<TPayloads[K]>;
33
- };
34
- type ExtensionAuthoringDefinition<TCommandSchemas extends CommandSchemas, TMiddlewareParams extends MiddlewareParams, TMiddlewareResults extends MiddlewareResults, THookPayloads extends HookPayloads, TScheduleParams extends MiddlewareParams, TSettings extends ExtensionSettingsContribution<SettingProperties> | undefined> = Omit<ExtensionDefinition, "commands" | "middlewares" | "hooks" | "schedules" | "settings"> & {
35
- settings?: TSettings;
36
- commands?: CommandDefinitions<TCommandSchemas, SettingsMap<TSettings>>;
37
- middlewares?: MiddlewareDefinitions<TMiddlewareParams, TMiddlewareResults>;
38
- hooks?: HookDefinitions<THookPayloads>;
39
- schedules?: {
40
- [K in keyof TScheduleParams]: ScheduleContribution<TScheduleParams[K]>;
41
- };
42
- };
43
- /**
44
- * Identity helper that types the passed contributions. Authors get autocomplete on
45
- * contributions. Extension identity (id, name, version, description, publisher,
46
- * engines.pstdio) lives in package.json.
47
- *
48
- * @example
49
- * export default defineExtension({
50
- * commands: { ... },
51
- * });
52
- */
53
- export declare const defineExtension: <const TCommandSchemas extends CommandSchemas = EmptyMap, const TMiddlewareParams extends MiddlewareParams = EmptyMap, const TMiddlewareResults extends MiddlewareResults = MiddlewareResults, const THookPayloads extends HookPayloads = EmptyMap, const TScheduleParams extends MiddlewareParams = EmptyMap, const TSettings extends ExtensionSettingsContribution<SettingProperties> | undefined = undefined>(extension: ExtensionAuthoringDefinition<TCommandSchemas, TMiddlewareParams, TMiddlewareResults, THookPayloads, TScheduleParams, TSettings>) => ExtensionAuthoringDefinition<TCommandSchemas, TMiddlewareParams, TMiddlewareResults, THookPayloads, TScheduleParams, TSettings> & ExtensionDefinition;
54
- export {};
@@ -1,13 +0,0 @@
1
- export type { CreateNotificationInput, ListNotificationsQuery, ListNotificationsResponse, Notification, NotificationAction, NotificationActionResult, NotificationActorType, NotificationKind, NotificationOrigin, NotificationPriority, NotificationStatus, UpdateNotificationInput, } from "pstdio-api-contracts";
2
- export type * from "pstdio-api-contracts/extension-kernel";
3
- export type { CommitPayload, ConflictPayload, MergePayload, RebasePayload, SessionLifecyclePayload, WorkspaceProvisionPayload, WorkspaceType, WorktreeRemovedPayload, } 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
- export { type CommandResponse, unwrapCommandOutcome } from "./command-outcome";
6
- export { defineCommand, defineHook, defineMiddleware } from "./define-command";
7
- export { defineExtension } from "./define-extension";
8
- export { defineExtensionView, type ExtensionViewModule, type ExtensionViewRender, type ExtensionViewRenderContext, type GuestHost, type PropsStore, type WebviewFilesClient, } from "./define-extension-view";
9
- export { params } from "./params";
10
- export { commandEvent, commandRef, eventRef } from "./refs";
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";
13
- export { matchesResourceWhen } from "./when";
@@ -1,36 +0,0 @@
1
- import type { BooleanParam, FilesParam, HarnessParam, JsonParam, ListParam, LongTextParam, MarkdownParam, MultiSelectParam, NumberParam, RepoParam, ResourceParam, SelectParam, TemplateParam, TextParam } from "pstdio-api-contracts/extension-kernel";
2
- type RequiredOf<TOptions> = TOptions extends {
3
- required: infer TRequired extends boolean;
4
- } ? TRequired : undefined;
5
- type ParamOptions<TParam extends {
6
- type: string;
7
- }> = Omit<TParam, "type">;
8
- /**
9
- * Builders for typed parameter descriptors. Each builder produces a discriminated
10
- * `ParamDescriptor` so the runtime and editor only see fields valid for that type.
11
- *
12
- * @example
13
- * params: {
14
- * amount: params.number({ defaultValue: 1 }),
15
- * mode: params.select({ options: [{ label: "Fast", value: "fast" }] }),
16
- * }
17
- */
18
- export declare const params: {
19
- text: <const TOptions extends ParamOptions<TextParam> | undefined = undefined>(options?: TOptions) => TextParam<RequiredOf<TOptions>>;
20
- longText: <const TOptions extends ParamOptions<LongTextParam> | undefined = undefined>(options?: TOptions) => LongTextParam<RequiredOf<TOptions>>;
21
- markdown: <const TOptions extends ParamOptions<MarkdownParam> | undefined = undefined>(options?: TOptions) => MarkdownParam<RequiredOf<TOptions>>;
22
- files: <const TOptions extends ParamOptions<FilesParam> | undefined = undefined>(options?: TOptions) => FilesParam<RequiredOf<TOptions>>;
23
- number: <const TOptions extends ParamOptions<NumberParam> | undefined = undefined>(options?: TOptions) => NumberParam<RequiredOf<TOptions>>;
24
- boolean: <const TOptions extends ParamOptions<BooleanParam> | undefined = undefined>(options?: TOptions) => BooleanParam<RequiredOf<TOptions>>;
25
- select: <const TOptions extends ParamOptions<SelectParam>>(options: TOptions) => SelectParam<RequiredOf<TOptions>>;
26
- multiSelect: <const TOptions extends ParamOptions<MultiSelectParam>>(options: TOptions) => MultiSelectParam<RequiredOf<TOptions>>;
27
- repo: <const TOptions extends ParamOptions<RepoParam> | undefined = undefined>(options?: TOptions) => RepoParam<RequiredOf<TOptions>>;
28
- harness: <const TOptions extends ParamOptions<HarnessParam> | undefined = undefined>(options?: TOptions) => HarnessParam<RequiredOf<TOptions>>;
29
- template: <const TOptions extends Omit<TemplateParam, "type" | "templateType"> & {
30
- type: string;
31
- }>(options: TOptions) => TemplateParam<RequiredOf<TOptions>>;
32
- resource: <const TOptions extends ParamOptions<ResourceParam>>(options: TOptions) => ResourceParam<RequiredOf<TOptions>>;
33
- json: <T = unknown, const TOptions extends ParamOptions<JsonParam<T>> | undefined = undefined>(options?: TOptions) => JsonParam<T, RequiredOf<TOptions>>;
34
- list: <const TOptions extends ParamOptions<ListParam> | undefined = undefined>(options?: TOptions) => ListParam<RequiredOf<TOptions>>;
35
- };
36
- export {};
@@ -1,8 +0,0 @@
1
- import type { CommandLifecycleEventPayload, CommandLifecyclePhase, CommandRef, EventRef, Struct } from "pstdio-api-contracts/extension-kernel";
2
- export { commandRef, eventRef } from "pstdio-api-contracts/extension-kernel";
3
- /**
4
- * Build an `EventRef` for a command lifecycle phase (`requested`, `started`, `completed`,
5
- * `rejected`, `failed`). The payload type is inferred from the command ref so hooks see
6
- * the correct shape.
7
- */
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>>;
@@ -1,32 +0,0 @@
1
- import type { TerminalSessionRequest } from "../api/terminal";
2
- import type { GuestHost } from "./define-extension-view";
3
- export interface TerminalSessionExit {
4
- code: number | null;
5
- signal: string | null;
6
- }
7
- /**
8
- * Renderer-side session over the `terminal.session` capability. Structurally
9
- * compatible with the `TerminalSessionAdapter` contract of `@pstdio/ui/terminal`,
10
- * so it plugs straight into the `Terminal` component's `bridge` prop.
11
- */
12
- export interface TerminalSessionAdapter {
13
- readonly id: string;
14
- write(data: string | Uint8Array): void;
15
- resize(cols: number, rows: number): void;
16
- kill(signal?: string): Promise<void>;
17
- onData(handler: (chunk: Uint8Array) => void): () => void;
18
- onExit(handler: (exit: TerminalSessionExit) => void): () => void;
19
- onError(handler: (error: {
20
- message: string;
21
- }) => void): () => void;
22
- }
23
- export interface TerminalSessionBridge {
24
- openSession(request: TerminalSessionRequest): Promise<TerminalSessionAdapter>;
25
- }
26
- /**
27
- * Builds a terminal bridge for an extension webview from its `GuestHost`.
28
- * Operations go through `host.call("terminal.session", ...)`; output and exit
29
- * events arrive through the host event channel. The webview must declare the
30
- * `terminal.session` capability or every call is rejected by the host gate.
31
- */
32
- export declare const createTerminalSessionBridge: (host: GuestHost) => TerminalSessionBridge;
@@ -1,41 +0,0 @@
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 {};
@@ -1,9 +0,0 @@
1
- import type { WhenExpression } from "pstdio-api-contracts/extension-kernel";
2
- /**
3
- * Resource-scoped visibility for command-palette contributions. Both the workbench host and the
4
- * dashboard palette gate the same way, so the rule lives here once instead of being re-derived per
5
- * surface. Only `resourceType` is evaluated: it is the sole `when` field a palette surface can
6
- * resolve from the active resource alone (`mode`/`source`/`metadata` require execution context the
7
- * palette does not have).
8
- */
9
- export declare const matchesResourceWhen: (when: Pick<WhenExpression, "resourceType"> | undefined, resourceType: string | undefined) => boolean;
@@ -1,17 +0,0 @@
1
- import type { FollowUpInput } from "../api/sessions";
2
- import type { PstdioClient } from "../client";
3
- import type { Session } from "../resources";
4
- export type SessionFollowupInput = Omit<FollowUpInput, "template" | "vars">;
5
- type HookSessionClient = {
6
- followup(input: SessionFollowupInput): Promise<Session>;
7
- };
8
- export type HookClient = PstdioClient & {
9
- session: HookSessionClient;
10
- };
11
- export type HookPayload = Record<string, unknown>;
12
- export type BaseHookContext = {
13
- client: HookClient;
14
- projectId: string;
15
- payload?: HookPayload;
16
- };
17
- export {};
@@ -1,8 +0,0 @@
1
- import type { Workspace } from "../resources";
2
- export type HookResourceAnchor = {
3
- type: string;
4
- id: string;
5
- label?: string;
6
- metadata?: Record<string, unknown>;
7
- };
8
- export type HookWorkspace = Workspace;
@@ -1,3 +0,0 @@
1
- export type { BaseHookContext, HookClient, HookPayload, SessionFollowupInput } from "./base";
2
- export type { SessionHookContext } from "./session";
3
- export type { CommitContext, ConflictContext, MergeContext, RebaseContext, WorktreeContext, WorktreeCreateContext, WorktreeRemoveContext, } from "./worktree";
@@ -1,12 +0,0 @@
1
- import type { BaseHookContext } from "./base";
2
- import type { HookResourceAnchor, HookWorkspace } from "./entities";
3
- export type SessionHookContext = BaseHookContext & {
4
- sessionId: string;
5
- sessionStatus: "in_progress" | "awaiting_input" | "queued" | "completed" | "failed" | "cancelled" | "disconnected";
6
- originalSessionId?: string;
7
- workspace?: HookWorkspace;
8
- workspaceId?: string;
9
- worktreePath?: string;
10
- branch?: string;
11
- anchors?: HookResourceAnchor[];
12
- };
@@ -1,53 +0,0 @@
1
- import type { BaseHookContext } from "./base";
2
- import type { HookResourceAnchor } from "./entities";
3
- export type WorktreeCreateContext = BaseHookContext & {
4
- repoPath: string;
5
- worktreePath: string;
6
- branch: string;
7
- workspace: string;
8
- base: string;
9
- anchors?: HookResourceAnchor[];
10
- };
11
- export type WorktreeContext = BaseHookContext & {
12
- repoPath: string;
13
- worktreePath: string;
14
- branch: string;
15
- workspace: string;
16
- workspaceId: string;
17
- anchors?: HookResourceAnchor[];
18
- };
19
- export type CommitContext = {
20
- repoPath: string;
21
- worktreePath: string;
22
- commitMessage: string;
23
- stagePolicy: string;
24
- commitSha?: string;
25
- };
26
- export type RebaseContext = {
27
- repoPath: string;
28
- branch: string;
29
- target: string;
30
- };
31
- export type MergeContext = {
32
- repoPath: string;
33
- branch: string;
34
- target: string;
35
- squash: boolean;
36
- commitMessage: string | null;
37
- commitSha?: string;
38
- };
39
- export type ConflictContext = {
40
- repoPath: string;
41
- branch: string;
42
- target: string;
43
- operation: "rebase" | "merge";
44
- };
45
- export type WorktreeRemoveContext = {
46
- repoPath: string;
47
- worktreePath: string | null;
48
- branch: string;
49
- workspace: string;
50
- workspaceId: string;
51
- anchors?: HookResourceAnchor[];
52
- projectId: string;
53
- };