@tpmjs/registry-execute 0.1.0 → 0.1.2

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/README.md +78 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -13,16 +13,20 @@ pnpm add @tpmjs/registry-execute
13
13
  ## Usage
14
14
 
15
15
  ```typescript
16
- import { Agent } from 'ai';
16
+ import { streamText } from 'ai';
17
+ import { anthropic } from '@ai-sdk/anthropic';
17
18
  import { registrySearchTool } from '@tpmjs/registry-search';
18
19
  import { registryExecuteTool } from '@tpmjs/registry-execute';
19
20
 
20
- const agent = new Agent({
21
- model: 'anthropic/claude-sonnet-4-20250514',
21
+ const result = streamText({
22
+ model: anthropic('claude-sonnet-4-20250514'),
22
23
  tools: {
23
24
  registrySearch: registrySearchTool,
24
25
  registryExecute: registryExecuteTool,
25
26
  },
27
+ system: `You have access to the TPMJS tool registry.
28
+ Use registrySearch to find tools, then registryExecute to run them.`,
29
+ prompt: 'Search for web scraping tools and scrape https://example.com',
26
30
  });
27
31
 
28
32
  // The agent can now:
@@ -86,10 +90,81 @@ export TPMJS_API_URL=https://registry.mycompany.com
86
90
  export TPMJS_EXECUTOR_URL=https://executor.mycompany.com
87
91
  ```
88
92
 
93
+ ## Passing API Keys to Tools
94
+
95
+ Many tools require API keys to function (e.g., web scraping tools need a Firecrawl key, search tools need an Exa key). The `env` parameter lets you pass these securely.
96
+
97
+ ### How It Works
98
+
99
+ 1. **Search returns required keys**: When you search for a tool, the response includes `requiredEnvVars`:
100
+ ```json
101
+ {
102
+ "toolId": "@firecrawl/ai-sdk::scrapeTool",
103
+ "requiredEnvVars": ["FIRECRAWL_API_KEY"]
104
+ }
105
+ ```
106
+
107
+ 2. **Pass keys when executing**: Include the required keys in the `env` parameter:
108
+ ```typescript
109
+ registryExecute({
110
+ toolId: '@firecrawl/ai-sdk::scrapeTool',
111
+ params: { url: 'https://example.com' },
112
+ env: { FIRECRAWL_API_KEY: 'fc-xxx' }
113
+ })
114
+ ```
115
+
116
+ 3. **Keys are injected into sandbox**: The executor injects these as environment variables in the isolated Deno runtime where the tool runs.
117
+
118
+ ### Example: Agent with Pre-configured Keys
119
+
120
+ ```typescript
121
+ import { streamText } from 'ai';
122
+ import { anthropic } from '@ai-sdk/anthropic';
123
+ import { registrySearchTool } from '@tpmjs/registry-search';
124
+ import { registryExecuteTool } from '@tpmjs/registry-execute';
125
+
126
+ // Pre-configure API keys your agent can use
127
+ const API_KEYS = {
128
+ FIRECRAWL_API_KEY: process.env.FIRECRAWL_API_KEY,
129
+ EXA_API_KEY: process.env.EXA_API_KEY,
130
+ };
131
+
132
+ const result = streamText({
133
+ model: anthropic('claude-sonnet-4-20250514'),
134
+ tools: {
135
+ registrySearch: registrySearchTool,
136
+ registryExecute: registryExecuteTool,
137
+ },
138
+ system: `You have access to the TPMJS tool registry.
139
+ When executing tools, use these API keys in the env parameter:
140
+ ${JSON.stringify(API_KEYS, null, 2)}
141
+
142
+ If a tool requires a key you don't have, tell the user.`,
143
+ prompt: 'Scrape https://example.com and summarize the content',
144
+ });
145
+ ```
146
+
147
+ ### Tools Without Required Keys
148
+
149
+ Some tools don't require any API keys (like `@tpmjs/createblogpost`). For these, you can omit the `env` parameter entirely:
150
+
151
+ ```typescript
152
+ registryExecute({
153
+ toolId: '@tpmjs/createblogpost::createBlogPostTool',
154
+ params: {
155
+ title: 'My Post',
156
+ author: 'Jane Doe',
157
+ content: 'Hello world...'
158
+ }
159
+ // No env needed
160
+ })
161
+ ```
162
+
89
163
  ## Security
90
164
 
91
165
  - All tools run in a sandboxed Deno environment on Railway
92
166
  - API keys are passed per-request, never stored
167
+ - Keys are isolated to the specific tool execution
93
168
  - Only registered tools can be executed (no arbitrary code)
94
169
 
95
170
  ## Related
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpmjs/registry-execute",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Execute tools from the TPMJS registry in any AI SDK agent",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",