@sourcegraph/amp-sdk 0.1.0-20251014160341-g7c5de51 → 0.1.0-20251021152627-g8658f12

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/README.md CHANGED
@@ -191,6 +191,38 @@ for await (const message of execute({
191
191
  }
192
192
  ```
193
193
 
194
+ ### Tool Permissions
195
+
196
+ Control which tools Amp can use with fine-grained permissions:
197
+
198
+ ```typescript
199
+ import { execute, createPermission } from '@sourcegraph/amp-sdk'
200
+
201
+ for await (const message of execute({
202
+ prompt: 'List files and run tests',
203
+ options: {
204
+ permissions: [
205
+ // Allow listing files
206
+ createPermission('Bash', 'allow', { matches: { cmd: 'ls *' } }),
207
+ // Allow running tests
208
+ createPermission('Bash', 'allow', { matches: { cmd: 'npm test' } }),
209
+ // Ask before reading sensitive files
210
+ createPermission('Read', 'ask', { matches: { path: '/etc/*' } }),
211
+ ],
212
+ },
213
+ })) {
214
+ // Process messages
215
+ }
216
+ ```
217
+
218
+ Permission rules support:
219
+
220
+ - **Pattern matching**: Use `*` wildcards and regex patterns
221
+ - **Context control**: Restrict rules to main thread or sub-agents
222
+ - **Delegation**: Delegate permission decisions to external programs
223
+
224
+ Learn more about permissions in the [manual](https://ampcode.com/manual#permissions) and the [appendix](https://ampcode.com/manual/appendix#permissions-reference).
225
+
194
226
  ## Advanced Usage
195
227
 
196
228
  ### Interactive Progress Tracking
package/dist/index.d.ts CHANGED
@@ -5,17 +5,16 @@
5
5
  * run Amp programmatically in Node.js applications. It wraps the Amp CLI
6
6
  * with the --stream-json flag to provide structured output.
7
7
  */
8
- import { type ExecuteOptions, type StreamMessage, type UserInputMessage } from './types.js';
9
- /**
10
- * Execute a command with Amp CLI and return an async iterator of messages
11
- *
12
- * @param options Execute configuration including prompt and options
13
- * @returns Async iterator of stream messages from Amp CLI
14
- */
8
+ import { type ExecuteOptions, type Permission, type PermissionMatchCondition, type StreamMessage, type UserInputMessage } from './types.js';
9
+ /** Execute a command with Amp CLI and return an async iterator of messages */
15
10
  export declare function execute(options: ExecuteOptions): AsyncIterable<StreamMessage>;
16
- /**
17
- * Helper function to create streaming input messages
18
- */
11
+ /** Create a user input message for streaming conversations */
19
12
  export declare function createUserMessage(text: string): UserInputMessage;
13
+ /** Create a permission object for controlling tool usage */
14
+ export declare function createPermission(tool: string, action: 'allow' | 'reject' | 'ask' | 'delegate', options?: {
15
+ matches?: Record<string, PermissionMatchCondition>;
16
+ context?: 'thread' | 'subagent';
17
+ to?: string;
18
+ }): Permission;
20
19
  export * from './types.js';
21
20
  //# sourceMappingURL=index.d.ts.map