@amplitude/ai 0.3.6 → 0.3.7
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.
- package/AGENTS.md +6 -4
- package/README.md +34 -36
- package/amplitude-ai.md +10 -26
- package/bin/amplitude-ai.mjs +16 -4
- package/dist/bound-agent.d.ts.map +1 -1
- package/dist/providers/mistral.d.ts.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/llms-full.txt +4 -1
- package/llms.txt +1 -1
- package/mcp.schema.json +1 -1
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AGENTS.md
|
|
2
2
|
|
|
3
|
-
Package: `@amplitude/ai` v0.3.
|
|
3
|
+
Package: `@amplitude/ai` v0.3.7
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -53,12 +53,12 @@ Codex auto-reads this `AGENTS.md` file for context.
|
|
|
53
53
|
|
|
54
54
|
## Decision Tree
|
|
55
55
|
|
|
56
|
-
-
|
|
57
|
-
- Already have a provider client: use `wrap()`
|
|
58
|
-
- Need user/session lineage: use `ai.agent(...).session(...)`.
|
|
56
|
+
- **Default: use `ai.agent(...).session(...)` with provider wrappers** — gives you every event type, per-user analytics, session enrichment, quality scoring.
|
|
57
|
+
- Already have a provider client: use `wrap()` to instrument it.
|
|
59
58
|
- Multiple agents collaborating: use `session.runAs(childAgent, fn)` for automatic identity propagation.
|
|
60
59
|
- Need tool telemetry: use `tool()`.
|
|
61
60
|
- Need span/observability: use `observe()`.
|
|
61
|
+
- Cannot modify call sites at all: use `patch()` for aggregate-only monitoring (no per-user analytics).
|
|
62
62
|
- Need agent-assistant guidance: run MCP prompt `instrument_app`.
|
|
63
63
|
|
|
64
64
|
## MCP Surface
|
|
@@ -102,6 +102,8 @@ Prompt:
|
|
|
102
102
|
|
|
103
103
|
## CLI
|
|
104
104
|
|
|
105
|
+
- `amplitude-ai` — Print instrumentation prompt for AI coding agents
|
|
106
|
+
- `amplitude-ai --print-guide` — Print the full amplitude-ai.md guide to stdout
|
|
105
107
|
- `amplitude-ai mcp` — Start the MCP server for AI coding agents
|
|
106
108
|
- `amplitude-ai doctor [--json]` — Validate environment, deps, and event pipeline
|
|
107
109
|
- `amplitude-ai status [--json]` — Show SDK version, installed providers, and env config
|
package/README.md
CHANGED
|
@@ -51,14 +51,19 @@ The CLI prints a prompt to paste into any AI coding agent (Cursor, Claude Code,
|
|
|
51
51
|
|
|
52
52
|
The agent reads the guide, scans your project, discovers your agents and LLM call sites, and instruments everything — provider wrappers, session lifecycle, multi-agent delegation, tool tracking, scoring, and a verification test. You review and approve each step.
|
|
53
53
|
|
|
54
|
-
###
|
|
54
|
+
### Manual setup
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
Whether you use a coding agent or set up manually, the goal is the same: **full instrumentation** — agents + sessions + provider wrappers. This gives you every event type, per-user analytics, and server-side enrichment.
|
|
57
|
+
|
|
58
|
+
Follow the [code example above](#amplitude-ai) to get started. The pattern is:
|
|
59
|
+
|
|
60
|
+
1. **Swap your LLM import** — `import { OpenAI } from '@amplitude/ai'` (or `Anthropic`, `Gemini`, etc.)
|
|
61
|
+
2. **Create an agent** — `ai.agent('my-agent')` to name and track your AI component
|
|
62
|
+
3. **Wrap in a session** — `agent.session({ userId, sessionId }).run(async (s) => { ... })` for per-user analytics, funnels, cohorts, and server-side enrichment
|
|
63
|
+
4. **Track user messages** — `s.trackUserMessage(...)` for conversation context
|
|
64
|
+
5. **Score responses** — `s.score(...)` for quality measurement
|
|
60
65
|
|
|
61
|
-
>
|
|
66
|
+
> `patch()` exists for quick verification or legacy codebases where you can't modify call sites, but it only captures `[Agent] AI Response` without user identity — no funnels, no cohorts, no retention. Start with full instrumentation; fall back to `patch()` only if you can't modify call sites.
|
|
62
67
|
|
|
63
68
|
| Property | Value |
|
|
64
69
|
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -100,7 +105,7 @@ The agent reads the guide, scans your project, discovers your agents and LLM cal
|
|
|
100
105
|
- [Auto-Instrumentation CLI](#auto-instrumentation-cli)
|
|
101
106
|
- [Integrations](#integrations)
|
|
102
107
|
- [Data Flow](#data-flow)
|
|
103
|
-
- [
|
|
108
|
+
- [Integration Approaches](#integration-approaches)
|
|
104
109
|
- [Integration Patterns](#integration-patterns)
|
|
105
110
|
- [Serverless Environments](#serverless-environments)
|
|
106
111
|
- [Error Handling and Reliability](#error-handling-and-reliability)
|
|
@@ -137,7 +142,7 @@ Install provider SDKs based on what you use (for example: `openai`, `@anthropic-
|
|
|
137
142
|
|
|
138
143
|
1. **Install:** `npm install @amplitude/ai @amplitude/analytics-node`
|
|
139
144
|
2. **Get your API key:** In Amplitude, go to **Settings > Projects** and copy the API key.
|
|
140
|
-
3. **
|
|
145
|
+
3. **Instrument:** Run `npx amplitude-ai` and paste the printed prompt into your AI coding agent. Or follow the [manual setup](#manual-setup) steps — the goal is the same: agents + sessions + provider wrappers.
|
|
141
146
|
4. **Set your API key** in the generated `.env` file and replace the placeholder `userId`/`sessionId`.
|
|
142
147
|
5. **Run your app.** You should see `[Agent] User Message`, `[Agent] AI Response`, and `[Agent] Session End` within 30 seconds.
|
|
143
148
|
|
|
@@ -504,7 +509,13 @@ const session = agent.session({
|
|
|
504
509
|
});
|
|
505
510
|
```
|
|
506
511
|
|
|
507
|
-
Without this, sessions with long idle periods may be closed and
|
|
512
|
+
Without this, sessions with long idle periods may be closed and enrichment may run earlier than expected. The default is 30 minutes.
|
|
513
|
+
|
|
514
|
+
**Session lifecycle and enrichment.** You do **not** need to call `trackSessionEnd()` for sessions to work. Amplitude's server automatically closes sessions after 30 minutes of inactivity and queues them for enrichment (topic classification, quality scoring, session evaluation) at that point. The only reason to call `trackSessionEnd()` is to **trigger enrichment sooner** — for example, if you know the conversation is over and want evaluation results immediately rather than waiting for the idle timeout.
|
|
515
|
+
|
|
516
|
+
"Closed" is a server-side concept meaning "queued for enrichment" — it does **not** prevent new events from flowing into the same session. If the user resumes a conversation after session end, new messages with the same `sessionId` are still associated with that session.
|
|
517
|
+
|
|
518
|
+
If you use `session.run()`, session end is tracked automatically when the callback completes. For long-lived conversations (chatbots, support agents), you can skip explicit session end entirely and let the server handle it.
|
|
508
519
|
|
|
509
520
|
**Link to Session Replay**: If your frontend uses Amplitude's [Session Replay](https://www.docs.developers.amplitude.com/session-replay/), pass the browser's `deviceId` and `browserSessionId` to link AI sessions to browser recordings:
|
|
510
521
|
|
|
@@ -1643,33 +1654,20 @@ Your Application
|
|
|
1643
1654
|
- The LLM Enrichment Pipeline runs asynchronously after session close (only when `contentMode: 'full'`). It produces server-side events like `[Agent] Session Evaluation` and `[Agent] Score`.
|
|
1644
1655
|
- With `contentMode: 'customer_enriched'`, the enrichment pipeline is skipped — you provide your own enrichments via `trackSessionEnrichment()`.
|
|
1645
1656
|
|
|
1646
|
-
##
|
|
1647
|
-
|
|
1648
|
-
Start
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
│ │
|
|
1661
|
-
Tier 1: Events Do you control
|
|
1662
|
-
Per-call tracking the LLM call site?
|
|
1663
|
-
+ userId │
|
|
1664
|
-
┌── Yes ──┴── No ──┐
|
|
1665
|
-
│ │
|
|
1666
|
-
Tier 2: Sessions Tier 3: OTEL Bridge
|
|
1667
|
-
session.run() Add exporter to
|
|
1668
|
-
Full enrichment existing OTEL pipeline
|
|
1669
|
-
Implicit feedback Limited to OTEL attrs
|
|
1670
|
-
```
|
|
1671
|
-
|
|
1672
|
-
**Rule of thumb:** If you own the LLM call site, start with **Tier 2** (sessions). If you don't (e.g., a third-party framework exports OTEL spans), use **Tier 3** (OTEL bridge). If you just want aggregate cost monitoring without user analytics, **Tier 0** (zero-code) is ready in 60 seconds.
|
|
1657
|
+
## Integration Approaches
|
|
1658
|
+
|
|
1659
|
+
**Start with full instrumentation.** Use agents + sessions + provider wrappers. This is the recommended approach for both coding agent and manual workflows — it gives you every event type, per-user analytics, and server-side enrichment.
|
|
1660
|
+
|
|
1661
|
+
| Approach | When to use | What you get |
|
|
1662
|
+
|---|---|---|
|
|
1663
|
+
| **Full control** (recommended) | Any project, new or existing | `BoundAgent` + `session.run()` + provider wrappers — all event types, per-user funnels, cohorts, retention, quality scoring, enrichments |
|
|
1664
|
+
| **Express/Fastify middleware** | Web app, auto-session per request | Same as full control with automatic session lifecycle via `createAmplitudeAIMiddleware` |
|
|
1665
|
+
| **Swap import** | Existing codebase, incremental adoption | `new OpenAI({ amplitude: ai })` — auto-tracking per call, add sessions when ready |
|
|
1666
|
+
| **Wrap** | You've already created a client | `wrap(client, ai)` — instruments an existing client instance |
|
|
1667
|
+
| **Zero-code / `patch()`** | Verification or legacy codebases only | `patch({ amplitudeAI: ai })` — `[Agent] AI Response` only, no user identity, no funnels |
|
|
1668
|
+
| **OTEL Bridge** | Third-party framework exports OTEL spans | Add exporter to existing OTEL pipeline — limited to OTEL attributes |
|
|
1669
|
+
|
|
1670
|
+
> The first four approaches all support the full event model. Choose based on how you want to integrate — the analytics capabilities are the same. **`patch()` is the exception**: it only captures aggregate `[Agent] AI Response` events without user identity, useful only for verifying the SDK works or for codebases where you can't modify call sites.
|
|
1673
1671
|
|
|
1674
1672
|
## Integration Patterns
|
|
1675
1673
|
|
package/amplitude-ai.md
CHANGED
|
@@ -29,30 +29,21 @@ Detected environment:
|
|
|
29
29
|
Multi-agent signals: [yes/no]
|
|
30
30
|
Streaming: [yes/no]
|
|
31
31
|
Frontend deps: [yes/no]
|
|
32
|
-
Recommended
|
|
32
|
+
Recommended: full instrumentation
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
**
|
|
36
|
-
- **Quick start** — `patch({ amplitudeAI: ai })`, zero code changes, good for getting data flowing
|
|
37
|
-
- **Standard** — Provider wrappers + session middleware (recommended for most apps)
|
|
38
|
-
- **Advanced** — Multi-agent `runAs`, agent descriptions, scoring, tool tracking
|
|
39
|
-
|
|
40
|
-
If multi-agent signals are detected, recommend Advanced.
|
|
35
|
+
**Next step:** Confirm the detection with the developer, then proceed to full instrumentation. Always instrument with agents, sessions, provider wrappers, tool tracking, and scoring. If multi-agent signals are detected, also add child agents and `runAs` delegation.
|
|
41
36
|
|
|
42
37
|
---
|
|
43
38
|
|
|
44
39
|
## Phase 2: Discover Agents and Call Sites
|
|
45
40
|
|
|
46
|
-
For **Quick start** tier, skip to Phase 3 — discovery is just "which providers are imported."
|
|
47
|
-
|
|
48
|
-
For **Standard** and **Advanced** tiers:
|
|
49
|
-
|
|
50
41
|
1. Identify files with LLM call sites (search for `chat.completions.create`, `messages.create`, `generateContent`, `streamText`, `generateText`)
|
|
51
42
|
2. For each file with call sites, read the actual source and review:
|
|
52
43
|
- Is it a route handler / API endpoint?
|
|
53
44
|
- What provider(s) does it use?
|
|
54
45
|
- Does it call other files with LLM call sites? (delegation → multi-agent)
|
|
55
|
-
3.
|
|
46
|
+
3. Identify:
|
|
56
47
|
- Agent boundaries (each distinct orchestration unit = one agent)
|
|
57
48
|
- Delegation patterns (parent calls child → `runAs`)
|
|
58
49
|
- Feedback handlers (thumbs up/down UI components)
|
|
@@ -135,17 +126,10 @@ export const openai = new OpenAI({
|
|
|
135
126
|
// export const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY!, amplitude: ai });
|
|
136
127
|
```
|
|
137
128
|
|
|
138
|
-
**Alternative: `wrap()` for existing clients.** If the project creates provider clients dynamically:
|
|
139
|
-
|
|
140
|
-
```typescript
|
|
141
|
-
import { wrap } from '@amplitude/ai';
|
|
142
|
-
import OpenAI from 'openai';
|
|
143
|
-
const rawClient = new OpenAI({ apiKey: process.env.OPENAI_API_KEY! });
|
|
144
|
-
export const openai = wrap(rawClient, ai);
|
|
145
|
-
```
|
|
146
|
-
|
|
147
129
|
Add `AMPLITUDE_AI_API_KEY` to `.env.example`. Check `.gitignore` includes `.env`.
|
|
148
130
|
|
|
131
|
+
> **Note:** If you cannot modify provider instantiation sites, use `wrap(existingClient, ai)` to instrument an existing client, or `patch({ amplitudeAI: ai })` for zero-code verification. These capture fewer event types — always prefer provider wrappers when possible.
|
|
132
|
+
|
|
149
133
|
### Step 3c: Swap provider imports
|
|
150
134
|
|
|
151
135
|
Replace direct provider instantiation with imports from the bootstrap file:
|
|
@@ -163,7 +147,7 @@ import { openai as client } from '@/lib/amplitude';
|
|
|
163
147
|
|
|
164
148
|
### Step 3d: Add session context
|
|
165
149
|
|
|
166
|
-
|
|
150
|
+
Wrap route handlers with agent + session:
|
|
167
151
|
|
|
168
152
|
```typescript
|
|
169
153
|
import { ai } from '@/lib/amplitude';
|
|
@@ -183,7 +167,7 @@ export async function POST(req: Request) {
|
|
|
183
167
|
}
|
|
184
168
|
```
|
|
185
169
|
|
|
186
|
-
|
|
170
|
+
If multi-agent signals were detected, add delegation with `runAs`:
|
|
187
171
|
|
|
188
172
|
```typescript
|
|
189
173
|
const orchestrator = ai.agent('shopping-agent', { description: 'Orchestrates shopping requests' });
|
|
@@ -220,7 +204,7 @@ s.trackAiMessage(completedMessage.content, 'gpt-4o', 'openai', latencyMs, {
|
|
|
220
204
|
});
|
|
221
205
|
```
|
|
222
206
|
|
|
223
|
-
### Step 3f: Add span tracking for orchestration
|
|
207
|
+
### Step 3f: Add span tracking for orchestration
|
|
224
208
|
|
|
225
209
|
When a parent agent delegates work to a child agent, wrap the delegation call with span tracking to measure latency and capture errors. Look for existing try/catch blocks around sub-agent execution — these are natural places to add span tracking with both success and error paths:
|
|
226
210
|
|
|
@@ -253,9 +237,9 @@ try {
|
|
|
253
237
|
}
|
|
254
238
|
```
|
|
255
239
|
|
|
256
|
-
### Step 3g: Add scoring
|
|
240
|
+
### Step 3g: Add scoring
|
|
257
241
|
|
|
258
|
-
If feedback handlers were detected (thumbs up/down UI),
|
|
242
|
+
If feedback handlers were detected (thumbs up/down UI), add scoring. Check whether the handler receives a `messageId` — if so, target the specific message for finer-grained scoring. Otherwise fall back to session-level scoring:
|
|
259
243
|
|
|
260
244
|
```typescript
|
|
261
245
|
const targetId = messageId ?? sessionId;
|
package/bin/amplitude-ai.mjs
CHANGED
|
@@ -25,9 +25,10 @@ Paste this into your AI coding agent (Cursor, Claude Code, Copilot, etc.):
|
|
|
25
25
|
Instrument this app with @amplitude/ai. Follow node_modules/@amplitude/ai/amplitude-ai.md
|
|
26
26
|
|
|
27
27
|
CLI commands:
|
|
28
|
-
mcp
|
|
29
|
-
doctor
|
|
30
|
-
status
|
|
28
|
+
mcp Start the MCP server (optional, for advanced tooling)
|
|
29
|
+
doctor Validate environment, deps, and event pipeline
|
|
30
|
+
status Show SDK version, installed providers, and env config
|
|
31
|
+
--print-guide Print the full amplitude-ai.md instrumentation guide to stdout
|
|
31
32
|
`
|
|
32
33
|
);
|
|
33
34
|
process.exit(0);
|
|
@@ -39,6 +40,17 @@ if (command === '--version' || command === '-v') {
|
|
|
39
40
|
process.exit(0);
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
if (command === '--print-guide') {
|
|
44
|
+
const guidePath = join(dirname(fileURLToPath(import.meta.url)), '..', 'amplitude-ai.md');
|
|
45
|
+
try {
|
|
46
|
+
process.stdout.write(readFileSync(guidePath, 'utf8'));
|
|
47
|
+
} catch {
|
|
48
|
+
process.stderr.write(`Guide not found at ${guidePath}\n`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
if (command in commandToBin) {
|
|
43
55
|
const binPath = fileURLToPath(new URL(commandToBin[command], import.meta.url));
|
|
44
56
|
const result = spawnSync(process.execPath, [binPath, ...rest], {
|
|
@@ -48,5 +60,5 @@ if (command in commandToBin) {
|
|
|
48
60
|
process.exit(result.status ?? 1);
|
|
49
61
|
}
|
|
50
62
|
|
|
51
|
-
process.stderr.write(`Unknown command: ${command}\nUsage: amplitude-ai <mcp|doctor|status>\n`);
|
|
63
|
+
process.stderr.write(`Unknown command: ${command}\nUsage: amplitude-ai <mcp|doctor|status|--print-guide>\n`);
|
|
52
64
|
process.exit(1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bound-agent.d.ts","names":[],"sources":["../src/bound-agent.ts"],"sourcesContent":[],"mappings":";;;;;;AAY8B,KAAlB,eAAA,GAAkB,OAAA,CAC5B,IAD4B,CACvB,UADuB,CACZ,WADY,CAAA,kBAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,SAAA,CAAA,CAAA;AAAO,KAIzB,aAAA,GAAgB,OAJS,CAKnC,IALmC,CAMjC,UANiC,CAMtB,WANsB,CAAA,gBAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,SAAA,GAAA,OAAA,GAAA,UAAA,GAAA,WAAA,CAAA,CAAA;AAIzB,KAOA,YAAA,GAAe,OAPF,CAQvB,IARuB,CASrB,UATqB,CASV,WATU,CAAA,eAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,UAAA,GAAA,WAAA,GAAA,SAAA,CAAA,CAAA;AAEV,KAYH,aAAA,GAAgB,OAZb,CAab,IAba,CAcX,UAdW,CAcA,WAdA,CAAA,gBAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,OAAA,GAAA,UAAA,GAAA,WAAA,CAAA,CAAA;AAAX,KAmBQ,QAAA,GAAW,OAnBnB,CAoBF,IApBE,CAoBG,UApBH,CAoBc,WApBd,CAAA,WAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,UAAA,GAAA,WAAA,CAAA,CAAA;AADF,KAwBU,cAAA,GAAiB,OAxB3B,CAyBA,UAzBA,CAyBW,WAzBX,CAAA,iBAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAD0B,KA6BhB,qBAAA,GAAwB,OA7BR,CA8B1B,IA9B0B,CA8BrB,UA9B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ADO,iBACS,
|
|
1
|
+
{"version":3,"file":"mistral.d.ts","names":[],"sources":["../../src/providers/mistral.ts"],"sourcesContent":[],"mappings":";;;;;;AAaM,cADO,iBACS,EAAA,OAAM;AAI5B,cAJM,cAIyB,EAJT,MAKT,CAAA,MAAA,EAAA,OAEK,CAAA,GAAA,IAAA;AAOD,UAVA,cAAA,CAUA;EAEM,SAAA,EAXV,aAWU;EAJM,MAAA,CAAA,EAAA,MAAA;EAAc,aAAA,CAAA,EALzB,aAKyB,GAAA,IAAA;EAoC9B;EAI2B,aAAA,CAAA,EAAA,OAAA;;AAQW,cAhDtC,OAAA,SAAgB,cAAA,CAgDsB;EAoF5B,QAAA,OAAA;EAA0B,SAAA,IAAA,EAlIhC,WAkIgC;EAAO,WAAA,CAAA,OAAA,EAhIjC,cAgIiC;;;cAhG3C,WAAA;;;wCAI2B;mBAQf,0BAA0B;iBAoF5B,0BAA0B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","names":[],"sources":["../../src/utils/logger.ts"],"sourcesContent":[],"mappings":";UAAiB,MAAA;EAAA,KAAA,CAAA,OAAM,EAAA,MAAA,CAAA,EAAA,IAAA;EAcP,KAAA,CAAA,OAAS,EAAA,MAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","names":[],"sources":["../../src/utils/logger.ts"],"sourcesContent":[],"mappings":";UAAiB,MAAA;EAAA,KAAA,CAAA,OAAM,EAAA,MAAA,CAAA,EAAA,IAAA;EAcP,KAAA,CAAA,OAAS,EAAA,MAAA,CAAA,EAAA,IAAuB;;;;iBAAhC,SAAA,uBAAgC"}
|
package/llms-full.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# llms-full.txt
|
|
2
|
-
# @amplitude/ai 0.3.
|
|
2
|
+
# @amplitude/ai 0.3.7 — Complete API Reference for AI Coding Agents
|
|
3
3
|
#
|
|
4
4
|
# This file is the definitive guide for any coding agent instrumenting
|
|
5
5
|
# a JavaScript/TypeScript AI application with @amplitude/ai.
|
|
@@ -67,6 +67,7 @@ const ai = new AmplitudeAI({
|
|
|
67
67
|
|
|
68
68
|
### patch(options) / unpatch()
|
|
69
69
|
Zero-code instrumentation. Monkey-patches all detected provider SDKs.
|
|
70
|
+
Captures aggregate `[Agent] AI Response` events only — no user identity, no funnels. Use as a quick verification or for legacy codebases where you cannot modify call sites.
|
|
70
71
|
```
|
|
71
72
|
import { patch, unpatch } from '@amplitude/ai';
|
|
72
73
|
patch({ amplitudeAI: ai });
|
|
@@ -395,6 +396,8 @@ with code examples for every step. Read this for guided instrumentation.
|
|
|
395
396
|
|
|
396
397
|
## CLI
|
|
397
398
|
|
|
399
|
+
- `amplitude-ai` — Print instrumentation prompt for AI coding agents
|
|
400
|
+
- `amplitude-ai --print-guide` — Print the full amplitude-ai.md guide to stdout
|
|
398
401
|
- `amplitude-ai mcp` — Start the MCP server for AI coding agents
|
|
399
402
|
- `amplitude-ai doctor [--json] [--no-mock-check]` — Validate environment and event pipeline
|
|
400
403
|
- `amplitude-ai status [--json]` — Show SDK version, installed providers, and env config
|
package/llms.txt
CHANGED
package/mcp.schema.json
CHANGED