{"id":49066801,"url":"https://github.com/scobb/nexus-example","last_synced_at":"2026-04-20T05:09:19.940Z","repository":{"id":350367648,"uuid":"1206525583","full_name":"scobb/nexus-example","owner":"scobb","description":"Minimal TypeScript example: LangChain agent with Nexus trace + span observability","archived":false,"fork":false,"pushed_at":"2026-04-10T02:12:23.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-10T04:12:25.267Z","etag":null,"topics":["ai-agents","example","langchain","nexus","observability","tracing","typescript"],"latest_commit_sha":null,"homepage":"https://nexus.keylightdigital.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scobb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-10T02:10:21.000Z","updated_at":"2026-04-10T02:12:27.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/scobb/nexus-example","commit_stats":null,"previous_names":["scobb/nexus-example"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/scobb/nexus-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scobb%2Fnexus-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scobb%2Fnexus-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scobb%2Fnexus-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scobb%2Fnexus-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scobb","download_url":"https://codeload.github.com/scobb/nexus-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scobb%2Fnexus-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32033759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agents","example","langchain","nexus","observability","tracing","typescript"],"created_at":"2026-04-20T05:09:19.159Z","updated_at":"2026-04-20T05:09:19.935Z","avatar_url":"https://github.com/scobb.png","language":"TypeScript","readme":"# nexus-example\n\n[![Nexus](https://img.shields.io/badge/observability-Nexus-6366f1)](https://nexus.keylightdigital.dev)\n[![LangChain](https://img.shields.io/badge/framework-LangChain-1c3c3c)](https://js.langchain.com)\n[![TypeScript](https://img.shields.io/badge/language-TypeScript-3178c6)](https://www.typescriptlang.org)\n[![License: MIT](https://img.shields.io/badge/license-MIT-green)](./LICENSE)\n\nA minimal TypeScript project showing how to instrument a **LangChain ReAct agent** with **[Nexus](https://nexus.keylightdigital.dev)** — trace every agent run, see every tool call, and debug failures in seconds.\n\n\u003e **Nexus** is the \"Plausible Analytics for AI agents\" — lightweight, privacy-friendly observability built on Cloudflare.\n\n---\n\n## What you'll see in the dashboard\n\nAfter running the example you'll find a trace like this in your [Nexus dashboard](https://nexus.keylightdigital.dev/dashboard/traces):\n\n```\nResearch: What are the latest features in TypeScript 5.x…   success  1.2s\n  ├── llm:react-agent           ok    1.1s   input: {question}   output: {answer}\n  ├── tool:web_search           ok    12ms   input: {query}      output: {result}\n  └── tool:calculator           ok    \u003c1ms   input: {expr}       output: {result}\n```\n\nEach span shows its name, status, duration, inputs, and outputs — no extra setup required.\n\n---\n\n## Prerequisites\n\n- Node.js 18+\n- An OpenAI API key — [get one here](https://platform.openai.com/api-keys)\n- A free Nexus account — [sign up here](https://nexus.keylightdigital.dev/register) (takes 30 seconds, no credit card)\n\n---\n\n## Run in 2 minutes\n\n### 1. Clone the repo\n\n```bash\ngit clone https://github.com/scobb/nexus-example.git\ncd nexus-example\n```\n\n### 2. Install dependencies\n\n```bash\nnpm install\n```\n\n### 3. Configure your API keys\n\n```bash\ncp .env.example .env\n```\n\nOpen `.env` and fill in:\n\n```env\nNEXUS_API_KEY=nxs_your_api_key_here    # from nexus.keylightdigital.dev/dashboard/keys\nOPENAI_API_KEY=sk-your_key_here        # from platform.openai.com/api-keys\n```\n\n**Get your Nexus API key:**\n1. Go to [nexus.keylightdigital.dev/register](https://nexus.keylightdigital.dev/register)\n2. Sign in with your email (magic link, no password)\n3. Go to **Dashboard → API Keys → Create new key**\n4. Copy the key into your `.env`\n\n### 4. Run the agent\n\n```bash\nnpm run dev\n```\n\nYou'll see output like:\n\n```\nQuestion: What are the latest features in TypeScript 5.x?\n\nNexus trace: https://nexus.keylightdigital.dev/t/abc123...\n\nAnswer: TypeScript 5.x introduced several improvements including...\n\nTrace complete (success) — view at:\n  https://nexus.keylightdigital.dev/t/abc123...\n```\n\nClick the trace URL to see the full span waterfall in your dashboard.\n\n### 5. Ask your own question\n\n```bash\nnpm run dev -- \"How many planets are in the solar system, and what is 8 * 365?\"\n```\n\n---\n\n## How it works\n\nThe instrumentation is three function calls around your existing agent code:\n\n```typescript\n// 1. Start a trace (marks the run as \"running\")\nconst { trace_id } = await createTrace(\"Research: my question\");\n\n// 2. Run your LangChain agent normally\nconst result = await executor.invoke({ input: question });\n\n// 3. Record spans for LLM calls and tool calls\nawait createSpan(traceId, \"llm:react-agent\", { input }, { output }, startedAt);\n\n// 4. Finish the trace (marks it \"success\" or \"error\")\nawait finishTrace(traceId, \"success\");\n```\n\nEach tool (`web_search`, `calculator`) also records its own span so you can see exactly what data was retrieved and how long each tool took.\n\nSee [`src/index.ts`](./src/index.ts) for the full annotated implementation.\n\n---\n\n## Project structure\n\n```\nnexus-example/\n├── src/\n│   └── index.ts        # LangChain agent + Nexus instrumentation\n├── .env.example        # API key placeholders\n├── package.json\n├── tsconfig.json\n└── README.md\n```\n\n---\n\n## Adapting this to your agent\n\n1. Replace the `web_search` and `calculator` tools with your own tools\n2. Change `agent_id: \"langchain-research-agent\"` to a meaningful name for your agent\n3. Add `metadata` to `finishTrace()` to capture any run-level context (user ID, session ID, etc.)\n\nFor more frameworks (CrewAI, DSPy, LlamaIndex, Anthropic SDK) see the [Nexus docs](https://nexus.keylightdigital.dev/docs).\n\n---\n\n## Links\n\n- **[Nexus dashboard](https://nexus.keylightdigital.dev/dashboard)** — view your traces\n- **[Nexus docs](https://nexus.keylightdigital.dev/docs)** — API reference + SDK quickstarts\n- **[Nexus repo](https://github.com/scobb/nexus)** — the open-source Nexus control plane\n- **[LangChain JS docs](https://js.langchain.com/docs)** — LangChain TypeScript documentation\n\n---\n\n## License\n\nMIT — use freely, attribution appreciated.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscobb%2Fnexus-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscobb%2Fnexus-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscobb%2Fnexus-example/lists"}