{
  "markdown": "# mirrorkit (Go)\n\nA lightweight, **drop-in** production trace collector for LLM agents — the Go\nsibling of the Python [`mirrorkit`](https://pypi.org/project/mirrorkit/) and\nTypeScript `mirrorkit` (npm) packages.\n\nIt does exactly one thing: **take traces you hand it and send them to your\nMirrors backend** — batched in the background, non-blocking, and safe (it never\npanics into your app after `Init`). It does **not** instrument SDKs and does\n**not** run agents; you build the trace, it ships it.\n\n## Install\n\n```bash\ngo get github.com/ai-singhal/mirrorkit-go\n```\n\nRequires **Go ≥ 1.21**. Zero dependencies (standard library only).\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"time\"\n\n\tmirrorkit \"github.com/ai-singhal/mirrorkit-go\"\n)\n\nfunc main() {\n\tmirrorkit.Init(mirrorkit.Options{APIKey: \"mk_live_...\", Project: \"my-agent\"})\n\tdefer mirrorkit.Shutdown(5 * time.Second)\n\n\tmirrorkit.LogTrace([]mirrorkit.Message{\n\t\tmirrorkit.SystemMessage(\"You are a helpful assistant.\"),\n\t\tmirrorkit.UserMessage(\"What's the weather in Paris?\"),\n\t\tmirrorkit.AssistantMessage(\"It's 18C and sunny.\"),\n\t}, mirrorkit.WithModel(\"claude-opus-4-8\"))\n}\n```\n\nEach trace is enqueued and flushed to `{endpoint}/api/collect` by a background\ngoroutine (`Authorization: Bearer <apiKey>`, body `{project, traces}`).\n\n### Tool calls\n\nBuild tool-call and tool-result messages with the helpers:\n\n```go\nmirrorkit.LogTrace([]mirrorkit.Message{\n\tmirrorkit.UserMessage(\"Cancel booking BK-4471.\"),\n\tmirrorkit.AssistantToolCalls(\n\t\tmirrorkit.NewToolCall(\"call_1\", \"cancel_booking\", map[string]any{\"id\": \"BK-4471\"}),\n\t),\n\tmirrorkit.ToolResult(\"call_1\", `{\"status\":\"cancelled\"}`),\n\tmirrorkit.AssistantMessage(\"Done — BK-4471 is cancelled.\"),\n})\n```\n\n## Options\n\n```go\nmirrorkit.Init(mirrorkit.Options{\n\tAPIKey:        \"mk_live_...\",           // required\n\tProject:       \"my-agent\",              // default \"default\"\n\tEndpoint:      \"https://api.mirror.dev\", // else MIRRORKIT_ENDPOINT / MIRROR_ENDPOINT / prod\n\tFlushInterval: 2 * time.Second,         // ms between background flushes\n\tMaxBatch:      50,                      // max traces per POST\n\tMaxQueue:      10_000,                  // in-memory cap; oldest dropped past this\n\tDebug:         false,                   // internal debug logs (or MIRRORKIT_DEBUG=1)\n})\n```\n\nEndpoint resolution: `Options.Endpoint` → `MIRRORKIT_ENDPOINT` → `MIRROR_ENDPOINT`\n→ the production default.\n\n## Lifecycle\n\n```go\nmirrorkit.Flush(5 * time.Second)     // block until the queue drains\nmirrorkit.Shutdown(5 * time.Second)  // stop the background goroutine (flushes first)\n```\n\nPrefer one collector per process via the package-level `Init` / `LogTrace` /\n`Flush` / `Shutdown`. For multiple independent collectors, use `NewClient` and\ncall `LogTrace` / `Flush` / `Shutdown` on the returned `*Client`.\n\n## Testing\n\n```bash\ncd mirrorkit-go && go vet ./... && go test ./...\n```\n",
  "bytes": 2870,
  "sha": "64d6135ce2b9d70e44f637e179712d5576484366ef5942323ab040233832d92a",
  "repo_slug": "ai-singhal/mirrorkit-go",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_com_runmirrors_mirrors_b19f51f2/readme"
}