workthin 1.0.1 → 1.0.2
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/README.md +10 -117
- package/README.repo.md +146 -0
- package/dist/cli/index.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,30 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Knowledge vaccination for AI. Turn every solved problem into a reusable vaccine. One project's experience becomes everyone's immunity.
|
|
4
4
|
|
|
5
|
-
**[workthin.app](https://workthin.app)** | **[Docs](https://workthin.app/docs)** | **[Pricing](https://workthin.app/pricing)**
|
|
6
|
-
|
|
7
|
-
## What is workthin?
|
|
8
|
-
|
|
9
|
-
workthin captures problem→solution knowledge from AI conversations and makes it searchable across your team. When an AI tool encounters a problem someone already solved, workthin provides the answer instantly — reducing token costs by up to 90%.
|
|
10
|
-
|
|
11
|
-
### How it works
|
|
12
|
-
|
|
13
|
-
1. **Capture** — AI work logs are structured into problem → environment → attempts → solution. Secrets are masked automatically.
|
|
14
|
-
2. **Search** — Semantic vector search in milliseconds. Three detail levels: L1 (~100 tokens), L2 (~500), L3 (~2,000).
|
|
15
|
-
3. **Immunize** — Each resolve strengthens the vaccine. Escalation rates drop weekly. Knowledge compounds.
|
|
16
|
-
|
|
17
|
-
## Features
|
|
18
|
-
|
|
19
|
-
- **MCP Server** — Works with Claude Code, Claude Desktop, ChatGPT, Cursor, VS Code / GitHub Copilot, Codex CLI, GitHub Copilot CLI, Gemini CLI, and any MCP-compatible tool
|
|
20
|
-
- **CLI** — `wt search`, `wt create`, `wt init`, `wt hooks` for terminal-native workflows
|
|
21
|
-
- **Automatic Hooks** — `wt hooks` sets up SessionStart search and Stop/SessionEnd capture reminders for all major AI tools
|
|
22
|
-
- **REST API** — Full CRUD + semantic search via Bearer token auth
|
|
23
|
-
- **OAuth 2.1** — PKCE, dynamic client registration, JWT access tokens
|
|
24
|
-
- **3-Stage Secret Protection** — Regex patterns + Shannon entropy + AI classification
|
|
25
|
-
- **Scope System** — Personal, project, and global knowledge visibility
|
|
26
|
-
- **Knowledge Chains** — Link related solutions, fork and branch knowledge
|
|
27
|
-
- **Contributor Rewards** — Track who creates the most valuable vaccines
|
|
28
|
-
|
|
29
5
|
## Quick Start
|
|
30
6
|
|
|
31
7
|
```bash
|
|
@@ -34,6 +10,8 @@ npx workthin@latest init
|
|
|
34
10
|
|
|
35
11
|
One command handles authentication, project detection, MCP configuration, hooks setup, and optional global CLI install.
|
|
36
12
|
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
37
15
|
```bash
|
|
38
16
|
# Search existing knowledge
|
|
39
17
|
wt search "supabase timeout"
|
|
@@ -41,105 +19,20 @@ wt search "supabase timeout"
|
|
|
41
19
|
# Create new knowledge
|
|
42
20
|
wt create "Fix: Edge Functions timeout at 30s" \
|
|
43
21
|
--body "Set function timeout to 150s in supabase/config.toml"
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Tech Stack
|
|
47
22
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
| Framework | Next.js 16 (App Router, React 19, Turbopack) |
|
|
51
|
-
| Language | TypeScript 5.9 |
|
|
52
|
-
| UI | Tailwind CSS 4, DaisyUI 5 |
|
|
53
|
-
| API | Hono (Valibot validation) |
|
|
54
|
-
| Database | Supabase (PostgreSQL + pgvector + RLS) |
|
|
55
|
-
| Auth | Supabase Auth (Google OAuth, GitHub OAuth, Magic Link) |
|
|
56
|
-
| AI | OpenAI GPT-5-mini (structuring, tagging, classification) |
|
|
57
|
-
| Embeddings | text-embedding-3-small (1536 dimensions) |
|
|
58
|
-
| Payment | Stripe (subscriptions + webhook) |
|
|
59
|
-
| MCP | Model Context Protocol (HTTP transport, OAuth 2.1) |
|
|
60
|
-
| Rate Limiting | Upstash Redis |
|
|
61
|
-
| Error Tracking | Sentry |
|
|
62
|
-
| Analytics | PostHog, Vercel Analytics |
|
|
63
|
-
| Lint / Format | Biome |
|
|
64
|
-
| Test | Vitest (970 tests, 92% line coverage) |
|
|
65
|
-
| Docs | Fumadocs |
|
|
66
|
-
|
|
67
|
-
## Architecture
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
src/
|
|
71
|
-
├── app/ # Next.js App Router
|
|
72
|
-
│ ├── (marketing)/ # Landing, pricing, legal pages
|
|
73
|
-
│ ├── (dashboard)/app/ # Dashboard (SSR + Client Components)
|
|
74
|
-
│ ├── (auth)/ # Sign in (Magic Link + OAuth)
|
|
75
|
-
│ ├── api/
|
|
76
|
-
│ │ ├── [[...route]]/ # Hono API catch-all
|
|
77
|
-
│ │ ├── routes/ # REST API (knowledge, search, auth, stripe)
|
|
78
|
-
│ │ └── mcp/ # MCP HTTP endpoint + tools
|
|
79
|
-
│ ├── oauth/ # OAuth 2.1 (authorize, token, register)
|
|
80
|
-
│ └── .well-known/ # OAuth discovery endpoints
|
|
81
|
-
├── core/
|
|
82
|
-
│ ├── knowledge/ # CRUD, search, chain, check, resolve
|
|
83
|
-
│ ├── protection/ # 3-stage secret masking pipeline
|
|
84
|
-
│ ├── structuring/ # AI structuring, tagging, embedding
|
|
85
|
-
│ ├── oauth/ # JWT, tokens, codes, clients
|
|
86
|
-
│ └── auth/ # API keys, device code flow
|
|
87
|
-
├── lib/
|
|
88
|
-
│ ├── supabase/ # Server/admin clients, queries, actions
|
|
89
|
-
│ ├── stripe/ # Subscription management
|
|
90
|
-
│ └── format.ts # Shared utilities
|
|
91
|
-
├── cli/ # CLI commands (init, login, search, create, hooks)
|
|
92
|
-
└── components/ # UI components
|
|
23
|
+
# Set up hooks for auto-search/capture
|
|
24
|
+
wt hooks
|
|
93
25
|
```
|
|
94
26
|
|
|
95
|
-
##
|
|
96
|
-
|
|
97
|
-
### Prerequisites
|
|
98
|
-
|
|
99
|
-
- [Bun](https://bun.sh/) (runtime + package manager)
|
|
100
|
-
- [Supabase CLI](https://supabase.com/docs/guides/cli) (local DB)
|
|
101
|
-
|
|
102
|
-
### Setup
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
bun install
|
|
106
|
-
cp .env.example .env # Fill in required values
|
|
107
|
-
bun run supabase:start
|
|
108
|
-
bun run supabase:reset
|
|
109
|
-
bun run dev # http://localhost:3001
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Commands
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
bun run dev # Dev server (port 3001)
|
|
116
|
-
bun run build # Production build
|
|
117
|
-
bun run test # Vitest + coverage (85% threshold)
|
|
118
|
-
bun run lint # Biome check + format
|
|
119
|
-
bun run type-check # TypeScript strict check
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Environment Variables
|
|
123
|
-
|
|
124
|
-
See [`.env.example`](.env.example) for the full list. Required:
|
|
27
|
+
## Supported AI Tools
|
|
125
28
|
|
|
126
|
-
|
|
127
|
-
|----------|---------|
|
|
128
|
-
| `NEXT_PUBLIC_SUPABASE_URL` | Supabase |
|
|
129
|
-
| `NEXT_PUBLIC_SUPABASE_PUBLIC_KEY` | Supabase |
|
|
130
|
-
| `SUPABASE_SECRET_KEY` | Supabase |
|
|
131
|
-
| `OPENAI_API_KEY` | OpenAI |
|
|
132
|
-
| `UPSTASH_REDIS_REST_URL` / `TOKEN` | Upstash |
|
|
29
|
+
Claude Code, Claude Desktop, ChatGPT, Cursor, VS Code / GitHub Copilot, OpenAI Codex CLI, GitHub Copilot CLI, Gemini CLI, and any other MCP-compatible tool.
|
|
133
30
|
|
|
134
|
-
##
|
|
31
|
+
## Links
|
|
135
32
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
| Global reads | 30 / month | Unlimited |
|
|
140
|
-
| CLI + MCP | Yes | Yes |
|
|
141
|
-
| Secret protection | Yes | Yes |
|
|
142
|
-
| Custom security rules | — | Yes |
|
|
33
|
+
- [Documentation](https://workthin.app/docs)
|
|
34
|
+
- [Quick Start Guide](https://workthin.app/docs/quick-start)
|
|
35
|
+
- [Pricing](https://workthin.app/pricing)
|
|
143
36
|
|
|
144
37
|
## License
|
|
145
38
|
|
package/README.repo.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# workthin
|
|
2
|
+
|
|
3
|
+
Knowledge vaccination for AI. Turn every solved problem into a reusable vaccine. One project's experience becomes everyone's immunity.
|
|
4
|
+
|
|
5
|
+
**[workthin.app](https://workthin.app)** | **[Docs](https://workthin.app/docs)** | **[Pricing](https://workthin.app/pricing)**
|
|
6
|
+
|
|
7
|
+
## What is workthin?
|
|
8
|
+
|
|
9
|
+
workthin captures problem→solution knowledge from AI conversations and makes it searchable across your team. When an AI tool encounters a problem someone already solved, workthin provides the answer instantly — reducing token costs by up to 90%.
|
|
10
|
+
|
|
11
|
+
### How it works
|
|
12
|
+
|
|
13
|
+
1. **Capture** — AI work logs are structured into problem → environment → attempts → solution. Secrets are masked automatically.
|
|
14
|
+
2. **Search** — Semantic vector search in milliseconds. Three detail levels: L1 (~100 tokens), L2 (~500), L3 (~2,000).
|
|
15
|
+
3. **Immunize** — Each resolve strengthens the vaccine. Escalation rates drop weekly. Knowledge compounds.
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **MCP Server** — Works with Claude Code, Claude Desktop, ChatGPT, Cursor, VS Code / GitHub Copilot, Codex CLI, GitHub Copilot CLI, Gemini CLI, and any MCP-compatible tool
|
|
20
|
+
- **CLI** — `wt search`, `wt create`, `wt init`, `wt hooks` for terminal-native workflows
|
|
21
|
+
- **Automatic Hooks** — `wt hooks` sets up SessionStart search and Stop/SessionEnd capture reminders for all major AI tools
|
|
22
|
+
- **REST API** — Full CRUD + semantic search via Bearer token auth
|
|
23
|
+
- **OAuth 2.1** — PKCE, dynamic client registration, JWT access tokens
|
|
24
|
+
- **3-Stage Secret Protection** — Regex patterns + Shannon entropy + AI classification
|
|
25
|
+
- **Scope System** — Personal, project, and global knowledge visibility
|
|
26
|
+
- **Knowledge Chains** — Link related solutions, fork and branch knowledge
|
|
27
|
+
- **Contributor Rewards** — Track who creates the most valuable vaccines
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx workthin@latest init
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
One command handles authentication, project detection, MCP configuration, hooks setup, and optional global CLI install.
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Search existing knowledge
|
|
39
|
+
wt search "supabase timeout"
|
|
40
|
+
|
|
41
|
+
# Create new knowledge
|
|
42
|
+
wt create "Fix: Edge Functions timeout at 30s" \
|
|
43
|
+
--body "Set function timeout to 150s in supabase/config.toml"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Tech Stack
|
|
47
|
+
|
|
48
|
+
| Category | Technology |
|
|
49
|
+
|----------|-----------|
|
|
50
|
+
| Framework | Next.js 16 (App Router, React 19, Turbopack) |
|
|
51
|
+
| Language | TypeScript 5.9 |
|
|
52
|
+
| UI | Tailwind CSS 4, DaisyUI 5 |
|
|
53
|
+
| API | Hono (Valibot validation) |
|
|
54
|
+
| Database | Supabase (PostgreSQL + pgvector + RLS) |
|
|
55
|
+
| Auth | Supabase Auth (Google OAuth, GitHub OAuth, Magic Link) |
|
|
56
|
+
| AI | OpenAI GPT-5-mini (structuring, tagging, classification) |
|
|
57
|
+
| Embeddings | text-embedding-3-small (1536 dimensions) |
|
|
58
|
+
| Payment | Stripe (subscriptions + webhook) |
|
|
59
|
+
| MCP | Model Context Protocol (HTTP transport, OAuth 2.1) |
|
|
60
|
+
| Rate Limiting | Upstash Redis |
|
|
61
|
+
| Error Tracking | Sentry |
|
|
62
|
+
| Analytics | PostHog, Vercel Analytics |
|
|
63
|
+
| Lint / Format | Biome |
|
|
64
|
+
| Test | Vitest (970 tests, 92% line coverage) |
|
|
65
|
+
| Docs | Fumadocs |
|
|
66
|
+
|
|
67
|
+
## Architecture
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
src/
|
|
71
|
+
├── app/ # Next.js App Router
|
|
72
|
+
│ ├── (marketing)/ # Landing, pricing, legal pages
|
|
73
|
+
│ ├── (dashboard)/app/ # Dashboard (SSR + Client Components)
|
|
74
|
+
│ ├── (auth)/ # Sign in (Magic Link + OAuth)
|
|
75
|
+
│ ├── api/
|
|
76
|
+
│ │ ├── [[...route]]/ # Hono API catch-all
|
|
77
|
+
│ │ ├── routes/ # REST API (knowledge, search, auth, stripe)
|
|
78
|
+
│ │ └── mcp/ # MCP HTTP endpoint + tools
|
|
79
|
+
│ ├── oauth/ # OAuth 2.1 (authorize, token, register)
|
|
80
|
+
│ └── .well-known/ # OAuth discovery endpoints
|
|
81
|
+
├── core/
|
|
82
|
+
│ ├── knowledge/ # CRUD, search, chain, check, resolve
|
|
83
|
+
│ ├── protection/ # 3-stage secret masking pipeline
|
|
84
|
+
│ ├── structuring/ # AI structuring, tagging, embedding
|
|
85
|
+
│ ├── oauth/ # JWT, tokens, codes, clients
|
|
86
|
+
│ └── auth/ # API keys, device code flow
|
|
87
|
+
├── lib/
|
|
88
|
+
│ ├── supabase/ # Server/admin clients, queries, actions
|
|
89
|
+
│ ├── stripe/ # Subscription management
|
|
90
|
+
│ └── format.ts # Shared utilities
|
|
91
|
+
├── cli/ # CLI commands (init, login, search, create, hooks)
|
|
92
|
+
└── components/ # UI components
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Development
|
|
96
|
+
|
|
97
|
+
### Prerequisites
|
|
98
|
+
|
|
99
|
+
- [Bun](https://bun.sh/) (runtime + package manager)
|
|
100
|
+
- [Supabase CLI](https://supabase.com/docs/guides/cli) (local DB)
|
|
101
|
+
|
|
102
|
+
### Setup
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
bun install
|
|
106
|
+
cp .env.example .env # Fill in required values
|
|
107
|
+
bun run supabase:start
|
|
108
|
+
bun run supabase:reset
|
|
109
|
+
bun run dev # http://localhost:3001
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Commands
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
bun run dev # Dev server (port 3001)
|
|
116
|
+
bun run build # Production build
|
|
117
|
+
bun run test # Vitest + coverage (85% threshold)
|
|
118
|
+
bun run lint # Biome check + format
|
|
119
|
+
bun run type-check # TypeScript strict check
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Environment Variables
|
|
123
|
+
|
|
124
|
+
See [`.env.example`](.env.example) for the full list. Required:
|
|
125
|
+
|
|
126
|
+
| Variable | Service |
|
|
127
|
+
|----------|---------|
|
|
128
|
+
| `NEXT_PUBLIC_SUPABASE_URL` | Supabase |
|
|
129
|
+
| `NEXT_PUBLIC_SUPABASE_PUBLIC_KEY` | Supabase |
|
|
130
|
+
| `SUPABASE_SECRET_KEY` | Supabase |
|
|
131
|
+
| `OPENAI_API_KEY` | OpenAI |
|
|
132
|
+
| `UPSTASH_REDIS_REST_URL` / `TOKEN` | Upstash |
|
|
133
|
+
|
|
134
|
+
## Plans
|
|
135
|
+
|
|
136
|
+
| | Free | Pro |
|
|
137
|
+
|--|------|-----|
|
|
138
|
+
| Knowledge storage | Unlimited | Unlimited |
|
|
139
|
+
| Global reads | 30 / month | Unlimited |
|
|
140
|
+
| CLI + MCP | Yes | Yes |
|
|
141
|
+
| Secret protection | Yes | Yes |
|
|
142
|
+
| Custom security rules | — | Yes |
|
|
143
|
+
|
|
144
|
+
## License
|
|
145
|
+
|
|
146
|
+
MIT
|
package/dist/cli/index.js
CHANGED
|
@@ -123,7 +123,7 @@ Event: ${w6(D)}`),!0}return!1}function eM0(D,F){if(!F?.length)return!1;return H$
|
|
|
123
123
|
`),V=H.shift();if(!V)return D.destroy(),Z(Error("No header received from proxy CONNECT response"));let U=V.split(" "),j=+(U[1]||0),C=U.slice(2).join(" "),O={};for(let L of H){if(!L)continue;let k=L.indexOf(":");if(k===-1)return D.destroy(),Z(Error(`Invalid header from proxy CONNECT response: "${L}"`));let P=L.slice(0,k).toLowerCase(),f=L.slice(k+1).trimStart(),R=O[P];if(typeof R==="string")O[P]=[R,f];else if(Array.isArray(R))R.push(f);else O[P]=f}UJ("got proxy server response: %o %o",V,O),X(),F({connect:{statusCode:j,statusText:C,headers:O},buffered:K})}D.on("error",W),D.on("end",Y),Q()})}function f5(...D){q.log("[https-proxy-agent]",...D)}class jJ extends RB{static __initStatic(){this.protocols=["http","https"]}constructor(D,F){super(F);this.options={},this.proxy=typeof D==="string"?new URL(D):D,this.proxyHeaders=F?.headers??{},f5("Creating new HttpsProxyAgent instance: %o",this.proxy.href);let Z=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),$=this.proxy.port?parseInt(this.proxy.port,10):this.proxy.protocol==="https:"?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...F?yg(F,"headers"):null,host:Z,port:$}}async connect(D,F){let{proxy:Z}=this;if(!F.host)throw TypeError('No "host" provided');let $;if(Z.protocol==="https:"){f5("Creating `tls.Socket`: %o",this.connectOpts);let K=this.connectOpts.servername||this.connectOpts.host;$=kB.connect({...this.connectOpts,servername:K&&l1.isIP(K)?void 0:K})}else f5("Creating `net.Socket`: %o",this.connectOpts),$=l1.connect(this.connectOpts);let J=typeof this.proxyHeaders==="function"?this.proxyHeaders():{...this.proxyHeaders},Q=l1.isIPv6(F.host)?`[${F.host}]`:F.host,X=`CONNECT ${Q}:${F.port} HTTP/1.1\r
|
|
124
124
|
`;if(Z.username||Z.password){let K=`${decodeURIComponent(Z.username)}:${decodeURIComponent(Z.password)}`;J["Proxy-Authorization"]=`Basic ${Buffer.from(K).toString("base64")}`}if(J.Host=`${Q}:${F.port}`,!J["Proxy-Connection"])J["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close";for(let K of Object.keys(J))X+=`${K}: ${J[K]}\r
|
|
125
125
|
`;let Y=fg($);$.write(`${X}\r
|
|
126
|
-
`);let{connect:W,buffered:z}=await Y;if(D.emit("proxyConnect",W),this.emit("proxyConnect",W,D),W.statusCode===200){if(D.once("socket",Af0),F.secureEndpoint){f5("Upgrading socket connection to TLS");let K=F.servername||F.host;return kB.connect({...yg(F,"host","path","port"),socket:$,servername:l1.isIP(K)?void 0:K})}return $}$.destroy();let B=new l1.Socket({writable:!1});return B.readable=!0,D.once("socket",(K)=>{f5("Replaying proxy buffer for failed request"),K.push(z),K.push(null)}),B}}jJ.__initStatic();function Af0(D){D.resume()}function yg(D,...F){let Z={},$;for($ in D)if(!F.includes($))Z[$]=D[$];return Z}var Tf0=32768;function Ef0(D){return new If0({read(){this.push(D),this.push(null)}})}function hg(D){let F;try{F=new URL(D.url)}catch(W){return h0(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),t4(D,()=>Promise.resolve({}))}let Z=F.protocol==="https:",$=ff0(F,D.proxy||(Z?process.env.https_proxy:void 0)||process.env.http_proxy),J=Z?kf0:Rf0,Q=D.keepAlive===void 0?!1:D.keepAlive,X=$?new jJ($):new J.Agent({keepAlive:Q,maxSockets:30,timeout:2000}),Y=yf0(D,D.httpModule??J,X);return t4(D,Y)}function ff0(D,F){let{no_proxy:Z}=process.env;if(Z?.split(",").some((J)=>D.host.endsWith(J)||D.hostname.endsWith(J)))return;else return F}function yf0(D,F,Z){let{hostname:$,pathname:J,port:Q,protocol:X,search:Y}=new URL(D.url);return function(z){return new Promise((B,K)=>{c9(()=>{let G=Ef0(z.body),H={...D.headers};if(z.body.length>Tf0)H["content-encoding"]="gzip",G=G.pipe(Nf0());let V=$.startsWith("["),U=F.request({method:"POST",agent:Z,headers:H,hostname:V?$.slice(1,-1):$,path:`${J}${Y}`,port:Q,protocol:X,ca:D.caCerts},(j)=>{j.on("data",()=>{}),j.on("end",()=>{}),j.setEncoding("utf8");let C=j.headers["retry-after"]??null,O=j.headers["x-sentry-rate-limits"]??null;B({statusCode:j.statusCode,headers:{"retry-after":C,"x-sentry-rate-limits":Array.isArray(O)?O[0]||null:O}})});U.on("error",K),G.pipe(U)})})}}function _g(D){if(D===!1)return!1;if(typeof D==="string")return D;let F=r9(process.env.SENTRY_SPOTLIGHT,{strict:!0}),Z=F===null&&process.env.SENTRY_SPOTLIGHT?process.env.SENTRY_SPOTLIGHT:void 0;return D===!0?Z??!0:F??Z}import{posix as hf0,sep as _f0}from"node:path";function Sg(D){return D.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}function bg(D=process.argv[1]?nz(process.argv[1]):process.cwd(),F=_f0==="\\"){let Z=F?Sg(D):D;return($)=>{if(!$)return;let J=F?Sg($):$,{dir:Q,base:X,ext:Y}=hf0.parse(J);if(Y===".js"||Y===".mjs"||Y===".cjs")X=X.slice(0,Y.length*-1);let W=decodeURIComponent(X);if(!Q)Q=".";let z=Q.lastIndexOf("/node_modules");if(z>-1)return`${Q.slice(z+14).replace(/\//g,".")}:${W}`;if(Q.startsWith(Z)){let B=Q.slice(Z.length+1).replace(/\//g,".");return B?`${B}:${W}`:W}return W}}function vg(D){if(process.env.SENTRY_RELEASE)return process.env.SENTRY_RELEASE;if(l.SENTRY_RELEASE?.id)return l.SENTRY_RELEASE.id;let F=process.env.GITHUB_SHA||process.env.CI_MERGE_REQUEST_SOURCE_BRANCH_SHA||process.env.CI_BUILD_REF||process.env.CI_COMMIT_SHA||process.env.BITBUCKET_COMMIT,Z=process.env.APPVEYOR_PULL_REQUEST_HEAD_COMMIT||process.env.APPVEYOR_REPO_COMMIT||process.env.CODEBUILD_RESOLVED_SOURCE_VERSION||process.env.AWS_COMMIT_ID||process.env.BUILD_SOURCEVERSION||process.env.GIT_CLONE_COMMIT_HASH||process.env.BUDDY_EXECUTION_REVISION||process.env.BUILDKITE_COMMIT||process.env.CIRCLE_SHA1||process.env.CIRRUS_CHANGE_IN_REPO||process.env.CF_REVISION||process.env.CM_COMMIT||process.env.CF_PAGES_COMMIT_SHA||process.env.DRONE_COMMIT_SHA||process.env.FC_GIT_COMMIT_SHA||process.env.HEROKU_TEST_RUN_COMMIT_VERSION||process.env.HEROKU_BUILD_COMMIT||process.env.HEROKU_SLUG_COMMIT||process.env.RAILWAY_GIT_COMMIT_SHA||process.env.RENDER_GIT_COMMIT||process.env.SEMAPHORE_GIT_SHA||process.env.TRAVIS_PULL_REQUEST_SHA||process.env.VERCEL_GIT_COMMIT_SHA||process.env.VERCEL_GITHUB_COMMIT_SHA||process.env.VERCEL_GITLAB_COMMIT_SHA||process.env.VERCEL_BITBUCKET_COMMIT_SHA||process.env.ZEIT_GITHUB_COMMIT_SHA||process.env.ZEIT_GITLAB_COMMIT_SHA||process.env.ZEIT_BITBUCKET_COMMIT_SHA,$=process.env.CI_COMMIT_ID||process.env.SOURCE_COMMIT||process.env.SOURCE_VERSION||process.env.GIT_COMMIT||process.env.COMMIT_REF||process.env.BUILD_VCS_NUMBER||process.env.CI_COMMIT_SHA;return F||Z||$||D}var xg=nZ(kK(bg()));var ug=N(M(),1),dg=N(i(),1);import*as gg from"node:os";import{threadId as Sf0,isMainThread as bf0}from"worker_threads";var vf0=60000;class IB extends U${constructor(D){let F=D.includeServerName===!1?void 0:D.serverName||global.process.env.SENTRY_NAME||gg.hostname(),Z={...D,platform:"node",runtime:D.runtime||{name:"node",version:global.process.version},serverName:F};if(D.openTelemetryInstrumentations)dg.registerInstrumentations({instrumentations:D.openTelemetryInstrumentations});E7(Z,"node"),q.log(`Initializing Sentry: process: ${process.pid}, thread: ${bf0?"main":`worker-${Sf0}`}.`);super(Z);if(this.getOptions().enableLogs){if(this._logOnExitFlushListener=()=>{i9(this)},F)this.on("beforeCaptureLog",($)=>{$.attributes={...$.attributes,"server.address":F}});process.on("beforeExit",this._logOnExitFlushListener)}}get tracer(){if(this._tracer)return this._tracer;let D="@sentry/node",F=D0,Z=ug.trace.getTracer(D,F);return this._tracer=Z,Z}async flush(D){if(await this.traceProvider?.forceFlush(),this.getOptions().sendClientReports)this._flushOutcomes();return super.flush(D)}async close(D){if(this._clientReportInterval)clearInterval(this._clientReportInterval);if(this._clientReportOnExitFlushListener)process.off("beforeExit",this._clientReportOnExitFlushListener);if(this._logOnExitFlushListener)process.off("beforeExit",this._logOnExitFlushListener);let F=await super.close(D);if(this.traceProvider)await this.traceProvider.shutdown();return F}startClientReportTracking(){let D=this.getOptions();if(D.sendClientReports)this._clientReportOnExitFlushListener=()=>{this._flushOutcomes()},this._clientReportInterval=setInterval(()=>{n&&q.log("Flushing client reports based on interval."),this._flushOutcomes()},D.clientReportFlushInterval??vf0).unref(),process.on("beforeExit",this._clientReportOnExitFlushListener)}_setupIntegrations(){uz(),super._setupIntegrations()}_getTraceInfoFromScope(D){if(!D)return[void 0,void 0];return xx(this,D)}}var mg=N(MW(),1);import*as cg from"module";function NB(){if(!qg())return;if(!l._sentryEsmLoaderHookRegistered){l._sentryEsmLoaderHookRegistered=!0;try{let{addHookMessagePort:D}=mg.createAddHookMessageChannel();cg.register("import-in-the-middle/hook.mjs",import.meta.url,{data:{addHookMessagePort:D,include:[]},transferList:[D]})}catch(D){q.warn("Failed to register 'import-in-the-middle' hook",D)}}}function qJ(){return[O$(),q$(),L$(),P$(),Eg(),rz(),A$(),Yg(),Mg(),Ag(),Rg(),Qg(),wg(),ex(),sx(),kg(),Pg()]}function TB(D={}){return xf0(D,qJ)}function xf0(D={},F){let Z=gf0(D,F);if(Z.debug===!0)if(n)q.enable();else h0(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")});if(Z.registerEsmLoaderHooks!==!1)NB();if(dx(),$0().update(Z.initialScope),Z.spotlight&&!Z.integrations.some(({name:Q})=>Q===MB))Z.integrations.push(Ng({sidecarUrl:typeof Z.spotlight==="string"?Z.spotlight:void 0}));E7(Z,"node-core");let J=new IB(Z);if($0().setClient(J),J.init(),q.log(`SDK initialized from ${T5()?"CommonJS":"ESM"}`),J.startClientReportTracking(),mf0(),Rx(J),ux(J),process.env.VERCEL)process.on("SIGTERM",async()=>{await J.flush(200)});return J}function EB(){if(!n)return;let D=Tx(),F=["SentryContextManager","SentryPropagator"];if(_0())F.push("SentrySpanProcessor");for(let Z of F)if(!D.includes(Z))q.error(`You have to set up the ${Z}. Without this, the OpenTelemetry & Sentry integration will not work properly.`);if(!D.includes("SentrySampler"))q.warn("You have to set up the SentrySampler. Without this, the OpenTelemetry & Sentry integration may still work, but sample rates set for the Sentry SDK will not be respected. If you use a custom sampler, make sure to use `wrapSamplingDecision`.")}function gf0(D,F){let Z=uf0(D.release),$=_g(D.spotlight),J=df0(D.tracesSampleRate),Q={...D,dsn:D.dsn??process.env.SENTRY_DSN,environment:D.environment??process.env.SENTRY_ENVIRONMENT,sendClientReports:D.sendClientReports??!0,transport:D.transport??hg,stackParser:oW(D.stackParser||xg),release:Z,tracesSampleRate:J,spotlight:$,debug:r9(D.debug??process.env.SENTRY_DEBUG)},X=D.integrations,Y=D.defaultIntegrations??F(Q);return{...Q,integrations:Tz({defaultIntegrations:Y,integrations:X})}}function uf0(D){if(D!==void 0)return D;let F=vg();if(F!==void 0)return F;return}function df0(D){if(D!==void 0)return D;let F=process.env.SENTRY_TRACES_SAMPLE_RATE;if(!F)return;let Z=parseFloat(F);return isFinite(Z)?Z:void 0}function mf0(){if(r9(process.env.SENTRY_USE_ENVIRONMENT)!==!1){let D=process.env.SENTRY_TRACE,F=process.env.SENTRY_BAGGAGE,Z=b4(D,F);$0().setPropagationContext(Z)}}function W0(D,F){D.setAttribute(u,F)}function y5(D){let F=D.protocol||"",Z=D.hostname||D.host||"",$=!D.port||D.port===80||D.port===443||/^(.*):(\d+)$/.test(Z)?"":`:${D.port}`,J=D.path?D.path:"/";return`${F}//${Z}${$}${J}`}var fB="Http",lg="@opentelemetry_sentry-patched/instrumentation-http",CJ=e8.major===22&&e8.minor>=12||e8.major===23&&e8.minor>=2||e8.major>=24,cf0=_(`${fB}.sentry`,(D)=>{return new W3(D)}),lf0=_(fB,(D)=>{let F=new ig.HttpInstrumentation({...D,disableIncomingRequestInstrumentation:!0});try{F._diag=pg.diag.createComponentLogger({namespace:lg}),F.instrumentationName=lg}catch{}try{let Z={get:()=>!1,set:()=>{}};Object.defineProperty(F,"_httpPatched",Z),Object.defineProperty(F,"_httpsPatched",Z)}catch{}return F});function pf0(D,F={}){if(typeof D.spans==="boolean")return D.spans;if(F.skipOpenTelemetrySetup)return!1;if(!_0(F)&&CJ)return!1;return!0}var ng=A((D={})=>{let F=D.spans??!0,Z=D.disableIncomingRequestSpans,$={sessions:D.trackIncomingRequestsAsSessions,sessionFlushingDelayMS:D.sessionFlushingDelayMS,ignoreRequestBody:D.ignoreIncomingRequestBody,maxRequestBodySize:D.maxIncomingRequestBodySize},J={ignoreIncomingRequests:D.ignoreIncomingRequests,ignoreStaticAssets:D.ignoreStaticAssets,ignoreStatusCodes:D.dropSpansForIncomingRequestStatusCodes,instrumentation:D.instrumentation,onSpanCreated:D.incomingRequestSpanHook},Q=B5($),X=G5(J),Y=F&&!Z;return{name:fB,setup(W){let z=W.getOptions();if(Y&&_0(z))X.setup(W)},setupOnce(){let W=v()?.getOptions()||{},z=pf0(D,W);Q.setupOnce();let B={breadcrumbs:D.breadcrumbs,propagateTraceInOutgoingRequests:typeof D.tracePropagation==="boolean"?D.tracePropagation:CJ||!z,createSpansForOutgoingRequests:CJ,spans:D.spans,ignoreOutgoingRequests:D.ignoreOutgoingRequests,outgoingRequestHook:(K,G)=>{let H=y5(G);if(H.startsWith("data:")){let V=t9(H);K.setAttribute("http.url",V),K.setAttribute(q6,V),K.updateName(`${G.method||"GET"} ${V}`)}D.instrumentation?.requestHook?.(K,G)},outgoingResponseHook:D.instrumentation?.responseHook,outgoingRequestApplyCustomAttributes:D.instrumentation?.applyCustomAttributesOnSpan};if(cf0(B),z){let K=if0(D);lf0(K)}},processEvent(W){return X.processEvent(W)}}});function if0(D={}){return{disableOutgoingRequestInstrumentation:CJ,ignoreOutgoingRequestHook:(Z)=>{let $=y5(Z);if(!$)return!1;let J=D.ignoreOutgoingRequests;if(J?.($,Z))return!0;return!1},requireParentforOutgoingSpans:!1,requestHook:(Z,$)=>{W0(Z,"auto.http.otel.http");let J=y5($);if(J.startsWith("data:")){let Q=t9(J);Z.setAttribute("http.url",Q),Z.setAttribute(q6,Q),Z.updateName(`${$.method||"GET"} ${Q}`)}D.instrumentation?.requestHook?.(Z,$)},responseHook:(Z,$)=>{D.instrumentation?.responseHook?.(Z,$)},applyCustomAttributesOnSpan:(Z,$,J)=>{D.instrumentation?.applyCustomAttributesOnSpan?.(Z,$,J)}}}var Ju=N(Zu(),1);var Qu="NodeFetch",rf0=_(Qu,Ju.UndiciInstrumentation,(D)=>{return Fy0(D)}),tf0=_(`${Qu}.sentry`,K3,(D)=>{return D}),ef0=(D={})=>{return{name:"NodeFetch",setupOnce(){if(Dy0(D,v()?.getOptions()))rf0(D);tf0(D)}}},Xu=A(ef0);function $u(D,F="/"){let Z=`${D}`;if(Z.endsWith("/")&&F.startsWith("/"))return`${Z}${F.slice(1)}`;if(!Z.endsWith("/")&&!F.startsWith("/"))return`${Z}/${F}`;return`${Z}${F}`}function Dy0(D,F={}){return typeof D.spans==="boolean"?D.spans:!F.skipOpenTelemetrySetup&&_0(F)}function Fy0(D={}){return{requireParentforSpans:!1,ignoreRequestHook:(Z)=>{let $=$u(Z.origin,Z.path),J=D.ignoreOutgoingRequests;return!!(J&&$&&J($))},startSpanHook:(Z)=>{let $=$u(Z.origin,Z.path);if($.startsWith("data:")){let J=t9($);return{[u]:"auto.http.otel.node_fetch","http.url":J,[q6]:J,[C8]:`${Z.method||"GET"} ${J}`}}return{[u]:"auto.http.otel.node_fetch"}},requestHook:D.requestHook,responseHook:D.responseHook,headersToSpanAttributes:D.headersToSpanAttributes}}var Nu=N(Iu(),1);var i0=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;var Tu="Express";function ky0(D){W0(D,"auto.http.otel.express");let F=g(D).data,Z=F["express.type"];if(Z)D.setAttribute(c,`${Z}.express`);let $=F["express.name"];if(typeof $==="string")D.updateName($)}function Iy0(D,F){if(e()===aD())return i0&&q.warn("Isolation scope is still default isolation scope - skipping setting transactionName"),F;if(D.layerType==="request_handler"){let Z=D.request,$=Z.method?Z.method.toUpperCase():"GET";e().setTransactionName(`${$} ${D.route}`)}return F}var Eu=_(Tu,()=>new Nu.ExpressInstrumentation({requestHook:(D)=>ky0(D),spanNameHook:(D,F)=>Iy0(D,F)})),Ny0=()=>{return{name:Tu,setupOnce(){Eu()}}},fu=A(Ny0);var wc=N(Yc(),1);import*as NG from"node:diagnostics_channel";var Z1=N(M(),1),xJ=N(Q0(),1),l7=N(i(),1),Gc=N(F0(),1);var p1;(function(D){D.FASTIFY_NAME="fastify.name";let Z="fastify.type";D.FASTIFY_TYPE=Z;let $="hook.name";D.HOOK_NAME=$;let J="plugin.name";D.PLUGIN_NAME=J})(p1||(p1={}));var o5;(function(D){D.MIDDLEWARE="middleware";let Z="request_handler";D.REQUEST_HANDLER=Z})(o5||(o5={}));var s5;(function(D){D.MIDDLEWARE="middleware";let Z="request handler";D.REQUEST_HANDLER=Z})(s5||(s5={}));var zc=N(M(),1);var r5=Symbol("opentelemetry.instrumentation.fastify.request_active_span");function kG(D,F,Z,$={}){let J=F.startSpan(Z,{attributes:$}),Q=D[r5]||[];return Q.push(J),Object.defineProperty(D,r5,{enumerable:!1,configurable:!0,value:Q}),J}function vJ(D,F){let Z=D[r5]||[];if(!Z.length)return;Z.forEach(($)=>{if(F)$.setStatus({code:zc.SpanStatusCode.ERROR,message:F.message}),$.recordException(F);$.end()}),delete D[r5]}function Kc(D,F,Z){let $,J=void 0;try{if(J=D(),Wc(J))J.then((Q)=>F(void 0,Q),(Q)=>F(Q))}catch(Q){$=Q}finally{if(!Wc(J)){if(F($,J),$)throw $}return J}}function Wc(D){return typeof D==="object"&&D&&typeof Object.getOwnPropertyDescriptor(D,"then")?.value==="function"||!1}var iS0="0.1.0",nS0="@sentry/instrumentation-fastify-v3",Bc="anonymous",aS0=new Set(["onTimeout","onRequest","preParsing","preValidation","preSerialization","preHandler","onSend","onResponse","onError"]);class IG extends l7.InstrumentationBase{constructor(D={}){super(nS0,iS0,D)}init(){return[new l7.InstrumentationNodeModuleDefinition("fastify",[">=3.0.0 <4"],(D)=>{return this._patchConstructor(D)})]}_hookOnRequest(){let D=this;return function(Z,$,J){if(!D.isEnabled())return J();D._wrap($,"send",D._patchSend());let Q=Z,X=xJ.getRPCMetadata(Z1.context.active()),Y=Q.routeOptions?Q.routeOptions.url:Z.routerPath;if(Y&&X?.type===xJ.RPCType.HTTP)X.route=Y;let W=Z.method||"GET";e().setTransactionName(`${W} ${Y}`),J()}}_wrapHandler(D,F,Z,$){let J=this;return this._diag.debug("Patching fastify route.handler function"),function(...Q){if(!J.isEnabled())return Z.apply(this,Q);let X=Z.name||D||Bc,Y=`${s5.MIDDLEWARE} - ${X}`,W=Q[1],z=kG(W,J.tracer,Y,{[p1.FASTIFY_TYPE]:o5.MIDDLEWARE,[p1.PLUGIN_NAME]:D,[p1.HOOK_NAME]:F}),B=$&&Q[Q.length-1];if(B)Q[Q.length-1]=function(...K){vJ(W),B.apply(this,K)};return Z1.context.with(Z1.trace.setSpan(Z1.context.active(),z),()=>{return Kc(()=>{return Z.apply(this,Q)},(K)=>{if(K instanceof Error)z.setStatus({code:Z1.SpanStatusCode.ERROR,message:K.message}),z.recordException(K);if(!$)vJ(W)})})}}_wrapAddHook(){let D=this;return this._diag.debug("Patching fastify server.addHook function"),function(F){return function(...$){let J=$[0],Q=$[1],X=this.pluginName;if(!aS0.has(J))return F.apply(this,$);let Y=typeof $[$.length-1]==="function"&&Q.constructor.name!=="AsyncFunction";return F.apply(this,[J,D._wrapHandler(X,J,Q,Y)])}}}_patchConstructor(D){let F=this;function Z(...$){let J=D.fastify.apply(this,$);return J.addHook("onRequest",F._hookOnRequest()),J.addHook("preHandler",F._hookPreHandler()),oS0(),F._wrap(J,"addHook",F._wrapAddHook()),J}if(D.errorCodes!==void 0)Z.errorCodes=D.errorCodes;return Z.fastify=Z,Z.default=Z,Z}_patchSend(){let D=this;return this._diag.debug("Patching fastify reply.send function"),function(Z){return function(...J){let Q=J[0];if(!D.isEnabled())return Z.apply(this,J);return l7.safeExecuteInTheMiddle(()=>{return Z.apply(this,J)},(X)=>{if(!X&&Q instanceof Error)X=Q;vJ(this,X)})}}}_hookPreHandler(){let D=this;return this._diag.debug("Patching fastify preHandler function"),function(Z,$,J){if(!D.isEnabled())return J();let Q=Z,X=Q.routeOptions?.handler||Q.context?.handler,Y=X?.name.startsWith("bound ")?X.name.substring(6):X?.name,W=`${s5.REQUEST_HANDLER} - ${Y||this.pluginName||Bc}`,z={[p1.PLUGIN_NAME]:this.pluginName,[p1.FASTIFY_TYPE]:o5.REQUEST_HANDLER,[Gc.SEMATTRS_HTTP_ROUTE]:Q.routeOptions?Q.routeOptions.url:Z.routerPath};if(Y)z[p1.FASTIFY_NAME]=Y;let B=kG($,D.tracer,W,z);Hc(B);let{requestHook:K}=D.getConfig();if(K)l7.safeExecuteInTheMiddle(()=>K(B,{request:Z}),(G)=>{if(G)D._diag.error("request hook failed",G)},!0);return Z1.context.with(Z1.trace.setSpan(Z1.context.active(),B),()=>{J()})}}}function oS0(){let D=v();if(D)D.on("spanStart",(F)=>{Hc(F)})}function Hc(D){let F=g(D).data,Z=F["fastify.type"];if(F[c]||!Z)return;D.setAttributes({[u]:"auto.http.otel.fastify",[c]:`${Z}.fastify`});let $=F["fastify.name"]||F["plugin.name"]||F["hook.name"];if(typeof $==="string"){let J=$.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");D.updateName(J)}}var gJ="Fastify",Uc=_(`${gJ}.v3`,()=>new IG);function sS0(){let D=v();if(!D)return;else return D.getIntegrationByName(gJ)}function Vc(D,F,Z,$){let J=sS0()?.getShouldHandleError()||Cc;if($==="diagnostics-channel")this.diagnosticsChannelExists=!0;if(this.diagnosticsChannelExists&&$==="onError-hook"){i0&&q.warn("Fastify error handler was already registered via diagnostics channel.","You can safely remove `setupFastifyErrorHandler` call and set `shouldHandleError` on the integration options.");return}if(J(D,F,Z))p(D,{mechanism:{handled:!1,type:"auto.function.fastify"}})}var jc=_(`${gJ}.v5`,()=>{let D=new wc.FastifyOtelInstrumentation,F=D.plugin();return NG.subscribe("fastify.initialization",(Z)=>{let $=Z.fastify;$?.register(F).after((J)=>{if(J)i0&&q.error("Failed to setup Fastify instrumentation",J);else if(tS0(),$)eS0($)})}),NG.subscribe("tracing:fastify.request.handler:error",(Z)=>{let{error:$,request:J,reply:Q}=Z;Vc.call(Vc,$,J,Q,"diagnostics-channel")}),D}),rS0=({shouldHandleError:D})=>{let F;return{name:gJ,setupOnce(){F=D||Cc,Uc(),jc()},getShouldHandleError(){return F},setShouldHandleError(Z){F=Z}}},qc=A((D={})=>rS0(D));function Cc(D,F,Z){let $=Z.statusCode;return $>=500||$<=299}function Oc(D){let F=g(D),Z=F.description,$=F.data,J=$["fastify.type"],Q=J==="hook",X=J===Z?.startsWith("handler -"),Y=Z==="request"||J==="request-handler";if($[c]||!X&&!Y&&!Q)return;let W=Q?"hook":X?"middleware":Y?"request_handler":"<unknown>";D.setAttributes({[u]:"auto.http.otel.fastify",[c]:`${W}.fastify`});let z=$["fastify.name"]||$["plugin.name"]||$["hook.name"];if(typeof z==="string"){let B=z.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");D.updateName(B)}}function tS0(){let D=v();if(D)D.on("spanStart",(F)=>{Oc(F)})}function eS0(D){D.addHook("onRequest",async(F,Z)=>{if(F.opentelemetry){let{span:Q}=F.opentelemetry();if(Q)Oc(Q)}let $=F.routeOptions?.url,J=F.method||"GET";e().setTransactionName(`${J} ${$}`)})}var $l=N(M(),1),Jl=N(Zl(),1);var Ql="Graphql",Xl=_(Ql,Jl.GraphQLInstrumentation,(D)=>{let F=Wl(D);return{...F,responseHook(Z,$){if(W0(Z,"auto.graphql.otel.graphql"),$.errors?.length&&!g(Z).status)Z.setStatus({code:$l.SpanStatusCode.ERROR});let Q=g(Z).data,X=Q["graphql.operation.type"],Y=Q["graphql.operation.name"];if(F.useOperationNameForRootSpan&&X){let W=I0(Z),B=g(W).data[q3]||[],K=Y?`${X} ${Y}`:`${X}`;if(Array.isArray(B))B.push(K),W.setAttribute(q3,B);else if(typeof B==="string")W.setAttribute(q3,[B,K]);else W.setAttribute(q3,K);if(!g(W).data["original-description"])W.setAttribute("original-description",g(W).description);W.updateName(`${g(W).data["original-description"]} (${Tb0(B)})`)}}}}),Nb0=(D={})=>{return{name:Ql,setupOnce(){Xl(Wl(D))}}},Yl=A(Nb0);function Wl(D){return{ignoreResolveSpans:!0,ignoreTrivialResolveSpans:!0,useOperationNameForRootSpan:!0,...D}}function Tb0(D){if(Array.isArray(D)){let F=D.slice().sort();if(F.length<=5)return F.join(", ");else return`${F.slice(0,5).join(", ")}, +${F.length-5}`}return`${D}`}var fl=N(El(),1);var yl="Kafka",hl=_(yl,()=>new fl.KafkaJsInstrumentation({consumerHook(D){W0(D,"auto.kafkajs.otel.consumer")},producerHook(D){W0(D,"auto.kafkajs.otel.producer")}})),ob0=()=>{return{name:yl,setupOnce(){hl()}}},_l=A(ob0);var il=N(pl(),1);var nl="LruMemoizer",al=_(nl,()=>new il.LruMemoizerInstrumentation),eb0=()=>{return{name:nl,setupOnce(){al()}}},ol=A(eb0);var Gp=N(Bp(),1);var Hp="Mongo",Vp=_(Hp,()=>new Gp.MongoDBInstrumentation({dbStatementSerializer:Uv0,responseHook(D){W0(D,"auto.db.otel.mongo")}}));function Uv0(D){let F=dG(D);return JSON.stringify(F)}function dG(D){if(Array.isArray(D))return D.map((F)=>dG(F));if(jv0(D)){let F={};return Object.entries(D).map(([Z,$])=>[Z,dG($)]).reduce((Z,$)=>{if(Cv0($))Z[$[0]]=$[1];return Z},F)}return"?"}function jv0(D){return typeof D==="object"&&D!==null&&!qv0(D)}function qv0(D){let F=!1;if(typeof Buffer<"u")F=Buffer.isBuffer(D);return F}function Cv0(D){return Array.isArray(D)}var Ov0=()=>{return{name:Hp,setupOnce(){Vp()}}},wp=A(Ov0);var Sp=N(_p(),1);var bp="Mongoose",vp=_(bp,()=>new Sp.MongooseInstrumentation({responseHook(D){W0(D,"auto.db.otel.mongoose")}})),dv0=()=>{return{name:bp,setupOnce(){vp()}}},xp=A(dv0);var Zi=N(Fi(),1);var $i="Mysql",Ji=_($i,()=>new Zi.MySQLInstrumentation({})),Hx0=()=>{return{name:$i,setupOnce(){Ji()}}},Qi=A(Hx0);var y80=N(f80(),1);var h80="Mysql2",_80=_(h80,()=>new y80.MySQL2Instrumentation({responseHook(D){W0(D,"auto.db.otel.mysql2")}})),Zt0=()=>{return{name:h80,setupOnce(){_80()}}},S80=A(Zt0);var h10=N(D10(),1),_10=N(N10(),1);var gt0=["get","set","setex"],RH=["get","mget"],ut0=["set","setex"];function GF(D,F){return D.includes(F.toLowerCase())}function kH(D){if(GF(RH,D))return"cache.get";else if(GF(ut0,D))return"cache.put";else return}function dt0(D,F){return F.some((Z)=>D.startsWith(Z))}function E10(D,F){try{if(F.length===0)return;let Z=(J)=>{if(typeof J==="string"||typeof J==="number"||Buffer.isBuffer(J))return[J.toString()];else if(Array.isArray(J))return T10(J.map((Q)=>Z(Q)));else return["<unknown>"]},$=F[0];if(GF(gt0,D)&&$!=null)return Z($);return T10(F.map((J)=>Z(J)))}catch{return}}function f10(D,F,Z){if(!kH(D))return!1;for(let $ of F)if(dt0($,Z))return!0;return!1}function y10(D){let F=(Z)=>{try{if(Buffer.isBuffer(Z))return Z.byteLength;else if(typeof Z==="string")return Z.length;else if(typeof Z==="number")return Z.toString().length;else if(Z===null||Z===void 0)return 0;return JSON.stringify(Z).length}catch{return}};return Array.isArray(D)?D.reduce((Z,$)=>{let J=F($);return typeof J==="number"?Z!==void 0?Z+J:J:Z},0):F(D)}function T10(D){let F=[],Z=($)=>{$.forEach((J)=>{if(Array.isArray(J))Z(J);else F.push(J)})};return Z(D),F}var BQ="Redis",HF={},S10=(D,F,Z,$)=>{D.setAttribute(u,"auto.db.otel.redis");let J=E10(F,Z),Q=kH(F);if(!J||!Q||!HF.cachePrefixes||!f10(F,J,HF.cachePrefixes))return;let X=g(D).data["net.peer.name"],Y=g(D).data["net.peer.port"];if(Y&&X)D.setAttributes({"network.peer.address":X,"network.peer.port":Y});let W=y10($);if(W)D.setAttribute(zz,W);if(GF(RH,F)&&W!==void 0)D.setAttribute(Yz,W>0);D.setAttributes({[c]:Q,[Wz]:J});let z=J.join(", ");D.updateName(HF.maxCacheKeyLength?H6(z,HF.maxCacheKeyLength):z)},mt0=_(`${BQ}.IORedis`,()=>{return new h10.IORedisInstrumentation({responseHook:S10})}),ct0=_(`${BQ}.Redis`,()=>{return new _10.RedisInstrumentation({responseHook:S10})}),b10=Object.assign(()=>{mt0(),ct0()},{id:BQ}),lt0=(D={})=>{return{name:BQ,setupOnce(){HF=D,b10()}}},v10=A(lt0);var H60=N(G60(),1);var V60="Postgres",w60=_(V60,H60.PgInstrumentation,(D)=>({requireParentSpan:!0,requestHook(F){W0(F,"auto.db.otel.postgres")},ignoreConnectSpans:D?.ignoreConnectSpans??!1})),be0=(D)=>{return{name:V60,setupOnce(){w60(D)}}},U60=A(be0);var y3=N(M(),1),a6=N(i(),1),X1=N(F0(),1);var hH="PostgresJs",j60=[">=3.0.0 <4"],ve0=/^(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER)/i,xe0=Symbol.for("sentry.query.from.instrumented.sql"),q60=_(hH,(D)=>new C60({requireParentSpan:D?.requireParentSpan??!0,requestHook:D?.requestHook}));class C60 extends a6.InstrumentationBase{constructor(D){super("sentry-postgres-js",D0,D)}init(){let D=new a6.InstrumentationNodeModuleDefinition("postgres",j60,(F)=>{try{return this._patchPostgres(F)}catch(Z){return i0&&q.error("Failed to patch postgres module:",Z),F}},(F)=>F);return["src","cf/src","cjs/src"].forEach((F)=>{D.files.push(new a6.InstrumentationNodeModuleFile(`postgres/${F}/query.js`,j60,this._patchQueryPrototype.bind(this),this._unpatchQueryPrototype.bind(this)))}),D}_patchPostgres(D){let F=typeof D==="function",Z=F?D:D.default;if(typeof Z!=="function")return i0&&q.warn("postgres module does not export a function. Skipping instrumentation."),D;let $=this,J=function(...Q){let X=Reflect.construct(Z,Q);if(!X||typeof X!=="function")return i0&&q.warn("postgres() did not return a valid instance"),X;let Y=$.getConfig();return sz(X,{requireParentSpan:Y.requireParentSpan,requestHook:Y.requestHook})};Object.setPrototypeOf(J,Z),Object.setPrototypeOf(J.prototype,Z.prototype);for(let Q of Object.getOwnPropertyNames(Z))if(!["length","name","prototype"].includes(Q)){let X=Object.getOwnPropertyDescriptor(Z,Q);if(X)Object.defineProperty(J,Q,X)}if(F)return J;else return K5(D,"default",J),D}_shouldCreateSpans(){let D=this.getConfig();return y3.trace.getSpan(y3.context.active())!==void 0||!D.requireParentSpan}_setOperationName(D,F,Z){if(Z){D.setAttribute(X1.ATTR_DB_OPERATION_NAME,Z);return}let $=F?.match(ve0);if($?.[1])D.setAttribute(X1.ATTR_DB_OPERATION_NAME,$[1].toUpperCase())}_reconstructQuery(D){if(!D?.length)return;if(D.length===1)return D[0]||void 0;return D.reduce((F,Z,$)=>$===0?Z:`${F}$${$}${Z}`,"")}_sanitizeSqlQuery(D){if(!D)return"Unknown SQL Query";return D.replace(/--.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/;\s*$/,"").replace(/\s+/g," ").trim().replace(/\bX'[0-9A-Fa-f]*'/gi,"?").replace(/\bB'[01]*'/gi,"?").replace(/'(?:[^']|'')*'/g,"?").replace(/\b0x[0-9A-Fa-f]+/gi,"?").replace(/\b(?:TRUE|FALSE)\b/gi,"?").replace(/-?\b\d+\.?\d*[eE][+-]?\d+\b/g,"?").replace(/-?\b\d+\.\d+\b/g,"?").replace(/-?\.\d+\b/g,"?").replace(/(?<!\$)-?\b\d+\b/g,"?").replace(/\bIN\b\s*\(\s*\?(?:\s*,\s*\?)*\s*\)/gi,"IN (?)").replace(/\bIN\b\s*\(\s*\$\d+(?:\s*,\s*\$\d+)*\s*\)/gi,"IN ($?)")}_patchQueryPrototype(D){let F=this,Z=D.Query.prototype.handle;return D.Query.prototype.handle=async function(...$){if(this[xe0])return Z.apply(this,$);if(!F._shouldCreateSpans())return Z.apply(this,$);let J=F._reconstructQuery(this.strings),Q=F._sanitizeSqlQuery(J);return e0({name:Q||"postgresjs.query",op:"db"},(X)=>{W0(X,"auto.db.postgresjs"),X.setAttributes({[X1.ATTR_DB_SYSTEM_NAME]:"postgres",[X1.ATTR_DB_QUERY_TEXT]:Q});let Y=F.getConfig(),{requestHook:W}=Y;if(W)a6.safeExecuteInTheMiddle(()=>W(X,Q,void 0),(K)=>{if(K)X.setAttribute("sentry.hook.error","requestHook failed"),i0&&q.error(`Error in requestHook for ${hH} integration:`,K)},!0);let z=this.resolve;this.resolve=new Proxy(z,{apply:(K,G,H)=>{try{F._setOperationName(X,Q,H?.[0]?.command),X.end()}catch(V){i0&&q.error("Error ending span in resolve callback:",V)}return Reflect.apply(K,G,H)}});let B=this.reject;this.reject=new Proxy(B,{apply:(K,G,H)=>{try{X.setStatus({code:s,message:H?.[0]?.message||"unknown_error"}),X.setAttribute(X1.ATTR_DB_RESPONSE_STATUS_CODE,H?.[0]?.code||"unknown"),X.setAttribute(X1.ATTR_ERROR_TYPE,H?.[0]?.name||"unknown"),F._setOperationName(X,Q),X.end()}catch(V){i0&&q.error("Error ending span in reject callback:",V)}return Reflect.apply(K,G,H)}});try{return Z.apply(this,$)}catch(K){throw X.setStatus({code:s,message:K instanceof Error?K.message:"unknown_error"}),X.end(),K}})},D.Query.prototype.handle.__sentry_original__=Z,D}_unpatchQueryPrototype(D){if(D.Query.prototype.handle.__sentry_original__)D.Query.prototype.handle=D.Query.prototype.handle.__sentry_original__;return D}}var ge0=(D)=>{return{name:hH,setupOnce(){q60(D)}}},O60=A(ge0);var b8=N(M(),1);var z90=N(M(),1),AQ=N(X90(),1),o6=N(M(),1);var _DD={name:"@prisma/instrumentation-contract",version:"7.4.2",description:"Shared types and utilities for Prisma instrumentation",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{require:{types:"./dist/index.d.ts",default:"./dist/index.js"},import:{types:"./dist/index.d.mts",default:"./dist/index.mjs"}}},license:"Apache-2.0",homepage:"https://www.prisma.io",repository:{type:"git",url:"https://github.com/prisma/prisma.git",directory:"packages/instrumentation-contract"},bugs:"https://github.com/prisma/prisma/issues",scripts:{dev:"DEV=true tsx helpers/build.ts",build:"tsx helpers/build.ts",prepublishOnly:"pnpm run build",test:"vitest run"},files:["dist"],sideEffects:!1,devDependencies:{"@opentelemetry/api":"1.9.0"},peerDependencies:{"@opentelemetry/api":"^1.8"}},SDD=_DD.version.split(".")[0],KV="PRISMA_INSTRUMENTATION",BV=`V${SDD}_PRISMA_INSTRUMENTATION`,S3=globalThis;function bDD(){let D=S3[BV];if(D?.helper)return D.helper;return S3[KV]?.helper}function vDD(D){let F={helper:D};S3[BV]=F,S3[KV]=F}function xDD(){delete S3[BV],delete S3[KV]}var gDD=process.env.PRISMA_SHOW_ALL_TRACES==="true",uDD="00-10-10-00";function dDD(D){switch(D){case"client":return o6.SpanKind.CLIENT;case"internal":default:return o6.SpanKind.INTERNAL}}var mDD=class{tracerProvider;ignoreSpanTypes;constructor({tracerProvider:D,ignoreSpanTypes:F}){this.tracerProvider=D,this.ignoreSpanTypes=F}isEnabled(){return!0}getTraceParent(D){let F=o6.trace.getSpanContext(D??o6.context.active());if(F)return`00-${F.traceId}-${F.spanId}-0${F.traceFlags}`;return uDD}dispatchEngineSpans(D){let F=this.tracerProvider.getTracer("prisma"),Z=new Map,$=D.filter((J)=>J.parentId===null);for(let J of $)K90(F,J,D,Z,this.ignoreSpanTypes)}getActiveContext(){return o6.context.active()}runInChildSpan(D,F){if(typeof D==="string")D={name:D};if(D.internal&&!gDD)return F();let Z=this.tracerProvider.getTracer("prisma"),$=D.context??this.getActiveContext(),J=`prisma:client:${D.name}`;if(B90(J,this.ignoreSpanTypes))return F();if(D.active===!1){let Q=Z.startSpan(J,D,$);return Y90(Q,F(Q,$))}return Z.startActiveSpan(J,D,(Q)=>Y90(Q,F(Q,$)))}};function K90(D,F,Z,$,J){if(B90(F.name,J))return;let Q={attributes:F.attributes,kind:dDD(F.kind),startTime:F.startTime};D.startActiveSpan(F.name,Q,(X)=>{if($.set(F.id,X.spanContext().spanId),F.links)X.addLinks(F.links.flatMap((W)=>{let z=$.get(W);if(!z)return[];return{context:{spanId:z,traceId:X.spanContext().traceId,traceFlags:X.spanContext().traceFlags}}}));let Y=Z.filter((W)=>W.parentId===F.id);for(let W of Y)K90(D,W,Z,$,J);X.end(F.endTime)})}function Y90(D,F){if(cDD(F))return F.then((Z)=>{return D.end(),Z},(Z)=>{throw D.end(),Z});return D.end(),F}function cDD(D){return D!=null&&typeof D.then==="function"}function B90(D,F){return F.some((Z)=>typeof Z==="string"?Z===D:Z.test(D))}var G90={name:"@prisma/instrumentation",version:"7.4.2",description:"OpenTelemetry compliant instrumentation for Prisma Client",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{require:{types:"./dist/index.d.ts",default:"./dist/index.js"},import:{types:"./dist/index.d.ts",default:"./dist/index.mjs"}}},license:"Apache-2.0",homepage:"https://www.prisma.io",repository:{type:"git",url:"https://github.com/prisma/prisma.git",directory:"packages/instrumentation"},bugs:"https://github.com/prisma/prisma/issues",devDependencies:{"@opentelemetry/api":"1.9.0","@prisma/instrumentation-contract":"workspace:*","@types/node":"~20.19.24",typescript:"5.4.5"},dependencies:{"@opentelemetry/instrumentation":"^0.207.0"},peerDependencies:{"@opentelemetry/api":"^1.8"},files:["dist"],keywords:["prisma","instrumentation","opentelemetry","otel"],scripts:{dev:"DEV=true tsx helpers/build.ts",build:"tsx helpers/build.ts",prepublishOnly:"pnpm run build",test:"vitest run"},sideEffects:!1},W90=G90.version,lDD=G90.name,pDD="@prisma/client",H90=class extends AQ.InstrumentationBase{tracerProvider;constructor(D={}){super(lDD,W90,D)}setTracerProvider(D){this.tracerProvider=D}init(){return[new AQ.InstrumentationNodeModuleDefinition(pDD,[W90])]}enable(){let D=this._config;vDD(new mDD({tracerProvider:this.tracerProvider??z90.trace.getTracerProvider(),ignoreSpanTypes:D.ignoreSpanTypes??[]}))}disable(){xDD()}isEnabled(){return bDD()!==void 0}};var V90="Prisma";function iDD(D){return!!D&&typeof D==="object"&&"dispatchEngineSpans"in D}function w90(){let D=globalThis.PRISMA_INSTRUMENTATION;return D&&typeof D==="object"&&"helper"in D?D.helper:void 0}class U90 extends H90{constructor(D){super(D?.instrumentationConfig)}enable(){super.enable();let D=w90();if(iDD(D))D.createEngineSpan=(F)=>{let Z=b8.trace.getTracer("prismaV5Compatibility"),$=Z._idGenerator;if(!$){h0(()=>{console.warn("[Sentry] Could not find _idGenerator on tracer, skipping Prisma v5 compatibility - some Prisma spans may be missing!")});return}try{F.spans.forEach((J)=>{let Q=nDD(J.kind),X=J.parent_span_id,Y=J.span_id,W=J.trace_id,z=J.links?.map((K)=>{return{context:{traceId:K.trace_id,spanId:K.span_id,traceFlags:b8.TraceFlags.SAMPLED}}}),B=b8.trace.setSpanContext(b8.context.active(),{traceId:W,spanId:X,traceFlags:b8.TraceFlags.SAMPLED});b8.context.with(B,()=>{let K={generateTraceId:()=>{return W},generateSpanId:()=>{return Y}};Z._idGenerator=K,Z.startSpan(J.name,{kind:Q,links:z,startTime:J.start_time,attributes:J.attributes}).end(J.end_time),Z._idGenerator=$})})}finally{Z._idGenerator=$}}}}function nDD(D){switch(D){case"client":return b8.SpanKind.CLIENT;case"internal":default:return b8.SpanKind.INTERNAL}}var aDD=_(V90,(D)=>{return new U90(D)}),j90=A((D)=>{return{name:V90,setupOnce(){aDD(D)},setup(F){if(!w90())return;F.on("spanStart",(Z)=>{let $=g(Z);if($.description?.startsWith("prisma:"))Z.setAttribute(u,"auto.db.otel.prisma");if($.description==="prisma:engine:db_query"&&$.data["db.query.text"])Z.updateName($.data["db.query.text"]);if($.description==="prisma:engine:db_query"&&!$.data["db.system"])Z.setAttribute("db.system","prisma")})}}});var g90=N(x90(),1);var u90="Hapi",d90=_(u90,()=>new g90.HapiInstrumentation),q8D=()=>{return{name:u90,setupOnce(){d90()}}},m90=A(q8D);var IQ=N(F0(),1);var r6={HONO_TYPE:"hono.type",HONO_NAME:"hono.name"},AF={MIDDLEWARE:"middleware",REQUEST_HANDLER:"request_handler"};var J9=N(M(),1),kQ=N(i(),1);var C8D="@sentry/instrumentation-hono",O8D="0.0.1";class UV extends kQ.InstrumentationBase{constructor(D={}){super(C8D,O8D,D)}init(){return[new kQ.InstrumentationNodeModuleDefinition("hono",[">=4.0.0 <5"],(D)=>this._patch(D))]}_patch(D){let F=this;class Z extends D.Hono{constructor(...$){super(...$);F._wrap(this,"get",F._patchHandler()),F._wrap(this,"post",F._patchHandler()),F._wrap(this,"put",F._patchHandler()),F._wrap(this,"delete",F._patchHandler()),F._wrap(this,"options",F._patchHandler()),F._wrap(this,"patch",F._patchHandler()),F._wrap(this,"all",F._patchHandler()),F._wrap(this,"on",F._patchOnHandler()),F._wrap(this,"use",F._patchMiddlewareHandler())}}try{D.Hono=Z}catch{return{...D,Hono:Z}}return D}_patchHandler(){let D=this;return function(F){return function(...$){if(typeof $[0]==="string"){let J=$[0];if($.length===1)return F.apply(this,[J]);let Q=$.slice(1);return F.apply(this,[J,...Q.map((X)=>D._wrapHandler(X))])}return F.apply(this,$.map((J)=>D._wrapHandler(J)))}}}_patchOnHandler(){let D=this;return function(F){return function(...$){let J=$.slice(2);return F.apply(this,[...$.slice(0,2),...J.map((Q)=>D._wrapHandler(Q))])}}}_patchMiddlewareHandler(){let D=this;return function(F){return function(...$){if(typeof $[0]==="string"){let J=$[0];if($.length===1)return F.apply(this,[J]);let Q=$.slice(1);return F.apply(this,[J,...Q.map((X)=>D._wrapHandler(X))])}return F.apply(this,$.map((J)=>D._wrapHandler(J)))}}}_wrapHandler(D){let F=this;return function(Z,$){if(!F.isEnabled())return D.apply(this,[Z,$]);let J=Z.req.path,Q=F.tracer.startSpan(J);return J9.context.with(J9.trace.setSpan(J9.context.active(),Q),()=>{return F._safeExecute(()=>{let X=D.apply(this,[Z,$]);if(YD(X))return X.then((Y)=>{let W=F._determineHandlerType(Y);return Q.setAttributes({[r6.HONO_TYPE]:W,[r6.HONO_NAME]:W===AF.REQUEST_HANDLER?J:D.name||"anonymous"}),F.getConfig().responseHook?.(Q),Y});else{let Y=F._determineHandlerType(X);return Q.setAttributes({[r6.HONO_TYPE]:Y,[r6.HONO_NAME]:Y===AF.REQUEST_HANDLER?J:D.name||"anonymous"}),F.getConfig().responseHook?.(Q),X}},()=>Q.end(),(X)=>{F._handleError(Q,X),Q.end()})})}}_safeExecute(D,F,Z){try{let $=D();if(YD($))$.then(()=>F(),(J)=>Z(J));else F();return $}catch($){throw Z($),$}}_determineHandlerType(D){return D===void 0?AF.MIDDLEWARE:AF.REQUEST_HANDLER}_handleError(D,F){if(F instanceof Error)D.setStatus({code:J9.SpanStatusCode.ERROR,message:F.message}),D.recordException(F)}}var c90="Hono";function L8D(D){let F=g(D).data,Z=F[r6.HONO_TYPE];if(F[c]||!Z)return;D.setAttributes({[u]:"auto.http.otel.hono",[c]:`${Z}.hono`});let $=F[r6.HONO_NAME];if(typeof $==="string")D.updateName($);if(e()===aD()){i0&&q.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let J=F[IQ.ATTR_HTTP_ROUTE],Q=F[IQ.ATTR_HTTP_REQUEST_METHOD];if(typeof J==="string"&&typeof Q==="string")e().setTransactionName(`${Q} ${J}`)}var l90=_(c90,()=>new UV({responseHook:(D)=>{L8D(D)}})),P8D=()=>{return{name:c90,setupOnce(){l90()}}},p90=A(P8D);var V30=N(H30(),1),w30=N(F0(),1);var U30="Koa",j30=_(U30,V30.KoaInstrumentation,(D={})=>{return{ignoreLayersType:D.ignoreLayersType,requestHook(F,Z){W0(F,"auto.http.otel.koa");let $=g(F).data,J=$["koa.type"];if(J)F.setAttribute(c,`${J}.koa`);let Q=$["koa.name"];if(typeof Q==="string")F.updateName(Q||"< unknown >");if(e()===aD()){i0&&q.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let X=$[w30.ATTR_HTTP_ROUTE],Y=Z.context?.request?.method?.toUpperCase()||"GET";if(X)e().setTransactionName(`${Y} ${X}`)}}}),_8D=(D={})=>{return{name:U30,setupOnce(){j30(D)}}},q30=A(_8D);var g30=N(x30(),1);var u30="Connect",d30=_(u30,()=>new g30.ConnectInstrumentation),a8D=()=>{return{name:u30,setupOnce(){d30()}}},m30=A(a8D);var X40=N(Q40(),1);var z1D=new Set(["callProcedure","execSql","execSqlBatch","execBulkLoad","prepare","execute"]),Y40="Tedious",W40=_(Y40,()=>new X40.TediousInstrumentation({})),K1D=()=>{let D;return{name:Y40,setupOnce(){let F=W40();D=I5(F)},setup(F){D?.(()=>F.on("spanStart",(Z)=>{let{description:$,data:J}=g(Z);if(!$||J["db.system"]!=="mssql")return;let Q=$.split(" ")[0]||"";if(z1D.has(Q))Z.setAttribute(u,"auto.db.otel.tedious")}))}}},z40=A(K1D);var C40=N(q40(),1);var O40="GenericPool",L40=_(O40,()=>new C40.GenericPoolInstrumentation({})),V1D=()=>{let D;return{name:O40,setupOnce(){let F=L40();D=I5(F)},setup(F){D?.(()=>F.on("spanStart",(Z)=>{let J=g(Z).description;if(J==="generic-pool.aquire"||J==="generic-pool.acquire")Z.setAttribute(u,"auto.db.otel.generic_pool")}))}}},P40=A(V1D);var i40=N(p40(),1);var n40="Amqplib",a1D={consumeEndHook:(D)=>{W0(D,"auto.amqplib.otel.consumer")},publishHook:(D)=>{W0(D,"auto.amqplib.otel.publisher")}},a40=_(n40,()=>new i40.AmqplibInstrumentation(a1D)),o1D=()=>{return{name:n40,setupOnce(){a40()}}},o40=A(o1D);var TF="VercelAI";var bQ=N(i(),1);var s1D=[">=3.0.0 <7"],s40=["generateText","streamText","generateObject","streamObject","embed","embedMany","rerank"];function r1D(D){if(typeof D!=="object"||D===null)return!1;let F=D;return"type"in F&&"error"in F&&"toolName"in F&&"toolCallId"in F&&F.type==="tool-error"&&F.error instanceof Error}function t1D(D){if(typeof D!=="object"||D===null||!("content"in D))return;let F=D;if(!Array.isArray(F.content))return;e1D(F.content),D6D(F.content)}function e1D(D){for(let F of D){if(!r1D(F))continue;let Z=UK(F.toolCallId);if(Z)oD(($)=>{$.setContext("trace",{trace_id:Z.traceId,span_id:Z.spanId}),$.setTag("vercel.ai.tool.name",F.toolName),$.setTag("vercel.ai.tool.callId",F.toolCallId),$.setLevel("error"),p(F.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})});else oD(($)=>{$.setTag("vercel.ai.tool.name",F.toolName),$.setTag("vercel.ai.tool.callId",F.toolCallId),$.setLevel("error"),p(F.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})})}}function D6D(D){for(let F of D)if(typeof F==="object"&&F!==null&&"toolCallId"in F&&typeof F.toolCallId==="string")jK(F.toolCallId)}function F6D(D,F,Z,$){let J=D?.recordInputs!==void 0?D.recordInputs:F.recordInputs!==void 0?F.recordInputs:Z===!0?!0:$,Q=D?.recordOutputs!==void 0?D.recordOutputs:F.recordOutputs!==void 0?F.recordOutputs:Z===!0?!0:$;return{recordInputs:J,recordOutputs:Q}}class EF extends bQ.InstrumentationBase{__init(){this._isPatched=!1}__init2(){this._callbacks=[]}constructor(D={}){super("@sentry/instrumentation-vercel-ai",D0,D);EF.prototype.__init.call(this),EF.prototype.__init2.call(this)}init(){return new bQ.InstrumentationNodeModuleDefinition("ai",s1D,this._patch.bind(this))}callWhenPatched(D){if(this._isPatched)D();else this._callbacks.push(D)}_patch(D){this._isPatched=!0,this._callbacks.forEach((Z)=>Z()),this._callbacks=[];let F=(Z)=>{return new Proxy(Z,{apply:($,J,Q)=>{let X=Q[0].experimental_telemetry||{},Y=X.isEnabled,W=v(),z=W?.getIntegrationByName(TF),B=z?.options,K=z?Boolean(W?.getOptions().sendDefaultPii):!1,{recordInputs:G,recordOutputs:H}=F6D(B,X,Y,K);return Q[0].experimental_telemetry={...X,isEnabled:Y!==void 0?Y:!0,recordInputs:G,recordOutputs:H},sD(()=>Reflect.apply($,J,Q),(V)=>{if(V&&typeof V==="object")x0(V,"_sentry_active_span",O8())},()=>{},(V)=>{t1D(V)})}})};if(Object.prototype.toString.call(D)==="[object Module]"){for(let Z of s40)if(D[Z]!=null)D[Z]=F(D[Z]);return D}else{let Z=s40.reduce(($,J)=>{if(D[J]!=null)$[J]=F(D[J]);return $},{});return{...D,...Z}}}}var r40=_(TF,()=>new EF({}));function Z6D(D){return!!D.getIntegrationByName("Modules")?.getModules?.()?.ai}var $6D=(D={})=>{let F;return{name:TF,options:D,setupOnce(){F=r40()},afterAllSetup(Z){if(D.force??Z6D(Z))S$(Z);else F?.callWhenPatched(()=>S$(Z))}}},t40=A($6D);var vQ=N(i(),1);var J6D=[">=4.0.0 <7"];class SV extends vQ.InstrumentationBase{constructor(D={}){super("@sentry/instrumentation-openai",D0,D)}init(){return new vQ.InstrumentationNodeModuleDefinition("openai",J6D,this._patch.bind(this))}_patch(D){let F=D;return F=this._patchClient(F,"OpenAI"),F=this._patchClient(F,"AzureOpenAI"),F}_patchClient(D,F){let Z=D[F];if(!Z)return D;let $=this.getConfig(),J=function(...Q){if(T7(y6))return Reflect.construct(Z,Q);let X=Reflect.construct(Z,Q);return x$(X,$)};Object.setPrototypeOf(J,Z),Object.setPrototypeOf(J.prototype,Z.prototype);for(let Q of Object.getOwnPropertyNames(Z))if(!["length","name","prototype"].includes(Q)){let X=Object.getOwnPropertyDescriptor(Z,Q);if(X)Object.defineProperty(J,Q,X)}try{D[F]=J}catch{Object.defineProperty(D,F,{value:J,writable:!0,configurable:!0,enumerable:!0})}if(D.default===Z)try{D.default=J}catch{Object.defineProperty(D,"default",{value:J,writable:!0,configurable:!0,enumerable:!0})}return D}}var e40=_(y6,(D)=>new SV(D)),Q6D=(D={})=>{return{name:y6,setupOnce(){e40(D)}}},D50=A(Q6D);var xQ=N(i(),1);var X6D=[">=0.19.2 <1.0.0"];class bV extends xQ.InstrumentationBase{constructor(D={}){super("@sentry/instrumentation-anthropic-ai",D0,D)}init(){return new xQ.InstrumentationNodeModuleDefinition("@anthropic-ai/sdk",X6D,this._patch.bind(this))}_patch(D){let F=D.Anthropic,Z=this.getConfig(),$=function(...J){if(T7(h6))return Reflect.construct(F,J);let Q=Reflect.construct(F,J);return g$(Q,Z)};Object.setPrototypeOf($,F),Object.setPrototypeOf($.prototype,F.prototype);for(let J of Object.getOwnPropertyNames(F))if(!["length","name","prototype"].includes(J)){let Q=Object.getOwnPropertyDescriptor(F,J);if(Q)Object.defineProperty($,J,Q)}try{D.Anthropic=$}catch{Object.defineProperty(D,"Anthropic",{value:$,writable:!0,configurable:!0,enumerable:!0})}if(D.default===F)try{D.default=$}catch{Object.defineProperty(D,"default",{value:$,writable:!0,configurable:!0,enumerable:!0})}return D}}var F50=_(h6,(D)=>new bV(D)),Y6D=(D={})=>{return{name:h6,options:D,setupOnce(){F50(D)}}},Z50=A(Y6D);var g3=N(i(),1);var $50=[">=0.10.0 <2"];class vV extends g3.InstrumentationBase{constructor(D={}){super("@sentry/instrumentation-google-genai",D0,D)}init(){return new g3.InstrumentationNodeModuleDefinition("@google/genai",$50,(F)=>this._patch(F),(F)=>F,[new g3.InstrumentationNodeModuleFile("@google/genai/dist/node/index.cjs",$50,(F)=>this._patch(F),(F)=>F)])}_patch(D){let F=D.GoogleGenAI,Z=this.getConfig();if(typeof F!=="function")return D;let $=function(...J){if(T7(_6))return Reflect.construct(F,J);let Q=Reflect.construct(F,J);return u$(Q,Z)};Object.setPrototypeOf($,F),Object.setPrototypeOf($.prototype,F.prototype);for(let J of Object.getOwnPropertyNames(F))if(!["length","name","prototype"].includes(J)){let Q=Object.getOwnPropertyDescriptor(F,J);if(Q)Object.defineProperty($,J,Q)}return K5(D,"GoogleGenAI",$),D}}var J50=_(_6,(D)=>new vV(D)),W6D=(D={})=>{return{name:_6,setupOnce(){J50(D)}}},Q50=A(W6D);var F7=N(i(),1);var gQ=[">=0.1.0 <2.0.0"];function z6D(D,F){if(!D)return[F];if(Array.isArray(D)){if(D.includes(F))return D;return[...D,F]}if(typeof D==="object")return[D,F];return D}function K6D(D,F,Z){return new Proxy(D,{apply($,J,Q){let Y=Q[1];if(!Y||typeof Y!=="object"||Array.isArray(Y))Y={},Q[1]=Y;let W=Y.callbacks,z=z6D(W,F);return Y.callbacks=z,Reflect.apply($,J,Q)}})}class xV extends F7.InstrumentationBase{constructor(D={}){super("@sentry/instrumentation-langchain",D0,D)}init(){let D=[],F=["@langchain/anthropic","@langchain/openai","@langchain/google-genai","@langchain/mistralai","@langchain/google-vertexai","@langchain/groq"];for(let Z of F)D.push(new F7.InstrumentationNodeModuleDefinition(Z,gQ,this._patch.bind(this),($)=>$,[new F7.InstrumentationNodeModuleFile(`${Z}/dist/index.cjs`,gQ,this._patch.bind(this),($)=>$)]));return D.push(new F7.InstrumentationNodeModuleDefinition("langchain",gQ,this._patch.bind(this),(Z)=>Z,[new F7.InstrumentationNodeModuleFile("langchain/dist/chat_models/universal.cjs",gQ,this._patch.bind(this),(Z)=>Z)])),D}_patch(D){gz([y6,h6,_6]);let F=m$(this.getConfig());return this._patchRunnableMethods(D,F),D}_patchRunnableMethods(D,F){let Z=["ChatAnthropic","ChatOpenAI","ChatGoogleGenerativeAI","ChatMistralAI","ChatVertexAI","ChatGroq","ConfigurableModel"],$=D.universal_exports??D,J=Object.values($).find((Y)=>{return typeof Y==="function"&&Z.includes(Y.name)});if(!J)return;let Q=J.prototype;if(Q.__sentry_patched__)return;Q.__sentry_patched__=!0;let X=["invoke","stream","batch"];for(let Y of X){let W=Q[Y];if(typeof W==="function")Q[Y]=K6D(W,F)}}}var X50=_(d$,(D)=>new xV(D)),B6D=(D={})=>{return{name:d$,setupOnce(){X50(D)}}},Y50=A(B6D);var u3=N(i(),1);var W50=[">=0.0.0 <2.0.0"];class gV extends u3.InstrumentationBase{constructor(D={}){super("@sentry/instrumentation-langgraph",D0,D)}init(){return new u3.InstrumentationNodeModuleDefinition("@langchain/langgraph",W50,this._patch.bind(this),(F)=>F,[new u3.InstrumentationNodeModuleFile("@langchain/langgraph/dist/index.cjs",W50,this._patch.bind(this),(F)=>F)])}_patch(D){if(D.StateGraph&&typeof D.StateGraph==="function")l$(D.StateGraph.prototype,this.getConfig());return D}}var z50=_(c$,(D)=>new gV(D)),G6D=(D={})=>{return{name:c$,setupOnce(){z50(D)}}},K50=A(G6D);var q50=N(i(),1);var D6=N(M(),1),F6=N(i(),1),v8=N(F0(),1);import*as G50 from"node:net";function H50(D,F,Z,$,J){let X=()=>{},Y=J.firestoreSpanCreationHook;if(typeof Y==="function")X=(B)=>{F6.safeExecuteInTheMiddle(()=>Y(B),(K)=>{if(!K)return;D6.diag.error(K?.message)},!0)};let W=new F6.InstrumentationNodeModuleDefinition("@firebase/firestore",F,(B)=>B50(B,Z,$,D,X)),z=["@firebase/firestore/dist/lite/index.node.cjs.js","@firebase/firestore/dist/lite/index.node.mjs.js","@firebase/firestore/dist/lite/index.rn.esm2017.js","@firebase/firestore/dist/lite/index.cjs.js"];for(let B of z)W.files.push(new F6.InstrumentationNodeModuleFile(B,F,(K)=>B50(K,Z,$,D,X),(K)=>V50(K,$)));return W}function B50(D,F,Z,$,J){return V50(D,Z),F(D,"addDoc",H6D($,J)),F(D,"getDocs",w6D($,J)),F(D,"setDoc",U6D($,J)),F(D,"deleteDoc",V6D($,J)),D}function V50(D,F){for(let Z of["addDoc","getDocs","setDoc","deleteDoc"])if(F6.isWrapped(D[Z]))F(D,Z);return D}function H6D(D,F){return function($){return function(J,Q){let X=dQ(D,"addDoc",J);return F(X),uQ(X,()=>{return $(J,Q)})}}}function V6D(D,F){return function($){return function(J){let Q=dQ(D,"deleteDoc",J.parent||J);return F(Q),uQ(Q,()=>{return $(J)})}}}function w6D(D,F){return function($){return function(J){let Q=dQ(D,"getDocs",J);return F(Q),uQ(Q,()=>{return $(J)})}}}function U6D(D,F){return function($){return function(J,Q,X){let Y=dQ(D,"setDoc",J.parent||J);return F(Y),uQ(Y,()=>{return typeof X<"u"?$(J,Q,X):$(J,Q)})}}}function uQ(D,F){return D6.context.with(D6.trace.setSpan(D6.context.active(),D),()=>{return F6.safeExecuteInTheMiddle(()=>{return F()},(Z)=>{if(Z)D.recordException(Z);D.end()},!0)})}function dQ(D,F,Z){let $=D.startSpan(`${F} ${Z.path}`,{kind:D6.SpanKind.CLIENT});return q6D($,Z),$.setAttribute(v8.ATTR_DB_OPERATION_NAME,F),$}function j6D(D){let F,Z;if(typeof D.host==="string")if(D.host.startsWith("[")){if(D.host.endsWith("]"))F=D.host.replace(/^\[|\]$/g,"");else if(D.host.includes("]:")){let $=D.host.lastIndexOf(":");if($!==-1)F=D.host.slice(1,$).replace(/^\[|\]$/g,""),Z=D.host.slice($+1)}}else if(G50.isIPv6(D.host))F=D.host;else{let $=D.host.lastIndexOf(":");if($!==-1)F=D.host.slice(0,$),Z=D.host.slice($+1);else F=D.host}return{address:F,port:Z?parseInt(Z,10):void 0}}function q6D(D,F){let Z=F.firestore.app,$=Z.options,Q=(F.firestore.toJSON()||{}).settings||{},X={[v8.ATTR_DB_COLLECTION_NAME]:F.path,[v8.ATTR_DB_NAMESPACE]:Z.name,[v8.ATTR_DB_SYSTEM_NAME]:"firebase.firestore","firebase.firestore.type":F.type,"firebase.firestore.options.projectId":$.projectId,"firebase.firestore.options.appId":$.appId,"firebase.firestore.options.messagingSenderId":$.messagingSenderId,"firebase.firestore.options.storageBucket":$.storageBucket},{address:Y,port:W}=j6D(Q);if(Y)X[v8.ATTR_SERVER_ADDRESS]=Y;if(W)X[v8.ATTR_SERVER_PORT]=W;D.setAttributes(X)}var M1=N(M(),1),Z6=N(i(),1);function w50(D,F,Z,$,J){let Q=()=>{},X=()=>{},Y=J.functions?.errorHook,W=J.functions?.requestHook,z=J.functions?.responseHook;if(typeof z==="function")X=(G,H)=>{Z6.safeExecuteInTheMiddle(()=>z(G,H),(V)=>{if(!V)return;M1.diag.error(V?.message)},!0)};if(typeof W==="function")Q=(G)=>{Z6.safeExecuteInTheMiddle(()=>W(G),(H)=>{if(!H)return;M1.diag.error(H?.message)},!0)};let B=new Z6.InstrumentationNodeModuleDefinition("firebase-functions",F);return[{name:"firebase-functions/lib/v2/providers/https.js",triggerType:"function"},{name:"firebase-functions/lib/v2/providers/firestore.js",triggerType:"firestore"},{name:"firebase-functions/lib/v2/providers/scheduler.js",triggerType:"scheduler"},{name:"firebase-functions/lib/v2/storage.js",triggerType:"storage"}].forEach(({name:G,triggerType:H})=>{B.files.push(new Z6.InstrumentationNodeModuleFile(G,F,(V)=>C6D(V,Z,$,D,{requestHook:Q,responseHook:X,errorHook:Y},H),(V)=>U50(V,$)))}),B}function _D(D,F,Z){return function(J){return function(...Q){let X=typeof Q[0]==="function"?Q[0]:Q[1],Y=typeof Q[0]==="function"?void 0:Q[0];if(!X)return J.call(this,...Q);let W=async function(...z){let B=process.env.FUNCTION_TARGET||process.env.K_SERVICE||"unknown",K=D.startSpan(`firebase.function.${Z}`,{kind:M1.SpanKind.SERVER}),G={"faas.name":B,"faas.trigger":Z,"faas.provider":"firebase"};if(process.env.GCLOUD_PROJECT)G["cloud.project_id"]=process.env.GCLOUD_PROJECT;if(process.env.EVENTARC_CLOUD_EVENT_SOURCE)G["cloud.event_source"]=process.env.EVENTARC_CLOUD_EVENT_SOURCE;return K.setAttributes(G),F?.requestHook?.(K),M1.context.with(M1.trace.setSpan(M1.context.active(),K),async()=>{let H,V;try{V=await X.apply(this,z)}catch(U){H=U}if(F?.responseHook?.(K,H),H)K.recordException(H);if(K.end(),H)throw await F?.errorHook?.(K,H),H;return V})};if(Y)return J.call(this,Y,W);else return J.call(this,W)}}}function C6D(D,F,Z,$,J,Q){switch(U50(D,Z),Q){case"function":F(D,"onRequest",_D($,J,"http.request")),F(D,"onCall",_D($,J,"http.call"));break;case"firestore":F(D,"onDocumentCreated",_D($,J,"firestore.document.created")),F(D,"onDocumentUpdated",_D($,J,"firestore.document.updated")),F(D,"onDocumentDeleted",_D($,J,"firestore.document.deleted")),F(D,"onDocumentWritten",_D($,J,"firestore.document.written")),F(D,"onDocumentCreatedWithAuthContext",_D($,J,"firestore.document.created")),F(D,"onDocumentUpdatedWithAuthContext",_D($,J,"firestore.document.updated")),F(D,"onDocumentDeletedWithAuthContext",_D($,J,"firestore.document.deleted")),F(D,"onDocumentWrittenWithAuthContext",_D($,J,"firestore.document.written"));break;case"scheduler":F(D,"onSchedule",_D($,J,"scheduler.scheduled"));break;case"storage":F(D,"onObjectFinalized",_D($,J,"storage.object.finalized")),F(D,"onObjectArchived",_D($,J,"storage.object.archived")),F(D,"onObjectDeleted",_D($,J,"storage.object.deleted")),F(D,"onObjectMetadataUpdated",_D($,J,"storage.object.metadataUpdated"));break}return D}function U50(D,F){let Z=["onSchedule","onRequest","onCall","onObjectFinalized","onObjectArchived","onObjectDeleted","onObjectMetadataUpdated","onDocumentCreated","onDocumentUpdated","onDocumentDeleted","onDocumentWritten","onDocumentCreatedWithAuthContext","onDocumentUpdatedWithAuthContext","onDocumentDeletedWithAuthContext","onDocumentWrittenWithAuthContext"];for(let $ of Z)if(Z6.isWrapped(D[$]))F(D,$);return D}var j50={},O6D=[">=3.0.0 <5"],L6D=[">=6.0.0 <7"];class uV extends q50.InstrumentationBase{constructor(D=j50){super("@sentry/instrumentation-firebase",D0,D)}setConfig(D={}){super.setConfig({...j50,...D})}init(){let D=[];return D.push(H50(this.tracer,O6D,this._wrap,this._unwrap,this.getConfig())),D.push(w50(this.tracer,L6D,this._wrap,this._unwrap,this.getConfig())),D}}var C50="Firebase",P6D={firestoreSpanCreationHook:(D)=>{W0(D,"auto.firebase.otel.firestore"),D.setAttribute(c,"db.query")},functions:{requestHook:(D)=>{W0(D,"auto.firebase.otel.functions"),D.setAttribute(c,"http.request")},errorHook:async(D,F)=>{if(F)p(F,{mechanism:{type:"auto.firebase.otel.functions",handled:!1}}),await p9(2000)}}},O50=_(C50,()=>new uV(P6D)),M6D=()=>{return{name:C50,setupOnce(){O50()}}},L50=A(M6D);function P50(){return[fu(),qc(),Yl(),p90(),wp(),xp(),Qi(),S80(),v10(),U60(),j90(),m90(),q30(),m30(),z40(),P40(),_l(),o40(),ol(),Y50(),K50(),t40(),D50(),Z50(),Q50(),O60(),L50()]}var d3=N(M(),1),mQ=N(mK(),1),M50=N(eK(),1),m3=N(F0(),1);var dV=1e6;function A50(D,F={}){if(D.getOptions().debug)jB();let[Z,$]=A6D(D,F);D.traceProvider=Z,D.asyncLocalStorageLookup=$}function A6D(D,F={}){let Z=new M50.BasicTracerProvider({sampler:new wB(D),resource:mQ.defaultResource().merge(mQ.resourceFromAttributes({[m3.ATTR_SERVICE_NAME]:"node",[m3.SEMRESATTRS_SERVICE_NAMESPACE]:"sentry",[m3.ATTR_SERVICE_VERSION]:D0})),forceFlushTimeoutMillis:500,spanProcessors:[new VB({timeout:R6D(D.getOptions().maxSpanWaitDuration)}),...F.spanProcessors||[]]});d3.trace.setGlobalTracerProvider(Z),d3.propagation.setGlobalPropagator(new HB);let $=new UB;return d3.context.setGlobalContextManager($),[Z,$.getAsyncLocalStorageLookup()]}function R6D(D){if(D==null)return;if(D>dV)return i0&&q.warn(`\`maxSpanWaitDuration\` is too high, using the maximum value of ${dV}`),dV;else if(D<=0||Number.isNaN(D)){i0&&q.warn("`maxSpanWaitDuration` must be a positive number, using default value instead.");return}return D}function R50(){return qJ().filter((F)=>F.name!=="Http"&&F.name!=="NodeFetch").concat(ng(),Xu())}function k50(D){return[...R50(),..._0(D)?P50():[]]}function mV(D={}){return k6D(D,k50)}function k6D(D={},F){E7(D,"node");let Z=TB({...D,defaultIntegrations:D.defaultIntegrations??F(D)});if(Z&&!D.skipOpenTelemetrySetup)A50(Z,{spanProcessors:D.openTelemetrySpanProcessors}),EB();return Z}var I50=!1;function N50(){if(I50)return;let D=process.env.SENTRY_DSN;if(!D)return;try{mV({dsn:D,environment:"development",release:"workthin-cli@1.0.0",beforeSend(F){return F}}),I50=!0}catch{}}function K8(D){try{p(D)}catch{}}async function T50(){try{await p9(2000)}catch{}}import{execFileSync as cV,spawn as E50}from"node:child_process";import{existsSync as yF,mkdirSync as pV,readFileSync as iV,writeFileSync as fF}from"node:fs";import{homedir as c3,platform as cQ}from"node:os";import{join as O0}from"node:path";var $6=(D)=>`${D}/api/mcp`;function f50(D){let F=O0(D,"..");if(!yF(F))pV(F,{recursive:!0})}function lQ(D,F,Z){let $={};if(yF(D))$=JSON.parse(iV(D,"utf-8"));let J=$[Z]??{};J.workthin=F,$[Z]=J,f50(D),fF(D,JSON.stringify($,null,2),"utf-8")}function lV(D,F){return{url:$6(F),headers:{Authorization:`Bearer ${D}`}}}var a0={chatgpt:{label:"ChatGPT",setup:(D,F)=>{let Z=`${F}/docs/mcp/integrations/chatgpt`;try{let $,J;if(cQ()==="win32")$="cmd",J=["/c","start",'""',Z];else if(cQ()==="linux")$="xdg-open",J=[Z];else $="open",J=[Z];E50($,J,{detached:!0,stdio:"ignore"}).unref()}catch{}r.info(`Setup guide: ${y.cyan(Z)}`)},note:"In ChatGPT, go to Settings > Connectors > Add connector and enter the workthin MCP URL. Requires Plus, Pro, or Team plan."},"claude-code":{label:"Claude Code",setup:(D,F)=>{let Z=$6(F);cV("claude",["mcp","add","-t","http","-s","user","workthin",Z],{stdio:"pipe"})}},"claude-desktop":{label:"Claude Desktop",setup:(D,F)=>{let Z=`${F}/docs/mcp/integrations/claude-desktop`;try{let $,J;if(cQ()==="win32")$="cmd",J=["/c","start",'""',Z];else if(cQ()==="linux")$="xdg-open",J=[Z];else $="open",J=[Z];E50($,J,{detached:!0,stdio:"ignore"}).unref()}catch{}r.info(`Setup guide: ${y.cyan(Z)}`)},note:"In Claude Desktop, go to Settings > Connectors > Add custom connector and enter the workthin MCP URL."},cursor:{label:"Cursor",setup:(D,F)=>{lQ(O0(c3(),".cursor","mcp.json"),lV(D,F),"mcpServers")}},"gemini-cli":{label:"Gemini CLI",setup:(D,F)=>{let Z=$6(F);try{cV("gemini",["mcp","add","-t","http","workthin",Z,"-H",`Authorization: Bearer ${D}`],{stdio:"pipe"})}catch{let $=O0(c3(),".gemini","settings.json");lQ($,{httpUrl:$6(F),headers:{Authorization:`Bearer ${D}`}},"mcpServers")}}},"codex-cli":{label:"OpenAI Codex CLI",setup:(D,F)=>{let Z=$6(F);try{cV("codex",["mcp","add","workthin","--","curl",Z],{stdio:"pipe"})}catch{let $=O0(c3(),".codex","config.toml"),J=`
|
|
126
|
+
`);let{connect:W,buffered:z}=await Y;if(D.emit("proxyConnect",W),this.emit("proxyConnect",W,D),W.statusCode===200){if(D.once("socket",Af0),F.secureEndpoint){f5("Upgrading socket connection to TLS");let K=F.servername||F.host;return kB.connect({...yg(F,"host","path","port"),socket:$,servername:l1.isIP(K)?void 0:K})}return $}$.destroy();let B=new l1.Socket({writable:!1});return B.readable=!0,D.once("socket",(K)=>{f5("Replaying proxy buffer for failed request"),K.push(z),K.push(null)}),B}}jJ.__initStatic();function Af0(D){D.resume()}function yg(D,...F){let Z={},$;for($ in D)if(!F.includes($))Z[$]=D[$];return Z}var Tf0=32768;function Ef0(D){return new If0({read(){this.push(D),this.push(null)}})}function hg(D){let F;try{F=new URL(D.url)}catch(W){return h0(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),t4(D,()=>Promise.resolve({}))}let Z=F.protocol==="https:",$=ff0(F,D.proxy||(Z?process.env.https_proxy:void 0)||process.env.http_proxy),J=Z?kf0:Rf0,Q=D.keepAlive===void 0?!1:D.keepAlive,X=$?new jJ($):new J.Agent({keepAlive:Q,maxSockets:30,timeout:2000}),Y=yf0(D,D.httpModule??J,X);return t4(D,Y)}function ff0(D,F){let{no_proxy:Z}=process.env;if(Z?.split(",").some((J)=>D.host.endsWith(J)||D.hostname.endsWith(J)))return;else return F}function yf0(D,F,Z){let{hostname:$,pathname:J,port:Q,protocol:X,search:Y}=new URL(D.url);return function(z){return new Promise((B,K)=>{c9(()=>{let G=Ef0(z.body),H={...D.headers};if(z.body.length>Tf0)H["content-encoding"]="gzip",G=G.pipe(Nf0());let V=$.startsWith("["),U=F.request({method:"POST",agent:Z,headers:H,hostname:V?$.slice(1,-1):$,path:`${J}${Y}`,port:Q,protocol:X,ca:D.caCerts},(j)=>{j.on("data",()=>{}),j.on("end",()=>{}),j.setEncoding("utf8");let C=j.headers["retry-after"]??null,O=j.headers["x-sentry-rate-limits"]??null;B({statusCode:j.statusCode,headers:{"retry-after":C,"x-sentry-rate-limits":Array.isArray(O)?O[0]||null:O}})});U.on("error",K),G.pipe(U)})})}}function _g(D){if(D===!1)return!1;if(typeof D==="string")return D;let F=r9(process.env.SENTRY_SPOTLIGHT,{strict:!0}),Z=F===null&&process.env.SENTRY_SPOTLIGHT?process.env.SENTRY_SPOTLIGHT:void 0;return D===!0?Z??!0:F??Z}import{posix as hf0,sep as _f0}from"node:path";function Sg(D){return D.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}function bg(D=process.argv[1]?nz(process.argv[1]):process.cwd(),F=_f0==="\\"){let Z=F?Sg(D):D;return($)=>{if(!$)return;let J=F?Sg($):$,{dir:Q,base:X,ext:Y}=hf0.parse(J);if(Y===".js"||Y===".mjs"||Y===".cjs")X=X.slice(0,Y.length*-1);let W=decodeURIComponent(X);if(!Q)Q=".";let z=Q.lastIndexOf("/node_modules");if(z>-1)return`${Q.slice(z+14).replace(/\//g,".")}:${W}`;if(Q.startsWith(Z)){let B=Q.slice(Z.length+1).replace(/\//g,".");return B?`${B}:${W}`:W}return W}}function vg(D){if(process.env.SENTRY_RELEASE)return process.env.SENTRY_RELEASE;if(l.SENTRY_RELEASE?.id)return l.SENTRY_RELEASE.id;let F=process.env.GITHUB_SHA||process.env.CI_MERGE_REQUEST_SOURCE_BRANCH_SHA||process.env.CI_BUILD_REF||process.env.CI_COMMIT_SHA||process.env.BITBUCKET_COMMIT,Z=process.env.APPVEYOR_PULL_REQUEST_HEAD_COMMIT||process.env.APPVEYOR_REPO_COMMIT||process.env.CODEBUILD_RESOLVED_SOURCE_VERSION||process.env.AWS_COMMIT_ID||process.env.BUILD_SOURCEVERSION||process.env.GIT_CLONE_COMMIT_HASH||process.env.BUDDY_EXECUTION_REVISION||process.env.BUILDKITE_COMMIT||process.env.CIRCLE_SHA1||process.env.CIRRUS_CHANGE_IN_REPO||process.env.CF_REVISION||process.env.CM_COMMIT||process.env.CF_PAGES_COMMIT_SHA||process.env.DRONE_COMMIT_SHA||process.env.FC_GIT_COMMIT_SHA||process.env.HEROKU_TEST_RUN_COMMIT_VERSION||process.env.HEROKU_BUILD_COMMIT||process.env.HEROKU_SLUG_COMMIT||process.env.RAILWAY_GIT_COMMIT_SHA||process.env.RENDER_GIT_COMMIT||process.env.SEMAPHORE_GIT_SHA||process.env.TRAVIS_PULL_REQUEST_SHA||process.env.VERCEL_GIT_COMMIT_SHA||process.env.VERCEL_GITHUB_COMMIT_SHA||process.env.VERCEL_GITLAB_COMMIT_SHA||process.env.VERCEL_BITBUCKET_COMMIT_SHA||process.env.ZEIT_GITHUB_COMMIT_SHA||process.env.ZEIT_GITLAB_COMMIT_SHA||process.env.ZEIT_BITBUCKET_COMMIT_SHA,$=process.env.CI_COMMIT_ID||process.env.SOURCE_COMMIT||process.env.SOURCE_VERSION||process.env.GIT_COMMIT||process.env.COMMIT_REF||process.env.BUILD_VCS_NUMBER||process.env.CI_COMMIT_SHA;return F||Z||$||D}var xg=nZ(kK(bg()));var ug=N(M(),1),dg=N(i(),1);import*as gg from"node:os";import{threadId as Sf0,isMainThread as bf0}from"worker_threads";var vf0=60000;class IB extends U${constructor(D){let F=D.includeServerName===!1?void 0:D.serverName||global.process.env.SENTRY_NAME||gg.hostname(),Z={...D,platform:"node",runtime:D.runtime||{name:"node",version:global.process.version},serverName:F};if(D.openTelemetryInstrumentations)dg.registerInstrumentations({instrumentations:D.openTelemetryInstrumentations});E7(Z,"node"),q.log(`Initializing Sentry: process: ${process.pid}, thread: ${bf0?"main":`worker-${Sf0}`}.`);super(Z);if(this.getOptions().enableLogs){if(this._logOnExitFlushListener=()=>{i9(this)},F)this.on("beforeCaptureLog",($)=>{$.attributes={...$.attributes,"server.address":F}});process.on("beforeExit",this._logOnExitFlushListener)}}get tracer(){if(this._tracer)return this._tracer;let D="@sentry/node",F=D0,Z=ug.trace.getTracer(D,F);return this._tracer=Z,Z}async flush(D){if(await this.traceProvider?.forceFlush(),this.getOptions().sendClientReports)this._flushOutcomes();return super.flush(D)}async close(D){if(this._clientReportInterval)clearInterval(this._clientReportInterval);if(this._clientReportOnExitFlushListener)process.off("beforeExit",this._clientReportOnExitFlushListener);if(this._logOnExitFlushListener)process.off("beforeExit",this._logOnExitFlushListener);let F=await super.close(D);if(this.traceProvider)await this.traceProvider.shutdown();return F}startClientReportTracking(){let D=this.getOptions();if(D.sendClientReports)this._clientReportOnExitFlushListener=()=>{this._flushOutcomes()},this._clientReportInterval=setInterval(()=>{n&&q.log("Flushing client reports based on interval."),this._flushOutcomes()},D.clientReportFlushInterval??vf0).unref(),process.on("beforeExit",this._clientReportOnExitFlushListener)}_setupIntegrations(){uz(),super._setupIntegrations()}_getTraceInfoFromScope(D){if(!D)return[void 0,void 0];return xx(this,D)}}var mg=N(MW(),1);import*as cg from"module";function NB(){if(!qg())return;if(!l._sentryEsmLoaderHookRegistered){l._sentryEsmLoaderHookRegistered=!0;try{let{addHookMessagePort:D}=mg.createAddHookMessageChannel();cg.register("import-in-the-middle/hook.mjs",import.meta.url,{data:{addHookMessagePort:D,include:[]},transferList:[D]})}catch(D){q.warn("Failed to register 'import-in-the-middle' hook",D)}}}function qJ(){return[O$(),q$(),L$(),P$(),Eg(),rz(),A$(),Yg(),Mg(),Ag(),Rg(),Qg(),wg(),ex(),sx(),kg(),Pg()]}function TB(D={}){return xf0(D,qJ)}function xf0(D={},F){let Z=gf0(D,F);if(Z.debug===!0)if(n)q.enable();else h0(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")});if(Z.registerEsmLoaderHooks!==!1)NB();if(dx(),$0().update(Z.initialScope),Z.spotlight&&!Z.integrations.some(({name:Q})=>Q===MB))Z.integrations.push(Ng({sidecarUrl:typeof Z.spotlight==="string"?Z.spotlight:void 0}));E7(Z,"node-core");let J=new IB(Z);if($0().setClient(J),J.init(),q.log(`SDK initialized from ${T5()?"CommonJS":"ESM"}`),J.startClientReportTracking(),mf0(),Rx(J),ux(J),process.env.VERCEL)process.on("SIGTERM",async()=>{await J.flush(200)});return J}function EB(){if(!n)return;let D=Tx(),F=["SentryContextManager","SentryPropagator"];if(_0())F.push("SentrySpanProcessor");for(let Z of F)if(!D.includes(Z))q.error(`You have to set up the ${Z}. Without this, the OpenTelemetry & Sentry integration will not work properly.`);if(!D.includes("SentrySampler"))q.warn("You have to set up the SentrySampler. Without this, the OpenTelemetry & Sentry integration may still work, but sample rates set for the Sentry SDK will not be respected. If you use a custom sampler, make sure to use `wrapSamplingDecision`.")}function gf0(D,F){let Z=uf0(D.release),$=_g(D.spotlight),J=df0(D.tracesSampleRate),Q={...D,dsn:D.dsn??process.env.SENTRY_DSN,environment:D.environment??process.env.SENTRY_ENVIRONMENT,sendClientReports:D.sendClientReports??!0,transport:D.transport??hg,stackParser:oW(D.stackParser||xg),release:Z,tracesSampleRate:J,spotlight:$,debug:r9(D.debug??process.env.SENTRY_DEBUG)},X=D.integrations,Y=D.defaultIntegrations??F(Q);return{...Q,integrations:Tz({defaultIntegrations:Y,integrations:X})}}function uf0(D){if(D!==void 0)return D;let F=vg();if(F!==void 0)return F;return}function df0(D){if(D!==void 0)return D;let F=process.env.SENTRY_TRACES_SAMPLE_RATE;if(!F)return;let Z=parseFloat(F);return isFinite(Z)?Z:void 0}function mf0(){if(r9(process.env.SENTRY_USE_ENVIRONMENT)!==!1){let D=process.env.SENTRY_TRACE,F=process.env.SENTRY_BAGGAGE,Z=b4(D,F);$0().setPropagationContext(Z)}}function W0(D,F){D.setAttribute(u,F)}function y5(D){let F=D.protocol||"",Z=D.hostname||D.host||"",$=!D.port||D.port===80||D.port===443||/^(.*):(\d+)$/.test(Z)?"":`:${D.port}`,J=D.path?D.path:"/";return`${F}//${Z}${$}${J}`}var fB="Http",lg="@opentelemetry_sentry-patched/instrumentation-http",CJ=e8.major===22&&e8.minor>=12||e8.major===23&&e8.minor>=2||e8.major>=24,cf0=_(`${fB}.sentry`,(D)=>{return new W3(D)}),lf0=_(fB,(D)=>{let F=new ig.HttpInstrumentation({...D,disableIncomingRequestInstrumentation:!0});try{F._diag=pg.diag.createComponentLogger({namespace:lg}),F.instrumentationName=lg}catch{}try{let Z={get:()=>!1,set:()=>{}};Object.defineProperty(F,"_httpPatched",Z),Object.defineProperty(F,"_httpsPatched",Z)}catch{}return F});function pf0(D,F={}){if(typeof D.spans==="boolean")return D.spans;if(F.skipOpenTelemetrySetup)return!1;if(!_0(F)&&CJ)return!1;return!0}var ng=A((D={})=>{let F=D.spans??!0,Z=D.disableIncomingRequestSpans,$={sessions:D.trackIncomingRequestsAsSessions,sessionFlushingDelayMS:D.sessionFlushingDelayMS,ignoreRequestBody:D.ignoreIncomingRequestBody,maxRequestBodySize:D.maxIncomingRequestBodySize},J={ignoreIncomingRequests:D.ignoreIncomingRequests,ignoreStaticAssets:D.ignoreStaticAssets,ignoreStatusCodes:D.dropSpansForIncomingRequestStatusCodes,instrumentation:D.instrumentation,onSpanCreated:D.incomingRequestSpanHook},Q=B5($),X=G5(J),Y=F&&!Z;return{name:fB,setup(W){let z=W.getOptions();if(Y&&_0(z))X.setup(W)},setupOnce(){let W=v()?.getOptions()||{},z=pf0(D,W);Q.setupOnce();let B={breadcrumbs:D.breadcrumbs,propagateTraceInOutgoingRequests:typeof D.tracePropagation==="boolean"?D.tracePropagation:CJ||!z,createSpansForOutgoingRequests:CJ,spans:D.spans,ignoreOutgoingRequests:D.ignoreOutgoingRequests,outgoingRequestHook:(K,G)=>{let H=y5(G);if(H.startsWith("data:")){let V=t9(H);K.setAttribute("http.url",V),K.setAttribute(q6,V),K.updateName(`${G.method||"GET"} ${V}`)}D.instrumentation?.requestHook?.(K,G)},outgoingResponseHook:D.instrumentation?.responseHook,outgoingRequestApplyCustomAttributes:D.instrumentation?.applyCustomAttributesOnSpan};if(cf0(B),z){let K=if0(D);lf0(K)}},processEvent(W){return X.processEvent(W)}}});function if0(D={}){return{disableOutgoingRequestInstrumentation:CJ,ignoreOutgoingRequestHook:(Z)=>{let $=y5(Z);if(!$)return!1;let J=D.ignoreOutgoingRequests;if(J?.($,Z))return!0;return!1},requireParentforOutgoingSpans:!1,requestHook:(Z,$)=>{W0(Z,"auto.http.otel.http");let J=y5($);if(J.startsWith("data:")){let Q=t9(J);Z.setAttribute("http.url",Q),Z.setAttribute(q6,Q),Z.updateName(`${$.method||"GET"} ${Q}`)}D.instrumentation?.requestHook?.(Z,$)},responseHook:(Z,$)=>{D.instrumentation?.responseHook?.(Z,$)},applyCustomAttributesOnSpan:(Z,$,J)=>{D.instrumentation?.applyCustomAttributesOnSpan?.(Z,$,J)}}}var Ju=N(Zu(),1);var Qu="NodeFetch",rf0=_(Qu,Ju.UndiciInstrumentation,(D)=>{return Fy0(D)}),tf0=_(`${Qu}.sentry`,K3,(D)=>{return D}),ef0=(D={})=>{return{name:"NodeFetch",setupOnce(){if(Dy0(D,v()?.getOptions()))rf0(D);tf0(D)}}},Xu=A(ef0);function $u(D,F="/"){let Z=`${D}`;if(Z.endsWith("/")&&F.startsWith("/"))return`${Z}${F.slice(1)}`;if(!Z.endsWith("/")&&!F.startsWith("/"))return`${Z}/${F}`;return`${Z}${F}`}function Dy0(D,F={}){return typeof D.spans==="boolean"?D.spans:!F.skipOpenTelemetrySetup&&_0(F)}function Fy0(D={}){return{requireParentforSpans:!1,ignoreRequestHook:(Z)=>{let $=$u(Z.origin,Z.path),J=D.ignoreOutgoingRequests;return!!(J&&$&&J($))},startSpanHook:(Z)=>{let $=$u(Z.origin,Z.path);if($.startsWith("data:")){let J=t9($);return{[u]:"auto.http.otel.node_fetch","http.url":J,[q6]:J,[C8]:`${Z.method||"GET"} ${J}`}}return{[u]:"auto.http.otel.node_fetch"}},requestHook:D.requestHook,responseHook:D.responseHook,headersToSpanAttributes:D.headersToSpanAttributes}}var Nu=N(Iu(),1);var i0=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;var Tu="Express";function ky0(D){W0(D,"auto.http.otel.express");let F=g(D).data,Z=F["express.type"];if(Z)D.setAttribute(c,`${Z}.express`);let $=F["express.name"];if(typeof $==="string")D.updateName($)}function Iy0(D,F){if(e()===aD())return i0&&q.warn("Isolation scope is still default isolation scope - skipping setting transactionName"),F;if(D.layerType==="request_handler"){let Z=D.request,$=Z.method?Z.method.toUpperCase():"GET";e().setTransactionName(`${$} ${D.route}`)}return F}var Eu=_(Tu,()=>new Nu.ExpressInstrumentation({requestHook:(D)=>ky0(D),spanNameHook:(D,F)=>Iy0(D,F)})),Ny0=()=>{return{name:Tu,setupOnce(){Eu()}}},fu=A(Ny0);var wc=N(Yc(),1);import*as NG from"node:diagnostics_channel";var Z1=N(M(),1),xJ=N(Q0(),1),l7=N(i(),1),Gc=N(F0(),1);var p1;(function(D){D.FASTIFY_NAME="fastify.name";let Z="fastify.type";D.FASTIFY_TYPE=Z;let $="hook.name";D.HOOK_NAME=$;let J="plugin.name";D.PLUGIN_NAME=J})(p1||(p1={}));var o5;(function(D){D.MIDDLEWARE="middleware";let Z="request_handler";D.REQUEST_HANDLER=Z})(o5||(o5={}));var s5;(function(D){D.MIDDLEWARE="middleware";let Z="request handler";D.REQUEST_HANDLER=Z})(s5||(s5={}));var zc=N(M(),1);var r5=Symbol("opentelemetry.instrumentation.fastify.request_active_span");function kG(D,F,Z,$={}){let J=F.startSpan(Z,{attributes:$}),Q=D[r5]||[];return Q.push(J),Object.defineProperty(D,r5,{enumerable:!1,configurable:!0,value:Q}),J}function vJ(D,F){let Z=D[r5]||[];if(!Z.length)return;Z.forEach(($)=>{if(F)$.setStatus({code:zc.SpanStatusCode.ERROR,message:F.message}),$.recordException(F);$.end()}),delete D[r5]}function Kc(D,F,Z){let $,J=void 0;try{if(J=D(),Wc(J))J.then((Q)=>F(void 0,Q),(Q)=>F(Q))}catch(Q){$=Q}finally{if(!Wc(J)){if(F($,J),$)throw $}return J}}function Wc(D){return typeof D==="object"&&D&&typeof Object.getOwnPropertyDescriptor(D,"then")?.value==="function"||!1}var iS0="0.1.0",nS0="@sentry/instrumentation-fastify-v3",Bc="anonymous",aS0=new Set(["onTimeout","onRequest","preParsing","preValidation","preSerialization","preHandler","onSend","onResponse","onError"]);class IG extends l7.InstrumentationBase{constructor(D={}){super(nS0,iS0,D)}init(){return[new l7.InstrumentationNodeModuleDefinition("fastify",[">=3.0.0 <4"],(D)=>{return this._patchConstructor(D)})]}_hookOnRequest(){let D=this;return function(Z,$,J){if(!D.isEnabled())return J();D._wrap($,"send",D._patchSend());let Q=Z,X=xJ.getRPCMetadata(Z1.context.active()),Y=Q.routeOptions?Q.routeOptions.url:Z.routerPath;if(Y&&X?.type===xJ.RPCType.HTTP)X.route=Y;let W=Z.method||"GET";e().setTransactionName(`${W} ${Y}`),J()}}_wrapHandler(D,F,Z,$){let J=this;return this._diag.debug("Patching fastify route.handler function"),function(...Q){if(!J.isEnabled())return Z.apply(this,Q);let X=Z.name||D||Bc,Y=`${s5.MIDDLEWARE} - ${X}`,W=Q[1],z=kG(W,J.tracer,Y,{[p1.FASTIFY_TYPE]:o5.MIDDLEWARE,[p1.PLUGIN_NAME]:D,[p1.HOOK_NAME]:F}),B=$&&Q[Q.length-1];if(B)Q[Q.length-1]=function(...K){vJ(W),B.apply(this,K)};return Z1.context.with(Z1.trace.setSpan(Z1.context.active(),z),()=>{return Kc(()=>{return Z.apply(this,Q)},(K)=>{if(K instanceof Error)z.setStatus({code:Z1.SpanStatusCode.ERROR,message:K.message}),z.recordException(K);if(!$)vJ(W)})})}}_wrapAddHook(){let D=this;return this._diag.debug("Patching fastify server.addHook function"),function(F){return function(...$){let J=$[0],Q=$[1],X=this.pluginName;if(!aS0.has(J))return F.apply(this,$);let Y=typeof $[$.length-1]==="function"&&Q.constructor.name!=="AsyncFunction";return F.apply(this,[J,D._wrapHandler(X,J,Q,Y)])}}}_patchConstructor(D){let F=this;function Z(...$){let J=D.fastify.apply(this,$);return J.addHook("onRequest",F._hookOnRequest()),J.addHook("preHandler",F._hookPreHandler()),oS0(),F._wrap(J,"addHook",F._wrapAddHook()),J}if(D.errorCodes!==void 0)Z.errorCodes=D.errorCodes;return Z.fastify=Z,Z.default=Z,Z}_patchSend(){let D=this;return this._diag.debug("Patching fastify reply.send function"),function(Z){return function(...J){let Q=J[0];if(!D.isEnabled())return Z.apply(this,J);return l7.safeExecuteInTheMiddle(()=>{return Z.apply(this,J)},(X)=>{if(!X&&Q instanceof Error)X=Q;vJ(this,X)})}}}_hookPreHandler(){let D=this;return this._diag.debug("Patching fastify preHandler function"),function(Z,$,J){if(!D.isEnabled())return J();let Q=Z,X=Q.routeOptions?.handler||Q.context?.handler,Y=X?.name.startsWith("bound ")?X.name.substring(6):X?.name,W=`${s5.REQUEST_HANDLER} - ${Y||this.pluginName||Bc}`,z={[p1.PLUGIN_NAME]:this.pluginName,[p1.FASTIFY_TYPE]:o5.REQUEST_HANDLER,[Gc.SEMATTRS_HTTP_ROUTE]:Q.routeOptions?Q.routeOptions.url:Z.routerPath};if(Y)z[p1.FASTIFY_NAME]=Y;let B=kG($,D.tracer,W,z);Hc(B);let{requestHook:K}=D.getConfig();if(K)l7.safeExecuteInTheMiddle(()=>K(B,{request:Z}),(G)=>{if(G)D._diag.error("request hook failed",G)},!0);return Z1.context.with(Z1.trace.setSpan(Z1.context.active(),B),()=>{J()})}}}function oS0(){let D=v();if(D)D.on("spanStart",(F)=>{Hc(F)})}function Hc(D){let F=g(D).data,Z=F["fastify.type"];if(F[c]||!Z)return;D.setAttributes({[u]:"auto.http.otel.fastify",[c]:`${Z}.fastify`});let $=F["fastify.name"]||F["plugin.name"]||F["hook.name"];if(typeof $==="string"){let J=$.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");D.updateName(J)}}var gJ="Fastify",Uc=_(`${gJ}.v3`,()=>new IG);function sS0(){let D=v();if(!D)return;else return D.getIntegrationByName(gJ)}function Vc(D,F,Z,$){let J=sS0()?.getShouldHandleError()||Cc;if($==="diagnostics-channel")this.diagnosticsChannelExists=!0;if(this.diagnosticsChannelExists&&$==="onError-hook"){i0&&q.warn("Fastify error handler was already registered via diagnostics channel.","You can safely remove `setupFastifyErrorHandler` call and set `shouldHandleError` on the integration options.");return}if(J(D,F,Z))p(D,{mechanism:{handled:!1,type:"auto.function.fastify"}})}var jc=_(`${gJ}.v5`,()=>{let D=new wc.FastifyOtelInstrumentation,F=D.plugin();return NG.subscribe("fastify.initialization",(Z)=>{let $=Z.fastify;$?.register(F).after((J)=>{if(J)i0&&q.error("Failed to setup Fastify instrumentation",J);else if(tS0(),$)eS0($)})}),NG.subscribe("tracing:fastify.request.handler:error",(Z)=>{let{error:$,request:J,reply:Q}=Z;Vc.call(Vc,$,J,Q,"diagnostics-channel")}),D}),rS0=({shouldHandleError:D})=>{let F;return{name:gJ,setupOnce(){F=D||Cc,Uc(),jc()},getShouldHandleError(){return F},setShouldHandleError(Z){F=Z}}},qc=A((D={})=>rS0(D));function Cc(D,F,Z){let $=Z.statusCode;return $>=500||$<=299}function Oc(D){let F=g(D),Z=F.description,$=F.data,J=$["fastify.type"],Q=J==="hook",X=J===Z?.startsWith("handler -"),Y=Z==="request"||J==="request-handler";if($[c]||!X&&!Y&&!Q)return;let W=Q?"hook":X?"middleware":Y?"request_handler":"<unknown>";D.setAttributes({[u]:"auto.http.otel.fastify",[c]:`${W}.fastify`});let z=$["fastify.name"]||$["plugin.name"]||$["hook.name"];if(typeof z==="string"){let B=z.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");D.updateName(B)}}function tS0(){let D=v();if(D)D.on("spanStart",(F)=>{Oc(F)})}function eS0(D){D.addHook("onRequest",async(F,Z)=>{if(F.opentelemetry){let{span:Q}=F.opentelemetry();if(Q)Oc(Q)}let $=F.routeOptions?.url,J=F.method||"GET";e().setTransactionName(`${J} ${$}`)})}var $l=N(M(),1),Jl=N(Zl(),1);var Ql="Graphql",Xl=_(Ql,Jl.GraphQLInstrumentation,(D)=>{let F=Wl(D);return{...F,responseHook(Z,$){if(W0(Z,"auto.graphql.otel.graphql"),$.errors?.length&&!g(Z).status)Z.setStatus({code:$l.SpanStatusCode.ERROR});let Q=g(Z).data,X=Q["graphql.operation.type"],Y=Q["graphql.operation.name"];if(F.useOperationNameForRootSpan&&X){let W=I0(Z),B=g(W).data[q3]||[],K=Y?`${X} ${Y}`:`${X}`;if(Array.isArray(B))B.push(K),W.setAttribute(q3,B);else if(typeof B==="string")W.setAttribute(q3,[B,K]);else W.setAttribute(q3,K);if(!g(W).data["original-description"])W.setAttribute("original-description",g(W).description);W.updateName(`${g(W).data["original-description"]} (${Tb0(B)})`)}}}}),Nb0=(D={})=>{return{name:Ql,setupOnce(){Xl(Wl(D))}}},Yl=A(Nb0);function Wl(D){return{ignoreResolveSpans:!0,ignoreTrivialResolveSpans:!0,useOperationNameForRootSpan:!0,...D}}function Tb0(D){if(Array.isArray(D)){let F=D.slice().sort();if(F.length<=5)return F.join(", ");else return`${F.slice(0,5).join(", ")}, +${F.length-5}`}return`${D}`}var fl=N(El(),1);var yl="Kafka",hl=_(yl,()=>new fl.KafkaJsInstrumentation({consumerHook(D){W0(D,"auto.kafkajs.otel.consumer")},producerHook(D){W0(D,"auto.kafkajs.otel.producer")}})),ob0=()=>{return{name:yl,setupOnce(){hl()}}},_l=A(ob0);var il=N(pl(),1);var nl="LruMemoizer",al=_(nl,()=>new il.LruMemoizerInstrumentation),eb0=()=>{return{name:nl,setupOnce(){al()}}},ol=A(eb0);var Gp=N(Bp(),1);var Hp="Mongo",Vp=_(Hp,()=>new Gp.MongoDBInstrumentation({dbStatementSerializer:Uv0,responseHook(D){W0(D,"auto.db.otel.mongo")}}));function Uv0(D){let F=dG(D);return JSON.stringify(F)}function dG(D){if(Array.isArray(D))return D.map((F)=>dG(F));if(jv0(D)){let F={};return Object.entries(D).map(([Z,$])=>[Z,dG($)]).reduce((Z,$)=>{if(Cv0($))Z[$[0]]=$[1];return Z},F)}return"?"}function jv0(D){return typeof D==="object"&&D!==null&&!qv0(D)}function qv0(D){let F=!1;if(typeof Buffer<"u")F=Buffer.isBuffer(D);return F}function Cv0(D){return Array.isArray(D)}var Ov0=()=>{return{name:Hp,setupOnce(){Vp()}}},wp=A(Ov0);var Sp=N(_p(),1);var bp="Mongoose",vp=_(bp,()=>new Sp.MongooseInstrumentation({responseHook(D){W0(D,"auto.db.otel.mongoose")}})),dv0=()=>{return{name:bp,setupOnce(){vp()}}},xp=A(dv0);var Zi=N(Fi(),1);var $i="Mysql",Ji=_($i,()=>new Zi.MySQLInstrumentation({})),Hx0=()=>{return{name:$i,setupOnce(){Ji()}}},Qi=A(Hx0);var y80=N(f80(),1);var h80="Mysql2",_80=_(h80,()=>new y80.MySQL2Instrumentation({responseHook(D){W0(D,"auto.db.otel.mysql2")}})),Zt0=()=>{return{name:h80,setupOnce(){_80()}}},S80=A(Zt0);var h10=N(D10(),1),_10=N(N10(),1);var gt0=["get","set","setex"],RH=["get","mget"],ut0=["set","setex"];function GF(D,F){return D.includes(F.toLowerCase())}function kH(D){if(GF(RH,D))return"cache.get";else if(GF(ut0,D))return"cache.put";else return}function dt0(D,F){return F.some((Z)=>D.startsWith(Z))}function E10(D,F){try{if(F.length===0)return;let Z=(J)=>{if(typeof J==="string"||typeof J==="number"||Buffer.isBuffer(J))return[J.toString()];else if(Array.isArray(J))return T10(J.map((Q)=>Z(Q)));else return["<unknown>"]},$=F[0];if(GF(gt0,D)&&$!=null)return Z($);return T10(F.map((J)=>Z(J)))}catch{return}}function f10(D,F,Z){if(!kH(D))return!1;for(let $ of F)if(dt0($,Z))return!0;return!1}function y10(D){let F=(Z)=>{try{if(Buffer.isBuffer(Z))return Z.byteLength;else if(typeof Z==="string")return Z.length;else if(typeof Z==="number")return Z.toString().length;else if(Z===null||Z===void 0)return 0;return JSON.stringify(Z).length}catch{return}};return Array.isArray(D)?D.reduce((Z,$)=>{let J=F($);return typeof J==="number"?Z!==void 0?Z+J:J:Z},0):F(D)}function T10(D){let F=[],Z=($)=>{$.forEach((J)=>{if(Array.isArray(J))Z(J);else F.push(J)})};return Z(D),F}var BQ="Redis",HF={},S10=(D,F,Z,$)=>{D.setAttribute(u,"auto.db.otel.redis");let J=E10(F,Z),Q=kH(F);if(!J||!Q||!HF.cachePrefixes||!f10(F,J,HF.cachePrefixes))return;let X=g(D).data["net.peer.name"],Y=g(D).data["net.peer.port"];if(Y&&X)D.setAttributes({"network.peer.address":X,"network.peer.port":Y});let W=y10($);if(W)D.setAttribute(zz,W);if(GF(RH,F)&&W!==void 0)D.setAttribute(Yz,W>0);D.setAttributes({[c]:Q,[Wz]:J});let z=J.join(", ");D.updateName(HF.maxCacheKeyLength?H6(z,HF.maxCacheKeyLength):z)},mt0=_(`${BQ}.IORedis`,()=>{return new h10.IORedisInstrumentation({responseHook:S10})}),ct0=_(`${BQ}.Redis`,()=>{return new _10.RedisInstrumentation({responseHook:S10})}),b10=Object.assign(()=>{mt0(),ct0()},{id:BQ}),lt0=(D={})=>{return{name:BQ,setupOnce(){HF=D,b10()}}},v10=A(lt0);var H60=N(G60(),1);var V60="Postgres",w60=_(V60,H60.PgInstrumentation,(D)=>({requireParentSpan:!0,requestHook(F){W0(F,"auto.db.otel.postgres")},ignoreConnectSpans:D?.ignoreConnectSpans??!1})),be0=(D)=>{return{name:V60,setupOnce(){w60(D)}}},U60=A(be0);var y3=N(M(),1),a6=N(i(),1),X1=N(F0(),1);var hH="PostgresJs",j60=[">=3.0.0 <4"],ve0=/^(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER)/i,xe0=Symbol.for("sentry.query.from.instrumented.sql"),q60=_(hH,(D)=>new C60({requireParentSpan:D?.requireParentSpan??!0,requestHook:D?.requestHook}));class C60 extends a6.InstrumentationBase{constructor(D){super("sentry-postgres-js",D0,D)}init(){let D=new a6.InstrumentationNodeModuleDefinition("postgres",j60,(F)=>{try{return this._patchPostgres(F)}catch(Z){return i0&&q.error("Failed to patch postgres module:",Z),F}},(F)=>F);return["src","cf/src","cjs/src"].forEach((F)=>{D.files.push(new a6.InstrumentationNodeModuleFile(`postgres/${F}/query.js`,j60,this._patchQueryPrototype.bind(this),this._unpatchQueryPrototype.bind(this)))}),D}_patchPostgres(D){let F=typeof D==="function",Z=F?D:D.default;if(typeof Z!=="function")return i0&&q.warn("postgres module does not export a function. Skipping instrumentation."),D;let $=this,J=function(...Q){let X=Reflect.construct(Z,Q);if(!X||typeof X!=="function")return i0&&q.warn("postgres() did not return a valid instance"),X;let Y=$.getConfig();return sz(X,{requireParentSpan:Y.requireParentSpan,requestHook:Y.requestHook})};Object.setPrototypeOf(J,Z),Object.setPrototypeOf(J.prototype,Z.prototype);for(let Q of Object.getOwnPropertyNames(Z))if(!["length","name","prototype"].includes(Q)){let X=Object.getOwnPropertyDescriptor(Z,Q);if(X)Object.defineProperty(J,Q,X)}if(F)return J;else return K5(D,"default",J),D}_shouldCreateSpans(){let D=this.getConfig();return y3.trace.getSpan(y3.context.active())!==void 0||!D.requireParentSpan}_setOperationName(D,F,Z){if(Z){D.setAttribute(X1.ATTR_DB_OPERATION_NAME,Z);return}let $=F?.match(ve0);if($?.[1])D.setAttribute(X1.ATTR_DB_OPERATION_NAME,$[1].toUpperCase())}_reconstructQuery(D){if(!D?.length)return;if(D.length===1)return D[0]||void 0;return D.reduce((F,Z,$)=>$===0?Z:`${F}$${$}${Z}`,"")}_sanitizeSqlQuery(D){if(!D)return"Unknown SQL Query";return D.replace(/--.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/;\s*$/,"").replace(/\s+/g," ").trim().replace(/\bX'[0-9A-Fa-f]*'/gi,"?").replace(/\bB'[01]*'/gi,"?").replace(/'(?:[^']|'')*'/g,"?").replace(/\b0x[0-9A-Fa-f]+/gi,"?").replace(/\b(?:TRUE|FALSE)\b/gi,"?").replace(/-?\b\d+\.?\d*[eE][+-]?\d+\b/g,"?").replace(/-?\b\d+\.\d+\b/g,"?").replace(/-?\.\d+\b/g,"?").replace(/(?<!\$)-?\b\d+\b/g,"?").replace(/\bIN\b\s*\(\s*\?(?:\s*,\s*\?)*\s*\)/gi,"IN (?)").replace(/\bIN\b\s*\(\s*\$\d+(?:\s*,\s*\$\d+)*\s*\)/gi,"IN ($?)")}_patchQueryPrototype(D){let F=this,Z=D.Query.prototype.handle;return D.Query.prototype.handle=async function(...$){if(this[xe0])return Z.apply(this,$);if(!F._shouldCreateSpans())return Z.apply(this,$);let J=F._reconstructQuery(this.strings),Q=F._sanitizeSqlQuery(J);return e0({name:Q||"postgresjs.query",op:"db"},(X)=>{W0(X,"auto.db.postgresjs"),X.setAttributes({[X1.ATTR_DB_SYSTEM_NAME]:"postgres",[X1.ATTR_DB_QUERY_TEXT]:Q});let Y=F.getConfig(),{requestHook:W}=Y;if(W)a6.safeExecuteInTheMiddle(()=>W(X,Q,void 0),(K)=>{if(K)X.setAttribute("sentry.hook.error","requestHook failed"),i0&&q.error(`Error in requestHook for ${hH} integration:`,K)},!0);let z=this.resolve;this.resolve=new Proxy(z,{apply:(K,G,H)=>{try{F._setOperationName(X,Q,H?.[0]?.command),X.end()}catch(V){i0&&q.error("Error ending span in resolve callback:",V)}return Reflect.apply(K,G,H)}});let B=this.reject;this.reject=new Proxy(B,{apply:(K,G,H)=>{try{X.setStatus({code:s,message:H?.[0]?.message||"unknown_error"}),X.setAttribute(X1.ATTR_DB_RESPONSE_STATUS_CODE,H?.[0]?.code||"unknown"),X.setAttribute(X1.ATTR_ERROR_TYPE,H?.[0]?.name||"unknown"),F._setOperationName(X,Q),X.end()}catch(V){i0&&q.error("Error ending span in reject callback:",V)}return Reflect.apply(K,G,H)}});try{return Z.apply(this,$)}catch(K){throw X.setStatus({code:s,message:K instanceof Error?K.message:"unknown_error"}),X.end(),K}})},D.Query.prototype.handle.__sentry_original__=Z,D}_unpatchQueryPrototype(D){if(D.Query.prototype.handle.__sentry_original__)D.Query.prototype.handle=D.Query.prototype.handle.__sentry_original__;return D}}var ge0=(D)=>{return{name:hH,setupOnce(){q60(D)}}},O60=A(ge0);var b8=N(M(),1);var z90=N(M(),1),AQ=N(X90(),1),o6=N(M(),1);var _DD={name:"@prisma/instrumentation-contract",version:"7.4.2",description:"Shared types and utilities for Prisma instrumentation",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{require:{types:"./dist/index.d.ts",default:"./dist/index.js"},import:{types:"./dist/index.d.mts",default:"./dist/index.mjs"}}},license:"Apache-2.0",homepage:"https://www.prisma.io",repository:{type:"git",url:"https://github.com/prisma/prisma.git",directory:"packages/instrumentation-contract"},bugs:"https://github.com/prisma/prisma/issues",scripts:{dev:"DEV=true tsx helpers/build.ts",build:"tsx helpers/build.ts",prepublishOnly:"pnpm run build",test:"vitest run"},files:["dist"],sideEffects:!1,devDependencies:{"@opentelemetry/api":"1.9.0"},peerDependencies:{"@opentelemetry/api":"^1.8"}},SDD=_DD.version.split(".")[0],KV="PRISMA_INSTRUMENTATION",BV=`V${SDD}_PRISMA_INSTRUMENTATION`,S3=globalThis;function bDD(){let D=S3[BV];if(D?.helper)return D.helper;return S3[KV]?.helper}function vDD(D){let F={helper:D};S3[BV]=F,S3[KV]=F}function xDD(){delete S3[BV],delete S3[KV]}var gDD=process.env.PRISMA_SHOW_ALL_TRACES==="true",uDD="00-10-10-00";function dDD(D){switch(D){case"client":return o6.SpanKind.CLIENT;case"internal":default:return o6.SpanKind.INTERNAL}}var mDD=class{tracerProvider;ignoreSpanTypes;constructor({tracerProvider:D,ignoreSpanTypes:F}){this.tracerProvider=D,this.ignoreSpanTypes=F}isEnabled(){return!0}getTraceParent(D){let F=o6.trace.getSpanContext(D??o6.context.active());if(F)return`00-${F.traceId}-${F.spanId}-0${F.traceFlags}`;return uDD}dispatchEngineSpans(D){let F=this.tracerProvider.getTracer("prisma"),Z=new Map,$=D.filter((J)=>J.parentId===null);for(let J of $)K90(F,J,D,Z,this.ignoreSpanTypes)}getActiveContext(){return o6.context.active()}runInChildSpan(D,F){if(typeof D==="string")D={name:D};if(D.internal&&!gDD)return F();let Z=this.tracerProvider.getTracer("prisma"),$=D.context??this.getActiveContext(),J=`prisma:client:${D.name}`;if(B90(J,this.ignoreSpanTypes))return F();if(D.active===!1){let Q=Z.startSpan(J,D,$);return Y90(Q,F(Q,$))}return Z.startActiveSpan(J,D,(Q)=>Y90(Q,F(Q,$)))}};function K90(D,F,Z,$,J){if(B90(F.name,J))return;let Q={attributes:F.attributes,kind:dDD(F.kind),startTime:F.startTime};D.startActiveSpan(F.name,Q,(X)=>{if($.set(F.id,X.spanContext().spanId),F.links)X.addLinks(F.links.flatMap((W)=>{let z=$.get(W);if(!z)return[];return{context:{spanId:z,traceId:X.spanContext().traceId,traceFlags:X.spanContext().traceFlags}}}));let Y=Z.filter((W)=>W.parentId===F.id);for(let W of Y)K90(D,W,Z,$,J);X.end(F.endTime)})}function Y90(D,F){if(cDD(F))return F.then((Z)=>{return D.end(),Z},(Z)=>{throw D.end(),Z});return D.end(),F}function cDD(D){return D!=null&&typeof D.then==="function"}function B90(D,F){return F.some((Z)=>typeof Z==="string"?Z===D:Z.test(D))}var G90={name:"@prisma/instrumentation",version:"7.4.2",description:"OpenTelemetry compliant instrumentation for Prisma Client",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{require:{types:"./dist/index.d.ts",default:"./dist/index.js"},import:{types:"./dist/index.d.ts",default:"./dist/index.mjs"}}},license:"Apache-2.0",homepage:"https://www.prisma.io",repository:{type:"git",url:"https://github.com/prisma/prisma.git",directory:"packages/instrumentation"},bugs:"https://github.com/prisma/prisma/issues",devDependencies:{"@opentelemetry/api":"1.9.0","@prisma/instrumentation-contract":"workspace:*","@types/node":"~20.19.24",typescript:"5.4.5"},dependencies:{"@opentelemetry/instrumentation":"^0.207.0"},peerDependencies:{"@opentelemetry/api":"^1.8"},files:["dist"],keywords:["prisma","instrumentation","opentelemetry","otel"],scripts:{dev:"DEV=true tsx helpers/build.ts",build:"tsx helpers/build.ts",prepublishOnly:"pnpm run build",test:"vitest run"},sideEffects:!1},W90=G90.version,lDD=G90.name,pDD="@prisma/client",H90=class extends AQ.InstrumentationBase{tracerProvider;constructor(D={}){super(lDD,W90,D)}setTracerProvider(D){this.tracerProvider=D}init(){return[new AQ.InstrumentationNodeModuleDefinition(pDD,[W90])]}enable(){let D=this._config;vDD(new mDD({tracerProvider:this.tracerProvider??z90.trace.getTracerProvider(),ignoreSpanTypes:D.ignoreSpanTypes??[]}))}disable(){xDD()}isEnabled(){return bDD()!==void 0}};var V90="Prisma";function iDD(D){return!!D&&typeof D==="object"&&"dispatchEngineSpans"in D}function w90(){let D=globalThis.PRISMA_INSTRUMENTATION;return D&&typeof D==="object"&&"helper"in D?D.helper:void 0}class U90 extends H90{constructor(D){super(D?.instrumentationConfig)}enable(){super.enable();let D=w90();if(iDD(D))D.createEngineSpan=(F)=>{let Z=b8.trace.getTracer("prismaV5Compatibility"),$=Z._idGenerator;if(!$){h0(()=>{console.warn("[Sentry] Could not find _idGenerator on tracer, skipping Prisma v5 compatibility - some Prisma spans may be missing!")});return}try{F.spans.forEach((J)=>{let Q=nDD(J.kind),X=J.parent_span_id,Y=J.span_id,W=J.trace_id,z=J.links?.map((K)=>{return{context:{traceId:K.trace_id,spanId:K.span_id,traceFlags:b8.TraceFlags.SAMPLED}}}),B=b8.trace.setSpanContext(b8.context.active(),{traceId:W,spanId:X,traceFlags:b8.TraceFlags.SAMPLED});b8.context.with(B,()=>{let K={generateTraceId:()=>{return W},generateSpanId:()=>{return Y}};Z._idGenerator=K,Z.startSpan(J.name,{kind:Q,links:z,startTime:J.start_time,attributes:J.attributes}).end(J.end_time),Z._idGenerator=$})})}finally{Z._idGenerator=$}}}}function nDD(D){switch(D){case"client":return b8.SpanKind.CLIENT;case"internal":default:return b8.SpanKind.INTERNAL}}var aDD=_(V90,(D)=>{return new U90(D)}),j90=A((D)=>{return{name:V90,setupOnce(){aDD(D)},setup(F){if(!w90())return;F.on("spanStart",(Z)=>{let $=g(Z);if($.description?.startsWith("prisma:"))Z.setAttribute(u,"auto.db.otel.prisma");if($.description==="prisma:engine:db_query"&&$.data["db.query.text"])Z.updateName($.data["db.query.text"]);if($.description==="prisma:engine:db_query"&&!$.data["db.system"])Z.setAttribute("db.system","prisma")})}}});var g90=N(x90(),1);var u90="Hapi",d90=_(u90,()=>new g90.HapiInstrumentation),q8D=()=>{return{name:u90,setupOnce(){d90()}}},m90=A(q8D);var IQ=N(F0(),1);var r6={HONO_TYPE:"hono.type",HONO_NAME:"hono.name"},AF={MIDDLEWARE:"middleware",REQUEST_HANDLER:"request_handler"};var J9=N(M(),1),kQ=N(i(),1);var C8D="@sentry/instrumentation-hono",O8D="0.0.1";class UV extends kQ.InstrumentationBase{constructor(D={}){super(C8D,O8D,D)}init(){return[new kQ.InstrumentationNodeModuleDefinition("hono",[">=4.0.0 <5"],(D)=>this._patch(D))]}_patch(D){let F=this;class Z extends D.Hono{constructor(...$){super(...$);F._wrap(this,"get",F._patchHandler()),F._wrap(this,"post",F._patchHandler()),F._wrap(this,"put",F._patchHandler()),F._wrap(this,"delete",F._patchHandler()),F._wrap(this,"options",F._patchHandler()),F._wrap(this,"patch",F._patchHandler()),F._wrap(this,"all",F._patchHandler()),F._wrap(this,"on",F._patchOnHandler()),F._wrap(this,"use",F._patchMiddlewareHandler())}}try{D.Hono=Z}catch{return{...D,Hono:Z}}return D}_patchHandler(){let D=this;return function(F){return function(...$){if(typeof $[0]==="string"){let J=$[0];if($.length===1)return F.apply(this,[J]);let Q=$.slice(1);return F.apply(this,[J,...Q.map((X)=>D._wrapHandler(X))])}return F.apply(this,$.map((J)=>D._wrapHandler(J)))}}}_patchOnHandler(){let D=this;return function(F){return function(...$){let J=$.slice(2);return F.apply(this,[...$.slice(0,2),...J.map((Q)=>D._wrapHandler(Q))])}}}_patchMiddlewareHandler(){let D=this;return function(F){return function(...$){if(typeof $[0]==="string"){let J=$[0];if($.length===1)return F.apply(this,[J]);let Q=$.slice(1);return F.apply(this,[J,...Q.map((X)=>D._wrapHandler(X))])}return F.apply(this,$.map((J)=>D._wrapHandler(J)))}}}_wrapHandler(D){let F=this;return function(Z,$){if(!F.isEnabled())return D.apply(this,[Z,$]);let J=Z.req.path,Q=F.tracer.startSpan(J);return J9.context.with(J9.trace.setSpan(J9.context.active(),Q),()=>{return F._safeExecute(()=>{let X=D.apply(this,[Z,$]);if(YD(X))return X.then((Y)=>{let W=F._determineHandlerType(Y);return Q.setAttributes({[r6.HONO_TYPE]:W,[r6.HONO_NAME]:W===AF.REQUEST_HANDLER?J:D.name||"anonymous"}),F.getConfig().responseHook?.(Q),Y});else{let Y=F._determineHandlerType(X);return Q.setAttributes({[r6.HONO_TYPE]:Y,[r6.HONO_NAME]:Y===AF.REQUEST_HANDLER?J:D.name||"anonymous"}),F.getConfig().responseHook?.(Q),X}},()=>Q.end(),(X)=>{F._handleError(Q,X),Q.end()})})}}_safeExecute(D,F,Z){try{let $=D();if(YD($))$.then(()=>F(),(J)=>Z(J));else F();return $}catch($){throw Z($),$}}_determineHandlerType(D){return D===void 0?AF.MIDDLEWARE:AF.REQUEST_HANDLER}_handleError(D,F){if(F instanceof Error)D.setStatus({code:J9.SpanStatusCode.ERROR,message:F.message}),D.recordException(F)}}var c90="Hono";function L8D(D){let F=g(D).data,Z=F[r6.HONO_TYPE];if(F[c]||!Z)return;D.setAttributes({[u]:"auto.http.otel.hono",[c]:`${Z}.hono`});let $=F[r6.HONO_NAME];if(typeof $==="string")D.updateName($);if(e()===aD()){i0&&q.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let J=F[IQ.ATTR_HTTP_ROUTE],Q=F[IQ.ATTR_HTTP_REQUEST_METHOD];if(typeof J==="string"&&typeof Q==="string")e().setTransactionName(`${Q} ${J}`)}var l90=_(c90,()=>new UV({responseHook:(D)=>{L8D(D)}})),P8D=()=>{return{name:c90,setupOnce(){l90()}}},p90=A(P8D);var V30=N(H30(),1),w30=N(F0(),1);var U30="Koa",j30=_(U30,V30.KoaInstrumentation,(D={})=>{return{ignoreLayersType:D.ignoreLayersType,requestHook(F,Z){W0(F,"auto.http.otel.koa");let $=g(F).data,J=$["koa.type"];if(J)F.setAttribute(c,`${J}.koa`);let Q=$["koa.name"];if(typeof Q==="string")F.updateName(Q||"< unknown >");if(e()===aD()){i0&&q.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let X=$[w30.ATTR_HTTP_ROUTE],Y=Z.context?.request?.method?.toUpperCase()||"GET";if(X)e().setTransactionName(`${Y} ${X}`)}}}),_8D=(D={})=>{return{name:U30,setupOnce(){j30(D)}}},q30=A(_8D);var g30=N(x30(),1);var u30="Connect",d30=_(u30,()=>new g30.ConnectInstrumentation),a8D=()=>{return{name:u30,setupOnce(){d30()}}},m30=A(a8D);var X40=N(Q40(),1);var z1D=new Set(["callProcedure","execSql","execSqlBatch","execBulkLoad","prepare","execute"]),Y40="Tedious",W40=_(Y40,()=>new X40.TediousInstrumentation({})),K1D=()=>{let D;return{name:Y40,setupOnce(){let F=W40();D=I5(F)},setup(F){D?.(()=>F.on("spanStart",(Z)=>{let{description:$,data:J}=g(Z);if(!$||J["db.system"]!=="mssql")return;let Q=$.split(" ")[0]||"";if(z1D.has(Q))Z.setAttribute(u,"auto.db.otel.tedious")}))}}},z40=A(K1D);var C40=N(q40(),1);var O40="GenericPool",L40=_(O40,()=>new C40.GenericPoolInstrumentation({})),V1D=()=>{let D;return{name:O40,setupOnce(){let F=L40();D=I5(F)},setup(F){D?.(()=>F.on("spanStart",(Z)=>{let J=g(Z).description;if(J==="generic-pool.aquire"||J==="generic-pool.acquire")Z.setAttribute(u,"auto.db.otel.generic_pool")}))}}},P40=A(V1D);var i40=N(p40(),1);var n40="Amqplib",a1D={consumeEndHook:(D)=>{W0(D,"auto.amqplib.otel.consumer")},publishHook:(D)=>{W0(D,"auto.amqplib.otel.publisher")}},a40=_(n40,()=>new i40.AmqplibInstrumentation(a1D)),o1D=()=>{return{name:n40,setupOnce(){a40()}}},o40=A(o1D);var TF="VercelAI";var bQ=N(i(),1);var s1D=[">=3.0.0 <7"],s40=["generateText","streamText","generateObject","streamObject","embed","embedMany","rerank"];function r1D(D){if(typeof D!=="object"||D===null)return!1;let F=D;return"type"in F&&"error"in F&&"toolName"in F&&"toolCallId"in F&&F.type==="tool-error"&&F.error instanceof Error}function t1D(D){if(typeof D!=="object"||D===null||!("content"in D))return;let F=D;if(!Array.isArray(F.content))return;e1D(F.content),D6D(F.content)}function e1D(D){for(let F of D){if(!r1D(F))continue;let Z=UK(F.toolCallId);if(Z)oD(($)=>{$.setContext("trace",{trace_id:Z.traceId,span_id:Z.spanId}),$.setTag("vercel.ai.tool.name",F.toolName),$.setTag("vercel.ai.tool.callId",F.toolCallId),$.setLevel("error"),p(F.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})});else oD(($)=>{$.setTag("vercel.ai.tool.name",F.toolName),$.setTag("vercel.ai.tool.callId",F.toolCallId),$.setLevel("error"),p(F.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})})}}function D6D(D){for(let F of D)if(typeof F==="object"&&F!==null&&"toolCallId"in F&&typeof F.toolCallId==="string")jK(F.toolCallId)}function F6D(D,F,Z,$){let J=D?.recordInputs!==void 0?D.recordInputs:F.recordInputs!==void 0?F.recordInputs:Z===!0?!0:$,Q=D?.recordOutputs!==void 0?D.recordOutputs:F.recordOutputs!==void 0?F.recordOutputs:Z===!0?!0:$;return{recordInputs:J,recordOutputs:Q}}class EF extends bQ.InstrumentationBase{__init(){this._isPatched=!1}__init2(){this._callbacks=[]}constructor(D={}){super("@sentry/instrumentation-vercel-ai",D0,D);EF.prototype.__init.call(this),EF.prototype.__init2.call(this)}init(){return new bQ.InstrumentationNodeModuleDefinition("ai",s1D,this._patch.bind(this))}callWhenPatched(D){if(this._isPatched)D();else this._callbacks.push(D)}_patch(D){this._isPatched=!0,this._callbacks.forEach((Z)=>Z()),this._callbacks=[];let F=(Z)=>{return new Proxy(Z,{apply:($,J,Q)=>{let X=Q[0].experimental_telemetry||{},Y=X.isEnabled,W=v(),z=W?.getIntegrationByName(TF),B=z?.options,K=z?Boolean(W?.getOptions().sendDefaultPii):!1,{recordInputs:G,recordOutputs:H}=F6D(B,X,Y,K);return Q[0].experimental_telemetry={...X,isEnabled:Y!==void 0?Y:!0,recordInputs:G,recordOutputs:H},sD(()=>Reflect.apply($,J,Q),(V)=>{if(V&&typeof V==="object")x0(V,"_sentry_active_span",O8())},()=>{},(V)=>{t1D(V)})}})};if(Object.prototype.toString.call(D)==="[object Module]"){for(let Z of s40)if(D[Z]!=null)D[Z]=F(D[Z]);return D}else{let Z=s40.reduce(($,J)=>{if(D[J]!=null)$[J]=F(D[J]);return $},{});return{...D,...Z}}}}var r40=_(TF,()=>new EF({}));function Z6D(D){return!!D.getIntegrationByName("Modules")?.getModules?.()?.ai}var $6D=(D={})=>{let F;return{name:TF,options:D,setupOnce(){F=r40()},afterAllSetup(Z){if(D.force??Z6D(Z))S$(Z);else F?.callWhenPatched(()=>S$(Z))}}},t40=A($6D);var vQ=N(i(),1);var J6D=[">=4.0.0 <7"];class SV extends vQ.InstrumentationBase{constructor(D={}){super("@sentry/instrumentation-openai",D0,D)}init(){return new vQ.InstrumentationNodeModuleDefinition("openai",J6D,this._patch.bind(this))}_patch(D){let F=D;return F=this._patchClient(F,"OpenAI"),F=this._patchClient(F,"AzureOpenAI"),F}_patchClient(D,F){let Z=D[F];if(!Z)return D;let $=this.getConfig(),J=function(...Q){if(T7(y6))return Reflect.construct(Z,Q);let X=Reflect.construct(Z,Q);return x$(X,$)};Object.setPrototypeOf(J,Z),Object.setPrototypeOf(J.prototype,Z.prototype);for(let Q of Object.getOwnPropertyNames(Z))if(!["length","name","prototype"].includes(Q)){let X=Object.getOwnPropertyDescriptor(Z,Q);if(X)Object.defineProperty(J,Q,X)}try{D[F]=J}catch{Object.defineProperty(D,F,{value:J,writable:!0,configurable:!0,enumerable:!0})}if(D.default===Z)try{D.default=J}catch{Object.defineProperty(D,"default",{value:J,writable:!0,configurable:!0,enumerable:!0})}return D}}var e40=_(y6,(D)=>new SV(D)),Q6D=(D={})=>{return{name:y6,setupOnce(){e40(D)}}},D50=A(Q6D);var xQ=N(i(),1);var X6D=[">=0.19.2 <1.0.0"];class bV extends xQ.InstrumentationBase{constructor(D={}){super("@sentry/instrumentation-anthropic-ai",D0,D)}init(){return new xQ.InstrumentationNodeModuleDefinition("@anthropic-ai/sdk",X6D,this._patch.bind(this))}_patch(D){let F=D.Anthropic,Z=this.getConfig(),$=function(...J){if(T7(h6))return Reflect.construct(F,J);let Q=Reflect.construct(F,J);return g$(Q,Z)};Object.setPrototypeOf($,F),Object.setPrototypeOf($.prototype,F.prototype);for(let J of Object.getOwnPropertyNames(F))if(!["length","name","prototype"].includes(J)){let Q=Object.getOwnPropertyDescriptor(F,J);if(Q)Object.defineProperty($,J,Q)}try{D.Anthropic=$}catch{Object.defineProperty(D,"Anthropic",{value:$,writable:!0,configurable:!0,enumerable:!0})}if(D.default===F)try{D.default=$}catch{Object.defineProperty(D,"default",{value:$,writable:!0,configurable:!0,enumerable:!0})}return D}}var F50=_(h6,(D)=>new bV(D)),Y6D=(D={})=>{return{name:h6,options:D,setupOnce(){F50(D)}}},Z50=A(Y6D);var g3=N(i(),1);var $50=[">=0.10.0 <2"];class vV extends g3.InstrumentationBase{constructor(D={}){super("@sentry/instrumentation-google-genai",D0,D)}init(){return new g3.InstrumentationNodeModuleDefinition("@google/genai",$50,(F)=>this._patch(F),(F)=>F,[new g3.InstrumentationNodeModuleFile("@google/genai/dist/node/index.cjs",$50,(F)=>this._patch(F),(F)=>F)])}_patch(D){let F=D.GoogleGenAI,Z=this.getConfig();if(typeof F!=="function")return D;let $=function(...J){if(T7(_6))return Reflect.construct(F,J);let Q=Reflect.construct(F,J);return u$(Q,Z)};Object.setPrototypeOf($,F),Object.setPrototypeOf($.prototype,F.prototype);for(let J of Object.getOwnPropertyNames(F))if(!["length","name","prototype"].includes(J)){let Q=Object.getOwnPropertyDescriptor(F,J);if(Q)Object.defineProperty($,J,Q)}return K5(D,"GoogleGenAI",$),D}}var J50=_(_6,(D)=>new vV(D)),W6D=(D={})=>{return{name:_6,setupOnce(){J50(D)}}},Q50=A(W6D);var F7=N(i(),1);var gQ=[">=0.1.0 <2.0.0"];function z6D(D,F){if(!D)return[F];if(Array.isArray(D)){if(D.includes(F))return D;return[...D,F]}if(typeof D==="object")return[D,F];return D}function K6D(D,F,Z){return new Proxy(D,{apply($,J,Q){let Y=Q[1];if(!Y||typeof Y!=="object"||Array.isArray(Y))Y={},Q[1]=Y;let W=Y.callbacks,z=z6D(W,F);return Y.callbacks=z,Reflect.apply($,J,Q)}})}class xV extends F7.InstrumentationBase{constructor(D={}){super("@sentry/instrumentation-langchain",D0,D)}init(){let D=[],F=["@langchain/anthropic","@langchain/openai","@langchain/google-genai","@langchain/mistralai","@langchain/google-vertexai","@langchain/groq"];for(let Z of F)D.push(new F7.InstrumentationNodeModuleDefinition(Z,gQ,this._patch.bind(this),($)=>$,[new F7.InstrumentationNodeModuleFile(`${Z}/dist/index.cjs`,gQ,this._patch.bind(this),($)=>$)]));return D.push(new F7.InstrumentationNodeModuleDefinition("langchain",gQ,this._patch.bind(this),(Z)=>Z,[new F7.InstrumentationNodeModuleFile("langchain/dist/chat_models/universal.cjs",gQ,this._patch.bind(this),(Z)=>Z)])),D}_patch(D){gz([y6,h6,_6]);let F=m$(this.getConfig());return this._patchRunnableMethods(D,F),D}_patchRunnableMethods(D,F){let Z=["ChatAnthropic","ChatOpenAI","ChatGoogleGenerativeAI","ChatMistralAI","ChatVertexAI","ChatGroq","ConfigurableModel"],$=D.universal_exports??D,J=Object.values($).find((Y)=>{return typeof Y==="function"&&Z.includes(Y.name)});if(!J)return;let Q=J.prototype;if(Q.__sentry_patched__)return;Q.__sentry_patched__=!0;let X=["invoke","stream","batch"];for(let Y of X){let W=Q[Y];if(typeof W==="function")Q[Y]=K6D(W,F)}}}var X50=_(d$,(D)=>new xV(D)),B6D=(D={})=>{return{name:d$,setupOnce(){X50(D)}}},Y50=A(B6D);var u3=N(i(),1);var W50=[">=0.0.0 <2.0.0"];class gV extends u3.InstrumentationBase{constructor(D={}){super("@sentry/instrumentation-langgraph",D0,D)}init(){return new u3.InstrumentationNodeModuleDefinition("@langchain/langgraph",W50,this._patch.bind(this),(F)=>F,[new u3.InstrumentationNodeModuleFile("@langchain/langgraph/dist/index.cjs",W50,this._patch.bind(this),(F)=>F)])}_patch(D){if(D.StateGraph&&typeof D.StateGraph==="function")l$(D.StateGraph.prototype,this.getConfig());return D}}var z50=_(c$,(D)=>new gV(D)),G6D=(D={})=>{return{name:c$,setupOnce(){z50(D)}}},K50=A(G6D);var q50=N(i(),1);var D6=N(M(),1),F6=N(i(),1),v8=N(F0(),1);import*as G50 from"node:net";function H50(D,F,Z,$,J){let X=()=>{},Y=J.firestoreSpanCreationHook;if(typeof Y==="function")X=(B)=>{F6.safeExecuteInTheMiddle(()=>Y(B),(K)=>{if(!K)return;D6.diag.error(K?.message)},!0)};let W=new F6.InstrumentationNodeModuleDefinition("@firebase/firestore",F,(B)=>B50(B,Z,$,D,X)),z=["@firebase/firestore/dist/lite/index.node.cjs.js","@firebase/firestore/dist/lite/index.node.mjs.js","@firebase/firestore/dist/lite/index.rn.esm2017.js","@firebase/firestore/dist/lite/index.cjs.js"];for(let B of z)W.files.push(new F6.InstrumentationNodeModuleFile(B,F,(K)=>B50(K,Z,$,D,X),(K)=>V50(K,$)));return W}function B50(D,F,Z,$,J){return V50(D,Z),F(D,"addDoc",H6D($,J)),F(D,"getDocs",w6D($,J)),F(D,"setDoc",U6D($,J)),F(D,"deleteDoc",V6D($,J)),D}function V50(D,F){for(let Z of["addDoc","getDocs","setDoc","deleteDoc"])if(F6.isWrapped(D[Z]))F(D,Z);return D}function H6D(D,F){return function($){return function(J,Q){let X=dQ(D,"addDoc",J);return F(X),uQ(X,()=>{return $(J,Q)})}}}function V6D(D,F){return function($){return function(J){let Q=dQ(D,"deleteDoc",J.parent||J);return F(Q),uQ(Q,()=>{return $(J)})}}}function w6D(D,F){return function($){return function(J){let Q=dQ(D,"getDocs",J);return F(Q),uQ(Q,()=>{return $(J)})}}}function U6D(D,F){return function($){return function(J,Q,X){let Y=dQ(D,"setDoc",J.parent||J);return F(Y),uQ(Y,()=>{return typeof X<"u"?$(J,Q,X):$(J,Q)})}}}function uQ(D,F){return D6.context.with(D6.trace.setSpan(D6.context.active(),D),()=>{return F6.safeExecuteInTheMiddle(()=>{return F()},(Z)=>{if(Z)D.recordException(Z);D.end()},!0)})}function dQ(D,F,Z){let $=D.startSpan(`${F} ${Z.path}`,{kind:D6.SpanKind.CLIENT});return q6D($,Z),$.setAttribute(v8.ATTR_DB_OPERATION_NAME,F),$}function j6D(D){let F,Z;if(typeof D.host==="string")if(D.host.startsWith("[")){if(D.host.endsWith("]"))F=D.host.replace(/^\[|\]$/g,"");else if(D.host.includes("]:")){let $=D.host.lastIndexOf(":");if($!==-1)F=D.host.slice(1,$).replace(/^\[|\]$/g,""),Z=D.host.slice($+1)}}else if(G50.isIPv6(D.host))F=D.host;else{let $=D.host.lastIndexOf(":");if($!==-1)F=D.host.slice(0,$),Z=D.host.slice($+1);else F=D.host}return{address:F,port:Z?parseInt(Z,10):void 0}}function q6D(D,F){let Z=F.firestore.app,$=Z.options,Q=(F.firestore.toJSON()||{}).settings||{},X={[v8.ATTR_DB_COLLECTION_NAME]:F.path,[v8.ATTR_DB_NAMESPACE]:Z.name,[v8.ATTR_DB_SYSTEM_NAME]:"firebase.firestore","firebase.firestore.type":F.type,"firebase.firestore.options.projectId":$.projectId,"firebase.firestore.options.appId":$.appId,"firebase.firestore.options.messagingSenderId":$.messagingSenderId,"firebase.firestore.options.storageBucket":$.storageBucket},{address:Y,port:W}=j6D(Q);if(Y)X[v8.ATTR_SERVER_ADDRESS]=Y;if(W)X[v8.ATTR_SERVER_PORT]=W;D.setAttributes(X)}var M1=N(M(),1),Z6=N(i(),1);function w50(D,F,Z,$,J){let Q=()=>{},X=()=>{},Y=J.functions?.errorHook,W=J.functions?.requestHook,z=J.functions?.responseHook;if(typeof z==="function")X=(G,H)=>{Z6.safeExecuteInTheMiddle(()=>z(G,H),(V)=>{if(!V)return;M1.diag.error(V?.message)},!0)};if(typeof W==="function")Q=(G)=>{Z6.safeExecuteInTheMiddle(()=>W(G),(H)=>{if(!H)return;M1.diag.error(H?.message)},!0)};let B=new Z6.InstrumentationNodeModuleDefinition("firebase-functions",F);return[{name:"firebase-functions/lib/v2/providers/https.js",triggerType:"function"},{name:"firebase-functions/lib/v2/providers/firestore.js",triggerType:"firestore"},{name:"firebase-functions/lib/v2/providers/scheduler.js",triggerType:"scheduler"},{name:"firebase-functions/lib/v2/storage.js",triggerType:"storage"}].forEach(({name:G,triggerType:H})=>{B.files.push(new Z6.InstrumentationNodeModuleFile(G,F,(V)=>C6D(V,Z,$,D,{requestHook:Q,responseHook:X,errorHook:Y},H),(V)=>U50(V,$)))}),B}function _D(D,F,Z){return function(J){return function(...Q){let X=typeof Q[0]==="function"?Q[0]:Q[1],Y=typeof Q[0]==="function"?void 0:Q[0];if(!X)return J.call(this,...Q);let W=async function(...z){let B=process.env.FUNCTION_TARGET||process.env.K_SERVICE||"unknown",K=D.startSpan(`firebase.function.${Z}`,{kind:M1.SpanKind.SERVER}),G={"faas.name":B,"faas.trigger":Z,"faas.provider":"firebase"};if(process.env.GCLOUD_PROJECT)G["cloud.project_id"]=process.env.GCLOUD_PROJECT;if(process.env.EVENTARC_CLOUD_EVENT_SOURCE)G["cloud.event_source"]=process.env.EVENTARC_CLOUD_EVENT_SOURCE;return K.setAttributes(G),F?.requestHook?.(K),M1.context.with(M1.trace.setSpan(M1.context.active(),K),async()=>{let H,V;try{V=await X.apply(this,z)}catch(U){H=U}if(F?.responseHook?.(K,H),H)K.recordException(H);if(K.end(),H)throw await F?.errorHook?.(K,H),H;return V})};if(Y)return J.call(this,Y,W);else return J.call(this,W)}}}function C6D(D,F,Z,$,J,Q){switch(U50(D,Z),Q){case"function":F(D,"onRequest",_D($,J,"http.request")),F(D,"onCall",_D($,J,"http.call"));break;case"firestore":F(D,"onDocumentCreated",_D($,J,"firestore.document.created")),F(D,"onDocumentUpdated",_D($,J,"firestore.document.updated")),F(D,"onDocumentDeleted",_D($,J,"firestore.document.deleted")),F(D,"onDocumentWritten",_D($,J,"firestore.document.written")),F(D,"onDocumentCreatedWithAuthContext",_D($,J,"firestore.document.created")),F(D,"onDocumentUpdatedWithAuthContext",_D($,J,"firestore.document.updated")),F(D,"onDocumentDeletedWithAuthContext",_D($,J,"firestore.document.deleted")),F(D,"onDocumentWrittenWithAuthContext",_D($,J,"firestore.document.written"));break;case"scheduler":F(D,"onSchedule",_D($,J,"scheduler.scheduled"));break;case"storage":F(D,"onObjectFinalized",_D($,J,"storage.object.finalized")),F(D,"onObjectArchived",_D($,J,"storage.object.archived")),F(D,"onObjectDeleted",_D($,J,"storage.object.deleted")),F(D,"onObjectMetadataUpdated",_D($,J,"storage.object.metadataUpdated"));break}return D}function U50(D,F){let Z=["onSchedule","onRequest","onCall","onObjectFinalized","onObjectArchived","onObjectDeleted","onObjectMetadataUpdated","onDocumentCreated","onDocumentUpdated","onDocumentDeleted","onDocumentWritten","onDocumentCreatedWithAuthContext","onDocumentUpdatedWithAuthContext","onDocumentDeletedWithAuthContext","onDocumentWrittenWithAuthContext"];for(let $ of Z)if(Z6.isWrapped(D[$]))F(D,$);return D}var j50={},O6D=[">=3.0.0 <5"],L6D=[">=6.0.0 <7"];class uV extends q50.InstrumentationBase{constructor(D=j50){super("@sentry/instrumentation-firebase",D0,D)}setConfig(D={}){super.setConfig({...j50,...D})}init(){let D=[];return D.push(H50(this.tracer,O6D,this._wrap,this._unwrap,this.getConfig())),D.push(w50(this.tracer,L6D,this._wrap,this._unwrap,this.getConfig())),D}}var C50="Firebase",P6D={firestoreSpanCreationHook:(D)=>{W0(D,"auto.firebase.otel.firestore"),D.setAttribute(c,"db.query")},functions:{requestHook:(D)=>{W0(D,"auto.firebase.otel.functions"),D.setAttribute(c,"http.request")},errorHook:async(D,F)=>{if(F)p(F,{mechanism:{type:"auto.firebase.otel.functions",handled:!1}}),await p9(2000)}}},O50=_(C50,()=>new uV(P6D)),M6D=()=>{return{name:C50,setupOnce(){O50()}}},L50=A(M6D);function P50(){return[fu(),qc(),Yl(),p90(),wp(),xp(),Qi(),S80(),v10(),U60(),j90(),m90(),q30(),m30(),z40(),P40(),_l(),o40(),ol(),Y50(),K50(),t40(),D50(),Z50(),Q50(),O60(),L50()]}var d3=N(M(),1),mQ=N(mK(),1),M50=N(eK(),1),m3=N(F0(),1);var dV=1e6;function A50(D,F={}){if(D.getOptions().debug)jB();let[Z,$]=A6D(D,F);D.traceProvider=Z,D.asyncLocalStorageLookup=$}function A6D(D,F={}){let Z=new M50.BasicTracerProvider({sampler:new wB(D),resource:mQ.defaultResource().merge(mQ.resourceFromAttributes({[m3.ATTR_SERVICE_NAME]:"node",[m3.SEMRESATTRS_SERVICE_NAMESPACE]:"sentry",[m3.ATTR_SERVICE_VERSION]:D0})),forceFlushTimeoutMillis:500,spanProcessors:[new VB({timeout:R6D(D.getOptions().maxSpanWaitDuration)}),...F.spanProcessors||[]]});d3.trace.setGlobalTracerProvider(Z),d3.propagation.setGlobalPropagator(new HB);let $=new UB;return d3.context.setGlobalContextManager($),[Z,$.getAsyncLocalStorageLookup()]}function R6D(D){if(D==null)return;if(D>dV)return i0&&q.warn(`\`maxSpanWaitDuration\` is too high, using the maximum value of ${dV}`),dV;else if(D<=0||Number.isNaN(D)){i0&&q.warn("`maxSpanWaitDuration` must be a positive number, using default value instead.");return}return D}function R50(){return qJ().filter((F)=>F.name!=="Http"&&F.name!=="NodeFetch").concat(ng(),Xu())}function k50(D){return[...R50(),..._0(D)?P50():[]]}function mV(D={}){return k6D(D,k50)}function k6D(D={},F){E7(D,"node");let Z=TB({...D,defaultIntegrations:D.defaultIntegrations??F(D)});if(Z&&!D.skipOpenTelemetrySetup)A50(Z,{spanProcessors:D.openTelemetrySpanProcessors}),EB();return Z}var I50=!1;function N50(){if(I50)return;let D=process.env.SENTRY_DSN;if(!D)return;try{mV({dsn:D,environment:"development",release:"workthin-cli@1.0.2",beforeSend(F){return F}}),I50=!0}catch{}}function K8(D){try{p(D)}catch{}}async function T50(){try{await p9(2000)}catch{}}import{execFileSync as cV,spawn as E50}from"node:child_process";import{existsSync as yF,mkdirSync as pV,readFileSync as iV,writeFileSync as fF}from"node:fs";import{homedir as c3,platform as cQ}from"node:os";import{join as O0}from"node:path";var $6=(D)=>`${D}/api/mcp`;function f50(D){let F=O0(D,"..");if(!yF(F))pV(F,{recursive:!0})}function lQ(D,F,Z){let $={};if(yF(D))$=JSON.parse(iV(D,"utf-8"));let J=$[Z]??{};J.workthin=F,$[Z]=J,f50(D),fF(D,JSON.stringify($,null,2),"utf-8")}function lV(D,F){return{url:$6(F),headers:{Authorization:`Bearer ${D}`}}}var a0={chatgpt:{label:"ChatGPT",setup:(D,F)=>{let Z=`${F}/docs/mcp/integrations/chatgpt`;try{let $,J;if(cQ()==="win32")$="cmd",J=["/c","start",'""',Z];else if(cQ()==="linux")$="xdg-open",J=[Z];else $="open",J=[Z];E50($,J,{detached:!0,stdio:"ignore"}).unref()}catch{}r.info(`Setup guide: ${y.cyan(Z)}`)},note:"In ChatGPT, go to Settings > Connectors > Add connector and enter the workthin MCP URL. Requires Plus, Pro, or Team plan."},"claude-code":{label:"Claude Code",setup:(D,F)=>{let Z=$6(F);cV("claude",["mcp","add","-t","http","-s","user","workthin",Z],{stdio:"pipe"})}},"claude-desktop":{label:"Claude Desktop",setup:(D,F)=>{let Z=`${F}/docs/mcp/integrations/claude-desktop`;try{let $,J;if(cQ()==="win32")$="cmd",J=["/c","start",'""',Z];else if(cQ()==="linux")$="xdg-open",J=[Z];else $="open",J=[Z];E50($,J,{detached:!0,stdio:"ignore"}).unref()}catch{}r.info(`Setup guide: ${y.cyan(Z)}`)},note:"In Claude Desktop, go to Settings > Connectors > Add custom connector and enter the workthin MCP URL."},cursor:{label:"Cursor",setup:(D,F)=>{lQ(O0(c3(),".cursor","mcp.json"),lV(D,F),"mcpServers")}},"gemini-cli":{label:"Gemini CLI",setup:(D,F)=>{let Z=$6(F);try{cV("gemini",["mcp","add","-t","http","workthin",Z,"-H",`Authorization: Bearer ${D}`],{stdio:"pipe"})}catch{let $=O0(c3(),".gemini","settings.json");lQ($,{httpUrl:$6(F),headers:{Authorization:`Bearer ${D}`}},"mcpServers")}}},"codex-cli":{label:"OpenAI Codex CLI",setup:(D,F)=>{let Z=$6(F);try{cV("codex",["mcp","add","workthin","--","curl",Z],{stdio:"pipe"})}catch{let $=O0(c3(),".codex","config.toml"),J=`
|
|
127
127
|
[mcp_servers.workthin]
|
|
128
128
|
url = "${Z}"
|
|
129
129
|
`;if(yF($)){let Q=iV($,"utf-8");if(!Q.includes("[mcp_servers.workthin]"))fF($,Q+J,"utf-8")}else f50($),fF($,J,"utf-8")}}},"copilot-cli":{label:"GitHub Copilot CLI",setup:(D,F)=>{let Z=O0(c3(),".github","copilot","mcp.json");lQ(Z,{type:"http",...lV(D,F)},"servers")}},vscode:{label:"VS Code",setup:(D,F,Z)=>{let $=O0(Z,".vscode","mcp.json");lQ($,{type:"http",...lV(D,F)},"servers")}}},hF=["# workthin — Capture Knowledge","","Review the current conversation and create a workthin knowledge entry.","","## Steps","","1. **Identify** the key problem(s) solved in this session","2. **Check** if similar knowledge already exists (`check-knowledge`)","3. **Create** a new knowledge entry with:"," - Clear, problem-focused title"," - Body describing: problem, environment, attempts, and solution"," - Omit scope (let workthin suggest via `suggested_scope`)"," - If `suggested_scope` differs from saved scope, ask user to confirm and update","4. If multiple problems were solved, create **separate entries** (one problem per entry)","5. Chain related entries using `prev_knowledge_id`"].join(`
|
|
@@ -286,8 +286,8 @@ ${U}
|
|
|
286
286
|
`);else for(let z of W.data){let B=z.relevance?`${Math.round(z.relevance*100)}%`:"";process.stdout.write(`${R1(z)} ${B?iD(`(${B} match)`):""}
|
|
287
287
|
|
|
288
288
|
`)}}catch(Q){if($)process.exit(0);J?.fail(Q.message),process.exit(1)}})}function ZF0(D){D.command("update <id>","Update a knowledge entry").option("--title <title>","New title").option("--body <body>","New body (will be re-structured and re-protected)").option("--scope <scope>","New scope: personal, project, global").option("--add-tags <tags>","Tags to add (comma-separated)").option("--remove-tags <tags>","Tags to remove (comma-separated)").option("--etag <etag>","ETag for concurrency check (required)").option("--json","Output as JSON").action(async(F,Z)=>{let $=Z.etag;if(!$)process.stderr.write("Error: --etag is required. Get it from `wt get <id> --json`.\n"),process.exit(1);let J={etag:$};if(Z.title)J.title=Z.title;if(Z.body)J.body=Z.body;if(Z.scope)J.scope=Z.scope==="open"?"global":Z.scope;if(Z.addTags)J.add_tags=Z.addTags.split(",").map((X)=>X.trim());if(Z.removeTags)J.remove_tags=Z.removeTags.split(",").map((X)=>X.trim());let Q=v0("Updating knowledge...").start();try{let X=await G0(`/knowledge/${F}`,{method:"PATCH",body:JSON.stringify(J)});if(Q.stop(),Z.json)JD(X.data);else process.stdout.write(`${d0("Updated!")} ${R1(X.data)}
|
|
289
|
-
`)}catch(X){Q.fail(X.message),process.exit(1)}})}import{existsSync as D7D,readFileSync as F7D,writeFileSync as Z7D}from"node:fs";import{homedir as $7D}from"node:os";import{join as J7D}from"node:path";var Q7D=86400000,aV=J7D($7D(),".workthin","update-check.json"),oV="1.0.
|
|
289
|
+
`)}catch(X){Q.fail(X.message),process.exit(1)}})}import{existsSync as D7D,readFileSync as F7D,writeFileSync as Z7D}from"node:fs";import{homedir as $7D}from"node:os";import{join as J7D}from"node:path";var Q7D=86400000,aV=J7D($7D(),".workthin","update-check.json"),oV="1.0.2";function X7D(){try{if(!D7D(aV))return null;return JSON.parse(F7D(aV,"utf-8"))}catch{return null}}function Y7D(D){try{Z7D(aV,JSON.stringify(D),"utf-8")}catch{}}async function W7D(){try{let D=new AbortController,F=setTimeout(()=>D.abort(),3000),Z=await fetch("https://registry.npmjs.org/workthin/latest",{signal:D.signal});if(clearTimeout(F),!Z.ok)return null;return(await Z.json()).version??null}catch{return null}}async function JF0(){let D=X7D();if(D&&Date.now()-D.lastCheck<Q7D){if(D.latestVersion&&D.latestVersion!==oV)$F0(D.latestVersion);return}W7D().then((F)=>{if(Y7D({lastCheck:Date.now(),latestVersion:F}),F&&F!==oV)$F0(F)})}function $F0(D){process.stderr.write(`
|
|
290
290
|
${y.yellow("Update available!")} ${y.dim(oV)} → ${y.green(D)}
|
|
291
291
|
Run ${y.cyan("npm install -g workthin@latest")} to update
|
|
292
292
|
|
|
293
|
-
`)}N50();var QD=$w("wt");d50(QD);m50(QD);ZF0(QD);r50(QD);FF0(QD);S50(QD);DF0(QD);b50(QD);t50(QD);_50(QD);e50(QD);s50(QD);y50(QD);p50(QD);v50(QD);QD.help();QD.version("1.0.
|
|
293
|
+
`)}N50();var QD=$w("wt");d50(QD);m50(QD);ZF0(QD);r50(QD);FF0(QD);S50(QD);DF0(QD);b50(QD);t50(QD);_50(QD);e50(QD);s50(QD);y50(QD);p50(QD);v50(QD);QD.help();QD.version("1.0.2");JF0();var WF0=process.argv[2],z7D=new Set(["init","add","hooks","login","logout","config","--help","-h","--version","-v"]);if(WF0&&!z7D.has(WF0)){let D=process.cwd(),F=c0(),Z=F.init_hint_shown_dirs??[];if(!Z.includes(D)){let $=YF0(D,"AGENTS.md"),J=YF0(D,"CLAUDE.md");if(!(QF0($)&&XF0($,"utf-8").includes("======== workthin ========")||QF0(J)&&XF0(J,"utf-8").includes("======== workthin ========")))console.error(y.dim(" Tip: Run `wt init` to set up workthin for this project.")),Z.push(D),s0({...F,init_hint_shown_dirs:Z})}}try{QD.parse()}catch(D){throw K8(D),await T50(),D}
|