@pstdio/sdk 0.1.0 → 0.2.1

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/README.md ADDED
@@ -0,0 +1,357 @@
1
+ # @pstdio/sdk
2
+
3
+ TypeScript SDK for Prompt Studio.
4
+
5
+ This package is the public integration surface for:
6
+
7
+ - calling the Prompt Studio HTTP API
8
+ - importing shared request and resource types
9
+ - rendering prompt templates
10
+ - authoring Prompt Studio plugins, actions, and lifecycle hooks
11
+
12
+ The package is ESM-only and is published through subpath exports. Import from the entrypoint you need, not from `@pstdio/sdk` directly.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ bun add @pstdio/sdk
18
+ ```
19
+
20
+ ## Entry Points
21
+
22
+ | Import path | Purpose |
23
+ | ----------------------- | --------------------------------------------------------- |
24
+ | `@pstdio/sdk/client` | Runtime HTTP client for Prompt Studio |
25
+ | `@pstdio/sdk/api` | Request and response payload types |
26
+ | `@pstdio/sdk/resources` | Shared resource/entity types |
27
+ | `@pstdio/sdk/plugins` | Plugin definition types, hook types, and helper utilities |
28
+ | `@pstdio/sdk/prompts` | Prompt rendering helpers |
29
+ | `@pstdio/sdk/hooks` | Hook context and hook client types |
30
+
31
+ Example:
32
+
33
+ ```ts
34
+ import { createClient, PstdioApiError } from "@pstdio/sdk/client";
35
+ import type { CreateTicketInput } from "@pstdio/sdk/api";
36
+ import type { TicketDetail } from "@pstdio/sdk/resources";
37
+ import { createSession, definePlugin } from "@pstdio/sdk/plugins";
38
+ import { renderPrompt } from "@pstdio/sdk/prompts";
39
+ import type { AttemptStatusChangeContext } from "@pstdio/sdk/hooks";
40
+ ```
41
+
42
+ ## HTTP Client
43
+
44
+ Create a client with `createClient()`:
45
+
46
+ ```ts
47
+ import { createClient } from "@pstdio/sdk/client";
48
+
49
+ const client = createClient({
50
+ baseUrl: process.env.PSTDIO_API_URL,
51
+ token: process.env.PSTDIO_API_TOKEN,
52
+ });
53
+
54
+ const tickets = await client.tickets.list("proj_123", {
55
+ status: "wip",
56
+ tag: ["backend", "bug"],
57
+ });
58
+ ```
59
+
60
+ ### Client options
61
+
62
+ - `baseUrl`: API base URL. Defaults to `process.env.PSTDIO_API_URL ?? "http://localhost:19840"`.
63
+ - `token`: Optional bearer token. Sent as `Authorization: Bearer <token>`.
64
+ - `fetch`: Optional `fetch` implementation override for tests or custom runtimes.
65
+
66
+ The client expects a runtime with `fetch` available, or an explicit `fetch` passed in through options.
67
+
68
+ ### Error handling
69
+
70
+ The request layer throws `PstdioApiError` for non-2xx responses.
71
+
72
+ - `error.message`: API error message
73
+ - `error.status`: HTTP status code
74
+ - when the API returns `hook_output`, it is appended to `message`
75
+
76
+ ```ts
77
+ import { PstdioApiError, createClient } from "@pstdio/sdk/client";
78
+
79
+ const client = createClient();
80
+
81
+ try {
82
+ await client.workspaces.updateAttemptStatus("ws_123", {
83
+ status: "review-ready",
84
+ });
85
+ } catch (error) {
86
+ if (error instanceof PstdioApiError) {
87
+ console.error(error.status, error.message);
88
+ }
89
+ throw error;
90
+ }
91
+ ```
92
+
93
+ ### Client groups
94
+
95
+ `createClient()` returns a grouped client with these domains:
96
+
97
+ | Group | Methods |
98
+ | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
99
+ | `projects` | `list`, `get`, `create`, `delete`, `listRepos`, `registerRepo`, `removeRepo` |
100
+ | `tickets` | `list`, `get`, `create`, `update`, `delete`, `createAttempt`, `updateWhenAttemptStatus`, `listFiles`, `getFileContent`, `uploadFile`, `deleteFile` |
101
+ | `workspaces` | `list`, `getByShorthand`, `create`, `updateAttemptStatus`, `removeWorktree`, `delete` |
102
+ | `sessions` | `list`, `get`, `create`, `archive`, `followUp`, `approve`, `getConversation`, `resolveSessionId`, `updateStatus` |
103
+ | `statuses` | `list`, `create`, `update`, `setDefault`, `delete`, `listAttemptStatuses`, `createAttemptStatus`, `updateAttemptStatus`, `deleteAttemptStatus` |
104
+ | `tags` | `list`, `create`, `update`, `delete`, `createOption`, `updateOption`, `deleteOption` |
105
+ | `templates` | `list`, `get`, `create`, `update`, `delete` |
106
+ | `skills` | `list`, `get`, `update` |
107
+ | `agents` | `list`, `info`, `models`, `setup`, `setupAvailable`, `update`, `delete` |
108
+ | `actions` | `list`, `execute` |
109
+
110
+ Notes:
111
+
112
+ - `tickets.list(projectId, filters)` supports `status`, `tag`, `archived`, `draft`, `parent_id`, `shorthand`, and `search`.
113
+ - `tickets.getFileContent(ticketId, fileId)` returns `Uint8Array`, not JSON.
114
+ - `createRequest()` is also exported if you want the lower-level request function without the grouped client.
115
+
116
+ ## API Types
117
+
118
+ `@pstdio/sdk/api` re-exports the public request and response types used by the HTTP client.
119
+
120
+ ```ts
121
+ import type {
122
+ CreateSessionInput,
123
+ CreateTicketInput,
124
+ UpdateTicketInput,
125
+ } from "@pstdio/sdk/api";
126
+ ```
127
+
128
+ Most of these types come from `pstdio-api-contracts`. The SDK also defines a few client-facing types:
129
+
130
+ - `ListTicketsInput`
131
+ - `TicketAttemptResponse`
132
+ - `ActionResult`
133
+ - `ExecuteActionInput`
134
+
135
+ Use `import type` for this entrypoint. It does not expose runtime helpers.
136
+
137
+ ## Resource Types
138
+
139
+ `@pstdio/sdk/resources` re-exports the shared Prompt Studio entities used across the API and plugin system.
140
+
141
+ Common exports include `Project`, `Repo`, `Ticket`, `TicketDetail`, `TicketListItem`, `TicketFile`, `Workspace`,
142
+ `WorkspaceListItem`, `Session`, `SessionStatus`, `Status`, `AttemptStatus`, `Tag`, `TagOption`, `Template`,
143
+ `TemplateWithContent`, `TemplateType`, `Skill`, `SkillWithContent`, `AgentConfig`, `AgentInfo`, `AgentModel`,
144
+ `AgentAvailabilityType`, and `FileRecord`.
145
+
146
+ ```ts
147
+ import type {
148
+ Session,
149
+ TicketDetail,
150
+ WorkspaceListItem,
151
+ } from "@pstdio/sdk/resources";
152
+ ```
153
+
154
+ ## Prompt Rendering
155
+
156
+ `@pstdio/sdk/prompts` exposes `renderPrompt(template, data)`, a small wrapper around Mustache.
157
+
158
+ ```ts
159
+ import { renderPrompt } from "@pstdio/sdk/prompts";
160
+
161
+ const prompt = renderPrompt("Implement ticket {{ticket}}", {
162
+ ticket: "PS-42",
163
+ });
164
+ ```
165
+
166
+ Use this when a session prompt or action prompt is stored as a reusable template with variables.
167
+
168
+ ## Plugins
169
+
170
+ Prompt Studio plugins export a default `definePlugin(...)` result from a TypeScript or JavaScript module.
171
+
172
+ Plugins can provide:
173
+
174
+ - `actions`: user-triggered actions attached to tickets, workspaces, or sessions
175
+ - `hooks`: lifecycle handlers that run before or after Prompt Studio events
176
+
177
+ ### Action example
178
+
179
+ ```ts
180
+ import { createSession, definePlugin } from "@pstdio/sdk/plugins";
181
+
182
+ export default definePlugin({
183
+ actions: [
184
+ {
185
+ key: "refine-ticket",
186
+ label: "Refine ticket",
187
+ targetType: "ticket",
188
+ placement: "overflow",
189
+ params: [
190
+ {
191
+ key: "context",
192
+ label: "Additional context",
193
+ type: "longtext",
194
+ required: false,
195
+ },
196
+ ],
197
+ async trigger(ctx) {
198
+ const context = ctx.params.context as string | undefined;
199
+
200
+ const parts = [`Refine ticket: ${ctx.target.shorthand}`];
201
+ if (context) parts.push(`Additional context:\n${context}`);
202
+
203
+ await createSession(ctx, {
204
+ title: `Refine ticket: ${ctx.target.shorthand}`,
205
+ prompt: parts.join("\n\n"),
206
+ });
207
+ },
208
+ },
209
+ ],
210
+ });
211
+ ```
212
+
213
+ ### Hook example
214
+
215
+ ```ts
216
+ import { definePlugin, runCommand } from "@pstdio/sdk/plugins";
217
+
218
+ export default definePlugin({
219
+ hooks: {
220
+ async preAttemptStatusChange(ctx) {
221
+ if (ctx.toStatus !== "review-ready") return;
222
+ if (!ctx.worktreePath) return;
223
+
224
+ const validation = await runCommand(ctx.worktreePath, [
225
+ "bun",
226
+ "run",
227
+ "validate",
228
+ ]);
229
+ if (validation.exitCode === 0) return;
230
+
231
+ const output = [validation.stdout, validation.stderr]
232
+ .filter(Boolean)
233
+ .join("\n\n");
234
+
235
+ return {
236
+ reject: true,
237
+ reason: output || "bun run validate failed",
238
+ };
239
+ },
240
+ },
241
+ });
242
+ ```
243
+
244
+ ### Plugin types
245
+
246
+ The plugin entrypoint exports the core types used by plugin authors, including `PluginDefinition`, `PluginHooks`,
247
+ `PrePluginHooks`, `PostPluginHooks`, `HookResponse`, `PreHookReturn`, `PostHookReturn`, `ActionDefinition`,
248
+ `ActionDescriptor`, `ActionInput`, `ActionTriggerContext`, `ActionParamDef`, `TargetType`, and `ActionPlacement`.
249
+
250
+ Action parameter definitions support `text`, `longtext`, `select`, `template-select`, `agent`, and `repo`.
251
+ Action targets support `ticket`, `workspace`, and `session`. Action placement supports `primary`, `secondary`,
252
+ and `overflow`.
253
+
254
+ `definePlugin()` is intentionally small. Today it mainly validates that every declared action has a `trigger(ctx)` function and then returns the plugin definition unchanged.
255
+
256
+ ### Lifecycle hooks
257
+
258
+ Pre hooks may return `{ reject, reason, data }` to stop an operation. Post hooks return `void`.
259
+
260
+ Available pre hooks:
261
+
262
+ - `preTicketCreation`
263
+ - `preTicketStatusChange`
264
+ - `preTicketArchive`
265
+ - `preTicketDeletion`
266
+ - `preWorktreeCreate`
267
+ - `preWorktreeRemove`
268
+ - `preCommit`
269
+ - `preRebase`
270
+ - `preMerge`
271
+ - `preAttemptStatusChange`
272
+
273
+ Available post hooks:
274
+
275
+ - `postTicketCreation`
276
+ - `postTicketStatusChange`
277
+ - `postTicketArchive`
278
+ - `postTicketDeletion`
279
+ - `postSessionStart`
280
+ - `postSessionSuccess`
281
+ - `postSessionFail`
282
+ - `postSessionResume`
283
+ - `postSessionAwaitInput`
284
+ - `postWorktreeCreate`
285
+ - `postWorktreeRemove`
286
+ - `postCommit`
287
+ - `postRebase`
288
+ - `postMerge`
289
+ - `onConflict`
290
+ - `postAttemptStatusChange`
291
+
292
+ ### Plugin helpers
293
+
294
+ `@pstdio/sdk/plugins` also exports helper functions for common workflow automation:
295
+
296
+ | Helper | Purpose |
297
+ | ---------------------------------- | -------------------------------------------------------------------------------------------- |
298
+ | `createAttempt` | Create a ticket attempt and start a session |
299
+ | `createWorkspace` | Create a ticket attempt without starting a session |
300
+ | `createSession` | Create a session using `ctx.projectId` automatically |
301
+ | `followupSession` | Send a follow-up message using an explicit or contextual session id |
302
+ | `findTicketByRef` | Resolve a ticket by id or shorthand |
303
+ | `findWorkspaceByRef` | Resolve a workspace by id or shorthand |
304
+ | `getAttemptsForTicket` | List workspaces for a ticket |
305
+ | `workspacesForTicket` | List workspaces for a ticket |
306
+ | `setTicketStatus` | Resolve a status by name and update the ticket |
307
+ | `setWorkspaceAttemptStatus` | Update a workspace attempt status by name |
308
+ | `updateTicketWhenAllAttemptsMatch` | Update a ticket when all attempts share a target attempt status |
309
+ | `removeAllWorktreesForTicket` | Remove every worktree currently attached to a ticket |
310
+ | `bootstrapWorktree` | Copy Prompt Studio and agent metadata into a worktree and optionally pull the ticket locally |
311
+ | `pullTickets` | Write ticket markdown and attachments into `.pstdio/tickets/...` |
312
+ | `runCommand` | Run a command array in a working directory and capture `stdout`, `stderr`, and `exitCode` |
313
+
314
+ These helpers accept action or hook context and resolve project-scoped ids for you where possible.
315
+
316
+ ## Hook Context Types
317
+
318
+ `@pstdio/sdk/hooks` exposes the shared context types used by hooks and hook runtimes:
319
+
320
+ `BaseHookContext`, `HookClient`, `HookPayload`, `SessionFollowupInput`, `AttemptStatusChangeContext`,
321
+ `SessionHookContext`, `TicketContext`, `TicketCreationContext`, `TicketStatusChangeContext`, `WorktreeContext`,
322
+ and `WorktreeCreateContext`.
323
+
324
+ Import from this entrypoint when you want to annotate hook code explicitly:
325
+
326
+ ```ts
327
+ import type {
328
+ SessionHookContext,
329
+ TicketStatusChangeContext,
330
+ } from "@pstdio/sdk/hooks";
331
+
332
+ const logStatusChange = (ctx: TicketStatusChangeContext) => {
333
+ console.log(ctx.shorthand, ctx.fromStatus, ctx.toStatus);
334
+ };
335
+
336
+ const onSessionStart = async (ctx: SessionHookContext) => {
337
+ console.log(ctx.sessionId, ctx.sessionStatus);
338
+ };
339
+ ```
340
+
341
+ ## Package Development
342
+
343
+ From the repo root:
344
+
345
+ ```bash
346
+ bun run --cwd packages/sdk build
347
+ bun run --cwd packages/sdk lint
348
+ bun run --cwd packages/sdk test
349
+ ```
350
+
351
+ From `packages/sdk`:
352
+
353
+ ```bash
354
+ bun run build
355
+ bun run lint
356
+ bun run test
357
+ ```
@@ -6,6 +6,7 @@ export type ExecuteActionInput = {
6
6
  export type ActionResult = {
7
7
  status: "success";
8
8
  session_id?: string;
9
+ message?: string;
9
10
  } | {
10
11
  status: "error";
11
12
  message: string;
@@ -24,6 +24,8 @@ var createProjectClient = (request) => ({
24
24
  get: (projectId) => request(`/v1/projects/${projectId}`),
25
25
  create: (input) => request("/v1/projects", { method: "POST", body: input }),
26
26
  delete: (projectId) => request(`/v1/projects/${projectId}`, { method: "DELETE" }),
27
+ listPlugins: (projectId) => request(`/v1/projects/${projectId}/plugins`),
28
+ registerPlugins: (projectId) => request(`/v1/projects/${projectId}/plugins/register`, { method: "POST" }),
27
29
  listRepos: (projectId) => request(`/v1/projects/${projectId}/repos`),
28
30
  registerRepo: (projectId, input) => request(`/v1/projects/${projectId}/repos`, { method: "POST", body: input }),
29
31
  removeRepo: (projectId, repoId) => request(`/v1/projects/${projectId}/repos/${repoId}`, { method: "DELETE" })
@@ -38,9 +40,29 @@ class PstdioApiError extends Error {
38
40
  this.status = status;
39
41
  }
40
42
  }
43
+ var formatZodIssues = (issues) => issues.map((issue) => {
44
+ const path = Array.isArray(issue.path) ? issue.path.filter((part) => part !== "").join(".") : "";
45
+ const message = typeof issue.message === "string" ? issue.message : JSON.stringify(issue);
46
+ return path ? `${path}: ${message}` : message;
47
+ }).join("; ");
48
+ var stringifyErrorField = (error) => {
49
+ if (typeof error === "string")
50
+ return error;
51
+ if (error && typeof error === "object") {
52
+ const issues = error.issues;
53
+ if (Array.isArray(issues))
54
+ return formatZodIssues(issues);
55
+ try {
56
+ return JSON.stringify(error);
57
+ } catch {
58
+ return String(error);
59
+ }
60
+ }
61
+ return String(error);
62
+ };
41
63
  var readErrorMessage = (errorBody, status) => {
42
64
  if (errorBody && typeof errorBody === "object" && errorBody !== null && "error" in errorBody) {
43
- const message = String(errorBody.error);
65
+ const message = stringifyErrorField(errorBody.error);
44
66
  const hookOutput = "hook_output" in errorBody && typeof errorBody.hook_output === "string" ? errorBody.hook_output.trim() : "";
45
67
  return hookOutput ? `${message}
