Skip to content

Commit cc264bf

Browse files
authored
Merge branch 'develop' into dependabot/npm_and_yarn/dev-packages/e2e-tests/test-applications/sveltekit-2-svelte-5/sveltejs/kit-2.52.2
2 parents ba16e8d + 2b62357 commit cc264bf

File tree

861 files changed

+45593
-7284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

861 files changed

+45593
-7284
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
name: add-ai-integration
3+
description: Add a new AI provider integration to the Sentry JavaScript SDK. Use when contributing a new AI instrumentation (OpenAI, Anthropic, Vercel AI, LangChain, etc.) or modifying an existing one.
4+
argument-hint: <provider-name>
5+
---
6+
7+
# Adding a New AI Integration
8+
9+
## Decision Tree
10+
11+
```
12+
Does the AI SDK have native OpenTelemetry support?
13+
|- YES -> Does it emit OTel spans automatically?
14+
| |- YES (like Vercel AI) -> Pattern 1: OTel Span Processors
15+
| +- NO -> Pattern 2: OTel Instrumentation (wrap client)
16+
+- NO -> Does the SDK provide hooks/callbacks?
17+
|- YES (like LangChain) -> Pattern 3: Callback/Hook Based
18+
+- NO -> Pattern 4: Client Wrapping
19+
```
20+
21+
## Runtime-Specific Placement
22+
23+
If an AI SDK only works in one runtime, code lives exclusively in that runtime's package. Do NOT add it to `packages/core/`.
24+
25+
- **Node.js-only** -> `packages/node/src/integrations/tracing/{provider}/`
26+
- **Cloudflare-only** -> `packages/cloudflare/src/integrations/tracing/{provider}.ts`
27+
- **Browser-only** -> `packages/browser/src/integrations/tracing/{provider}/`
28+
- **Multi-runtime** -> shared core in `packages/core/src/tracing/{provider}/` with runtime-specific wrappers
29+
30+
## Span Hierarchy
31+
32+
- `gen_ai.invoke_agent` — parent/pipeline spans (chains, agents, orchestration)
33+
- `gen_ai.chat`, `gen_ai.generate_text`, etc. — child spans (actual LLM calls)
34+
35+
## Shared Utilities (`packages/core/src/tracing/ai/`)
36+
37+
- `gen-ai-attributes.ts` — OTel Semantic Convention attribute constants. **Always use these, never hardcode.**
38+
- `utils.ts``setTokenUsageAttributes()`, `getTruncatedJsonString()`, `truncateGenAiMessages()`, `buildMethodPath()`
39+
- Only use attributes from [Sentry Gen AI Conventions](https://getsentry.github.io/sentry-conventions/attributes/gen_ai/).
40+
41+
## Streaming
42+
43+
- **Non-streaming:** `startSpan()`, set attributes from response
44+
- **Streaming:** `startSpanManual()`, accumulate state via async generator or event listeners, set `GEN_AI_RESPONSE_STREAMING_ATTRIBUTE: true`, call `span.end()` in finally block
45+
- Detect via `params.stream === true`
46+
- References: `openai/streaming.ts` (async generator), `anthropic-ai/streaming.ts` (event listeners)
47+
48+
## Token Accumulation
49+
50+
- **Child spans:** Set tokens directly from API response via `setTokenUsageAttributes()`
51+
- **Parent spans (`invoke_agent`):** Accumulate from children using event processor (see `vercel-ai/`)
52+
53+
## Pattern 1: OTel Span Processors
54+
55+
**Use when:** SDK emits OTel spans automatically (Vercel AI)
56+
57+
1. **Core:** Create `add{Provider}Processors()` in `packages/core/src/tracing/{provider}/index.ts` — registers `spanStart` listener + event processor
58+
2. **Node.js:** Add `callWhenPatched()` optimization in `packages/node/src/integrations/tracing/{provider}/index.ts` — defers registration until package is imported
59+
3. **Edge:** Direct registration in `packages/cloudflare/src/integrations/tracing/{provider}.ts` — no OTel, call processors immediately
60+
61+
Reference: `packages/node/src/integrations/tracing/vercelai/`
62+
63+
## Pattern 2: OTel Instrumentation (Client Wrapping)
64+
65+
**Use when:** SDK has no native OTel support (OpenAI, Anthropic, Google GenAI)
66+
67+
1. **Core:** Create `instrument{Provider}Client()` in `packages/core/src/tracing/{provider}/index.ts` — Proxy to wrap client methods, create spans manually
68+
2. **Node.js `instrumentation.ts`:** Patch module exports, wrap client constructor. Check `_INTERNAL_shouldSkipAiProviderWrapping()` for LangChain compatibility.
69+
3. **Node.js `index.ts`:** Export integration function using `generateInstrumentOnce()` helper
70+
71+
Reference: `packages/node/src/integrations/tracing/openai/`
72+
73+
## Pattern 3: Callback/Hook Based
74+
75+
**Use when:** SDK provides lifecycle hooks (LangChain, LangGraph)
76+
77+
1. **Core:** Create `create{Provider}CallbackHandler()` — implement SDK's callback interface, create spans in callbacks
78+
2. **Node.js `instrumentation.ts`:** Auto-inject callbacks by patching runnable methods. Disable underlying AI provider wrapping.
79+
80+
Reference: `packages/node/src/integrations/tracing/langchain/`
81+
82+
## Auto-Instrumentation (Node.js)
83+
84+
**Mandatory** for Node.js AI integrations. OTel only patches when the package is imported (zero cost if unused).
85+
86+
### Steps
87+
88+
1. **Add to `getAutoPerformanceIntegrations()`** in `packages/node/src/integrations/tracing/index.ts` — LangChain MUST come first
89+
2. **Add to `getOpenTelemetryInstrumentationToPreload()`** for OTel-based integrations
90+
3. **Export from `packages/node/src/index.ts`**: integration function + options type
91+
4. **Add E2E tests:**
92+
- Node.js: `dev-packages/node-integration-tests/suites/tracing/{provider}/`
93+
- Cloudflare: `dev-packages/cloudflare-integration-tests/suites/tracing/{provider}/`
94+
- Browser: `dev-packages/browser-integration-tests/suites/tracing/ai-providers/{provider}/`
95+
96+
## Key Rules
97+
98+
1. Respect `sendDefaultPii` for `recordInputs`/`recordOutputs`
99+
2. Set `SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = 'auto.ai.{provider}'` (alphanumerics, `_`, `.` only)
100+
3. Truncate large data with helper functions from `utils.ts`
101+
4. `gen_ai.invoke_agent` for parent ops, `gen_ai.chat` for child ops
102+
103+
## Checklist
104+
105+
- [ ] Runtime-specific code placed only in that runtime's package
106+
- [ ] Added to `getAutoPerformanceIntegrations()` in correct order (Node.js)
107+
- [ ] Added to `getOpenTelemetryInstrumentationToPreload()` (Node.js with OTel)
108+
- [ ] Exported from appropriate package index
109+
- [ ] E2E tests added and verifying auto-instrumentation
110+
- [ ] Only used attributes from [Sentry Gen AI Conventions](https://getsentry.github.io/sentry-conventions/attributes/gen_ai/)
111+
- [ ] JSDoc says "enabled by default" or "not enabled by default"
112+
- [ ] Documented how to disable (if auto-enabled)
113+
- [ ] Verified OTel only patches when package imported (Node.js)
114+
115+
## Reference Implementations
116+
117+
- **Pattern 1 (Span Processors):** `packages/node/src/integrations/tracing/vercelai/`
118+
- **Pattern 2 (Client Wrapping):** `packages/node/src/integrations/tracing/openai/`
119+
- **Pattern 3 (Callback/Hooks):** `packages/node/src/integrations/tracing/langchain/`
120+
121+
**When in doubt, follow the pattern of the most similar existing integration.**
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: bump-size-limit
3+
description: Bump size limits in .size-limit.js when the size-limit CI check is failing. Use when the user mentions size limit failures, bundle size checks failing, CI size check errors, or needs to update size-limit thresholds. Also use when the user says "bumpSizeLimit", "fix size limit", "size check failing", or "update bundle size limits".
4+
---
5+
6+
# Bump Size Limit
7+
8+
When the size-limit GitHub Action fails, it means one or more bundle scenarios exceed their configured byte thresholds in `.size-limit.js`. This skill walks through building, measuring, and bumping only the limits that need it.
9+
10+
## Workflow
11+
12+
### Step 1: Build all packages (including CDN bundles)
13+
14+
A full build is required because size-limit measures the actual compiled artifacts.
15+
16+
```bash
17+
yarn build
18+
```
19+
20+
This takes a few minutes. CDN bundles in `packages/browser/build/bundles/` must be up to date — a dev build is not sufficient.
21+
22+
### Step 2: Run the size check in JSON mode
23+
24+
```bash
25+
yarn test:size-limit
26+
```
27+
28+
The JSON output is an array of objects. Each object has:
29+
30+
- `name` — the scenario label
31+
- `passed` — whether it's within the limit
32+
- `size` — actual size in bytes
33+
- `sizeLimit` — configured limit in bytes
34+
35+
### Step 3: Identify failed scenarios
36+
37+
Filter for entries where `"passed": false`. These are the only ones that need bumping.
38+
39+
### Step 4: Calculate new limits
40+
41+
For each failed scenario, round the actual size **up to the next full KB** (1 KB = 1000 bytes in this context, matching how size-limit interprets the limits in `.size-limit.js`).
42+
43+
**Example:** If actual size is `129,127` bytes, the new limit is `130 KB` (i.e. 130,000 bytes).
44+
45+
The heuristic is intentionally conservative — it gives just enough headroom without inflating limits unnecessarily.
46+
47+
### Step 5: Update `.size-limit.js`
48+
49+
Open `.size-limit.js` at the repository root and update the `limit` field for each failed scenario. Limits are strings like `'130 KB'`.
50+
51+
Only change limits for scenarios that actually failed. Do not touch passing scenarios.
52+
53+
### Step 6: Verify the fix
54+
55+
Re-run size-limit to confirm everything passes:
56+
57+
```bash
58+
yarn test:size-limit
59+
```
60+
61+
If any scenario still fails (e.g., due to rounding edge cases), bump that specific limit by another 1 KB and re-run.

.agents/skills/dotagents/SKILL.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
name: dotagents
3+
description: Manage agent skill dependencies with dotagents. Use when asked to "add a skill", "install skills", "remove a skill", "update skills", "dotagents init", "agents.toml", "agents.lock", "sync skills", "list skills", "set up dotagents", "configure trust", "add MCP server", "add hook", "wildcard skills", "user scope", or any dotagents-related task.
4+
---
5+
6+
Manage agent skill dependencies declared in `agents.toml`. dotagents resolves, installs, and symlinks skills so multiple agent tools (Claude Code, Cursor, Codex, VS Code, OpenCode) discover them from `.agents/skills/`.
7+
8+
## Running dotagents
9+
10+
If `dotagents` is not available as a direct command, use `npx @sentry/dotagents` instead. For example: `npx @sentry/dotagents sync`. All commands and flags work the same way.
11+
12+
## References
13+
14+
Read the relevant reference when the task requires deeper detail:
15+
16+
| Document | Read When |
17+
| ---------------------------------------------------------- | ------------------------------------------------------------------------- |
18+
| [references/cli-reference.md](references/cli-reference.md) | Full command options, flags, examples |
19+
| [references/configuration.md](references/configuration.md) | Editing agents.toml, source formats, trust, MCP, hooks, wildcards, scopes |
20+
| [references/config-schema.md](references/config-schema.md) | Exact field names, types, and defaults |
21+
22+
## Quick Start
23+
24+
```bash
25+
# Initialize a new project (interactive TUI)
26+
dotagents init
27+
28+
# Add a skill from GitHub
29+
dotagents add getsentry/skills find-bugs
30+
31+
# Add multiple skills at once
32+
dotagents add getsentry/skills find-bugs code-review commit
33+
34+
# Add all skills from a repo
35+
dotagents add getsentry/skills --all
36+
37+
# Add a pinned skill
38+
dotagents add getsentry/warden@v1.0.0
39+
40+
# Install all dependencies from agents.toml
41+
dotagents install
42+
43+
# List installed skills
44+
dotagents list
45+
```
46+
47+
## Commands
48+
49+
| Command | Description |
50+
| --------------------------- | ------------------------------------------------------------------ |
51+
| `dotagents init` | Initialize `agents.toml` and `.agents/` directory |
52+
| `dotagents install` | Install all skills from `agents.toml` |
53+
| `dotagents add <specifier>` | Add a skill dependency |
54+
| `dotagents remove <name>` | Remove a skill |
55+
| `dotagents update [name]` | Update skills to latest versions |
56+
| `dotagents sync` | Reconcile state (adopt orphans, repair symlinks, verify integrity) |
57+
| `dotagents list` | Show installed skills and their status |
58+
| `dotagents mcp` | Add, remove, or list MCP server declarations |
59+
60+
All commands accept `--user` to operate on user scope (`~/.agents/`) instead of the current project.
61+
62+
For full options and flags, read [references/cli-reference.md](references/cli-reference.md).
63+
64+
## Source Formats
65+
66+
| Format | Example | Description |
67+
| ---------------- | -------------------------------------- | ------------------------------------- |
68+
| GitHub shorthand | `getsentry/skills` | Owner/repo (resolves to GitHub HTTPS) |
69+
| GitHub pinned | `getsentry/warden@v1.0.0` | With tag, branch, or commit |
70+
| GitHub SSH | `git@github.com:owner/repo.git` | SSH clone URL |
71+
| GitHub HTTPS | `https://github.com/owner/repo` | Full HTTPS URL |
72+
| Git URL | `git:https://git.corp.dev/team/skills` | Any non-GitHub git remote |
73+
| Local path | `path:./my-skills/custom` | Relative to project root |
74+
75+
## Key Concepts
76+
77+
- **`.agents/skills/`** is the canonical home for all installed skills
78+
- **`agents.toml`** declares dependencies; **`agents.lock`** pins exact commits and integrity hashes
79+
- **Symlinks**: `.claude/skills/`, `.cursor/skills/` point to `.agents/skills/`
80+
- **Wildcards**: `name = "*"` installs all skills from a source, with optional `exclude` list
81+
- **Trust**: Optional `[trust]` section restricts which sources are allowed
82+
- **Hooks**: `[[hooks]]` declarations write tool-event hooks to each agent's config
83+
- **Gitignore**: When `gitignore = true`, managed skills are gitignored; custom in-place skills are tracked
84+
- **User scope**: `--user` flag manages skills in `~/.agents/` shared across all projects

0 commit comments

Comments
 (0)