@ampcode/plugin 0.0.0-20261029001459-g185813a → 0.0.0-20261031001138-gc59f010

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 +64 -6
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // sitemap-lastmod: /docs/plugin-api 2026-10-27
1
+ // sitemap-lastmod: /docs/plugin-api 2026-10-29
2
2
 
3
3
  declare module '@ampcode/plugin' {
4
4
  /**
@@ -116,15 +116,24 @@ declare module '@ampcode/plugin' {
116
116
  registerTool(definition: PluginToolDefinition): Subscription
117
117
 
118
118
  /**
119
- * Register an Agent Skill from this plugin's directory.
119
+ * Register an Agent Skill from this plugin's directory or its cache directory.
120
120
  *
121
- * The path must be relative to a directory plugin's root and name a directory that contains
122
- * `SKILL.md`. Amp validates the package and makes it available under the qualified name
123
- * `<plugin-name>:<skill-name>`.
121
+ * The path names a directory that contains `SKILL.md`: either relative to a directory
122
+ * plugin's root, or absolute and inside {@link PluginSystem.cacheDirectory}, for skills the
123
+ * plugin downloads or generates at runtime. Amp validates the package and makes it
124
+ * available under the qualified name `<plugin-name>:<skill-name>`; the agent loads it with
125
+ * the skill tool, which also starts any MCP servers the skill bundles. Unsubscribe to
126
+ * remove the skill. Pass `listed: false` for a skill a plugin tool hands to the agent by
127
+ * name, so it stays out of the skills list.
124
128
  *
125
129
  * @example
126
130
  * ```ts
127
131
  * await amp.registerSkill({ path: 'skills/simulator' })
132
+ *
133
+ * const dir = path.join(amp.system.cacheDirectory, 'skills', 'pdf')
134
+ * // ...write dir/SKILL.md and the skill's other files...
135
+ * await amp.registerSkill({ path: dir, listed: false })
136
+ * // ...then tell the agent to load "<plugin-name>:pdf" with the skill tool
128
137
  * ```
129
138
  */
130
139
  registerSkill(definition: PluginSkillDefinition): Promise<Subscription>
@@ -687,6 +696,7 @@ declare module '@ampcode/plugin' {
687
696
  | 'meta'
688
697
  | 'minimax'
689
698
  | 'moonshotai'
699
+ | 'nvidia'
690
700
  | 'ollama-cloud'
691
701
  | 'openai'
692
702
  | 'thinkingmachines'
@@ -1191,6 +1201,14 @@ declare module '@ampcode/plugin' {
1191
1201
  */
1192
1202
  readonly workspaceRoot: URI | null
1193
1203
 
1204
+ /**
1205
+ * Absolute path of a directory this plugin may write to, on the machine that runs the
1206
+ * plugin, such as `~/.cache/amp/plugin-cache/<plugin-name>`. It is kept across sessions
1207
+ * but may be cleared like any cache, and Amp does not create it. Skills stored here can be
1208
+ * registered with {@link PluginAPI.registerSkill}.
1209
+ */
1210
+ readonly cacheDirectory: string
1211
+
1194
1212
  /**
1195
1213
  * Get the effective Amp base URL currently used by this Amp client.
1196
1214
  * This reflects the active runtime configuration (for example, custom domains via `AMP_URL`).
@@ -1255,6 +1273,18 @@ declare module '@ampcode/plugin' {
1255
1273
  status: 'done' | 'error' | 'cancelled' | 'running' | 'pending'
1256
1274
  }
1257
1275
 
1276
+ /**
1277
+ * Token usage of the inference that produced an assistant message.
1278
+ */
1279
+ export interface ThreadMessageUsage {
1280
+ /** The model that produced the message, as the inference provider names it. */
1281
+ model?: string
1282
+ inputTokens: number
1283
+ outputTokens: number
1284
+ cacheCreationInputTokens: number | null
1285
+ cacheReadInputTokens: number | null
1286
+ }
1287
+
1258
1288
  /**
1259
1289
  * A user message in the thread.
1260
1290
  */
@@ -1264,6 +1294,9 @@ declare module '@ampcode/plugin' {
1264
1294
  /** The message ID, which is unique in the thread. */
1265
1295
  id: ThreadMessageID
1266
1296
 
1297
+ /** When the message was created, as an ISO 8601 timestamp. */
1298
+ createdAt?: string
1299
+
1267
1300
  content: (ThreadTextBlock | ThreadToolResultBlock)[]
1268
1301
  }
1269
1302
 
@@ -1276,6 +1309,18 @@ declare module '@ampcode/plugin' {
1276
1309
  /** The message ID, which is unique in the thread. */
1277
1310
  id: ThreadMessageID
1278
1311
 
1312
+ /** When the message was created, as an ISO 8601 timestamp. */
1313
+ createdAt?: string
1314
+
1315
+ /**
1316
+ * Why the message ended: `tool_use` when it calls tools, `end_turn` when the agent
1317
+ * finished, `cancelled` when the turn was cancelled.
1318
+ */
1319
+ stopReason?: 'end_turn' | 'tool_use' | 'cancelled'
1320
+
1321
+ /** Token usage of the inference that produced the message, when recorded. */
1322
+ usage?: ThreadMessageUsage
1323
+
1279
1324
  content: (ThreadTextBlock | ThreadThinkingBlock | ThreadToolUseBlock)[]
1280
1325
  }
1281
1326
 
@@ -1288,6 +1333,9 @@ declare module '@ampcode/plugin' {
1288
1333
  /** The message ID, which is unique in the thread. */
1289
1334
  id: ThreadMessageID
1290
1335
 
1336
+ /** When the message was created, as an ISO 8601 timestamp. */
1337
+ createdAt?: string
1338
+
1291
1339
  content: ThreadTextBlock[]
1292
1340
  }
1293
1341
 
@@ -2495,8 +2543,18 @@ declare module '@ampcode/plugin' {
2495
2543
  * An Agent Skill directory contributed by a plugin.
2496
2544
  */
2497
2545
  export interface PluginSkillDefinition {
2498
- /** Path to the skill directory, relative to the directory plugin's root. */
2546
+ /**
2547
+ * Path to the skill directory: relative to the directory plugin's root, or absolute and
2548
+ * inside {@link PluginSystem.cacheDirectory}.
2549
+ */
2499
2550
  path: string
2551
+
2552
+ /**
2553
+ * Set to `false` to leave the skill out of the skills list the model sees. The agent can
2554
+ * still load it with the skill tool by its qualified name, for example after a plugin tool
2555
+ * that found the skill returns that name. Defaults to `true`.
2556
+ */
2557
+ listed?: boolean
2500
2558
  }
2501
2559
 
2502
2560
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampcode/plugin",
3
- "version": "0.0.0-20261029001459-g185813a",
3
+ "version": "0.0.0-20261031001138-gc59f010",
4
4
  "description": "Amp Plugin API",
5
5
  "license": "Amp Commercial License",
6
6
  "homepage": "https://ampcode.com/docs/plugin-api",