@struct-ai/sdk 0.1.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 (228) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +168 -0
  3. package/dist/commonjs/content-capture.d.ts +10 -0
  4. package/dist/commonjs/content-capture.js +23 -0
  5. package/dist/commonjs/context.d.ts +30 -0
  6. package/dist/commonjs/context.js +94 -0
  7. package/dist/commonjs/core.d.ts +120 -0
  8. package/dist/commonjs/core.js +408 -0
  9. package/dist/commonjs/events.d.ts +12 -0
  10. package/dist/commonjs/events.js +103 -0
  11. package/dist/commonjs/index.d.ts +6 -0
  12. package/dist/commonjs/index.js +10 -0
  13. package/dist/commonjs/integrations/anthropic-content.d.ts +24 -0
  14. package/dist/commonjs/integrations/anthropic-content.js +178 -0
  15. package/dist/commonjs/integrations/anthropic.d.ts +34 -0
  16. package/dist/commonjs/integrations/anthropic.js +377 -0
  17. package/dist/commonjs/integrations/index.d.ts +5 -0
  18. package/dist/commonjs/integrations/index.js +47 -0
  19. package/dist/commonjs/integrations/langchain-callback.d.ts +134 -0
  20. package/dist/commonjs/integrations/langchain-callback.js +723 -0
  21. package/dist/commonjs/integrations/langchain-content.d.ts +35 -0
  22. package/dist/commonjs/integrations/langchain-content.js +307 -0
  23. package/dist/commonjs/integrations/langchain.d.ts +11 -0
  24. package/dist/commonjs/integrations/langchain.js +100 -0
  25. package/dist/commonjs/package.json +3 -0
  26. package/dist/commonjs/semconv.d.ts +54 -0
  27. package/dist/commonjs/semconv.js +74 -0
  28. package/dist/commonjs/truncation.d.ts +10 -0
  29. package/dist/commonjs/truncation.js +103 -0
  30. package/dist/esm/content-capture.d.ts +10 -0
  31. package/dist/esm/content-capture.js +17 -0
  32. package/dist/esm/context.d.ts +30 -0
  33. package/dist/esm/context.js +80 -0
  34. package/dist/esm/core.d.ts +120 -0
  35. package/dist/esm/core.js +403 -0
  36. package/dist/esm/events.d.ts +12 -0
  37. package/dist/esm/events.js +99 -0
  38. package/dist/esm/index.d.ts +6 -0
  39. package/dist/esm/index.js +5 -0
  40. package/dist/esm/integrations/anthropic-content.d.ts +24 -0
  41. package/dist/esm/integrations/anthropic-content.js +168 -0
  42. package/dist/esm/integrations/anthropic.d.ts +34 -0
  43. package/dist/esm/integrations/anthropic.js +370 -0
  44. package/dist/esm/integrations/index.d.ts +5 -0
  45. package/dist/esm/integrations/index.js +42 -0
  46. package/dist/esm/integrations/langchain-callback.d.ts +134 -0
  47. package/dist/esm/integrations/langchain-callback.js +719 -0
  48. package/dist/esm/integrations/langchain-content.d.ts +35 -0
  49. package/dist/esm/integrations/langchain-content.js +294 -0
  50. package/dist/esm/integrations/langchain.d.ts +11 -0
  51. package/dist/esm/integrations/langchain.js +95 -0
  52. package/dist/esm/package.json +3 -0
  53. package/dist/esm/semconv.d.ts +54 -0
  54. package/dist/esm/semconv.js +71 -0
  55. package/dist/esm/truncation.d.ts +10 -0
  56. package/dist/esm/truncation.js +96 -0
  57. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/content-capture.d.ts +10 -0
  58. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/context.d.ts +30 -0
  59. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/core.d.ts +120 -0
  60. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/events.d.ts +12 -0
  61. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/index.d.ts +6 -0
  62. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/anthropic-content.d.ts +24 -0
  63. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/anthropic.d.ts +34 -0
  64. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/index.d.ts +5 -0
  65. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/langchain-callback.d.ts +134 -0
  66. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/langchain-content.d.ts +35 -0
  67. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/langchain.d.ts +11 -0
  68. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/package.json +3 -0
  69. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/semconv.d.ts +54 -0
  70. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/truncation.d.ts +10 -0
  71. package/dist/node_modules/@struct-ai/sdk/dist/esm/content-capture.d.ts +10 -0
  72. package/dist/node_modules/@struct-ai/sdk/dist/esm/context.d.ts +30 -0
  73. package/dist/node_modules/@struct-ai/sdk/dist/esm/core.d.ts +120 -0
  74. package/dist/node_modules/@struct-ai/sdk/dist/esm/events.d.ts +12 -0
  75. package/dist/node_modules/@struct-ai/sdk/dist/esm/index.d.ts +6 -0
  76. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/anthropic-content.d.ts +24 -0
  77. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/anthropic.d.ts +34 -0
  78. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/index.d.ts +5 -0
  79. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/langchain-callback.d.ts +134 -0
  80. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/langchain-content.d.ts +35 -0
  81. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/langchain.d.ts +11 -0
  82. package/dist/node_modules/@struct-ai/sdk/dist/esm/package.json +3 -0
  83. package/dist/node_modules/@struct-ai/sdk/dist/esm/semconv.d.ts +54 -0
  84. package/dist/node_modules/@struct-ai/sdk/dist/esm/truncation.d.ts +10 -0
  85. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/dist/commonjs/package.json +3 -0
  86. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/dist/esm/package.json +3 -0
  87. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/package.json +100 -0
  88. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/package.json +103 -0
  89. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/package.json +118 -0
  90. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/package.json +916 -0
  91. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/package.json +188 -0
  92. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api/package.json +96 -0
  93. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api-logs/package.json +91 -0
  94. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/core/package.json +96 -0
  95. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-logs-otlp-proto/package.json +108 -0
  96. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-trace-otlp-proto/package.json +105 -0
  97. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/resources/package.json +100 -0
  98. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-logs/package.json +109 -0
  99. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-base/package.json +100 -0
  100. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-node/package.json +76 -0
  101. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/package.json +140 -0
  102. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/nock/package.json +89 -0
  103. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/tshy/package.json +81 -0
  104. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/typescript/package.json +120 -0
  105. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/vitest/package.json +239 -0
  106. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/package.json +100 -0
  107. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/core.d.ts +244 -0
  108. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/error.d.ts +54 -0
  109. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/index.d.ts +188 -0
  110. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/package.json +103 -0
  111. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/pagination.d.ts +26 -0
  112. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/resource.d.ts +6 -0
  113. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/streaming.d.ts +41 -0
  114. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/uploads.d.ts +75 -0
  115. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/version.d.ts +2 -0
  116. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/experimental.d.ts +1 -0
  117. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/index.d.ts +1 -0
  118. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/package.json +118 -0
  119. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/agents.d.ts +1 -0
  120. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/caches.d.ts +1 -0
  121. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/chat_history.d.ts +1 -0
  122. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/context.d.ts +1 -0
  123. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/documents.d.ts +1 -0
  124. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/embeddings.d.ts +1 -0
  125. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/example_selectors.d.ts +1 -0
  126. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/index.d.ts +1 -0
  127. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/indexing.d.ts +1 -0
  128. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/load.d.ts +1 -0
  129. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/memory.d.ts +1 -0
  130. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/messages.d.ts +1 -0
  131. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/output_parsers.d.ts +1 -0
  132. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/outputs.d.ts +1 -0
  133. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/package.json +916 -0
  134. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/prompt_values.d.ts +1 -0
  135. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/prompts.d.ts +1 -0
  136. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/retrievers.d.ts +1 -0
  137. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/runnables.d.ts +1 -0
  138. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/singletons.d.ts +1 -0
  139. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/stores.d.ts +1 -0
  140. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/structured_query.d.ts +1 -0
  141. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/tools.d.ts +1 -0
  142. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/vectorstores.d.ts +1 -0
  143. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/index.d.ts +1 -0
  144. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/package.json +188 -0
  145. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/prebuilt.d.ts +1 -0
  146. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/pregel.d.ts +1 -0
  147. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/remote.d.ts +1 -0
  148. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/web.d.ts +1 -0
  149. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/zod.d.ts +1 -0
  150. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api/package.json +96 -0
  151. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api-logs/package.json +91 -0
  152. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/core/package.json +96 -0
  153. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-logs-otlp-proto/package.json +108 -0
  154. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-trace-otlp-proto/package.json +105 -0
  155. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/resources/package.json +100 -0
  156. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-logs/package.json +109 -0
  157. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-base/package.json +100 -0
  158. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-node/package.json +76 -0
  159. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/assert.d.ts +1062 -0
  160. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/async_hooks.d.ts +605 -0
  161. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/buffer.buffer.d.ts +471 -0
  162. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/buffer.d.ts +1936 -0
  163. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/child_process.d.ts +1475 -0
  164. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/cluster.d.ts +577 -0
  165. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/console.d.ts +452 -0
  166. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/constants.d.ts +21 -0
  167. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/crypto.d.ts +4590 -0
  168. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/dgram.d.ts +597 -0
  169. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
  170. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/dns.d.ts +871 -0
  171. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/domain.d.ts +170 -0
  172. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/events.d.ts +977 -0
  173. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/fs.d.ts +4375 -0
  174. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/globals.d.ts +172 -0
  175. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/globals.typedarray.d.ts +38 -0
  176. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/http.d.ts +2049 -0
  177. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/http2.d.ts +2631 -0
  178. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/https.d.ts +578 -0
  179. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/index.d.ts +93 -0
  180. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/inspector.generated.d.ts +3966 -0
  181. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/module.d.ts +539 -0
  182. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/net.d.ts +1031 -0
  183. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/os.d.ts +506 -0
  184. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/package.json +140 -0
  185. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/path.d.ts +200 -0
  186. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/perf_hooks.d.ts +961 -0
  187. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/process.d.ts +1961 -0
  188. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/punycode.d.ts +117 -0
  189. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/querystring.d.ts +152 -0
  190. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/readline.d.ts +589 -0
  191. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/repl.d.ts +430 -0
  192. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/sea.d.ts +153 -0
  193. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/stream.d.ts +1698 -0
  194. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/string_decoder.d.ts +67 -0
  195. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/test.d.ts +1787 -0
  196. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/timers.d.ts +286 -0
  197. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/tls.d.ts +1259 -0
  198. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/trace_events.d.ts +197 -0
  199. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/tty.d.ts +208 -0
  200. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/url.d.ts +964 -0
  201. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/util.d.ts +2331 -0
  202. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/v8.d.ts +809 -0
  203. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/vm.d.ts +1001 -0
  204. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/wasi.d.ts +181 -0
  205. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/worker_threads.d.ts +715 -0
  206. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/zlib.d.ts +598 -0
  207. package/dist/node_modules/@struct-ai/sdk/node_modules/nock/package.json +89 -0
  208. package/dist/node_modules/@struct-ai/sdk/node_modules/tshy/package.json +81 -0
  209. package/dist/node_modules/@struct-ai/sdk/node_modules/typescript/package.json +120 -0
  210. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/config.d.ts +3 -0
  211. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/coverage.d.ts +1 -0
  212. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/environments.d.ts +1 -0
  213. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/globals.d.ts +22 -0
  214. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/import-meta.d.ts +5 -0
  215. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/importMeta.d.ts +4 -0
  216. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/jsdom.d.ts +6 -0
  217. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/mocker.d.ts +1 -0
  218. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/node.d.ts +1 -0
  219. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/optional-runtime-types.d.ts +6 -0
  220. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/optional-types.d.ts +7 -0
  221. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/package.json +239 -0
  222. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/reporters.d.ts +1 -0
  223. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/runners.d.ts +1 -0
  224. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/snapshot.d.ts +1 -0
  225. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/suite.d.ts +1 -0
  226. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/worker.d.ts +1 -0
  227. package/dist/node_modules/@struct-ai/sdk/package.json +100 -0
  228. package/package.json +100 -0
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TRUNCATION_MARKER = exports.MAX_FIELD_SIZE = exports.MAX_CONTENT_SIZE = void 0;
4
+ exports.truncateField = truncateField;
5
+ exports.truncateParts = truncateParts;
6
+ exports.truncateAndSerialize = truncateAndSerialize;
7
+ exports.safeJsonStringify = safeJsonStringify;
8
+ exports.MAX_CONTENT_SIZE = 128 * 1024;
9
+ exports.MAX_FIELD_SIZE = 16384;
10
+ exports.TRUNCATION_MARKER = "… [truncated]";
11
+ function truncateField(value, maxLen = exports.MAX_FIELD_SIZE) {
12
+ if (typeof value === "string" && value.length > maxLen) {
13
+ return value.slice(0, maxLen) + exports.TRUNCATION_MARKER;
14
+ }
15
+ return value;
16
+ }
17
+ function truncateParts(parts) {
18
+ const result = [];
19
+ for (const original of parts) {
20
+ const part = { ...original };
21
+ if (typeof part.content === "string") {
22
+ part.content = truncateField(part.content);
23
+ }
24
+ if ("arguments" in part) {
25
+ const arg = part.arguments;
26
+ if (typeof arg === "string") {
27
+ part.arguments = truncateField(arg);
28
+ }
29
+ else if (arg && typeof arg === "object") {
30
+ const serialized = safeJsonStringify(arg);
31
+ if (serialized.length > exports.MAX_FIELD_SIZE) {
32
+ part.arguments = serialized.slice(0, exports.MAX_FIELD_SIZE) + exports.TRUNCATION_MARKER;
33
+ }
34
+ }
35
+ }
36
+ if ("response" in part) {
37
+ const resp = part.response;
38
+ if (typeof resp === "string") {
39
+ part.response = truncateField(resp);
40
+ }
41
+ else if (resp && typeof resp === "object") {
42
+ const serialized = safeJsonStringify(resp);
43
+ if (serialized.length > exports.MAX_FIELD_SIZE) {
44
+ part.response = serialized.slice(0, exports.MAX_FIELD_SIZE) + exports.TRUNCATION_MARKER;
45
+ }
46
+ }
47
+ }
48
+ result.push(part);
49
+ }
50
+ return result;
51
+ }
52
+ function truncateAndSerialize(obj, maxSize = exports.MAX_CONTENT_SIZE) {
53
+ let result;
54
+ if (Array.isArray(obj)) {
55
+ const truncated = obj.map((item) => {
56
+ if (!item || typeof item !== "object")
57
+ return item;
58
+ const copy = { ...item };
59
+ if (Array.isArray(copy.parts)) {
60
+ copy.parts = truncateParts(copy.parts);
61
+ }
62
+ else if (typeof copy.content === "string") {
63
+ copy.content = truncateField(copy.content);
64
+ }
65
+ return copy;
66
+ });
67
+ result = safeJsonStringify(truncated);
68
+ }
69
+ else {
70
+ result = safeJsonStringify(obj);
71
+ }
72
+ if (result.length > maxSize) {
73
+ const cut = result.slice(0, maxSize - 50);
74
+ const lastBrace = cut.lastIndexOf("}");
75
+ if (lastBrace > 0) {
76
+ result = cut.slice(0, lastBrace + 1) + "]";
77
+ }
78
+ else {
79
+ result = "[]";
80
+ }
81
+ }
82
+ return result;
83
+ }
84
+ function safeJsonStringify(obj) {
85
+ try {
86
+ return JSON.stringify(obj, defaultReplacer);
87
+ }
88
+ catch {
89
+ return JSON.stringify(String(obj));
90
+ }
91
+ }
92
+ function defaultReplacer(_key, value) {
93
+ if (typeof value === "bigint")
94
+ return value.toString();
95
+ if (value instanceof Error)
96
+ return `${value.name}: ${value.message}`;
97
+ if (value instanceof Map)
98
+ return Object.fromEntries(value.entries());
99
+ if (value instanceof Set)
100
+ return Array.from(value);
101
+ return value;
102
+ }
103
+ //# sourceMappingURL=truncation.js.map
@@ -0,0 +1,10 @@
1
+ export declare enum ContentCaptureMode {
2
+ None = "none",
3
+ EventOnly = "event_only",
4
+ SpanOnly = "span_only",
5
+ SpanAndEvent = "span_and_event"
6
+ }
7
+ export declare function emitEventsFor(mode: ContentCaptureMode): boolean;
8
+ export declare function emitSpanContentFor(mode: ContentCaptureMode): boolean;
9
+ export declare function captureContentFor(mode: ContentCaptureMode): boolean;
10
+ //# sourceMappingURL=content-capture.d.ts.map
@@ -0,0 +1,17 @@
1
+ export var ContentCaptureMode;
2
+ (function (ContentCaptureMode) {
3
+ ContentCaptureMode["None"] = "none";
4
+ ContentCaptureMode["EventOnly"] = "event_only";
5
+ ContentCaptureMode["SpanOnly"] = "span_only";
6
+ ContentCaptureMode["SpanAndEvent"] = "span_and_event";
7
+ })(ContentCaptureMode || (ContentCaptureMode = {}));
8
+ export function emitEventsFor(mode) {
9
+ return mode === ContentCaptureMode.EventOnly || mode === ContentCaptureMode.SpanAndEvent;
10
+ }
11
+ export function emitSpanContentFor(mode) {
12
+ return mode === ContentCaptureMode.SpanOnly || mode === ContentCaptureMode.SpanAndEvent;
13
+ }
14
+ export function captureContentFor(mode) {
15
+ return mode !== ContentCaptureMode.None;
16
+ }
17
+ //# sourceMappingURL=content-capture.js.map
@@ -0,0 +1,30 @@
1
+ import type { Span } from "@opentelemetry/api";
2
+ export interface StructContext {
3
+ sessionId?: string;
4
+ conversationId?: string;
5
+ agentSpan?: Span;
6
+ pendingToolCalls?: Record<string, string[]>;
7
+ }
8
+ export declare function getStore(): StructContext | undefined;
9
+ export declare function getSessionId(): string | undefined;
10
+ export declare function getConversationId(): string | undefined;
11
+ export declare function getAgentSpan(): Span | undefined;
12
+ export declare function getPendingToolCalls(): Record<string, string[]> | undefined;
13
+ export declare function runWithContext<T>(patch: Partial<StructContext>, fn: () => T): T;
14
+ export declare function ensurePendingToolCallsSlot(): Record<string, string[]>;
15
+ /**
16
+ * Pop the first pending tool_use id matching `name`, or undefined.
17
+ * FIFO semantics match Python struct-sdk-python.
18
+ */
19
+ export declare function popPendingToolCallId(name: string): string | undefined;
20
+ /**
21
+ * Push (name, id) pairs into the active pending-tool-calls slot.
22
+ * Initializes a transient dict if no active agent scope.
23
+ */
24
+ export declare function pushPendingToolCalls(pairs: readonly [string, string][]): void;
25
+ /** Snapshot the store for wrapping async iterators. */
26
+ export declare function snapshotStore(): StructContext | undefined;
27
+ export declare function runWithStore<T>(store: StructContext | undefined, fn: () => T): T;
28
+ /** Test-only: run `fn` inside a completely fresh context (no parent store). */
29
+ export declare function runInFreshContext<T>(fn: () => T): T;
30
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1,80 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ const als = new AsyncLocalStorage();
3
+ export function getStore() {
4
+ return als.getStore();
5
+ }
6
+ export function getSessionId() {
7
+ return als.getStore()?.sessionId;
8
+ }
9
+ export function getConversationId() {
10
+ return als.getStore()?.conversationId;
11
+ }
12
+ export function getAgentSpan() {
13
+ return als.getStore()?.agentSpan;
14
+ }
15
+ export function getPendingToolCalls() {
16
+ return als.getStore()?.pendingToolCalls;
17
+ }
18
+ export function runWithContext(patch, fn) {
19
+ const current = als.getStore() ?? {};
20
+ const next = { ...current, ...patch };
21
+ return als.run(next, fn);
22
+ }
23
+ export function ensurePendingToolCallsSlot() {
24
+ const store = als.getStore();
25
+ if (store) {
26
+ if (!store.pendingToolCalls) {
27
+ store.pendingToolCalls = {};
28
+ }
29
+ return store.pendingToolCalls;
30
+ }
31
+ // No active store — nothing to attach to. Caller is expected to handle this.
32
+ return {};
33
+ }
34
+ /**
35
+ * Pop the first pending tool_use id matching `name`, or undefined.
36
+ * FIFO semantics match Python struct-sdk-python.
37
+ */
38
+ export function popPendingToolCallId(name) {
39
+ const pending = getPendingToolCalls();
40
+ if (!pending)
41
+ return undefined;
42
+ const ids = pending[name];
43
+ if (!ids || ids.length === 0)
44
+ return undefined;
45
+ return ids.shift();
46
+ }
47
+ /**
48
+ * Push (name, id) pairs into the active pending-tool-calls slot.
49
+ * Initializes a transient dict if no active agent scope.
50
+ */
51
+ export function pushPendingToolCalls(pairs) {
52
+ if (pairs.length === 0)
53
+ return;
54
+ const store = als.getStore();
55
+ if (!store)
56
+ return;
57
+ if (!store.pendingToolCalls) {
58
+ store.pendingToolCalls = {};
59
+ }
60
+ for (const [name, id] of pairs) {
61
+ if (!store.pendingToolCalls[name])
62
+ store.pendingToolCalls[name] = [];
63
+ store.pendingToolCalls[name].push(id);
64
+ }
65
+ }
66
+ /** Snapshot the store for wrapping async iterators. */
67
+ export function snapshotStore() {
68
+ const store = als.getStore();
69
+ return store ? { ...store } : undefined;
70
+ }
71
+ export function runWithStore(store, fn) {
72
+ if (!store)
73
+ return fn();
74
+ return als.run(store, fn);
75
+ }
76
+ /** Test-only: run `fn` inside a completely fresh context (no parent store). */
77
+ export function runInFreshContext(fn) {
78
+ return als.run({}, fn);
79
+ }
80
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1,120 @@
1
+ import { type Tracer } from "@opentelemetry/api";
2
+ import { type Logger } from "@opentelemetry/api-logs";
3
+ import { type LogRecordProcessor } from "@opentelemetry/sdk-logs";
4
+ import type { SpanProcessor } from "@opentelemetry/sdk-trace-base";
5
+ import { ContentCaptureMode } from "./content-capture.js";
6
+ export declare const DEFAULT_ENDPOINT = "https://ingest.struct.ai";
7
+ export interface InitOptions {
8
+ ingestKey: string;
9
+ serviceName?: string;
10
+ serviceVersion?: string;
11
+ environment?: string;
12
+ endpoint?: string;
13
+ captureContent?: boolean;
14
+ contentCapture?: ContentCaptureMode;
15
+ /**
16
+ * Maximum time `shutdown()` is allowed to spend flushing telemetry providers
17
+ * before returning. If the ingest endpoint is dead or slow, shutdown returns
18
+ * within this budget rather than hanging the host process exit. Defaults to
19
+ * 5000ms. Can be overridden per call via `shutdown(timeoutMs)`.
20
+ */
21
+ shutdownTimeoutMs?: number;
22
+ }
23
+ export interface AgentScopeOptions {
24
+ name: string;
25
+ sessionId?: string;
26
+ /**
27
+ * Stable identifier for the agent DEFINITION — `gen_ai.agent.id` per the OTel
28
+ * GenAI spec. Not the same as sessionId (which identifies a single
29
+ * invocation / conversation). Omit if you don't have a stable ID.
30
+ */
31
+ agentId?: string;
32
+ version?: string;
33
+ metadata?: Record<string, string>;
34
+ }
35
+ export interface ToolScopeOptions {
36
+ name: string;
37
+ toolCallId?: string;
38
+ }
39
+ export interface InternalLogger {
40
+ info(msg: string, ...args: unknown[]): void;
41
+ warn(msg: string, ...args: unknown[]): void;
42
+ debug(msg: string, ...args: unknown[]): void;
43
+ }
44
+ /**
45
+ * Sites that have already logged a first-failure WARN; subsequent failures at
46
+ * the same site log at DEBUG. Mirrors `_first_failure_logged` in the Python
47
+ * SDK.
48
+ *
49
+ * Exported for tests that need to clear the set between runs so log-level
50
+ * assertions are deterministic. Internal — not re-exported from `index.ts`,
51
+ * so consumers cannot reach it via the package's public API surface.
52
+ */
53
+ export declare const firstFailureLogged: Set<string>;
54
+ /**
55
+ * Run `fn`; swallow any exception. The first failure per `site` logs at WARN
56
+ * (with the error attached); subsequent failures at the same site log at
57
+ * DEBUG. The caller's logger is passed explicitly so this helper stays a free
58
+ * module-level function — usable from instrumentation modules that don't
59
+ * carry an SDK reference of their own.
60
+ *
61
+ * Mirrors `_safe(fn, *, site)` in the Python SDK.
62
+ */
63
+ export declare function safe(fn: () => void, site: string, logger: InternalLogger): void;
64
+ export declare class StructSDK {
65
+ private _initialized;
66
+ private _tracerProvider;
67
+ private _loggerProvider;
68
+ private _ingestKey;
69
+ private _endpoint;
70
+ private _contentCapture;
71
+ private _shutdownHook;
72
+ private _shutdownTimeoutMs;
73
+ private _internalLogger;
74
+ private _readyPromise;
75
+ /** Resolves once auto-instrumentation has attempted to patch every detected library. */
76
+ get ready(): Promise<void>;
77
+ get initialized(): boolean;
78
+ get endpoint(): string;
79
+ get ingestKey(): string;
80
+ get contentCapture(): ContentCaptureMode;
81
+ get captureContent(): boolean;
82
+ get emitEvents(): boolean;
83
+ get emitSpanContent(): boolean;
84
+ init(options: InitOptions): void;
85
+ getTracer(name?: string): Tracer;
86
+ getLogger(name?: string): Logger;
87
+ getInternalLogger(): InternalLogger;
88
+ /** Test-only: attach a custom span processor to the internal provider. */
89
+ addSpanProcessor(processor: SpanProcessor): void;
90
+ /** Test-only: attach a custom log record processor. */
91
+ addLogRecordProcessor(processor: LogRecordProcessor): void;
92
+ /**
93
+ * Shut down the SDK and flush pending telemetry.
94
+ *
95
+ * Returns within `timeoutMs` (default: SDK init's `shutdownTimeoutMs`,
96
+ * fallback 5000ms). If the ingest endpoint is unreachable, in-flight
97
+ * telemetry may be dropped — the trade-off vs. blocking process exit.
98
+ *
99
+ * In serverless / edge runtimes (Lambda, Vercel, etc.), the runtime does
100
+ * NOT await our `beforeExit` hook. Call `await struct.shutdown()`
101
+ * explicitly before your function returns or before container freeze.
102
+ *
103
+ * Safe to call multiple times. Safe to call on an SDK that failed to init
104
+ * or was never initialized.
105
+ *
106
+ * @param timeoutMs - Override the configured shutdown timeout for this call.
107
+ */
108
+ shutdown(timeoutMs?: number): Promise<void>;
109
+ /**
110
+ * Run `fn` inside an `invoke_agent` span scope.
111
+ * Matches Python's _AgentContext behavior.
112
+ */
113
+ agent<T>(options: AgentScopeOptions, fn: () => Promise<T> | T): Promise<T>;
114
+ /**
115
+ * Run `fn` inside an `execute_tool` span scope.
116
+ * Matches Python's _ToolContext behavior.
117
+ */
118
+ tool<T>(options: ToolScopeOptions, fn: () => Promise<T> | T): Promise<T>;
119
+ }
120
+ //# sourceMappingURL=core.d.ts.map