@ampcode/plugin 0.0.0-20260512003045-g373e11b → 0.0.0-20260514003522-g664bf7d
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/index.d.ts +60 -7
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -48,6 +48,9 @@ declare module '@ampcode/plugin' {
|
|
|
48
48
|
isPluginUINotAvailableError: IsPluginUINotAvailableError
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/** Platform UI capabilities */
|
|
52
|
+
ui: PluginUI
|
|
53
|
+
|
|
51
54
|
/**
|
|
52
55
|
* Register a handler for plugin events.
|
|
53
56
|
* For request events (e.g., tool.call), the handler must return a result.
|
|
@@ -79,7 +82,7 @@ declare module '@ampcode/plugin' {
|
|
|
79
82
|
id: string,
|
|
80
83
|
options: PluginCommandOptions,
|
|
81
84
|
handler: (ctx: PluginCommandContext) => void | Promise<void>,
|
|
82
|
-
):
|
|
85
|
+
): CommandSubscription
|
|
83
86
|
|
|
84
87
|
/**
|
|
85
88
|
* Register a tool that the agent can call.
|
|
@@ -155,7 +158,12 @@ declare module '@ampcode/plugin' {
|
|
|
155
158
|
/** Text to show. */
|
|
156
159
|
text: string
|
|
157
160
|
|
|
158
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* URL to open when clicked, if any.
|
|
163
|
+
*
|
|
164
|
+
* Use a `command:` URI to execute a command registered by a plugin or the
|
|
165
|
+
* command palette. For example, `command:foo` runs the command with ID `foo`.
|
|
166
|
+
*/
|
|
159
167
|
url?: string
|
|
160
168
|
}
|
|
161
169
|
|
|
@@ -219,6 +227,16 @@ declare module '@ampcode/plugin' {
|
|
|
219
227
|
*/
|
|
220
228
|
subscribe(observer: PluginConfigurationObserver<T>): Subscription
|
|
221
229
|
subscribe(onNext: (value: T) => void): Subscription
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Pipe operators for transforming this observable.
|
|
233
|
+
*/
|
|
234
|
+
pipe<Out>(op: (input: Observable<T>) => Out): Out
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Return this observable for interop with observable libraries.
|
|
238
|
+
*/
|
|
239
|
+
[Symbol.observable](): Observable<T>
|
|
222
240
|
}
|
|
223
241
|
|
|
224
242
|
/**
|
|
@@ -226,11 +244,6 @@ declare module '@ampcode/plugin' {
|
|
|
226
244
|
* Provides a limited subset of Observable functionality for plugins.
|
|
227
245
|
*/
|
|
228
246
|
export interface PluginConfiguration<T> extends Observable<T> {
|
|
229
|
-
/**
|
|
230
|
-
* Pipe operators for transforming the configuration observable.
|
|
231
|
-
*/
|
|
232
|
-
pipe<Out>(op: (input: PluginConfiguration<T>) => Out): Out
|
|
233
|
-
|
|
234
247
|
/**
|
|
235
248
|
* Get the current configuration value.
|
|
236
249
|
*/
|
|
@@ -460,6 +473,9 @@ declare module '@ampcode/plugin' {
|
|
|
460
473
|
/** Message body shown below the title */
|
|
461
474
|
message?: string
|
|
462
475
|
|
|
476
|
+
/** Initially selected option value */
|
|
477
|
+
initialValue?: string
|
|
478
|
+
|
|
463
479
|
/** Entries to display as choices */
|
|
464
480
|
options: string[]
|
|
465
481
|
}
|
|
@@ -790,6 +806,18 @@ declare module '@ampcode/plugin' {
|
|
|
790
806
|
*/
|
|
791
807
|
export type IsPluginUINotAvailableError = (error: Error) => boolean
|
|
792
808
|
|
|
809
|
+
/**
|
|
810
|
+
* Whether a registered command is selectable in the command palette.
|
|
811
|
+
*
|
|
812
|
+
* - `enabled`: shown and selectable.
|
|
813
|
+
* - `disabled`: shown but not selectable; `reason` is displayed alongside the command.
|
|
814
|
+
* - `hidden`: not shown in the palette at all.
|
|
815
|
+
*/
|
|
816
|
+
export type CommandAvailability =
|
|
817
|
+
| { type: 'enabled' }
|
|
818
|
+
| { type: 'disabled'; reason: string }
|
|
819
|
+
| { type: 'hidden' }
|
|
820
|
+
|
|
793
821
|
/**
|
|
794
822
|
* Options for registering a command.
|
|
795
823
|
*/
|
|
@@ -802,6 +830,31 @@ declare module '@ampcode/plugin' {
|
|
|
802
830
|
|
|
803
831
|
/** Human-readable description of what this command does */
|
|
804
832
|
description?: string
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Initial availability of the command in the command palette.
|
|
836
|
+
* Defaults to `{ type: 'enabled' }`.
|
|
837
|
+
*
|
|
838
|
+
* Use the {@link CommandSubscription.setAvailability} method on the
|
|
839
|
+
* subscription returned by {@link PluginAPI.registerCommand} to update
|
|
840
|
+
* availability dynamically.
|
|
841
|
+
*/
|
|
842
|
+
availability?: CommandAvailability
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Subscription returned by {@link PluginAPI.registerCommand}.
|
|
847
|
+
*
|
|
848
|
+
* Allows updating the command's availability in the palette in addition to
|
|
849
|
+
* unregistering it.
|
|
850
|
+
*/
|
|
851
|
+
export interface CommandSubscription extends Subscription {
|
|
852
|
+
/**
|
|
853
|
+
* Update whether this command is selectable in the command palette.
|
|
854
|
+
* Triggers a refresh in the host so the palette reflects the new state
|
|
855
|
+
* on its next read.
|
|
856
|
+
*/
|
|
857
|
+
setAvailability(status: CommandAvailability): void
|
|
805
858
|
}
|
|
806
859
|
|
|
807
860
|
/**
|