@smarter.sh/api 0.0.0-stage → 1.0.1

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 (251) hide show
  1. package/LICENSE.txt +671 -0
  2. package/README.md +193 -2
  3. package/dist/client.d.ts +146 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +178 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/core/config.d.ts +148 -0
  8. package/dist/core/config.d.ts.map +1 -0
  9. package/dist/core/config.js +212 -0
  10. package/dist/core/config.js.map +1 -0
  11. package/dist/core/errors.d.ts +189 -0
  12. package/dist/core/errors.d.ts.map +1 -0
  13. package/dist/core/errors.js +187 -0
  14. package/dist/core/errors.js.map +1 -0
  15. package/dist/core/http.d.ts +207 -0
  16. package/dist/core/http.d.ts.map +1 -0
  17. package/dist/core/http.js +456 -0
  18. package/dist/core/http.js.map +1 -0
  19. package/dist/core/log.d.ts +62 -0
  20. package/dist/core/log.d.ts.map +1 -0
  21. package/dist/core/log.js +68 -0
  22. package/dist/core/log.js.map +1 -0
  23. package/dist/core/sse.d.ts +38 -0
  24. package/dist/core/sse.d.ts.map +1 -0
  25. package/dist/core/sse.js +79 -0
  26. package/dist/core/sse.js.map +1 -0
  27. package/dist/core/typing.d.ts +21 -0
  28. package/dist/core/typing.d.ts.map +1 -0
  29. package/dist/core/typing.js +13 -0
  30. package/dist/core/typing.js.map +1 -0
  31. package/dist/index.d.ts +51 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +51 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/models/account.d.ts +112 -0
  36. package/dist/models/account.d.ts.map +1 -0
  37. package/dist/models/account.js +55 -0
  38. package/dist/models/account.js.map +1 -0
  39. package/dist/models/base.d.ts +99 -0
  40. package/dist/models/base.d.ts.map +1 -0
  41. package/dist/models/base.js +111 -0
  42. package/dist/models/base.js.map +1 -0
  43. package/dist/models/chat.d.ts +2243 -0
  44. package/dist/models/chat.d.ts.map +1 -0
  45. package/dist/models/chat.js +451 -0
  46. package/dist/models/chat.js.map +1 -0
  47. package/dist/models/guardrail.d.ts +109 -0
  48. package/dist/models/guardrail.d.ts.map +1 -0
  49. package/dist/models/guardrail.js +68 -0
  50. package/dist/models/guardrail.js.map +1 -0
  51. package/dist/models/journal.d.ts +159 -0
  52. package/dist/models/journal.d.ts.map +1 -0
  53. package/dist/models/journal.js +115 -0
  54. package/dist/models/journal.js.map +1 -0
  55. package/dist/models/llmclient.d.ts +183 -0
  56. package/dist/models/llmclient.d.ts.map +1 -0
  57. package/dist/models/llmclient.js +105 -0
  58. package/dist/models/llmclient.js.map +1 -0
  59. package/dist/models/llmhost.d.ts +121 -0
  60. package/dist/models/llmhost.d.ts.map +1 -0
  61. package/dist/models/llmhost.js +79 -0
  62. package/dist/models/llmhost.js.map +1 -0
  63. package/dist/models/manifest.d.ts +211 -0
  64. package/dist/models/manifest.d.ts.map +1 -0
  65. package/dist/models/manifest.js +290 -0
  66. package/dist/models/manifest.js.map +1 -0
  67. package/dist/models/mcpclient.d.ts +99 -0
  68. package/dist/models/mcpclient.d.ts.map +1 -0
  69. package/dist/models/mcpclient.js +65 -0
  70. package/dist/models/mcpclient.js.map +1 -0
  71. package/dist/models/misc.d.ts +232 -0
  72. package/dist/models/misc.d.ts.map +1 -0
  73. package/dist/models/misc.js +110 -0
  74. package/dist/models/misc.js.map +1 -0
  75. package/dist/models/platform.d.ts +88 -0
  76. package/dist/models/platform.d.ts.map +1 -0
  77. package/dist/models/platform.js +35 -0
  78. package/dist/models/platform.js.map +1 -0
  79. package/dist/models/plugin.d.ts +36 -0
  80. package/dist/models/plugin.d.ts.map +1 -0
  81. package/dist/models/plugin.js +16 -0
  82. package/dist/models/plugin.js.map +1 -0
  83. package/dist/models/react.d.ts +104 -0
  84. package/dist/models/react.d.ts.map +1 -0
  85. package/dist/models/react.js +136 -0
  86. package/dist/models/react.js.map +1 -0
  87. package/dist/models/sam/account.d.ts +155 -0
  88. package/dist/models/sam/account.d.ts.map +1 -0
  89. package/dist/models/sam/account.js +7 -0
  90. package/dist/models/sam/account.js.map +1 -0
  91. package/dist/models/sam/apiconnection.d.ts +147 -0
  92. package/dist/models/sam/apiconnection.d.ts.map +1 -0
  93. package/dist/models/sam/apiconnection.js +7 -0
  94. package/dist/models/sam/apiconnection.js.map +1 -0
  95. package/dist/models/sam/apiplugin.d.ts +278 -0
  96. package/dist/models/sam/apiplugin.d.ts.map +1 -0
  97. package/dist/models/sam/apiplugin.js +7 -0
  98. package/dist/models/sam/apiplugin.js.map +1 -0
  99. package/dist/models/sam/budget.d.ts +219 -0
  100. package/dist/models/sam/budget.d.ts.map +1 -0
  101. package/dist/models/sam/budget.js +7 -0
  102. package/dist/models/sam/budget.js.map +1 -0
  103. package/dist/models/sam/customdomain.d.ts +139 -0
  104. package/dist/models/sam/customdomain.d.ts.map +1 -0
  105. package/dist/models/sam/customdomain.js +7 -0
  106. package/dist/models/sam/customdomain.js.map +1 -0
  107. package/dist/models/sam/guardrail.d.ts +222 -0
  108. package/dist/models/sam/guardrail.d.ts.map +1 -0
  109. package/dist/models/sam/guardrail.js +7 -0
  110. package/dist/models/sam/guardrail.js.map +1 -0
  111. package/dist/models/sam/imagesearchplugin.d.ts +235 -0
  112. package/dist/models/sam/imagesearchplugin.d.ts.map +1 -0
  113. package/dist/models/sam/imagesearchplugin.js +7 -0
  114. package/dist/models/sam/imagesearchplugin.js.map +1 -0
  115. package/dist/models/sam/index.d.ts +104 -0
  116. package/dist/models/sam/index.d.ts.map +1 -0
  117. package/dist/models/sam/index.js +50 -0
  118. package/dist/models/sam/index.js.map +1 -0
  119. package/dist/models/sam/llmclient.d.ts +490 -0
  120. package/dist/models/sam/llmclient.d.ts.map +1 -0
  121. package/dist/models/sam/llmclient.js +7 -0
  122. package/dist/models/sam/llmclient.js.map +1 -0
  123. package/dist/models/sam/llmhost.d.ts +429 -0
  124. package/dist/models/sam/llmhost.d.ts.map +1 -0
  125. package/dist/models/sam/llmhost.js +7 -0
  126. package/dist/models/sam/llmhost.js.map +1 -0
  127. package/dist/models/sam/llmhostcompute.d.ts +221 -0
  128. package/dist/models/sam/llmhostcompute.d.ts.map +1 -0
  129. package/dist/models/sam/llmhostcompute.js +7 -0
  130. package/dist/models/sam/llmhostcompute.js.map +1 -0
  131. package/dist/models/sam/mcpclient.d.ts +195 -0
  132. package/dist/models/sam/mcpclient.d.ts.map +1 -0
  133. package/dist/models/sam/mcpclient.js +7 -0
  134. package/dist/models/sam/mcpclient.js.map +1 -0
  135. package/dist/models/sam/orchestrator.d.ts +163 -0
  136. package/dist/models/sam/orchestrator.d.ts.map +1 -0
  137. package/dist/models/sam/orchestrator.js +7 -0
  138. package/dist/models/sam/orchestrator.js.map +1 -0
  139. package/dist/models/sam/plugin.d.ts +163 -0
  140. package/dist/models/sam/plugin.d.ts.map +1 -0
  141. package/dist/models/sam/plugin.js +7 -0
  142. package/dist/models/sam/plugin.js.map +1 -0
  143. package/dist/models/sam/prompt.d.ts +116 -0
  144. package/dist/models/sam/prompt.d.ts.map +1 -0
  145. package/dist/models/sam/prompt.js +7 -0
  146. package/dist/models/sam/prompt.js.map +1 -0
  147. package/dist/models/sam/provider.d.ts +195 -0
  148. package/dist/models/sam/provider.d.ts.map +1 -0
  149. package/dist/models/sam/provider.js +7 -0
  150. package/dist/models/sam/provider.js.map +1 -0
  151. package/dist/models/sam/proxy.d.ts +163 -0
  152. package/dist/models/sam/proxy.d.ts.map +1 -0
  153. package/dist/models/sam/proxy.js +7 -0
  154. package/dist/models/sam/proxy.js.map +1 -0
  155. package/dist/models/sam/schemas.d.ts +8 -0
  156. package/dist/models/sam/schemas.d.ts.map +1 -0
  157. package/dist/models/sam/schemas.js +6059 -0
  158. package/dist/models/sam/schemas.js.map +1 -0
  159. package/dist/models/sam/secret.d.ts +123 -0
  160. package/dist/models/sam/secret.d.ts.map +1 -0
  161. package/dist/models/sam/secret.js +7 -0
  162. package/dist/models/sam/secret.js.map +1 -0
  163. package/dist/models/sam/skillplugin.d.ts +181 -0
  164. package/dist/models/sam/skillplugin.d.ts.map +1 -0
  165. package/dist/models/sam/skillplugin.js +7 -0
  166. package/dist/models/sam/skillplugin.js.map +1 -0
  167. package/dist/models/sam/smarterauthtoken.d.ts +115 -0
  168. package/dist/models/sam/smarterauthtoken.d.ts.map +1 -0
  169. package/dist/models/sam/smarterauthtoken.js +7 -0
  170. package/dist/models/sam/smarterauthtoken.js.map +1 -0
  171. package/dist/models/sam/sqlconnection.d.ts +187 -0
  172. package/dist/models/sam/sqlconnection.d.ts.map +1 -0
  173. package/dist/models/sam/sqlconnection.js +7 -0
  174. package/dist/models/sam/sqlconnection.js.map +1 -0
  175. package/dist/models/sam/sqlplugin.d.ts +232 -0
  176. package/dist/models/sam/sqlplugin.d.ts.map +1 -0
  177. package/dist/models/sam/sqlplugin.js +7 -0
  178. package/dist/models/sam/sqlplugin.js.map +1 -0
  179. package/dist/models/sam/user.d.ts +135 -0
  180. package/dist/models/sam/user.d.ts.map +1 -0
  181. package/dist/models/sam/user.js +7 -0
  182. package/dist/models/sam/user.js.map +1 -0
  183. package/dist/models/sam/vectorsearch.d.ts +150 -0
  184. package/dist/models/sam/vectorsearch.d.ts.map +1 -0
  185. package/dist/models/sam/vectorsearch.js +7 -0
  186. package/dist/models/sam/vectorsearch.js.map +1 -0
  187. package/dist/models/sam/vectorstore.d.ts +291 -0
  188. package/dist/models/sam/vectorstore.d.ts.map +1 -0
  189. package/dist/models/sam/vectorstore.js +7 -0
  190. package/dist/models/sam/vectorstore.js.map +1 -0
  191. package/dist/models/sam/websearchplugin.d.ts +229 -0
  192. package/dist/models/sam/websearchplugin.d.ts.map +1 -0
  193. package/dist/models/sam/websearchplugin.js +7 -0
  194. package/dist/models/sam/websearchplugin.js.map +1 -0
  195. package/dist/models/vectorstore.d.ts +165 -0
  196. package/dist/models/vectorstore.d.ts.map +1 -0
  197. package/dist/models/vectorstore.js +90 -0
  198. package/dist/models/vectorstore.js.map +1 -0
  199. package/dist/resources/accounts.d.ts +107 -0
  200. package/dist/resources/accounts.d.ts.map +1 -0
  201. package/dist/resources/accounts.js +84 -0
  202. package/dist/resources/accounts.js.map +1 -0
  203. package/dist/resources/base.d.ts +127 -0
  204. package/dist/resources/base.d.ts.map +1 -0
  205. package/dist/resources/base.js +139 -0
  206. package/dist/resources/base.js.map +1 -0
  207. package/dist/resources/catalog.d.ts +209 -0
  208. package/dist/resources/catalog.d.ts.map +1 -0
  209. package/dist/resources/catalog.js +124 -0
  210. package/dist/resources/catalog.js.map +1 -0
  211. package/dist/resources/guardrails.d.ts +82 -0
  212. package/dist/resources/guardrails.d.ts.map +1 -0
  213. package/dist/resources/guardrails.js +46 -0
  214. package/dist/resources/guardrails.js.map +1 -0
  215. package/dist/resources/history.d.ts +97 -0
  216. package/dist/resources/history.d.ts.map +1 -0
  217. package/dist/resources/history.js +109 -0
  218. package/dist/resources/history.js.map +1 -0
  219. package/dist/resources/llmclients.d.ts +348 -0
  220. package/dist/resources/llmclients.d.ts.map +1 -0
  221. package/dist/resources/llmclients.js +367 -0
  222. package/dist/resources/llmclients.js.map +1 -0
  223. package/dist/resources/llmhosts.d.ts +146 -0
  224. package/dist/resources/llmhosts.d.ts.map +1 -0
  225. package/dist/resources/llmhosts.js +128 -0
  226. package/dist/resources/llmhosts.js.map +1 -0
  227. package/dist/resources/manifests.d.ts +153 -0
  228. package/dist/resources/manifests.d.ts.map +1 -0
  229. package/dist/resources/manifests.js +203 -0
  230. package/dist/resources/manifests.js.map +1 -0
  231. package/dist/resources/mcpclients.d.ts +90 -0
  232. package/dist/resources/mcpclients.d.ts.map +1 -0
  233. package/dist/resources/mcpclients.js +57 -0
  234. package/dist/resources/mcpclients.js.map +1 -0
  235. package/dist/resources/providers.d.ts +33 -0
  236. package/dist/resources/providers.d.ts.map +1 -0
  237. package/dist/resources/providers.js +39 -0
  238. package/dist/resources/providers.js.map +1 -0
  239. package/dist/resources/proxies.d.ts +61 -0
  240. package/dist/resources/proxies.d.ts.map +1 -0
  241. package/dist/resources/proxies.js +57 -0
  242. package/dist/resources/proxies.js.map +1 -0
  243. package/dist/resources/vectorstores.d.ts +194 -0
  244. package/dist/resources/vectorstores.d.ts.map +1 -0
  245. package/dist/resources/vectorstores.js +200 -0
  246. package/dist/resources/vectorstores.js.map +1 -0
  247. package/dist/version.d.ts +3 -0
  248. package/dist/version.d.ts.map +1 -0
  249. package/dist/version.js +5 -0
  250. package/dist/version.js.map +1 -0
  251. package/package.json +81 -4
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Proxies: authenticated passthrough access to LLM providers' own apis.
3
+ *
4
+ * The platform holds the provider's api key, and callers use their Smarter api key instead. The
5
+ * easiest way to call a proxy is with the provider's own SDK:
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import OpenAI from "openai";
10
+ * import { Smarter } from "@smarter.sh/api";
11
+ *
12
+ * const smarter = new Smarter();
13
+ * const openai = new OpenAI({ baseURL: smarter.proxies.baseUrl("openai"), apiKey: smarter.apiKey });
14
+ * ```
15
+ */
16
+ import type { QueryParamValue, RequestOptions } from "../core/http.ts";
17
+ import { JsonValue } from "../core/typing.ts";
18
+ import { type Proxy } from "../models/misc.ts";
19
+ import { SmarterAPIResource } from "./base.ts";
20
+ /** The options of a proxied request, beside the per-request options. */
21
+ export interface ProxyRequestOptions extends RequestOptions {
22
+ /** The http method, `POST` by default. */
23
+ method?: string;
24
+ /** The JSON body, as the provider's api expects it. */
25
+ json?: JsonValue;
26
+ /** Query parameters. */
27
+ params?: Record<string, QueryParamValue>;
28
+ }
29
+ /**
30
+ * Proxies: `/api/v1/proxy/`.
31
+ *
32
+ * The platform serves these endpoints only when `SMARTER_ENABLE_PROXY` is true.
33
+ */
34
+ export declare class Proxies extends SmarterAPIResource {
35
+ /** The proxies' endpoint. */
36
+ readonly path = "proxy/";
37
+ /**
38
+ * The proxies that the user may call.
39
+ *
40
+ * @param options - Per-request options.
41
+ * @returns The proxies.
42
+ */
43
+ list(options?: RequestOptions): Promise<Proxy[]>;
44
+ /**
45
+ * A proxy's base url, for the provider's own SDK.
46
+ *
47
+ * @param name - The proxy's name, e.g. `openai`.
48
+ * @returns e.g. `https://platform.smarter.sh/api/v1/proxy/openai/`.
49
+ */
50
+ baseUrl(name: string): string;
51
+ /**
52
+ * Send a request to a provider's api, through its proxy.
53
+ *
54
+ * @param name - The proxy's name, e.g. `openai`.
55
+ * @param path - The provider api's path, e.g. `v1/chat/completions`. It must be one of the proxy's `allowedPaths`.
56
+ * @param options - `method`, `json` and `params`.
57
+ * @returns The provider's JSON response, or undefined for an empty response.
58
+ */
59
+ request(name: string, path: string, options?: ProxyRequestOptions): Promise<JsonValue | undefined>;
60
+ }
61
+ //# sourceMappingURL=proxies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxies.d.ts","sourceRoot":"","sources":["../../src/resources/proxies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAa,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAc,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE3D,wEAAwE;AACxE,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,wBAAwB;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC1C;AAED;;;;GAIG;AACH,qBAAa,OAAQ,SAAQ,kBAAkB;IAC7C,6BAA6B;IAC7B,QAAQ,CAAC,IAAI,YAAY;IAEzB;;;;;OAKG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAItD;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI7B;;;;;;;OAOG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;CAQzG"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Proxies: authenticated passthrough access to LLM providers' own apis.
3
+ *
4
+ * The platform holds the provider's api key, and callers use their Smarter api key instead. The
5
+ * easiest way to call a proxy is with the provider's own SDK:
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import OpenAI from "openai";
10
+ * import { Smarter } from "@smarter.sh/api";
11
+ *
12
+ * const smarter = new Smarter();
13
+ * const openai = new OpenAI({ baseURL: smarter.proxies.baseUrl("openai"), apiKey: smarter.apiKey });
14
+ * ```
15
+ */
16
+ import { JsonValue } from "../core/typing.js";
17
+ import { ProxyList } from "../models/misc.js";
18
+ import { resourceId, SmarterAPIResource } from "./base.js";
19
+ /**
20
+ * Proxies: `/api/v1/proxy/`.
21
+ *
22
+ * The platform serves these endpoints only when `SMARTER_ENABLE_PROXY` is true.
23
+ */
24
+ export class Proxies extends SmarterAPIResource {
25
+ /** The proxies' endpoint. */
26
+ path = "proxy/";
27
+ /**
28
+ * The proxies that the user may call.
29
+ *
30
+ * @param options - Per-request options.
31
+ * @returns The proxies.
32
+ */
33
+ async list(options) {
34
+ return (await this.http.request("GET", this.path, ProxyList, options)).proxies;
35
+ }
36
+ /**
37
+ * A proxy's base url, for the provider's own SDK.
38
+ *
39
+ * @param name - The proxy's name, e.g. `openai`.
40
+ * @returns e.g. `https://platform.smarter.sh/api/v1/proxy/openai/`.
41
+ */
42
+ baseUrl(name) {
43
+ return this.http.url(`${this.path}${resourceId(name)}/`);
44
+ }
45
+ /**
46
+ * Send a request to a provider's api, through its proxy.
47
+ *
48
+ * @param name - The proxy's name, e.g. `openai`.
49
+ * @param path - The provider api's path, e.g. `v1/chat/completions`. It must be one of the proxy's `allowedPaths`.
50
+ * @param options - `method`, `json` and `params`.
51
+ * @returns The provider's JSON response, or undefined for an empty response.
52
+ */
53
+ async request(name, path, options) {
54
+ return this.http.request((options?.method ?? "POST").toUpperCase(), `${this.path}${resourceId(name)}/${path.replace(/^\/+/, "")}`, JsonValue.optional(), options);
55
+ }
56
+ }
57
+ //# sourceMappingURL=proxies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxies.js","sourceRoot":"","sources":["../../src/resources/proxies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAc,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAY3D;;;;GAIG;AACH,MAAM,OAAO,OAAQ,SAAQ,kBAAkB;IAC7C,6BAA6B;IACpB,IAAI,GAAG,QAAQ,CAAC;IAEzB;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CAAC,OAAwB;QACjC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IACjF,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,IAAY;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,IAAY,EAAE,OAA6B;QACrE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACtB,CAAC,OAAO,EAAE,MAAM,IAAI,MAAM,CAAC,CAAC,WAAW,EAAE,EACzC,GAAG,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,EAC7D,SAAS,CAAC,QAAQ,EAAE,EACpB,OAAO,CACR,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Vectorstores: vector databases for retrieval-augmented generation.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * await client.vectorstores.addText(2, "Our refund window is 30 days.", { name: "refunds" });
7
+ * await client.vectorstores.addFiles(2, ["handbook.pdf"]);
8
+ * for (const result of (await client.vectorstores.search(2, "How long is the refund window?")).results) {
9
+ * console.log(result.score, result.text);
10
+ * }
11
+ * ```
12
+ */
13
+ import type { RequestOptions } from "../core/http.ts";
14
+ import type { JsonValue, SmarterId } from "../core/typing.ts";
15
+ import { Vectorstore, VectorstoreDocumentDeleted, VectorstoreDocuments, VectorstoreDocumentsAdded, VectorstoreRestored, VectorstoreSearchResults, VectorstoreSnapshot, VectorstoreSnapshots, VectorstoreStatus } from "../models/vectorstore.ts";
16
+ import { SmarterKindResource } from "./base.ts";
17
+ /** How a vectorstore search ranks chunks. */
18
+ export type VectorstoreSearchType = "similarity" | "mmr" | "similarity_score_threshold";
19
+ /** The options of a vectorstore search, beside the per-request options. */
20
+ export interface VectorstoreSearchOptions extends RequestOptions {
21
+ /** How many chunks to return, 4 by default. The platform caps it. */
22
+ k?: number;
23
+ /** `similarity` (the default), `mmr` (maximal marginal relevance), or `similarity_score_threshold`. */
24
+ searchType?: VectorstoreSearchType;
25
+ /** The minimum score, for `similarity_score_threshold`. */
26
+ scoreThreshold?: number | null;
27
+ /** How many chunks `mmr` considers. */
28
+ fetchK?: number | null;
29
+ /** `mmr`'s balance of relevance (1) and diversity (0). */
30
+ lambdaMult?: number | null;
31
+ /** Only chunks whose metadata match. */
32
+ filter?: Record<string, JsonValue> | null;
33
+ }
34
+ /** A file to upload: its path, its `file:` url, or a `File`. */
35
+ export type UploadInput = string | URL | File;
36
+ /**
37
+ * Vectorstores: `/api/v1/vectorstores/`, and the manifest api's `Vectorstore` kind.
38
+ *
39
+ * The platform serves these endpoints only when `SMARTER_ENABLE_VECTORSTORE` is true.
40
+ */
41
+ export declare class Vectorstores extends SmarterKindResource<typeof Vectorstore> {
42
+ readonly kind = "Vectorstore";
43
+ readonly path = "vectorstores/";
44
+ readonly model: import("zod").ZodObject<{
45
+ id: import("zod").ZodNumber;
46
+ hashedId: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
47
+ name: import("zod").ZodString;
48
+ description: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
49
+ version: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
50
+ tags: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
51
+ annotations: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>, unknown>>>;
52
+ createdAt: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
53
+ updatedAt: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
54
+ userProfile: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodObject<{
55
+ user: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodObject<{
56
+ username: import("zod").ZodString;
57
+ email: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
58
+ }, import("zod/v4/core").$loose>>>;
59
+ account: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodObject<{
60
+ accountNumber: import("zod").ZodString;
61
+ }, import("zod/v4/core").$loose>>>;
62
+ }, import("zod/v4/core").$loose>>>;
63
+ canDelete: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodBoolean>>;
64
+ manifestUrl: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
65
+ detailUrl: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
66
+ ready: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodBoolean>>;
67
+ backend: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
68
+ hosting: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
69
+ isActive: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodBoolean>>;
70
+ dimension: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
71
+ metric: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
72
+ embeddingsProvider: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
73
+ embeddingsModel: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
74
+ status: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
75
+ statusMessage: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
76
+ indexName: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
77
+ endpointUrl: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
78
+ vectorCount: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
79
+ documentCount: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
80
+ snapshotCount: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
81
+ spec: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodType<import("../core/typing.ts").JsonObject, unknown, import("zod/v4/core").$ZodTypeInternals<import("../core/typing.ts").JsonObject, unknown>>>>;
82
+ deployedAt: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
83
+ }, import("zod/v4/core").$loose>;
84
+ /**
85
+ * A vectorstore's state, checked now.
86
+ *
87
+ * @param id - The vectorstore's id or hashed id.
88
+ * @param options - Per-request options.
89
+ * @returns Its status and vector count.
90
+ */
91
+ status(id: SmarterId, options?: RequestOptions): Promise<VectorstoreStatus>;
92
+ /**
93
+ * Deploy a vectorstore: create its database, or connect to the provider's.
94
+ *
95
+ * A self-hosted vectorstore creates real, possibly billable, Kubernetes resources.
96
+ *
97
+ * @param id - The vectorstore's id or hashed id.
98
+ * @param options - Per-request options.
99
+ * @returns The vectorstore.
100
+ */
101
+ deploy(id: SmarterId, options?: RequestOptions): Promise<Vectorstore>;
102
+ /**
103
+ * Stop serving a vectorstore. A self-hosted server's data is kept.
104
+ *
105
+ * @param id - The vectorstore's id or hashed id.
106
+ * @param options - Per-request options.
107
+ * @returns The vectorstore.
108
+ */
109
+ undeploy(id: SmarterId, options?: RequestOptions): Promise<Vectorstore>;
110
+ /**
111
+ * A vectorstore's documents, newest first.
112
+ *
113
+ * @param id - The vectorstore's id or hashed id.
114
+ * @param options - Per-request options.
115
+ * @returns The documents.
116
+ */
117
+ documents(id: SmarterId, options?: RequestOptions): Promise<VectorstoreDocuments>;
118
+ /**
119
+ * Add a text as a document.
120
+ *
121
+ * @param id - The vectorstore's id or hashed id.
122
+ * @param text - The text.
123
+ * @param options - `name`: the document's name. `metadata`: a JSON object, stored with each of the document's chunks.
124
+ * @returns The added document. It is loaded asynchronously, once the vectorstore is deployed.
125
+ */
126
+ addText(id: SmarterId, text: string, options?: RequestOptions & {
127
+ name?: string | null;
128
+ metadata?: Record<string, JsonValue> | null;
129
+ }): Promise<VectorstoreDocumentsAdded>;
130
+ /**
131
+ * Add a public web page or file, by its url, as a document. The platform fetches it.
132
+ *
133
+ * @param id - The vectorstore's id or hashed id.
134
+ * @param url - The url.
135
+ * @param options - `metadata`: a JSON object, stored with each of the document's chunks.
136
+ * @returns The added document.
137
+ */
138
+ addUrl(id: SmarterId, url: string, options?: RequestOptions & {
139
+ metadata?: Record<string, JsonValue> | null;
140
+ }): Promise<VectorstoreDocumentsAdded>;
141
+ /**
142
+ * Upload files as documents, e.g. PDF, Word, HTML or text files. The platform extracts their text.
143
+ *
144
+ * @param id - The vectorstore's id or hashed id.
145
+ * @param files - The files: paths, `file:` urls, or `File` objects.
146
+ * @param options - Per-request options.
147
+ * @returns The added documents.
148
+ */
149
+ addFiles(id: SmarterId, files: readonly UploadInput[], options?: RequestOptions): Promise<VectorstoreDocumentsAdded>;
150
+ /**
151
+ * Remove a document and its chunks. The removal is asynchronous.
152
+ *
153
+ * @param id - The vectorstore's id or hashed id.
154
+ * @param documentId - The document's id.
155
+ * @param options - Per-request options.
156
+ * @returns The document, being deleted.
157
+ */
158
+ deleteDocument(id: SmarterId, documentId: number, options?: RequestOptions): Promise<VectorstoreDocumentDeleted>;
159
+ /**
160
+ * Search a vectorstore.
161
+ *
162
+ * @param id - The vectorstore's id or hashed id.
163
+ * @param query - The search text.
164
+ * @param options - `k`, `searchType`, `scoreThreshold`, `fetchK`, `lambdaMult` and `filter`.
165
+ * @returns The matching chunks, best first.
166
+ */
167
+ search(id: SmarterId, query: string, options?: VectorstoreSearchOptions): Promise<VectorstoreSearchResults>;
168
+ /**
169
+ * A vectorstore's snapshots.
170
+ *
171
+ * @param id - The vectorstore's id or hashed id.
172
+ * @param options - Per-request options.
173
+ * @returns The snapshots.
174
+ */
175
+ snapshots(id: SmarterId, options?: RequestOptions): Promise<VectorstoreSnapshots>;
176
+ /**
177
+ * Take a snapshot of a vectorstore's data now.
178
+ *
179
+ * @param id - The vectorstore's id or hashed id.
180
+ * @param options - Per-request options.
181
+ * @returns The snapshot.
182
+ */
183
+ createSnapshot(id: SmarterId, options?: RequestOptions): Promise<VectorstoreSnapshot>;
184
+ /**
185
+ * Replace a vectorstore's data with one of its snapshots.
186
+ *
187
+ * @param id - The vectorstore's id or hashed id.
188
+ * @param snapshotId - The snapshot's id.
189
+ * @param options - Per-request options.
190
+ * @returns The restored vector count.
191
+ */
192
+ restore(id: SmarterId, snapshotId: number, options?: RequestOptions): Promise<VectorstoreRestored>;
193
+ }
194
+ //# sourceMappingURL=vectorstores.d.ts.map
@@ -0,0 +1 @@
1
+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AS,EACb,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,0BAA0B,CAAC;IAStC;;;;;;;OAOG;IACG,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAmBjH;;;;;;OAMG;IACG,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIvF;;;;;;OAMG;IACG,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI3F;;;;;;;OAOG;IACG,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAQzG"}
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Vectorstores: vector databases for retrieval-augmented generation.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * await client.vectorstores.addText(2, "Our refund window is 30 days.", { name: "refunds" });
7
+ * await client.vectorstores.addFiles(2, ["handbook.pdf"]);
8
+ * for (const result of (await client.vectorstores.search(2, "How long is the refund window?")).results) {
9
+ * console.log(result.score, result.text);
10
+ * }
11
+ * ```
12
+ */
13
+ import { openAsBlob } from "node:fs";
14
+ import { basename } from "node:path";
15
+ import { fileURLToPath } from "node:url";
16
+ import { Vectorstore, VectorstoreDocumentDeleted, VectorstoreDocuments, VectorstoreDocumentsAdded, VectorstoreRestored, VectorstoreSearchResults, VectorstoreSnapshot, VectorstoreSnapshots, VectorstoreStatus, } from "../models/vectorstore.js";
17
+ import { resourceId, SmarterKindResource } from "./base.js";
18
+ /**
19
+ * Vectorstores: `/api/v1/vectorstores/`, and the manifest api's `Vectorstore` kind.
20
+ *
21
+ * The platform serves these endpoints only when `SMARTER_ENABLE_VECTORSTORE` is true.
22
+ */
23
+ export class Vectorstores extends SmarterKindResource {
24
+ kind = "Vectorstore";
25
+ path = "vectorstores/";
26
+ model = Vectorstore;
27
+ /**
28
+ * A vectorstore's state, checked now.
29
+ *
30
+ * @param id - The vectorstore's id or hashed id.
31
+ * @param options - Per-request options.
32
+ * @returns Its status and vector count.
33
+ */
34
+ async status(id, options) {
35
+ return this.http.request("GET", `${this.path}${resourceId(id)}/status/`, VectorstoreStatus, options);
36
+ }
37
+ /**
38
+ * Deploy a vectorstore: create its database, or connect to the provider's.
39
+ *
40
+ * A self-hosted vectorstore creates real, possibly billable, Kubernetes resources.
41
+ *
42
+ * @param id - The vectorstore's id or hashed id.
43
+ * @param options - Per-request options.
44
+ * @returns The vectorstore.
45
+ */
46
+ async deploy(id, options) {
47
+ return this.http.request("POST", `${this.path}${resourceId(id)}/deploy/`, Vectorstore, options);
48
+ }
49
+ /**
50
+ * Stop serving a vectorstore. A self-hosted server's data is kept.
51
+ *
52
+ * @param id - The vectorstore's id or hashed id.
53
+ * @param options - Per-request options.
54
+ * @returns The vectorstore.
55
+ */
56
+ async undeploy(id, options) {
57
+ return this.http.request("POST", `${this.path}${resourceId(id)}/undeploy/`, Vectorstore, options);
58
+ }
59
+ /**
60
+ * A vectorstore's documents, newest first.
61
+ *
62
+ * @param id - The vectorstore's id or hashed id.
63
+ * @param options - Per-request options.
64
+ * @returns The documents.
65
+ */
66
+ async documents(id, options) {
67
+ return this.http.request("GET", `${this.path}${resourceId(id)}/documents/`, VectorstoreDocuments, options);
68
+ }
69
+ /**
70
+ * Add a text as a document.
71
+ *
72
+ * @param id - The vectorstore's id or hashed id.
73
+ * @param text - The text.
74
+ * @param options - `name`: the document's name. `metadata`: a JSON object, stored with each of the document's chunks.
75
+ * @returns The added document. It is loaded asynchronously, once the vectorstore is deployed.
76
+ */
77
+ async addText(id, text, options) {
78
+ const body = { text };
79
+ if (options?.name)
80
+ body["name"] = options.name;
81
+ if (options?.metadata)
82
+ body["metadata"] = options.metadata;
83
+ return this.http.request("POST", `${this.path}${resourceId(id)}/documents/`, VectorstoreDocumentsAdded, {
84
+ ...options,
85
+ json: body,
86
+ });
87
+ }
88
+ /**
89
+ * Add a public web page or file, by its url, as a document. The platform fetches it.
90
+ *
91
+ * @param id - The vectorstore's id or hashed id.
92
+ * @param url - The url.
93
+ * @param options - `metadata`: a JSON object, stored with each of the document's chunks.
94
+ * @returns The added document.
95
+ */
96
+ async addUrl(id, url, options) {
97
+ const body = { url };
98
+ if (options?.metadata)
99
+ body["metadata"] = options.metadata;
100
+ return this.http.request("POST", `${this.path}${resourceId(id)}/documents/`, VectorstoreDocumentsAdded, {
101
+ ...options,
102
+ json: body,
103
+ });
104
+ }
105
+ /**
106
+ * Upload files as documents, e.g. PDF, Word, HTML or text files. The platform extracts their text.
107
+ *
108
+ * @param id - The vectorstore's id or hashed id.
109
+ * @param files - The files: paths, `file:` urls, or `File` objects.
110
+ * @param options - Per-request options.
111
+ * @returns The added documents.
112
+ */
113
+ async addFiles(id, files, options) {
114
+ const form = new FormData();
115
+ for (const file of files) {
116
+ if (file instanceof File) {
117
+ form.append("files", file, file.name);
118
+ }
119
+ else {
120
+ const path = file instanceof URL ? fileURLToPath(file) : file;
121
+ form.append("files", await openAsBlob(path), basename(path));
122
+ }
123
+ }
124
+ return this.http.request("POST", `${this.path}${resourceId(id)}/documents/`, VectorstoreDocumentsAdded, {
125
+ ...options,
126
+ body: form,
127
+ });
128
+ }
129
+ /**
130
+ * Remove a document and its chunks. The removal is asynchronous.
131
+ *
132
+ * @param id - The vectorstore's id or hashed id.
133
+ * @param documentId - The document's id.
134
+ * @param options - Per-request options.
135
+ * @returns The document, being deleted.
136
+ */
137
+ async deleteDocument(id, documentId, options) {
138
+ return this.http.request("DELETE", `${this.path}${resourceId(id)}/documents/${resourceId(documentId)}/`, VectorstoreDocumentDeleted, options);
139
+ }
140
+ /**
141
+ * Search a vectorstore.
142
+ *
143
+ * @param id - The vectorstore's id or hashed id.
144
+ * @param query - The search text.
145
+ * @param options - `k`, `searchType`, `scoreThreshold`, `fetchK`, `lambdaMult` and `filter`.
146
+ * @returns The matching chunks, best first.
147
+ */
148
+ async search(id, query, options) {
149
+ const body = {
150
+ query,
151
+ k: options?.k ?? 4,
152
+ searchType: options?.searchType ?? "similarity",
153
+ };
154
+ const optional = {
155
+ scoreThreshold: options?.scoreThreshold ?? undefined,
156
+ fetchK: options?.fetchK ?? undefined,
157
+ lambdaMult: options?.lambdaMult ?? undefined,
158
+ filter: options?.filter && Object.keys(options.filter).length > 0 ? options.filter : undefined,
159
+ };
160
+ for (const [key, value] of Object.entries(optional))
161
+ if (value !== undefined)
162
+ body[key] = value;
163
+ return this.http.request("POST", `${this.path}${resourceId(id)}/search/`, VectorstoreSearchResults, {
164
+ ...options,
165
+ json: body,
166
+ });
167
+ }
168
+ /**
169
+ * A vectorstore's snapshots.
170
+ *
171
+ * @param id - The vectorstore's id or hashed id.
172
+ * @param options - Per-request options.
173
+ * @returns The snapshots.
174
+ */
175
+ async snapshots(id, options) {
176
+ return this.http.request("GET", `${this.path}${resourceId(id)}/snapshots/`, VectorstoreSnapshots, options);
177
+ }
178
+ /**
179
+ * Take a snapshot of a vectorstore's data now.
180
+ *
181
+ * @param id - The vectorstore's id or hashed id.
182
+ * @param options - Per-request options.
183
+ * @returns The snapshot.
184
+ */
185
+ async createSnapshot(id, options) {
186
+ return this.http.request("POST", `${this.path}${resourceId(id)}/snapshots/`, VectorstoreSnapshot, options);
187
+ }
188
+ /**
189
+ * Replace a vectorstore's data with one of its snapshots.
190
+ *
191
+ * @param id - The vectorstore's id or hashed id.
192
+ * @param snapshotId - The snapshot's id.
193
+ * @param options - Per-request options.
194
+ * @returns The restored vector count.
195
+ */
196
+ async restore(id, snapshotId, options) {
197
+ return this.http.request("POST", `${this.path}${resourceId(id)}/snapshots/${resourceId(snapshotId)}/restore/`, VectorstoreRestored, options);
198
+ }
199
+ }
200
+ //# sourceMapping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AO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC,aAAa,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;IAC7G,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CAAC,EAAa,EAAE,UAAkB,EAAE,OAAwB;QACvE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACtB,MAAM,EACN,GAAG,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC,cAAc,UAAU,CAAC,UAAU,CAAC,WAAW,EAC5E,mBAAmB,EACnB,OAAO,CACR,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ /** The SDK's version. */
2
+ export declare const VERSION = "1.0.1";
3
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAEA,yBAAyB;AACzB,eAAO,MAAM,OAAO,UAAU,CAAC"}
@@ -0,0 +1,5 @@
1
+ // DO NOT EDIT.
2
+ // Managed via automated CI/CD in release.config.js.
3
+ /** The SDK's version. */
4
+ export const VERSION = "1.0.1";
5
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,oDAAoD;AACpD,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,83 @@
1
1
  {
2
2
  "name": "@smarter.sh/api",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.1",
4
+ "description": "The official Node.js SDK of the Smarter platform's api.",
5
+ "keywords": [
6
+ "smarter",
7
+ "sdk",
8
+ "api",
9
+ "llm",
10
+ "ai",
11
+ "agents",
12
+ "typescript"
13
+ ],
14
+ "homepage": "https://docs.smarter.sh/en/latest/smarter-framework/smarter-nodejs.html",
15
+ "bugs": "https://github.com/smarter-sh/smarter-nodejs/issues",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/smarter-sh/smarter-nodejs.git"
19
+ },
20
+ "license": "AGPL-3.0-or-later",
21
+ "author": "Lawrence McDaniel <lpm0073@gmail.com>",
22
+ "type": "module",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "main": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "files": [
33
+ "dist",
34
+ "README.md",
35
+ "LICENSE.txt"
36
+ ],
37
+ "sideEffects": false,
38
+ "engines": {
39
+ "node": ">=22"
40
+ },
41
+ "scripts": {
42
+ "build": "rm -rf dist && tsc -p tsconfig.build.json",
43
+ "prepublishOnly": "npm run build",
44
+ "test": "vitest run",
45
+ "coverage": "vitest run --coverage",
46
+ "test:live": "SMARTER_TEST_LIVE=true vitest run test/live",
47
+ "typecheck": "tsc --noEmit",
48
+ "lint": "eslint .",
49
+ "format": "prettier --write .",
50
+ "reference": "typedoc --json build/typedoc.json && node scripts/generate-reference.ts",
51
+ "sam-models": "node scripts/generate-sam-models.ts && prettier --write src/models/sam"
52
+ },
53
+ "dependencies": {
54
+ "ajv": "^8.17.1",
55
+ "yaml": "^2.8.0",
56
+ "zod": "^4.1.0"
57
+ },
58
+ "devDependencies": {
59
+ "@commitlint/cli": "21.2.4",
60
+ "@commitlint/config-angular": "21.2.4",
61
+ "@commitlint/config-conventional": "21.2.3",
62
+ "@eslint/js": "10.0.1",
63
+ "@semantic-release/changelog": "7.0.0",
64
+ "@semantic-release/commit-analyzer": "13.0.1",
65
+ "@semantic-release/exec": "7.1.0",
66
+ "@semantic-release/git": "11.0.1",
67
+ "@semantic-release/github": "12.0.10",
68
+ "@semantic-release/release-notes-generator": "14.1.1",
69
+ "@types/node": "26.6.5",
70
+ "@vitest/coverage-v8": "5.0.5",
71
+ "conventional-changelog-conventionalcommits": "9.3.1",
72
+ "eslint": "10.13.0",
73
+ "eslint-plugin-tsdoc": "0.5.4",
74
+ "json-schema-to-typescript": "16.0.0",
75
+ "prettier": "3.9.10",
76
+ "publint": "0.3.25",
77
+ "semantic-release": "25.0.9",
78
+ "typedoc": "0.28.20",
79
+ "typescript": "5.9.3",
80
+ "typescript-eslint": "8.71.2",
81
+ "vitest": "5.0.5"
82
+ }
83
+ }