@ampcode/plugin 0.0.0-20260921001857-g6fa23da → 0.0.0-20260923001649-g009f5d9

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 +107 -8
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -129,6 +129,24 @@ declare module '@ampcode/plugin' {
129
129
  */
130
130
  registerSkill(definition: PluginSkillDefinition): Promise<Subscription>
131
131
 
132
+ /**
133
+ * Register a text pattern that Amp turns into a link wherever it appears in a thread
134
+ * transcript: user messages and the prose of assistant replies.
135
+ *
136
+ * Amp records the patterns on each thread this plugin's executor connects to, so readers
137
+ * who open the thread later without an executor still see the links.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * amp.registerLinkPattern({
142
+ * id: 'issue',
143
+ * pattern: 'ENG-\\d{1,6}',
144
+ * href: 'https://linear.app/acme/issue/{{match}}',
145
+ * })
146
+ * ```
147
+ */
148
+ registerLinkPattern(definition: PluginLinkPatternDefinition): Subscription
149
+
132
150
  /**
133
151
  * Register a callback that runs before this plugin instance is stopped.
134
152
  *
@@ -1252,10 +1270,25 @@ declare module '@ampcode/plugin' {
1252
1270
  steer?: boolean
1253
1271
  }
1254
1272
 
1273
+ /**
1274
+ * Options shared by the dialogs that wait for an answer (`ui.input`, `ui.confirm`, and
1275
+ * `ui.select`).
1276
+ */
1277
+ export interface PluginDialogOptions {
1278
+ /**
1279
+ * Mark this dialog as one only the thread owner may answer in person. Without it, an agent
1280
+ * acting for the owner, such as a Puck thread that created and supervises this thread, may
1281
+ * be allowed to answer on the owner's behalf. Set this when the dialog is a deterministic
1282
+ * gate, such as a permission or approval prompt, so that only a human can pass it. Agents
1283
+ * can still see what the dialog asks. Secret inputs (`secret: true`) always require a human.
1284
+ */
1285
+ requireHuman?: boolean
1286
+ }
1287
+
1255
1288
  /**
1256
1289
  * Options for the input dialog.
1257
1290
  */
1258
- export interface PluginInputOptions {
1291
+ export interface PluginInputOptions extends PluginDialogOptions {
1259
1292
  /** Dialog title */
1260
1293
  title?: string
1261
1294
 
@@ -1288,7 +1321,7 @@ declare module '@ampcode/plugin' {
1288
1321
  /**
1289
1322
  * Options for the confirm dialog.
1290
1323
  */
1291
- export interface PluginConfirmOptions {
1324
+ export interface PluginConfirmOptions extends PluginDialogOptions {
1292
1325
  /** Dialog title */
1293
1326
  title: string
1294
1327
 
@@ -1299,19 +1332,28 @@ declare module '@ampcode/plugin' {
1299
1332
  confirmButtonText?: string
1300
1333
  }
1301
1334
 
1302
- /** An editable, required text field in a confirmation dialog. */
1335
+ /** A field shown in a confirmation dialog. */
1303
1336
  export interface PluginConfirmField {
1337
+ /**
1338
+ * How to show the field. Text fields are editable. Image fields show a read-only preview
1339
+ * of an HTTP(S) image URL and are omitted from the returned values. Defaults to `text`.
1340
+ */
1341
+ type?: 'text' | 'image'
1342
+
1304
1343
  /** Stable key used in the returned record */
1305
1344
  name: string
1306
1345
 
1307
1346
  /** Label shown above the field */
1308
1347
  label: string
1309
1348
 
1310
- /** Initial field value */
1349
+ /** Initial text value or, for an image field, an HTTP(S) image URL */
1311
1350
  value: string
1312
1351
 
1313
- /** Allow the field to span multiple lines */
1352
+ /** Allow a text field to span multiple lines */
1314
1353
  multiline?: boolean
1354
+
1355
+ /** Allow a text field to be left empty. Text fields are required unless this is set. */
1356
+ optional?: boolean
1315
1357
  }
1316
1358
 
1317
1359
  /** Options for a confirmation dialog that returns edited field values. */
@@ -1322,7 +1364,7 @@ declare module '@ampcode/plugin' {
1322
1364
  /**
1323
1365
  * Options for the select dialog.
1324
1366
  */
1325
- export interface PluginSelectOptions {
1367
+ export interface PluginSelectOptions extends PluginDialogOptions {
1326
1368
  /** Dialog title */
1327
1369
  title: string
1328
1370
 
@@ -1355,8 +1397,9 @@ declare module '@ampcode/plugin' {
1355
1397
  input(options: PluginInputOptions): Promise<string | undefined>
1356
1398
 
1357
1399
  /**
1358
- * Show required editable fields in a confirmation dialog.
1359
- * @returns The edited values by field name, or undefined if cancelled.
1400
+ * Show editable text fields and read-only image previews in a confirmation dialog.
1401
+ * @returns The edited text values by field name, or undefined if cancelled. Image fields
1402
+ * are omitted.
1360
1403
  */
1361
1404
  confirm(options: PluginEditableConfirmOptions): Promise<Record<string, string> | undefined>
1362
1405
  /**
@@ -1541,6 +1584,14 @@ declare module '@ampcode/plugin' {
1541
1584
 
1542
1585
  /** The message ID */
1543
1586
  id: ThreadMessageID
1587
+
1588
+ /**
1589
+ * Set when a client's canned changes workflow started this turn: `ship` for the Ship
1590
+ * button and `push_branch` for Push to Branch. Absent for prompts the user typed.
1591
+ * Use it to append workflow-specific instructions (for example, issue-tracker follow-up
1592
+ * after shipping) instead of matching on the prompt text.
1593
+ */
1594
+ changesWorkflow?: 'ship' | 'push_branch'
1544
1595
  }
1545
1596
 
1546
1597
  /**
@@ -1594,6 +1645,52 @@ declare module '@ampcode/plugin' {
1594
1645
  maxContinuations?: number
1595
1646
  } | void
1596
1647
 
1648
+ /**
1649
+ * Event payload for changes.prompt event.
1650
+ * Fired when a client prepares the prompt behind its Ship or Push to Branch button, before
1651
+ * the user sees it. The Ship dialog shows the assembled prompt, so the user can edit anything a
1652
+ * plugin adds before sending.
1653
+ */
1654
+ export interface ChangesPromptEvent {
1655
+ /** The thread whose changes are about to be shipped or pushed */
1656
+ thread: { id: ThreadID }
1657
+
1658
+ /** `ship` for the Ship button, `push_branch` for Push to Branch */
1659
+ workflow: 'ship' | 'push_branch'
1660
+ }
1661
+
1662
+ /**
1663
+ * Result returned from a changes.prompt handler.
1664
+ * Return `append` to add instructions after the prompt, such as issue-tracker follow-up steps
1665
+ * for the shipped commits. Every plugin's `append` is added, in plugin load order.
1666
+ */
1667
+ export type ChangesPromptResult = { append?: string } | void
1668
+
1669
+ /**
1670
+ * A text pattern that Amp turns into a link in thread transcripts.
1671
+ * See {@link PluginAPI.registerLinkPattern}.
1672
+ */
1673
+ export interface PluginLinkPatternDefinition {
1674
+ /** Stable identifier within this plugin, such as `issue`. Letters, digits, and hyphens; up to 64 characters. */
1675
+ id: string
1676
+
1677
+ /**
1678
+ * Regular expression source that matches one token, such as `ENG-\d{1,6}`, written
1679
+ * without anchors, flags, or delimiters. Amp compiles it with the `u` flag, requires a
1680
+ * token boundary on both sides, and limits it to 200 characters. Backreferences and
1681
+ * lookbehind are rejected, as is a pattern that matches the empty string. Named capture
1682
+ * groups can be used in `href`.
1683
+ */
1684
+ pattern: string
1685
+
1686
+ /**
1687
+ * URL template for the link. `{{match}}` is replaced with the whole match and
1688
+ * `{{name}}` with the named capture group `name`, both URL-encoded. The result must be an
1689
+ * `http:` or `https:` URL, or an absolute path on Amp such as `/admin/bug-reports/{{match}}`.
1690
+ */
1691
+ href: string
1692
+ }
1693
+
1597
1694
  /**
1598
1695
  * Map of event names to their payload types.
1599
1696
  */
@@ -1603,6 +1700,7 @@ declare module '@ampcode/plugin' {
1603
1700
  'tool.result': ToolResultEvent
1604
1701
  'agent.start': AgentStartEvent
1605
1702
  'agent.end': AgentEndEvent
1703
+ 'changes.prompt': ChangesPromptEvent
1606
1704
  }
1607
1705
 
1608
1706
  /**
@@ -1614,6 +1712,7 @@ declare module '@ampcode/plugin' {
1614
1712
  'tool.result': ToolResultResult
1615
1713
  'agent.start': AgentStartResult
1616
1714
  'agent.end': AgentEndResult
1715
+ 'changes.prompt': ChangesPromptResult
1617
1716
  }
1618
1717
 
1619
1718
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampcode/plugin",
3
- "version": "0.0.0-20260921001857-g6fa23da",
3
+ "version": "0.0.0-20260923001649-g009f5d9",
4
4
  "description": "Amp Plugin API",
5
5
  "homepage": "https://ampcode.com/docs/plugin-api",
6
6
  "author": {