@ampcode/plugin 0.0.0-20260527003623-g8232386 → 0.0.0-20260528003340-g17febba

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.
Files changed (2) hide show
  1. package/index.d.ts +112 -2
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -124,6 +124,12 @@ declare module '@ampcode/plugin' {
124
124
  * APIs under `PluginAPI.experimental` are not stable and may change or be removed.
125
125
  */
126
126
  export interface ExperimentalPluginAPI {
127
+ /** Create a custom agent bound to this plugin runtime. */
128
+ createAgent(config: CreateAgentConfig): Agent
129
+
130
+ /** Register a custom agent mode that clients may show alongside built-in modes. */
131
+ registerAgentMode(definition: PluginAgentModeDefinition): Subscription
132
+
127
133
  /**
128
134
  * Create a status item shown near the prompt editor or status bar in the Amp client.
129
135
  *
@@ -146,6 +152,73 @@ declare module '@ampcode/plugin' {
146
152
  }
147
153
  }
148
154
 
155
+ export type AgentReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high'
156
+
157
+ export type AgentToolSelection =
158
+ | readonly string[]
159
+ | 'all'
160
+ | {
161
+ /** Tool names to include. Defaults to all tools. */
162
+ include?: readonly string[] | 'all'
163
+ /** Tool names to exclude after applying include. */
164
+ exclude?: readonly string[]
165
+ }
166
+
167
+ export interface CreateAgentConfig {
168
+ /** Optional stable identifier for logs, UI, and persisted run metadata. */
169
+ name?: string
170
+ /** Model identifier in `provider/model` format, such as `anthropic/claude-sonnet-4-6`. */
171
+ model: string
172
+ /** Instructions appended to Amp's base agent prompt. */
173
+ instructions: string
174
+ /** Tools available to this agent. Use 'all' for all tools available in its runtime. */
175
+ tools?: AgentToolSelection
176
+ /** Optional reasoning effort override for models that support it. */
177
+ reasoningEffort?: AgentReasoningEffort
178
+ }
179
+
180
+ export interface AgentDefinition extends CreateAgentConfig {
181
+ readonly kind: 'agent-definition'
182
+ }
183
+
184
+ export interface RunAgentOptions {
185
+ /** Maximum time to wait for the agent run to finish, in milliseconds. */
186
+ timeoutMs?: number
187
+ /** Parent thread for this run when the agent is being used as a subagent/tool. */
188
+ parentThreadID?: ThreadID
189
+ }
190
+
191
+ export interface AgentRunResult {
192
+ /** Thread created for this run, when exposed by the runtime. */
193
+ threadID?: `T-${string}`
194
+ /** Final text response from the agent. */
195
+ text: string
196
+ }
197
+
198
+ export interface Agent {
199
+ readonly definition: AgentDefinition
200
+ run(message: string, options?: RunAgentOptions): Promise<AgentRunResult>
201
+ }
202
+
203
+ /** A plugin-defined agent mode shown by supported Amp clients. */
204
+ export interface PluginAgentModeDefinition {
205
+ /** Stable identifier within the plugin. */
206
+ key: string
207
+ /** Label shown in compact mode pickers, for example "review" or "architect". */
208
+ label: string
209
+ /** Optional longer description shown in command palettes and pickers. */
210
+ description?: string
211
+ /** Optional label color as a hex RGB string, for example "#d97706". */
212
+ color?: string
213
+ /** Agent definition used when creating a thread with this mode selected. */
214
+ agent: AgentDefinition
215
+ }
216
+
217
+ export interface PluginAgentMode extends Omit<PluginAgentModeDefinition, 'agent'> {
218
+ pluginName: string
219
+ agent: AgentDefinition
220
+ }
221
+
149
222
  /**
150
223
  * A plugin status item shown in supported Amp clients.
151
224
  */
@@ -411,12 +484,46 @@ declare module '@ampcode/plugin' {
411
484
  export type ThreadMessage = ThreadUserMessage | ThreadAssistantMessage | ThreadInfoMessage
412
485
 
413
486
  /**
414
- * Thread API for manipulating the current thread.
487
+ * Options for reading messages from a thread.
488
+ */
489
+ export interface ThreadMessagesOptions {
490
+ /**
491
+ * Where to read from. Defaults to `end` so callers read recent messages by
492
+ * default instead of accidentally loading the start of a large thread.
493
+ */
494
+ from?: 'start' | 'end'
495
+
496
+ /**
497
+ * What the offset is in relation to `from`. Defaults to 0.
498
+ */
499
+ offset?: number
500
+
501
+ /**
502
+ * Maximum number of messages to return. Clamped to 20.
503
+ */
504
+ limit?: number
505
+
506
+ /**
507
+ * Optional role filter.
508
+ */
509
+ roles?: Array<'user' | 'assistant'>
510
+ }
511
+
512
+ /**
513
+ * Thread API for reading and manipulating the current thread.
415
514
  */
416
515
  export interface PluginThread {
417
516
  /** Active thread ID for the current invocation context */
418
517
  id: ThreadID
419
518
 
519
+ /**
520
+ * Read messages from the thread in a stable plugin-facing schema.
521
+ *
522
+ * Defaults to `{ from: 'end', limit: 10 }`. The maximum `limit`
523
+ * is 20. Combine with `offset` to fetch more messages.
524
+ */
525
+ messages(options?: ThreadMessagesOptions): Promise<ThreadMessage[]>
526
+
420
527
  /**
421
528
  * Append a user message to the thread.
422
529
  */
@@ -544,7 +651,7 @@ declare module '@ampcode/plugin' {
544
651
  * This is a request that expects a response from the handler.
545
652
  */
546
653
  export interface ToolCallEvent extends ToolCall {
547
- /** The active thread for this tool invocation */
654
+ /** The active thread reference for this tool invocation. */
548
655
  thread: { id: ThreadID }
549
656
  }
550
657
 
@@ -887,6 +994,9 @@ declare module '@ampcode/plugin' {
887
994
 
888
995
  /** Scoped logger for plugin output */
889
996
  logger: PluginLogger
997
+
998
+ /** Current thread context for this tool invocation */
999
+ thread: PluginThread
890
1000
  }
891
1001
 
892
1002
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampcode/plugin",
3
- "version": "0.0.0-20260527003623-g8232386",
3
+ "version": "0.0.0-20260528003340-g17febba",
4
4
  "description": "Amp Plugin API",
5
5
  "homepage": "https://ampcode.com/manual/plugin-api",
6
6
  "author": {