mboaai-sdk 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +126 -0
  2. package/package.json +6 -2
package/README.md CHANGED
@@ -0,0 +1,126 @@
1
+ # **MboaAI JavaScript SDK**
2
+
3
+ Tiny, framework-agnostic helper to talk to MboaAI agents from **Node, React, Vue, Angular, Svelte or plain-browser JS**.
4
+
5
+ * ✅ One-line `init({ apiKey })`
6
+ * ✅ `await T.translate(text, targetLang, type?)`
7
+ * ✅ Graceful fallback → returns original text when the agent fails
8
+ * ✅ UMD **and** ESM builds (works with `import` *or* `require`)
9
+ * ✅ TypeScript types included
10
+
11
+ ---
12
+
13
+ ## 🛠 Installation
14
+
15
+ ```bash
16
+ npm i mboaai-sdk # or yarn add mboaai-sdk / pnpm add …
17
+ ```
18
+
19
+ ---
20
+
21
+ ## 🚀 Quick start
22
+
23
+ ```js
24
+ import { T } from "mboaai-sdk";
25
+
26
+ await T.init({
27
+ apiKey: "pk_live_yourKey", // ← required
28
+ defaultType: "website", // optional: default pipeline
29
+ });
30
+
31
+ const de = await T.translate("Bonjour tout le monde", "DE"); // uses defaultType
32
+ console.log(de); // → „Hallo zusammen“
33
+
34
+ const it = await T.translate("Hello!", "IT", "standard"); // override pipeline
35
+ console.log(it); // → „Ciao!“
36
+ ```
37
+
38
+ ### Node <sup>(CommonJS)</sup>
39
+
40
+ ```js
41
+ const { T } = require("mboaai-sdk");
42
+
43
+ (async () => {
44
+ await T.init({ apiKey: process.env.MBOAAI_KEY });
45
+ console.log(await T.translate("Salut", "EN"));
46
+ })();
47
+ ```
48
+
49
+ ### Plain browser (UMD script tag)
50
+
51
+ ```html
52
+ <script src="https://cdn.jsdelivr.net/npm/mboaai-sdk"></script>
53
+ <script>
54
+ (async () => {
55
+ await MboaAI.T.init({ apiKey: "pk_live_xx" });
56
+ const es = await MboaAI.T.translate("Wie geht's?", "ES");
57
+ console.log(es);
58
+ })();
59
+ </script>
60
+ ```
61
+
62
+ ---
63
+
64
+ ## 📚 API
65
+
66
+ | Method | Description |
67
+ | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
68
+ | `await T.init(opts)` | Establishes SSE connection and stores your API key. Call once. |
69
+ | `await T.translate(text, lang, type?)` | Returns translated string, or original text on error. `type` defaults to the value given in `init()` (else `"standard"`). |
70
+
71
+ ### `TranslateType`
72
+
73
+ > `"standard"` | `"website"` | any string
74
+ > Future pipelines (e.g. `"legal"`, `"marketing"`) are accepted automatically.
75
+
76
+ ---
77
+
78
+ ## 📝 Example – Straight-up translation
79
+
80
+ ```js
81
+ import { T } from "mboaai-sdk";
82
+
83
+ (async () => {
84
+ /* 1) Initialise once */
85
+ await T.init({
86
+ apiKey : "pk_live_xx", // your secret key
87
+ defaultType : "website", // optional
88
+ });
89
+
90
+ /* 2) Translate a French marketing line into English (defaultType = "website") */
91
+ const fr = "Découvrez nos nouvelles chaussures de sport éco-responsables !";
92
+ const en = await T.translate(fr, "EN"); // → uses “website” pipeline
93
+ console.log("English:", en);
94
+
95
+ /* 3) Translate the same line into Italian using the “standard” pipeline */
96
+ const it = await T.translate(fr, "IT", "standard");
97
+ console.log("Italian:", it);
98
+ })();
99
+
100
+ ```
101
+
102
+ ---
103
+
104
+ ## ⚠️ Error handling
105
+
106
+ * If the agent returns malformed JSON or network fails, the SDK logs
107
+ a warning and **returns the original `text` unchanged** so your UI
108
+ never breaks.
109
+
110
+ ---
111
+
112
+ ## 📦 Bundle details
113
+
114
+ | File | Format | Usage |
115
+ | ------------------------ | ------ | ------------------------------------ |
116
+ | `dist/mboaai-sdk.esm.js` | ESM | modern bundlers, Node ≥16 `import` |
117
+ | `dist/mboaai-sdk.umd.js` | UMD | `<script>` tag, CommonJS `require()` |
118
+
119
+ The build is minified with **Terser** and ships its TypeScript typings
120
+ (`index.d.ts`).
121
+
122
+ ---
123
+
124
+ ## 🛡 License
125
+
126
+ MIT © 2025 MboaAI.
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "mboaai-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Lightweight JavaScript SDK for calling MboaAI agents",
5
5
  "main": "dist/mboaai-sdk.umd.js",
6
6
  "module": "dist/mboaai-sdk.esm.js",
7
+ "exports": {
8
+ "import": "./dist/mboaai-sdk.esm.js",
9
+ "require": "./dist/mboaai-sdk.umd.js"
10
+ },
7
11
  "types": "dist/index.d.ts",
8
12
  "scripts": {
9
13
  "build": "rollup -c",
@@ -24,4 +28,4 @@
24
28
  "rollup-plugin-terser": "^7.0.2",
25
29
  "typescript": "^5.8.3"
26
30
  }
27
- }
31
+ }