@pstdio/sdk 0.11.0 → 0.13.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/dist/api/index.d.ts +0 -1
- package/dist/client/agents.d.ts +5 -8
- package/dist/client/index.js +17 -7
- package/dist/extensions/command-outcome.d.ts +1 -1
- package/dist/extensions/define-command.d.ts +1 -3
- package/dist/extensions/define-extension-view.d.ts +2 -2
- package/dist/extensions/define-extension.d.ts +1 -4
- package/dist/extensions/index.d.ts +3 -8
- package/dist/extensions/index.js +145 -129
- package/dist/extensions/params.d.ts +1 -1
- package/dist/extensions/refs.d.ts +2 -14
- package/dist/extensions/when.d.ts +1 -1
- package/dist/prompts/index.js +15 -0
- package/dist/resources/agent.d.ts +2 -1
- package/dist/resources/index.d.ts +2 -3
- package/dist/resources/index.js +14738 -19
- package/package.json +2 -2
- package/dist/api/agents.d.ts +0 -1
- package/dist/extensions/kernel-slots.d.ts +0 -112
- package/dist/extensions/l10n.d.ts +0 -10
- 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 -258
- package/dist/extensions/types/contributions.d.ts +0 -374
- package/dist/extensions/types/events.d.ts +0 -10
- package/dist/extensions/types/extension.d.ts +0 -183
- package/dist/extensions/types/index.d.ts +0 -11
- package/dist/extensions/types/json.d.ts +0 -7
- package/dist/extensions/types/params.d.ts +0 -83
- package/dist/extensions/types/resources.d.ts +0 -25
- package/dist/extensions/types/slots.d.ts +0 -22
- package/dist/extensions/types/tree-renderer.d.ts +0 -89
- package/dist/extensions/types/webview-capabilities.d.ts +0 -93
- package/dist/extensions/workbench-targets.d.ts +0 -124
- package/dist/resources/known-agents.d.ts +0 -12
package/dist/api/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type { SetupAgentInput, SetupAvailableAgentsInput, UpdateAgentInput } from "./agents";
|
|
2
1
|
export type { CommandExecuteRequest, CommandExecuteResponse, ExtensionCommandPaletteContribution, ExtensionCommandPaletteResourceRecord, ExtensionCommandRecord, ExtensionDataRendererRecord, ExtensionDiagnostic, ExtensionKeybindingRecord, ExtensionMenuContribution, ExtensionModeRecord, ExtensionNavigationRecord, ExtensionRecord, ExtensionRouteRecord, ExtensionSettingDefinitionRecord, ExtensionSettingsPanelRecord, ExtensionSettingValueRecord, ExtensionTreeItemContribution, ExtensionTreeRendererRecord, ExtensionViewRecord, ListExtensionAppearanceResponse, ListExtensionCommandsResponse, ListExtensionSettingsResponse, ListProjectExtensionsResponse, LocalizableString, ProjectExtensionInstance, UpdateExtensionSettingRequest, UpdateInstalledExtensionTemplateInput, UpdateInstalledExtensionTemplateResponse, WorkbenchExtensionCommandPaletteResourceRecord, WorkbenchExtensionDataRendererRecord, WorkbenchExtensionMetadata, WorkbenchExtensionTreeRendererRecord, } from "./extensions";
|
|
3
2
|
export type { CreateProjectInput, RegisterRepoInput } from "./projects";
|
|
4
3
|
export type { ApprovalInput, CreateSessionInput, FollowUpInput, ResolveSessionIdInput, ResolveSessionIdResponse, SessionConversationResponse, } from "./sessions";
|
package/dist/client/agents.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import type { AgentModel
|
|
2
|
-
import type {
|
|
1
|
+
import type { AgentModel } from "pstdio-api-contracts";
|
|
2
|
+
import type { AgentInfo } from "../resources";
|
|
3
3
|
import type { RequestFn } from "./request";
|
|
4
4
|
export type AgentClient = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
info(params?: {
|
|
6
|
+
project?: string;
|
|
7
|
+
}): Promise<AgentInfo[]>;
|
|
7
8
|
models(agentId: string): Promise<AgentModel[]>;
|
|
8
|
-
setup(input: SetupAgentInput): Promise<AgentConfig>;
|
|
9
|
-
setupAvailable(input: SetupAvailableAgentsInput): Promise<AgentConfig[]>;
|
|
10
|
-
update(agentId: string, input: UpdateAgentInput): Promise<AgentConfig>;
|
|
11
|
-
delete(agentId: string): Promise<void>;
|
|
12
9
|
};
|
|
13
10
|
export declare const createAgentClient: (request: RequestFn) => AgentClient;
|
package/dist/client/index.js
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __returnValue = (v) => v;
|
|
3
|
+
function __exportSetter(name, newValue) {
|
|
4
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
5
|
+
}
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
set: __exportSetter.bind(all, name)
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
1
16
|
// src/client/agents.ts
|
|
2
17
|
var createAgentClient = (request) => ({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
models: (agentId) => request(`/v1/agents/${agentId}/models`),
|
|
6
|
-
setup: (input) => request("/v1/agents", { method: "POST", body: input }),
|
|
7
|
-
setupAvailable: (input) => request("/v1/agents/setup-available", { method: "POST", body: input }),
|
|
8
|
-
update: (agentId, input) => request(`/v1/agents/${agentId}`, { method: "PATCH", body: input }),
|
|
9
|
-
delete: (agentId) => request(`/v1/agents/${agentId}`, { method: "DELETE" })
|
|
18
|
+
info: (params) => request(params?.project ? `/v1/agents/info?project=${encodeURIComponent(params.project)}` : "/v1/agents/info"),
|
|
19
|
+
models: (agentId) => request(`/v1/agents/${agentId}/models`)
|
|
10
20
|
});
|
|
11
21
|
|
|
12
22
|
// src/client/extensions.ts
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { CommandDefinition, HookDefinition, MiddlewareDefinition } from "
|
|
2
|
-
import type { Struct } from "./types/json";
|
|
3
|
-
import type { ParamObjectSchema } from "./types/params";
|
|
1
|
+
import type { CommandDefinition, HookDefinition, MiddlewareDefinition, ParamObjectSchema, Struct } from "pstdio-api-contracts/extension-kernel";
|
|
4
2
|
/**
|
|
5
3
|
* Define a single command outside an extension's object literal. Use this when commands
|
|
6
4
|
* grow large enough to split into separate files, or when you need to share a command
|
|
@@ -28,13 +28,13 @@ export interface WebviewFilesClient {
|
|
|
28
28
|
type: string;
|
|
29
29
|
id?: string;
|
|
30
30
|
};
|
|
31
|
-
}): Promise<import("
|
|
31
|
+
}): Promise<import("pstdio-api-contracts/extension-kernel").ExtensionBlobRef>;
|
|
32
32
|
list(input?: {
|
|
33
33
|
scope?: {
|
|
34
34
|
type: string;
|
|
35
35
|
id?: string;
|
|
36
36
|
};
|
|
37
|
-
}): Promise<import("
|
|
37
|
+
}): Promise<import("pstdio-api-contracts/extension-kernel").ExtensionBlobRef[]>;
|
|
38
38
|
delete(id: string): Promise<void>;
|
|
39
39
|
}
|
|
40
40
|
export type ExtensionViewRenderContext<TProps = unknown> = {
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type { ExtensionSettingProperty, ExtensionSettingsContribution } from "
|
|
2
|
-
import type { CommandDefinition, ExtensionDefinition, HookDefinition, MiddlewareDefinition, ScheduleContribution } from "./types/extension";
|
|
3
|
-
import type { Struct } from "./types/json";
|
|
4
|
-
import type { ParamObjectSchema } from "./types/params";
|
|
1
|
+
import type { CommandDefinition, ExtensionDefinition, ExtensionSettingProperty, ExtensionSettingsContribution, HookDefinition, MiddlewareDefinition, ParamObjectSchema, ScheduleContribution, Struct } from "pstdio-api-contracts/extension-kernel";
|
|
5
2
|
type CommandSchemas = Record<string, ParamObjectSchema | undefined>;
|
|
6
3
|
type MiddlewareParams = Record<string, Struct>;
|
|
7
4
|
type MiddlewareResults = Record<string, unknown>;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
+
export type * from "pstdio-api-contracts/extension-kernel";
|
|
2
|
+
export type { CommitPayload, ConflictPayload, MergePayload, RebasePayload, SessionLifecyclePayload, WorktreeCreatedEventPayload, WorktreeRemovedPayload, } from "pstdio-api-contracts/extension-kernel";
|
|
3
|
+
export { ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES, EXTENSION_API_VERSION, getWorkbenchTargetDefinition, gitEvents, isLocalizedString, type Localizable, type LocalizedString, l10n, packageAsset, projectEvents, projectSlots, sessionEvents, sessionSlots, WEBVIEW_DECLARABLE_CAPABILITIES, WEBVIEW_HOST_CAPABILITIES, WEBVIEW_HOST_CAPABILITY_VERSION, type WorkbenchAttachmentTarget, type WorkbenchContributionKind, type WorkbenchLayoutTarget, type WorkbenchMenuTarget, type WorkbenchModeLayoutTarget, type WorkbenchSettingsScope, type WorkbenchSettingsTarget, type WorkbenchTargetDefinition, type WorkbenchTargetGranularity, type WorkbenchTreeTarget, type WorkbenchViewTarget, workbenchMenuTargets, workbenchModeLayoutTargets, workbenchSettingsScopes, workbenchSettingsTargets, workbenchTargets, workbenchTreeTargets, workbenchViewTargets, workspaceEvents, workspaceSlots, worktreeEvents, } from "pstdio-api-contracts/extension-kernel";
|
|
1
4
|
export { type CommandResponse, unwrapCommandOutcome } from "./command-outcome";
|
|
2
5
|
export { defineCommand, defineHook, defineMiddleware } from "./define-command";
|
|
3
6
|
export { defineExtension } from "./define-extension";
|
|
4
7
|
export { defineExtensionView, type ExtensionViewModule, type ExtensionViewRender, type ExtensionViewRenderContext, type GuestHost, type PropsStore, type WebviewFilesClient, } from "./define-extension-view";
|
|
5
|
-
export type { CommitPayload, ConflictPayload, MergePayload, RebasePayload, SessionLifecyclePayload, WorktreeCreatedEventPayload, WorktreeRemovedPayload, } from "./kernel-slots";
|
|
6
|
-
export { gitEvents, projectEvents, projectSlots, sessionEvents, sessionSlots, workspaceEvents, workspaceSlots, worktreeEvents, } from "./kernel-slots";
|
|
7
|
-
export { isLocalizedString, type Localizable, type LocalizedString, l10n } from "./l10n";
|
|
8
|
-
export { packageAsset } from "./package-asset";
|
|
9
8
|
export { params } from "./params";
|
|
10
9
|
export { commandEvent, commandRef, commandsOf, eventRef } from "./refs";
|
|
11
|
-
export type * from "./types";
|
|
12
|
-
export { EXTENSION_API_VERSION } from "./types/extension";
|
|
13
|
-
export { ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES, WEBVIEW_DECLARABLE_CAPABILITIES, WEBVIEW_HOST_CAPABILITIES, WEBVIEW_HOST_CAPABILITY_VERSION, } from "./types/webview-capabilities";
|
|
14
10
|
export { matchesResourceWhen } from "./when";
|
|
15
|
-
export { getWorkbenchTargetDefinition, type WorkbenchAttachmentTarget, type WorkbenchContributionKind, type WorkbenchLayoutTarget, type WorkbenchMenuTarget, type WorkbenchModeLayoutTarget, type WorkbenchSettingsScope, type WorkbenchSettingsTarget, type WorkbenchTargetDefinition, type WorkbenchTargetGranularity, type WorkbenchTreeTarget, type WorkbenchViewTarget, workbenchMenuTargets, workbenchModeLayoutTargets, workbenchSettingsScopes, workbenchSettingsTargets, workbenchTargets, workbenchTreeTargets, workbenchViewTargets, } from "./workbench-targets";
|
package/dist/extensions/index.js
CHANGED
|
@@ -1,97 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// src/extensions/define-extension.ts
|
|
14
|
-
var defineExtension = (extension) => extension;
|
|
15
|
-
// src/extensions/define-extension-view.ts
|
|
16
|
-
var pickFiles = (opts = {}) => new Promise((resolve, reject) => {
|
|
17
|
-
const input = document.createElement("input");
|
|
18
|
-
input.type = "file";
|
|
19
|
-
input.accept = opts.accept ?? "";
|
|
20
|
-
input.multiple = opts.multiple ?? false;
|
|
21
|
-
input.style.display = "none";
|
|
22
|
-
input.addEventListener("change", () => {
|
|
23
|
-
const files = input.files ? Array.from(input.files) : [];
|
|
24
|
-
input.remove();
|
|
25
|
-
resolve(files);
|
|
26
|
-
});
|
|
27
|
-
input.addEventListener("cancel", () => {
|
|
28
|
-
input.remove();
|
|
29
|
-
resolve([]);
|
|
30
|
-
});
|
|
31
|
-
input.addEventListener("error", () => {
|
|
32
|
-
input.remove();
|
|
33
|
-
reject(new Error("Could not pick files."));
|
|
34
|
-
});
|
|
35
|
-
document.body.appendChild(input);
|
|
36
|
-
input.click();
|
|
37
|
-
});
|
|
38
|
-
var createFilesClient = (host) => ({
|
|
39
|
-
pick: pickFiles,
|
|
40
|
-
upload: (input) => host.call("files.upload", input),
|
|
41
|
-
list: async (input) => {
|
|
42
|
-
const response = await host.call("files.list", input ?? {});
|
|
43
|
-
return response.files ?? [];
|
|
44
|
-
},
|
|
45
|
-
delete: (id) => host.call("files.delete", { id })
|
|
46
|
-
});
|
|
47
|
-
var readTranslationProps = (props) => {
|
|
48
|
-
const translations = typeof props === "object" && props !== null && "translations" in props ? props.translations : undefined;
|
|
49
|
-
if (typeof translations !== "object" || translations === null)
|
|
50
|
-
return null;
|
|
51
|
-
return translations;
|
|
52
|
-
};
|
|
53
|
-
var interpolate = (value, args) => Object.entries(args ?? {}).reduce((next, [key, replacement]) => next.replaceAll(`{{${key}}}`, String(replacement)), value);
|
|
54
|
-
var createTranslationApi = (propsStore) => {
|
|
55
|
-
const locale = () => readTranslationProps(propsStore.get())?.locale ?? "en";
|
|
56
|
-
const t = (key, defaultValue, args) => {
|
|
57
|
-
const translations = readTranslationProps(propsStore.get());
|
|
58
|
-
const value = translations?.bundle?.[key] ?? translations?.defaultBundle?.[key] ?? defaultValue ?? key;
|
|
59
|
-
return interpolate(value, args);
|
|
60
|
-
};
|
|
61
|
-
return { locale, t };
|
|
62
|
-
};
|
|
63
|
-
var defineExtensionView = (definition) => ({
|
|
64
|
-
mount: async (mount, host, propsStore) => {
|
|
65
|
-
const translations = createTranslationApi(propsStore);
|
|
66
|
-
const cleanup = await definition.render({
|
|
67
|
-
mount,
|
|
68
|
-
host,
|
|
69
|
-
files: createFilesClient(host),
|
|
70
|
-
propsStore,
|
|
71
|
-
get locale() {
|
|
72
|
-
return translations.locale();
|
|
73
|
-
},
|
|
74
|
-
t: translations.t
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __returnValue = (v) => v;
|
|
3
|
+
function __exportSetter(name, newValue) {
|
|
4
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
5
|
+
}
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
set: __exportSetter.bind(all, name)
|
|
75
13
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// src/extensions/refs.ts
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// ../pstdio-api-contracts/src/extension-kernel/refs.ts
|
|
80
17
|
var commandRef = (id) => ({ id });
|
|
81
18
|
var eventRef = (id) => ({ id });
|
|
82
|
-
var commandEvent = (command, phase) => ({
|
|
83
|
-
id: `command.${phase}:${command.id}`
|
|
84
|
-
});
|
|
85
|
-
var commandsOf = (packageName, extension) => {
|
|
86
|
-
const refs = {};
|
|
87
|
-
const commands = extension.commands ?? {};
|
|
88
|
-
for (const key of Object.keys(commands)) {
|
|
89
|
-
refs[key] = { id: `${packageName}.${key}` };
|
|
90
|
-
}
|
|
91
|
-
return refs;
|
|
92
|
-
};
|
|
93
19
|
|
|
94
|
-
// src/
|
|
20
|
+
// ../pstdio-api-contracts/src/extension-kernel/slots.ts
|
|
95
21
|
var defineSlot = (id, options) => ({
|
|
96
22
|
id,
|
|
97
23
|
kind: options.kind,
|
|
@@ -100,7 +26,7 @@ var defineSlot = (id, options) => ({
|
|
|
100
26
|
metadata: options.metadata
|
|
101
27
|
});
|
|
102
28
|
|
|
103
|
-
// src/
|
|
29
|
+
// ../pstdio-api-contracts/src/extension-kernel/kernel-slots.ts
|
|
104
30
|
var projectSlots = {
|
|
105
31
|
sidebar: defineSlot("project.sidebar", { kind: "view" }),
|
|
106
32
|
headerPrimary: defineSlot("project.headerPrimary", { kind: "menu" }),
|
|
@@ -143,47 +69,21 @@ var gitEvents = {
|
|
|
143
69
|
merged: eventRef("git.merged"),
|
|
144
70
|
conflicted: eventRef("git.conflicted")
|
|
145
71
|
};
|
|
146
|
-
// src/
|
|
72
|
+
// ../pstdio-api-contracts/src/extension-kernel/l10n.ts
|
|
147
73
|
var l10n = (key, defaultValue) => ({
|
|
148
74
|
$l10n: key,
|
|
149
75
|
...defaultValue === undefined ? {} : { default: defaultValue }
|
|
150
76
|
});
|
|
151
77
|
var isLocalizedString = (value) => typeof value === "object" && value !== null && ("$l10n" in value) && typeof value.$l10n === "string";
|
|
152
|
-
// src/
|
|
78
|
+
// ../pstdio-api-contracts/src/extension-kernel/package-asset.ts
|
|
153
79
|
var packageAsset = (path, baseUrl) => ({
|
|
154
80
|
kind: "package-asset",
|
|
155
81
|
path,
|
|
156
82
|
baseUrl
|
|
157
83
|
});
|
|
158
|
-
// src/
|
|
159
|
-
var params = {
|
|
160
|
-
text: (options) => ({ type: "text", ...options }),
|
|
161
|
-
longText: (options) => ({ type: "longtext", ...options }),
|
|
162
|
-
number: (options) => ({ type: "number", ...options }),
|
|
163
|
-
boolean: (options) => ({ type: "boolean", ...options }),
|
|
164
|
-
select: (options) => ({ type: "select", ...options }),
|
|
165
|
-
multiSelect: (options) => ({
|
|
166
|
-
type: "multi-select",
|
|
167
|
-
...options
|
|
168
|
-
}),
|
|
169
|
-
repo: (options) => ({ type: "repo", ...options }),
|
|
170
|
-
harness: (options) => ({ type: "harness", ...options }),
|
|
171
|
-
template: (options) => ({
|
|
172
|
-
label: options.label,
|
|
173
|
-
description: options.description,
|
|
174
|
-
required: options.required,
|
|
175
|
-
defaultValue: options.defaultValue,
|
|
176
|
-
metadata: options.metadata,
|
|
177
|
-
type: "template",
|
|
178
|
-
templateType: options.type
|
|
179
|
-
}),
|
|
180
|
-
resource: (options) => ({ type: "resource", ...options }),
|
|
181
|
-
json: (options) => ({ type: "json", ...options }),
|
|
182
|
-
list: (options) => ({ type: "list", ...options })
|
|
183
|
-
};
|
|
184
|
-
// src/extensions/types/extension.ts
|
|
84
|
+
// ../pstdio-api-contracts/src/extension-kernel/types/extension.ts
|
|
185
85
|
var EXTENSION_API_VERSION = "1.0.0";
|
|
186
|
-
// src/
|
|
86
|
+
// ../pstdio-api-contracts/src/extension-kernel/types/webview-capabilities.ts
|
|
187
87
|
var WEBVIEW_HOST_CAPABILITY_VERSION = 1;
|
|
188
88
|
var WEBVIEW_DECLARABLE_CAPABILITIES = [
|
|
189
89
|
"commands.execute",
|
|
@@ -204,14 +104,7 @@ var WEBVIEW_HOST_CAPABILITIES = [
|
|
|
204
104
|
...WEBVIEW_DECLARABLE_CAPABILITIES,
|
|
205
105
|
...ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES
|
|
206
106
|
];
|
|
207
|
-
// src/
|
|
208
|
-
var matchesResourceWhen = (when, resourceType) => {
|
|
209
|
-
const resourceTypes = when?.resourceType;
|
|
210
|
-
if (!resourceTypes?.length)
|
|
211
|
-
return true;
|
|
212
|
-
return resourceType ? resourceTypes.includes(resourceType) : false;
|
|
213
|
-
};
|
|
214
|
-
// src/extensions/workbench-targets.ts
|
|
107
|
+
// ../pstdio-api-contracts/src/extension-kernel/workbench-targets.ts
|
|
215
108
|
var workbenchMenuTargets = ["workbench.nav.actions", "workbench.nav.overflow"];
|
|
216
109
|
var workbenchTreeTargets = [
|
|
217
110
|
"workbench.left.tree",
|
|
@@ -296,6 +189,129 @@ var workbenchTargets = [
|
|
|
296
189
|
}
|
|
297
190
|
];
|
|
298
191
|
var getWorkbenchTargetDefinition = (id) => workbenchTargets.find((target) => target.id === id);
|
|
192
|
+
// src/extensions/command-outcome.ts
|
|
193
|
+
var unwrapCommandOutcome = (response, fallbackReason = "Command failed.") => {
|
|
194
|
+
const { outcome } = response;
|
|
195
|
+
if (outcome.status !== "success") {
|
|
196
|
+
throw new Error(outcome.reason || fallbackReason);
|
|
197
|
+
}
|
|
198
|
+
return outcome.value;
|
|
199
|
+
};
|
|
200
|
+
// src/extensions/define-command.ts
|
|
201
|
+
var defineCommand = (definition) => definition;
|
|
202
|
+
var defineMiddleware = (definition) => definition;
|
|
203
|
+
var defineHook = (definition) => definition;
|
|
204
|
+
// src/extensions/define-extension.ts
|
|
205
|
+
var defineExtension = (extension) => extension;
|
|
206
|
+
// src/extensions/define-extension-view.ts
|
|
207
|
+
var pickFiles = (opts = {}) => new Promise((resolve, reject) => {
|
|
208
|
+
const input = document.createElement("input");
|
|
209
|
+
input.type = "file";
|
|
210
|
+
input.accept = opts.accept ?? "";
|
|
211
|
+
input.multiple = opts.multiple ?? false;
|
|
212
|
+
input.style.display = "none";
|
|
213
|
+
input.addEventListener("change", () => {
|
|
214
|
+
const files = input.files ? Array.from(input.files) : [];
|
|
215
|
+
input.remove();
|
|
216
|
+
resolve(files);
|
|
217
|
+
});
|
|
218
|
+
input.addEventListener("cancel", () => {
|
|
219
|
+
input.remove();
|
|
220
|
+
resolve([]);
|
|
221
|
+
});
|
|
222
|
+
input.addEventListener("error", () => {
|
|
223
|
+
input.remove();
|
|
224
|
+
reject(new Error("Could not pick files."));
|
|
225
|
+
});
|
|
226
|
+
document.body.appendChild(input);
|
|
227
|
+
input.click();
|
|
228
|
+
});
|
|
229
|
+
var createFilesClient = (host) => ({
|
|
230
|
+
pick: pickFiles,
|
|
231
|
+
upload: (input) => host.call("files.upload", input),
|
|
232
|
+
list: async (input) => {
|
|
233
|
+
const response = await host.call("files.list", input ?? {});
|
|
234
|
+
return response.files ?? [];
|
|
235
|
+
},
|
|
236
|
+
delete: (id) => host.call("files.delete", { id })
|
|
237
|
+
});
|
|
238
|
+
var readTranslationProps = (props) => {
|
|
239
|
+
const translations = typeof props === "object" && props !== null && "translations" in props ? props.translations : undefined;
|
|
240
|
+
if (typeof translations !== "object" || translations === null)
|
|
241
|
+
return null;
|
|
242
|
+
return translations;
|
|
243
|
+
};
|
|
244
|
+
var interpolate = (value, args) => Object.entries(args ?? {}).reduce((next, [key, replacement]) => next.replaceAll(`{{${key}}}`, String(replacement)), value);
|
|
245
|
+
var createTranslationApi = (propsStore) => {
|
|
246
|
+
const locale = () => readTranslationProps(propsStore.get())?.locale ?? "en";
|
|
247
|
+
const t = (key, defaultValue, args) => {
|
|
248
|
+
const translations = readTranslationProps(propsStore.get());
|
|
249
|
+
const value = translations?.bundle?.[key] ?? translations?.defaultBundle?.[key] ?? defaultValue ?? key;
|
|
250
|
+
return interpolate(value, args);
|
|
251
|
+
};
|
|
252
|
+
return { locale, t };
|
|
253
|
+
};
|
|
254
|
+
var defineExtensionView = (definition) => ({
|
|
255
|
+
mount: async (mount, host, propsStore) => {
|
|
256
|
+
const translations = createTranslationApi(propsStore);
|
|
257
|
+
const cleanup = await definition.render({
|
|
258
|
+
mount,
|
|
259
|
+
host,
|
|
260
|
+
files: createFilesClient(host),
|
|
261
|
+
propsStore,
|
|
262
|
+
get locale() {
|
|
263
|
+
return translations.locale();
|
|
264
|
+
},
|
|
265
|
+
t: translations.t
|
|
266
|
+
});
|
|
267
|
+
return typeof cleanup === "function" ? cleanup : () => {};
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
// src/extensions/params.ts
|
|
271
|
+
var params = {
|
|
272
|
+
text: (options) => ({ type: "text", ...options }),
|
|
273
|
+
longText: (options) => ({ type: "longtext", ...options }),
|
|
274
|
+
number: (options) => ({ type: "number", ...options }),
|
|
275
|
+
boolean: (options) => ({ type: "boolean", ...options }),
|
|
276
|
+
select: (options) => ({ type: "select", ...options }),
|
|
277
|
+
multiSelect: (options) => ({
|
|
278
|
+
type: "multi-select",
|
|
279
|
+
...options
|
|
280
|
+
}),
|
|
281
|
+
repo: (options) => ({ type: "repo", ...options }),
|
|
282
|
+
harness: (options) => ({ type: "harness", ...options }),
|
|
283
|
+
template: (options) => ({
|
|
284
|
+
label: options.label,
|
|
285
|
+
description: options.description,
|
|
286
|
+
required: options.required,
|
|
287
|
+
defaultValue: options.defaultValue,
|
|
288
|
+
metadata: options.metadata,
|
|
289
|
+
type: "template",
|
|
290
|
+
templateType: options.type
|
|
291
|
+
}),
|
|
292
|
+
resource: (options) => ({ type: "resource", ...options }),
|
|
293
|
+
json: (options) => ({ type: "json", ...options }),
|
|
294
|
+
list: (options) => ({ type: "list", ...options })
|
|
295
|
+
};
|
|
296
|
+
// src/extensions/refs.ts
|
|
297
|
+
var commandEvent = (command, phase) => ({
|
|
298
|
+
id: `command.${phase}:${command.id}`
|
|
299
|
+
});
|
|
300
|
+
var commandsOf = (packageName, extension) => {
|
|
301
|
+
const refs = {};
|
|
302
|
+
const commands = extension.commands ?? {};
|
|
303
|
+
for (const key of Object.keys(commands)) {
|
|
304
|
+
refs[key] = { id: `${packageName}.${key}` };
|
|
305
|
+
}
|
|
306
|
+
return refs;
|
|
307
|
+
};
|
|
308
|
+
// src/extensions/when.ts
|
|
309
|
+
var matchesResourceWhen = (when, resourceType) => {
|
|
310
|
+
const resourceTypes = when?.resourceType;
|
|
311
|
+
if (!resourceTypes?.length)
|
|
312
|
+
return true;
|
|
313
|
+
return resourceType ? resourceTypes.includes(resourceType) : false;
|
|
314
|
+
};
|
|
299
315
|
export {
|
|
300
316
|
worktreeEvents,
|
|
301
317
|
workspaceSlots,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BooleanParam, HarnessParam, JsonParam, ListParam, 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;
|
|
@@ -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 {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WhenExpression } from "
|
|
1
|
+
import type { WhenExpression } from "pstdio-api-contracts/extension-kernel";
|
|
2
2
|
/**
|
|
3
3
|
* Resource-scoped visibility for command-palette contributions. Both the workbench host and the
|
|
4
4
|
* dashboard palette gate the same way, so the rule lives here once instead of being re-derived per
|
package/dist/prompts/index.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __returnValue = (v) => v;
|
|
3
|
+
function __exportSetter(name, newValue) {
|
|
4
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
5
|
+
}
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
set: __exportSetter.bind(all, name)
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
1
16
|
// src/prompts/render-prompt.ts
|
|
2
17
|
import Mustache from "mustache";
|
|
3
18
|
var renderPrompt = (template, data) => Mustache.render(template, data);
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export type { AgentAvailabilityType,
|
|
1
|
+
export type { AgentAvailabilityType, AgentInfo, AgentModel, AgentSkillsLayout } from "pstdio-api-contracts";
|
|
2
|
+
export { harnessLocalId } from "pstdio-api-contracts";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export type { Repo } from "pstdio-api-contracts";
|
|
2
|
-
export type { AgentAvailabilityType,
|
|
2
|
+
export type { AgentAvailabilityType, AgentInfo, AgentModel, AgentSkillsLayout } from "./agent";
|
|
3
|
+
export { harnessLocalId } from "./agent";
|
|
3
4
|
export type { FileRecord } from "./file";
|
|
4
|
-
export type { KnownAgent, KnownAgentId } from "./known-agents";
|
|
5
|
-
export { findAgent, isKnownAgentId, KNOWN_AGENT_IDS, KNOWN_AGENTS } from "./known-agents";
|
|
6
5
|
export type { Project } from "./project";
|
|
7
6
|
export type { Session, SessionStatus } from "./session";
|
|
8
7
|
export type { Settings } from "./settings";
|