@ampcode/plugin 0.0.0-20260922001754-ga9ffbd3 → 0.0.0-20260924001720-g7fda6e0

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 +41 -10
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1270,10 +1270,28 @@ declare module '@ampcode/plugin' {
1270
1270
  steer?: boolean
1271
1271
  }
1272
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
+ * Require a human response rather than an agent response. The thread owner can answer these
1280
+ * dialogs. While multiplayer is active, human contributors can also answer interactive
1281
+ * selections, confirmations, and non-secret inputs, including dialogs with `requireHuman: true`.
1282
+ * Secret inputs (`secret: true`) remain owner-only and always require a human. Dialogs targeted
1283
+ * to a specific connection are not shared with contributors.
1284
+ *
1285
+ * Use this for approval and permission prompts. It does not grant agents access to dialogs
1286
+ * or enable them to answer on the owner's behalf.
1287
+ */
1288
+ requireHuman?: boolean
1289
+ }
1290
+
1273
1291
  /**
1274
1292
  * Options for the input dialog.
1275
1293
  */
1276
- export interface PluginInputOptions {
1294
+ export interface PluginInputOptions extends PluginDialogOptions {
1277
1295
  /** Dialog title */
1278
1296
  title?: string
1279
1297
 
@@ -1306,7 +1324,7 @@ declare module '@ampcode/plugin' {
1306
1324
  /**
1307
1325
  * Options for the confirm dialog.
1308
1326
  */
1309
- export interface PluginConfirmOptions {
1327
+ export interface PluginConfirmOptions extends PluginDialogOptions {
1310
1328
  /** Dialog title */
1311
1329
  title: string
1312
1330
 
@@ -1317,21 +1335,27 @@ declare module '@ampcode/plugin' {
1317
1335
  confirmButtonText?: string
1318
1336
  }
1319
1337
 
1320
- /** An editable text field in a confirmation dialog. */
1338
+ /** A field shown in a confirmation dialog. */
1321
1339
  export interface PluginConfirmField {
1340
+ /**
1341
+ * How to show the field. Text fields are editable. Image fields show a read-only preview
1342
+ * of an HTTP(S) image URL and are omitted from the returned values. Defaults to `text`.
1343
+ */
1344
+ type?: 'text' | 'image'
1345
+
1322
1346
  /** Stable key used in the returned record */
1323
1347
  name: string
1324
1348
 
1325
1349
  /** Label shown above the field */
1326
1350
  label: string
1327
1351
 
1328
- /** Initial field value */
1352
+ /** Initial text value or, for an image field, an HTTP(S) image URL */
1329
1353
  value: string
1330
1354
 
1331
- /** Allow the field to span multiple lines */
1355
+ /** Allow a text field to span multiple lines */
1332
1356
  multiline?: boolean
1333
1357
 
1334
- /** Allow the field to be left empty. Fields are required unless this is set. */
1358
+ /** Allow a text field to be left empty. Text fields are required unless this is set. */
1335
1359
  optional?: boolean
1336
1360
  }
1337
1361
 
@@ -1343,7 +1367,7 @@ declare module '@ampcode/plugin' {
1343
1367
  /**
1344
1368
  * Options for the select dialog.
1345
1369
  */
1346
- export interface PluginSelectOptions {
1370
+ export interface PluginSelectOptions extends PluginDialogOptions {
1347
1371
  /** Dialog title */
1348
1372
  title: string
1349
1373
 
@@ -1376,8 +1400,9 @@ declare module '@ampcode/plugin' {
1376
1400
  input(options: PluginInputOptions): Promise<string | undefined>
1377
1401
 
1378
1402
  /**
1379
- * Show required editable fields in a confirmation dialog.
1380
- * @returns The edited values by field name, or undefined if cancelled.
1403
+ * Show editable text fields and read-only image previews in a confirmation dialog.
1404
+ * @returns The edited text values by field name, or undefined if cancelled. Image fields
1405
+ * are omitted.
1381
1406
  */
1382
1407
  confirm(options: PluginEditableConfirmOptions): Promise<Record<string, string> | undefined>
1383
1408
  /**
@@ -1961,7 +1986,13 @@ declare module '@ampcode/plugin' {
1961
1986
  [key: string]: unknown
1962
1987
  }
1963
1988
 
1964
- /** Execute the tool with the given input and return a result */
1989
+ /**
1990
+ * Execute the tool with the given input and return a result.
1991
+ *
1992
+ * Returning nothing is allowed and is shown to the model as `(no tool output)`. Throw an
1993
+ * error to report a failure; the model then sees a tool error instead of a successful
1994
+ * empty result.
1995
+ */
1965
1996
  execute: (
1966
1997
  input: Record<string, unknown>,
1967
1998
  ctx: PluginToolContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampcode/plugin",
3
- "version": "0.0.0-20260922001754-ga9ffbd3",
3
+ "version": "0.0.0-20260924001720-g7fda6e0",
4
4
  "description": "Amp Plugin API",
5
5
  "homepage": "https://ampcode.com/docs/plugin-api",
6
6
  "author": {