@sentry/cloudflare 10.68.0 → 10.70.0

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.
Files changed (177) hide show
  1. package/build/cjs/client.js +5 -0
  2. package/build/cjs/client.js.map +1 -1
  3. package/build/cjs/durableobject.js +210 -97
  4. package/build/cjs/durableobject.js.map +1 -1
  5. package/build/cjs/flush.js.map +1 -1
  6. package/build/cjs/index.js +3 -0
  7. package/build/cjs/index.js.map +1 -1
  8. package/build/cjs/instrumentations/agents/index.js +16 -0
  9. package/build/cjs/instrumentations/agents/index.js.map +1 -0
  10. package/build/cjs/instrumentations/agents/instrumentAgentCallableRpc.js +52 -0
  11. package/build/cjs/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  12. package/build/cjs/instrumentations/agents/instrumentAgentRequestConversation.js +19 -0
  13. package/build/cjs/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  14. package/build/cjs/instrumentations/agents/instrumentChatAgentConversation.js +31 -0
  15. package/build/cjs/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  16. package/build/cjs/instrumentations/agents/types.js +77 -0
  17. package/build/cjs/instrumentations/agents/types.js.map +1 -0
  18. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js +6 -0
  19. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  20. package/build/cjs/instrumentations/instrumentSqlStorage.js +1 -1
  21. package/build/cjs/instrumentations/instrumentSqlStorage.js.map +1 -1
  22. package/build/cjs/integrations/spotlight.js +64 -0
  23. package/build/cjs/integrations/spotlight.js.map +1 -0
  24. package/build/cjs/nodejs_compat/index.js +5 -2
  25. package/build/cjs/nodejs_compat/index.js.map +1 -1
  26. package/build/cjs/options.js +14 -1
  27. package/build/cjs/options.js.map +1 -1
  28. package/build/cjs/request.js +3 -2
  29. package/build/cjs/request.js.map +1 -1
  30. package/build/cjs/sdk.js +8 -0
  31. package/build/cjs/sdk.js.map +1 -1
  32. package/build/cjs/utils/internalSqlQuery.js +13 -7
  33. package/build/cjs/utils/internalSqlQuery.js.map +1 -1
  34. package/build/cjs/utils/internalStorageKey.js +44 -0
  35. package/build/cjs/utils/internalStorageKey.js.map +1 -0
  36. package/build/cjs/utils/invocationScope.js +12 -0
  37. package/build/cjs/utils/invocationScope.js.map +1 -0
  38. package/build/cjs/utils/rpcMeta.js +4 -0
  39. package/build/cjs/utils/rpcMeta.js.map +1 -1
  40. package/build/cjs/vite/agentClass.js +114 -0
  41. package/build/cjs/vite/agentClass.js.map +1 -0
  42. package/build/cjs/vite/autoInstrument.js +17 -4
  43. package/build/cjs/vite/autoInstrument.js.map +1 -1
  44. package/build/cjs/vite/index.js +1 -1
  45. package/build/cjs/vite/index.js.map +1 -1
  46. package/build/cjs/vite/moduleShape.js +231 -0
  47. package/build/cjs/vite/moduleShape.js.map +1 -0
  48. package/build/cjs/vite/transform.js +6 -1
  49. package/build/cjs/vite/transform.js.map +1 -1
  50. package/build/cjs/vite/wranglerConfig.js +1 -1
  51. package/build/cjs/vite/wranglerConfig.js.map +1 -1
  52. package/build/cjs/workflows.js +1 -1
  53. package/build/cjs/workflows.js.map +1 -1
  54. package/build/cjs/wrapMethodWithSentry.js +2 -3
  55. package/build/cjs/wrapMethodWithSentry.js.map +1 -1
  56. package/build/esm/client.js +6 -1
  57. package/build/esm/client.js.map +1 -1
  58. package/build/esm/durableobject.js +211 -101
  59. package/build/esm/durableobject.js.map +1 -1
  60. package/build/esm/flush.js.map +1 -1
  61. package/build/esm/index.js +2 -1
  62. package/build/esm/index.js.map +1 -1
  63. package/build/esm/instrumentations/agents/index.js +14 -0
  64. package/build/esm/instrumentations/agents/index.js.map +1 -0
  65. package/build/esm/instrumentations/agents/instrumentAgentCallableRpc.js +50 -0
  66. package/build/esm/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  67. package/build/esm/instrumentations/agents/instrumentAgentRequestConversation.js +17 -0
  68. package/build/esm/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  69. package/build/esm/instrumentations/agents/instrumentChatAgentConversation.js +29 -0
  70. package/build/esm/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  71. package/build/esm/instrumentations/agents/types.js +69 -0
  72. package/build/esm/instrumentations/agents/types.js.map +1 -0
  73. package/build/esm/instrumentations/instrumentDurableObjectStorage.js +7 -1
  74. package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  75. package/build/esm/instrumentations/instrumentSqlStorage.js +1 -1
  76. package/build/esm/instrumentations/instrumentSqlStorage.js.map +1 -1
  77. package/build/esm/integrations/spotlight.js +61 -0
  78. package/build/esm/integrations/spotlight.js.map +1 -0
  79. package/build/esm/nodejs_compat/index.js +2 -1
  80. package/build/esm/nodejs_compat/index.js.map +1 -1
  81. package/build/esm/options.js +14 -1
  82. package/build/esm/options.js.map +1 -1
  83. package/build/esm/package.json +1 -1
  84. package/build/esm/request.js +4 -3
  85. package/build/esm/request.js.map +1 -1
  86. package/build/esm/sdk.js +8 -0
  87. package/build/esm/sdk.js.map +1 -1
  88. package/build/esm/utils/internalSqlQuery.js +13 -7
  89. package/build/esm/utils/internalSqlQuery.js.map +1 -1
  90. package/build/esm/utils/internalStorageKey.js +41 -0
  91. package/build/esm/utils/internalStorageKey.js.map +1 -0
  92. package/build/esm/utils/invocationScope.js +10 -0
  93. package/build/esm/utils/invocationScope.js.map +1 -0
  94. package/build/esm/utils/rpcMeta.js +4 -1
  95. package/build/esm/utils/rpcMeta.js.map +1 -1
  96. package/build/esm/utils/traceLinks.js +1 -1
  97. package/build/esm/vite/agentClass.js +111 -0
  98. package/build/esm/vite/agentClass.js.map +1 -0
  99. package/build/esm/vite/autoInstrument.js +17 -4
  100. package/build/esm/vite/autoInstrument.js.map +1 -1
  101. package/build/esm/vite/index.js +1 -1
  102. package/build/esm/vite/index.js.map +1 -1
  103. package/build/esm/vite/moduleShape.js +227 -0
  104. package/build/esm/vite/moduleShape.js.map +1 -0
  105. package/build/esm/vite/transform.js +6 -1
  106. package/build/esm/vite/transform.js.map +1 -1
  107. package/build/esm/vite/wranglerConfig.js +1 -1
  108. package/build/esm/vite/wranglerConfig.js.map +1 -1
  109. package/build/esm/workflows.js +2 -2
  110. package/build/esm/workflows.js.map +1 -1
  111. package/build/esm/wrapMethodWithSentry.js +3 -4
  112. package/build/esm/wrapMethodWithSentry.js.map +1 -1
  113. package/build/types/client.d.ts +37 -0
  114. package/build/types/client.d.ts.map +1 -1
  115. package/build/types/durableobject.d.ts +90 -0
  116. package/build/types/durableobject.d.ts.map +1 -1
  117. package/build/types/flush.d.ts +1 -1
  118. package/build/types/flush.d.ts.map +1 -1
  119. package/build/types/index.d.ts +2 -1
  120. package/build/types/index.d.ts.map +1 -1
  121. package/build/types/instrumentations/agents/index.d.ts +25 -0
  122. package/build/types/instrumentations/agents/index.d.ts.map +1 -0
  123. package/build/types/instrumentations/agents/instrumentAgentCallableRpc.d.ts +14 -0
  124. package/build/types/instrumentations/agents/instrumentAgentCallableRpc.d.ts.map +1 -0
  125. package/build/types/instrumentations/agents/instrumentAgentRequestConversation.d.ts +16 -0
  126. package/build/types/instrumentations/agents/instrumentAgentRequestConversation.d.ts.map +1 -0
  127. package/build/types/instrumentations/agents/instrumentChatAgentConversation.d.ts +23 -0
  128. package/build/types/instrumentations/agents/instrumentChatAgentConversation.d.ts.map +1 -0
  129. package/build/types/instrumentations/agents/types.d.ts +94 -0
  130. package/build/types/instrumentations/agents/types.d.ts.map +1 -0
  131. package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -1
  132. package/build/types/integrations/spotlight.d.ts +22 -0
  133. package/build/types/integrations/spotlight.d.ts.map +1 -0
  134. package/build/types/options.d.ts.map +1 -1
  135. package/build/types/request.d.ts.map +1 -1
  136. package/build/types/sdk.d.ts.map +1 -1
  137. package/build/types/utils/internalSqlQuery.d.ts +4 -2
  138. package/build/types/utils/internalSqlQuery.d.ts.map +1 -1
  139. package/build/types/utils/internalStorageKey.d.ts +22 -0
  140. package/build/types/utils/internalStorageKey.d.ts.map +1 -0
  141. package/build/types/utils/invocationScope.d.ts +24 -0
  142. package/build/types/utils/invocationScope.d.ts.map +1 -0
  143. package/build/types/utils/rpcMeta.d.ts +8 -0
  144. package/build/types/utils/rpcMeta.d.ts.map +1 -1
  145. package/build/types/vite/agentClass.d.ts +41 -0
  146. package/build/types/vite/agentClass.d.ts.map +1 -0
  147. package/build/types/vite/autoInstrument.d.ts +7 -6
  148. package/build/types/vite/autoInstrument.d.ts.map +1 -1
  149. package/build/types/vite/index.d.ts +14 -4
  150. package/build/types/vite/index.d.ts.map +1 -1
  151. package/build/types/vite/moduleShape.d.ts +52 -0
  152. package/build/types/vite/moduleShape.d.ts.map +1 -0
  153. package/build/types/vite/transform.d.ts +6 -1
  154. package/build/types/vite/transform.d.ts.map +1 -1
  155. package/build/types/wrapMethodWithSentry.d.ts +1 -1
  156. package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
  157. package/build/types-ts3.8/client.d.ts +37 -0
  158. package/build/types-ts3.8/durableobject.d.ts +90 -0
  159. package/build/types-ts3.8/flush.d.ts +1 -1
  160. package/build/types-ts3.8/index.d.ts +2 -1
  161. package/build/types-ts3.8/instrumentations/agents/index.d.ts +25 -0
  162. package/build/types-ts3.8/instrumentations/agents/instrumentAgentCallableRpc.d.ts +14 -0
  163. package/build/types-ts3.8/instrumentations/agents/instrumentAgentRequestConversation.d.ts +16 -0
  164. package/build/types-ts3.8/instrumentations/agents/instrumentChatAgentConversation.d.ts +23 -0
  165. package/build/types-ts3.8/instrumentations/agents/types.d.ts +94 -0
  166. package/build/types-ts3.8/integrations/spotlight.d.ts +22 -0
  167. package/build/types-ts3.8/utils/internalSqlQuery.d.ts +4 -2
  168. package/build/types-ts3.8/utils/internalStorageKey.d.ts +22 -0
  169. package/build/types-ts3.8/utils/invocationScope.d.ts +24 -0
  170. package/build/types-ts3.8/utils/rpcMeta.d.ts +8 -0
  171. package/build/types-ts3.8/vite/agentClass.d.ts +41 -0
  172. package/build/types-ts3.8/vite/autoInstrument.d.ts +7 -6
  173. package/build/types-ts3.8/vite/index.d.ts +14 -4
  174. package/build/types-ts3.8/vite/moduleShape.d.ts +52 -0
  175. package/build/types-ts3.8/vite/transform.d.ts +6 -1
  176. package/build/types-ts3.8/wrapMethodWithSentry.d.ts +1 -1
  177. package/package.json +3 -3
