@pstdio/sdk 0.3.0 → 0.4.2

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.
@@ -0,0 +1,117 @@
1
+ import type { JsonObject, JsonValue, Struct } from "./json";
2
+ import type { RepoContext, ResourceRef } from "./resources";
3
+ import type { SlotInvocationContext } from "./slots";
4
+ export type CommandSource = "cli" | "dashboard" | "api" | "schedule" | "event" | "automation" | "command-panel";
5
+ export interface CommandRef<TParams extends Struct = Struct, TResult = unknown> {
6
+ id: string;
7
+ params?: TParams;
8
+ result?: TResult;
9
+ }
10
+ export interface SerializedError {
11
+ name?: string;
12
+ message: string;
13
+ stack?: string;
14
+ cause?: JsonValue;
15
+ }
16
+ export interface CommandInvocation<TParams extends Struct = Struct> {
17
+ params: TParams;
18
+ resource?: ResourceRef;
19
+ repoId?: string;
20
+ repoPath?: string;
21
+ slot?: SlotInvocationContext;
22
+ metadata?: JsonObject;
23
+ }
24
+ export interface CommandContinue {
25
+ type: "continue";
26
+ }
27
+ export interface CommandPatchParams<TParams extends Struct = Struct> {
28
+ type: "patchParams";
29
+ params: Partial<TParams>;
30
+ }
31
+ export interface CommandReplaceParams<TParams extends Struct = Struct> {
32
+ type: "replaceParams";
33
+ params: TParams;
34
+ }
35
+ export interface CommandReplaceInvocation<TParams extends Struct = Struct> {
36
+ type: "replaceInvocation";
37
+ invocation: CommandInvocation<TParams>;
38
+ }
39
+ export interface CommandReject {
40
+ type: "reject";
41
+ code?: string;
42
+ reason: string;
43
+ data?: JsonObject;
44
+ }
45
+ export type CommandMiddlewareResult<TParams extends Struct = Struct> = void | CommandContinue | CommandPatchParams<TParams> | CommandReplaceParams<TParams> | CommandReplaceInvocation<TParams> | CommandReject;
46
+ export interface CommandNotice {
47
+ type: "info" | "success" | "warning" | "error";
48
+ title?: string;
49
+ message: string;
50
+ metadata?: JsonObject;
51
+ }
52
+ export interface CommandDiagnostic {
53
+ code: string;
54
+ message: string;
55
+ severity: "info" | "warning" | "error";
56
+ extensionId?: string;
57
+ commandId?: string;
58
+ metadata?: JsonObject;
59
+ }
60
+ export type CommandOutcome<TResult = unknown> = {
61
+ ok: true;
62
+ status: "success";
63
+ value: TResult;
64
+ notices?: CommandNotice[];
65
+ diagnostics?: CommandDiagnostic[];
66
+ } | {
67
+ ok: false;
68
+ status: "rejected";
69
+ code?: string;
70
+ reason: string;
71
+ data?: JsonObject;
72
+ notices?: CommandNotice[];
73
+ diagnostics?: CommandDiagnostic[];
74
+ } | {
75
+ ok: false;
76
+ status: "error";
77
+ code?: string;
78
+ reason: string;
79
+ error?: SerializedError;
80
+ notices?: CommandNotice[];
81
+ diagnostics?: CommandDiagnostic[];
82
+ };
83
+ export interface CommandHelpersApi {
84
+ execute<TParams extends Struct = Struct, TResult = unknown>(command: CommandRef<TParams, TResult> | string, invocation: CommandInvocation<TParams>): Promise<CommandOutcome<TResult>>;
85
+ continue(): CommandContinue;
86
+ patchParams<TParams extends Struct = Struct>(params: Partial<TParams>): CommandPatchParams<TParams>;
87
+ replaceParams<TParams extends Struct = Struct>(params: TParams): CommandReplaceParams<TParams>;
88
+ replaceInvocation<TParams extends Struct = Struct>(invocation: CommandInvocation<TParams>): CommandReplaceInvocation<TParams>;
89
+ reject(input: Omit<CommandReject, "type">): CommandReject;
90
+ }
91
+ export interface CommandRequestedEvent<TParams extends Struct = Struct> {
92
+ commandId: string;
93
+ invocationId: string;
94
+ source?: CommandSource;
95
+ params: TParams;
96
+ resource?: ResourceRef;
97
+ repo?: RepoContext;
98
+ }
99
+ export interface CommandStartedEvent<TParams extends Struct = Struct> extends CommandRequestedEvent<TParams> {
100
+ }
101
+ export interface CommandCompletedEvent<TParams extends Struct = Struct, TResult = unknown> extends CommandStartedEvent<TParams> {
102
+ result: TResult;
103
+ elapsedMs: number;
104
+ }
105
+ export interface CommandRejectedEvent<TParams extends Struct = Struct> extends CommandRequestedEvent<TParams> {
106
+ code?: string;
107
+ reason: string;
108
+ data?: JsonObject;
109
+ }
110
+ export interface CommandFailedEvent<TParams extends Struct = Struct> extends CommandRequestedEvent<TParams> {
111
+ code?: string;
112
+ reason: string;
113
+ error?: SerializedError;
114
+ elapsedMs: number;
115
+ }
116
+ export type CommandLifecyclePhase = "requested" | "started" | "completed" | "rejected" | "failed";
117
+ export type CommandLifecycleEventPayload<TPhase extends CommandLifecyclePhase, TParams extends Struct = Struct, TResult = unknown> = TPhase extends "requested" ? CommandRequestedEvent<TParams> : TPhase extends "started" ? CommandStartedEvent<TParams> : TPhase extends "completed" ? CommandCompletedEvent<TParams, TResult> : TPhase extends "rejected" ? CommandRejectedEvent<TParams> : CommandFailedEvent<TParams>;
@@ -0,0 +1,188 @@
1
+ import type { CommandHelpersApi, CommandInvocation, CommandMiddlewareResult, CommandNotice, CommandSource } from "./commands";
2
+ import type { EventDeliveryResult, EventRef } from "./events";
3
+ import type { JsonObject, MaybePromise, Struct } from "./json";
4
+ import type { RepoContext, ResourceAnchor, ResourceRef } from "./resources";
5
+ import type { SlotInvocationContext } from "./slots";
6
+ export interface ExtensionStorageCollectionApi<TItem = unknown> {
7
+ get(id: string): Promise<TItem | undefined>;
8
+ list(): Promise<TItem[]>;
9
+ put(id: string, value: TItem): Promise<void>;
10
+ create(value: TItem): Promise<TItem & {
11
+ id: string;
12
+ }>;
13
+ delete(id: string): Promise<void>;
14
+ }
15
+ export type StorageScope = {
16
+ type: "project";
17
+ } | {
18
+ type: "repo";
19
+ repoId?: string;
20
+ } | {
21
+ type: "resource";
22
+ resource?: ResourceRef;
23
+ } | {
24
+ type: string;
25
+ id?: string;
26
+ };
27
+ export interface ExtensionStorageApi {
28
+ scope(scope: StorageScope): ExtensionStorageApi;
29
+ get<T = unknown>(key: string): Promise<T | undefined>;
30
+ set<T = unknown>(key: string, value: T): Promise<void>;
31
+ delete(key: string): Promise<void>;
32
+ collection<TItem = unknown>(name: string): ExtensionStorageCollectionApi<TItem>;
33
+ }
34
+ export interface ArtifactFile {
35
+ path: string;
36
+ size?: number;
37
+ updatedAt?: string;
38
+ }
39
+ export interface ArtifactMount {
40
+ exists(path: string): Promise<boolean>;
41
+ readText(path: string): Promise<string>;
42
+ writeText(path: string, value: string): Promise<void>;
43
+ readBytes(path: string): Promise<Uint8Array>;
44
+ writeBytes(path: string, value: Uint8Array): Promise<void>;
45
+ list(pattern?: string): Promise<ArtifactFile[]>;
46
+ listDirs(path?: string): Promise<string[]>;
47
+ delete(path: string): Promise<void>;
48
+ }
49
+ export interface ExtensionArtifactApi {
50
+ mount(key: string): ArtifactMount;
51
+ }
52
+ export interface ExtensionFilesApi {
53
+ readText(fileId: string): Promise<string>;
54
+ writeText(fileId: string, value: string): Promise<void>;
55
+ createText(input: {
56
+ name: string;
57
+ content: string;
58
+ metadata?: JsonObject;
59
+ }): Promise<{
60
+ id: string;
61
+ }>;
62
+ delete(fileId: string): Promise<void>;
63
+ }
64
+ export interface ExtensionSessionsApi {
65
+ create(input: {
66
+ title: string;
67
+ prompt?: string;
68
+ template?: string;
69
+ vars?: JsonObject;
70
+ harness?: unknown;
71
+ workspaceId?: string;
72
+ repoId?: string;
73
+ anchors?: ResourceAnchor[];
74
+ originalSessionId?: string;
75
+ }): Promise<{
76
+ id: string;
77
+ }>;
78
+ followup(input: {
79
+ sessionId: string;
80
+ prompt?: string;
81
+ template?: string;
82
+ vars?: JsonObject;
83
+ }): Promise<void>;
84
+ }
85
+ export interface ExtensionWorkspacesApi {
86
+ get(id: string): Promise<unknown>;
87
+ create(input: JsonObject): Promise<unknown>;
88
+ archive(id: string): Promise<void>;
89
+ delete(id: string): Promise<void>;
90
+ }
91
+ export interface ExtensionReposApi {
92
+ list(): Promise<RepoContext[]>;
93
+ get(repoId: string): Promise<RepoContext>;
94
+ getDefault(): Promise<RepoContext | undefined>;
95
+ resolvePath(repoId: string, relativePath: string, options?: {
96
+ basePath?: string;
97
+ }): Promise<string>;
98
+ }
99
+ export interface ExtensionEventsApi {
100
+ emit<TPayload extends Struct>(event: EventRef<TPayload> | string, payload: TPayload): Promise<EventDeliveryResult>;
101
+ }
102
+ export interface ExtensionActivityApi {
103
+ record(input: {
104
+ message: string;
105
+ target?: ResourceRef;
106
+ related?: ResourceRef[];
107
+ metadata?: JsonObject;
108
+ }): Promise<{
109
+ id: string;
110
+ }>;
111
+ }
112
+ export interface ExtensionNotifyApi {
113
+ toast(notice: CommandNotice): Promise<void>;
114
+ }
115
+ export interface ProcessRunResult {
116
+ exitCode: number;
117
+ stdout: string;
118
+ stderr: string;
119
+ }
120
+ export interface ExtensionProcessApi {
121
+ run(input: {
122
+ command: string[];
123
+ cwd?: string;
124
+ env?: Record<string, string>;
125
+ timeoutMs?: number;
126
+ }): Promise<ProcessRunResult>;
127
+ spawnDetached(input: {
128
+ command: string[];
129
+ cwd?: string;
130
+ env?: Record<string, string>;
131
+ }): Promise<{
132
+ pid?: number;
133
+ }>;
134
+ }
135
+ export interface ExtensionNetApi {
136
+ findFreePort(input?: {
137
+ host?: string;
138
+ }): Promise<number>;
139
+ }
140
+ export interface ExtensionLoggerApi {
141
+ info(message: string, metadata?: JsonObject): void;
142
+ warn(message: string, metadata?: JsonObject): void;
143
+ error(message: string, metadata?: JsonObject): void;
144
+ }
145
+ export interface ExtensionSettingsApi<TSettings extends Struct = Struct> {
146
+ all(): Promise<Partial<TSettings>>;
147
+ get<TKey extends keyof TSettings>(key: TKey): Promise<TSettings[TKey] | undefined>;
148
+ set<TKey extends keyof TSettings>(key: TKey, value: TSettings[TKey]): Promise<void>;
149
+ delete<TKey extends keyof TSettings>(key: TKey): Promise<void>;
150
+ }
151
+ export interface ExtensionContextBase {
152
+ projectId: string;
153
+ extensionId: string;
154
+ namespace: string;
155
+ repo?: RepoContext;
156
+ source?: CommandSource;
157
+ storage: ExtensionStorageApi;
158
+ artifacts: ExtensionArtifactApi;
159
+ files: ExtensionFilesApi;
160
+ sessions: ExtensionSessionsApi;
161
+ workspaces: ExtensionWorkspacesApi;
162
+ repos: ExtensionReposApi;
163
+ commands: CommandHelpersApi;
164
+ events: ExtensionEventsApi;
165
+ activity: ExtensionActivityApi;
166
+ notify: ExtensionNotifyApi;
167
+ process: ExtensionProcessApi;
168
+ net: ExtensionNetApi;
169
+ logger: ExtensionLoggerApi;
170
+ settings: ExtensionSettingsApi;
171
+ }
172
+ export interface CommandContext<TParams extends Struct = Struct> extends ExtensionContextBase {
173
+ commandId: string;
174
+ invocationId: string;
175
+ invocation: CommandInvocation<TParams>;
176
+ resource?: ResourceRef;
177
+ slot?: SlotInvocationContext;
178
+ params: TParams;
179
+ }
180
+ export type CommandMiddlewareContext<TParams extends Struct = Struct> = CommandContext<TParams>;
181
+ export type CommandMiddlewareHandler<TParams extends Struct = Struct> = (ctx: CommandMiddlewareContext<TParams>) => MaybePromise<CommandMiddlewareResult<TParams>>;
182
+ export type CommandRunHandler<TParams extends Struct = Struct, TResult = unknown> = (ctx: CommandContext<TParams>) => MaybePromise<TResult>;
183
+ export interface EventContext extends ExtensionContextBase {
184
+ eventId: string;
185
+ deliveryId: string;
186
+ }
187
+ export type SetupContext = ExtensionContextBase;
188
+ export type MigrationContext = ExtensionContextBase;
@@ -0,0 +1,92 @@
1
+ import type { CommandRef, CommandSource } from "./commands";
2
+ import type { JsonObject, Struct } from "./json";
3
+ import type { PackageAssetDescriptor } from "./resources";
4
+ import type { SlotRef } from "./slots";
5
+ export interface CliContribution {
6
+ path?: string[];
7
+ globalAliases?: string[][];
8
+ description?: string;
9
+ examples?: string[];
10
+ hidden?: boolean;
11
+ }
12
+ export interface WhenExpression {
13
+ source?: CommandSource[];
14
+ resourceType?: string[];
15
+ metadata?: JsonObject;
16
+ }
17
+ export interface CommandPanelContribution {
18
+ group?: string;
19
+ keywords?: string[];
20
+ when?: WhenExpression;
21
+ }
22
+ export interface MenuContribution<TSlotContext extends Struct = Struct, TParams extends Struct = Struct> {
23
+ slot: SlotRef<TSlotContext, "menu"> | string;
24
+ label?: string;
25
+ group?: string;
26
+ placement?: "first" | "default" | "last";
27
+ icon?: string;
28
+ when?: WhenExpression;
29
+ command?: CommandRef<TParams, unknown> | string;
30
+ params?: Partial<TParams>;
31
+ presentation?: "menu-item" | "button" | "icon-button";
32
+ }
33
+ export interface NavigationContribution<TSlotContext extends Struct = Struct, TParams extends Struct = Struct> {
34
+ slot: SlotRef<TSlotContext, "navigation"> | string;
35
+ label: string;
36
+ group?: string;
37
+ placement?: "first" | "default" | "last";
38
+ route?: string;
39
+ href?: string;
40
+ command?: CommandRef<TParams, unknown> | string;
41
+ params?: Partial<TParams>;
42
+ icon?: string;
43
+ when?: WhenExpression;
44
+ }
45
+ export interface WebviewContribution {
46
+ entry: PackageAssetDescriptor;
47
+ title?: string;
48
+ sandbox?: "default" | "strict";
49
+ }
50
+ export interface ViewContribution<TSlotContext extends Struct = Struct> {
51
+ title: string;
52
+ slot: SlotRef<TSlotContext, "view"> | string;
53
+ group?: string;
54
+ placement?: "first" | "default" | "last";
55
+ webview: WebviewContribution;
56
+ }
57
+ export interface RouteContribution {
58
+ path: string;
59
+ label: string;
60
+ webview: WebviewContribution;
61
+ }
62
+ export interface SettingsPanelContribution<TSlotContext extends Struct = Struct> {
63
+ title: string;
64
+ slot: SlotRef<TSlotContext, "settings"> | string;
65
+ webview: WebviewContribution;
66
+ }
67
+ export interface RendererContribution<TSlotContext extends Struct = Struct> {
68
+ slot: SlotRef<TSlotContext, "renderer"> | string;
69
+ for: string;
70
+ webview: WebviewContribution;
71
+ }
72
+ export interface ArtifactMountContribution {
73
+ /** Relative path under .pstdio/<extension.namespace>/. */
74
+ path: string;
75
+ label: string;
76
+ repoRole?: "default" | "selected" | "workspace";
77
+ }
78
+ export interface TemplateTypeContribution {
79
+ label: string;
80
+ description?: string;
81
+ }
82
+ export interface TemplateContribution {
83
+ title: string;
84
+ type: string;
85
+ source: PackageAssetDescriptor;
86
+ description?: string;
87
+ }
88
+ export interface SkillContribution {
89
+ title: string;
90
+ source: PackageAssetDescriptor;
91
+ description?: string;
92
+ }
@@ -0,0 +1,10 @@
1
+ import type { CommandDiagnostic } from "./commands";
2
+ import type { Struct } from "./json";
3
+ export interface EventRef<TPayload extends Struct = Struct> {
4
+ id: string;
5
+ payload?: TPayload;
6
+ }
7
+ export interface EventDeliveryResult {
8
+ delivered: number;
9
+ diagnostics?: CommandDiagnostic[];
10
+ }
@@ -0,0 +1,158 @@
1
+ import type { CommandRef } from "./commands";
2
+ import type { CommandMiddlewareHandler, CommandRunHandler, EventContext, ExtensionContextBase, MigrationContext, SetupContext } from "./context";
3
+ import type { ArtifactMountContribution, CliContribution, CommandPanelContribution, MenuContribution, NavigationContribution, RendererContribution, RouteContribution, SettingsPanelContribution, SkillContribution, TemplateContribution, TemplateTypeContribution, ViewContribution } from "./contributions";
4
+ import type { EventRef } from "./events";
5
+ import type { JsonObject, MaybePromise, Struct } from "./json";
6
+ import type { ParamObjectSchema, ParamsOf } from "./params";
7
+ import type { SlotRef } from "./slots";
8
+ /** API version of an extension's manifest. The runtime uses this to detect old extensions. */
9
+ export type ExtensionApiVersion = "1";
10
+ type SchemaParams<TSchema extends ParamObjectSchema | undefined> = TSchema extends ParamObjectSchema ? ParamsOf<TSchema> : Struct;
11
+ /**
12
+ * A command exposed by an extension. The `params` schema (typed via `params.*`) drives
13
+ * the inferred shape of `ctx.params` in `run`.
14
+ */
15
+ export interface CommandDefinition<TSchema extends ParamObjectSchema | undefined = ParamObjectSchema | undefined, TResult = unknown> {
16
+ title: string;
17
+ description?: string;
18
+ params?: TSchema;
19
+ /** Defaults to true. */
20
+ commandPanel?: boolean | CommandPanelContribution;
21
+ menus?: MenuContribution[];
22
+ cli?: boolean | CliContribution;
23
+ run: CommandRunHandler<SchemaParams<TSchema>, TResult>;
24
+ }
25
+ /**
26
+ * Middleware that runs before a command. Use `command` for a typed `CommandRef`; use
27
+ * `commandId` only when referencing a command from another extension you don't import.
28
+ */
29
+ export interface MiddlewareDefinition<TParams extends Struct = Struct, TResult = unknown> {
30
+ command?: CommandRef<TParams, TResult>;
31
+ commandId?: string;
32
+ handler: CommandMiddlewareHandler<TParams>;
33
+ }
34
+ /**
35
+ * A handler for an event. Use `event` for a typed `EventRef`; use `eventId` for events
36
+ * you cannot import (e.g. originating in another extension).
37
+ */
38
+ export interface HookDefinition<TPayload extends Struct = Struct> {
39
+ event?: EventRef<TPayload>;
40
+ eventId?: string;
41
+ handler(ctx: EventContext, payload: TPayload): MaybePromise<void>;
42
+ }
43
+ export interface ScheduleContribution<TParams extends Struct = Struct> {
44
+ title: string;
45
+ cron: string;
46
+ command?: CommandRef<TParams, unknown>;
47
+ commandId?: string;
48
+ params?: TParams;
49
+ repoId?: string;
50
+ repoPath?: string;
51
+ disabled?: boolean;
52
+ }
53
+ export interface HarnessDetectionResult {
54
+ available: boolean;
55
+ version?: string;
56
+ reason?: string;
57
+ }
58
+ export interface HarnessRun {
59
+ runId: string;
60
+ pid?: number;
61
+ metadata?: JsonObject;
62
+ }
63
+ export interface HarnessProvider {
64
+ id: string;
65
+ label: string;
66
+ detect?(ctx: ExtensionContextBase): MaybePromise<HarnessDetectionResult>;
67
+ start(ctx: ExtensionContextBase, input: {
68
+ workspacePath: string;
69
+ sessionId: string;
70
+ prompt?: string;
71
+ }): MaybePromise<HarnessRun>;
72
+ send?(ctx: ExtensionContextBase, input: {
73
+ runId: string;
74
+ message: string;
75
+ }): MaybePromise<void>;
76
+ stop?(ctx: ExtensionContextBase, input: {
77
+ runId: string;
78
+ }): MaybePromise<void>;
79
+ }
80
+ export interface WorkspaceTypeProvider {
81
+ id: string;
82
+ label: string;
83
+ create(ctx: ExtensionContextBase, input: JsonObject): MaybePromise<JsonObject>;
84
+ resolve(ctx: ExtensionContextBase, workspace: JsonObject): MaybePromise<{
85
+ rootPath: string;
86
+ displayPath?: string;
87
+ }>;
88
+ archive?(ctx: ExtensionContextBase, workspace: JsonObject): MaybePromise<void>;
89
+ delete?(ctx: ExtensionContextBase, workspace: JsonObject): MaybePromise<void>;
90
+ }
91
+ export interface LocalExtensionSource {
92
+ name: string;
93
+ path: string;
94
+ origin?: string;
95
+ installedAt: string;
96
+ updatedAt: string;
97
+ }
98
+ export interface ProjectExtensionInstance {
99
+ projectId: string;
100
+ extensionId: string;
101
+ namespace: string;
102
+ sourceName: string;
103
+ enabled: boolean;
104
+ config: JsonObject;
105
+ }
106
+ /** Identifying metadata for an extension. */
107
+ export interface ExtensionMetadata {
108
+ id: string;
109
+ namespace: string;
110
+ name: string;
111
+ version?: string;
112
+ description?: string;
113
+ /** Manifest API version. The runtime uses this to detect incompatible extensions. */
114
+ apiVersion: ExtensionApiVersion;
115
+ settings?: ParamObjectSchema;
116
+ }
117
+ /** UI surface contributions: slots, routes, panels, renderers. */
118
+ export interface UiContributions {
119
+ slots?: Record<string, SlotRef>;
120
+ routes?: Record<string, RouteContribution>;
121
+ views?: Record<string, ViewContribution>;
122
+ navigation?: Record<string, NavigationContribution>;
123
+ settingsPanels?: Record<string, SettingsPanelContribution>;
124
+ activityRenderers?: Record<string, RendererContribution>;
125
+ sessionAnchorRenderers?: Record<string, RendererContribution>;
126
+ }
127
+ /** Behavioural surface: commands, middleware, hooks, schedules. */
128
+ export interface BehaviourContributions {
129
+ commands?: Record<string, CommandDefinition<any, any>>;
130
+ middlewares?: Record<string, MiddlewareDefinition<any, any>>;
131
+ hooks?: Record<string, HookDefinition<any>>;
132
+ schedules?: Record<string, ScheduleContribution<any>>;
133
+ }
134
+ /** Static asset contributions: artifact mounts, templates, skills. */
135
+ export interface AssetContributions {
136
+ artifactMounts?: Record<string, ArtifactMountContribution>;
137
+ templateTypes?: Record<string, TemplateTypeContribution>;
138
+ templates?: Record<string, TemplateContribution>;
139
+ skills?: Record<string, SkillContribution>;
140
+ }
141
+ /** Provider contributions: harnesses, workspace types. */
142
+ export interface ProviderContributions {
143
+ workspaceTypes?: Record<string, WorkspaceTypeProvider>;
144
+ harnesses?: Record<string, HarnessProvider>;
145
+ }
146
+ /** Lifecycle hooks invoked by the runtime when an extension is installed or upgraded. */
147
+ export interface ExtensionLifecycle {
148
+ initialSetup?: (ctx: SetupContext) => MaybePromise<void>;
149
+ migrate?: (ctx: MigrationContext, fromVersion: string | null) => MaybePromise<void>;
150
+ }
151
+ /**
152
+ * The full shape of an extension manifest. Composed from focused capability mixins so
153
+ * each surface is independently discoverable.
154
+ */
155
+ export interface ExtensionDefinition extends ExtensionMetadata, UiContributions, BehaviourContributions, AssetContributions, ProviderContributions, ExtensionLifecycle {
156
+ }
157
+ export type ExtensionSourceKind = "local" | "package" | "builtin";
158
+ export {};
@@ -0,0 +1,9 @@
1
+ export type * from "./commands";
2
+ export type * from "./context";
3
+ export type * from "./contributions";
4
+ export type * from "./events";
5
+ export type * from "./extension";
6
+ export type * from "./json";
7
+ export type * from "./params";
8
+ export type * from "./resources";
9
+ export type * from "./slots";
@@ -0,0 +1,7 @@
1
+ export type JsonPrimitive = string | number | boolean | null;
2
+ export type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
3
+ export type JsonObject = {
4
+ [key: string]: JsonValue;
5
+ };
6
+ export type MaybePromise<T> = T | Promise<T>;
7
+ export type Struct = object;
@@ -0,0 +1,66 @@
1
+ import type { JsonObject } from "./json";
2
+ import type { ResourceRef } from "./resources";
3
+ export type ParamType = "text" | "longtext" | "number" | "boolean" | "select" | "multi-select" | "repo" | "harness" | "template" | "resource" | "json";
4
+ interface ParamBase<TValue> {
5
+ label?: string;
6
+ description?: string;
7
+ required?: boolean;
8
+ defaultValue?: TValue;
9
+ metadata?: JsonObject;
10
+ }
11
+ export interface TextParam extends ParamBase<string> {
12
+ type: "text";
13
+ }
14
+ export interface LongTextParam extends ParamBase<string> {
15
+ type: "longtext";
16
+ }
17
+ export interface NumberParam extends ParamBase<number> {
18
+ type: "number";
19
+ }
20
+ export interface BooleanParam extends ParamBase<boolean> {
21
+ type: "boolean";
22
+ }
23
+ export interface SelectParam extends ParamBase<string> {
24
+ type: "select";
25
+ options: Array<{
26
+ label: string;
27
+ value: string;
28
+ }>;
29
+ }
30
+ export interface MultiSelectParam extends ParamBase<string[]> {
31
+ type: "multi-select";
32
+ options: Array<{
33
+ label: string;
34
+ value: string;
35
+ }>;
36
+ }
37
+ export interface RepoParam extends ParamBase<{
38
+ repoId: string;
39
+ branch?: string;
40
+ }> {
41
+ type: "repo";
42
+ }
43
+ export interface HarnessParam extends ParamBase<{
44
+ harnessId: string;
45
+ model?: string;
46
+ }> {
47
+ type: "harness";
48
+ }
49
+ export interface TemplateParam extends ParamBase<string> {
50
+ type: "template";
51
+ templateType: string;
52
+ }
53
+ export interface ResourceParam extends ParamBase<ResourceRef> {
54
+ type: "resource";
55
+ resourceType: string;
56
+ }
57
+ export interface JsonParam<T = unknown> extends ParamBase<T> {
58
+ type: "json";
59
+ }
60
+ export type ParamDescriptor<TValue = unknown> = TextParam | LongTextParam | NumberParam | BooleanParam | SelectParam | MultiSelectParam | RepoParam | HarnessParam | TemplateParam | ResourceParam | JsonParam<TValue>;
61
+ export type ParamObjectSchema = Record<string, ParamDescriptor>;
62
+ export type ParamValue<TDescriptor extends ParamDescriptor> = TDescriptor extends ParamDescriptor<infer V> ? V : never;
63
+ export type ParamsOf<TSchema extends ParamObjectSchema> = {
64
+ [K in keyof TSchema]: ParamValue<TSchema[K]>;
65
+ };
66
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { JsonObject } from "./json";
2
+ export type ResourceRole = "primary" | "context" | "source" | "result";
3
+ export interface ResourceRef {
4
+ type: string;
5
+ id: string;
6
+ projectId?: string;
7
+ label?: string;
8
+ extensionId?: string;
9
+ metadata?: JsonObject;
10
+ }
11
+ export interface ResourceAnchor extends ResourceRef {
12
+ role?: ResourceRole;
13
+ }
14
+ export interface RepoContext {
15
+ projectId: string;
16
+ repoId: string;
17
+ path: string;
18
+ remote?: string | null;
19
+ role?: "default" | "selected" | "workspace";
20
+ }
21
+ export interface PackageAssetDescriptor {
22
+ kind: "package-asset";
23
+ path: string;
24
+ baseUrl: string;
25
+ }