Playground - Local

The fastest way to understand TrikHub is to run it yourself. These examples run an agent with Triks loaded directly in-process — no server needed. Both playgrounds support every major LLM API key so you can use your own and test it.

Clone the repository

git clone https://github.com/molefas/trikhub.git cd trikhub

Setup

# Install dependencies and build packages pnpm install pnpm build # Navigate to the example cd examples/js/local-playground # Install dependencies just for the demo npm install # Provide an LLM key to the main Agent cp .env.example .env # Edit .env and add your LLM's API KEY
# Provide an LLM key to the Trik Agent cd .trikhub cp secrets.json.example secrets.json # Edit secrets.json with your LLM's API KEY

Run

npm run dev

You should see:

[TrikGateway] Loaded 1 trik(s) from config [Triks] Loaded: trik-article-search LLM: anthropic (claude-sonnet-4-20250514) Built-in tools: get_weather, calculate, search_web Triks: trik-article-search Total tools: 6 You:

Try It Out

Article Search (uses the trik)

You: search for articles about AI Agent: I found 3 articles about AI. You: list them --- Direct Content (article-list) --- 1. **The Future of AI in Healthcare** - AI is transforming... 2. **Understanding Machine Learning** - A beginner's guide... 3. **AI Ethics and Society** - Exploring the implications... --- End --- You: show me the healthcare one --- Direct Content (article) --- # The Future of AI in Healthcare AI is revolutionizing medical diagnosis and treatment planning... --- End ---

Notice:

  • Search returns a template (“I found X articles”) - safe structured data
  • List/Details return passthrough content - delivered directly to you, bypassing the agent

Built-in Tools

You: Can you tell me the weather in Lisbon, Portugal? Agent: The weather in Lisbon is currently rainy with a temperature of 30°C (86 F). It's quite warm despite the rain!

How It Works

Template Mode (Safe for Agent)

Trik returns: { template: "success", count: 3 } Agent sees: "I found 3 articles about AI."

The agent only sees structured data (enums, numbers, IDs) - never free-form text that could contain prompt injection.

Passthrough Mode (Direct to User)

Trik returns: { content: "# Article Title\n\nFull article text..." } Agent sees: "[Content delivered directly]" You see: The full article

Content that might contain untrusted text bypasses the agent entirely.

Session State

Triks remember context. When you say “the healthcare one”, the trik resolves this reference using the history of your conversation.

Project Structure

js/local-playground/ ├── src/ │ ├── cli.ts # Interactive REPL │ ├── agent.ts # LangGraph workflow with validation │ ├── tools.ts # Built-in tools + trik loader │ └── llm.ts # LangGraph Model selection ├── .trikhub/ │ └── config.json # Installed triks │ └── secrets.json # Secrets per Trik ├── .env.example # Environment template └── package.json

What’s happening

  • Your agent calls Trik actions as LangGraph tools
  • The gateway validates input/output and manages sessions
  • Template responses give the agent safe structured data
  • Passthrough content goes directly to you (never touches the LLM)

Cross-Environment Support

Both playgrounds can run triks written in either language:

  • The TypeScript gateway can run Python triks via a worker subprocess
  • The Python gateway can run JavaScript triks via a Node.js subprocess

For a multi-language setup using HTTP, see the Server Playground.