@@ -0,0 +1,24 @@
1
+ import { type Scope } from '@sentry/core';
2
+ /**
3
+ * Runs `callback` on the isolation scope for the current invocation.
4
+ *
5
+ * An instrumented handler is either the entry point of an invocation or reentrant — reached from
6
+ * another instrumented handler already serving the same invocation (a Durable Object method calling
7
+ * its own `fetch`, an RPC method reaching a sibling method). Only the entry point may fork:
8
+ *
9
+ * - Forking at the entry point is mandatory. `setUser`/`setTag` write to the isolation scope, and a
10
+ * Durable Object's isolation scope outlives the invocation that touched it, so without a fork one
11
+ * invocation's user and tags reappear on the next invocation's events in the same isolate.
12
+ * Forking clones, so request data set by an enclosing wrapper is still inherited.
13
+ * - Forking again when reentrant would be wrong. Everything below the entry point is one logical
14
+ * unit of work: a nested call must see what the caller set and be able to add to it, the way it
15
+ * would if the SDK were not wrapping it at all.
16
+ *
17
+ * The AsyncLocalStorage strategy hands the default isolation scope back whenever no invocation is in
18
+ * flight, and a forked one while inside `withIsolationScope`. Reference-comparing against the default
19
+ * is therefore enough to tell the two cases apart. The stack fallback does not fork, so it reports the
20
+ * default scope even inside an invocation; there the fork degrades to a no-op, which the stack strategy
21
+ * tolerates. This matches the approach used by `patchEventHandler` in Nuxt.
22
+ */
23
+ export declare function withInvocationIsolationScope<T>(callback: (scope: Scope) => T): T;
24
+ //# sourceMappingURL=invocationScope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invocationScope.d.ts","sourceRoot":"","sources":["../../../src/utils/invocationScope.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,KAAK,KAAK,EAAsB,MAAM,cAAc,CAAC;AAE3G;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,CAAC,GAAG,CAAC,CAMhF"}
@@ -4,6 +4,14 @@ import { type SerializedTraceData } from '@sentry/core';
4
4
  * If no active trace exists, returns the original args unchanged.
