@punica/editor 1.0.6 → 1.0.7
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/index.bundle.esm.js +1 -1
- package/dist/index.bundle.esm.js.map +1 -1
- package/dist/index.bundle.umd.js +1 -1
- package/dist/index.bundle.umd.js.map +1 -1
- package/package.json +28 -3
- package/types/index.d.ts +120 -11
- package/types/punica.module.bootstrap.d.ts +45 -0
- package/types/punica.module.capability.d.ts +359 -0
- package/types/punica.module.extensions.api.d.ts +740 -0
- package/types/punica.module.extensions.settings.d.ts +106 -0
- package/types/punica.module.flow.agent.d.ts +75 -0
- package/types/punica.module.flow.api.d.ts +128 -0
- package/types/punica.module.flow.d.ts +490 -0
- package/types/punica.module.flow.engine.d.ts +228 -0
- package/types/punica.module.flow.mcp.d.ts +26 -0
- package/types/punica.module.flow.notebook.d.ts +210 -0
- package/types/punica.module.flow.primitives.d.ts +700 -0
- package/types/punica.module.flow.shell.d.ts +374 -0
- package/types/punica.module.kernel.ai.d.ts +462 -0
- package/types/punica.module.kernel.commands.d.ts +49 -0
- package/types/punica.module.kernel.events.d.ts +274 -0
- package/types/punica.module.kernel.history.d.ts +20 -0
- package/types/punica.module.kernel.llm.d.ts +343 -0
- package/types/punica.module.kernel.notifications.d.ts +64 -0
- package/types/punica.module.kernel.policy.d.ts +273 -0
- package/types/punica.module.kernel.tasks.d.ts +107 -0
- package/types/punica.module.kernel.timeServer.d.ts +16 -0
- package/types/punica.module.runtime.api.d.ts +214 -0
- package/types/punica.module.runtime.capabilities.d.ts +175 -0
- package/types/punica.module.runtime.compute.d.ts +339 -0
- package/types/punica.module.runtime.datasets.d.ts +234 -0
- package/types/punica.module.runtime.fs.d.ts +385 -0
- package/types/punica.module.runtime.harness.d.ts +246 -0
- package/types/punica.module.runtime.host.d.ts +272 -0
- package/types/punica.module.runtime.inference.d.ts +164 -0
- package/types/punica.module.runtime.lifecycle.d.ts +15 -0
- package/types/punica.module.runtime.llm.d.ts +470 -0
- package/types/punica.module.runtime.mcp.d.ts +139 -0
- package/types/punica.module.runtime.modelRuntimes.d.ts +90 -0
- package/types/punica.module.runtime.models.d.ts +254 -0
- package/types/punica.module.runtime.search.d.ts +59 -0
- package/types/punica.module.runtime.secrets.d.ts +26 -0
- package/types/punica.module.runtime.tasks.d.ts +27 -0
- package/types/punica.module.runtime.vcs.d.ts +67 -0
- package/types/punica.module.runtime.vectors.d.ts +74 -0
- package/types/punica.module.runtime.workspace.d.ts +134 -0
- package/types/punica.module.shell.activityBar.d.ts +42 -0
- package/types/punica.module.shell.components.d.ts +87 -0
- package/types/punica.module.shell.contentTabs.d.ts +33 -0
- package/types/punica.module.shell.dragDrop.d.ts +25 -0
- package/types/punica.module.shell.keyboardShortcuts.d.ts +38 -0
- package/types/punica.module.shell.layout.d.ts +106 -0
- package/types/punica.module.shell.markdown.d.ts +36 -0
- package/types/punica.module.shell.panelTabs.d.ts +48 -0
- package/types/punica.module.shell.profile.d.ts +278 -0
- package/types/punica.module.shell.statusbar.d.ts +26 -0
- package/types/punica.module.shell.view.d.ts +455 -0
- package/types/punica.module.shell.views.d.ts +150 -0
- package/types/punica.module.test.d.ts +562 -0
- package/types/punica.module.activityBar.d.ts +0 -21
- package/types/punica.module.commands.d.ts +0 -21
- package/types/punica.module.dragDrop.d.ts +0 -23
- package/types/punica.module.extensions.d.ts +0 -157
- package/types/punica.module.history.d.ts +0 -18
- package/types/punica.module.keyboardShortcuts.d.ts +0 -29
- package/types/punica.module.layout.d.ts +0 -22
- package/types/punica.module.statusbar.d.ts +0 -21
- package/types/punica.module.timeServer.d.ts +0 -14
- package/types/punica.module.view.d.ts +0 -8
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace Extensions {
|
|
3
|
+
interface BaseView {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
alignment?: 'primary' | 'secondary';
|
|
10
|
+
content?: HTMLElement;
|
|
11
|
+
/**
|
|
12
|
+
* Capability id to execute when the view is activated.
|
|
13
|
+
* For activity bar items this will be invoked when the icon is clicked.
|
|
14
|
+
*/
|
|
15
|
+
capability?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface Views {
|
|
19
|
+
primarySidebar?: BaseView;
|
|
20
|
+
secondarySidebar?: BaseView;
|
|
21
|
+
/**
|
|
22
|
+
* Contextual detail drawer (overlay). TRANSIENT: its content is
|
|
23
|
+
* parameterized per open, so the shell re-renders the view's
|
|
24
|
+
* provider on every reveal, and hiding unmounts the drawer.
|
|
25
|
+
*/
|
|
26
|
+
contentSidebar?: BaseView;
|
|
27
|
+
content?: BaseView;
|
|
28
|
+
/**
|
|
29
|
+
* Declarative bottom-panel tab. The tab appears in the panel tab
|
|
30
|
+
* strip at load time (like activity bar items); content renders
|
|
31
|
+
* only on reveal — via the extension's ViewProvider, or, for
|
|
32
|
+
* pre-migration extensions, via the bound `capability` command.
|
|
33
|
+
*/
|
|
34
|
+
panel?: BaseView & { order?: number };
|
|
35
|
+
activityBar?: Pick<BaseView, 'id' | 'name'> &
|
|
36
|
+
Required<Pick<BaseView, 'title' | 'icon' | 'alignment'>>;
|
|
37
|
+
statusBar?: Pick<BaseView, 'id' | 'name'> &
|
|
38
|
+
Required<Pick<BaseView, 'title' | 'label' | 'icon' | 'alignment'>>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface Command {
|
|
42
|
+
command: string;
|
|
43
|
+
title: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface Keybinding {
|
|
47
|
+
/**
|
|
48
|
+
* Capability id to execute when the keybinding is triggered.
|
|
49
|
+
*/
|
|
50
|
+
capability?: string;
|
|
51
|
+
key: string;
|
|
52
|
+
when: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface MenuItem {
|
|
56
|
+
/**
|
|
57
|
+
* Capability id to execute when the menu item is selected.
|
|
58
|
+
*/
|
|
59
|
+
capability?: string;
|
|
60
|
+
when: string;
|
|
61
|
+
group: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface Menu {
|
|
65
|
+
commandPalette: MenuItem;
|
|
66
|
+
context: MenuItem;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface BooleanProperty {
|
|
70
|
+
type: 'boolean';
|
|
71
|
+
default: boolean;
|
|
72
|
+
description: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface StringProperty {
|
|
76
|
+
type: 'string';
|
|
77
|
+
default: string;
|
|
78
|
+
description: string;
|
|
79
|
+
enum?: string[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface NumberProperty {
|
|
83
|
+
type: 'number';
|
|
84
|
+
default: number;
|
|
85
|
+
description: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface ArrayProperty {
|
|
89
|
+
type: 'array';
|
|
90
|
+
default: any[];
|
|
91
|
+
description: string;
|
|
92
|
+
items: any;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface ObjectProperty {
|
|
96
|
+
type: 'object';
|
|
97
|
+
default: { [key: string]: any };
|
|
98
|
+
description: string;
|
|
99
|
+
properties: { [key: string]: Property };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
type Property =
|
|
103
|
+
| BooleanProperty
|
|
104
|
+
| StringProperty
|
|
105
|
+
| NumberProperty
|
|
106
|
+
| ArrayProperty
|
|
107
|
+
| ObjectProperty;
|
|
108
|
+
|
|
109
|
+
interface Configuration {
|
|
110
|
+
title: string;
|
|
111
|
+
properties: {
|
|
112
|
+
[key: string]: Property;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface MarketplaceScreenshot {
|
|
117
|
+
path: string;
|
|
118
|
+
label?: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface MarketplacePermissions {
|
|
122
|
+
fs?: 'none' | 'read-only' | 'read-write';
|
|
123
|
+
network?: 'none' | 'limited' | 'full';
|
|
124
|
+
kernels?: string[];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface MarketplaceMeta {
|
|
128
|
+
/**
|
|
129
|
+
* Relative path to the primary icon for this extension (used in
|
|
130
|
+
* marketplace listings and, when appropriate, activity bar).
|
|
131
|
+
*/
|
|
132
|
+
icon?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Optional banner / hero image shown on the extension detail page.
|
|
135
|
+
*/
|
|
136
|
+
banner?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Relative path to the README file that describes this extension in
|
|
139
|
+
* more detail. Typically "README.md" at the extension root.
|
|
140
|
+
*/
|
|
141
|
+
readmePath?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Optional path to a changelog file.
|
|
144
|
+
*/
|
|
145
|
+
changelogPath?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Publisher / owner identifier for this extension (e.g. "ivyx").
|
|
148
|
+
*/
|
|
149
|
+
publisher?: string;
|
|
150
|
+
/**
|
|
151
|
+
* Homepage or marketing site for this extension.
|
|
152
|
+
*/
|
|
153
|
+
homepage?: string;
|
|
154
|
+
/**
|
|
155
|
+
* Repository URL for the extension source code.
|
|
156
|
+
*/
|
|
157
|
+
repository?: string;
|
|
158
|
+
/**
|
|
159
|
+
* Optional screenshots shown on the detail page.
|
|
160
|
+
*/
|
|
161
|
+
screenshots?: MarketplaceScreenshot[];
|
|
162
|
+
/**
|
|
163
|
+
* High-level capabilities / tags used for discovery and filtering
|
|
164
|
+
* in the marketplace (e.g. "flow", "ai-assistant", "notebook").
|
|
165
|
+
*/
|
|
166
|
+
capabilities?: string[];
|
|
167
|
+
/**
|
|
168
|
+
* Declared permissions for this extension. This is advisory metadata
|
|
169
|
+
* that helps users understand what the extension might access.
|
|
170
|
+
*/
|
|
171
|
+
permissions?: MarketplacePermissions;
|
|
172
|
+
/**
|
|
173
|
+
* Target platforms / hosts supported by this extension, such as
|
|
174
|
+
* "browser", "electron", or "server".
|
|
175
|
+
*/
|
|
176
|
+
platforms?: string[];
|
|
177
|
+
/**
|
|
178
|
+
* Optional base URL for this extension module on a marketplace or
|
|
179
|
+
* extension gallery. When provided, hosts or managers can call
|
|
180
|
+
* Extensions.manager.load(moduleURL) to install/activate it.
|
|
181
|
+
*/
|
|
182
|
+
moduleURL?: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
interface FileOpenerIntegration {
|
|
186
|
+
/**
|
|
187
|
+
* Capability id to execute when a matching file is opened.
|
|
188
|
+
*/
|
|
189
|
+
capability?: string;
|
|
190
|
+
priority?: number;
|
|
191
|
+
matches?: Runtime.FileMatch[];
|
|
192
|
+
id?: string;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Extension capability definition — same unified shape as module-level
|
|
197
|
+
* {@link CapabilityDefinition}. Alias (not `extends CapabilityDefinition`
|
|
198
|
+
* inside this namespace) avoids a self-referential empty interface.
|
|
199
|
+
*
|
|
200
|
+
* Extensions declare these in `.punica/capabilities.yaml` using JSON Schema
|
|
201
|
+
* for inputs/outputs.
|
|
202
|
+
*/
|
|
203
|
+
type CapabilityDefinition = import('punica').CapabilityDefinition;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Extension activation lifecycle events.
|
|
207
|
+
*
|
|
208
|
+
* - `onStartup` / `onStartup:begin`:
|
|
209
|
+
* For extensions that should run early during editor startup,
|
|
210
|
+
* after the core systems and layout/render have been initialized.
|
|
211
|
+
* - `onStartup:finish`:
|
|
212
|
+
* For heavy or background work that should start only after
|
|
213
|
+
* the UI + workspace are fully ready / idle (deferred startup).
|
|
214
|
+
* - `onCommand:<commandId>`:
|
|
215
|
+
* Activates the extension the first time the given command is executed.
|
|
216
|
+
* - `onExtension:<extensionName>`:
|
|
217
|
+
* Triggers when another extension is activated.
|
|
218
|
+
* - `onView:<viewId>`:
|
|
219
|
+
* Activates the extension when a specific view (e.g. sidebar/content)
|
|
220
|
+
* is shown for the first time.
|
|
221
|
+
*
|
|
222
|
+
* Other custom activation events are supported as generic strings,
|
|
223
|
+
* but the ones above define the official, documented lifecycle flow.
|
|
224
|
+
*/
|
|
225
|
+
type ActivationEvent =
|
|
226
|
+
| 'onStartup'
|
|
227
|
+
| 'onStartup:begin'
|
|
228
|
+
| 'onStartup:finish'
|
|
229
|
+
| `onCommand:${string}`
|
|
230
|
+
| `onExtension:${string}`
|
|
231
|
+
| `onView:${string}`
|
|
232
|
+
| (string & {});
|
|
233
|
+
|
|
234
|
+
interface Integrations {
|
|
235
|
+
keybindings?: Keybinding[];
|
|
236
|
+
menus?: Menu;
|
|
237
|
+
views?: Views;
|
|
238
|
+
configuration?: Configuration;
|
|
239
|
+
fileOpeners?: FileOpenerIntegration[];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
interface Extension {
|
|
243
|
+
module: Extensions.IExtension;
|
|
244
|
+
moduleURL: string;
|
|
245
|
+
name: string;
|
|
246
|
+
displayName: string;
|
|
247
|
+
description: string;
|
|
248
|
+
version: string;
|
|
249
|
+
main: string;
|
|
250
|
+
categories?: string[];
|
|
251
|
+
tags?: string[];
|
|
252
|
+
activationEvents?: ActivationEvent[];
|
|
253
|
+
dependOns?: string[];
|
|
254
|
+
integrations: Integrations;
|
|
255
|
+
/**
|
|
256
|
+
* When true, the Reader loads `.punica/capabilities.yaml` and populates
|
|
257
|
+
* `capabilities`. Absent/false ⇒ the file is never fetched, so extensions
|
|
258
|
+
* that expose no gateway capabilities don't trigger a speculative 404.
|
|
259
|
+
*/
|
|
260
|
+
hasCapabilities?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Optional capabilities registry loaded from `.punica/capabilities.yaml`.
|
|
263
|
+
* Keys are capability ids. Populated by the Reader only when
|
|
264
|
+
* `hasCapabilities` is declared in config.yaml.
|
|
265
|
+
*/
|
|
266
|
+
capabilities?: Record<string, CapabilityDefinition>;
|
|
267
|
+
/**
|
|
268
|
+
* Instruction classes loaded from `.punica/instruction-classes/*.ic.yaml`.
|
|
269
|
+
* Populated by the Reader during analysis phase; auto-registered into
|
|
270
|
+
* the kernel instructionClassRegistry by the extension manager.
|
|
271
|
+
*/
|
|
272
|
+
instructionClasses?: kernel.llm.InstructionClass[];
|
|
273
|
+
engines: {
|
|
274
|
+
punica: string;
|
|
275
|
+
};
|
|
276
|
+
marketplace?: MarketplaceMeta;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
interface ExtensionDecorator {
|
|
280
|
+
execute(): Promise<Extension>;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Extension runtime state — dimension A of the lifecycle model.
|
|
285
|
+
* Contains NO UI/visibility state: whether an extension runs as a
|
|
286
|
+
* service and whether its views are shown are orthogonal. View
|
|
287
|
+
* presentation state lives in `punica.shell.Views.manager`, per view.
|
|
288
|
+
*/
|
|
289
|
+
type ExtensionRuntimeState =
|
|
290
|
+
| 'loaded'
|
|
291
|
+
| 'activating'
|
|
292
|
+
| 'active'
|
|
293
|
+
| 'deactivating'
|
|
294
|
+
| 'failed';
|
|
295
|
+
|
|
296
|
+
/** Why an activation was requested. */
|
|
297
|
+
type ActivationReason =
|
|
298
|
+
| 'startup:begin'
|
|
299
|
+
| 'startup:finish'
|
|
300
|
+
| 'command'
|
|
301
|
+
| 'view'
|
|
302
|
+
| 'capability'
|
|
303
|
+
| 'extension'
|
|
304
|
+
| 'host';
|
|
305
|
+
|
|
306
|
+
interface ActivationOptions {
|
|
307
|
+
reason?: ActivationReason;
|
|
308
|
+
/** What triggered it: command id, capability id, viewId, extension name. */
|
|
309
|
+
trigger?: string;
|
|
310
|
+
/**
|
|
311
|
+
* 'headless': activation must not change focus-stealing UI state
|
|
312
|
+
* (derived for capability invocations). 'interactive': a
|
|
313
|
+
* user-visible flow. Derived from `reason` when omitted.
|
|
314
|
+
*/
|
|
315
|
+
presentation?: 'interactive' | 'headless';
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
interface IExtensionContext {
|
|
319
|
+
/**
|
|
320
|
+
* Why this extension is being activated. `presentation:
|
|
321
|
+
* 'headless'` means a service caller (agent, MCP client, flow)
|
|
322
|
+
* triggered the activation — do not attempt to show UI; defer
|
|
323
|
+
* UI-adjacent warmup until a view is revealed.
|
|
324
|
+
*/
|
|
325
|
+
activation: Readonly<{
|
|
326
|
+
reason: ActivationReason;
|
|
327
|
+
trigger?: string;
|
|
328
|
+
presentation: 'interactive' | 'headless';
|
|
329
|
+
}>;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Disposal bag: everything pushed here is disposed by
|
|
333
|
+
* `punica.extensions.manager.deactivate(name)`.
|
|
334
|
+
*/
|
|
335
|
+
subscriptions: Array<{ dispose(): void }>;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Capability API available during extension activation.
|
|
339
|
+
*
|
|
340
|
+
* Call `registerHandler` for each capability declared in
|
|
341
|
+
* `.punica/capabilities.yaml` that you want to make
|
|
342
|
+
* gateway-invocable. The gateway will invoke the handler after
|
|
343
|
+
* the full 13-stage middleware pipeline runs (policy, audit, etc.).
|
|
344
|
+
*
|
|
345
|
+
* Example:
|
|
346
|
+
* ```ts
|
|
347
|
+
* async activate(context) {
|
|
348
|
+
* context.capabilities.registerHandler('myext.doThing', async (input, ctx) => {
|
|
349
|
+
* return { result: 'ok' };
|
|
350
|
+
* });
|
|
351
|
+
* }
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
capabilities: {
|
|
355
|
+
/** Register an execution handler for a capability declared by this extension. */
|
|
356
|
+
registerHandler(
|
|
357
|
+
capabilityId: string,
|
|
358
|
+
handler: (input: unknown, ctx: unknown) => Promise<unknown>
|
|
359
|
+
): void;
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Declarative UI contribution API. Activation NEVER shows UI —
|
|
364
|
+
* register a provider and the shell materializes/renders it
|
|
365
|
+
* lazily on first reveal (user gesture or `shell.revealView`).
|
|
366
|
+
*/
|
|
367
|
+
ui: {
|
|
368
|
+
/**
|
|
369
|
+
* Register the render provider for a view declared in this
|
|
370
|
+
* extension's `integrations.views`. Registration alone never
|
|
371
|
+
* shows anything.
|
|
372
|
+
*/
|
|
373
|
+
registerViewProvider(
|
|
374
|
+
viewId: string,
|
|
375
|
+
provider: shell.Views.ViewProvider
|
|
376
|
+
): { dispose(): void };
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Deliberate, audited reveal — a thin shortcut over the
|
|
380
|
+
* `shell.revealView` core capability (the substrate's single
|
|
381
|
+
* visibility mutator). Use sparingly: showing UI should almost
|
|
382
|
+
* always be the user's or the host's decision.
|
|
383
|
+
*/
|
|
384
|
+
reveal(viewId: string, options?: { focus?: boolean }): Promise<void>;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Deliberate, audited hide — a thin shortcut over the
|
|
388
|
+
* `shell.hideView` core capability. The close affordance of
|
|
389
|
+
* transient views (the contentSidebar drawer's close button /
|
|
390
|
+
* Escape) goes through here, never through direct DOM removal.
|
|
391
|
+
*/
|
|
392
|
+
hide(viewId: string): Promise<void>;
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
interface StyleHandle {
|
|
397
|
+
id: string;
|
|
398
|
+
dispose(): void;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
interface StyleOptions {
|
|
402
|
+
/**
|
|
403
|
+
* Target element to append the <style> tag into. Defaults to document.head.
|
|
404
|
+
*/
|
|
405
|
+
target?: HTMLElement;
|
|
406
|
+
/**
|
|
407
|
+
* When true, an existing style with the same id will be updated with the
|
|
408
|
+
* new CSS instead of being left untouched.
|
|
409
|
+
*/
|
|
410
|
+
overwrite?: boolean;
|
|
411
|
+
/**
|
|
412
|
+
* Optional attributes applied to the created <style> element. Useful for
|
|
413
|
+
* debugging (e.g. data-extension="ivy-nodes").
|
|
414
|
+
*/
|
|
415
|
+
attrs?: Record<string, string>;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Helper API for managing extension-scoped <style> tags.
|
|
420
|
+
*
|
|
421
|
+
* This is a lightweight utility; extensions remain free to manage styles
|
|
422
|
+
* however they like. Using this helper simply standardizes the common
|
|
423
|
+
* pattern of injecting CSS on activate() and cleaning it up on deactivate().
|
|
424
|
+
*/
|
|
425
|
+
const Styles: {
|
|
426
|
+
/**
|
|
427
|
+
* Inject a CSS string as a <style> tag. Returns a handle that can be
|
|
428
|
+
* disposed to remove the style.
|
|
429
|
+
*/
|
|
430
|
+
register(id: string, css: string, options?: StyleOptions): StyleHandle;
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Remove a previously registered style by id. Safe to call multiple times.
|
|
434
|
+
*/
|
|
435
|
+
unregister(id: string): void;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Check whether a style with the given id is currently registered.
|
|
439
|
+
*/
|
|
440
|
+
has(id: string): boolean;
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
interface IExtension {
|
|
444
|
+
activate: (context: IExtensionContext) => Promise<void>;
|
|
445
|
+
deactivate: () => void;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
interface IExtensionManager {
|
|
449
|
+
/**
|
|
450
|
+
* Load one or more extensions from URL or file path.
|
|
451
|
+
*/
|
|
452
|
+
load(extensionPath: string, ...args: string[]): Promise<void>;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Activate a specific extension by name — start it as a running
|
|
456
|
+
* service. Activation never shows UI; visibility flows through
|
|
457
|
+
* the `shell.revealView` capability.
|
|
458
|
+
*
|
|
459
|
+
* Concurrent calls coalesce (single-flight). A failed activation
|
|
460
|
+
* records `failed` state and rethrows; a later call retries.
|
|
461
|
+
*/
|
|
462
|
+
activate(
|
|
463
|
+
extensionName: string,
|
|
464
|
+
options?: ActivationOptions
|
|
465
|
+
): Promise<void>;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Deactivate an extension: `active → deactivating → loaded`.
|
|
469
|
+
* Shell unmounts its rendered views (manifest placements stay),
|
|
470
|
+
* `module.deactivate()` runs, `context.subscriptions` are
|
|
471
|
+
* disposed and its capability handlers are removed. A later
|
|
472
|
+
* capability call re-activates headlessly.
|
|
473
|
+
*/
|
|
474
|
+
deactivate(extensionName: string): Promise<void>;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Current runtime state of an extension, or undefined when not
|
|
478
|
+
* loaded.
|
|
479
|
+
*/
|
|
480
|
+
getRuntimeState(extensionName: string): ExtensionRuntimeState | undefined;
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Trigger activation of all extensions that declare `onStartup:begin`
|
|
484
|
+
* in their activationEvents.
|
|
485
|
+
*/
|
|
486
|
+
startupBegin(): Promise<void>;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Trigger activation of all extensions that declare `onStartup:finish`
|
|
490
|
+
* in their activationEvents.
|
|
491
|
+
*/
|
|
492
|
+
startupFinish(): Promise<void>;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Get loaded extension metadata by name.
|
|
496
|
+
*/
|
|
497
|
+
getExtension(extensionName: string): Extension | undefined;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Return all loaded extensions metadata as an array. This is primarily
|
|
501
|
+
* used by the Extension Manager UI to list installed extensions.
|
|
502
|
+
*/
|
|
503
|
+
getAllExtensions(): Extension[];
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Return the list of extensions that declared `onCommand:<commandId>`
|
|
507
|
+
* activation events.
|
|
508
|
+
*/
|
|
509
|
+
getExtensionsForCommand(commandId: string): string[];
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Resolve a capability definition by id across all loaded extensions.
|
|
513
|
+
*/
|
|
514
|
+
getCapability(capabilityId: string): CapabilityDefinition | undefined;
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* List all capabilities known to the extension manager.
|
|
518
|
+
*/
|
|
519
|
+
listCapabilities(): Array<{
|
|
520
|
+
id: string;
|
|
521
|
+
extensionName: string;
|
|
522
|
+
definition: CapabilityDefinition;
|
|
523
|
+
}>;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Validate a capability input against its declared inputs schema.
|
|
527
|
+
* Early iterations may implement only minimal checks.
|
|
528
|
+
*/
|
|
529
|
+
validateCapabilityInput(
|
|
530
|
+
capabilityId: string,
|
|
531
|
+
input: unknown
|
|
532
|
+
): { ok: boolean; errors?: string[] };
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Register a JS handler for an extension capability.
|
|
536
|
+
*
|
|
537
|
+
* Typically called internally via `context.capabilities.registerHandler`
|
|
538
|
+
* during extension activation. Exposed here for host/test access.
|
|
539
|
+
*/
|
|
540
|
+
registerCapabilityHandler(
|
|
541
|
+
id: string,
|
|
542
|
+
handler: (input: unknown, ctx: unknown) => Promise<unknown>
|
|
543
|
+
): void;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Execute an extension capability by id, routing through the
|
|
547
|
+
* registered handler. Called by the gateway's extension provider
|
|
548
|
+
* after the middleware pipeline.
|
|
549
|
+
*
|
|
550
|
+
* Lazily activates the owning extension if not yet active.
|
|
551
|
+
* Throws `CAPABILITY_HANDLER_MISSING` when the extension did not
|
|
552
|
+
* register a handler during activation.
|
|
553
|
+
*/
|
|
554
|
+
executeCapability(
|
|
555
|
+
id: string,
|
|
556
|
+
input: unknown,
|
|
557
|
+
ctx: unknown
|
|
558
|
+
): Promise<unknown>;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Register built-in capabilities that ship with the editor (virtual extension).
|
|
562
|
+
*
|
|
563
|
+
* This is intended for core capabilities like workspace/vcs/tasks that are
|
|
564
|
+
* always present without loading an external extension.
|
|
565
|
+
*/
|
|
566
|
+
registerBuiltinCapabilities(
|
|
567
|
+
entries: Array<{
|
|
568
|
+
id: string;
|
|
569
|
+
extensionName: string;
|
|
570
|
+
definition: CapabilityDefinition;
|
|
571
|
+
}>
|
|
572
|
+
): void;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
const manager: IExtensionManager;
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Readonly Extension Metadata API
|
|
579
|
+
*/
|
|
580
|
+
namespace metadata {
|
|
581
|
+
export interface ReadonlyExtension {
|
|
582
|
+
readonly name: string;
|
|
583
|
+
readonly displayName?: string;
|
|
584
|
+
readonly description?: string;
|
|
585
|
+
readonly version: string;
|
|
586
|
+
readonly configuration?: Readonly<{
|
|
587
|
+
title: string;
|
|
588
|
+
properties: Readonly<
|
|
589
|
+
Record<string, ReadonlyExtensionSettingProperty>
|
|
590
|
+
>;
|
|
591
|
+
}>;
|
|
592
|
+
readonly capabilities?: Readonly<
|
|
593
|
+
Record<string, ReadonlyCapabilityDefinition>
|
|
594
|
+
>;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
export interface ReadonlyExtensionSettingProperty {
|
|
598
|
+
readonly type: 'boolean' | 'string' | 'number';
|
|
599
|
+
readonly default?: unknown;
|
|
600
|
+
readonly description?: string;
|
|
601
|
+
readonly enum?: readonly string[];
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
export interface ReadonlyCapabilityDefinition {
|
|
605
|
+
readonly title?: string;
|
|
606
|
+
readonly description?: string;
|
|
607
|
+
readonly inputs?: Readonly<unknown>;
|
|
608
|
+
readonly outputs?: Readonly<unknown>;
|
|
609
|
+
readonly policy?: Readonly<unknown>;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
export interface ExtensionMetadataApi {
|
|
613
|
+
/**
|
|
614
|
+
* Get readonly extension metadata by name
|
|
615
|
+
*/
|
|
616
|
+
getExtension(extensionName: string): ReadonlyExtension | undefined;
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Get all extensions as readonly array
|
|
620
|
+
*/
|
|
621
|
+
getAllExtensions(): readonly ReadonlyExtension[];
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Get readonly capabilities for an extension
|
|
625
|
+
*/
|
|
626
|
+
getExtensionCapabilities(
|
|
627
|
+
extensionName: string
|
|
628
|
+
): Readonly<Record<string, ReadonlyCapabilityDefinition>> | undefined;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Extension metadata manager façade surfaced via `punica.extensions.metadata.manager`.
|
|
633
|
+
*/
|
|
634
|
+
export const manager: ExtensionMetadataApi;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Settings API for managing extension and system settings
|
|
639
|
+
*/
|
|
640
|
+
namespace settings {
|
|
641
|
+
/**
|
|
642
|
+
* Settings manager façade surfaced via `punica.extensions.settings.manager`.
|
|
643
|
+
*/
|
|
644
|
+
export const manager: extensions.settings.SettingsApi;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* extensions: top-level extension system façade exposed as `punica.extensions`.
|
|
650
|
+
* This is a convenience alias around the existing Extensions namespace.
|
|
651
|
+
*/
|
|
652
|
+
export namespace extensions {
|
|
653
|
+
export import Extension = Extensions.Extension;
|
|
654
|
+
export import ExtensionDecorator = Extensions.ExtensionDecorator;
|
|
655
|
+
export import IExtension = Extensions.IExtension;
|
|
656
|
+
export import IExtensionManager = Extensions.IExtensionManager;
|
|
657
|
+
export import IExtensionContext = Extensions.IExtensionContext;
|
|
658
|
+
export import Styles = Extensions.Styles;
|
|
659
|
+
/**
|
|
660
|
+
* Extension manager façade surfaced via `punica.extensions.manager`.
|
|
661
|
+
*/
|
|
662
|
+
export const manager: Extensions.IExtensionManager;
|
|
663
|
+
export import MarketplaceMeta = Extensions.MarketplaceMeta;
|
|
664
|
+
export import ActivationEvent = Extensions.ActivationEvent;
|
|
665
|
+
export import ActivationOptions = Extensions.ActivationOptions;
|
|
666
|
+
export import ActivationReason = Extensions.ActivationReason;
|
|
667
|
+
export import ExtensionRuntimeState = Extensions.ExtensionRuntimeState;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Readonly Extension Metadata API
|
|
671
|
+
*/
|
|
672
|
+
export namespace metadata {
|
|
673
|
+
export interface ReadonlyExtension {
|
|
674
|
+
readonly name: string;
|
|
675
|
+
readonly displayName?: string;
|
|
676
|
+
readonly description?: string;
|
|
677
|
+
readonly version: string;
|
|
678
|
+
readonly configuration?: Readonly<{
|
|
679
|
+
title: string;
|
|
680
|
+
properties: Readonly<
|
|
681
|
+
Record<string, ReadonlyExtensionSettingProperty>
|
|
682
|
+
>;
|
|
683
|
+
}>;
|
|
684
|
+
readonly capabilities?: Readonly<
|
|
685
|
+
Record<string, ReadonlyCapabilityDefinition>
|
|
686
|
+
>;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
export interface ReadonlyExtensionSettingProperty {
|
|
690
|
+
readonly type: 'boolean' | 'string' | 'number';
|
|
691
|
+
readonly default?: unknown;
|
|
692
|
+
readonly description?: string;
|
|
693
|
+
readonly enum?: readonly string[];
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export interface ReadonlyCapabilityDefinition {
|
|
697
|
+
readonly title?: string;
|
|
698
|
+
readonly description?: string;
|
|
699
|
+
readonly inputs?: Readonly<unknown>;
|
|
700
|
+
readonly outputs?: Readonly<unknown>;
|
|
701
|
+
readonly policy?: Readonly<unknown>;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
export interface ExtensionMetadataApi {
|
|
705
|
+
/**
|
|
706
|
+
* Get readonly extension metadata by name
|
|
707
|
+
*/
|
|
708
|
+
getExtension(extensionName: string): ReadonlyExtension | undefined;
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Get all extensions as readonly array
|
|
712
|
+
*/
|
|
713
|
+
getAllExtensions(): readonly ReadonlyExtension[];
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Get readonly capabilities for an extension
|
|
717
|
+
*/
|
|
718
|
+
getExtensionCapabilities(
|
|
719
|
+
extensionName: string
|
|
720
|
+
): Readonly<Record<string, ReadonlyCapabilityDefinition>> | undefined;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Extension metadata manager façade surfaced via `punica.extensions.metadata.manager`.
|
|
725
|
+
*/
|
|
726
|
+
export const manager: ExtensionMetadataApi;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Settings API for managing extension and system settings
|
|
731
|
+
*/
|
|
732
|
+
export namespace settings {
|
|
733
|
+
export import SettingsApi = extensions.settings.SettingsApi;
|
|
734
|
+
/**
|
|
735
|
+
* Settings manager façade surfaced via `punica.extensions.settings.manager`.
|
|
736
|
+
*/
|
|
737
|
+
export const manager: SettingsApi;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|