@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,403 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { context as otelContext, SpanKind, SpanStatusCode, trace, } from "@opentelemetry/api";
3
+ import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-proto";
4
+ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
5
+ import { Resource } from "@opentelemetry/resources";
6
+ import { BatchLogRecordProcessor, LoggerProvider, } from "@opentelemetry/sdk-logs";
7
+ import { BatchSpanProcessor, NodeTracerProvider, } from "@opentelemetry/sdk-trace-node";
8
+ import { ContentCaptureMode, captureContentFor, emitEventsFor, emitSpanContentFor, } from "./content-capture.js";
9
+ import { getAgentSpan, getSessionId, popPendingToolCallId, runWithContext, } from "./context.js";
10
+ import { autoInstrument } from "./integrations/index.js";
11
+ import { ERROR_TYPE, GEN_AI, STRUCT, } from "./semconv.js";
12
+ import { safeJsonStringify } from "./truncation.js";
13
+ export const DEFAULT_ENDPOINT = "https://ingest.struct.ai";
14
+ const LOG_ENABLED = process.env.STRUCT_SDK_LOG === "1";
15
+ const defaultInternalLogger = {
16
+ info: (msg, ...args) => {
17
+ if (LOG_ENABLED)
18
+ console.info(`[struct-sdk] ${msg}`, ...args);
19
+ },
20
+ warn: (msg, ...args) => console.warn(`[struct-sdk] ${msg}`, ...args),
21
+ debug: (msg, ...args) => {
22
+ if (LOG_ENABLED)
23
+ console.debug(`[struct-sdk] ${msg}`, ...args);
24
+ },
25
+ };
26
+ /**
27
+ * Sites that have already logged a first-failure WARN; subsequent failures at
28
+ * the same site log at DEBUG. Mirrors `_first_failure_logged` in the Python
29
+ * SDK.
30
+ *
31
+ * Exported for tests that need to clear the set between runs so log-level
32
+ * assertions are deterministic. Internal — not re-exported from `index.ts`,
33
+ * so consumers cannot reach it via the package's public API surface.
34
+ */
35
+ export const firstFailureLogged = new Set();
36
+ /**
37
+ * Run `fn`; swallow any exception. The first failure per `site` logs at WARN
38
+ * (with the error attached); subsequent failures at the same site log at
39
+ * DEBUG. The caller's logger is passed explicitly so this helper stays a free
40
+ * module-level function — usable from instrumentation modules that don't
41
+ * carry an SDK reference of their own.
42
+ *
43
+ * Mirrors `_safe(fn, *, site)` in the Python SDK.
44
+ */
45
+ export function safe(fn, site, logger) {
46
+ try {
47
+ fn();
48
+ }
49
+ catch (err) {
50
+ if (firstFailureLogged.has(site)) {
51
+ logger.debug(`Struct SDK suppressed exception at ${site}`, err);
52
+ }
53
+ else {
54
+ firstFailureLogged.add(site);
55
+ logger.warn(`Struct SDK suppressed exception at ${site}`, err);
56
+ }
57
+ }
58
+ }
59
+ export class StructSDK {
60
+ _initialized = false;
61
+ _tracerProvider;
62
+ _loggerProvider;
63
+ _ingestKey = "";
64
+ _endpoint = DEFAULT_ENDPOINT;
65
+ _contentCapture = ContentCaptureMode.EventOnly;
66
+ _shutdownHook;
67
+ // Always set so `shutdown()` can read it even when init() was never called
68
+ // or failed before reaching the assignment in init(). Mirrors the Python
69
+ // SDK's `_shutdown_timeout_seconds` default in `__init__`.
70
+ _shutdownTimeoutMs = 5000;
71
+ _internalLogger = defaultInternalLogger;
72
+ _readyPromise = Promise.resolve();
73
+ /** Resolves once auto-instrumentation has attempted to patch every detected library. */
74
+ get ready() {
75
+ return this._readyPromise;
76
+ }
77
+ get initialized() {
78
+ return this._initialized;
79
+ }
80
+ get endpoint() {
81
+ return this._endpoint;
82
+ }
83
+ get ingestKey() {
84
+ return this._ingestKey;
85
+ }
86
+ get contentCapture() {
87
+ return this._contentCapture;
88
+ }
89
+ get captureContent() {
90
+ return captureContentFor(this._contentCapture);
91
+ }
92
+ get emitEvents() {
93
+ return emitEventsFor(this._contentCapture);
94
+ }
95
+ get emitSpanContent() {
96
+ return emitSpanContentFor(this._contentCapture);
97
+ }
98
+ init(options) {
99
+ if (this._initialized) {
100
+ this._internalLogger.warn("struct.init() called multiple times — ignoring");
101
+ return;
102
+ }
103
+ const { ingestKey, serviceName = "default-agent", serviceVersion = "0.0.0", environment = "development", endpoint = DEFAULT_ENDPOINT, captureContent = true, contentCapture, shutdownTimeoutMs = 5000, } = options;
104
+ this._ingestKey = ingestKey;
105
+ this._endpoint = endpoint.replace(/\/+$/, "");
106
+ // Stored before any code that could throw so shutdown() always sees
107
+ // the user-configured timeout, even on a partially-failed init.
108
+ this._shutdownTimeoutMs = shutdownTimeoutMs;
109
+ if (contentCapture !== undefined) {
110
+ this._contentCapture = contentCapture;
111
+ }
112
+ else if (!captureContent) {
113
+ this._contentCapture = ContentCaptureMode.None;
114
+ }
115
+ else {
116
+ this._contentCapture = ContentCaptureMode.EventOnly;
117
+ }
118
+ // Everything from here through autoInstrument() can fail in the wild —
119
+ // exporter constructors validate URLs, the resource builder may reject
120
+ // attribute values, processors allocate buffers, etc. The SDK contract
121
+ // is that init() never raises; on failure we leave the SDK in a clean
122
+ // disabled state and let the user's app keep running. Decorator-style
123
+ // calls (`agent`, `tool`) already short-circuit when `_initialized`
124
+ // is false, so a disabled SDK is a no-op rather than a hazard.
125
+ try {
126
+ const headers = { "x-struct-ingest-key": ingestKey };
127
+ const spanExporter = new OTLPTraceExporter({
128
+ url: `${this._endpoint}/v1/traces`,
129
+ headers,
130
+ });
131
+ const spanProcessor = new BatchSpanProcessor(spanExporter, {
132
+ maxQueueSize: 10000,
133
+ maxExportBatchSize: 100,
134
+ scheduledDelayMillis: 1000,
135
+ });
136
+ const resource = new Resource({
137
+ "service.name": serviceName,
138
+ "service.version": serviceVersion,
139
+ "deployment.environment": environment,
140
+ });
141
+ this._tracerProvider = new NodeTracerProvider({
142
+ resource,
143
+ spanProcessors: [spanProcessor],
144
+ });
145
+ const logExporter = new OTLPLogExporter({
146
+ url: `${this._endpoint}/v1/logs`,
147
+ headers,
148
+ });
149
+ const logProcessor = new BatchLogRecordProcessor(logExporter, {
150
+ maxQueueSize: 10000,
151
+ maxExportBatchSize: 100,
152
+ scheduledDelayMillis: 1000,
153
+ });
154
+ this._loggerProvider = new LoggerProvider({ resource });
155
+ this._loggerProvider.addLogRecordProcessor(logProcessor);
156
+ this._initialized = true;
157
+ this._shutdownHook = () => {
158
+ void this.shutdown();
159
+ };
160
+ process.on("beforeExit", this._shutdownHook);
161
+ this._readyPromise = autoInstrument(this);
162
+ }
163
+ catch (err) {
164
+ this._internalLogger.warn(`Struct SDK init failed; SDK disabled: service=${serviceName} endpoint=${this._endpoint}`, err);
165
+ // Tear down anything we may have already wired up. If process.on
166
+ // succeeded but a later step failed, the beforeExit listener is still
167
+ // live — unregister it so the disabled SDK doesn't run shutdown logic
168
+ // against half-built providers at process exit.
169
+ if (this._shutdownHook) {
170
+ process.off("beforeExit", this._shutdownHook);
171
+ }
172
+ this._initialized = false;
173
+ this._tracerProvider = undefined;
174
+ this._loggerProvider = undefined;
175
+ this._shutdownHook = undefined;
176
+ this._readyPromise = Promise.resolve();
177
+ return;
178
+ }
179
+ this._internalLogger.info(`Struct SDK initialized: service=${serviceName} endpoint=${this._endpoint} content_capture=${this._contentCapture}`);
180
+ }
181
+ getTracer(name = "struct-sdk") {
182
+ if (!this._tracerProvider) {
183
+ throw new Error("Call struct.init() before using the SDK");
184
+ }
185
+ return this._tracerProvider.getTracer(name);
186
+ }
187
+ getLogger(name = "struct-sdk") {
188
+ if (!this._loggerProvider) {
189
+ throw new Error("Call struct.init() before using the SDK");
190
+ }
191
+ return this._loggerProvider.getLogger(name);
192
+ }
193
+ getInternalLogger() {
194
+ return this._internalLogger;
195
+ }
196
+ /** Test-only: attach a custom span processor to the internal provider. */
197
+ addSpanProcessor(processor) {
198
+ this._tracerProvider?.addSpanProcessor(processor);
199
+ }
200
+ /** Test-only: attach a custom log record processor. */
201
+ addLogRecordProcessor(processor) {
202
+ this._loggerProvider?.addLogRecordProcessor(processor);
203
+ }
204
+ /**
205
+ * Shut down the SDK and flush pending telemetry.
206
+ *
207
+ * Returns within `timeoutMs` (default: SDK init's `shutdownTimeoutMs`,
208
+ * fallback 5000ms). If the ingest endpoint is unreachable, in-flight
209
+ * telemetry may be dropped — the trade-off vs. blocking process exit.
210
+ *
211
+ * In serverless / edge runtimes (Lambda, Vercel, etc.), the runtime does
212
+ * NOT await our `beforeExit` hook. Call `await struct.shutdown()`
213
+ * explicitly before your function returns or before container freeze.
214
+ *
215
+ * Safe to call multiple times. Safe to call on an SDK that failed to init
216
+ * or was never initialized.
217
+ *
218
+ * @param timeoutMs - Override the configured shutdown timeout for this call.
219
+ */
220
+ async shutdown(timeoutMs) {
221
+ const timeout = timeoutMs ?? this._shutdownTimeoutMs;
222
+ if (this._shutdownHook) {
223
+ process.off("beforeExit", this._shutdownHook);
224
+ this._shutdownHook = undefined;
225
+ }
226
+ // Order matches the previous behavior (logger first, tracer second) so
227
+ // any consumer that depended on relative ordering keeps working.
228
+ const flushAll = async () => {
229
+ await this._loggerProvider?.shutdown().catch(() => undefined);
230
+ await this._tracerProvider?.shutdown().catch(() => undefined);
231
+ };
232
+ let timedOut = false;
233
+ const timer = new Promise((resolve) => {
234
+ const handle = setTimeout(() => {
235
+ timedOut = true;
236
+ resolve("timeout");
237
+ }, timeout);
238
+ // Don't keep the event loop alive for this timer — once flushAll
239
+ // resolves, the process is free to exit even though the timer hasn't
240
+ // fired. `unref` is missing on some non-Node timer shims, hence `?.`.
241
+ handle.unref?.();
242
+ });
243
+ const result = await Promise.race([flushAll(), timer]);
244
+ if (timedOut || result === "timeout") {
245
+ // DEBUG-only: atexit context is noisy enough; a WARN here would
246
+ // clutter user stderr for a fault we already handled.
247
+ this._internalLogger.debug(`Struct SDK shutdown timed out after ${timeout}ms (ingest may be unreachable)`);
248
+ }
249
+ }
250
+ /**
251
+ * Run `fn` inside an `invoke_agent` span scope.
252
+ * Matches Python's _AgentContext behavior.
253
+ */
254
+ async agent(options, fn) {
255
+ if (!this._initialized) {
256
+ return await fn();
257
+ }
258
+ const agentName = options.name;
259
+ const sessionId = options.sessionId ?? randomUUID();
260
+ const parentSessionId = getSessionId();
261
+ const tracer = this.getTracer("struct-sdk");
262
+ // Parent the new agent span on the nearest enclosing agent span (if
263
+ // any) so nested `struct.agent()` / `struct.tool()` calls build a
264
+ // single trace tree. Falls back to OTel's active context (which may
265
+ // include the caller's own OTel span), or a fresh trace when there's
266
+ // nothing to hang off. We do NOT rely on the global OTel context
267
+ // manager being installed — the SDK manages its own parent chain via
268
+ // StructContext ALS to stay neutral in multi-tenant OTel setups.
269
+ const parentSpan = getAgentSpan();
270
+ const parentCtx = parentSpan
271
+ ? trace.setSpan(otelContext.active(), parentSpan)
272
+ : otelContext.active();
273
+ // Span creation itself can fail (custom tracer, broken context). If it
274
+ // does, fall through to running `fn` directly so the user's call
275
+ // always runs uninstrumented rather than blowing up on telemetry.
276
+ let span;
277
+ safe(() => {
278
+ span = tracer.startSpan(`invoke_agent ${agentName}`, { kind: SpanKind.INTERNAL }, parentCtx);
279
+ }, "agent.start_span", this._internalLogger);
280
+ if (span === undefined) {
281
+ return await fn();
282
+ }
283
+ const startedSpan = span;
284
+ safe(() => {
285
+ startedSpan.setAttribute(GEN_AI.OPERATION_NAME, "invoke_agent");
286
+ startedSpan.setAttribute(GEN_AI.PROVIDER_NAME, "struct");
287
+ startedSpan.setAttribute(GEN_AI.AGENT_NAME, agentName);
288
+ // gen_ai.agent.id is the stable identifier of the agent
289
+ // DEFINITION. Only set it when the caller provides one — we do
290
+ // not auto-derive it from sessionId (that would conflate agent
291
+ // identity with invocation).
292
+ if (options.agentId) {
293
+ startedSpan.setAttribute(GEN_AI.AGENT_ID, options.agentId);
294
+ }
295
+ if (options.version) {
296
+ startedSpan.setAttribute(GEN_AI.AGENT_VERSION, options.version);
297
+ }
298
+ // gen_ai.conversation.id is the spec-blessed name for
299
+ // session/thread id.
300
+ startedSpan.setAttribute(GEN_AI.CONVERSATION_ID, sessionId);
301
+ if (parentSessionId && parentSessionId !== sessionId) {
302
+ startedSpan.setAttribute(STRUCT.AGENT_PARENT_SESSION_ID, parentSessionId);
303
+ }
304
+ if (options.metadata) {
305
+ for (const [key, value] of Object.entries(options.metadata)) {
306
+ startedSpan.setAttribute(`${STRUCT.METADATA_PREFIX}${key}`, value);
307
+ }
308
+ }
309
+ }, "agent.set_attrs", this._internalLogger);
310
+ return await runWithContext({
311
+ sessionId,
312
+ conversationId: sessionId,
313
+ agentSpan: startedSpan,
314
+ pendingToolCalls: {},
315
+ }, async () => {
316
+ const activeCtx = trace.setSpan(otelContext.active(), startedSpan);
317
+ try {
318
+ const result = await otelContext.with(activeCtx, fn);
319
+ safe(() => startedSpan.setStatus({ code: SpanStatusCode.OK }), "agent.set_ok_status", this._internalLogger);
320
+ return result;
321
+ }
322
+ catch (err) {
323
+ safe(() => recordError(startedSpan, err), "agent.record_error", this._internalLogger);
324
+ throw err;
325
+ }
326
+ finally {
327
+ safe(() => startedSpan.end(), "agent.span_end", this._internalLogger);
328
+ }
329
+ });
330
+ }
331
+ /**
332
+ * Run `fn` inside an `execute_tool` span scope.
333
+ * Matches Python's _ToolContext behavior.
334
+ */
335
+ async tool(options, fn) {
336
+ if (!this._initialized) {
337
+ return await fn();
338
+ }
339
+ const toolName = options.name;
340
+ let toolCallId = options.toolCallId;
341
+ if (!toolCallId) {
342
+ toolCallId = popPendingToolCallId(toolName);
343
+ }
344
+ const tracer = this.getTracer("struct-sdk");
345
+ // Parent on the enclosing agent span (StructContext ALS) so tool spans
346
+ // live under their agent in the same trace. See the comment in
347
+ // `agent()` — we manage our own parent chain rather than depend on the
348
+ // global OTel context manager being registered.
349
+ const parentSpan = getAgentSpan();
350
+ const parentCtx = parentSpan
351
+ ? trace.setSpan(otelContext.active(), parentSpan)
352
+ : otelContext.active();
353
+ // Span creation itself can fail. Fall through to running `fn` so the
354
+ // user's tool call always runs uninstrumented rather than failing
355
+ // because of telemetry.
356
+ let span;
357
+ safe(() => {
358
+ span = tracer.startSpan(`execute_tool ${toolName}`, { kind: SpanKind.INTERNAL }, parentCtx);
359
+ }, "tool.start_span", this._internalLogger);
360
+ if (span === undefined) {
361
+ return await fn();
362
+ }
363
+ const startedSpan = span;
364
+ safe(() => {
365
+ startedSpan.setAttribute(GEN_AI.OPERATION_NAME, "execute_tool");
366
+ startedSpan.setAttribute(GEN_AI.PROVIDER_NAME, "struct");
367
+ startedSpan.setAttribute(GEN_AI.TOOL_NAME, toolName);
368
+ if (toolCallId) {
369
+ startedSpan.setAttribute(GEN_AI.TOOL_CALL_ID, toolCallId);
370
+ }
371
+ const sessionId = getSessionId();
372
+ if (sessionId) {
373
+ startedSpan.setAttribute(GEN_AI.CONVERSATION_ID, sessionId);
374
+ }
375
+ }, "tool.set_attrs", this._internalLogger);
376
+ const activeCtx = trace.setSpan(otelContext.active(), startedSpan);
377
+ try {
378
+ const result = await otelContext.with(activeCtx, fn);
379
+ if (this.captureContent && result !== undefined && result !== null) {
380
+ safe(() => startedSpan.setAttribute(GEN_AI.TOOL_CALL_RESULT, safeJsonStringify(result).slice(0, 8192)), "tool.set_result_attr", this._internalLogger);
381
+ }
382
+ safe(() => startedSpan.setStatus({ code: SpanStatusCode.OK }), "tool.set_ok_status", this._internalLogger);
383
+ return result;
384
+ }
385
+ catch (err) {
386
+ safe(() => recordError(startedSpan, err), "tool.record_error", this._internalLogger);
387
+ throw err;
388
+ }
389
+ finally {
390
+ safe(() => startedSpan.end(), "tool.span_end", this._internalLogger);
391
+ }
392
+ }
393
+ }
394
+ function recordError(span, err) {
395
+ const errorType = err instanceof Error ? err.constructor.name : typeof err;
396
+ const message = err instanceof Error ? err.message : String(err);
397
+ span.setAttribute(ERROR_TYPE, errorType);
398
+ span.setStatus({ code: SpanStatusCode.ERROR, message });
399
+ if (err instanceof Error) {
400
+ span.recordException(err);
401
+ }
402
+ }
403
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1,12 @@
1
+ import { type Logger } from "@opentelemetry/api-logs";
2
+ /**
3
+ * Emit per-message log events for an Anthropic messages.create() call.
4
+ * Port of _emit_message_events from anthropic.py.
5
+ */
6
+ export declare function emitAnthropicMessageEvents(logger: Logger, messages: unknown, system: unknown): void;
7
+ /**
8
+ * Emit a gen_ai.choice LogRecord for an Anthropic response.
9
+ * Port of _emit_choice_event from anthropic.py.
10
+ */
11
+ export declare function emitAnthropicChoiceEvent(logger: Logger, contentBlocks: unknown, stopReason: string | null | undefined): void;
12
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1,99 @@
1
+ import { context as otelContext } from "@opentelemetry/api";
2
+ import { SeverityNumber, } from "@opentelemetry/api-logs";
3
+ import { getSessionId } from "./context.js";
4
+ import { ANTHROPIC_FINISH_REASON_MAP, EVENT_NAME, EVENT_NAMES, GEN_AI, ROLE_TO_EVENT_NAME, } from "./semconv.js";
5
+ import { safeJsonStringify, truncateParts } from "./truncation.js";
6
+ import { contentToParts, } from "./integrations/anthropic-content.js";
7
+ /**
8
+ * Emit a LogRecord with the active span context linked.
9
+ *
10
+ * Follows the OTel logs data model convention:
11
+ * - `body` (log record body) = event tag string (human-readable signal)
12
+ * - `attributes.body` (log record attribute) = JSON-serialised payload
13
+ */
14
+ function emitLogRecord({ logger, eventName, payload, extraAttrs = {}, }) {
15
+ const sessionId = getSessionId();
16
+ const attributes = {
17
+ [EVENT_NAME]: eventName,
18
+ body: payload,
19
+ ...extraAttrs,
20
+ };
21
+ if (sessionId)
22
+ attributes[GEN_AI.CONVERSATION_ID] = sessionId;
23
+ logger.emit({
24
+ body: eventName,
25
+ severityNumber: SeverityNumber.INFO,
26
+ attributes,
27
+ context: otelContext.active(),
28
+ });
29
+ }
30
+ /**
31
+ * Emit per-message log events for an Anthropic messages.create() call.
32
+ * Port of _emit_message_events from anthropic.py.
33
+ */
34
+ export function emitAnthropicMessageEvents(logger, messages, system) {
35
+ if (!Array.isArray(messages))
36
+ return;
37
+ let msgIndex = 0;
38
+ if (system) {
39
+ const parts = typeof system === "string"
40
+ ? [{ type: "text", content: system }]
41
+ : Array.isArray(system)
42
+ ? contentToParts(system)
43
+ : [{ type: "text", content: String(system) }];
44
+ emitLogRecord({
45
+ logger,
46
+ eventName: EVENT_NAMES.SYSTEM_MESSAGE,
47
+ payload: safeJsonStringify({
48
+ role: "system",
49
+ parts: truncateParts(parts),
50
+ }),
51
+ extraAttrs: {
52
+ [GEN_AI.SYSTEM]: "anthropic",
53
+ [GEN_AI.MESSAGE_INDEX]: msgIndex,
54
+ },
55
+ });
56
+ msgIndex++;
57
+ }
58
+ for (const msg of messages) {
59
+ if (!msg || typeof msg !== "object")
60
+ continue;
61
+ const m = msg;
62
+ const role = typeof m.role === "string" ? m.role : "user";
63
+ const parts = contentToParts(m.content);
64
+ const eventName = ROLE_TO_EVENT_NAME[role] ?? `gen_ai.${role}.message`;
65
+ emitLogRecord({
66
+ logger,
67
+ eventName,
68
+ payload: safeJsonStringify({ role, parts: truncateParts(parts) }),
69
+ extraAttrs: {
70
+ [GEN_AI.SYSTEM]: "anthropic",
71
+ [GEN_AI.MESSAGE_INDEX]: msgIndex,
72
+ },
73
+ });
74
+ msgIndex++;
75
+ }
76
+ }
77
+ /**
78
+ * Emit a gen_ai.choice LogRecord for an Anthropic response.
79
+ * Port of _emit_choice_event from anthropic.py.
80
+ */
81
+ export function emitAnthropicChoiceEvent(logger, contentBlocks, stopReason) {
82
+ const parts = contentToParts(contentBlocks);
83
+ const mappedReason = (stopReason && (ANTHROPIC_FINISH_REASON_MAP[stopReason] ?? stopReason)) ||
84
+ "stop";
85
+ const payload = safeJsonStringify({
86
+ index: 0,
87
+ finish_reason: mappedReason,
88
+ message: { role: "assistant", parts: truncateParts(parts) },
89
+ });
90
+ emitLogRecord({
91
+ logger,
92
+ eventName: EVENT_NAMES.CHOICE,
93
+ payload,
94
+ extraAttrs: {
95
+ [GEN_AI.SYSTEM]: "anthropic",
96
+ },
97
+ });
98
+ }
99
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1,6 @@
1
+ import { StructSDK } from "./core.js";
2
+ export { ContentCaptureMode } from "./content-capture.js";
3
+ export type { AgentScopeOptions, InitOptions, InternalLogger, ToolScopeOptions, } from "./core.js";
4
+ export { StructSDK } from "./core.js";
5
+ export declare const struct: StructSDK;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { StructSDK } from "./core.js";
2
+ export { ContentCaptureMode } from "./content-capture.js";
3
+ export { StructSDK } from "./core.js";
4
+ export const struct = new StructSDK();
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,24 @@
1
+ import { truncateField } from "../truncation.js";
2
+ /** Part in the GenAI spec format. */
3
+ export type Part = Record<string, unknown>;
4
+ /**
5
+ * Walk Anthropic response content blocks, return (name, id) pairs for tool_use blocks.
6
+ * Port of _iter_tool_uses from anthropic.py.
7
+ */
8
+ export declare function iterToolUses(blocks: unknown): Array<[string, string]>;
9
+ /**
10
+ * Convert arbitrary content (string | block[] | unknown) → GenAI parts.
11
+ * Port of _content_to_parts from anthropic.py.
12
+ */
13
+ export declare function contentToParts(content: unknown): Part[];
14
+ /** Convert Anthropic message list → GenAI input-messages JSON string. */
15
+ export declare function toInputMessages(messages: unknown): string;
16
+ /** Convert response content blocks → GenAI output-messages JSON string. */
17
+ export declare function toOutputMessages(contentBlocks: unknown, stopReason: string | null | undefined): string;
18
+ /** Convert system prompt (string | block[]) → GenAI system_instructions JSON string. */
19
+ export declare function toSystemInstructions(system: unknown): string;
20
+ export declare function safeJsonForTool(obj: unknown): string;
21
+ /** Extract the last user message's parts for parent-span propagation. */
22
+ export declare function lastUserMessageParts(messages: unknown): Part[] | undefined;
23
+ export { truncateField };
24
+ //# sourceMappingURL=anthropic-content.d.ts.map