@respan/cli 0.12.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,7 +73,56 @@ Use this section when the user asks to set up Respan tracing in their project.
73
73
 
74
74
  The API key is stored in \`.env\` as \`RESPAN_API_KEY\`.
75
75
 
76
- ### 1. Analyze the Project
76
+ ### 1. Ask first: Auto or Full?
77
+
78
+ **Before analyzing anything, ask the user which setup they want.** This is the first question — the two branches diverge immediately.
79
+
80
+ 1. **Auto** — the fastest path. Install the core SDK and add \`Respan()\` (one line). Every LLM call from a supported direct SDK — OpenAI, Anthropic, Azure OpenAI, Bedrock, Vertex, Cohere, Together, Gemini, LiteLLM — is automatically captured as a flat span. **No decorators and no framework instrumentor, even if a framework is detected.** Best for a quick start or a live demo: traces flowing in under two minutes.
81
+ 2. **Full** — structured setup. Adds framework-specific instrumentation and/or workflow structure on top:
82
+ - **Explicit instrumentor** — for agent frameworks (LangChain, CrewAI, OpenAI Agents, Claude Agent SDK, LlamaIndex, Haystack, …) so the framework's agent / tool / chain structure is captured.
83
+ - **Decorators** — wrap the user's own functions with \`@workflow\` / \`@task\` for nested spans.
84
+
85
+ Follow only the branch the user picks; skip the other one.
86
+
87
+ > **Frameworks under Auto:** Auto never installs a framework instrumentor. If the app uses a framework (LangChain, CrewAI, an agents SDK) and the user picks Auto, they get only the flat LLM spans the underlying direct SDK emits — no agent / tool / chain structure. Capturing framework structure requires Full.
88
+
89
+ ---
90
+
91
+ ### Auto path
92
+
93
+ **A1. Detect language and package manager** — \`package.json\` (JS/TS) or \`pyproject.toml\` / \`requirements.txt\` (Python).
94
+
95
+ **A2. Install the core SDK** (pin the exact current version):
96
+ \`\`\`bash
97
+ # Python
98
+ pip install respan-ai
99
+
100
+ # TypeScript
101
+ npm install @respan/respan
102
+ \`\`\`
103
+
104
+ **A3. Add initialization code** at the top of the entrypoint, before any LLM client is created:
105
+ \`\`\`python
106
+ # Python
107
+ from respan import Respan
108
+ Respan()
109
+ \`\`\`
110
+ \`\`\`typescript
111
+ // TypeScript
112
+ import { Respan } from "@respan/respan";
113
+ const respan = new Respan();
114
+ await respan.initialize();
115
+ \`\`\`
116
+
117
+ Do **not** add decorators or a framework instrumentor. Go straight to **Verify**.
118
+
119
+ ---
120
+
121
+ ### Full path
122
+
123
+ The rest of this section is the **Full** path — follow it only if the user chose Full. It adds an explicit framework instrumentor and/or decorators on top of the core SDK.
124
+
125
+ #### 1. Analyze the Project
77
126
 
78
127
  **1a. Detect language and package manager:**
79
128
  - Check \`package.json\` (JS/TS) or \`pyproject.toml\` / \`requirements.txt\` (Python)
@@ -91,16 +140,18 @@ Check higher-priority categories first. If a match is found, use that instrument
91
140
  | OpenAI Agents SDK | \`openai-agents\` | \`@openai/agents\` | \`respan-instrumentation-openai-agents\` | \`@respan/instrumentation-openai-agents\` | [docs](https://respan.ai/docs/integrations/openai-agents-sdk.md) |
92
141
  | Claude Agent SDK | \`claude-agent-sdk\` | — | \`respan-instrumentation-claude-agent-sdk\` | — | [docs](https://respan.ai/docs/integrations/claude-agents-sdk.md) |
93
142
  | Pydantic AI | \`pydantic-ai\` | — | \`respan-instrumentation-pydantic-ai\` | — | [docs](https://respan.ai/docs/integrations/pydantic-ai.md) |
94
- | LangChain | \`langchain\` | \`langchain\` | via OpenInference | — | [docs](https://respan.ai/docs/integrations/langchain.md) |
95
- | LangGraph | \`langgraph\` | — | via OpenInference | — | [docs](https://respan.ai/docs/integrations/langgraph.md) |
143
+ | LangChain | \`langchain\` | \`langchain\` | \`respan-instrumentation-langchain\` (callback) | — | [docs](https://respan.ai/docs/integrations/langchain.md) |
144
+ | LangGraph | \`langgraph\` | — | \`respan-instrumentation-langchain\` (callback) | — | [docs](https://respan.ai/docs/integrations/langgraph.md) |
96
145
  | CrewAI | \`crewai\` | — | \`respan-instrumentation-crewai\` | — | [docs](https://respan.ai/docs/integrations/crewai.md) |
97
- | LlamaIndex | \`llama-index\` | — | via OpenInference | — | [docs](https://respan.ai/docs/integrations/llama-index.md) |
146
+ | LlamaIndex | \`llama-index\` | — | \`respan-instrumentation-llama-index\` | — | [docs](https://respan.ai/docs/integrations/llama-index.md) |
98
147
  | Haystack | \`haystack-ai\` | — | \`respan-instrumentation-haystack\` | — | [docs](https://respan.ai/docs/integrations/haystack.md) |
99
148
  | Mastra | — | \`mastra\` | — | via OTEL | [docs](https://respan.ai/docs/integrations/mastra.md) |
100
- | Google ADK | \`google-adk\` | — | via OpenInference | — | [docs](https://respan.ai/docs/integrations/google-adk.md) |
149
+ | Google ADK | \`google-adk\` | — | \`respan-instrumentation-google-adk\` | — | [docs](https://respan.ai/docs/integrations/google-adk.md) |
101
150
 
102
151
  If a Priority 1 framework is found, use its instrumentation. Do NOT also add Priority 2 instrumentation for the same provider.
103
152
 
153
+ **LangChain / LangGraph use a callback pattern, not \`Respan(instrumentations=[...])\`.** Set up \`RespanTelemetry\` and pass \`add_respan_callback(config=...)\` into the chain/graph invocation: \`from respan_tracing import RespanTelemetry\` + \`from respan_instrumentation_langchain import add_respan_callback\`. (The other Priority-1 frameworks use the standard \`Respan(instrumentations=[XInstrumentor()])\` plugin pattern.)
154
+
104
155
  **Priority 2 — Direct LLM SDKs** (only if no P1 framework covers this provider):
105
156
 
106
157
  These are **auto-instrumented** — just \`Respan()\` / \`new Respan()\`, no extra packages needed:
@@ -126,7 +177,7 @@ This is the most important step. Read the entrypoint and all files that make LLM
126
177
  - Are there **agent loops**? (e.g. a loop that calls tools until done)
127
178
  - Are there **tool calls**? (e.g. functions the LLM invokes)
128
179
 
129
- ### 2. Propose an Implementation Plan
180
+ #### 2. Propose an Implementation Plan
130
181
 
131
182
  Present the user with a concrete plan before making any changes. The plan should include:
132
183
 
@@ -179,13 +230,13 @@ def write_draft(outline):
179
230
  return client.chat.completions.create(...)
180
231
  \`\`\`
181
232
 
182
- **Ask the user which approach they prefer:**
183
- 1. **Auto-trace only** — just add init code, every LLM call is automatically captured as a flat span. Zero code changes beyond initialization. Good for quick setup or simple projects.
184
- 2. **Structured traces** — wrap existing code with workflow/task decorators for nested spans showing how the app flows. Better for complex projects with multiple LLM calls.
233
+ Within Full, pick what the app needs (they can combine):
234
+ - **Framework detected** → add its **explicit instrumentor** (or the LangChain callback). The framework auto-captures its agent / tool / chain structure — usually no manual wrapping needed.
235
+ - **Direct LLM SDK, or you want structure over your own orchestration code** → add **decorators** (\`@workflow\` / \`@task\`) to wrap the logical workflow into nested spans.
185
236
 
186
- If the user picks option 1, skip the wrappers entirely — just install + init code.
237
+ (If the user only wanted flat spans with zero code changes, that's the **Auto** path — go back to it.)
187
238
 
188
- If the user picks option 2:
239
+ When adding decorators:
189
240
  - **If multiple independent workflows are detected** (e.g. \`writeArticle()\`, \`summarizeDoc()\`, \`classifyEmail()\`), list them and ask which ones to instrument. Don't assume all of them.
190
241
  - **Show the user what the trace will look like** — describe the span hierarchy:
191
242
  \`\`\`
@@ -198,7 +249,7 @@ workflow: write_article
198
249
 
199
250
  Wait for user confirmation before proceeding.
200
251
 
201
- ### 3. Implement
252
+ #### 3. Implement
202
253
 
203
254
  **a) Install packages:**
204
255
 
@@ -245,9 +296,9 @@ await respan.initialize();
245
296
 
246
297
  **c) Add workflow wrappers** — if the user chose structured traces in the plan.
247
298
 
248
- ### 4. Verify (final test — always run this)
299
+ ### Verify (final test — always run this, both paths)
249
300
 
250
- As the final step, **run the user's program once with a small request** and confirm tracing works end to end:
301
+ As the final step — for **both** Auto and Full — **run the user's program once with a small request** and confirm tracing works end to end:
251
302
 
252
303
  - The app runs without errors
253
304
  - A trace appears at https://platform.respan.ai or via \`respan traces list --limit 5\`