@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.
- package/README.md +22 -192
- package/dist/api/index.js +932 -483
- package/dist/api.d.ts +3767 -0
- package/dist/client/index.js +21 -14
- package/dist/client.d.ts +1714 -0
- package/dist/extensions/index.js +262 -140
- package/dist/extensions/react/index.js +2 -1
- package/dist/{extensions/react/index.d.ts → extensions-react.d.ts} +23 -16
- package/dist/extensions.d.ts +3826 -0
- package/dist/hooks.d.ts +1775 -0
- package/dist/{prompts/render-prompt.d.ts → prompts.d.ts} +3 -1
- package/dist/resources/index.js +932 -483
- package/dist/resources.d.ts +422 -0
- package/package.json +12 -31
- package/dist/api/extensions.d.ts +0 -1
- package/dist/api/index.d.ts +0 -10
- package/dist/api/projects.d.ts +0 -1
- package/dist/api/sessions.d.ts +0 -2
- package/dist/api/settings.d.ts +0 -1
- package/dist/api/skills.d.ts +0 -1
- package/dist/api/templates.d.ts +0 -1
- package/dist/api/terminal.d.ts +0 -49
- package/dist/api/workspaces.d.ts +0 -12
- package/dist/client/agents.d.ts +0 -10
- package/dist/client/client.d.ts +0 -26
- package/dist/client/extensions.d.ts +0 -12
- package/dist/client/index.d.ts +0 -14
- package/dist/client/notifications.d.ts +0 -23
- package/dist/client/projects.d.ts +0 -14
- package/dist/client/request.d.ts +0 -25
- package/dist/client/runtime.d.ts +0 -5
- package/dist/client/sessions.d.ts +0 -45
- package/dist/client/settings.d.ts +0 -7
- package/dist/client/skills.d.ts +0 -9
- package/dist/client/sse.d.ts +0 -15
- package/dist/client/sync.d.ts +0 -35
- package/dist/client/templates.d.ts +0 -11
- package/dist/client/workspaces.d.ts +0 -20
- package/dist/extensions/command-outcome.d.ts +0 -5
- package/dist/extensions/define-command.d.ts +0 -26
- package/dist/extensions/define-extension-view.d.ts +0 -58
- package/dist/extensions/define-extension.d.ts +0 -54
- package/dist/extensions/index.d.ts +0 -13
- package/dist/extensions/params.d.ts +0 -36
- package/dist/extensions/refs.d.ts +0 -8
- package/dist/extensions/terminal-session-bridge.d.ts +0 -32
- package/dist/extensions/webview-client.d.ts +0 -41
- package/dist/extensions/when.d.ts +0 -9
- package/dist/hooks/base.d.ts +0 -17
- package/dist/hooks/entities.d.ts +0 -8
- package/dist/hooks/index.d.ts +0 -3
- package/dist/hooks/session.d.ts +0 -12
- package/dist/hooks/worktree.d.ts +0 -53
- package/dist/prompts/index.d.ts +0 -1
- package/dist/resources/agent.d.ts +0 -2
- package/dist/resources/file.d.ts +0 -1
- package/dist/resources/index.d.ts +0 -10
- package/dist/resources/project.d.ts +0 -1
- package/dist/resources/session.d.ts +0 -1
- package/dist/resources/settings.d.ts +0 -1
- package/dist/resources/skill.d.ts +0 -1
- package/dist/resources/template.d.ts +0 -1
- package/dist/resources/workspace.d.ts +0 -3
package/README.md
CHANGED
|
@@ -1,209 +1,39 @@
|
|
|
1
1
|
# @pstdio/sdk
|
|
2
2
|
|
|
3
|
-
TypeScript SDK for Prompt Studio.
|
|
3
|
+
The public TypeScript SDK for Prompt Studio. It provides extension contracts, the HTTP client, and prompt helpers. The package is ESM-only; import a declared subpath.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- calling the Prompt Studio HTTP API
|
|
8
|
-
- importing shared request and resource types
|
|
9
|
-
- rendering prompt templates
|
|
10
|
-
- authoring Prompt Studio extensions
|
|
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
|
|
5
|
+
```sh
|
|
17
6
|
bun add @pstdio/sdk
|
|
18
7
|
```
|
|
19
8
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
| `@pstdio/sdk/client`
|
|
25
|
-
| `@pstdio/sdk/api`
|
|
26
|
-
| `@pstdio/sdk/resources`
|
|
27
|
-
| `@pstdio/sdk/prompts`
|
|
28
|
-
| `@pstdio/sdk/
|
|
29
|
-
| `@pstdio/sdk/hooks` | Hook context and 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 { renderPrompt } from "@pstdio/sdk/prompts";
|
|
38
|
-
import type { ExtensionDefinition } from "@pstdio/sdk/extensions";
|
|
39
|
-
import type { WorktreeCreateContext } 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 projects = await client.projects.list();
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### Client options
|
|
58
|
-
|
|
59
|
-
- `baseUrl`: API base URL. Defaults to `process.env.PSTDIO_API_URL ?? "http://localhost:19840"`.
|
|
60
|
-
- `token`: Optional bearer token. Sent as `Authorization: Bearer <token>`.
|
|
61
|
-
- `fetch`: Optional `fetch` implementation override for tests or custom runtimes.
|
|
62
|
-
|
|
63
|
-
The client expects a runtime with `fetch` available, or an explicit `fetch` passed in through options.
|
|
64
|
-
|
|
65
|
-
### Error handling
|
|
66
|
-
|
|
67
|
-
The request layer throws `PstdioApiError` for non-2xx responses.
|
|
68
|
-
|
|
69
|
-
- `error.message`: API error message
|
|
70
|
-
- `error.status`: HTTP status code
|
|
71
|
-
|
|
72
|
-
```ts
|
|
73
|
-
import { PstdioApiError, createClient } from "@pstdio/sdk/client";
|
|
74
|
-
|
|
75
|
-
const client = createClient();
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
await client.workspaces.updateAttemptStatus("ws_123", {
|
|
79
|
-
status: "review-ready",
|
|
80
|
-
});
|
|
81
|
-
} catch (error) {
|
|
82
|
-
if (error instanceof PstdioApiError) {
|
|
83
|
-
console.error(error.status, error.message);
|
|
84
|
-
}
|
|
85
|
-
throw error;
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Client groups
|
|
9
|
+
| Entry point | Purpose |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `@pstdio/sdk/extensions` | Contributions, typed refs, commands, storage contracts, and webview clients |
|
|
12
|
+
| `@pstdio/sdk/extensions/react` | React query and mutation hooks for webviews |
|
|
13
|
+
| `@pstdio/sdk/client` | HTTP client |
|
|
14
|
+
| `@pstdio/sdk/api` | API request and response types |
|
|
15
|
+
| `@pstdio/sdk/resources` | Product resource types |
|
|
16
|
+
| `@pstdio/sdk/prompts` | Prompt rendering |
|
|
17
|
+
| `@pstdio/sdk/hooks` | Hook API contracts |
|
|
90
18
|
|
|
91
|
-
|
|
19
|
+
Native extension entries work without React. The React entry requires its declared React and TanStack Query peers. Public declarations include their private contract dependencies and support `skipLibCheck: false` outside the repository.
|
|
92
20
|
|
|
93
|
-
|
|
94
|
-
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
95
|
-
| `projects` | `list`, `get`, `create`, `delete`, `listRepos`, `registerRepo`, `removeRepo` |
|
|
96
|
-
| `tickets` | `list`, `get`, `create`, `update`, `delete`, `createAttempt`, `updateWhenAttemptStatus`, `listFiles`, `getFileContent`, `uploadFile`, `deleteFile` |
|
|
97
|
-
| `workspaces` | `list`, `getByShorthand`, `create`, `updateAttemptStatus`, `removeWorktree`, `delete` |
|
|
98
|
-
| `sessions` | `list`, `get`, `create`, `archive`, `followUp`, `approve`, `getConversation`, `resolveSessionId`, `updateStatus`, `uploadAttachment`, `deleteAttachment` |
|
|
99
|
-
| `statuses` | `list`, `create`, `update`, `setDefault`, `delete`, `listAttemptStatuses`, `createAttemptStatus`, `updateAttemptStatus`, `deleteAttemptStatus` |
|
|
100
|
-
| `tags` | `list`, `create`, `update`, `delete`, `createOption`, `updateOption`, `deleteOption` |
|
|
101
|
-
| `templates` | `list`, `get`, `create`, `update`, `delete` |
|
|
102
|
-
| `skills` | `list`, `get`, `update` |
|
|
103
|
-
| `agents` | `list`, `info`, `models`, `setup`, `setupAvailable`, `update`, `delete` |
|
|
21
|
+
## Build an extension
|
|
104
22
|
|
|
105
|
-
|
|
23
|
+
Start with the [workbench cookbook](https://github.com/pufflyai/prompt-studio/blob/main/.pstdio/docs/extensions/cookbook.md) and [Extension Lab](https://github.com/pufflyai/prompt-studio/blob/main/extensions/extension-lab/README.md). Existing examples cover saved edits, inspectors, shared panels, custom modes, provider refs, and webview cleanup.
|
|
106
24
|
|
|
107
|
-
|
|
108
|
-
- `tickets.getFileContent(ticketId, fileId)` returns `Uint8Array`, not JSON.
|
|
109
|
-
- `createRequest()` is also exported if you want the lower-level request function without the grouped client.
|
|
25
|
+
Keep package identity in `package.json`. Export `defineExtension(...)` from the manifest's `main`. Install through `pst extensions dev <path>` from a linked project. The same workflow watches native TypeScript, contribution declarations, and webview assets.
|
|
110
26
|
|
|
111
|
-
|
|
27
|
+
A view supplies content. A page owns its route, routed resource, and page panels. A mode supplies shared panels and chrome. Use `ResourceRef` with `type`, `id`, and optional `label` across these contracts. Main, Side, and Secondary are the panel regions.
|
|
112
28
|
|
|
113
|
-
|
|
29
|
+
A page declares `resource: { kinds }` separately from `main`. Main can show a view or a collection of peer panels with an empty view. Additional slots expose generated refs such as `page.panels.inspector`. Slots and mode placements share the same static-view or resource-binding item union.
|
|
114
30
|
|
|
115
|
-
|
|
116
|
-
import type {
|
|
117
|
-
CreateSessionInput,
|
|
118
|
-
SessionAttachment,
|
|
119
|
-
SessionAttachmentRef,
|
|
120
|
-
CreateTicketInput,
|
|
121
|
-
UpdateTicketInput,
|
|
122
|
-
} from "@pstdio/sdk/api";
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Most of these types come from `pstdio-api-contracts`. Use `import type` for this entrypoint. It does not expose runtime helpers.
|
|
126
|
-
|
|
127
|
-
## Resource Types
|
|
128
|
-
|
|
129
|
-
`@pstdio/sdk/resources` re-exports the shared Prompt Studio entities used across the API and extension system.
|
|
130
|
-
|
|
131
|
-
Common exports include `Project`, `Repo`, `Ticket`, `TicketDetail`, `TicketListItem`, `TicketFile`, `Workspace`,
|
|
132
|
-
`WorkspaceListItem`, `Session`, `SessionStatus`, `Status`, `AttemptStatus`, `Tag`, `TagOption`, `Template`,
|
|
133
|
-
`TemplateWithContent`, `TemplateType`, `Skill`, `SkillWithContent`, `AgentConfig`, `AgentInfo`, `AgentModel`,
|
|
134
|
-
`AgentAvailabilityType`, and `FileRecord`.
|
|
135
|
-
|
|
136
|
-
```ts
|
|
137
|
-
import type {
|
|
138
|
-
Session,
|
|
139
|
-
TicketDetail,
|
|
140
|
-
WorkspaceListItem,
|
|
141
|
-
} from "@pstdio/sdk/resources";
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## Prompt Rendering
|
|
145
|
-
|
|
146
|
-
`@pstdio/sdk/prompts` exposes `renderPrompt(template, data)`, a small wrapper around Mustache.
|
|
147
|
-
|
|
148
|
-
```ts
|
|
149
|
-
import { renderPrompt } from "@pstdio/sdk/prompts";
|
|
150
|
-
|
|
151
|
-
const prompt = renderPrompt("Implement ticket {{ticket}}", {
|
|
152
|
-
ticket: "PS-42",
|
|
153
|
-
});
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
## Extensions
|
|
31
|
+
Page targets change location. Panel targets preserve it. Compound targets contain only page and panel steps, prepared before one commit. Commands and external links remain standalone actions. Omitted mode chrome retains host navigation for custom modes too.
|
|
157
32
|
|
|
158
|
-
|
|
33
|
+
Use `qualifyRef(owner, ref)` in provider contract modules. Keep definitions local and pass qualified refs between extensions. For webviews, declare capabilities and call the typed `GuestHost`; `placement.close` closes the calling placement through the normal tab controller.
|
|
159
34
|
|
|
160
|
-
|
|
161
|
-
import type { ExtensionDefinition } from "@pstdio/sdk/extensions";
|
|
35
|
+
## Package delivery
|
|
162
36
|
|
|
163
|
-
|
|
164
|
-
manifest: {
|
|
165
|
-
id: "example-extension",
|
|
166
|
-
name: "Example extension",
|
|
167
|
-
version: "0.0.0",
|
|
168
|
-
},
|
|
169
|
-
activate(ctx) {
|
|
170
|
-
ctx.commands.register({
|
|
171
|
-
id: "example-extension.say-hello",
|
|
172
|
-
title: "Say hello",
|
|
173
|
-
handler: () => ({ ok: true }),
|
|
174
|
-
});
|
|
175
|
-
},
|
|
176
|
-
};
|
|
37
|
+
Development and installed consumers both load built SDK entries. Repository development builds this package before starting the source CLI. Builds stage release files under `.publish` through the shared release script. Package verification installs those same staged artifacts into a temporary directory outside the monorepo and checks every entry point.
|
|
177
38
|
|
|
178
|
-
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## Hook Types
|
|
182
|
-
|
|
183
|
-
`@pstdio/sdk/hooks` exposes the shared context types used by hook runtimes and hook handlers.
|
|
184
|
-
|
|
185
|
-
```ts
|
|
186
|
-
import type {
|
|
187
|
-
CommitContext,
|
|
188
|
-
RebaseContext,
|
|
189
|
-
WorktreeRemoveContext,
|
|
190
|
-
} from "@pstdio/sdk/hooks";
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## Package Development
|
|
194
|
-
|
|
195
|
-
From the repo root:
|
|
196
|
-
|
|
197
|
-
```bash
|
|
198
|
-
bun run --cwd packages/sdk build
|
|
199
|
-
bun run --cwd packages/sdk lint
|
|
200
|
-
bun run --cwd packages/sdk test
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
From `packages/sdk`:
|
|
204
|
-
|
|
205
|
-
```bash
|
|
206
|
-
bun run build
|
|
207
|
-
bun run lint
|
|
208
|
-
bun run test
|
|
209
|
-
```
|
|
39
|
+
Host authors should use the [workbench guide](https://github.com/pufflyai/prompt-studio/blob/main/packages/pstdio-workbench/README.md). Extension authors should use this SDK and public UI packages.
|