@ampcode/plugin 0.0.0-20261027001613-g52e251f → 0.0.0-20261028001330-gaedc463

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 +135 -1
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // sitemap-lastmod: /docs/plugin-api 2026-10-06
1
+ // sitemap-lastmod: /docs/plugin-api 2026-10-27
2
2
 
3
3
  declare module '@ampcode/plugin' {
4
4
  /**
@@ -1450,6 +1450,118 @@ declare module '@ampcode/plugin' {
1450
1450
  * steering message and is preferred when the thread next dequeues work.
1451
1451
  */
1452
1452
  appendUserMessage(message: UserMessage, options?: AppendUserMessageOptions): Promise<void>
1453
+
1454
+ /**
1455
+ * Show a quick action: a button above this thread's composer in the Amp web app, after
1456
+ * Amp's own quick actions. It is independent of the agent's turns: it stays until you call
1457
+ * `unsubscribe()` on the returned handle or the plugin stops, so create, update, and remove
1458
+ * it whenever your plugin learns something, such as in an `agent.end` handler, a webhook,
1459
+ * or a command. Amp shows up to 5 quick actions per thread across all plugins, oldest
1460
+ * first.
1461
+ *
1462
+ * Throws when the definition is invalid.
1463
+ *
1464
+ * @example
1465
+ * ```ts
1466
+ * amp.on('agent.end', async (event, ctx) => {
1467
+ * shipAction?.unsubscribe()
1468
+ * if (await looksFinished(event, ctx)) {
1469
+ * shipAction = ctx.thread.createQuickAction({
1470
+ * text: 'Send It',
1471
+ * icon: 'rocket',
1472
+ * action: 'send-message',
1473
+ * args: { message: 'Send it' },
1474
+ * })
1475
+ * }
1476
+ * })
1477
+ * ```
1478
+ */
1479
+ createQuickAction(definition: QuickActionDefinition): QuickAction
1480
+ }
1481
+
1482
+ /**
1483
+ * The actions that control the thread's UI, and the arguments each takes. A plugin runs them
1484
+ * with {@link PluginUI.perform}, and a quick action can run them on click.
1485
+ *
1486
+ * - `open-pane`: opens one of the thread's panes beside the transcript.
1487
+ * - `open-portal`: opens an `http:` or `https:` URL served from the thread's orb in the
1488
+ * Portal pane, as a portal link in the transcript does.
1489
+ */
1490
+ export interface UIActionArgs {
1491
+ 'open-pane': { pane: UIPane }
1492
+ 'open-portal': { url: string }
1493
+ }
1494
+
1495
+ /** The thread panes an `open-pane` action can open. */
1496
+ export type UIPane = 'changes' | 'files' | 'terminal' | 'desktop' | 'portal'
1497
+
1498
+ /** A UI action and its arguments, such as `{ action: 'open-pane', args: { pane: 'changes' } }`. */
1499
+ export type UIAction = {
1500
+ [A in keyof UIActionArgs]: { action: A; args: UIActionArgs[A] }
1501
+ }[keyof UIActionArgs]
1502
+
1503
+ /**
1504
+ * The actions a quick action can run, and the arguments each takes: every {@link UIActionArgs}
1505
+ * action, plus:
1506
+ *
1507
+ * - `send-message`: sends `message` as the user's next message. ⌘/Ctrl-click puts it in the
1508
+ * composer to edit first. Up to 10,000 characters.
1509
+ * - `open-url`: opens an `http:` or `https:` URL in a new browser tab.
1510
+ * - `copy`: copies `text` to the clipboard. Up to 100,000 characters.
1511
+ * - `run-command`: runs `command`, the ID of a command this plugin registered with
1512
+ * {@link PluginAPI.registerCommand}, in this thread. It needs a connected executor.
1513
+ *
1514
+ * Amp hides an `open-pane` quick action in threads that cannot show that pane, such as
1515
+ * `desktop` outside an orb.
1516
+ */
1517
+ export interface QuickActionArgs extends UIActionArgs {
1518
+ 'send-message': { message: string }
1519
+ 'open-url': { url: string }
1520
+ copy: { text: string }
1521
+ 'run-command': { command: string }
1522
+ }
1523
+
1524
+ /** An action a quick action can run. See {@link QuickActionArgs}. */
1525
+ export type QuickActionName = keyof QuickActionArgs
1526
+
1527
+ /** The icons a quick action can show, named as in Lucide (https://lucide.dev). */
1528
+ export type QuickActionIcon =
1529
+ | 'activity'
1530
+ | 'archive'
1531
+ | 'bug'
1532
+ | 'check'
1533
+ | 'copy'
1534
+ | 'external-link'
1535
+ | 'eye'
1536
+ | 'flask-conical'
1537
+ | 'git-pull-request'
1538
+ | 'message-square'
1539
+ | 'play'
1540
+ | 'refresh-cw'
1541
+ | 'rocket'
1542
+ | 'send'
1543
+ | 'sparkles'
1544
+ | 'terminal'
1545
+
1546
+ /** A quick action's button and what it does. See {@link PluginThread.createQuickAction}. */
1547
+ export type QuickActionDefinition = {
1548
+ [A in QuickActionName]: {
1549
+ /** The button's text, 1 to 40 characters, such as `Send It`. */
1550
+ text: string
1551
+ /**
1552
+ * The icon the button leads with. Without one, the button shows the action's icon, or
1553
+ * for `open-pane`, the pane's icon.
1554
+ */
1555
+ icon?: QuickActionIcon
1556
+ action: A
1557
+ args: QuickActionArgs[A]
1558
+ }
1559
+ }[QuickActionName]
1560
+
1561
+ /** A quick action shown in a thread. Unsubscribing removes it. */
1562
+ export interface QuickAction extends Subscription {
1563
+ /** Replace the quick action's text, icon, action, or arguments. Throws when invalid. */
1564
+ update(definition: QuickActionDefinition): void
1453
1565
  }
