# Deno — Secure Runtime for AI Agent Scripts > Modern JavaScript/TypeScript runtime with built-in security, native TypeScript support, and web-standard APIs. Deno runs AI agent scripts safely with permission controls. ## Install Save as a script file and run: ## Quick Use ```bash # Install Deno curl -fsSL https://deno.land/install.sh | sh ``` ```typescript // ai_agent.ts — run with: deno run --allow-net ai_agent.ts const response = await fetch("https://api.anthropic.com/v1/messages", { method: "POST", headers: { "x-api-key": Deno.env.get("ANTHROPIC_API_KEY")!, "content-type": "application/json", "anthropic-version": "2023-06-01", }, body: JSON.stringify({ model: "claude-sonnet-4-20250514", max_tokens: 1024, messages: [{ role: "user", content: "Hello Claude!" }], }), }); const data = await response.json(); console.log(data.content[0].text); ``` ## What is Deno? Deno is a modern JavaScript/TypeScript runtime created by Ryan Dahl (the original creator of Node.js). It fixes Node.js design mistakes with built-in TypeScript support, web-standard APIs (fetch, WebSocket, etc.), and a permission-based security model. For AI applications, Deno is ideal for running agent scripts safely — network, file, and environment access must be explicitly granted. **Answer-Ready**: Deno is a secure JS/TS runtime by Node.js creator Ryan Dahl. Native TypeScript, web-standard APIs, permission-based security. Ideal for AI agent scripts with controlled access. Built-in formatter, linter, and test runner. 100k+ GitHub stars. **Best for**: Developers writing AI agent scripts needing security controls. **Works with**: Any LLM API, MCP servers, Claude Code extensions. **Setup time**: Under 1 minute. ## Core Features ### 1. Permission-Based Security ```bash # Explicit permissions — agent can only access what you allow deno run --allow-net=api.anthropic.com --allow-env=ANTHROPIC_API_KEY agent.ts # Deny all by default deno run agent.ts # Error: network access denied ``` ### 2. Native TypeScript ```typescript // No tsconfig, no build step, just run interface AgentResponse { thought: string; action: string; result: string; } const response: AgentResponse = await runAgent(query); ``` ### 3. Web Standard APIs ```typescript // fetch, WebSocket, TextEncoder — all built in const ws = new WebSocket("wss://stream.example.com"); ws.onmessage = (e) => console.log(e.data); // ReadableStream for streaming LLM responses const stream = response.body!.pipeThrough(new TextDecoderStream()); for await (const chunk of stream) { Deno.stdout.write(new TextEncoder().encode(chunk)); } ``` ### 4. Built-in Toolchain ```bash deno fmt # Format code deno lint # Lint code deno test # Run tests deno compile # Compile to single binary deno jupyter # Jupyter notebook kernel ``` ### 5. npm Compatibility ```typescript // Use any npm package with npm: specifier import Anthropic from "npm:@anthropic-ai/sdk"; import OpenAI from "npm:openai"; ``` ## Deno vs Node.js for AI Scripts | Feature | Deno | Node.js | |---------|------|---------| | TypeScript | Native | Needs tsc/tsx | | Security | Permission-based | Full access | | fetch API | Built-in | Node 18+ | | Package manager | URL imports + npm: | npm/yarn/pnpm | | Single binary compile | Yes | pkg/nexe | | Top-level await | Yes | ESM only | ## FAQ **Q: Can I use npm packages?** A: Yes, use `npm:package-name` imports. Most npm packages work out of the box. **Q: Is Deno good for MCP servers?** A: Yes, the permission model is perfect for MCP servers — grant only the access each server needs. **Q: How does it compare to Bun?** A: Bun focuses on speed and Node compatibility. Deno focuses on security and web standards. For AI agents, Deno's permission model is a significant advantage. ## Source & Thanks > Created by [Ryan Dahl](https://github.com/denoland). Licensed under MIT. > > [denoland/deno](https://github.com/denoland/deno) — 100k+ stars ## 快速使用 ```bash curl -fsSL https://deno.land/install.sh | sh ``` 安全运行 TypeScript AI Agent 脚本,无需配置。 ## 什么是 Deno? Deno 是 Node.js 创始人打造的现代 JS/TS 运行时。原生 TypeScript、Web 标准 API、权限安全模型,适合运行 AI Agent 脚本。 **一句话总结**:安全 JS/TS 运行时,原生 TypeScript + 权限控制 + Web 标准 API,Node.js 创始人出品,AI Agent 脚本理想选择,100k+ stars。 **适合人群**:编写 AI Agent 脚本需要安全控制的开发者。 ## 核心功能 ### 1. 权限安全 网络/文件/环境变量访问需显式授权。 ### 2. 原生 TypeScript 无需配置,直接运行 .ts 文件。 ### 3. npm 兼容 `npm:` 前缀使用任意 npm 包。 ## 常见问题 **Q: 能用 npm 包?** A: 可以,`npm:package-name` 导入。 **Q: 适合写 MCP 服务器?** A: 非常适合,权限模型完美匹配。 ## 来源与致谢 > [denoland/deno](https://github.com/denoland/deno) — 100k+ stars, MIT --- Source: https://tokrepo.com/en/workflows/568daf2d-ffc9-4aa6-81d6-e17c843c9bd3 Author: Script Depot