@pragma-sh/plugin 0.1.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 +27 -0
- package/dist/catalog.cjs +77 -0
- package/dist/catalog.d.cts +363 -0
- package/dist/catalog.d.ts +363 -0
- package/dist/catalog.js +15 -0
- package/dist/icons.cjs +57 -0
- package/dist/icons.d.cts +13 -0
- package/dist/icons.d.ts +13 -0
- package/dist/icons.js +10 -0
- package/dist/index.cjs +217 -0
- package/dist/index.d.cts +533 -0
- package/dist/index.d.ts +533 -0
- package/dist/index.js +151 -0
- package/dist/jsx-runtime.cjs +61 -0
- package/dist/jsx-runtime.d.cts +5 -0
- package/dist/jsx-runtime.d.ts +5 -0
- package/dist/jsx-runtime.js +14 -0
- package/dist/react-dom.cjs +73 -0
- package/dist/react-dom.d.cts +12 -0
- package/dist/react-dom.d.ts +12 -0
- package/dist/react-dom.js +26 -0
- package/dist/react.cjs +127 -0
- package/dist/react.d.cts +39 -0
- package/dist/react.d.ts +39 -0
- package/dist/react.js +80 -0
- package/dist/shared/chunk-2jf7fbtp.js +10 -0
- package/dist/shared/chunk-qjw1esw6.js +4 -0
- package/dist/shared/chunk-yjtz35sp.js +33 -0
- package/dist/ui.cjs +61 -0
- package/dist/ui.d.cts +21 -0
- package/dist/ui.d.ts +21 -0
- package/dist/ui.js +14 -0
- package/dist/version.cjs +47 -0
- package/dist/version.d.cts +7 -0
- package/dist/version.d.ts +7 -0
- package/dist/version.js +6 -0
- package/package.json +96 -0
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @pragma-sh/plugin
|
|
2
|
+
|
|
3
|
+
Build a Pragma plugin in TypeScript. Part of [Pragma](https://github.com/pragma-sh/pragma) — a desktop workspace for
|
|
4
|
+
running persistent, worktree-scoped coding agents.
|
|
5
|
+
|
|
6
|
+
Sidebar tabs, cards, commands, themes, web views and launchable agents, plus the
|
|
7
|
+
React runtime the host provides. Scaffold a project with
|
|
8
|
+
[`create-pragma-plugin`](https://www.npmjs.com/package/create-pragma-plugin)
|
|
9
|
+
rather than wiring this up by hand.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
bun create pragma-plugin my-plugin
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { definePlugin, defineSidebarTab } from "@pragma-sh/plugin";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
React, React DOM and the JSX runtime are re-exported under
|
|
20
|
+
`@pragma-sh/plugin/react`, `/react-dom` and `/jsx-runtime` — alias them in your
|
|
21
|
+
bundler so your plugin shares the host's single React instance.
|
|
22
|
+
|
|
23
|
+
Docs: <https://pragma-app.sh/docs/plugins/getting-started>
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
|
|
27
|
+
AGPL-3.0-only. See [LICENSE](https://github.com/pragma-sh/pragma/blob/main/LICENSE).
|
package/dist/catalog.cjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/catalog.ts
|
|
40
|
+
var exports_catalog = {};
|
|
41
|
+
__export(exports_catalog, {
|
|
42
|
+
runProviderCommand: () => runProviderCommand,
|
|
43
|
+
defineUsageLimitProvider: () => defineUsageLimitProvider,
|
|
44
|
+
definePlugin: () => definePlugin,
|
|
45
|
+
defineAgent: () => defineAgent,
|
|
46
|
+
CLI_MISSING_STATUS: () => CLI_MISSING_STATUS
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(exports_catalog);
|
|
49
|
+
|
|
50
|
+
// src/agent.ts
|
|
51
|
+
function defineAgent(input) {
|
|
52
|
+
return input;
|
|
53
|
+
}
|
|
54
|
+
// src/generated/version.ts
|
|
55
|
+
var PLUGIN_API_VERSION = "0.1.0";
|
|
56
|
+
|
|
57
|
+
// src/plugin.ts
|
|
58
|
+
function definePlugin(input) {
|
|
59
|
+
return { ...input, __apiVersion: PLUGIN_API_VERSION };
|
|
60
|
+
}
|
|
61
|
+
// src/usage-limits.ts
|
|
62
|
+
var CLI_MISSING_STATUS = 20;
|
|
63
|
+
async function runProviderCommand(ctx, command, missingStatus = CLI_MISSING_STATUS) {
|
|
64
|
+
const [result] = await ctx.sdk.exec.run({
|
|
65
|
+
cwd: ctx.project?.path ?? "/tmp",
|
|
66
|
+
commands: [command]
|
|
67
|
+
});
|
|
68
|
+
if (result?.status === missingStatus)
|
|
69
|
+
return { kind: "missing" };
|
|
70
|
+
if (!result || result.status !== 0) {
|
|
71
|
+
return { kind: "failed", stderr: result?.stderr.trim() ?? "" };
|
|
72
|
+
}
|
|
73
|
+
return { kind: "ok", stdout: result.stdout };
|
|
74
|
+
}
|
|
75
|
+
function defineUsageLimitProvider(input) {
|
|
76
|
+
return input;
|
|
77
|
+
}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { AgentFeature as SharedAgentFeature } from "@pragma-sh/constants";
|
|
2
|
+
import { ComponentType, ReactNode } from "react";
|
|
3
|
+
import { PragmaClient } from "@pragma-sh/sdk";
|
|
4
|
+
/** Imperative durable JSON storage bound by the host to one plugin. */
|
|
5
|
+
interface PluginStorage {
|
|
6
|
+
get<T>(key: string, initialValue: T): Promise<T>;
|
|
7
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
8
|
+
delete(key: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/** The active project a plugin is rendered against, or `null` when none is selected. */
|
|
11
|
+
interface PluginProject {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
path: string;
|
|
15
|
+
}
|
|
16
|
+
/** Options for {@link PluginContext.notify} / `useNotify()`. */
|
|
17
|
+
interface PluginNotifyOptions {
|
|
18
|
+
variant?: "info" | "success" | "warning" | "error";
|
|
19
|
+
description?: string;
|
|
20
|
+
/** Also send a native OS notification through Pragma's notification bridge. */
|
|
21
|
+
native?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Context passed to every plugin callback: contribution `when` guards, command
|
|
25
|
+
* `run` handlers, agent event handlers, and `activate`.
|
|
26
|
+
*/
|
|
27
|
+
interface PluginContext<TConfig = unknown> {
|
|
28
|
+
/** This plugin's stable id, derived from its `package.json` name. */
|
|
29
|
+
pluginId: string;
|
|
30
|
+
/** Absolute plugin package directory when available in this runtime. */
|
|
31
|
+
pluginDir?: string;
|
|
32
|
+
/** This plugin's user-supplied config, already validated against its `config` schema. */
|
|
33
|
+
config: TConfig;
|
|
34
|
+
/** The active project, or `null` when no project is selected. */
|
|
35
|
+
project: PluginProject | null;
|
|
36
|
+
/** Typed SDK client for talking to the local Pragma gateway. */
|
|
37
|
+
sdk: PragmaClient;
|
|
38
|
+
/** Shows an in-app notification. */
|
|
39
|
+
notify: (message: string, options?: PluginNotifyOptions) => void;
|
|
40
|
+
/** Durable storage scoped to this plugin. Available in desktop-hosted callbacks. */
|
|
41
|
+
storage?: PluginStorage;
|
|
42
|
+
}
|
|
43
|
+
/** Payload emitted for `pragma://plugin/<pluginId>/<path>` deep links. */
|
|
44
|
+
interface PluginDeepLinkEvent {
|
|
45
|
+
pluginId: string;
|
|
46
|
+
path: string;
|
|
47
|
+
url: string;
|
|
48
|
+
params: Record<string, string[]>;
|
|
49
|
+
}
|
|
50
|
+
/** An icon contributed alongside a sidebar tab, command, or agent. */
|
|
51
|
+
type PluginIcon = ComponentType<{
|
|
52
|
+
className?: string;
|
|
53
|
+
}>;
|
|
54
|
+
/** Values passed directly to every host-rendered plugin component. */
|
|
55
|
+
interface PluginComponentProps<TWebViewPayload = unknown> {
|
|
56
|
+
/** Payload supplied when this component renders as a plugin web view. */
|
|
57
|
+
webViewPayload?: TWebViewPayload;
|
|
58
|
+
}
|
|
59
|
+
/** A host-rendered plugin component. Hooks remain available for reactive host state. */
|
|
60
|
+
type PluginComponent<TWebViewPayload = unknown> = {
|
|
61
|
+
bivarianceHack(props: PluginComponentProps<TWebViewPayload>): ReactNode;
|
|
62
|
+
}["bivarianceHack"];
|
|
63
|
+
/** A guard evaluated by the host to decide whether a contribution should render. */
|
|
64
|
+
type PluginWhen<TConfig = unknown> = (ctx: PluginContext<TConfig>) => boolean;
|
|
65
|
+
/** A tab contributed to the project sidebar. */
|
|
66
|
+
interface SidebarTabDefinition<TConfig = unknown> {
|
|
67
|
+
id: string;
|
|
68
|
+
title: string;
|
|
69
|
+
icon?: PluginIcon;
|
|
70
|
+
component: PluginComponent;
|
|
71
|
+
when?: PluginWhen<TConfig>;
|
|
72
|
+
}
|
|
73
|
+
/** A page contributed to Pragma Settings. */
|
|
74
|
+
interface SettingsPageDefinition<TConfig = unknown> {
|
|
75
|
+
id: string;
|
|
76
|
+
title: string;
|
|
77
|
+
icon?: PluginIcon;
|
|
78
|
+
component: PluginComponent;
|
|
79
|
+
when?: PluginWhen<TConfig>;
|
|
80
|
+
}
|
|
81
|
+
/** Options used when opening a plugin web view tab. */
|
|
82
|
+
interface OpenWebViewOptions<TPayload = unknown> {
|
|
83
|
+
/** Overrides the tab title; falls back to the web view title, then id. */
|
|
84
|
+
title?: string;
|
|
85
|
+
/** JSON-serializable data made available through `useWebViewPayload`. */
|
|
86
|
+
payload?: TPayload;
|
|
87
|
+
/** Stable key used by the host to focus an existing matching web view tab. */
|
|
88
|
+
dedupeKey?: string;
|
|
89
|
+
}
|
|
90
|
+
/** A plugin-defined React view that renders inside a workspace tab web view. */
|
|
91
|
+
interface WebViewDefinition<TPayload = unknown> {
|
|
92
|
+
id: string;
|
|
93
|
+
title?: string;
|
|
94
|
+
component: PluginComponent<TPayload>;
|
|
95
|
+
/** Opens this web view as a workspace tab. */
|
|
96
|
+
open(options?: OpenWebViewOptions<TPayload>): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
/** An item contributed to the workspace topper bar. */
|
|
99
|
+
interface TopperItemDefinition<TConfig = unknown> {
|
|
100
|
+
align: "left" | "right";
|
|
101
|
+
component: PluginComponent;
|
|
102
|
+
when?: PluginWhen<TConfig>;
|
|
103
|
+
}
|
|
104
|
+
/** A card contributed to the project sidebar. */
|
|
105
|
+
interface SidebarCardDefinition<TConfig = unknown> {
|
|
106
|
+
title: string;
|
|
107
|
+
component: PluginComponent;
|
|
108
|
+
when?: PluginWhen<TConfig>;
|
|
109
|
+
}
|
|
110
|
+
/** A command contributed to the command palette / keybindings surface. */
|
|
111
|
+
interface CommandDefinition<TConfig = unknown> {
|
|
112
|
+
id: string;
|
|
113
|
+
title: string;
|
|
114
|
+
icon?: PluginIcon;
|
|
115
|
+
defaultBinding?: string;
|
|
116
|
+
hidden?: boolean;
|
|
117
|
+
run: (ctx: PluginContext<TConfig>, args?: unknown) => void | Promise<void>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Timed input sent to the agent's terminal after launch and before an
|
|
121
|
+
* optional prompt prefill. Field names mirror the host's existing
|
|
122
|
+
* the old `~/.pragma/agents/<id>/config.json` shape (`startupInput`) exactly, so
|
|
123
|
+
* plugin-contributed agents carry over unchanged.
|
|
124
|
+
*/
|
|
125
|
+
interface AgentStartupInput {
|
|
126
|
+
delayMs: number;
|
|
127
|
+
data: string;
|
|
128
|
+
}
|
|
129
|
+
/** One selectable reasoning-effort level for a model. */
|
|
130
|
+
interface AgentReasoning {
|
|
131
|
+
id: string;
|
|
132
|
+
name: string;
|
|
133
|
+
}
|
|
134
|
+
/** One selectable model for an agent. */
|
|
135
|
+
interface AgentModelEntry {
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
reasoning?: AgentReasoning[];
|
|
139
|
+
}
|
|
140
|
+
/** One selectable permission mode for an agent. */
|
|
141
|
+
interface AgentPermissionMode {
|
|
142
|
+
id: string;
|
|
143
|
+
name: string;
|
|
144
|
+
}
|
|
145
|
+
/** Builds the launch command-line arguments for a selected model/reasoning/permission mode. */
|
|
146
|
+
interface AgentArgsBuilder {
|
|
147
|
+
model: (modelId: string) => string[];
|
|
148
|
+
reasoning: (reasoningId: string) => string[];
|
|
149
|
+
modelReasoning?: (modelId: string, reasoningId: string) => string[];
|
|
150
|
+
permissionMode: (permissionModeId: string) => string[];
|
|
151
|
+
}
|
|
152
|
+
/** Optional agent capabilities that can be excluded from `pragma-cli agent verify`. */
|
|
153
|
+
type AgentFeature = SharedAgentFeature;
|
|
154
|
+
/**
|
|
155
|
+
* Declares an agent a plugin makes launchable from Pragma. Field names below
|
|
156
|
+
* `launch`/`models`/`permissionModes`/`args` are new, JS-only additions;
|
|
157
|
+
* `startupInput`/`prefillDelayMs`/`prefillMode`/`prefillSubmit`/
|
|
158
|
+
* `prefillSubmitDelayMs` carry over the existing agent-launcher config shape
|
|
159
|
+
* exactly (see `src-tauri/src/agents.rs`).
|
|
160
|
+
*/
|
|
161
|
+
interface AgentDefinition<TConfig = unknown> {
|
|
162
|
+
id: string;
|
|
163
|
+
name: string;
|
|
164
|
+
icon: PluginIcon;
|
|
165
|
+
/** Browser URL, absolute filesystem path, or plugin-dir-relative asset path for the agent icon. */
|
|
166
|
+
iconPath?: string;
|
|
167
|
+
launch: {
|
|
168
|
+
command: string[];
|
|
169
|
+
};
|
|
170
|
+
models: AgentModelEntry[] | ((ctx: PluginContext<TConfig>) => Promise<AgentModelEntry[]>);
|
|
171
|
+
permissionModes: AgentPermissionMode[];
|
|
172
|
+
args: AgentArgsBuilder;
|
|
173
|
+
/** Capabilities this agent does not support; matching verification scenarios are skipped. */
|
|
174
|
+
excludeFeatures?: AgentFeature[];
|
|
175
|
+
startupInput?: AgentStartupInput[];
|
|
176
|
+
prefillDelayMs?: number;
|
|
177
|
+
prefillMode?: "bracketed" | "plain";
|
|
178
|
+
prefillSubmit?: string;
|
|
179
|
+
prefillSubmitDelayMs?: number;
|
|
180
|
+
}
|
|
181
|
+
/** Declares an agent contribution. */
|
|
182
|
+
declare function defineAgent<TConfig = unknown>(input: AgentDefinition<TConfig>): AgentDefinition<TConfig>;
|
|
183
|
+
import { AgentReportPayload } from "@pragma-sh/constants";
|
|
184
|
+
import { ZodType, ZodTypeAny } from "zod";
|
|
185
|
+
import { AgentMessage, PragmaClient as PragmaClient2 } from "@pragma-sh/sdk";
|
|
186
|
+
/** Declares a watcher a plugin attaches to one of its agents' sessions. */
|
|
187
|
+
interface WatcherDefinition<TConfig = unknown> {
|
|
188
|
+
/** The `defineAgent` id this watcher attaches to. */
|
|
189
|
+
agent: string;
|
|
190
|
+
/** Runs once per launched session; lives until the session exits. */
|
|
191
|
+
watch: (ctx: WatcherContext<TConfig>) => void | Promise<void>;
|
|
192
|
+
}
|
|
193
|
+
/** Host-side context passed to a running watcher instance. */
|
|
194
|
+
interface WatcherContext<TConfig = unknown> {
|
|
195
|
+
/** Typed gateway SDK. */
|
|
196
|
+
sdk: PragmaClient2;
|
|
197
|
+
/** Full agent id this watcher instance is bound to (plugin-qualified). */
|
|
198
|
+
agentId: string;
|
|
199
|
+
/** This plugin's validated config. */
|
|
200
|
+
config: TConfig;
|
|
201
|
+
/** Session this watcher is attached to. */
|
|
202
|
+
session: {
|
|
203
|
+
id: string;
|
|
204
|
+
tabId: string;
|
|
205
|
+
worktreeId: string;
|
|
206
|
+
};
|
|
207
|
+
/** Decoded terminal output chunks for this session. */
|
|
208
|
+
output: AsyncIterable<string>;
|
|
209
|
+
/** Writes bytes into the live terminal session. */
|
|
210
|
+
sendKeys: (data: string) => Promise<void>;
|
|
211
|
+
/** Reports a rich message for this watcher-owned agent. */
|
|
212
|
+
reportMessage: (msg: Omit<AgentMessage, "agent" | "tabId" | "worktreeId">) => Promise<void>;
|
|
213
|
+
/** Aborts when the session exits or the watcher is stopped. */
|
|
214
|
+
signal: AbortSignal;
|
|
215
|
+
}
|
|
216
|
+
/** One finite or unlimited usage category reported by a provider. */
|
|
217
|
+
interface UsageLimit {
|
|
218
|
+
id: string;
|
|
219
|
+
title: string;
|
|
220
|
+
used: number;
|
|
221
|
+
/** A null limit represents unlimited usage. */
|
|
222
|
+
limit: number | null;
|
|
223
|
+
/** Milliseconds until this category resets, measured from `observedAt`. */
|
|
224
|
+
resetsInMs?: number;
|
|
225
|
+
}
|
|
226
|
+
/** A successful provider snapshot. */
|
|
227
|
+
interface UsageLimitsReady {
|
|
228
|
+
status: "ready";
|
|
229
|
+
/** Unix time in milliseconds when the provider observed these values. */
|
|
230
|
+
observedAt: number;
|
|
231
|
+
/** Optional collapsed-row metric derived separately from the detailed limits. */
|
|
232
|
+
summary?: UsageLimit;
|
|
233
|
+
limits: UsageLimit[];
|
|
234
|
+
}
|
|
235
|
+
/** Why a provider cannot currently report usage limits. */
|
|
236
|
+
type UsageLimitsUnavailableReason = "not-configured" | "authentication-required" | "unsupported" | "error";
|
|
237
|
+
/** A provider state that requires user or platform action before loading. */
|
|
238
|
+
interface UsageLimitsUnavailable {
|
|
239
|
+
status: "unavailable";
|
|
240
|
+
reason: UsageLimitsUnavailableReason;
|
|
241
|
+
message: string;
|
|
242
|
+
}
|
|
243
|
+
/** Result returned by a usage-limit provider. Unexpected failures should throw. */
|
|
244
|
+
type UsageLimitsResult = UsageLimitsReady | UsageLimitsUnavailable;
|
|
245
|
+
/**
|
|
246
|
+
* Exit status a provider's shell wrapper uses to report that the agent CLI is
|
|
247
|
+
* not on PATH, distinguishing "not installed" from a genuine command failure.
|
|
248
|
+
*/
|
|
249
|
+
declare const CLI_MISSING_STATUS = 20;
|
|
250
|
+
/** Outcome of one provider CLI invocation. */
|
|
251
|
+
type ProviderCommandOutcome = {
|
|
252
|
+
kind: "missing";
|
|
253
|
+
} | {
|
|
254
|
+
kind: "failed";
|
|
255
|
+
stderr: string;
|
|
256
|
+
} | {
|
|
257
|
+
kind: "ok";
|
|
258
|
+
stdout: string;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Runs a single provider command in the active project and classifies its exit
|
|
262
|
+
* status. Callers map `missing`/`failed` onto their own messages, since the
|
|
263
|
+
* wording and the reasons worth special-casing differ per agent.
|
|
264
|
+
*/
|
|
265
|
+
declare function runProviderCommand<TConfig>(ctx: PluginContext<TConfig>, command: string, missingStatus?: number): Promise<ProviderCommandOutcome>;
|
|
266
|
+
/** A plugin-owned usage source rendered by Pragma's shared usage-limits UI. */
|
|
267
|
+
interface UsageLimitProviderDefinition<TConfig = unknown> {
|
|
268
|
+
id: string;
|
|
269
|
+
title: string;
|
|
270
|
+
/** Absolute URL for viewing this provider's usage in its dashboard. */
|
|
271
|
+
dashboardUrl: string;
|
|
272
|
+
icon?: PluginIcon;
|
|
273
|
+
/** Browser URL, absolute path, or plugin-directory-relative asset path. */
|
|
274
|
+
iconPath?: string;
|
|
275
|
+
/** Category rendered in the provider's collapsed summary row. */
|
|
276
|
+
primaryLimitId: string;
|
|
277
|
+
/** Requested refresh cadence. The host may enforce a larger minimum. */
|
|
278
|
+
refreshIntervalMs?: number;
|
|
279
|
+
load: (ctx: PluginContext<TConfig>) => Promise<UsageLimitsResult>;
|
|
280
|
+
}
|
|
281
|
+
/** Declares a provider for Pragma's shared usage-limits UI. */
|
|
282
|
+
declare function defineUsageLimitProvider<TConfig = unknown>(input: UsageLimitProviderDefinition<TConfig>): UsageLimitProviderDefinition<TConfig>;
|
|
283
|
+
/** Color schemes supported by Pragma themes. */
|
|
284
|
+
type ThemeMode = "light" | "dark";
|
|
285
|
+
/** Theme token overrides for one color scheme, keyed without the `--` prefix. */
|
|
286
|
+
type ThemeColors = Record<ThemeMode, Record<string, string>>;
|
|
287
|
+
/** A selectable theme contributed to Pragma's Theme settings. */
|
|
288
|
+
interface ThemeDefinition {
|
|
289
|
+
/** Stable id within this plugin. */
|
|
290
|
+
id: string;
|
|
291
|
+
/** Human-readable name shown in Theme settings. */
|
|
292
|
+
name: string;
|
|
293
|
+
/** Optional detail shown under the theme name. */
|
|
294
|
+
description?: string;
|
|
295
|
+
/** Light and dark Pragma theme-token overrides. */
|
|
296
|
+
colors: ThemeColors;
|
|
297
|
+
}
|
|
298
|
+
/** Infers a config schema's parsed output type, defaulting to `unknown` when no schema is given. */
|
|
299
|
+
type InferConfig<TConfigSchema extends ZodTypeAny> = TConfigSchema extends ZodType<infer Output> ? Output : unknown;
|
|
300
|
+
/** UI surfaces a plugin can contribute to. */
|
|
301
|
+
interface PluginUiContributions<TConfig = unknown> {
|
|
302
|
+
sidebarTabs?: SidebarTabDefinition<TConfig>[];
|
|
303
|
+
settingsPages?: SettingsPageDefinition<TConfig>[];
|
|
304
|
+
topper?: TopperItemDefinition<TConfig>[];
|
|
305
|
+
sidebarCards?: SidebarCardDefinition<TConfig>[];
|
|
306
|
+
webViews?: WebViewDefinition[];
|
|
307
|
+
}
|
|
308
|
+
/** Whether a plugin's declared values are merged with or replace host defaults. */
|
|
309
|
+
type PluginContributionStrategy = "merge" | "replace";
|
|
310
|
+
/** Default settings values a plugin contributes. */
|
|
311
|
+
interface PluginSettingsContributions {
|
|
312
|
+
strategy?: PluginContributionStrategy;
|
|
313
|
+
values: Record<string, unknown>;
|
|
314
|
+
}
|
|
315
|
+
/** Default keybindings a plugin contributes. */
|
|
316
|
+
interface PluginKeybindingsContributions {
|
|
317
|
+
strategy?: PluginContributionStrategy;
|
|
318
|
+
bindings: Record<string, string>;
|
|
319
|
+
}
|
|
320
|
+
/** Daemon-forwarded events a plugin can subscribe to declaratively. */
|
|
321
|
+
interface PluginEventHandlers<TConfig = unknown> {
|
|
322
|
+
"agent.report"?: (event: AgentReportPayload, ctx: PluginContext<TConfig>) => void;
|
|
323
|
+
deepLink?: (event: PluginDeepLinkEvent, ctx: PluginContext<TConfig>) => void;
|
|
324
|
+
}
|
|
325
|
+
/** The object shape passed to `definePlugin`. */
|
|
326
|
+
interface PluginDefinitionInput<TConfigSchema extends ZodTypeAny = ZodTypeAny> {
|
|
327
|
+
name: string;
|
|
328
|
+
description?: string;
|
|
329
|
+
icon?: PluginIcon;
|
|
330
|
+
config?: TConfigSchema;
|
|
331
|
+
ui?: PluginUiContributions<InferConfig<TConfigSchema>>;
|
|
332
|
+
agents?: AgentDefinition<InferConfig<TConfigSchema>>[];
|
|
333
|
+
watchers?: WatcherDefinition<InferConfig<TConfigSchema>>[];
|
|
334
|
+
commands?: CommandDefinition<InferConfig<TConfigSchema>>[];
|
|
335
|
+
settings?: PluginSettingsContributions;
|
|
336
|
+
keybindings?: PluginKeybindingsContributions;
|
|
337
|
+
events?: PluginEventHandlers<InferConfig<TConfigSchema>>;
|
|
338
|
+
usageLimits?: UsageLimitProviderDefinition<InferConfig<TConfigSchema>>[];
|
|
339
|
+
themes?: ThemeDefinition[];
|
|
340
|
+
css?: string;
|
|
341
|
+
/** Runs once when Pragma first discovers this plugin installation. */
|
|
342
|
+
onInstall?: (ctx: PluginContext<InferConfig<TConfigSchema>>) => void | Promise<void>;
|
|
343
|
+
/** Runs once during every Pragma server boot. */
|
|
344
|
+
onPragmaLoad?: (ctx: PluginContext<InferConfig<TConfigSchema>>) => void | Promise<void>;
|
|
345
|
+
activate?: (ctx: PluginContext<InferConfig<TConfigSchema>>) => void | (() => void);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* A fully-declared plugin, as returned by `definePlugin`. `__apiVersion` is
|
|
349
|
+
* stamped automatically — plugin authors never set it themselves, and it
|
|
350
|
+
* lives under a deliberately internal-looking name so it doesn't show up as
|
|
351
|
+
* something to configure.
|
|
352
|
+
*/
|
|
353
|
+
interface PluginDefinition<TConfigSchema extends ZodTypeAny = ZodTypeAny> extends PluginDefinitionInput<TConfigSchema> {
|
|
354
|
+
/** @internal The `@pragma-sh/plugin` version this plugin was compiled against. */
|
|
355
|
+
readonly __apiVersion: string;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Declares a Pragma plugin. This is the single entry point a plugin's bundle
|
|
359
|
+
* must default-export. Stamps the compiled-against `@pragma-sh/plugin` version
|
|
360
|
+
* onto the result so the host can check compatibility before loading it.
|
|
361
|
+
*/
|
|
362
|
+
declare function definePlugin<TConfigSchema extends ZodTypeAny = ZodTypeAny>(input: PluginDefinitionInput<TConfigSchema>): PluginDefinition<TConfigSchema>;
|
|
363
|
+
export { runProviderCommand, defineUsageLimitProvider, definePlugin, defineAgent, UsageLimitsResult, UsageLimitProviderDefinition, UsageLimit, ProviderCommandOutcome, PluginDefinition, PluginContext, CLI_MISSING_STATUS, AgentModelEntry, AgentFeature, AgentDefinition };
|