1454
1566
 
1455
1567
  /** APIs for accessing threads by ID. */
@@ -1725,6 +1837,28 @@ declare module '@ampcode/plugin' {
1725
1837
  * @returns The selected or entered value, or undefined if the user cancelled.
1726
1838
  */
1727
1839
  select(options: PluginSelectOptions): Promise<string | undefined>
1840
+
1841
+ /**
1842
+ * Run a UI action in the thread for the people viewing it in the Amp web app, such as
1843
+ * opening the Changes pane after the agent edits files. The same action objects work as
1844
+ * quick actions (see {@link PluginThread.createQuickAction}).
1845
+ *
1846
+ * A pane that is already open is left as it is, even when another tab is in front of it, so
1847
+ * calling this on every event is safe. The action reaches only the thread owner's open
1848
+ * browser tabs, opens a pane only as a tab beside the transcript (not on a phone), and does
1849
+ * not take focus. It is not queued for viewers who open the thread later. Resolves once Amp
1850
+ * accepts the action; throws when the action is invalid or there is no current thread.
1851
+ *
1852
+ * @example
1853
+ * ```ts
1854
+ * amp.on('tool.result', async (event, ctx) => {
1855
+ * if (event.status === 'done' && ['edit_file', 'create_file', 'apply_patch'].includes(event.tool)) {
1856
+ * await ctx.ui.perform({ action: 'open-pane', args: { pane: 'changes' } })
1857
+ * }
1858
+ * })
1859
+ * ```
1860
+ */
1861
+ perform(action: UIAction): Promise<void>
1728
1862
  }
1729
1863
 
1730
1864
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampcode/plugin",
3
- "version": "0.0.0-20261027001613-g52e251f",
3
+ "version": "0.0.0-20261028001330-gaedc463",
4
4
  "description": "Amp Plugin API",
5
5
  "license": "Amp Commercial License",
6
6
  "homepage": "https://ampcode.com/docs/plugin-api",