5
5
  */
6
6
  export declare function appendRpcMeta(args: unknown[]): unknown[];
7
+ /**
8
+ * Whether the trailing argument carries Sentry RPC metadata.
9
+ *
10
+ * Separate from {@link extractRpcMeta} because the RPC method wrappers run this check on every
11
+ * call — including the instance's own internal method calls, which never carry metadata — and
12
+ * must not allocate on that path.
13
+ */
14
+ export declare function hasRpcMeta(args: unknown[]): boolean;
7
15
  /**
8
16
  * Extracts Sentry RPC metadata from the trailing argument of an args array.
9
17
  * Returns cleaned args (without meta) and the extracted trace data if found.
@@ -1 +1 @@
1
- {"version":3,"file":"rpcMeta.d.ts","sourceRoot":"","sources":["../../../src/utils/rpcMeta.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAoBpF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAQxD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,OAAO,EAAE,EAChD,IAAI,EAAE,CAAC,GACN;IACD,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B,CAcA"}
1
+ {"version":3,"file":"rpcMeta.d.ts","sourceRoot":"","sources":["../../../src/utils/rpcMeta.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAoBpF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAQxD;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAEnD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,OAAO,EAAE,EAChD,IAAI,EAAE,CAAC,GACN;IACD,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B,CAcA"}
@@ -0,0 +1,41 @@
1
+ import type { ProgramBody } from './transform';
2
+ /**
3
+ * The subset of the Vite/Rollup plugin context needed to walk the module graph.
4
+ *
5
+ * `resolve` is optional: without it detection still works, but only for base-class chains declared
6
+ * inside the entry module itself. `readFile` is injectable for tests and defaults to reading disk.
7
+ *
8
+ * Deliberately **no `load`**: awaiting the plugin context's `load()` from inside a `transform` hook
9
+ * deadlocks the build — the module cannot finish loading while its own transform is still pending
10
+ * (Rollup documents this hazard, and Vite's Rolldown pipeline is stricter still). Sibling modules
11
+ * are therefore read straight off disk; see {@link getModuleShape}.
12
+ */
13
+ export interface ModuleResolver {
14
+ parse(code: string): ProgramBody;
15
+ resolve?(source: string, importer: string): Promise<{
16
+ id: string;
17
+ } | null | undefined>;
18
+ readFile?(id: string): string | undefined;
19
+ }
20
+ /**
21
+ * Find which of `candidates` (top-level class names in the entry module) are Cloudflare
22
+ * [`agents`](https://www.npmjs.com/package/agents) Agents.
23
+ *
24
+ * An Agent is a Durable Object under the hood, so wrangler configures it as one and the transform
25
+ * would otherwise reach for `instrumentDurableObjectWithSentry`. Detecting the Agent base chain lets
26
+ * it pick `instrumentAgentWithSentry` instead, which adds the Agent-specific telemetry on top.
27
+ *
28
+ * Unlike `WorkerEntrypoint` detection, the chain is followed *across* modules: base classes commonly
29
+ * live in their own file (`import { MyBase } from './base'`), and there is no runtime fallback that
30
+ * would catch a missed one. Resolution stops at package boundaries — a base class imported from
31
+ * `node_modules` is only recognized when it is one of {@link AGENT_BASE_CLASSES}.
32
+ */
33
+ export declare function detectAgentClasses(ast: ProgramBody, entryId: string, candidates: Iterable<string>, resolver: ModuleResolver): Promise<Set<string>>;
34
+ /**
35
+ * The local class names in the entry that a configured class name could refer to — either declared
36
+ * under that name directly, or aliased to it by an `export { Local as Configured }` specifier.
37
+ *
38
+ * Keeps detection (which reads and scans other modules) off classes that no binding points at.
39
+ */
40
+ export declare function collectAgentCandidates(ast: ProgramBody, configuredNames: Iterable<string>): Set<string>;
41
+ //# sourceMappingURL=agentClass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentClass.d.ts","sourceRoot":"","sources":["../../../src/vite/agentClass.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAuB/C;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IACjC,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACvF,QAAQ,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC3C;AAOD;;;;;;;;;;;;GAYG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,EAC5B,QAAQ,EAAE,cAAc,GACvB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CActB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAevG"}
@@ -1,5 +1,7 @@
1
- import { type ProgramBody } from './transform';
2
- export declare function sentryCloudflareAutoInstrumentPlugin(): {
1
+ import { type ModuleResolver } from './agentClass';
2
+ export declare function sentryCloudflareAutoInstrumentPlugin(options?: {
3
+ wranglerConfigPath?: string;
4
+ }): {
3
5
  name: string;
4
6
  configResolved(config: {
5
7
  root: string;
@@ -7,15 +9,14 @@ export declare function sentryCloudflareAutoInstrumentPlugin(): {
7
9
  warn(msg: string): void;
8
10
  };
9
11
  }): void;
10
- transform(this: {
11
- parse(code: string): ProgramBody;
12
+ transform(this: ModuleResolver & {
12
13
  warn?(msg: string): void;
13
14
  environment?: {
14
15
  name?: string;
15
16
  };
16
- }, code: string, id: string): {
17
+ }, code: string, id: string): Promise<{
17
18
  code: string;
18
19
  map: unknown;
19
- } | undefined;
20
+ } | undefined>;
20
21
  };
21
22
  //# sourceMappingURL=autoInstrument.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"autoInstrument.d.ts","sourceRoot":"","sources":["../../../src/vite/autoInstrument.ts"],"names":[],"mappings":"AACA,OAAO,EAAwD,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAcrG,wBAAgB,oCAAoC;;2BAUzB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE;YAAE,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAA;KAAE,GAAG,IAAI;oBAyB5E;QAAE,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;QAAC,IAAI,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,WAAW,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,QAC/F,MAAM,MACR,MAAM,GACT;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS;EA6DhD"}
1
+ {"version":3,"file":"autoInstrument.d.ts","sourceRoot":"","sources":["../../../src/vite/autoInstrument.ts"],"names":[],"mappings":"AACA,OAAO,EAA8C,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAgB/F,wBAAgB,oCAAoC,CAAC,OAAO,GAAE;IAAE,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAO;;2BAUvE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE;YAAE,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAA;KAAE,GAAG,IAAI;oBAkC5E,cAAc,GAAG;QAAE,IAAI,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,WAAW,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,QAC9E,MAAM,MACR,MAAM,GACT,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC;EAiFzD"}
@@ -2,6 +2,17 @@
2
2
  * Options for {@link sentryCloudflareVitePlugin}.
3
3
  */
4
4
  export interface SentryCloudflareVitePluginOptions {
5
+ /**
6
+ * Path to the wrangler config, relative to the Vite root (or absolute).
7
+ * Set this when your config doesn't use a default name — e.g. when you
8
+ * pass `configPath: './wrangler.agent.jsonc'` to `@cloudflare/vite-plugin`,
9
+ * which the Sentry plugin cannot see. When set, only this file is read
10
+ * (no default-name probing), and a warning is emitted if it is missing or
11
+ * unparseable.
12
+ *
13
+ * @default undefined (probes `wrangler.json`, `wrangler.jsonc`, `wrangler.toml` at the Vite root)
14
+ */
15
+ wranglerConfigPath?: string;
5
16
  /**
6
17
  * Experimental options that may change or be removed without notice.
7
18
  */
@@ -74,15 +85,14 @@ export declare function sentryCloudflareVitePlugin(options?: SentryCloudflareVit
74
85
  warn(msg: string): void;
75
86
  };
76
87
  }): void;
