@pstdio/sdk 0.10.0 → 0.12.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 +1 -4
- package/dist/api/extensions.d.ts +1 -1
- package/dist/api/index.d.ts +2 -6
- package/dist/api/workspaces.d.ts +2 -6
- package/dist/client/agents.d.ts +2 -7
- package/dist/client/client.d.ts +0 -9
- package/dist/client/index.d.ts +0 -3
- package/dist/client/index.js +17 -116
- package/dist/client/projects.d.ts +2 -2
- package/dist/client/workspaces.d.ts +2 -4
- package/dist/extensions/command-outcome.d.ts +5 -0
- package/dist/extensions/define-command.d.ts +1 -3
- package/dist/extensions/define-extension-view.d.ts +25 -0
- package/dist/extensions/define-extension.d.ts +1 -4
- package/dist/extensions/index.d.ts +6 -8
- package/dist/extensions/index.js +145 -89
- package/dist/extensions/params.d.ts +2 -1
- package/dist/extensions/refs.d.ts +2 -14
- package/dist/extensions/when.d.ts +9 -0
- package/dist/hooks/entities.d.ts +7 -9
- package/dist/hooks/index.d.ts +0 -2
- package/dist/hooks/session.d.ts +2 -3
- package/dist/hooks/worktree.d.ts +4 -3
- package/dist/resources/agent.d.ts +1 -1
- package/dist/resources/index.d.ts +2 -5
- package/dist/resources/index.js +3 -1
- package/dist/resources/known-agents.d.ts +2 -0
- package/dist/resources/workspace.d.ts +0 -1
- package/package.json +2 -2
- package/dist/api/agents.d.ts +0 -1
- package/dist/api/statuses.d.ts +0 -2
- package/dist/api/tags.d.ts +0 -2
- package/dist/api/tickets.d.ts +0 -26
- package/dist/client/statuses.d.ts +0 -24
- package/dist/client/tags.d.ts +0 -15
- package/dist/client/tickets.d.ts +0 -24
- package/dist/extensions/kernel-slots.d.ts +0 -168
- package/dist/extensions/package-asset.d.ts +0 -10
- package/dist/extensions/slots.d.ts +0 -6
- package/dist/extensions/types/commands.d.ts +0 -125
- package/dist/extensions/types/context.d.ts +0 -396
- package/dist/extensions/types/contributions.d.ts +0 -275
- package/dist/extensions/types/events.d.ts +0 -10
- package/dist/extensions/types/extension.d.ts +0 -174
- package/dist/extensions/types/index.d.ts +0 -10
- package/dist/extensions/types/json.d.ts +0 -7
- package/dist/extensions/types/params.d.ts +0 -80
- package/dist/extensions/types/resources.d.ts +0 -25
- package/dist/extensions/types/slots.d.ts +0 -22
- package/dist/extensions/types/webview-capabilities.d.ts +0 -65
- package/dist/extensions/workbench-targets.d.ts +0 -134
- package/dist/hooks/attempt.d.ts +0 -16
- package/dist/hooks/ticket.d.ts +0 -26
- package/dist/resources/status.d.ts +0 -2
- package/dist/resources/tag.d.ts +0 -2
- package/dist/resources/ticket.d.ts +0 -2
package/dist/extensions/index.js
CHANGED
|
@@ -1,32 +1,8 @@
|
|
|
1
|
-
// src/
|
|
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/define-extension-view.ts
|
|
8
|
-
var defineExtensionView = (definition) => ({
|
|
9
|
-
mount: async (mount, host, propsStore) => {
|
|
10
|
-
const cleanup = await definition.render({ mount, host, propsStore });
|
|
11
|
-
return typeof cleanup === "function" ? cleanup : () => {};
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
// src/extensions/refs.ts
|
|
1
|
+
// ../pstdio-api-contracts/src/extension-kernel/refs.ts
|
|
15
2
|
var commandRef = (id) => ({ id });
|
|
16
3
|
var eventRef = (id) => ({ id });
|
|
17
|
-
var commandEvent = (command, phase) => ({
|
|
18
|
-
id: `command.${phase}:${command.id}`
|
|
19
|
-
});
|
|
20
|
-
var commandsOf = (packageName, extension) => {
|
|
21
|
-
const refs = {};
|
|
22
|
-
const commands = extension.commands ?? {};
|
|
23
|
-
for (const key of Object.keys(commands)) {
|
|
24
|
-
refs[key] = { id: `${packageName}.${key}` };
|
|
25
|
-
}
|
|
26
|
-
return refs;
|
|
27
|
-
};
|
|
28
4
|
|
|
29
|
-
// src/
|
|
5
|
+
// ../pstdio-api-contracts/src/extension-kernel/slots.ts
|
|
30
6
|
var defineSlot = (id, options) => ({
|
|
31
7
|
id,
|
|
32
8
|
kind: options.kind,
|
|
@@ -35,12 +11,11 @@ var defineSlot = (id, options) => ({
|
|
|
35
11
|
metadata: options.metadata
|
|
36
12
|
});
|
|
37
13
|
|
|
38
|
-
// src/
|
|
14
|
+
// ../pstdio-api-contracts/src/extension-kernel/kernel-slots.ts
|
|
39
15
|
var projectSlots = {
|
|
40
16
|
sidebar: defineSlot("project.sidebar", { kind: "view" }),
|
|
41
17
|
headerPrimary: defineSlot("project.headerPrimary", { kind: "menu" }),
|
|
42
18
|
headerOverflow: defineSlot("project.headerOverflow", { kind: "menu" }),
|
|
43
|
-
commandPanel: defineSlot("project.commandPanel", { kind: "menu" }),
|
|
44
19
|
settingsPanels: defineSlot("project.settingsPanels", { kind: "settings" })
|
|
45
20
|
};
|
|
46
21
|
var sessionSlots = {
|
|
@@ -48,10 +23,6 @@ var sessionSlots = {
|
|
|
48
23
|
headerOverflow: defineSlot("session.headerOverflow", { kind: "menu" }),
|
|
49
24
|
transcriptActions: defineSlot("session.transcriptActions", { kind: "menu" })
|
|
50
25
|
};
|
|
51
|
-
var ticketSlots = {
|
|
52
|
-
headerPrimary: defineSlot("ticket.headerPrimary", { kind: "menu" }),
|
|
53
|
-
headerOverflow: defineSlot("ticket.headerOverflow", { kind: "menu" })
|
|
54
|
-
};
|
|
55
26
|
var workspaceSlots = {
|
|
56
27
|
headerPrimary: defineSlot("workspace.headerPrimary", { kind: "menu" }),
|
|
57
28
|
headerOverflow: defineSlot("workspace.headerOverflow", { kind: "menu" }),
|
|
@@ -68,12 +39,6 @@ var sessionEvents = {
|
|
|
68
39
|
failed: eventRef("session.failed"),
|
|
69
40
|
completed: eventRef("session.completed")
|
|
70
41
|
};
|
|
71
|
-
var ticketEvents = {
|
|
72
|
-
created: eventRef("ticket.created"),
|
|
73
|
-
statusChanged: eventRef("ticket.statusChanged"),
|
|
74
|
-
archived: eventRef("ticket.archived"),
|
|
75
|
-
deleted: eventRef("ticket.deleted")
|
|
76
|
-
};
|
|
77
42
|
var workspaceEvents = {
|
|
78
43
|
created: eventRef("workspace.created"),
|
|
79
44
|
archived: eventRef("workspace.archived"),
|
|
@@ -89,46 +54,21 @@ var gitEvents = {
|
|
|
89
54
|
merged: eventRef("git.merged"),
|
|
90
55
|
conflicted: eventRef("git.conflicted")
|
|
91
56
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// src/
|
|
57
|
+
// ../pstdio-api-contracts/src/extension-kernel/l10n.ts
|
|
58
|
+
var l10n = (key, defaultValue) => ({
|
|
59
|
+
$l10n: key,
|
|
60
|
+
...defaultValue === undefined ? {} : { default: defaultValue }
|
|
61
|
+
});
|
|
62
|
+
var isLocalizedString = (value) => typeof value === "object" && value !== null && ("$l10n" in value) && typeof value.$l10n === "string";
|
|
63
|
+
// ../pstdio-api-contracts/src/extension-kernel/package-asset.ts
|
|
99
64
|
var packageAsset = (path, baseUrl) => ({
|
|
100
65
|
kind: "package-asset",
|
|
101
66
|
path,
|
|
102
67
|
baseUrl
|
|
103
68
|
});
|
|
104
|
-
// src/
|
|
105
|
-
var params = {
|
|
106
|
-
text: (options) => ({ type: "text", ...options }),
|
|
107
|
-
longText: (options) => ({ type: "longtext", ...options }),
|
|
108
|
-
number: (options) => ({ type: "number", ...options }),
|
|
109
|
-
boolean: (options) => ({ type: "boolean", ...options }),
|
|
110
|
-
select: (options) => ({ type: "select", ...options }),
|
|
111
|
-
multiSelect: (options) => ({
|
|
112
|
-
type: "multi-select",
|
|
113
|
-
...options
|
|
114
|
-
}),
|
|
115
|
-
repo: (options) => ({ type: "repo", ...options }),
|
|
116
|
-
harness: (options) => ({ type: "harness", ...options }),
|
|
117
|
-
template: (options) => ({
|
|
118
|
-
label: options.label,
|
|
119
|
-
description: options.description,
|
|
120
|
-
required: options.required,
|
|
121
|
-
defaultValue: options.defaultValue,
|
|
122
|
-
metadata: options.metadata,
|
|
123
|
-
type: "template",
|
|
124
|
-
templateType: options.type
|
|
125
|
-
}),
|
|
126
|
-
resource: (options) => ({ type: "resource", ...options }),
|
|
127
|
-
json: (options) => ({ type: "json", ...options })
|
|
128
|
-
};
|
|
129
|
-
// src/extensions/types/extension.ts
|
|
69
|
+
// ../pstdio-api-contracts/src/extension-kernel/types/extension.ts
|
|
130
70
|
var EXTENSION_API_VERSION = "1.0.0";
|
|
131
|
-
// src/
|
|
71
|
+
// ../pstdio-api-contracts/src/extension-kernel/types/webview-capabilities.ts
|
|
132
72
|
var WEBVIEW_HOST_CAPABILITY_VERSION = 1;
|
|
133
73
|
var WEBVIEW_DECLARABLE_CAPABILITIES = [
|
|
134
74
|
"commands.execute",
|
|
@@ -139,19 +79,18 @@ var WEBVIEW_DECLARABLE_CAPABILITIES = [
|
|
|
139
79
|
"extension.settings.all",
|
|
140
80
|
"extension.settings.get",
|
|
141
81
|
"extension.settings.set",
|
|
142
|
-
"extension.settings.delete"
|
|
82
|
+
"extension.settings.delete",
|
|
83
|
+
"files.upload",
|
|
84
|
+
"files.list",
|
|
85
|
+
"files.delete"
|
|
143
86
|
];
|
|
144
87
|
var ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES = ["host.dispatchKeyboardEvent"];
|
|
145
88
|
var WEBVIEW_HOST_CAPABILITIES = [
|
|
146
89
|
...WEBVIEW_DECLARABLE_CAPABILITIES,
|
|
147
90
|
...ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES
|
|
148
91
|
];
|
|
149
|
-
// src/
|
|
150
|
-
var workbenchMenuTargets = [
|
|
151
|
-
"workbench.nav.actions",
|
|
152
|
-
"workbench.nav.overflow",
|
|
153
|
-
"workbench.commandPalette"
|
|
154
|
-
];
|
|
92
|
+
// ../pstdio-api-contracts/src/extension-kernel/workbench-targets.ts
|
|
93
|
+
var workbenchMenuTargets = ["workbench.nav.actions", "workbench.nav.overflow"];
|
|
155
94
|
var workbenchTreeTargets = [
|
|
156
95
|
"workbench.left.tree",
|
|
157
96
|
"workbench.main.left.tree",
|
|
@@ -185,12 +124,6 @@ var workbenchTargets = [
|
|
|
185
124
|
granularity: "surface",
|
|
186
125
|
rationale: "Secondary command surface in the host-owned nav (top) workbench chrome."
|
|
187
126
|
},
|
|
188
|
-
{
|
|
189
|
-
id: "workbench.commandPalette",
|
|
190
|
-
allowedKinds: ["menu"],
|
|
191
|
-
granularity: "surface",
|
|
192
|
-
rationale: "Global command discovery surface owned by the workbench."
|
|
193
|
-
},
|
|
194
127
|
{
|
|
195
128
|
id: "workbench.left.tree",
|
|
196
129
|
allowedKinds: ["treeItem"],
|
|
@@ -241,11 +174,133 @@ var workbenchTargets = [
|
|
|
241
174
|
}
|
|
242
175
|
];
|
|
243
176
|
var getWorkbenchTargetDefinition = (id) => workbenchTargets.find((target) => target.id === id);
|
|
177
|
+
// src/extensions/command-outcome.ts
|
|
178
|
+
var unwrapCommandOutcome = (response, fallbackReason = "Command failed.") => {
|
|
179
|
+
const { outcome } = response;
|
|
180
|
+
if (outcome.status !== "success") {
|
|
181
|
+
throw new Error(outcome.reason || fallbackReason);
|
|
182
|
+
}
|
|
183
|
+
return outcome.value;
|
|
184
|
+
};
|
|
185
|
+
// src/extensions/define-command.ts
|
|
186
|
+
var defineCommand = (definition) => definition;
|
|
187
|
+
var defineMiddleware = (definition) => definition;
|
|
188
|
+
var defineHook = (definition) => definition;
|
|
189
|
+
// src/extensions/define-extension.ts
|
|
190
|
+
var defineExtension = (extension) => extension;
|
|
191
|
+
// src/extensions/define-extension-view.ts
|
|
192
|
+
var pickFiles = (opts = {}) => new Promise((resolve, reject) => {
|
|
193
|
+
const input = document.createElement("input");
|
|
194
|
+
input.type = "file";
|
|
195
|
+
input.accept = opts.accept ?? "";
|
|
196
|
+
input.multiple = opts.multiple ?? false;
|
|
197
|
+
input.style.display = "none";
|
|
198
|
+
input.addEventListener("change", () => {
|
|
199
|
+
const files = input.files ? Array.from(input.files) : [];
|
|
200
|
+
input.remove();
|
|
201
|
+
resolve(files);
|
|
202
|
+
});
|
|
203
|
+
input.addEventListener("cancel", () => {
|
|
204
|
+
input.remove();
|
|
205
|
+
resolve([]);
|
|
206
|
+
});
|
|
207
|
+
input.addEventListener("error", () => {
|
|
208
|
+
input.remove();
|
|
209
|
+
reject(new Error("Could not pick files."));
|
|
210
|
+
});
|
|
211
|
+
document.body.appendChild(input);
|
|
212
|
+
input.click();
|
|
213
|
+
});
|
|
214
|
+
var createFilesClient = (host) => ({
|
|
215
|
+
pick: pickFiles,
|
|
216
|
+
upload: (input) => host.call("files.upload", input),
|
|
217
|
+
list: async (input) => {
|
|
218
|
+
const response = await host.call("files.list", input ?? {});
|
|
219
|
+
return response.files ?? [];
|
|
220
|
+
},
|
|
221
|
+
delete: (id) => host.call("files.delete", { id })
|
|
222
|
+
});
|
|
223
|
+
var readTranslationProps = (props) => {
|
|
224
|
+
const translations = typeof props === "object" && props !== null && "translations" in props ? props.translations : undefined;
|
|
225
|
+
if (typeof translations !== "object" || translations === null)
|
|
226
|
+
return null;
|
|
227
|
+
return translations;
|
|
228
|
+
};
|
|
229
|
+
var interpolate = (value, args) => Object.entries(args ?? {}).reduce((next, [key, replacement]) => next.replaceAll(`{{${key}}}`, String(replacement)), value);
|
|
230
|
+
var createTranslationApi = (propsStore) => {
|
|
231
|
+
const locale = () => readTranslationProps(propsStore.get())?.locale ?? "en";
|
|
232
|
+
const t = (key, defaultValue, args) => {
|
|
233
|
+
const translations = readTranslationProps(propsStore.get());
|
|
234
|
+
const value = translations?.bundle?.[key] ?? translations?.defaultBundle?.[key] ?? defaultValue ?? key;
|
|
235
|
+
return interpolate(value, args);
|
|
236
|
+
};
|
|
237
|
+
return { locale, t };
|
|
238
|
+
};
|
|
239
|
+
var defineExtensionView = (definition) => ({
|
|
240
|
+
mount: async (mount, host, propsStore) => {
|
|
241
|
+
const translations = createTranslationApi(propsStore);
|
|
242
|
+
const cleanup = await definition.render({
|
|
243
|
+
mount,
|
|
244
|
+
host,
|
|
245
|
+
files: createFilesClient(host),
|
|
246
|
+
propsStore,
|
|
247
|
+
get locale() {
|
|
248
|
+
return translations.locale();
|
|
249
|
+
},
|
|
250
|
+
t: translations.t
|
|
251
|
+
});
|
|
252
|
+
return typeof cleanup === "function" ? cleanup : () => {};
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
// src/extensions/params.ts
|
|
256
|
+
var params = {
|
|
257
|
+
text: (options) => ({ type: "text", ...options }),
|
|
258
|
+
longText: (options) => ({ type: "longtext", ...options }),
|
|
259
|
+
number: (options) => ({ type: "number", ...options }),
|
|
260
|
+
boolean: (options) => ({ type: "boolean", ...options }),
|
|
261
|
+
select: (options) => ({ type: "select", ...options }),
|
|
262
|
+
multiSelect: (options) => ({
|
|
263
|
+
type: "multi-select",
|
|
264
|
+
...options
|
|
265
|
+
}),
|
|
266
|
+
repo: (options) => ({ type: "repo", ...options }),
|
|
267
|
+
harness: (options) => ({ type: "harness", ...options }),
|
|
268
|
+
template: (options) => ({
|
|
269
|
+
label: options.label,
|
|
270
|
+
description: options.description,
|
|
271
|
+
required: options.required,
|
|
272
|
+
defaultValue: options.defaultValue,
|
|
273
|
+
metadata: options.metadata,
|
|
274
|
+
type: "template",
|
|
275
|
+
templateType: options.type
|
|
276
|
+
}),
|
|
277
|
+
resource: (options) => ({ type: "resource", ...options }),
|
|
278
|
+
json: (options) => ({ type: "json", ...options }),
|
|
279
|
+
list: (options) => ({ type: "list", ...options })
|
|
280
|
+
};
|
|
281
|
+
// src/extensions/refs.ts
|
|
282
|
+
var commandEvent = (command, phase) => ({
|
|
283
|
+
id: `command.${phase}:${command.id}`
|
|
284
|
+
});
|
|
285
|
+
var commandsOf = (packageName, extension) => {
|
|
286
|
+
const refs = {};
|
|
287
|
+
const commands = extension.commands ?? {};
|
|
288
|
+
for (const key of Object.keys(commands)) {
|
|
289
|
+
refs[key] = { id: `${packageName}.${key}` };
|
|
290
|
+
}
|
|
291
|
+
return refs;
|
|
292
|
+
};
|
|
293
|
+
// src/extensions/when.ts
|
|
294
|
+
var matchesResourceWhen = (when, resourceType) => {
|
|
295
|
+
const resourceTypes = when?.resourceType;
|
|
296
|
+
if (!resourceTypes?.length)
|
|
297
|
+
return true;
|
|
298
|
+
return resourceType ? resourceTypes.includes(resourceType) : false;
|
|
299
|
+
};
|
|
244
300
|
export {
|
|
245
301
|
worktreeEvents,
|
|
246
302
|
workspaceSlots,
|
|
247
303
|
workspaceEvents,
|
|
248
|
-
workspaceCommands,
|
|
249
304
|
workbenchViewTargets,
|
|
250
305
|
workbenchTreeTargets,
|
|
251
306
|
workbenchTargets,
|
|
@@ -253,14 +308,16 @@ export {
|
|
|
253
308
|
workbenchSettingsScopes,
|
|
254
309
|
workbenchModeLayoutTargets,
|
|
255
310
|
workbenchMenuTargets,
|
|
256
|
-
|
|
257
|
-
ticketEvents,
|
|
311
|
+
unwrapCommandOutcome,
|
|
258
312
|
sessionSlots,
|
|
259
313
|
sessionEvents,
|
|
260
314
|
projectSlots,
|
|
261
315
|
projectEvents,
|
|
262
316
|
params,
|
|
263
317
|
packageAsset,
|
|
318
|
+
matchesResourceWhen,
|
|
319
|
+
l10n,
|
|
320
|
+
isLocalizedString,
|
|
264
321
|
gitEvents,
|
|
265
322
|
getWorkbenchTargetDefinition,
|
|
266
323
|
eventRef,
|
|
@@ -272,7 +329,6 @@ export {
|
|
|
272
329
|
commandsOf,
|
|
273
330
|
commandRef,
|
|
274
331
|
commandEvent,
|
|
275
|
-
attemptStatusEvents,
|
|
276
332
|
WEBVIEW_HOST_CAPABILITY_VERSION,
|
|
277
333
|
WEBVIEW_HOST_CAPABILITIES,
|
|
278
334
|
WEBVIEW_DECLARABLE_CAPABILITIES,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BooleanParam, HarnessParam, JsonParam, LongTextParam, MultiSelectParam, NumberParam, RepoParam, ResourceParam, SelectParam, TemplateParam, TextParam } from "
|
|
1
|
+
import type { BooleanParam, HarnessParam, JsonParam, ListParam, LongTextParam, MultiSelectParam, NumberParam, RepoParam, ResourceParam, SelectParam, TemplateParam, TextParam } from "pstdio-api-contracts/extension-kernel";
|
|
2
2
|
type RequiredOf<TOptions> = TOptions extends {
|
|
3
3
|
required: infer TRequired extends boolean;
|
|
4
4
|
} ? TRequired : undefined;
|
|
@@ -29,5 +29,6 @@ export declare const params: {
|
|
|
29
29
|
}>(options: TOptions) => TemplateParam<RequiredOf<TOptions>>;
|
|
30
30
|
resource: <const TOptions extends ParamOptions<ResourceParam>>(options: TOptions) => ResourceParam<RequiredOf<TOptions>>;
|
|
31
31
|
json: <T = unknown, const TOptions extends ParamOptions<JsonParam<T>> | undefined = undefined>(options?: TOptions) => JsonParam<T, RequiredOf<TOptions>>;
|
|
32
|
+
list: <const TOptions extends ParamOptions<ListParam> | undefined = undefined>(options?: TOptions) => ListParam<RequiredOf<TOptions>>;
|
|
32
33
|
};
|
|
33
34
|
export {};
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import type { CommandLifecycleEventPayload, CommandLifecyclePhase, CommandRef } from "
|
|
2
|
-
|
|
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
|
|
8
|
-
* `commandsOf(packageName, ext)`, which derives refs from the extension definition
|
|
9
|
-
* so a renamed command becomes a type 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>;
|
|
1
|
+
import type { CommandDefinition, CommandLifecycleEventPayload, CommandLifecyclePhase, CommandRef, EventRef, ParamObjectSchema, ParamsOf, Struct } from "pstdio-api-contracts/extension-kernel";
|
|
2
|
+
export { commandRef, eventRef } from "pstdio-api-contracts/extension-kernel";
|
|
14
3
|
/**
|
|
15
4
|
* Build an `EventRef` for a command lifecycle phase (`requested`, `started`, `completed`,
|
|
16
5
|
* `rejected`, `failed`). The payload type is inferred from the command ref so hooks see
|
|
@@ -37,4 +26,3 @@ type CommandsRefMap<TCommands extends CommandsRecord> = {
|
|
|
37
26
|
export declare const commandsOf: <TExtension extends {
|
|
38
27
|
commands?: CommandsRecord;
|
|
39
28
|
}>(packageName: string, extension: TExtension) => CommandsRefMap<NonNullable<TExtension["commands"]>>;
|
|
40
|
-
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WhenExpression } from "pstdio-api-contracts/extension-kernel";
|
|
2
|
+
/**
|
|
3
|
+
* Resource-scoped visibility for command-palette contributions. Both the workbench host and the
|
|
4
|
+
* dashboard palette gate the same way, so the rule lives here once instead of being re-derived per
|
|
5
|
+
* surface. Only `resourceType` is evaluated: it is the sole `when` field a palette surface can
|
|
6
|
+
* resolve from the active resource alone (`mode`/`source`/`metadata` require execution context the
|
|
7
|
+
* palette does not have).
|
|
8
|
+
*/
|
|
9
|
+
export declare const matchesResourceWhen: (when: Pick<WhenExpression, "resourceType"> | undefined, resourceType: string | undefined) => boolean;
|
package/dist/hooks/entities.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/** @deprecated Legacy ticket-workspace linkage. Ticket data is owned by the pstdio tickets extension. */
|
|
8
|
-
ticket_shorthand: string;
|
|
9
|
-
attempt_status_name: string | null;
|
|
1
|
+
import type { Workspace } from "../resources";
|
|
2
|
+
export type HookResourceAnchor = {
|
|
3
|
+
type: string;
|
|
4
|
+
id: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
metadata?: Record<string, unknown>;
|
|
10
7
|
};
|
|
8
|
+
export type HookWorkspace = Workspace;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export type { AttemptStatusChangeContext } from "./attempt";
|
|
2
1
|
export type { BaseHookContext, HookClient, HookPayload, SessionFollowupInput } from "./base";
|
|
3
2
|
export type { SessionHookContext } from "./session";
|
|
4
|
-
export type { TicketContext, TicketCreationContext, TicketStatusChangeContext } from "./ticket";
|
|
5
3
|
export type { CommitContext, ConflictContext, MergeContext, RebaseContext, WorktreeContext, WorktreeCreateContext, WorktreeRemoveContext, } from "./worktree";
|
package/dist/hooks/session.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseHookContext } from "./base";
|
|
2
|
-
import type {
|
|
2
|
+
import type { HookResourceAnchor, HookWorkspace } from "./entities";
|
|
3
3
|
export type SessionHookContext = BaseHookContext & {
|
|
4
4
|
sessionId: string;
|
|
5
5
|
sessionStatus: "in_progress" | "awaiting_input" | "queued" | "completed" | "failed" | "cancelled" | "disconnected";
|
|
@@ -8,6 +8,5 @@ export type SessionHookContext = BaseHookContext & {
|
|
|
8
8
|
workspaceId?: string;
|
|
9
9
|
worktreePath?: string;
|
|
10
10
|
branch?: string;
|
|
11
|
-
|
|
12
|
-
attemptStatus?: string;
|
|
11
|
+
anchors?: HookResourceAnchor[];
|
|
13
12
|
};
|
package/dist/hooks/worktree.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { BaseHookContext } from "./base";
|
|
2
|
+
import type { HookResourceAnchor } from "./entities";
|
|
2
3
|
export type WorktreeCreateContext = BaseHookContext & {
|
|
3
4
|
repoPath: string;
|
|
4
5
|
worktreePath: string;
|
|
5
6
|
branch: string;
|
|
6
7
|
workspace: string;
|
|
7
|
-
ticket: string;
|
|
8
8
|
base: string;
|
|
9
|
+
anchors?: HookResourceAnchor[];
|
|
9
10
|
};
|
|
10
11
|
export type WorktreeContext = BaseHookContext & {
|
|
11
12
|
repoPath: string;
|
|
@@ -13,7 +14,7 @@ export type WorktreeContext = BaseHookContext & {
|
|
|
13
14
|
branch: string;
|
|
14
15
|
workspace: string;
|
|
15
16
|
workspaceId: string;
|
|
16
|
-
|
|
17
|
+
anchors?: HookResourceAnchor[];
|
|
17
18
|
};
|
|
18
19
|
export type CommitContext = {
|
|
19
20
|
repoPath: string;
|
|
@@ -47,6 +48,6 @@ export type WorktreeRemoveContext = {
|
|
|
47
48
|
branch: string;
|
|
48
49
|
workspace: string;
|
|
49
50
|
workspaceId: string;
|
|
50
|
-
|
|
51
|
+
anchors?: HookResourceAnchor[];
|
|
51
52
|
projectId: string;
|
|
52
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { AgentAvailabilityType,
|
|
1
|
+
export type { AgentAvailabilityType, AgentInfo, AgentModel } from "pstdio-api-contracts";
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
export type { Repo } from "pstdio-api-contracts";
|
|
2
|
-
export type { AgentAvailabilityType,
|
|
2
|
+
export type { AgentAvailabilityType, AgentInfo, AgentModel } from "./agent";
|
|
3
3
|
export type { FileRecord } from "./file";
|
|
4
4
|
export type { KnownAgent, KnownAgentId } from "./known-agents";
|
|
5
|
-
export { findAgent, isKnownAgentId, KNOWN_AGENT_IDS, KNOWN_AGENTS } from "./known-agents";
|
|
5
|
+
export { findAgent, harnessLocalId, isKnownAgentId, KNOWN_AGENT_IDS, KNOWN_AGENTS } from "./known-agents";
|
|
6
6
|
export type { Project } from "./project";
|
|
7
7
|
export type { Session, SessionStatus } from "./session";
|
|
8
8
|
export type { Settings } from "./settings";
|
|
9
9
|
export type { Skill, SkillFile, SkillWithContent } from "./skill";
|
|
10
|
-
export type { AttemptStatus, Status } from "./status";
|
|
11
|
-
export type { Tag, TagOption } from "./tag";
|
|
12
10
|
export type { Template, TemplateType, TemplateWithContent } from "./template";
|
|
13
|
-
export type { Ticket, TicketDetail, TicketFile, TicketListItem } from "./ticket";
|
|
14
11
|
export type { Workspace, WorkspaceListItem } from "./workspace";
|
package/dist/resources/index.js
CHANGED
|
@@ -16,10 +16,12 @@ var KNOWN_AGENTS = [
|
|
|
16
16
|
}
|
|
17
17
|
];
|
|
18
18
|
var KNOWN_AGENT_IDS = KNOWN_AGENTS.map((agent) => agent.id);
|
|
19
|
-
var
|
|
19
|
+
var harnessLocalId = (id) => id.slice(id.lastIndexOf(".") + 1);
|
|
20
|
+
var findAgent = (id) => KNOWN_AGENTS.find((agent) => agent.id === harnessLocalId(id)) ?? null;
|
|
20
21
|
var isKnownAgentId = (id) => KNOWN_AGENT_IDS.includes(id);
|
|
21
22
|
export {
|
|
22
23
|
isKnownAgentId,
|
|
24
|
+
harnessLocalId,
|
|
23
25
|
findAgent,
|
|
24
26
|
KNOWN_AGENT_IDS,
|
|
25
27
|
KNOWN_AGENTS
|
|
@@ -8,5 +8,7 @@ export type KnownAgent = {
|
|
|
8
8
|
};
|
|
9
9
|
export declare const KNOWN_AGENTS: KnownAgent[];
|
|
10
10
|
export declare const KNOWN_AGENT_IDS: KnownAgentId[];
|
|
11
|
+
/** Bare provider id of a (possibly namespaced) harness id, e.g. "pstdio.harness-claude-code.claude-code" -> "claude-code". */
|
|
12
|
+
export declare const harnessLocalId: (id: string) => string;
|
|
11
13
|
export declare const findAgent: (id: string) => KnownAgent | null;
|
|
12
14
|
export declare const isKnownAgentId: (id: string) => id is KnownAgentId;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { Workspace as ContractWorkspace, WorkspaceListItem as ContractWorkspaceListItem } from "pstdio-api-contracts";
|
|
2
2
|
export type Workspace = ContractWorkspace;
|
|
3
|
-
/** @deprecated Includes legacy ticket-workspace linkage. Ticket ownership is moving to the pstdio tickets extension. */
|
|
4
3
|
export type WorkspaceListItem = ContractWorkspaceListItem;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pstdio/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/pufflyai/prompt-studio"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "rm -rf ./dist && bun run build:js && bun run build:types",
|
|
43
|
-
"build:js": "bun build ./src/api/index.ts ./src/client/index.ts ./src/extensions/index.ts ./src/prompts/index.ts ./src/hooks/index.ts ./src/resources/index.ts --outdir ./dist --root ./src --target node --format esm --
|
|
43
|
+
"build:js": "bun build ./src/api/index.ts ./src/client/index.ts ./src/extensions/index.ts ./src/prompts/index.ts ./src/hooks/index.ts ./src/resources/index.ts --outdir ./dist --root ./src --target node --format esm --external mustache",
|
|
44
44
|
"build:types": "tsc --project ./tsconfig.build.json",
|
|
45
45
|
"prepack": "bun run build",
|
|
46
46
|
"typecheck": "tsc --noEmit",
|
package/dist/api/agents.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { SetupAgentInput, SetupAvailableAgentsInput, UpdateAgentInput } from "pstdio-api-contracts";
|
package/dist/api/statuses.d.ts
DELETED
package/dist/api/tags.d.ts
DELETED
package/dist/api/tickets.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/** @deprecated Legacy core ticket API. Ticket data is owned by the pstdio tickets extension. */
|
|
2
|
-
export type { CreateTicketAttemptInput, CreateTicketInput, ListProjectActivityForTicketsInput, ListTicketActivityInput, ListTicketActivityResponse, TicketAttemptMode, UpdateTicketInput, UpdateWhenAttemptStatusInput, UpdateWhenAttemptStatusResponse, UploadTicketFileInput, } from "pstdio-api-contracts";
|
|
3
|
-
import type { Ticket, Workspace } from "../resources";
|
|
4
|
-
/** @deprecated Legacy core ticket API. Ticket data is owned by the pstdio tickets extension. */
|
|
5
|
-
export type ListTicketsInput = {
|
|
6
|
-
status?: string;
|
|
7
|
-
tag?: string | string[];
|
|
8
|
-
archived?: boolean;
|
|
9
|
-
draft?: boolean;
|
|
10
|
-
parent_id?: string;
|
|
11
|
-
shorthand?: string;
|
|
12
|
-
search?: string;
|
|
13
|
-
};
|
|
14
|
-
/** @deprecated Legacy core ticket attempts. Ticket attempts are owned by the pstdio tickets extension. */
|
|
15
|
-
export type TicketAttemptResponse = {
|
|
16
|
-
mode: "worktree" | "current_branch";
|
|
17
|
-
ticket: Ticket;
|
|
18
|
-
workspace: Workspace;
|
|
19
|
-
session: {
|
|
20
|
-
id: string;
|
|
21
|
-
workspace_id: string;
|
|
22
|
-
title: string;
|
|
23
|
-
created_at: string;
|
|
24
|
-
updated_at: string;
|
|
25
|
-
} | null;
|
|
26
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { AttemptStatus, CreateAttemptStatusInput, CreateStatusInput } from "pstdio-api-contracts";
|
|
2
|
-
import type { Status } from "../resources";
|
|
3
|
-
import type { RequestFn } from "./request";
|
|
4
|
-
/** @deprecated Legacy core ticket status client. Ticket statuses are owned by the pstdio tickets extension. */
|
|
5
|
-
export type StatusClient = {
|
|
6
|
-
list(projectId: string): Promise<Status[]>;
|
|
7
|
-
create(projectId: string, input: CreateStatusInput): Promise<Status>;
|
|
8
|
-
update(projectId: string, statusId: string, input: {
|
|
9
|
-
color?: string;
|
|
10
|
-
}): Promise<Status>;
|
|
11
|
-
setDefault(projectId: string, statusId: string): Promise<void>;
|
|
12
|
-
delete(projectId: string, statusId: string): Promise<void>;
|
|
13
|
-
listAttemptStatuses(projectId: string): Promise<AttemptStatus[]>;
|
|
14
|
-
createAttemptStatus(projectId: string, input: CreateAttemptStatusInput): Promise<AttemptStatus>;
|
|
15
|
-
updateAttemptStatus(projectId: string, statusId: string, input: {
|
|
16
|
-
name?: string;
|
|
17
|
-
color?: string;
|
|
18
|
-
sort_order?: number;
|
|
19
|
-
is_default?: boolean;
|
|
20
|
-
}): Promise<AttemptStatus>;
|
|
21
|
-
deleteAttemptStatus(projectId: string, statusId: string): Promise<void>;
|
|
22
|
-
};
|
|
23
|
-
/** @deprecated Legacy core ticket status client. Ticket statuses are owned by the pstdio tickets extension. */
|
|
24
|
-
export declare const createStatusClient: (request: RequestFn) => StatusClient;
|
package/dist/client/tags.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { CreateTagInput, CreateTagOptionInput, UpdateTagInput, UpdateTagOptionInput } from "../api/tags";
|
|
2
|
-
import type { Tag, TagOption } from "../resources";
|
|
3
|
-
import type { RequestFn } from "./request";
|
|
4
|
-
/** @deprecated Legacy core ticket tag client. Ticket tags are owned by the pstdio tickets extension. */
|
|
5
|
-
export type TagClient = {
|
|
6
|
-
list(projectId: string): Promise<Tag[]>;
|
|
7
|
-
create(projectId: string, input: CreateTagInput): Promise<Tag>;
|
|
8
|
-
update(projectId: string, tagId: string, input: UpdateTagInput): Promise<Tag>;
|
|
9
|
-
delete(projectId: string, tagId: string): Promise<void>;
|
|
10
|
-
createOption(projectId: string, tagId: string, input: CreateTagOptionInput): Promise<TagOption>;
|
|
11
|
-
updateOption(projectId: string, tagId: string, optionId: string, input: UpdateTagOptionInput): Promise<TagOption>;
|
|
12
|
-
deleteOption(projectId: string, tagId: string, optionId: string): Promise<void>;
|
|
13
|
-
};
|
|
14
|
-
/** @deprecated Legacy core ticket tag client. Ticket tags are owned by the pstdio tickets extension. */
|
|
15
|
-
export declare const createTagClient: (request: RequestFn) => TagClient;
|
package/dist/client/tickets.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { CreateTicketAttemptInput, CreateTicketInput, ListProjectActivityForTicketsInput, ListTicketActivityInput, ListTicketActivityResponse, ListTicketsInput, TicketAttemptResponse, UpdateTicketInput, UpdateWhenAttemptStatusInput, UpdateWhenAttemptStatusResponse, UploadTicketFileInput } from "../api/tickets";
|
|
2
|
-
import type { Ticket, TicketDetail, TicketFile, TicketListItem } from "../resources";
|
|
3
|
-
import { type ClientOptions, type RequestFn } from "./request";
|
|
4
|
-
/** @deprecated Legacy core ticket client. Ticket data is owned by the pstdio tickets extension. */
|
|
5
|
-
export type TicketClient = {
|
|
6
|
-
list(projectId: string, input?: ListTicketsInput): Promise<TicketListItem[]>;
|
|
7
|
-
get(ticketId: string): Promise<TicketDetail>;
|
|
8
|
-
create(input: CreateTicketInput): Promise<Ticket>;
|
|
9
|
-
update(ticketId: string, input: UpdateTicketInput): Promise<Ticket>;
|
|
10
|
-
delete(ticketId: string): Promise<void>;
|
|
11
|
-
createAttempt(ticketId: string, input: CreateTicketAttemptInput): Promise<TicketAttemptResponse>;
|
|
12
|
-
listActivity(ticketId: string, input?: ListTicketActivityInput): Promise<ListTicketActivityResponse>;
|
|
13
|
-
listProjectActivity(projectId: string, input?: ListProjectActivityForTicketsInput): Promise<ListTicketActivityResponse>;
|
|
14
|
-
updateWhenAttemptStatus(ticketId: string, input: UpdateWhenAttemptStatusInput): Promise<UpdateWhenAttemptStatusResponse>;
|
|
15
|
-
listFiles(ticketId: string): Promise<TicketFile[]>;
|
|
16
|
-
getFileContent(ticketId: string, fileId: string, options?: {
|
|
17
|
-
cache?: RequestCache;
|
|
18
|
-
signal?: AbortSignal;
|
|
19
|
-
}): Promise<Uint8Array>;
|
|
20
|
-
uploadFile(ticketId: string, input: UploadTicketFileInput): Promise<TicketFile>;
|
|
21
|
-
deleteFile(ticketId: string, fileId: string): Promise<void>;
|
|
22
|
-
};
|
|
23
|
-
/** @deprecated Legacy core ticket client. Ticket data is owned by the pstdio tickets extension. */
|
|
24
|
-
export declare const createTicketClient: (request: RequestFn, options?: ClientOptions) => TicketClient;
|