@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/dist/index.d.cts
ADDED
|
@@ -0,0 +1,533 @@
|
|
|
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
|
+
/** Result shape shared by every `useSdkQuery`-style hook. */
|
|
44
|
+
interface PluginQueryResult<T> {
|
|
45
|
+
data: T | undefined;
|
|
46
|
+
error: string | null;
|
|
47
|
+
loading: boolean;
|
|
48
|
+
refetch: () => void;
|
|
49
|
+
}
|
|
50
|
+
/** One agent's live status, as surfaced by `useAgentStatuses`. */
|
|
51
|
+
interface PluginAgentStatusEntry {
|
|
52
|
+
agent: string;
|
|
53
|
+
status: "running" | "attention" | "done";
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Minimal live terminal-session summary surfaced by `useSessions` and
|
|
57
|
+
* `listSessions`. This is intentionally small until the SDK exposes a
|
|
58
|
+
* dedicated session-list RPC.
|
|
59
|
+
*/
|
|
60
|
+
interface PluginSessionSummary {
|
|
61
|
+
id: string;
|
|
62
|
+
cwd: string;
|
|
63
|
+
}
|
|
64
|
+
/** Payload emitted for `pragma://plugin/<pluginId>/<path>` deep links. */
|
|
65
|
+
interface PluginDeepLinkEvent {
|
|
66
|
+
pluginId: string;
|
|
67
|
+
path: string;
|
|
68
|
+
url: string;
|
|
69
|
+
params: Record<string, string[]>;
|
|
70
|
+
}
|
|
71
|
+
/** An icon contributed alongside a sidebar tab, command, or agent. */
|
|
72
|
+
type PluginIcon = ComponentType<{
|
|
73
|
+
className?: string;
|
|
74
|
+
}>;
|
|
75
|
+
/** Values passed directly to every host-rendered plugin component. */
|
|
76
|
+
interface PluginComponentProps<TWebViewPayload = unknown> {
|
|
77
|
+
/** Payload supplied when this component renders as a plugin web view. */
|
|
78
|
+
webViewPayload?: TWebViewPayload;
|
|
79
|
+
}
|
|
80
|
+
/** A host-rendered plugin component. Hooks remain available for reactive host state. */
|
|
81
|
+
type PluginComponent<TWebViewPayload = unknown> = {
|
|
82
|
+
bivarianceHack(props: PluginComponentProps<TWebViewPayload>): ReactNode;
|
|
83
|
+
}["bivarianceHack"];
|
|
84
|
+
/** A guard evaluated by the host to decide whether a contribution should render. */
|
|
85
|
+
type PluginWhen<TConfig = unknown> = (ctx: PluginContext<TConfig>) => boolean;
|
|
86
|
+
/** A tab contributed to the project sidebar. */
|
|
87
|
+
interface SidebarTabDefinition<TConfig = unknown> {
|
|
88
|
+
id: string;
|
|
89
|
+
title: string;
|
|
90
|
+
icon?: PluginIcon;
|
|
91
|
+
component: PluginComponent;
|
|
92
|
+
when?: PluginWhen<TConfig>;
|
|
93
|
+
}
|
|
94
|
+
/** Declares a sidebar tab contribution. */
|
|
95
|
+
declare function defineSidebarTab<TConfig = unknown>(input: SidebarTabDefinition<TConfig>): SidebarTabDefinition<TConfig>;
|
|
96
|
+
/** A page contributed to Pragma Settings. */
|
|
97
|
+
interface SettingsPageDefinition<TConfig = unknown> {
|
|
98
|
+
id: string;
|
|
99
|
+
title: string;
|
|
100
|
+
icon?: PluginIcon;
|
|
101
|
+
component: PluginComponent;
|
|
102
|
+
when?: PluginWhen<TConfig>;
|
|
103
|
+
}
|
|
104
|
+
/** Declares a React page contribution for Pragma Settings. */
|
|
105
|
+
declare function defineSettingsPage<TConfig = unknown>(input: SettingsPageDefinition<TConfig>): SettingsPageDefinition<TConfig>;
|
|
106
|
+
/** Options used when opening a plugin web view tab. */
|
|
107
|
+
interface OpenWebViewOptions<TPayload = unknown> {
|
|
108
|
+
/** Overrides the tab title; falls back to the web view title, then id. */
|
|
109
|
+
title?: string;
|
|
110
|
+
/** JSON-serializable data made available through `useWebViewPayload`. */
|
|
111
|
+
payload?: TPayload;
|
|
112
|
+
/** Stable key used by the host to focus an existing matching web view tab. */
|
|
113
|
+
dedupeKey?: string;
|
|
114
|
+
}
|
|
115
|
+
/** A plugin-defined React view that renders inside a workspace tab web view. */
|
|
116
|
+
interface WebViewDefinition<TPayload = unknown> {
|
|
117
|
+
id: string;
|
|
118
|
+
title?: string;
|
|
119
|
+
component: PluginComponent<TPayload>;
|
|
120
|
+
/** Opens this web view as a workspace tab. */
|
|
121
|
+
open(options?: OpenWebViewOptions<TPayload>): Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
/** Input accepted by `defineWebView`; the returned definition adds `.open()`. */
|
|
124
|
+
type WebViewDefinitionInput<TPayload = unknown> = Omit<WebViewDefinition<TPayload>, "open">;
|
|
125
|
+
/** Reference accepted by `openWebView`: a web view handle or a unique web view id. */
|
|
126
|
+
type WebViewReference<TPayload = unknown> = WebViewDefinition<TPayload> | string;
|
|
127
|
+
/** Opens a plugin web view tab by handle, or by id when the id is unambiguous. */
|
|
128
|
+
declare function openWebView2<TPayload = unknown>(webView: WebViewReference<TPayload>, options?: OpenWebViewOptions<TPayload>): Promise<void>;
|
|
129
|
+
/** Declares a plugin web view contribution. */
|
|
130
|
+
declare function defineWebView<TPayload = unknown>(input: WebViewDefinitionInput<TPayload>): WebViewDefinition<TPayload>;
|
|
131
|
+
/** An item contributed to the workspace topper bar. */
|
|
132
|
+
interface TopperItemDefinition<TConfig = unknown> {
|
|
133
|
+
align: "left" | "right";
|
|
134
|
+
component: PluginComponent;
|
|
135
|
+
when?: PluginWhen<TConfig>;
|
|
136
|
+
}
|
|
137
|
+
/** Declares a topper-bar item contribution. */
|
|
138
|
+
declare function defineTopperItem<TConfig = unknown>(input: TopperItemDefinition<TConfig>): TopperItemDefinition<TConfig>;
|
|
139
|
+
/** A card contributed to the project sidebar. */
|
|
140
|
+
interface SidebarCardDefinition<TConfig = unknown> {
|
|
141
|
+
title: string;
|
|
142
|
+
component: PluginComponent;
|
|
143
|
+
when?: PluginWhen<TConfig>;
|
|
144
|
+
}
|
|
145
|
+
/** Declares a sidebar card contribution. */
|
|
146
|
+
declare function defineSidebarCard<TConfig = unknown>(input: SidebarCardDefinition<TConfig>): SidebarCardDefinition<TConfig>;
|
|
147
|
+
/** A command contributed to the command palette / keybindings surface. */
|
|
148
|
+
interface CommandDefinition<TConfig = unknown> {
|
|
149
|
+
id: string;
|
|
150
|
+
title: string;
|
|
151
|
+
icon?: PluginIcon;
|
|
152
|
+
defaultBinding?: string;
|
|
153
|
+
hidden?: boolean;
|
|
154
|
+
run: (ctx: PluginContext<TConfig>, args?: unknown) => void | Promise<void>;
|
|
155
|
+
}
|
|
156
|
+
/** Declares a command contribution. */
|
|
157
|
+
declare function defineCommand<TConfig = unknown>(input: CommandDefinition<TConfig>): CommandDefinition<TConfig>;
|
|
158
|
+
/**
|
|
159
|
+
* Timed input sent to the agent's terminal after launch and before an
|
|
160
|
+
* optional prompt prefill. Field names mirror the host's existing
|
|
161
|
+
* the old `~/.pragma/agents/<id>/config.json` shape (`startupInput`) exactly, so
|
|
162
|
+
* plugin-contributed agents carry over unchanged.
|
|
163
|
+
*/
|
|
164
|
+
interface AgentStartupInput {
|
|
165
|
+
delayMs: number;
|
|
166
|
+
data: string;
|
|
167
|
+
}
|
|
168
|
+
/** One selectable reasoning-effort level for a model. */
|
|
169
|
+
interface AgentReasoning {
|
|
170
|
+
id: string;
|
|
171
|
+
name: string;
|
|
172
|
+
}
|
|
173
|
+
/** One selectable model for an agent. */
|
|
174
|
+
interface AgentModelEntry {
|
|
175
|
+
id: string;
|
|
176
|
+
name: string;
|
|
177
|
+
reasoning?: AgentReasoning[];
|
|
178
|
+
}
|
|
179
|
+
/** One selectable permission mode for an agent. */
|
|
180
|
+
interface AgentPermissionMode {
|
|
181
|
+
id: string;
|
|
182
|
+
name: string;
|
|
183
|
+
}
|
|
184
|
+
/** Builds the launch command-line arguments for a selected model/reasoning/permission mode. */
|
|
185
|
+
interface AgentArgsBuilder {
|
|
186
|
+
model: (modelId: string) => string[];
|
|
187
|
+
reasoning: (reasoningId: string) => string[];
|
|
188
|
+
modelReasoning?: (modelId: string, reasoningId: string) => string[];
|
|
189
|
+
permissionMode: (permissionModeId: string) => string[];
|
|
190
|
+
}
|
|
191
|
+
/** Optional agent capabilities that can be excluded from `pragma-cli agent verify`. */
|
|
192
|
+
type AgentFeature = SharedAgentFeature;
|
|
193
|
+
/**
|
|
194
|
+
* Declares an agent a plugin makes launchable from Pragma. Field names below
|
|
195
|
+
* `launch`/`models`/`permissionModes`/`args` are new, JS-only additions;
|
|
196
|
+
* `startupInput`/`prefillDelayMs`/`prefillMode`/`prefillSubmit`/
|
|
197
|
+
* `prefillSubmitDelayMs` carry over the existing agent-launcher config shape
|
|
198
|
+
* exactly (see `src-tauri/src/agents.rs`).
|
|
199
|
+
*/
|
|
200
|
+
interface AgentDefinition<TConfig = unknown> {
|
|
201
|
+
id: string;
|
|
202
|
+
name: string;
|
|
203
|
+
icon: PluginIcon;
|
|
204
|
+
/** Browser URL, absolute filesystem path, or plugin-dir-relative asset path for the agent icon. */
|
|
205
|
+
iconPath?: string;
|
|
206
|
+
launch: {
|
|
207
|
+
command: string[];
|
|
208
|
+
};
|
|
209
|
+
models: AgentModelEntry[] | ((ctx: PluginContext<TConfig>) => Promise<AgentModelEntry[]>);
|
|
210
|
+
permissionModes: AgentPermissionMode[];
|
|
211
|
+
args: AgentArgsBuilder;
|
|
212
|
+
/** Capabilities this agent does not support; matching verification scenarios are skipped. */
|
|
213
|
+
excludeFeatures?: AgentFeature[];
|
|
214
|
+
startupInput?: AgentStartupInput[];
|
|
215
|
+
prefillDelayMs?: number;
|
|
216
|
+
prefillMode?: "bracketed" | "plain";
|
|
217
|
+
prefillSubmit?: string;
|
|
218
|
+
prefillSubmitDelayMs?: number;
|
|
219
|
+
}
|
|
220
|
+
/** Declares an agent contribution. */
|
|
221
|
+
declare function defineAgent<TConfig = unknown>(input: AgentDefinition<TConfig>): AgentDefinition<TConfig>;
|
|
222
|
+
import { ButtonHTMLAttributes, ComponentType as ComponentType2, HTMLAttributes, JSX } from "react";
|
|
223
|
+
import { AgentMessage as AgentMessage2 } from "@pragma-sh/sdk";
|
|
224
|
+
import { AgentMessage, BranchSyncStatus, DirEntry, FileContents, PragmaClient as PragmaClient2, WorktreeChanges } from "@pragma-sh/sdk";
|
|
225
|
+
/**
|
|
226
|
+
* The hook implementations the Pragma host installs at `__PRAGMA__.hooks`.
|
|
227
|
+
* Every plugin-facing hook below is a thin delegator onto this object — the
|
|
228
|
+
* host owns the real React state/effects; `@pragma-sh/plugin` only declares the
|
|
229
|
+
* shape so plugin authors get full typing.
|
|
230
|
+
*/
|
|
231
|
+
interface PragmaHooksBridge {
|
|
232
|
+
usePluginConfig: <TConfig>() => TConfig;
|
|
233
|
+
useSdk: () => PragmaClient2;
|
|
234
|
+
useProject: () => PluginProject | null;
|
|
235
|
+
useTheme: () => "light" | "dark";
|
|
236
|
+
useWebViewPayload: <T>() => T | undefined;
|
|
237
|
+
useNotify: () => (message: string, options?: PluginNotifyOptions) => void;
|
|
238
|
+
useStoredState: <T>(key: string, initialValue: T) => [T, (value: T | ((prev: T) => T)) => void];
|
|
239
|
+
useSdkQuery: <T>(queryFn: (sdk: PragmaClient2) => Promise<T>, deps: readonly unknown[]) => PluginQueryResult<T>;
|
|
240
|
+
useEvent: <TPayload>(eventName: string, handler: (payload: TPayload) => void) => void;
|
|
241
|
+
useWorktreeChanges: (worktreeRoot: string | null) => PluginQueryResult<WorktreeChanges>;
|
|
242
|
+
useBranchStatus: (worktreeRoot: string | null) => PluginQueryResult<BranchSyncStatus>;
|
|
243
|
+
useDirEntries: (root: string | null, path?: string) => PluginQueryResult<DirEntry[]>;
|
|
244
|
+
useFileContents: (root: string | null, path: string | null) => PluginQueryResult<FileContents>;
|
|
245
|
+
useAgentStatuses: (worktreeId: string | null) => PluginQueryResult<PluginAgentStatusEntry[]>;
|
|
246
|
+
useAgentMessages: (worktreeId: string | null, tabId?: string | null) => PluginQueryResult<AgentMessage[]>;
|
|
247
|
+
useSessions: () => PluginQueryResult<PluginSessionSummary[]>;
|
|
248
|
+
}
|
|
249
|
+
/** This plugin's config, already validated against its `config` schema. */
|
|
250
|
+
declare function usePluginConfig<TConfig = unknown>(): TConfig;
|
|
251
|
+
/** Typed SDK client for talking to the local Pragma gateway. */
|
|
252
|
+
declare function useSdk(): PragmaClient2;
|
|
253
|
+
/** The active project, or `null` when no project is selected. */
|
|
254
|
+
declare function useProject(): PluginProject | null;
|
|
255
|
+
/** The host's current color theme. */
|
|
256
|
+
declare function useTheme(): "light" | "dark";
|
|
257
|
+
/** Payload supplied when the current plugin web view tab was opened. */
|
|
258
|
+
declare function useWebViewPayload<TPayload = unknown>(): TPayload | undefined;
|
|
259
|
+
/** Returns a function that shows an in-app notification. */
|
|
260
|
+
declare function useNotify(): (message: string, options?: PluginNotifyOptions) => void;
|
|
261
|
+
/** State persisted across app restarts, scoped to this plugin. */
|
|
262
|
+
declare function useStoredState<T>(key: string, initialValue: T): [T, (value: T | ((prev: T) => T)) => void];
|
|
263
|
+
/** Runs an arbitrary SDK query, re-running when `deps` change. */
|
|
264
|
+
declare function useSdkQuery<T>(queryFn: (sdk: PragmaClient2) => Promise<T>, deps: readonly unknown[]): PluginQueryResult<T>;
|
|
265
|
+
/** Subscribes to a named host event (e.g. `"agent.report"`) for this plugin's lifetime. */
|
|
266
|
+
declare function useEvent<TPayload = unknown>(eventName: string, handler: (payload: TPayload) => void): void;
|
|
267
|
+
/** Uncommitted + committed diff summary for a worktree root. */
|
|
268
|
+
declare function useWorktreeChanges(worktreeRoot: string | null): PluginQueryResult<WorktreeChanges>;
|
|
269
|
+
/** Ahead/behind sync status against the branch's upstream. */
|
|
270
|
+
declare function useBranchStatus(worktreeRoot: string | null): PluginQueryResult<BranchSyncStatus>;
|
|
271
|
+
/** Directory listing for a worktree-relative path (defaults to the root itself). */
|
|
272
|
+
declare function useDirEntries(root: string | null, path?: string): PluginQueryResult<DirEntry[]>;
|
|
273
|
+
/** File contents for a worktree-relative path. */
|
|
274
|
+
declare function useFileContents(root: string | null, path: string | null): PluginQueryResult<FileContents>;
|
|
275
|
+
/** Live agent statuses for a worktree. */
|
|
276
|
+
declare function useAgentStatuses(worktreeId: string | null): PluginQueryResult<PluginAgentStatusEntry[]>;
|
|
277
|
+
/** Live rich agent messages for a worktree, optionally scoped to one tab. */
|
|
278
|
+
declare function useAgentMessages(worktreeId: string | null, tabId?: string | null): PluginQueryResult<AgentMessage[]>;
|
|
279
|
+
/** Live PTY sessions. */
|
|
280
|
+
declare function useSessions(): PluginQueryResult<PluginSessionSummary[]>;
|
|
281
|
+
import * as import_1sj3pb from "react";
|
|
282
|
+
import * as import_ilo9os from "react-dom";
|
|
283
|
+
import { z as z_3e } from "zod";
|
|
284
|
+
/** Minimal host Button props exposed through `@pragma-sh/plugin/ui`. */
|
|
285
|
+
type PragmaButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
286
|
+
variant?: "default" | "outline" | "secondary" | "ghost" | "destructive" | "success" | "warning" | "link";
|
|
287
|
+
size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg";
|
|
288
|
+
};
|
|
289
|
+
/** Minimal host keyboard-badge props exposed through `@pragma-sh/plugin/ui`. */
|
|
290
|
+
type PragmaKbdProps = HTMLAttributes<HTMLElement>;
|
|
291
|
+
/** A rendered UI primitive contributed by the host (`@pragma-sh/plugin/ui`). */
|
|
292
|
+
interface PragmaUiBridge {
|
|
293
|
+
Button: ComponentType2<PragmaButtonProps>;
|
|
294
|
+
Kbd: ComponentType2<PragmaKbdProps>;
|
|
295
|
+
}
|
|
296
|
+
/** A rendered icon component contributed by the host (`@pragma-sh/plugin/icons`). */
|
|
297
|
+
type PragmaIconsBridge = Record<string, ComponentType2<{
|
|
298
|
+
className?: string;
|
|
299
|
+
}>>;
|
|
300
|
+
/** Host actions exposed to plugin code outside React render trees. */
|
|
301
|
+
interface PragmaActionsBridge {
|
|
302
|
+
openWebView: <TPayload = unknown>(webView: WebViewReference<TPayload>, options?: OpenWebViewOptions<TPayload>) => Promise<void>;
|
|
303
|
+
agents: {
|
|
304
|
+
/** Reports one rich agent message through the host SDK bridge. */
|
|
305
|
+
reportMessage: (message: AgentMessage2) => Promise<void>;
|
|
306
|
+
};
|
|
307
|
+
events: {
|
|
308
|
+
/** Subscribes to one named host event. */
|
|
309
|
+
subscribe: (eventName: string, handler: (payload: unknown) => void) => () => void;
|
|
310
|
+
};
|
|
311
|
+
theme: {
|
|
312
|
+
/** Returns the host's current color theme. */
|
|
313
|
+
get: () => "light" | "dark";
|
|
314
|
+
/** Subscribes to host color-theme changes. */
|
|
315
|
+
subscribe: (listener: () => void) => () => void;
|
|
316
|
+
};
|
|
317
|
+
sessions: {
|
|
318
|
+
/** Lists current host sessions. */
|
|
319
|
+
list: () => Promise<PluginSessionSummary[]>;
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* The runtime surface the Pragma host installs at `globalThis.__PRAGMA__`
|
|
324
|
+
* before any plugin bundle is imported. Every value here is a compile-time
|
|
325
|
+
* stub in `@pragma-sh/plugin` — the host supplies the real implementation so
|
|
326
|
+
* plugin bundles never need to bundle React, zod, or host UI code themselves.
|
|
327
|
+
*/
|
|
328
|
+
interface PragmaBridge {
|
|
329
|
+
react: typeof import_1sj3pb;
|
|
330
|
+
reactDom: typeof import_ilo9os;
|
|
331
|
+
jsxRuntime: {
|
|
332
|
+
jsx: (type: unknown, props: unknown, key?: unknown) => JSX.Element;
|
|
333
|
+
jsxs: (type: unknown, props: unknown, key?: unknown) => JSX.Element;
|
|
334
|
+
Fragment: unknown;
|
|
335
|
+
};
|
|
336
|
+
zod: typeof z_3e;
|
|
337
|
+
ui: PragmaUiBridge;
|
|
338
|
+
icons: PragmaIconsBridge;
|
|
339
|
+
hooks: PragmaHooksBridge;
|
|
340
|
+
actions: PragmaActionsBridge;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Returns the host-installed Pragma bridge, throwing a clear error when a
|
|
344
|
+
* plugin module runs outside a Pragma host (e.g. imported directly in a Node
|
|
345
|
+
* script, a unit test, or a non-Pragma bundler build).
|
|
346
|
+
*/
|
|
347
|
+
declare function getBridge(): PragmaBridge;
|
|
348
|
+
/**
|
|
349
|
+
* The `@pragma-sh/plugin` version a plugin was compiled against, stamped onto
|
|
350
|
+
* every plugin definition by `definePlugin`. Used by the Pragma host to check
|
|
351
|
+
* compatibility before loading a plugin bundle.
|
|
352
|
+
*/
|
|
353
|
+
declare const PLUGIN_API_VERSION = "0.1.0";
|
|
354
|
+
import { AgentReportPayload } from "@pragma-sh/constants";
|
|
355
|
+
import { ZodType, ZodTypeAny } from "zod";
|
|
356
|
+
import { AgentMessage as AgentMessage3, PragmaClient as PragmaClient3 } from "@pragma-sh/sdk";
|
|
357
|
+
/** Declares a watcher a plugin attaches to one of its agents' sessions. */
|
|
358
|
+
interface WatcherDefinition<TConfig = unknown> {
|
|
359
|
+
/** The `defineAgent` id this watcher attaches to. */
|
|
360
|
+
agent: string;
|
|
361
|
+
/** Runs once per launched session; lives until the session exits. */
|
|
362
|
+
watch: (ctx: WatcherContext<TConfig>) => void | Promise<void>;
|
|
363
|
+
}
|
|
364
|
+
/** Host-side context passed to a running watcher instance. */
|
|
365
|
+
interface WatcherContext<TConfig = unknown> {
|
|
366
|
+
/** Typed gateway SDK. */
|
|
367
|
+
sdk: PragmaClient3;
|
|
368
|
+
/** Full agent id this watcher instance is bound to (plugin-qualified). */
|
|
369
|
+
agentId: string;
|
|
370
|
+
/** This plugin's validated config. */
|
|
371
|
+
config: TConfig;
|
|
372
|
+
/** Session this watcher is attached to. */
|
|
373
|
+
session: {
|
|
374
|
+
id: string;
|
|
375
|
+
tabId: string;
|
|
376
|
+
worktreeId: string;
|
|
377
|
+
};
|
|
378
|
+
/** Decoded terminal output chunks for this session. */
|
|
379
|
+
output: AsyncIterable<string>;
|
|
380
|
+
/** Writes bytes into the live terminal session. */
|
|
381
|
+
sendKeys: (data: string) => Promise<void>;
|
|
382
|
+
/** Reports a rich message for this watcher-owned agent. */
|
|
383
|
+
reportMessage: (msg: Omit<AgentMessage3, "agent" | "tabId" | "worktreeId">) => Promise<void>;
|
|
384
|
+
/** Aborts when the session exits or the watcher is stopped. */
|
|
385
|
+
signal: AbortSignal;
|
|
386
|
+
}
|
|
387
|
+
/** Declares a watcher contribution. */
|
|
388
|
+
declare function defineWatcher<TConfig = unknown>(input: WatcherDefinition<TConfig>): WatcherDefinition<TConfig>;
|
|
389
|
+
/** One finite or unlimited usage category reported by a provider. */
|
|
390
|
+
interface UsageLimit {
|
|
391
|
+
id: string;
|
|
392
|
+
title: string;
|
|
393
|
+
used: number;
|
|
394
|
+
/** A null limit represents unlimited usage. */
|
|
395
|
+
limit: number | null;
|
|
396
|
+
/** Milliseconds until this category resets, measured from `observedAt`. */
|
|
397
|
+
resetsInMs?: number;
|
|
398
|
+
}
|
|
399
|
+
/** A successful provider snapshot. */
|
|
400
|
+
interface UsageLimitsReady {
|
|
401
|
+
status: "ready";
|
|
402
|
+
/** Unix time in milliseconds when the provider observed these values. */
|
|
403
|
+
observedAt: number;
|
|
404
|
+
/** Optional collapsed-row metric derived separately from the detailed limits. */
|
|
405
|
+
summary?: UsageLimit;
|
|
406
|
+
limits: UsageLimit[];
|
|
407
|
+
}
|
|
408
|
+
/** Why a provider cannot currently report usage limits. */
|
|
409
|
+
type UsageLimitsUnavailableReason = "not-configured" | "authentication-required" | "unsupported" | "error";
|
|
410
|
+
/** A provider state that requires user or platform action before loading. */
|
|
411
|
+
interface UsageLimitsUnavailable {
|
|
412
|
+
status: "unavailable";
|
|
413
|
+
reason: UsageLimitsUnavailableReason;
|
|
414
|
+
message: string;
|
|
415
|
+
}
|
|
416
|
+
/** Result returned by a usage-limit provider. Unexpected failures should throw. */
|
|
417
|
+
type UsageLimitsResult = UsageLimitsReady | UsageLimitsUnavailable;
|
|
418
|
+
/** A plugin-owned usage source rendered by Pragma's shared usage-limits UI. */
|
|
419
|
+
interface UsageLimitProviderDefinition<TConfig = unknown> {
|
|
420
|
+
id: string;
|
|
421
|
+
title: string;
|
|
422
|
+
/** Absolute URL for viewing this provider's usage in its dashboard. */
|
|
423
|
+
dashboardUrl: string;
|
|
424
|
+
icon?: PluginIcon;
|
|
425
|
+
/** Browser URL, absolute path, or plugin-directory-relative asset path. */
|
|
426
|
+
iconPath?: string;
|
|
427
|
+
/** Category rendered in the provider's collapsed summary row. */
|
|
428
|
+
primaryLimitId: string;
|
|
429
|
+
/** Requested refresh cadence. The host may enforce a larger minimum. */
|
|
430
|
+
refreshIntervalMs?: number;
|
|
431
|
+
load: (ctx: PluginContext<TConfig>) => Promise<UsageLimitsResult>;
|
|
432
|
+
}
|
|
433
|
+
/** Declares a provider for Pragma's shared usage-limits UI. */
|
|
434
|
+
declare function defineUsageLimitProvider<TConfig = unknown>(input: UsageLimitProviderDefinition<TConfig>): UsageLimitProviderDefinition<TConfig>;
|
|
435
|
+
/** Color schemes supported by Pragma themes. */
|
|
436
|
+
type ThemeMode = "light" | "dark";
|
|
437
|
+
/** Theme token overrides for one color scheme, keyed without the `--` prefix. */
|
|
438
|
+
type ThemeColors = Record<ThemeMode, Record<string, string>>;
|
|
439
|
+
/** A selectable theme contributed to Pragma's Theme settings. */
|
|
440
|
+
interface ThemeDefinition {
|
|
441
|
+
/** Stable id within this plugin. */
|
|
442
|
+
id: string;
|
|
443
|
+
/** Human-readable name shown in Theme settings. */
|
|
444
|
+
name: string;
|
|
445
|
+
/** Optional detail shown under the theme name. */
|
|
446
|
+
description?: string;
|
|
447
|
+
/** Light and dark Pragma theme-token overrides. */
|
|
448
|
+
colors: ThemeColors;
|
|
449
|
+
}
|
|
450
|
+
/** Declares a theme contribution. */
|
|
451
|
+
declare function defineTheme(input: ThemeDefinition): ThemeDefinition;
|
|
452
|
+
/** Infers a config schema's parsed output type, defaulting to `unknown` when no schema is given. */
|
|
453
|
+
type InferConfig<TConfigSchema extends ZodTypeAny> = TConfigSchema extends ZodType<infer Output> ? Output : unknown;
|
|
454
|
+
/** UI surfaces a plugin can contribute to. */
|
|
455
|
+
interface PluginUiContributions<TConfig = unknown> {
|
|
456
|
+
sidebarTabs?: SidebarTabDefinition<TConfig>[];
|
|
457
|
+
settingsPages?: SettingsPageDefinition<TConfig>[];
|
|
458
|
+
topper?: TopperItemDefinition<TConfig>[];
|
|
459
|
+
sidebarCards?: SidebarCardDefinition<TConfig>[];
|
|
460
|
+
webViews?: WebViewDefinition[];
|
|
461
|
+
}
|
|
462
|
+
/** Whether a plugin's declared values are merged with or replace host defaults. */
|
|
463
|
+
type PluginContributionStrategy = "merge" | "replace";
|
|
464
|
+
/** Default settings values a plugin contributes. */
|
|
465
|
+
interface PluginSettingsContributions {
|
|
466
|
+
strategy?: PluginContributionStrategy;
|
|
467
|
+
values: Record<string, unknown>;
|
|
468
|
+
}
|
|
469
|
+
/** Default keybindings a plugin contributes. */
|
|
470
|
+
interface PluginKeybindingsContributions {
|
|
471
|
+
strategy?: PluginContributionStrategy;
|
|
472
|
+
bindings: Record<string, string>;
|
|
473
|
+
}
|
|
474
|
+
/** Daemon-forwarded events a plugin can subscribe to declaratively. */
|
|
475
|
+
interface PluginEventHandlers<TConfig = unknown> {
|
|
476
|
+
"agent.report"?: (event: AgentReportPayload, ctx: PluginContext<TConfig>) => void;
|
|
477
|
+
deepLink?: (event: PluginDeepLinkEvent, ctx: PluginContext<TConfig>) => void;
|
|
478
|
+
}
|
|
479
|
+
/** The object shape passed to `definePlugin`. */
|
|
480
|
+
interface PluginDefinitionInput<TConfigSchema extends ZodTypeAny = ZodTypeAny> {
|
|
481
|
+
name: string;
|
|
482
|
+
description?: string;
|
|
483
|
+
icon?: PluginIcon;
|
|
484
|
+
config?: TConfigSchema;
|
|
485
|
+
ui?: PluginUiContributions<InferConfig<TConfigSchema>>;
|
|
486
|
+
agents?: AgentDefinition<InferConfig<TConfigSchema>>[];
|
|
487
|
+
watchers?: WatcherDefinition<InferConfig<TConfigSchema>>[];
|
|
488
|
+
commands?: CommandDefinition<InferConfig<TConfigSchema>>[];
|
|
489
|
+
settings?: PluginSettingsContributions;
|
|
490
|
+
keybindings?: PluginKeybindingsContributions;
|
|
491
|
+
events?: PluginEventHandlers<InferConfig<TConfigSchema>>;
|
|
492
|
+
usageLimits?: UsageLimitProviderDefinition<InferConfig<TConfigSchema>>[];
|
|
493
|
+
themes?: ThemeDefinition[];
|
|
494
|
+
css?: string;
|
|
495
|
+
/** Runs once when Pragma first discovers this plugin installation. */
|
|
496
|
+
onInstall?: (ctx: PluginContext<InferConfig<TConfigSchema>>) => void | Promise<void>;
|
|
497
|
+
/** Runs once during every Pragma server boot. */
|
|
498
|
+
onPragmaLoad?: (ctx: PluginContext<InferConfig<TConfigSchema>>) => void | Promise<void>;
|
|
499
|
+
activate?: (ctx: PluginContext<InferConfig<TConfigSchema>>) => void | (() => void);
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* A fully-declared plugin, as returned by `definePlugin`. `__apiVersion` is
|
|
503
|
+
* stamped automatically — plugin authors never set it themselves, and it
|
|
504
|
+
* lives under a deliberately internal-looking name so it doesn't show up as
|
|
505
|
+
* something to configure.
|
|
506
|
+
*/
|
|
507
|
+
interface PluginDefinition<TConfigSchema extends ZodTypeAny = ZodTypeAny> extends PluginDefinitionInput<TConfigSchema> {
|
|
508
|
+
/** @internal The `@pragma-sh/plugin` version this plugin was compiled against. */
|
|
509
|
+
readonly __apiVersion: string;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Declares a Pragma plugin. This is the single entry point a plugin's bundle
|
|
513
|
+
* must default-export. Stamps the compiled-against `@pragma-sh/plugin` version
|
|
514
|
+
* onto the result so the host can check compatibility before loading it.
|
|
515
|
+
*/
|
|
516
|
+
declare function definePlugin<TConfigSchema extends ZodTypeAny = ZodTypeAny>(input: PluginDefinitionInput<TConfigSchema>): PluginDefinition<TConfigSchema>;
|
|
517
|
+
/** Returns the host's current color theme outside React. */
|
|
518
|
+
declare function getTheme(): "light" | "dark";
|
|
519
|
+
/** Subscribes to color-theme changes outside React. Returns an unsubscribe function. */
|
|
520
|
+
declare function subscribeTheme(listener: (theme: "light" | "dark") => void): () => void;
|
|
521
|
+
/** Subscribes to a named host event outside React. Returns an unsubscribe function. */
|
|
522
|
+
declare function subscribeEvent<TPayload = unknown>(eventName: string, handler: (payload: TPayload) => void): () => void;
|
|
523
|
+
/** Lists current host sessions outside React. */
|
|
524
|
+
declare function listSessions(): Promise<PluginSessionSummary[]>;
|
|
525
|
+
import { z as ZodNamespace } from "zod";
|
|
526
|
+
/**
|
|
527
|
+
* The zod v4 namespace, delegated to the host's own zod instance at runtime
|
|
528
|
+
* via the Pragma bridge so plugin bundles never bundle zod themselves. Typed
|
|
529
|
+
* against real zod so `z.object(...)`, `z.infer<...>`, etc. work exactly as
|
|
530
|
+
* they would with a direct zod import.
|
|
531
|
+
*/
|
|
532
|
+
declare const z: typeof ZodNamespace;
|
|
533
|
+
export { z, useWorktreeChanges, useWebViewPayload, useTheme, useStoredState, useSessions, useSdkQuery, useSdk, useProject, usePluginConfig, useNotify, useFileContents, useEvent, useDirEntries, useBranchStatus, useAgentStatuses, useAgentMessages, subscribeTheme, subscribeEvent, openWebView2 as openWebView, listSessions, getTheme, getBridge, defineWebView, defineWatcher, defineUsageLimitProvider, defineTopperItem, defineTheme, defineSidebarTab, defineSidebarCard, defineSettingsPage, definePlugin, defineCommand, defineAgent, WebViewReference, WebViewDefinitionInput, WebViewDefinition, WatcherDefinition, WatcherContext, UsageLimitsUnavailableReason, UsageLimitsUnavailable, UsageLimitsResult, UsageLimitsReady, UsageLimitProviderDefinition, UsageLimit, TopperItemDefinition, ThemeMode, ThemeDefinition, ThemeColors, SidebarTabDefinition, SidebarCardDefinition, SettingsPageDefinition, PragmaUiBridge, PragmaIconsBridge, PragmaHooksBridge, PragmaBridge, PragmaActionsBridge, PluginWhen, PluginUiContributions, PluginStorage, PluginSettingsContributions, PluginSessionSummary, PluginQueryResult, PluginProject, PluginNotifyOptions, PluginKeybindingsContributions, PluginIcon, PluginEventHandlers, PluginDefinitionInput, PluginDefinition, PluginDeepLinkEvent, PluginContributionStrategy, PluginContext, PluginComponentProps, PluginComponent, PluginAgentStatusEntry, PLUGIN_API_VERSION, OpenWebViewOptions, InferConfig, CommandDefinition, AgentStartupInput, AgentReasoning, AgentPermissionMode, AgentModelEntry, AgentFeature, AgentDefinition, AgentArgsBuilder };
|