@ampcode/plugin 0.0.0-20260817001132-gbee24f5 → 0.0.0-20260818001058-gcb0a91a

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 +92 -0
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1699,4 +1699,96 @@ declare module '@ampcode/plugin' {
1699
1699
  /** Path to the skill directory, relative to the directory plugin's root. */
1700
1700
  path: string
1701
1701
  }
1702
+
1703
+ /**
1704
+ * Config for a declarative agent, the argument to {@link defineAgent} in an agent directory's
1705
+ * `agent.ts`. Amp parses this object statically, so it must be a plain object literal of
1706
+ * string, number, boolean, array, and object literals — no imports, variables, or computed
1707
+ * values. The file is required in every agent directory, but every config field is optional;
1708
+ * `defineAgent({})` is a complete config.
1709
+ */
1710
+ export interface AgentConfig {
1711
+ /** Label shown in mode pickers and thread headers, 24 characters or less. Defaults to the agent's directory name. */
1712
+ label?: string
1713
+ /** Description shown in agent listings, 500 characters or less. */
1714
+ description?: string
1715
+ /** Label color as a hex RGB string, for example "#d97706". */
1716
+ color?: string
1717
+ /**
1718
+ * Model identifier in `provider/model` format, such as `anthropic/claude-sonnet-4-6`.
1719
+ * Omit to use the default model.
1720
+ */
1721
+ model?: PluginAIModel
1722
+ /** Run entirely on Amp's thread actor without creating or attaching an executor. */
1723
+ serverOnly?: boolean
1724
+ /**
1725
+ * Built-in tools available to this agent: 'all' for all tools available in its runtime,
1726
+ * or a list of tool names with `*` suffix wildcards.
1727
+ */
1728
+ tools?: 'all' | readonly string[]
1729
+ /** Optional reasoning effort override for models that support it. */
1730
+ reasoningEffort?: AgentReasoningEffort
1731
+ /** Features required on threads created from this agent. */
1732
+ features?: readonly AgentFeature[]
1733
+ }
1734
+
1735
+ /**
1736
+ * Declare a declarative agent's config in its directory's `agent.ts`:
1737
+ *
1738
+ * ```ts
1739
+ * import { defineAgent } from '@ampcode/plugin'
1740
+ *
1741
+ * export default defineAgent({
1742
+ * description: 'Researches requests and cites primary sources',
1743
+ * model: 'openai/gpt-5-mini',
1744
+ * tools: ['web_search', 'read_web_page'],
1745
+ * reasoningEffort: 'medium',
1746
+ * })
1747
+ * ```
1748
+ *
1749
+ * Returns the config unchanged; it exists for typing and static parsing.
1750
+ */
1751
+ export function defineAgent(config: AgentConfig): AgentConfig
1752
+
1753
+ /**
1754
+ * A custom tool declared in an agent directory's `tools/<name>.ts` file, the argument to
1755
+ * {@link defineTool}. The tool's name is the filename. The `description` and `execution`
1756
+ * fields must be static literals; `inputSchema` and `execute` are real code that is not
1757
+ * statically parsed and runs where `execution` places it.
1758
+ */
1759
+ export interface AgentToolConfig {
1760
+ /** Description shown to the LLM explaining what the tool does */
1761
+ description?: string
1762
+
1763
+ /**
1764
+ * Where the tool executes. `server` tools run where the agent runs (its sandbox, no
1765
+ * repository checkout needed); `executor` tools are dispatched to the attached executor
1766
+ * at the repository checkout. Defaults to `server`.
1767
+ */
1768
+ execution?: 'server' | 'executor'
1769
+
1770
+ /** JSON Schema for the tool's input parameters */
1771
+ inputSchema: PluginToolDefinition['inputSchema']
1772
+
1773
+ /** Execute the tool with the given input and return a result */
1774
+ execute: PluginToolDefinition['execute']
1775
+ }
1776
+
1777
+ /**
1778
+ * Declare a custom tool in an agent directory's `tools/<name>.ts`:
1779
+ *
1780
+ * ```ts
1781
+ * import { defineTool } from '@ampcode/plugin'
1782
+ *
1783
+ * export default defineTool({
1784
+ * description: 'Fetch open tickets',
1785
+ * execution: 'server',
1786
+ * inputSchema: { type: 'object', properties: { query: { type: 'string' } } },
1787
+ * execute: async (input) => ({ content: [{ type: 'text', text: JSON.stringify(input) }] }),
1788
+ * })
1789
+ * ```
1790
+ *
1791
+ * Returns the tool unchanged; it exists for typing and static parsing.
1792
+ */
1793
+ export function defineTool(tool: AgentToolConfig): AgentToolConfig
1702
1794
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampcode/plugin",
3
- "version": "0.0.0-20260817001132-gbee24f5",
3
+ "version": "0.0.0-20260818001058-gcb0a91a",
4
4
  "description": "Amp Plugin API",
5
5
  "homepage": "https://ampcode.com/manual/plugin-api",
6
6
  "author": {