Skip to content

Commit 4f8e3db

Browse files
authored
Merge pull request #45 from plotday/feat/http-access
Require http access permissions
2 parents 93d7c0b + 0490f8e commit 4f8e3db

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

.changeset/old-wolves-boil.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plotday/sdk": minor
3+
---
4+
5+
Changed: BREAKING: Agents are now restricted to the http URLs they request via tools.enableInternet().

sdk/cli/templates/AGENTS.template.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ constructor(id: string, protected tools: Tools) {
5959

6060
All `tools.get()` calls must occur in the constructor as they are used for dependency analysis.
6161

62+
IMPORTANT: http access is restricted to URLs requested via `tools.enableInternet([url1, url2, ...])` in the constructor. Wildcards are supported. Use `tools.enableInternet(['*'])` if full access is needed.
63+
6264
### Built-in Tools (Always Available)
6365

6466
For complete API documentation of built-in tools including all methods, types, and detailed examples, see the TypeScript definitions in your installed package at `node_modules/@plotday/sdk/src/tools/*.ts`. Each tool file contains comprehensive JSDoc documentation.

sdk/src/agent.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,4 +401,44 @@ export interface Tools {
401401
* @throws When the tool is not found or not properly configured
402402
*/
403403
get<T extends ITool>(ToolClass: ToolConstructor<T>): T;
404+
405+
/**
406+
* Enables HTTP access to the specified URLs for this agent or tool.
407+
*
408+
* **IMPORTANT**: This method must be called in the Agent or Tool constructor
409+
* to request HTTP access permissions. Without calling this method, all outbound
410+
* HTTP requests (fetch, etc.) will be blocked.
411+
*
412+
* @param urls - Array of URL patterns to allow. Supports wildcards:
413+
* - `*` - Allow access to all URLs
414+
* - `https://*.example.com` - Allow access to all subdomains
415+
* - `https://api.example.com/*` - Allow access to all paths on the domain
416+
* - `https://api.example.com/v1/*` - Allow access to specific path prefix
417+
*
418+
* @example
419+
* ```typescript
420+
* class MyAgent extends Agent<MyAgent> {
421+
* constructor(id: string, tools: Tools) {
422+
* super(id, tools);
423+
* // Request HTTP access to specific APIs
424+
* tools.enableInternet([
425+
* 'https://api.github.com/*',
426+
* 'https://api.openai.com/*'
427+
* ]);
428+
* }
429+
* }
430+
* ```
431+
*
432+
* @example
433+
* ```typescript
434+
* class MyTool extends Tool<MyTool> {
435+
* constructor(id: string, tools: Tools) {
436+
* super(id, tools);
437+
* // Request unrestricted HTTP access
438+
* tools.enableInternet(['*']);
439+
* }
440+
* }
441+
* ```
442+
*/
443+
enableInternet(urls: string[]): void;
404444
}

0 commit comments

Comments
 (0)