The run command executes a TypeScript script in the Toolshed runtime with your role’s full tool catalog available. You can pass a path to a .ts file or provide an inline TypeScript expression. The command loads your credentials and role from the Toolshed server, sets up the runtime, runs the script, and prints the result as JSON.
Usage
<script> is either a path to a TypeScript file or a string of TypeScript code.
Examples
toolshed run ./my-script.ts
The output is the return value of the script, printed as formatted JSON:
{
"issues": [
{ "number": 42, "title": "Fix login bug" }
]
}
How it works
When you run toolshed run:
- The CLI reads your session token from
~/.toolshed/config.json and the server URL from TOOLSHED_SERVER
- It fetches your role and the available tool catalog from the Toolshed server
- It creates a runtime instance scoped to your role’s authorized tools
- It executes the script, routing any tool calls through the runtime
- It prints the result and disposes the runtime
Run toolshed login before using toolshed run so the CLI can authenticate against the server and fetch your tool catalog.
Environment variables
Common
| Variable | Description | Default |
|---|
TOOLSHED_SERVER | URL of the Toolshed server | http://localhost:3000 |
TOOLSHED_RUNTIME | Execution runtime: local or vercel | local |
Vercel runtime
When TOOLSHED_RUNTIME=vercel, the following variables are required:
| Variable | Description |
|---|
VERCEL_TEAM_ID | Your Vercel team ID |
VERCEL_PROJECT_ID | The Vercel project ID for the sandboxed runtime |
VERCEL_TOKEN | A Vercel API token with deployment access |
TOOLSHED_SNAPSHOT_ID | (Optional) Snapshot ID to pin the runtime version |
TOOLSHED_RUNTIME=vercel \
VERCEL_TEAM_ID=team_xxxx \
VERCEL_PROJECT_ID=prj_xxxx \
VERCEL_TOKEN=your_token \
toolshed run ./my-script.ts
Scripts run with full access to your role’s authorized tools. Review scripts carefully before executing them, especially those that call destructive or write-capable tools.