@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.
- package/dist/api/sessions.d.ts +1 -1
- package/dist/api/tickets.d.ts +1 -1
- package/dist/api/workspaces.d.ts +1 -1
- package/dist/client/client.d.ts +2 -0
- package/dist/client/extensions.d.ts +7 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +88 -1
- package/dist/client/projects.d.ts +2 -1
- package/dist/client/sessions.d.ts +2 -1
- package/dist/client/tickets.d.ts +3 -1
- package/dist/client/workspaces.d.ts +2 -1
- package/dist/extensions/define-command.d.ts +28 -0
- package/dist/extensions/define-extension.d.ts +16 -0
- package/dist/extensions/index.d.ts +8 -0
- package/dist/extensions/index.js +111 -0
- package/dist/extensions/kernel-slots.d.ts +46 -0
- package/dist/extensions/package-asset.d.ts +10 -0
- package/dist/extensions/params.d.ts +26 -0
- package/dist/extensions/refs.d.ts +38 -0
- package/dist/extensions/slots.d.ts +14 -0
- package/dist/extensions/types/commands.d.ts +117 -0
- package/dist/extensions/types/context.d.ts +188 -0
- package/dist/extensions/types/contributions.d.ts +92 -0
- package/dist/extensions/types/events.d.ts +10 -0
- package/dist/extensions/types/extension.d.ts +158 -0
- package/dist/extensions/types/index.d.ts +9 -0
- package/dist/extensions/types/json.d.ts +7 -0
- package/dist/extensions/types/params.d.ts +66 -0
- package/dist/extensions/types/resources.d.ts +25 -0
- package/dist/extensions/types/slots.d.ts +22 -0
- package/dist/plugins/index.js +39 -23
- package/package.json +6 -2
package/dist/api/sessions.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { ApprovalInput, CreateSessionInput, FollowUpInput, ResolveSessionIdInput, ResolveSessionIdResponse, SessionConversationResponse, } from "pstdio-api-contracts";
|
|
1
|
+
export type { ApprovalInput, CreateSessionInput, FollowUpInput, ListSessionActivityInput, ListSessionActivityResponse, ResolveSessionIdInput, ResolveSessionIdResponse, SessionConversationResponse, } from "pstdio-api-contracts";
|
package/dist/api/tickets.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { CreateTicketAttemptInput, CreateTicketInput, TicketAttemptMode, UpdateTicketInput, UpdateWhenAttemptStatusInput, UpdateWhenAttemptStatusResponse, UploadTicketFileInput, } from "pstdio-api-contracts";
|
|
1
|
+
export type { CreateTicketAttemptInput, CreateTicketInput, ListProjectActivityForTicketsInput, ListTicketActivityInput, ListTicketActivityResponse, TicketAttemptMode, UpdateTicketInput, UpdateWhenAttemptStatusInput, UpdateWhenAttemptStatusResponse, UploadTicketFileInput, } from "pstdio-api-contracts";
|
|
2
2
|
import type { Ticket, Workspace } from "../resources";
|
|
3
3
|
export type ListTicketsInput = {
|
|
4
4
|
status?: string;
|
package/dist/api/workspaces.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { CreateWorkspaceInput, RemoveWorktreeResponse, UpdateAttemptStatusInput, UpdateAttemptStatusResponse, } from "pstdio-api-contracts";
|
|
1
|
+
export type { CreateWorkspaceInput, ListWorkspaceActivityInput, ListWorkspaceActivityResponse, RemoveWorktreeResponse, UpdateAttemptStatusInput, UpdateAttemptStatusResponse, } from "pstdio-api-contracts";
|
package/dist/client/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ActionClient } from "./actions";
|
|
2
2
|
import { type AgentClient } from "./agents";
|
|
3
|
+
import { type ExtensionClient } from "./extensions";
|
|
3
4
|
import { type ProjectClient } from "./projects";
|
|
4
5
|
import type { ClientOptions } from "./request";
|
|
5
6
|
import { type SessionClient } from "./sessions";
|
|
@@ -20,5 +21,6 @@ export type PstdioClient = {
|
|
|
20
21
|
skills: SkillClient;
|
|
21
22
|
agents: AgentClient;
|
|
22
23
|
actions: ActionClient;
|
|
24
|
+
extensions: ExtensionClient;
|
|
23
25
|
};
|
|
24
26
|
export declare const createClient: (options?: ClientOptions) => PstdioClient;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CommandExecuteRequest, CommandExecuteResponse, EnableInstalledExtensionRequest, EnableInstalledExtensionResponse } from "pstdio-api-contracts";
|
|
2
|
+
import type { RequestFn } from "./request";
|
|
3
|
+
export type ExtensionClient = {
|
|
4
|
+
enableInstalled(projectId: string, installName: string, request: EnableInstalledExtensionRequest): Promise<EnableInstalledExtensionResponse>;
|
|
5
|
+
execute(commandId: string, request: CommandExecuteRequest): Promise<CommandExecuteResponse>;
|
|
6
|
+
};
|
|
7
|
+
export declare const createExtensionClient: (request: RequestFn) => ExtensionClient;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type { ActionClient } from "./actions";
|
|
2
2
|
export type { AgentClient } from "./agents";
|
|
3
3
|
export { createClient, type PstdioClient } from "./client";
|
|
4
|
+
export type { ExtensionClient } from "./extensions";
|
|
4
5
|
export type { ProjectClient } from "./projects";
|
|
5
6
|
export { type ClientOptions, createRequest, PstdioApiError, type RequestFn } from "./request";
|
|
6
7
|
export type { SessionClient } from "./sessions";
|
package/dist/client/index.js
CHANGED
|
@@ -18,12 +18,44 @@ var createAgentClient = (request) => ({
|
|
|
18
18
|
delete: (agentId) => request(`/v1/agents/${agentId}`, { method: "DELETE" })
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
// src/client/extensions.ts
|
|
22
|
+
var createExtensionClient = (request) => ({
|
|
23
|
+
enableInstalled: (projectId, installName, body) => request(`/v1/projects/${projectId}/extensions/installed/${encodeURIComponent(installName)}/enable`, {
|
|
24
|
+
method: "POST",
|
|
25
|
+
body
|
|
26
|
+
}),
|
|
27
|
+
execute: (commandId, input) => {
|
|
28
|
+
const { projectId, ...body } = input;
|
|
29
|
+
return request(`/v1/projects/${projectId}/extensions/commands/${encodeURIComponent(commandId)}/execute`, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
body
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
21
36
|
// src/client/projects.ts
|
|
22
37
|
var createProjectClient = (request) => ({
|
|
23
38
|
list: () => request("/v1/projects"),
|
|
24
39
|
get: (projectId) => request(`/v1/projects/${projectId}`),
|
|
25
40
|
create: (input) => request("/v1/projects", { method: "POST", body: input }),
|
|
26
41
|
delete: (projectId) => request(`/v1/projects/${projectId}`, { method: "DELETE" }),
|
|
42
|
+
listActivity: (projectId, input = {}) => {
|
|
43
|
+
const params = new URLSearchParams;
|
|
44
|
+
if (input.resource_type)
|
|
45
|
+
params.append("resource_type", input.resource_type);
|
|
46
|
+
if (input.event_type)
|
|
47
|
+
params.append("event_type", input.event_type);
|
|
48
|
+
if (input.from)
|
|
49
|
+
params.append("from", input.from);
|
|
50
|
+
if (input.to)
|
|
51
|
+
params.append("to", input.to);
|
|
52
|
+
if (input.cursor)
|
|
53
|
+
params.append("cursor", input.cursor);
|
|
54
|
+
if (input.limit !== undefined)
|
|
55
|
+
params.append("limit", String(input.limit));
|
|
56
|
+
const query = params.toString();
|
|
57
|
+
return request(`/v1/projects/${projectId}/activity${query ? `?${query}` : ""}`);
|
|
58
|
+
},
|
|
27
59
|
listPlugins: (projectId) => request(`/v1/projects/${projectId}/plugins`),
|
|
28
60
|
registerPlugins: (projectId) => request(`/v1/projects/${projectId}/plugins/register`, { method: "POST" }),
|
|
29
61
|
listRepos: (projectId) => request(`/v1/projects/${projectId}/repos`),
|
|
@@ -97,6 +129,21 @@ var createRequest = (options) => {
|
|
|
97
129
|
|
|
98
130
|
// src/client/sessions.ts
|
|
99
131
|
var createSessionClient = (request) => ({
|
|
132
|
+
listActivity: (sessionId, input = {}) => {
|
|
133
|
+
const params = new URLSearchParams;
|
|
134
|
+
if (input.event_type)
|
|
135
|
+
params.append("event_type", input.event_type);
|
|
136
|
+
if (input.from)
|
|
137
|
+
params.append("from", input.from);
|
|
138
|
+
if (input.to)
|
|
139
|
+
params.append("to", input.to);
|
|
140
|
+
if (input.cursor)
|
|
141
|
+
params.append("cursor", input.cursor);
|
|
142
|
+
if (input.limit !== undefined)
|
|
143
|
+
params.append("limit", String(input.limit));
|
|
144
|
+
const query = params.toString();
|
|
145
|
+
return request(`/v1/sessions/${sessionId}/activity${query ? `?${query}` : ""}`);
|
|
146
|
+
},
|
|
100
147
|
list: (projectId) => request(`/v1/sessions?project_id=${projectId}`),
|
|
101
148
|
get: (sessionId) => request(`/v1/sessions/${sessionId}`),
|
|
102
149
|
create: (input) => request("/v1/sessions", { method: "POST", body: input }),
|
|
@@ -179,6 +226,22 @@ var buildTicketsQuery = (projectId, input = {}) => {
|
|
|
179
226
|
params.append("search", input.search);
|
|
180
227
|
return params.toString();
|
|
181
228
|
};
|
|
229
|
+
var buildActivityQuery = (input = {}) => {
|
|
230
|
+
const params = new URLSearchParams;
|
|
231
|
+
if (input.resource_type)
|
|
232
|
+
params.append("resource_type", input.resource_type);
|
|
233
|
+
if (input.event_type)
|
|
234
|
+
params.append("event_type", input.event_type);
|
|
235
|
+
if (input.from)
|
|
236
|
+
params.append("from", input.from);
|
|
237
|
+
if (input.to)
|
|
238
|
+
params.append("to", input.to);
|
|
239
|
+
if (input.cursor)
|
|
240
|
+
params.append("cursor", input.cursor);
|
|
241
|
+
if (input.limit !== undefined)
|
|
242
|
+
params.append("limit", String(input.limit));
|
|
243
|
+
return params.toString();
|
|
244
|
+
};
|
|
182
245
|
var createTicketClient = (request, options = {}) => ({
|
|
183
246
|
list: (projectId, input) => request(`/v1/tickets?${buildTicketsQuery(projectId, input)}`),
|
|
184
247
|
get: (ticketId) => request(`/v1/tickets/${ticketId}`),
|
|
@@ -186,6 +249,14 @@ var createTicketClient = (request, options = {}) => ({
|
|
|
186
249
|
update: (ticketId, input) => request(`/v1/tickets/${ticketId}`, { method: "PATCH", body: input }),
|
|
187
250
|
delete: (ticketId) => request(`/v1/tickets/${ticketId}`, { method: "DELETE" }),
|
|
188
251
|
createAttempt: (ticketId, input) => request(`/v1/tickets/${ticketId}/attempts`, { method: "POST", body: input }),
|
|
252
|
+
listActivity: (ticketId, input) => {
|
|
253
|
+
const query = buildActivityQuery(input);
|
|
254
|
+
return request(`/v1/tickets/${ticketId}/activity${query ? `?${query}` : ""}`);
|
|
255
|
+
},
|
|
256
|
+
listProjectActivity: (projectId, input) => {
|
|
257
|
+
const query = buildActivityQuery(input);
|
|
258
|
+
return request(`/v1/projects/${projectId}/activity${query ? `?${query}` : ""}`);
|
|
259
|
+
},
|
|
189
260
|
updateWhenAttemptStatus: (ticketId, input) => request(`/v1/tickets/${ticketId}/update-when-attempt-status`, { method: "POST", body: input }),
|
|
190
261
|
listFiles: (ticketId) => request(`/v1/tickets/${ticketId}/files`),
|
|
191
262
|
getFileContent: async (ticketId, fileId) => {
|
|
@@ -206,6 +277,21 @@ var createTicketClient = (request, options = {}) => ({
|
|
|
206
277
|
|
|
207
278
|
// src/client/workspaces.ts
|
|
208
279
|
var createWorkspaceClient = (request) => ({
|
|
280
|
+
listActivity: (workspaceId, input = {}) => {
|
|
281
|
+
const params = new URLSearchParams;
|
|
282
|
+
if (input.event_type)
|
|
283
|
+
params.append("event_type", input.event_type);
|
|
284
|
+
if (input.from)
|
|
285
|
+
params.append("from", input.from);
|
|
286
|
+
if (input.to)
|
|
287
|
+
params.append("to", input.to);
|
|
288
|
+
if (input.cursor)
|
|
289
|
+
params.append("cursor", input.cursor);
|
|
290
|
+
if (input.limit !== undefined)
|
|
291
|
+
params.append("limit", String(input.limit));
|
|
292
|
+
const query = params.toString();
|
|
293
|
+
return request(`/v1/workspaces/${workspaceId}/activity${query ? `?${query}` : ""}`);
|
|
294
|
+
},
|
|
209
295
|
list: (projectId) => request(`/v1/workspaces?project_id=${projectId}`),
|
|
210
296
|
getByShorthand: (projectId, shorthand) => request(`/v1/workspaces/by-shorthand?project_id=${encodeURIComponent(projectId)}&shorthand=${encodeURIComponent(shorthand)}`),
|
|
211
297
|
create: (input) => request("/v1/workspaces", { method: "POST", body: input }),
|
|
@@ -227,7 +313,8 @@ var createClient = (options = {}) => {
|
|
|
227
313
|
templates: createTemplateClient(request),
|
|
228
314
|
skills: createSkillClient(request),
|
|
229
315
|
agents: createAgentClient(request),
|
|
230
|
-
actions: createActionClient(request)
|
|
316
|
+
actions: createActionClient(request),
|
|
317
|
+
extensions: createExtensionClient(request)
|
|
231
318
|
};
|
|
232
319
|
};
|
|
233
320
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CreateProjectInput, RegisterRepoInput, Repo } from "pstdio-api-contracts";
|
|
1
|
+
import type { CreateProjectInput, ListProjectActivityForTicketsInput, ListTicketActivityResponse, RegisterRepoInput, Repo } from "pstdio-api-contracts";
|
|
2
2
|
import type { Project } from "../resources";
|
|
3
3
|
import type { RequestFn } from "./request";
|
|
4
4
|
type RegisteredPlugin = {
|
|
@@ -16,6 +16,7 @@ export type ProjectClient = {
|
|
|
16
16
|
delete(projectId: string): Promise<void>;
|
|
17
17
|
listPlugins(projectId: string): Promise<RegisteredPluginsResponse>;
|
|
18
18
|
registerPlugins(projectId: string): Promise<RegisteredPluginsResponse>;
|
|
19
|
+
listActivity(projectId: string, input?: ListProjectActivityForTicketsInput): Promise<ListTicketActivityResponse>;
|
|
19
20
|
listRepos(projectId: string): Promise<Repo[]>;
|
|
20
21
|
registerRepo(projectId: string, input: RegisterRepoInput): Promise<Repo>;
|
|
21
22
|
removeRepo(projectId: string, repoId: string): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApprovalInput, CreateSessionInput, FollowUpInput, ResolveSessionIdInput, ResolveSessionIdResponse, SessionConversationResponse } from "pstdio-api-contracts";
|
|
1
|
+
import type { ApprovalInput, CreateSessionInput, FollowUpInput, ListSessionActivityInput, ListSessionActivityResponse, ResolveSessionIdInput, ResolveSessionIdResponse, SessionConversationResponse } from "pstdio-api-contracts";
|
|
2
2
|
import type { Session } from "../resources";
|
|
3
3
|
import type { RequestFn } from "./request";
|
|
4
4
|
export type SessionClient = {
|
|
@@ -11,5 +11,6 @@ export type SessionClient = {
|
|
|
11
11
|
getConversation(sessionId: string): Promise<SessionConversationResponse>;
|
|
12
12
|
resolveSessionId(input: ResolveSessionIdInput): Promise<ResolveSessionIdResponse>;
|
|
13
13
|
updateStatus(sessionId: string, status: string): Promise<Session>;
|
|
14
|
+
listActivity(sessionId: string, input?: ListSessionActivityInput): Promise<ListSessionActivityResponse>;
|
|
14
15
|
};
|
|
15
16
|
export declare const createSessionClient: (request: RequestFn) => SessionClient;
|
package/dist/client/tickets.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CreateTicketAttemptInput, CreateTicketInput, ListTicketsInput, TicketAttemptResponse, UpdateTicketInput, UpdateWhenAttemptStatusInput, UpdateWhenAttemptStatusResponse, UploadTicketFileInput } from "../api/tickets";
|
|
1
|
+
import type { CreateTicketAttemptInput, CreateTicketInput, ListProjectActivityForTicketsInput, ListTicketActivityInput, ListTicketActivityResponse, ListTicketsInput, TicketAttemptResponse, UpdateTicketInput, UpdateWhenAttemptStatusInput, UpdateWhenAttemptStatusResponse, UploadTicketFileInput } from "../api/tickets";
|
|
2
2
|
import type { Ticket, TicketDetail, TicketFile, TicketListItem } from "../resources";
|
|
3
3
|
import { type ClientOptions, type RequestFn } from "./request";
|
|
4
4
|
export type TicketClient = {
|
|
@@ -8,6 +8,8 @@ export type TicketClient = {
|
|
|
8
8
|
update(ticketId: string, input: UpdateTicketInput): Promise<Ticket>;
|
|
9
9
|
delete(ticketId: string): Promise<void>;
|
|
10
10
|
createAttempt(ticketId: string, input: CreateTicketAttemptInput): Promise<TicketAttemptResponse>;
|
|
11
|
+
listActivity(ticketId: string, input?: ListTicketActivityInput): Promise<ListTicketActivityResponse>;
|
|
12
|
+
listProjectActivity(projectId: string, input?: ListProjectActivityForTicketsInput): Promise<ListTicketActivityResponse>;
|
|
11
13
|
updateWhenAttemptStatus(ticketId: string, input: UpdateWhenAttemptStatusInput): Promise<UpdateWhenAttemptStatusResponse>;
|
|
12
14
|
listFiles(ticketId: string): Promise<TicketFile[]>;
|
|
13
15
|
getFileContent(ticketId: string, fileId: string): Promise<Uint8Array>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CreateWorkspaceInput, RemoveWorktreeResponse, UpdateAttemptStatusInput, UpdateAttemptStatusResponse } from "pstdio-api-contracts";
|
|
1
|
+
import type { CreateWorkspaceInput, ListWorkspaceActivityInput, ListWorkspaceActivityResponse, RemoveWorktreeResponse, UpdateAttemptStatusInput, UpdateAttemptStatusResponse } from "pstdio-api-contracts";
|
|
2
2
|
import type { Workspace, WorkspaceListItem } from "../resources";
|
|
3
3
|
import type { RequestFn } from "./request";
|
|
4
4
|
export type WorkspaceClient = {
|
|
@@ -6,6 +6,7 @@ export type WorkspaceClient = {
|
|
|
6
6
|
getByShorthand(projectId: string, shorthand: string): Promise<Workspace>;
|
|
7
7
|
create(input: CreateWorkspaceInput): Promise<Workspace>;
|
|
8
8
|
updateAttemptStatus(workspaceId: string, input: UpdateAttemptStatusInput): Promise<UpdateAttemptStatusResponse>;
|
|
9
|
+
listActivity(workspaceId: string, input?: ListWorkspaceActivityInput): Promise<ListWorkspaceActivityResponse>;
|
|
9
10
|
removeWorktree(workspaceId: string): Promise<RemoveWorktreeResponse>;
|
|
10
11
|
delete(workspaceId: string): Promise<void>;
|
|
11
12
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CommandDefinition, HookDefinition, MiddlewareDefinition } from "./types/extension";
|
|
2
|
+
import type { Struct } from "./types/json";
|
|
3
|
+
import type { ParamObjectSchema } from "./types/params";
|
|
4
|
+
/**
|
|
5
|
+
* Define a single command outside an extension's object literal. Use this when commands
|
|
6
|
+
* grow large enough to split into separate files, or when you need to share a command
|
|
7
|
+
* shape across extensions. The `params` schema drives the inferred shape of `ctx.params`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* export const sayHello = defineCommand({
|
|
11
|
+
* title: "Say hello",
|
|
12
|
+
* params: { name: params.text() },
|
|
13
|
+
* async run(ctx) {
|
|
14
|
+
* ctx.params.name; // string
|
|
15
|
+
* },
|
|
16
|
+
* });
|
|
17
|
+
*/
|
|
18
|
+
export declare const defineCommand: <const TSchema extends ParamObjectSchema | undefined, TResult = unknown>(definition: CommandDefinition<TSchema, TResult>) => CommandDefinition<TSchema, TResult>;
|
|
19
|
+
/**
|
|
20
|
+
* Define middleware for a command. Pass the typed `command` ref (preferred) or
|
|
21
|
+
* `commandId` for cross-extension references where the typed ref isn't importable.
|
|
22
|
+
*/
|
|
23
|
+
export declare const defineMiddleware: <TParams extends Struct = Struct, TResult = unknown>(definition: MiddlewareDefinition<TParams, TResult>) => MiddlewareDefinition<TParams, TResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Define a hook for an event. Pass the typed `event` ref (preferred) or `eventId` for
|
|
26
|
+
* cross-extension references where the typed ref isn't importable.
|
|
27
|
+
*/
|
|
28
|
+
export declare const defineHook: <TPayload extends Struct = Struct>(definition: HookDefinition<TPayload>) => HookDefinition<TPayload>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ExtensionDefinition } from "./types/extension";
|
|
2
|
+
/**
|
|
3
|
+
* Identity helper that preserves the literal type of the passed extension. Authors get
|
|
4
|
+
* full autocomplete on contributions, and `commandsOf(ext)` can derive typed refs from
|
|
5
|
+
* the returned definition.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* export default defineExtension({
|
|
9
|
+
* id: "pstdio.example",
|
|
10
|
+
* namespace: "example",
|
|
11
|
+
* name: "Example",
|
|
12
|
+
* apiVersion: "1",
|
|
13
|
+
* commands: { ... },
|
|
14
|
+
* });
|
|
15
|
+
*/
|
|
16
|
+
export declare const defineExtension: <const TExtension extends ExtensionDefinition>(extension: TExtension) => TExtension;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { defineCommand, defineHook, defineMiddleware } from "./define-command";
|
|
2
|
+
export { defineExtension } from "./define-extension";
|
|
3
|
+
export { projectEvents, projectSlots, sessionEvents, sessionSlots, workspaceEvents, workspaceSlots, } from "./kernel-slots";
|
|
4
|
+
export { packageAsset } from "./package-asset";
|
|
5
|
+
export { params } from "./params";
|
|
6
|
+
export { commandEvent, commandRef, commandsOf, eventRef } from "./refs";
|
|
7
|
+
export { defineSlot } from "./slots";
|
|
8
|
+
export type * from "./types";
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// src/extensions/define-command.ts
|
|
2
|
+
var defineCommand = (definition) => definition;
|
|
3
|
+
var defineMiddleware = (definition) => definition;
|
|
4
|
+
var defineHook = (definition) => definition;
|
|
5
|
+
// src/extensions/define-extension.ts
|
|
6
|
+
var defineExtension = (extension) => extension;
|
|
7
|
+
// src/extensions/refs.ts
|
|
8
|
+
var commandRef = (id) => ({ id });
|
|
9
|
+
var eventRef = (id) => ({ id });
|
|
10
|
+
var commandEvent = (command, phase) => ({
|
|
11
|
+
id: `command.${phase}:${command.id}`
|
|
12
|
+
});
|
|
13
|
+
var commandsOf = (extension) => {
|
|
14
|
+
const refs = {};
|
|
15
|
+
const commands = extension.commands ?? {};
|
|
16
|
+
for (const key of Object.keys(commands)) {
|
|
17
|
+
refs[key] = { id: `${extension.namespace}.${key}` };
|
|
18
|
+
}
|
|
19
|
+
return refs;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/extensions/slots.ts
|
|
23
|
+
var defineSlot = (id, options) => ({
|
|
24
|
+
id,
|
|
25
|
+
kind: options.kind,
|
|
26
|
+
label: options.label,
|
|
27
|
+
description: options.description,
|
|
28
|
+
metadata: options.metadata
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// src/extensions/kernel-slots.ts
|
|
32
|
+
var projectSlots = {
|
|
33
|
+
sidebarNav: defineSlot("project.sidebarNav", { kind: "navigation" }),
|
|
34
|
+
sidebar: defineSlot("project.sidebar", { kind: "view" }),
|
|
35
|
+
headerPrimary: defineSlot("project.headerPrimary", { kind: "menu" }),
|
|
36
|
+
headerOverflow: defineSlot("project.headerOverflow", { kind: "menu" }),
|
|
37
|
+
settingsPanels: defineSlot("project.settingsPanels", { kind: "settings" })
|
|
38
|
+
};
|
|
39
|
+
var sessionSlots = {
|
|
40
|
+
headerPrimary: defineSlot("session.headerPrimary", { kind: "menu" }),
|
|
41
|
+
headerOverflow: defineSlot("session.headerOverflow", { kind: "menu" }),
|
|
42
|
+
transcriptActions: defineSlot("session.transcriptActions", { kind: "menu" })
|
|
43
|
+
};
|
|
44
|
+
var workspaceSlots = {
|
|
45
|
+
headerPrimary: defineSlot("workspace.headerPrimary", { kind: "menu" }),
|
|
46
|
+
headerOverflow: defineSlot("workspace.headerOverflow", { kind: "menu" }),
|
|
47
|
+
tabs: defineSlot("workspace.tabs", { kind: "navigation" }),
|
|
48
|
+
sidebar: defineSlot("workspace.sidebar", { kind: "view" })
|
|
49
|
+
};
|
|
50
|
+
var projectEvents = {
|
|
51
|
+
opened: eventRef("project.opened")
|
|
52
|
+
};
|
|
53
|
+
var sessionEvents = {
|
|
54
|
+
started: eventRef("session.started"),
|
|
55
|
+
completed: eventRef("session.completed")
|
|
56
|
+
};
|
|
57
|
+
var workspaceEvents = {
|
|
58
|
+
created: eventRef("workspace.created"),
|
|
59
|
+
archived: eventRef("workspace.archived"),
|
|
60
|
+
deleted: eventRef("workspace.deleted")
|
|
61
|
+
};
|
|
62
|
+
// src/extensions/package-asset.ts
|
|
63
|
+
var packageAsset = (path, baseUrl) => ({
|
|
64
|
+
kind: "package-asset",
|
|
65
|
+
path,
|
|
66
|
+
baseUrl
|
|
67
|
+
});
|
|
68
|
+
// src/extensions/params.ts
|
|
69
|
+
var params = {
|
|
70
|
+
text: (options = {}) => ({ type: "text", ...options }),
|
|
71
|
+
longText: (options = {}) => ({ type: "longtext", ...options }),
|
|
72
|
+
number: (options = {}) => ({ type: "number", ...options }),
|
|
73
|
+
boolean: (options = {}) => ({ type: "boolean", ...options }),
|
|
74
|
+
select: (options) => ({ type: "select", ...options }),
|
|
75
|
+
multiSelect: (options) => ({
|
|
76
|
+
type: "multi-select",
|
|
77
|
+
...options
|
|
78
|
+
}),
|
|
79
|
+
repo: (options = {}) => ({ type: "repo", ...options }),
|
|
80
|
+
harness: (options = {}) => ({ type: "harness", ...options }),
|
|
81
|
+
template: (options) => ({
|
|
82
|
+
label: options.label,
|
|
83
|
+
description: options.description,
|
|
84
|
+
required: options.required,
|
|
85
|
+
defaultValue: options.defaultValue,
|
|
86
|
+
metadata: options.metadata,
|
|
87
|
+
type: "template",
|
|
88
|
+
templateType: options.type
|
|
89
|
+
}),
|
|
90
|
+
resource: (options) => ({ type: "resource", ...options }),
|
|
91
|
+
json: (options = {}) => ({ type: "json", ...options })
|
|
92
|
+
};
|
|
93
|
+
export {
|
|
94
|
+
workspaceSlots,
|
|
95
|
+
workspaceEvents,
|
|
96
|
+
sessionSlots,
|
|
97
|
+
sessionEvents,
|
|
98
|
+
projectSlots,
|
|
99
|
+
projectEvents,
|
|
100
|
+
params,
|
|
101
|
+
packageAsset,
|
|
102
|
+
eventRef,
|
|
103
|
+
defineSlot,
|
|
104
|
+
defineMiddleware,
|
|
105
|
+
defineHook,
|
|
106
|
+
defineExtension,
|
|
107
|
+
defineCommand,
|
|
108
|
+
commandsOf,
|
|
109
|
+
commandRef,
|
|
110
|
+
commandEvent
|
|
111
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { JsonObject } from "./types/json";
|
|
2
|
+
import type { ResourceAnchor } from "./types/resources";
|
|
3
|
+
export declare const projectSlots: {
|
|
4
|
+
sidebarNav: import("./types").SlotRef<object, "navigation">;
|
|
5
|
+
sidebar: import("./types").SlotRef<object, "view">;
|
|
6
|
+
headerPrimary: import("./types").SlotRef<object, "menu">;
|
|
7
|
+
headerOverflow: import("./types").SlotRef<object, "menu">;
|
|
8
|
+
settingsPanels: import("./types").SlotRef<object, "settings">;
|
|
9
|
+
};
|
|
10
|
+
export declare const sessionSlots: {
|
|
11
|
+
headerPrimary: import("./types").SlotRef<object, "menu">;
|
|
12
|
+
headerOverflow: import("./types").SlotRef<object, "menu">;
|
|
13
|
+
transcriptActions: import("./types").SlotRef<object, "menu">;
|
|
14
|
+
};
|
|
15
|
+
export declare const workspaceSlots: {
|
|
16
|
+
headerPrimary: import("./types").SlotRef<object, "menu">;
|
|
17
|
+
headerOverflow: import("./types").SlotRef<object, "menu">;
|
|
18
|
+
tabs: import("./types").SlotRef<object, "navigation">;
|
|
19
|
+
sidebar: import("./types").SlotRef<object, "view">;
|
|
20
|
+
};
|
|
21
|
+
export declare const projectEvents: {
|
|
22
|
+
opened: import("./types").EventRef<{
|
|
23
|
+
projectId: string;
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
26
|
+
export declare const sessionEvents: {
|
|
27
|
+
started: import("./types").EventRef<{
|
|
28
|
+
sessionId: string;
|
|
29
|
+
anchors?: ResourceAnchor[];
|
|
30
|
+
}>;
|
|
31
|
+
completed: import("./types").EventRef<{
|
|
32
|
+
sessionId: string;
|
|
33
|
+
anchors?: ResourceAnchor[];
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
export declare const workspaceEvents: {
|
|
37
|
+
created: import("./types").EventRef<{
|
|
38
|
+
workspace: JsonObject;
|
|
39
|
+
}>;
|
|
40
|
+
archived: import("./types").EventRef<{
|
|
41
|
+
workspace: JsonObject;
|
|
42
|
+
}>;
|
|
43
|
+
deleted: import("./types").EventRef<{
|
|
44
|
+
workspace: JsonObject;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PackageAssetDescriptor } from "./types/resources";
|
|
2
|
+
/**
|
|
3
|
+
* Reference an asset shipped alongside the extension's compiled output. `path` is
|
|
4
|
+
* resolved relative to `baseUrl`; in practice authors always pass `import.meta.url`
|
|
5
|
+
* so the runtime can locate the file no matter where the extension is installed.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* webview: { entry: packageAsset("./dist/page.html", import.meta.url) }
|
|
9
|
+
*/
|
|
10
|
+
export declare const packageAsset: (path: string, baseUrl: string) => PackageAssetDescriptor;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { BooleanParam, HarnessParam, JsonParam, LongTextParam, MultiSelectParam, NumberParam, RepoParam, ResourceParam, SelectParam, TemplateParam, TextParam } from "./types/params";
|
|
2
|
+
/**
|
|
3
|
+
* Builders for typed parameter descriptors. Each builder produces a discriminated
|
|
4
|
+
* `ParamDescriptor` so the runtime and editor only see fields valid for that type.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* params: {
|
|
8
|
+
* amount: params.number({ defaultValue: 1 }),
|
|
9
|
+
* mode: params.select({ options: [{ label: "Fast", value: "fast" }] }),
|
|
10
|
+
* }
|
|
11
|
+
*/
|
|
12
|
+
export declare const params: {
|
|
13
|
+
text: (options?: Omit<TextParam, "type">) => TextParam;
|
|
14
|
+
longText: (options?: Omit<LongTextParam, "type">) => LongTextParam;
|
|
15
|
+
number: (options?: Omit<NumberParam, "type">) => NumberParam;
|
|
16
|
+
boolean: (options?: Omit<BooleanParam, "type">) => BooleanParam;
|
|
17
|
+
select: (options: Omit<SelectParam, "type">) => SelectParam;
|
|
18
|
+
multiSelect: (options: Omit<MultiSelectParam, "type">) => MultiSelectParam;
|
|
19
|
+
repo: (options?: Omit<RepoParam, "type">) => RepoParam;
|
|
20
|
+
harness: (options?: Omit<HarnessParam, "type">) => HarnessParam;
|
|
21
|
+
template: (options: Omit<TemplateParam, "type" | "templateType"> & {
|
|
22
|
+
type: string;
|
|
23
|
+
}) => TemplateParam;
|
|
24
|
+
resource: (options: Omit<ResourceParam, "type">) => ResourceParam;
|
|
25
|
+
json: <T = unknown>(options?: Omit<JsonParam<T>, "type">) => JsonParam<T>;
|
|
26
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CommandLifecycleEventPayload, CommandLifecyclePhase, CommandRef } from "./types/commands";
|
|
2
|
+
import type { EventRef } from "./types/events";
|
|
3
|
+
import type { CommandDefinition } from "./types/extension";
|
|
4
|
+
import type { Struct } from "./types/json";
|
|
5
|
+
import type { ParamObjectSchema, ParamsOf } from "./types/params";
|
|
6
|
+
/**
|
|
7
|
+
* Build a typed reference to a command by id. Authors generally prefer `commandsOf(ext)`,
|
|
8
|
+
* which derives refs from the extension definition so a renamed command becomes a type
|
|
9
|
+
* error at every call site.
|
|
10
|
+
*/
|
|
11
|
+
export declare const commandRef: <TParams extends Struct = Struct, TResult = unknown>(id: string) => CommandRef<TParams, TResult>;
|
|
12
|
+
/** Build a typed reference to an event by id. */
|
|
13
|
+
export declare const eventRef: <TPayload extends Struct = Struct>(id: string) => EventRef<TPayload>;
|
|
14
|
+
/**
|
|
15
|
+
* Build an `EventRef` for a command lifecycle phase (`requested`, `started`, `completed`,
|
|
16
|
+
* `rejected`, `failed`). The payload type is inferred from the command ref so hooks see
|
|
17
|
+
* the correct shape.
|
|
18
|
+
*/
|
|
19
|
+
export declare const commandEvent: <TPhase extends CommandLifecyclePhase, TParams extends Struct = Struct, TResult = unknown>(command: CommandRef<TParams, TResult>, phase: TPhase) => EventRef<CommandLifecycleEventPayload<TPhase, TParams, TResult>>;
|
|
20
|
+
type CommandsRecord = Record<string, CommandDefinition<any, any>>;
|
|
21
|
+
type CommandRefFromDefinition<TDefinition> = TDefinition extends CommandDefinition<infer TSchema, infer TResult> ? CommandRef<TSchema extends ParamObjectSchema ? ParamsOf<TSchema> : Struct, TResult> : never;
|
|
22
|
+
type CommandsRefMap<TCommands extends CommandsRecord> = {
|
|
23
|
+
[K in keyof TCommands]: CommandRefFromDefinition<TCommands[K]>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Derive typed `CommandRef`s from an extension. Renaming a command in the definition
|
|
27
|
+
* surfaces as a type error wherever the ref is used.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const ext = defineExtension({ id: "lab", namespace: "lab", commands: { ... } });
|
|
31
|
+
* const labCommands = commandsOf(ext);
|
|
32
|
+
* labCommands.awaken; // CommandRef<{ title: string }, ...>
|
|
33
|
+
*/
|
|
34
|
+
export declare const commandsOf: <TExtension extends {
|
|
35
|
+
namespace: string;
|
|
36
|
+
commands?: CommandsRecord;
|
|
37
|
+
}>(extension: TExtension) => CommandsRefMap<NonNullable<TExtension["commands"]>>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Struct } from "./types/json";
|
|
2
|
+
import type { SlotOptions, SlotRef, UiSlotKind } from "./types/slots";
|
|
3
|
+
/**
|
|
4
|
+
* Define a UI slot that contributions can target. The `TContext` parameter constrains
|
|
5
|
+
* the data passed to renderers/menus invoked through the slot, and `TKind` picks the
|
|
6
|
+
* contribution shape (`menu`, `navigation`, `view`, `settings`, `renderer`).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* export const projectHeader = defineSlot<{ projectId: string }, "menu">("project.header", {
|
|
10
|
+
* kind: "menu",
|
|
11
|
+
* label: "Project header",
|
|
12
|
+
* });
|
|
13
|
+
*/
|
|
14
|
+
export declare const defineSlot: <TContext extends Struct = Struct, TKind extends UiSlotKind = UiSlotKind>(id: string, options: SlotOptions<TKind>) => SlotRef<TContext, TKind>;
|