@ampcode/plugin 0.0.0-20260717002806-g76909f1 → 0.0.0-20260719002729-g9e7d25b
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 +65 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -108,6 +108,31 @@ declare module '@ampcode/plugin' {
|
|
|
108
108
|
*/
|
|
109
109
|
registerTool(definition: PluginToolDefinition): Subscription
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Register a durable generic webhook for this plugin and the owning Orb thread.
|
|
113
|
+
*
|
|
114
|
+
* The key is stable within the plugin and thread. Re-registering the same key,
|
|
115
|
+
* including after a plugin reload, returns the same capability URL. Treat the
|
|
116
|
+
* URL as a credential.
|
|
117
|
+
*
|
|
118
|
+
* Handler side effects are delivered at least once. Use `event.id` as an
|
|
119
|
+
* idempotency key because an executor can stop after the handler succeeds but
|
|
120
|
+
* before durable consumption is recorded. Handlers have 30 seconds to complete;
|
|
121
|
+
* `ctx.signal` is aborted when that deadline elapses, and the event is retried.
|
|
122
|
+
*
|
|
123
|
+
* @experimental
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* const { url } = await amp.createWebhook({
|
|
127
|
+
* key: 'deploy',
|
|
128
|
+
* handler: async (event, ctx) => {
|
|
129
|
+
* ctx.logger.log('Deployment received', event.id, event.payload)
|
|
130
|
+
* },
|
|
131
|
+
* })
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
createWebhook(options: CreateWebhookOptions): Promise<WebhookRegistration>
|
|
135
|
+
|
|
111
136
|
/** AI helpers */
|
|
112
137
|
ai: PluginAI
|
|
113
138
|
|
|
@@ -452,7 +477,7 @@ declare module '@ampcode/plugin' {
|
|
|
452
477
|
| 'vertexai'
|
|
453
478
|
| 'xai'
|
|
454
479
|
|
|
455
|
-
/** Model identifier in `provider/model` format, such as `openai/gpt-5.
|
|
480
|
+
/** Model identifier in `provider/model` format, such as `openai/gpt-5.6-sol`. */
|
|
456
481
|
export type PluginAIModel = `${PluginAIModelProvider}/${string}`
|
|
457
482
|
|
|
458
483
|
export type PluginAIFieldSchema = {
|
|
@@ -1416,6 +1441,45 @@ declare module '@ampcode/plugin' {
|
|
|
1416
1441
|
thread: PluginThread
|
|
1417
1442
|
}
|
|
1418
1443
|
|
|
1444
|
+
/** A provider-neutral webhook event delivered to a plugin handler. */
|
|
1445
|
+
export interface WebhookEvent {
|
|
1446
|
+
/** Stable server-owned event ID. Use this to make handler effects idempotent. */
|
|
1447
|
+
id: string
|
|
1448
|
+
|
|
1449
|
+
/** JSON-compatible request payload accepted by the generic webhook endpoint. */
|
|
1450
|
+
payload: unknown
|
|
1451
|
+
|
|
1452
|
+
/** Bounded string metadata recorded by the webhook ingress. */
|
|
1453
|
+
metadata: Readonly<Record<string, string>>
|
|
1454
|
+
|
|
1455
|
+
/** ISO 8601 timestamp recorded when the server accepted the webhook. */
|
|
1456
|
+
receivedAt: string
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
/** Context passed to webhook handlers for the owning thread. */
|
|
1460
|
+
export interface WebhookHandlerContext extends PluginEventContextBase {
|
|
1461
|
+
/** Thread that owns this webhook registration. */
|
|
1462
|
+
thread: PluginThread
|
|
1463
|
+
|
|
1464
|
+
/** Aborted when the handler's execution deadline elapses. */
|
|
1465
|
+
signal: AbortSignal
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
/** Options for registering a generic webhook handler. */
|
|
1469
|
+
export interface CreateWebhookOptions {
|
|
1470
|
+
/** Stable, non-whitespace-padded key within this plugin and thread (1-128 characters). */
|
|
1471
|
+
key: string
|
|
1472
|
+
|
|
1473
|
+
/** At-least-once handler for matching durable webhook events. */
|
|
1474
|
+
handler: (event: WebhookEvent, ctx: WebhookHandlerContext) => void | Promise<void>
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
/** Safe registration information returned to the plugin. */
|
|
1478
|
+
export interface WebhookRegistration {
|
|
1479
|
+
/** Capability URL for webhook POST requests. Treat this URL as a credential. */
|
|
1480
|
+
url: string
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1419
1483
|
/**
|
|
1420
1484
|
* Options for registering a tool that the agent can call.
|
|
1421
1485
|
*/
|