46
68
  ${hookOutput}` : message;
@@ -1,13 +1,24 @@
1
1
  import type { CreateProjectInput, RegisterRepoInput, Repo } from "pstdio-api-contracts";
2
2
  import type { Project } from "../resources";
3
3
  import type { RequestFn } from "./request";
4
+ type RegisteredPlugin = {
5
+ identity: string;
6
+ filePath: string;
7
+ };
8
+ type RegisteredPluginsResponse = {
9
+ plugins: RegisteredPlugin[];
10
+ pluginsDir: string | null;
11
+ };
4
12
  export type ProjectClient = {
5
13
  list(): Promise<Project[]>;
6
14
  get(projectId: string): Promise<Project>;
7
15
  create(input: CreateProjectInput): Promise<Project>;
8
16
  delete(projectId: string): Promise<void>;
17
+ listPlugins(projectId: string): Promise<RegisteredPluginsResponse>;
18
+ registerPlugins(projectId: string): Promise<RegisteredPluginsResponse>;
9
19
  listRepos(projectId: string): Promise<Repo[]>;
10
20
  registerRepo(projectId: string, input: RegisterRepoInput): Promise<Repo>;
11
21
  removeRepo(projectId: string, repoId: string): Promise<void>;
12
22
  };
13
23
  export declare const createProjectClient: (request: RequestFn) => ProjectClient;
24
+ export {};
@@ -2,7 +2,7 @@ import type { BaseHookContext } from "./base";
2
2
  import type { HookTicket, HookWorkspace } from "./entities";
3
3
  export type SessionHookContext = BaseHookContext & {
4
4
  sessionId: string;
5
- sessionStatus: "in_progress" | "awaiting_input" | "completed" | "failed" | "cancelled";
5
+ sessionStatus: "in_progress" | "awaiting_input" | "completed" | "failed" | "cancelled" | "disconnected";
6
6
  originalSessionId?: string;
7
7
  workspace?: HookWorkspace;
8
8
  workspaceId?: string;
@@ -5,7 +5,7 @@ export declare const createSession: (ctx: PluginHelperContext, input: CreateSess
5
5
  id: string;
6
6
  project_id: string | null;
7
7
  title: string;
8
- status: "in_progress" | "awaiting_input" | "completed" | "failed" | "cancelled";
8
+ status: "in_progress" | "awaiting_input" | "completed" | "failed" | "cancelled" | "disconnected";
9
9
  archived: boolean;
10
10
  last_request_started: string | null;
11
11
  last_request_ended: string | null;
@@ -7,7 +7,7 @@ export declare const followupSession: (ctx: PluginHelperContext, input: Followup
7
7
  id: string;
8
8
  project_id: string | null;
9
9
  title: string;
10
- status: "in_progress" | "awaiting_input" | "completed" | "failed" | "cancelled";
10
+ status: "in_progress" | "awaiting_input" | "completed" | "failed" | "cancelled" | "disconnected";
11
11
  archived: boolean;
12
12
  last_request_started: string | null;
13
13
  last_request_ended: string | null;
@@ -1,4 +1,5 @@
1
1
  type CommandOutputOptions = {
2
+ env?: NodeJS.ProcessEnv;
2
3
  quiet?: boolean;
3
4
  };
4
5
  export declare const runCommand: (cwd: string, command: string[], options?: CommandOutputOptions) => Promise<{
@@ -2,4 +2,4 @@ export { renderPrompt } from "../prompts";
2
2
  export { definePlugin } from "./define-plugin";
3
3
  export { bootstrapWorktree, createAttempt, createSession, createWorkspace, findTicketByRef, findWorkspaceByRef, followupSession, getAttemptsForTicket, type PullTicketsInput, type PullTicketsResult, pullTickets, removeAllWorktreesForTicket, runCommand, setTicketStatus, setWorkspaceAttemptStatus, updateTicketWhenAllAttemptsMatch, workspacesForTicket, } from "./helpers";
4
4
  export type { HookResponse, PluginHooks, PostHookReturn, PostPluginHooks, PreHookReturn, PrePluginHooks, } from "./hooks";
5
- export type { ActionDefinition, ActionDescriptor, ActionInput, ActionParamDef, ActionParamValue, ActionPlacement, ActionTargetMap, ActionTriggerContext, AgentActionParam, AgentParamValue, LongTextActionParam, PluginDefinition, RepoActionParam, RepoParamValue, SelectActionParam, TargetType, TemplateSelectActionParam, TextActionParam, } from "./types";
5
+ export type { ActionDefinition, ActionDescriptor, ActionInput, ActionParamDef, ActionParamValue, ActionPlacement, ActionTargetMap, ActionTriggerContext, ActionTriggerResult, AgentActionParam, AgentParamValue, LongTextActionParam, PluginDefinition, RepoActionParam, RepoParamValue, SelectActionParam, TargetType, TemplateSelectActionParam, TextActionParam, } from "./types";
@@ -170,24 +170,29 @@ var removeAllWorktreesForTicket = async (ctx, input) => {
170
170
  return removed;
171
171
  };
172
172
  // src/plugins/helpers/run-command.ts
173
- import { spawn as nodeSpawn } from "node:child_process";
174
173
  var runCommand = async (cwd, command, options = {}) => {
175
174
  const [cmd, ...args] = command;
176
175
  const stdio = options.quiet ? "ignore" : "pipe";
177
- return new Promise((resolve) => {
178
- const proc = nodeSpawn(cmd, args, { cwd, stdio: ["ignore", stdio, stdio] });
179
- const stdout = [];
180
- const stderr = [];
181
- proc.stdout?.on("data", (chunk) => stdout.push(chunk.toString()));
182
- proc.stderr?.on("data", (chunk) => stderr.push(chunk.toString()));
183
- proc.on("close", (code) => {
184
- resolve({
185
- exitCode: code ?? 1,
186
- stdout: stdout.join("").trim(),
187
- stderr: stderr.join("").trim()
188
- });
176
+ let proc;
177
+ try {
178
+ proc = Bun.spawn([cmd, ...args], {
179
+ cwd,
180
+ env: options.env,
181
+ stdin: "ignore",
182
+ stdout: stdio,
183
+ stderr: stdio
189
184
  });
190
- });
185
+ } catch (error) {
186
+ return { exitCode: 1, stdout: "", stderr: error.message };
187
+ }
188
+ const readStream = (stream) => stream && typeof stream !== "number" ? new Response(stream).text() : Promise.resolve("");
189
+ const [stdout, stderr] = await Promise.all([readStream(proc.stdout), readStream(proc.stderr)]);
190
+ const exitCode = await proc.exited;
191
+ return {
192
+ exitCode,
193
+ stdout: stdout.trim(),
194
+ stderr: stderr.trim()
195
+ };
191
196
  };
192
197
  // src/plugins/helpers/set-ticket-status.ts
193
198
  var setTicketStatus = async (ctx, input) => {
@@ -61,6 +61,11 @@ export type ActionTriggerContext<TTargetType extends TargetType = TargetType> =
61
61
  targetId: string;
62
62
  target: ActionTargetMap[TTargetType];
63
63
  } : never);
64
+ export type ActionTriggerResult = {
65
+ session_id?: string;
66
+ message?: string;
67
+ };
68
+ type ActionTrigger<TTargetType extends TargetType = TargetType> = ((ctx: ActionTriggerContext<TTargetType>) => void) | ((ctx: ActionTriggerContext<TTargetType>) => ActionTriggerResult) | ((ctx: ActionTriggerContext<TTargetType>) => Promise<ActionTriggerResult | undefined>);
64
69
  export type ActionInput = {
65
70
  [K in TargetType]: {
66
71
  key: string;
@@ -68,7 +73,7 @@ export type ActionInput = {
68
73
  targetType: K;
69
74
  placement: ActionPlacement;
70
75
  params?: ActionParamDef[];
71
- trigger: (ctx: ActionTriggerContext<K>) => void | Promise<void>;
76
+ trigger: ActionTrigger<K>;
72
77
  };
73
78
  }[TargetType];
74
79
  export type ActionDescriptor = {
@@ -79,7 +84,7 @@ export type ActionDescriptor = {
79
84
  params?: ActionParamDef[];
80
85
  };
81
86
  export type ActionDefinition = ActionDescriptor & {
82
- trigger: (ctx: ActionTriggerContext) => void | Promise<void>;
87
+ trigger: ActionTrigger;
83
88
  };
84
89
  export type PluginDefinition = {
85
90
  key?: string;
@@ -3,7 +3,7 @@ export type { AgentAvailabilityType, AgentConfig, AgentInfo, AgentModel } from "
3
3
  export type { FileRecord } from "./file";
4
4
  export type { Project } from "./project";
5
5
  export type { Session, SessionStatus } from "./session";
6
- export type { Skill, SkillWithContent } from "./skill";
6
+ export type { Skill, SkillFile, SkillWithContent } from "./skill";
7
7
  export type { AttemptStatus, Status } from "./status";
8
8
  export type { Tag, TagOption } from "./tag";
9
9
  export type { Template, TemplateType, TemplateWithContent } from "./template";
@@ -1 +1 @@
1
- export type { Skill, SkillWithContent } from "pstdio-api-contracts";
1
+ export type { Skill, SkillFile, SkillWithContent } from "pstdio-api-contracts";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pstdio/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/pufflyai/prompt-studio"
@@ -56,6 +56,6 @@
56
56
  "@types/bun": "latest",
57
57
  "@types/mustache": "^4.2.6",
58
58
  "pstdio-api-contracts": "workspace:*",
59
- "typescript": "^5.9.3"
59
+ "typescript": "6.0.2"
60
60
  }
61
61
  }