77
- transform(this: {
78
- parse(code: string): import("./transform").ProgramBody;
88
+ transform(this: import("./agentClass").ModuleResolver & {
79
89
  warn?(msg: string): void;
80
90
  environment?: {
81
91
  name?: string;
82
92
  };
83
- }, code: string, id: string): {
93
+ }, code: string, id: string): Promise<{
84
94
  code: string;
85
95
  map: unknown;
86
- } | undefined;
96
+ } | undefined>;
87
97
  } | import("vite").Plugin<any>)[];
88
98
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD;;OAEG;IACH,aAAa,CAAC,EAAE;QACd;;;;;;;;;;;;;WAaG;QACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;QACzC;;;;;;;;;;WAUG;QACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;KAC/B,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,iCAAsC;;;;cAvDpC,CAAC;;;;;;YAoB7B,CAAA;mBAKf,CAAC;gBAAQ,CAAC;;;;;;kCAqCpB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD;;;;;;;;;OASG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,aAAa,CAAC,EAAE;QACd;;;;;;;;;;;;;WAaG;QACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;QACzC;;;;;;;;;;WAUG;QACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;KAC/B,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,iCAAsC;;;;cA5DlF,CAAC;;;;;YAiCgE,CAAC;mBAChD,CAAC;gBAAS,CAAA;;;;;;kCAmCnC"}
@@ -0,0 +1,52 @@
1
+ import type { ProgramBody } from './transform';
2
+ /** Binding name used for a module's default export. */
3
+ export declare const DEFAULT_EXPORT = "default";
4
+ /** A resolved superclass reference: a bare identifier or a `ns.Member` expression. */
5
+ export type SuperRef = {
6
+ kind: 'identifier';
7
+ name: string;
8
+ } | {
9
+ kind: 'member';
10
+ object: string;
11
+ property: string;
12
+ };
13
+ /** The declarations of a single module that binding resolution needs. */
14
+ export interface ModuleShape {
15
+ /** Top-level class names → their superclass reference (absent when the class has no `extends`). */
16
+ classes: Map<string, SuperRef | undefined>;
17
+ /** Local binding name → the import it came from (`imported` is `default` for a default import). */
18
+ imports: Map<string, {
19
+ source: string;
20
+ imported: string;
21
+ }>;
22
+ /** Local binding name → module specifier, for `import * as ns from '...'`. */
23
+ namespaces: Map<string, string>;
24
+ /** Exported name → the re-export it came from, for `export { x as y } from '...'`. */
25
+ reexports: Map<string, {
26
+ source: string;
27
+ imported: string;
28
+ }>;
29
+ /** Exported name → local binding name, for `export { x as y }` without a source. */
30
+ localExports: Map<string, string>;
31
+ /** Module specifiers of bare `export * from '...'` declarations. */
32
+ starExports: string[];
33
+ /** `export default <Identifier>` — the local name it refers to. */
34
+ defaultExportName?: string;
35
+ /** True when the module's default export is a class declaration/expression. */
36
+ defaultExportIsClass?: boolean;
37
+ /** Superclass of an anonymous `export default class extends X`. */
38
+ defaultExportSuper?: SuperRef;
39
+ }
40
+ /** Collect the shape of a module from its parsed AST — used for the already-parsed entry module. */
41
+ export declare function shapeFromAst(ast: ProgramBody): ModuleShape;
42
+ /**
43
+ * Extract the module shape from **unprocessed source**.
44
+ *
45
+ * Sibling modules are read straight from disk (the plugin context's `load()` would deadlock inside a
46
+ * transform hook), so they may still be TypeScript — which no JS parser will accept. Only
47
+ * import/export statements and `class X extends Y` headers matter here, and those are
48
+ * declaration-level syntax a scan can pick out reliably; class bodies, type annotations and generics
49
+ * are irrelevant and simply skipped.
50
+ */
51
+ export declare function shapeFromSource(rawCode: string): ModuleShape;
52
+ //# sourceMappingURL=moduleShape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moduleShape.d.ts","sourceRoot":"","sources":["../../../src/vite/moduleShape.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,aAAa,CAAC;AAoDzD,uDAAuD;AACvD,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC,sFAAsF;AACtF,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnH,yEAAyE;AACzE,MAAM,WAAW,WAAW;IAC1B,mGAAmG;IACnG,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC;IAC3C,mGAAmG;IACnG,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3D,8EAA8E;IAC9E,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,sFAAsF;IACtF,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7D,oFAAoF;IACpF,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,oEAAoE;IACpE,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,+EAA+E;IAC/E,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mEAAmE;IACnE,kBAAkB,CAAC,EAAE,QAAQ,CAAC;CAC/B;AAiBD,oGAAoG;AACpG,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,CAqC1D;AAiED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAgD5D"}
@@ -18,7 +18,7 @@ export interface ProgramBody {
18
18
  * config providing only a fallback for self-bound entrypoints whose base class
19
19
  * lives in another module.
20
20
  */
21
- export type ClassWrapperKind = 'durableObject' | 'workflow' | 'workerEntrypoint';
21
+ export type ClassWrapperKind = 'durableObject' | 'agent' | 'workflow' | 'workerEntrypoint';
22
22
  export interface TransformContext {
23
23
  /**
24
24
  * Exported class name → the kind of Sentry wrapper to apply. Populated from
@@ -26,6 +26,11 @@ export interface TransformContext {
26
26
  * each class's base type.
27
27
  */
28
28
  classWrappers: Map<string, ClassWrapperKind>;
29
+ /**
30
+ * Local class names detected as `agents` Agents. An Agent is configured as a Durable Object in
31
+ * wrangler, so this upgrades those entries from `durableObject` to `agent`.
32
+ */
33
+ agentClasses?: ReadonlySet<string>;
29
34
  optionsFn: string;
30
35
  /** Import statement prepended when `optionsFn` references a separate module. */
31
36
  optionsImport?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/vite/transform.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAC;AAOvC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,EAAE,CAAC;CAClB;AAuDD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,UAAU,GAAG,kBAAkB,CAAC;AAajF,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IAC5C;;;;OAIG;IACH,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,gBAAgB,GACpB,eAAe,GAAG,SAAS,CA6C7B"}
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/vite/transform.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAC;AAOvC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,EAAE,CAAC;CAClB;AAuDD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,OAAO,GAAG,UAAU,GAAG,kBAAkB,CAAC;AAc3F,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC7C;;;OAGG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IAC5C;;;;OAIG;IACH,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,gBAAgB,GACpB,eAAe,GAAG,SAAS,CA8C7B"}
@@ -1,7 +1,7 @@
1
1
  import type { DurableObjectStorage } from '@cloudflare/workers-types';
2
2
  import type { CloudflareOptions } from './client';
3
3
  /** Extended DurableObjectState with originalStorage exposed by instrumentContext */
4
- interface InstrumentedDurableObjectState extends DurableObjectState {
4
+ export interface InstrumentedDurableObjectState extends DurableObjectState {
5
5
  originalStorage?: DurableObjectStorage;
6
6
  }
7
7
  type MethodWrapperOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"wrapMethodWithSentry.d.ts","sourceRoot":"","sources":["../../src/wrapMethodWithSentry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAgBtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAQlD,oFAAoF;AACpF,UAAU,8BAA+B,SAAQ,kBAAkB;IACjE,eAAe,CAAC,EAAE,oBAAoB,CAAC;CACxC;AAyBD,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,gBAAgB,GAAG,8BAA8B,CAAC;IAC3D;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AACtD,KAAK,cAAc,GAAG,eAAe,CAAC;AAEtC;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,cAAc,EAC3D,cAAc,EAAE,oBAAoB,EACpC,OAAO,EAAE,CAAC,EACV,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,EAC3C,MAAM,CAAC,EAAE,IAAI,GACZ,CAAC,CA0JH"}
1
+ {"version":3,"file":"wrapMethodWithSentry.d.ts","sourceRoot":"","sources":["../../src/wrapMethodWithSentry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAatE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AASlD,oFAAoF;AACpF,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE,eAAe,CAAC,EAAE,oBAAoB,CAAC;CACxC;AAyBD,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,gBAAgB,GAAG,8BAA8B,CAAC;IAC3D;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AACtD,KAAK,cAAc,GAAG,eAAe,CAAC;AAEtC;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,cAAc,EAC3D,cAAc,EAAE,oBAAoB,EACpC,OAAO,EAAE,CAAC,EACV,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,EAC3C,MAAM,CAAC,EAAE,IAAI,GACZ,CAAC,CAqJH"}
@@ -41,6 +41,8 @@ export declare class CloudflareClient extends ServerRuntimeClient {
41
41
  * After calling dispose(), the client should not be used anymore.
42
42
  */
43
43
  dispose(): void;
44
+ /** @inheritDoc */
45
+ protected _setupIntegrations(): void;
44
46
  /**
45
47
  * Resets the span completion promise and resolve function.
46
48
  */
@@ -132,6 +134,30 @@ interface BaseCloudflareOptions {
132
134
  * ```
133
135
  */
134
136
  durableObjectSqlSpanAllowlist?: Array<string | RegExp>;
137
+ /**
138
+ * KV keys that should stay instrumented even though they match a reserved prefix used by Durable
139
+ * Object frameworks (`agents`, `partyserver`, ...) for their internal storage entries.
140
+ *
141
+ * By default, KV reads/writes (`get`, `put`, `delete`, `list`) of `cf_`- or `__ps_`-prefixed keys
142
+ * are treated as framework noise and no `durable_object_storage_*` span is created for them,
143
+ * mirroring how `cf_`-prefixed SQL tables are handled (see {@link durableObjectSqlSpanAllowlist}).
144
+ * If one of your own keys happens to use such a prefix, add it here to opt it back into
145
+ * instrumentation. Strings must match exactly, while regular expressions give you prefix/pattern
146
+ * matching.
147
+ *
148
+ * @default []
149
+ * @example
150
+ * ```ts
151
+ * export default Sentry.withSentry(
152
+ * (env) => ({
153
+ * dsn: env.SENTRY_DSN,
154
+ * durableObjectStorageSpanAllowlist: ['cf_my_key', /^cf_reports_/],
155
+ * }),
156
+ * handler,
157
+ * );
158
+ * ```
159
+ */
160
+ durableObjectStorageSpanAllowlist?: Array<string | RegExp>;
135
161
  /**
136
162
  * @deprecated Use `enableRpcTracePropagation` instead. This option will be removed in a future major version.
137
163
  *
@@ -145,6 +171,17 @@ interface BaseCloudflareOptions {
145
171
  * @default false
146
172
  */
147
173
  instrumentPrototypeMethods?: boolean | string[];
174
+ /**
175
+ * If you use Spotlight by Sentry during development, use
176
+ * this option to forward captured Sentry events to Spotlight.
177
+ *
178
+ * Either set it to true, or provide a specific Spotlight Sidecar URL.
179
+ *
180
+ * More details: https://spotlightjs.com/
181
+ *
182
+ * IMPORTANT: Only set this option to `true` while developing, not in production!
183
+ */
184
+ spotlight?: boolean | string;
148
185
  }
149
186
  /**
150
187
  * Configuration options for the Sentry Cloudflare SDK
@@ -1,5 +1,53 @@
1
1
  import { DurableObject } from 'cloudflare:workers';
2
2
  import { CloudflareOptions } from './client';
3
+ /**
4
+ * The instrumented context passed between the shared construction helpers.
5
+ *
6
+ * This is intentionally `any` rather than `ReturnType<typeof instrumentContext<DurableObjectState>>`.
7
+ * A concrete `DurableObjectState` here forces `tsc` to structurally relate its `storage: SqlStorage`
8
+ * graph against the `ExecutionContext | InstrumentedDurableObjectState` parameter of
9
+ * `wrapMethodWithSentry`, while the RPC-branded `DurableObject` from `cloudflare:workers` is also in
10
+ * scope. That union comparison explodes (1296×1296) and hangs the type build. The original inline
11
+ * implementation avoided this only incidentally, because `ctx` reached it as `any` through the Proxy
12
+ * `construct` trap. Keeping the shared context `any` preserves that behavior.
13
+ */
14
+ type InstrumentedDurableObjectContext = any;
15
+ /**
16
+ * Constructs a Durable Object instance and instruments its built-in handler methods
17
+ * (`fetch`, `alarm`, `webSocketMessage`, `webSocketClose`, `webSocketError`).
18
+ *
19
+ * This is the shared construction path used by both {@link instrumentDurableObjectWithSentry}
20
+ * and {@link instrumentAgentWithSentry}. It intentionally does NOT apply the RPC prototype-method
21
+ * instrumentation — callers apply that last via {@link finalizeWithRpcInstrumentation}, after any
22
+ * additional per-instance instrumentation has been layered onto the returned object.
23
+ *
24
+ * @internal
25
+ */
26
+ export declare function constructInstrumentedDurableObject<E, T extends DurableObject<E>>(target: new (state: DurableObjectState, env: E) => T, ctx: DurableObjectState, env: E, newTarget: NewableFunction, optionsCallback: (env: E) => CloudflareOptions): {
27
+ obj: T;
28
+ options: CloudflareOptions;
29
+ context: InstrumentedDurableObjectContext;
30
+ frameworkManagedMethods: ReadonlySet<string>;
31
+ };
32
+ /**
33
+ * Adds trace propagation to a constructed Durable Object's RPC methods.
34
+ *
35
+ * RPC methods are wrapped on the prototype because Cloudflare dispatches them with the Durable
36
+ * Object instance as the receiver. This preserves native private-field access and keeps the methods
37
+ * visible to Cloudflare's RPC dispatcher. Built-in handlers, Agent handlers, and methods managed by
38
+ * another framework are left untouched.
39
+ *
40
+ * Call this after all per-instance instrumentation has been applied. If RPC trace propagation is
41
+ * disabled, the object is returned unchanged.
42
+ *
43
+ * @param obj The constructed Durable Object instance.
44
+ * @param options The resolved SDK options for this instance.
45
+ * @param context The instrumented execution context for this instance.
46
+ * @param excludedMethods Method names owned by another framework and therefore not safe to wrap.
47
+ * @returns The same Durable Object instance, with eligible prototype methods instrumented.
48
+ * @internal
49
+ */
50
+ export declare function finalizeWithRpcInstrumentation<T extends object>(obj: T, options: CloudflareOptions, context: InstrumentedDurableObjectContext, excludedMethods?: ReadonlySet<string>): T;
3
51
  /**
4
52
  * Instruments a Durable Object class to capture errors and performance data.
5
53
  *
@@ -34,4 +82,46 @@ import { CloudflareOptions } from './client';
34
82
  * ```
35
83
  */
36
84
  export declare function instrumentDurableObjectWithSentry<E, T extends DurableObject<E>, C extends new (state: DurableObjectState, env: E) => T>(optionsCallback: (env: E) => CloudflareOptions, DurableObjectClass: C): C;
85
+ /**
86
+ * Instruments a Cloudflare [`agents`](https://www.npmjs.com/package/agents) Agent class with Sentry.
87
+ *
88
+ * An `Agent` is a Durable Object under the hood, so this applies the same instrumentation as
89
+ * {@link instrumentDurableObjectWithSentry} (request transactions, `alarm`, WebSocket handlers, RPC
90
+ * trace propagation, SQL spans) and additionally captures Agent-specific telemetry via
91
+ * `instrumentCloudflareAgent`:
92
+ *
93
+ * - **Callable RPC spans** — a span (op `rpc`) for each `@callable()` method invoked over WebSocket.
94
+ * - **Breadcrumbs** — for every Agent observability event (`rpc`, `state:update`, `connect`,
95
+ * `disconnect`, `schedule:*`, `queue:*`, `workflow:*`, `email:*`, `mcp:*`, ...).
96
+ *
97
+ * Cloudflare Workers cannot auto-instrument, so the Agent class must be wrapped manually.
98
+ *
99
+ * @param optionsCallback Function that returns the options for the SDK initialization.
100
+ * @param AgentClass The Agent class to instrument.
101
+ * @returns The instrumented Agent class.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * import { Agent, callable, routeAgentRequest } from 'agents';
106
+ * import * as Sentry from '@sentry/cloudflare';
107
+ *
108
+ * class MyAgentBase extends Agent<Env> {
109
+ * @callable()
110
+ * async greet(name: string): Promise<string> {
111
+ * return `Hello, ${name}!`;
112
+ * }
113
+ * }
114
+ *
115
+ * export const MyAgent = Sentry.instrumentAgentWithSentry(
116
+ * env => ({
117
+ * dsn: env.SENTRY_DSN,
118
+ * tracesSampleRate: 1.0,
119
+ * enableRpcTracePropagation: true,
120
+ * }),
121
+ * MyAgentBase,
122
+ * );
123
+ * ```
124
+ */
125
+ export declare function instrumentAgentWithSentry<E, T extends DurableObject<E>, C extends new (state: DurableObjectState, env: E) => T>(optionsCallback: (env: E) => CloudflareOptions, AgentClass: C): C;
126
+ export {};
37
127
  //# sourceMappingURL=durableobject.d.ts.map
@@ -19,7 +19,7 @@ type FlushLock = {
19
19
  *
20
20
  * By using the original waitUntil for flush operations, we bypass this issue.
21
21
  */
22
- export declare function getOriginalWaitUntil(context: ExecutionContextCompat): ExecutionContext['waitUntil'] | undefined;
22
+ export declare function getOriginalWaitUntil(context: ExecutionContextCompat): ExecutionContext['waitUntil'];
23
23
  /**
24
24
  * Enhances the given execution context by wrapping its `waitUntil` method with a proxy
25
25
  * to monitor pending tasks, and provides a flusher function to ensure all tasks
@@ -3,13 +3,14 @@ export { CloudflareOptions } from './client';
3
3
  export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureFeedback, close, createTransport, lastEventId, flush, getClient, isInitialized, isEnabled, getCurrentScope, getGlobalScope, getIsolationScope, setCurrentClient, Scope, SDK_VERSION, setContext, setExtra, setExtras, setTag, setTags, setAttribute, setAttributes, setUser, setConversationId, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, captureCheckIn, withMonitor, setMeasurement, getActiveSpan, getRootSpan, getTraceData, getTraceMetaTags, startSpan, startInactiveSpan, startSpanManual, startNewTrace, bindScopeToEmitter, suppressTracing, withActiveSpan, getSpanDescendants, continueTrace, functionToStringIntegration, inboundFiltersIntegration, instrumentOpenAiClient, instrumentGoogleGenAIClient, instrumentAnthropicAiClient, eventFiltersIntegration, linkedErrorsIntegration, requestDataIntegration, extraErrorDataIntegration, dedupeIntegration, rewriteFramesIntegration, captureConsoleIntegration, moduleMetadataIntegration, supabaseIntegration, instrumentSupabaseClient, instrumentPostgresJsSql, zodErrorsIntegration, consoleIntegration, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, trpcMiddleware, spanToJSON, spanToTraceHeader, spanToBaggageHeader, updateSpanName, wrapMcpServerWithSentry, consoleLoggingIntegration, createConsolaReporter, createLangChainCallbackHandler, instrumentLangChainEmbeddings, featureFlagsIntegration, growthbookIntegration, logger, metrics, withStreamedSpan, spanStreamingIntegration, instrumentStateGraph, instrumentLangGraph, instrumentCreateReactAgent, } from '@sentry/core';
4
4
  export { withSentry } from './withSentry';
5
5
  export { defineCloudflareOptions } from './defineCloudflareOptions';
6
- export { instrumentDurableObjectWithSentry } from './durableobject';
6
+ export { instrumentAgentWithSentry, instrumentDurableObjectWithSentry } from './durableobject';
7
7
  export { sentryPagesPlugin } from './pages-plugin';
8
8
  export { wrapRequestHandler } from './request';
9
9
  export { CloudflareClient } from './client';
10
10
  export { getDefaultIntegrations } from './sdk';
11
11
  export { httpServerIntegration } from './integrations/httpServer';
12
12
  export { fetchIntegration } from './integrations/fetch';
13
+ export { spotlightIntegration } from './integrations/spotlight';
13
14
  export { vercelAIIntegration } from './integrations/tracing/vercelai';
14
15
  export { honoIntegration } from './integrations/hono';
15
16
  export { instrumentD1WithSentry } from './instrumentations/worker/instrumentD1';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Instruments an instance of a Cloudflare [`agents`](https://www.npmjs.com/package/agents) `Agent`
3
+ * with Sentry, adding telemetry that is specific to the Agent's runtime behavior:
4
+ *
5
+ * - **Callable RPC spans** — a span (op `rpc`) for each `@callable()` method invoked over WebSocket.
6
+ * - **Conversation correlation** — sets the conversation id on the scope for each unit of agent
7
+ * work — chat turn, callable RPC call, or HTTP request — so `gen_ai` spans created within it are
8
+ * correlated, for chat and plain agents alike. The id is minted once per agent instance and
9
+ * rotated when the chat is cleared (the `message:clear` observability event); it is persisted to
10
+ * Durable Object storage so it survives hibernation.
11
+ *
12
+ * It only hooks the `agents` package internals and uses Sentry's tracing primitives. On Cloudflare
13
+ * Workers, prefer `instrumentAgentWithSentry`, which additionally instruments the Durable Object
14
+ * handlers and initializes the SDK; that function calls this one internally.
15
+ *
16
+ * The hooks replace own-properties on the instance and defer to the original implementation, so
17
+ * they compose with any other instrumentation applied to the same instance.
18
+ *
19
+ * @param agent The `agents` `Agent` instance to instrument.
20
+ * @returns The same instance, instrumented.
21
+ *
22
+ * @internal Use `instrumentAgentWithSentry` instead — this is called internally by it.
23
+ */
24
+ export declare function instrumentCloudflareAgent<T extends object>(agent: T): T;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { AgentInternals } from './types';
2
+ /**
3
+ * Wraps the Agent's `onMessage` handler to create a span for each `@callable()` RPC invocation.
4
+ * RPC requests arrive as WebSocket messages, so this span nests under the active transaction for
5
+ * the WebSocket message (on Cloudflare, the instrumented Durable Object `webSocketMessage` hook).
6
+ *
7
+ * Also sets the conversation id on the scope for the duration of the call: callable methods are the
8
+ * unit of work for plain (non-chat) agents, which run LLM calls just like chat turns do. It is
9
+ * awaited so the id is on the scope before the method body creates any span; the `agents`
10
+ * `onMessage` own property this wraps is already `async`, so the promise return is nothing new to
11
+ * the WebSocket dispatch upstream.
12
+ */
13
+ export declare function instrumentAgentCallableRpc(obj: AgentInternals): void;
14
+ //# sourceMappingURL=instrumentAgentCallableRpc.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { AgentInternals } from './types';
2
+ /**
3
+ * Correlates the AI spans of an HTTP-driven agent turn with a conversation id on the active scope.
4
+ *
5
+ * `onRequest` is the third unit of agent work, alongside chat turns and `@callable()` RPC: the
6
+ * `agents` router sends every non-WebSocket request to it, which is how REST endpoints and webhooks
7
+ * reach an agent.
8
+ *
9
+ * `agents` installs `onRequest` as an own property in the `Agent` constructor (as it does
10
+ * `onMessage`), and we instrument after construction, so wrapping the own property is what the
11
+ * router ends up calling. That own property is already `async`, and partyserver's `fetch` awaits it,
12
+ * so returning a promise from this wrapper — to get the conversation id onto the scope before the
13
+ * request handler creates any span — keeps the existing contract.
14
+ */
15
+ export declare function instrumentAgentRequestConversation(obj: AgentInternals): void;
16
+ //# sourceMappingURL=instrumentAgentRequestConversation.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { AgentInternals } from './types';
2
+ /**
3
+ * For chat agents (`AIChatAgent` from `@cloudflare/ai-chat`), correlates each chat turn's AI spans
4
+ * with a conversation id on the active scope.
5
+ *
6
+ * In the Agents model one agent instance is one long-lived conversation, so the conversation id is
7
+ * minted once per instance and persisted to Durable Object storage, which is what carries it across
8
+ * hibernation (that destroys the in-memory instance). When the user clears the chat, they expect a
9
+ * fresh conversation — but recreating the Durable Object for that would also drop the MCP/OAuth
10
+ * state stored per instance (GitHub/Sentry sign-in). To get a fresh conversation id *without*
11
+ * losing that state, we rotate the persisted id when the SDK reports a cleared chat.
12
+ *
13
+ * The id itself is not attached to spans here — `setAgentConversationId` resolves it, and the SDK's
14
+ * `conversationIdIntegration` picks it off the scope at `spanStart` to stamp
15
+ * `gen_ai.conversation.id` onto the AI spans created inside the turn (e.g. by the Workers AI
16
+ * instrumentation), which correlates a turn's model and tool calls.
17
+ *
18
+ * Plain (non-chat) `Agent`s do not define `onChatMessage`, so they are skipped here — their unit
19
+ * of work is the callable RPC method, where `instrumentAgentCallableRpc` sets the conversation id
20
+ * instead.
21
+ */
22
+ export declare function instrumentChatAgentConversation(obj: AgentInternals): void;
23
+ //# sourceMappingURL=instrumentChatAgentConversation.d.ts.map