Skip to main content

What you’ll build

An agent you can feed a function, a filename, or a commit hash — and it returns the complete backstory: who proposed it, what tradeoffs were debated, which ticket it closed, what the original spec said. Five integrations, one narrative. This is the recipe that’s genuinely impossible without a federated knowledge graph. Vector search over chunks won’t link entities across sources. Copass does.

The code

import { AgentRouter } from '@copass/agent-router';
import open from 'open';

const router = new AgentRouter({
  auth: { type: 'api-key', key: process.env.COPASS_API_KEY! },
  sandboxId: process.env.COPASS_SANDBOX_ID!,
});

// Federate your team's knowledge. One sandbox, five sources.
await router.integrations.connect('github',       { onConnectUrl: open });
await router.integrations.connect('slack_v2',     { onConnectUrl: open });
await router.integrations.connect('linear',       { onConnectUrl: open });
await router.integrations.connect('notion',       { onConnectUrl: open });
await router.integrations.connect('google_drive', { onConnectUrl: open });

for await (const event of router.run({
  provider: 'anthropic',
  model: 'claude-opus-4-7',
  system: `You are a code historian. Given a function name, filename, or commit hash,
reconstruct the full decision trail:
  • GitHub — the PR that introduced it, the reviewers who pushed back, follow-up PRs.
  • Slack — the channels and threads where it was debated.
  • Linear — the ticket(s) it closed and the epic it belonged to.
  • Notion — the design doc or RFC it came from.
  • Google Drive — the original spec, diagrams, or one-pager.

Weave them into a single narrative with dates and citations. If a source is silent on this, say so.`,
  message: 'Why does handleRateLimitRetry in src/net/retry.ts exist?',
  endUserId: 'u-123',
})) {
  if (event.type === 'text')      process.stdout.write(event.text);
  if (event.type === 'tool_call') console.log(`\n${event.name}`);
}

What’s happening

  • Five connections, zero tool glue — every source lights up automatically. The agent decides which ones to reach for based on what the question needs.
  • The graph does the linking — Copass already connected the PR to the Linear ticket to the Slack thread to the Notion doc during ingestion. The agent is just reading a structure, not inferring relationships turn-by-turn.
  • claude-opus-4-7 — worth it here because the synthesis is the work. The sources are cheap; the narrative is what you’re paying for.

Make it yours

  • Scope to one repo or team…Why does handleRateLimitRetry in the payments service exist? The agent filters automatically.
  • Swap the sources — add jira and confluence for non-Linear/Notion shops; add figma to trace UI decisions. App slugs live in Pipedream’s catalog or via router.integrations.catalog({ q: 'confluence' }).
  • Ship it as a PR reviewer — point the same prompt at an incoming diff and ask why the code it’s replacing exists. Reviewers stop guessing at context.