@mentingo/luma-sdk 0.3.0 → 0.4.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.
package/README.md CHANGED
@@ -10,11 +10,11 @@ It provides two separate clients:
10
10
  ## Installation
11
11
 
12
12
  ```bash
13
- pnpm add @mentingo/luma-sdk
13
+ pnpm add @mentingo/luma-sdk@0.4.1
14
14
  # or
15
- npm install @mentingo/luma-sdk
15
+ npm install @mentingo/luma-sdk@0.4.1
16
16
  # or
17
- yarn add @mentingo/luma-sdk
17
+ yarn add @mentingo/luma-sdk@0.4.1
18
18
  ```
19
19
 
20
20
  ## Quick Start (HTTP)
@@ -154,7 +154,7 @@ Namespaces:
154
154
 
155
155
  - `client.mentor.streamChat(opts)` - stream mentor chat through the public custom-runtime endpoint. Pass `voiceSessionId` for voice mentor sessions so Luma can forward mentor text directly to the voice session.
156
156
  - `client.mentor.chat(opts)` - alias for `client.mentor.streamChat(opts)`.
157
- - `client.mentor.generateChat(opts)` - generate a non-stream mentor chat response.
157
+ - `client.mentor.generateChat(opts, { signal? })` - generate a native non-stream chat response, with optional cancellation.
158
158
  - `client.mentor.judge(opts)`
159
159
  - `client.ai.createEmbeddings(opts)`
160
160
  - `client.ai.generateJudgeConfiguration(opts)`
@@ -185,7 +185,82 @@ for the API key. The SDK exports `AiCapability`, `AiCapabilityMode`,
185
185
  Custom model names should use the backend `provider:model` format, for example
186
186
  `openai:gpt-4.1-mini` or `ollama:llama3.1`.
187
187
 
188
- For voice mentor flows, use `client.mentor.streamChat({ ..., voiceSessionId })` so streamed mentor text can be forwarded to the active socket session without a separate polling or relay step. Use `client.mentor.generateChat(opts)` only for normal one-shot text responses.
188
+ Voice TTS capabilities expose an optional `vendor` (`TTSProvider`) for core-mode
189
+ routing. API key settings use extensible non-secret metadata, for example
190
+ `metadata: { textToSpeechProvider: TextToSpeechProvider.Elevenlabs }` in
191
+ `admin.apiKeys.update`. Omitted metadata entries stay unchanged; setting an entry
192
+ to `null` removes it. Credentials remain in the write-only `textToSpeechApiKey`
193
+ field; `hasTextToSpeechApiKey` reports whether one is saved.
194
+
195
+ For voice mentor flows, use `client.mentor.streamChat({ ..., voiceSessionId })` so streamed mentor text can be forwarded to the active socket session without a separate polling or relay step. Use `client.mentor.generateChat(opts)` for normal one-shot text responses. Tool-capable assistant calls use the native options below and do not attach a voice session.
196
+
197
+ ## Native Tool-Capable Chat
198
+
199
+ The existing Mentor client also carries assistant tool calls through Luma's native
200
+ chat API. Luma resolves the API key's configured Custom chat profile; the SDK does
201
+ not choose a vendor or contact an OpenAI chat-completions endpoint.
202
+
203
+ ```ts
204
+ const result = await client.mentor.generateChat(
205
+ {
206
+ messages: [{ role: "user", content: "Read the course title." }],
207
+ tools: [
208
+ {
209
+ name: "read_course",
210
+ description: "Read an authorized course",
211
+ inputSchema: { type: "object", properties: { courseId: { type: "string" } } },
212
+ },
213
+ ],
214
+ toolChoice: "required",
215
+ maxOutputTokens: 2500,
216
+ streamFormat: "events",
217
+ },
218
+ { signal },
219
+ );
220
+ // result.toolCalls contains native { id, name, arguments } calls.
221
+ // Execute tools with the application's normal authorization checks, then append
222
+ // assistant toolCalls and role: "tool" / toolCallId messages to the next request.
223
+ ```
224
+
225
+ For streaming, call `client.mentor.streamChat(opts, { signal })` with
226
+ `streamFormat: "events"`. The existing `/api/public/v1/ai/mentor/chat` route returns
227
+ UTF-8 NDJSON records: `text-delta`, complete `tool-call`, `finish`, or a stable
228
+ `error` code. The response body remains the transport's readable stream; callers
229
+ must decode UTF-8 and newline framing incrementally rather than treating each
230
+ network chunk as one JSON event. The SDK does not execute tools or retry a stream.
231
+ Generation uses the existing `/api/public/v1/ai/mentor/chat/generate` route.
232
+
233
+ Calls omitting tool/event options retain the existing `{ message }` generation
234
+ response and plain-text streaming behavior. `streamChat` already supports request
235
+ cancellation in SDK 0.4.0; the optional generation `signal` parameter is added by
236
+ SDK 0.4.1. Model execution, provider availability and fallback policy stay with
237
+ Luma and the consuming application. Deploy the matching Luma native tool-chat
238
+ contract before enabling event-mode callers.
239
+
240
+ ## Native Embeddings
241
+
242
+ Use the existing AI client to embed text with the API key's configured Custom
243
+ embedding profile:
244
+
245
+ ```ts
246
+ const result = await client.ai.createEmbeddings({
247
+ texts: ["Customer onboarding policy"],
248
+ dimensions: 1536,
249
+ });
250
+ // result.embeddings contains the vectors; result.model identifies the profile model.
251
+ ```
252
+
253
+ This calls `POST /api/public/v1/ai/embeddings` with the normal `X-API-Key`
254
+ transport. `dimensions` is optional and must be supported by the configured model.
255
+ Luma validates the returned vector count, dimensions and finite values. The model
256
+ identity comes from the same runtime resolution that produced the vectors.
257
+ Texts-only calls remain valid. Older Luma responses may omit `model`; consumers
258
+ that persist or compare vector spaces must reject missing identity rather than
259
+ assuming a model. Matching dimensions alone do not make embedding spaces compatible.
260
+
261
+ The public contract is generated from Mentingo AI PR #63. The SDK update adds types
262
+ and transport regressions; published SDK 0.4.0 already forwards these additive body
263
+ and response fields unchanged at runtime. No OpenAI-format embeddings relay is used.
189
264
 
190
265
  ## Durable Course Authoring
191
266
 
@@ -24,6 +24,11 @@ var TurnPartKind = /* @__PURE__ */ ((TurnPartKind2) => {
24
24
  TurnPartKind2["Question"] = "question";
25
25
  return TurnPartKind2;
26
26
  })(TurnPartKind || {});
27
+ var TextToSpeechProvider = /* @__PURE__ */ ((TextToSpeechProvider2) => {
28
+ TextToSpeechProvider2["Cartesia"] = "cartesia";
29
+ TextToSpeechProvider2["Elevenlabs"] = "elevenlabs";
30
+ return TextToSpeechProvider2;
31
+ })(TextToSpeechProvider || {});
27
32
  var TaskKind = /* @__PURE__ */ ((TaskKind2) => {
28
33
  TaskKind2["Plan"] = "plan";
29
34
  TaskKind2["Route"] = "route";
@@ -32,10 +37,17 @@ var TaskKind = /* @__PURE__ */ ((TaskKind2) => {
32
37
  TaskKind2["Lesson"] = "lesson";
33
38
  TaskKind2["Edit"] = "edit";
34
39
  TaskKind2["Source"] = "source";
40
+ TaskKind2["SourceVision"] = "source_vision";
35
41
  TaskKind2["Asset"] = "asset";
36
42
  TaskKind2["CourseReview"] = "course_review";
37
43
  return TaskKind2;
38
44
  })(TaskKind || {});
45
+ var TTSProvider = /* @__PURE__ */ ((TTSProvider2) => {
46
+ TTSProvider2["Cartesia"] = "cartesia";
47
+ TTSProvider2["Elevenlabs"] = "elevenlabs";
48
+ TTSProvider2["Fish"] = "fish";
49
+ return TTSProvider2;
50
+ })(TTSProvider || {});
39
51
  var ReasoningEffort = /* @__PURE__ */ ((ReasoningEffort2) => {
40
52
  ReasoningEffort2["Low"] = "low";
41
53
  ReasoningEffort2["Medium"] = "medium";
@@ -58,6 +70,7 @@ var AiModelDomain = /* @__PURE__ */ ((AiModelDomain2) => {
58
70
  AiModelDomain2["AiJudgeConfigurationValidator"] = "aiJudgeConfigurationValidator";
59
71
  AiModelDomain2["Translations"] = "translations";
60
72
  AiModelDomain2["CourseGeneration"] = "courseGeneration";
73
+ AiModelDomain2["CourseGenerationVision"] = "courseGenerationVision";
61
74
  AiModelDomain2["CourseGenerationVisualAssets"] = "courseGenerationVisualAssets";
62
75
  AiModelDomain2["CourseGenerationEmbeddings"] = "courseGenerationEmbeddings";
63
76
  AiModelDomain2["Embeddings"] = "embeddings";
@@ -79,6 +92,7 @@ var AiCapabilityMode = /* @__PURE__ */ ((AiCapabilityMode2) => {
79
92
  })(AiCapabilityMode || {});
80
93
  var AiCapability = /* @__PURE__ */ ((AiCapability2) => {
81
94
  AiCapability2["CourseGeneration"] = "courseGeneration";
95
+ AiCapability2["CourseGenerationVision"] = "courseGenerationVision";
82
96
  AiCapability2["CourseGenerationVisualAssets"] = "courseGenerationVisualAssets";
83
97
  AiCapability2["CourseGenerationEmbeddings"] = "courseGenerationEmbeddings";
84
98
  AiCapability2["AiMentorChat"] = "aiMentorChat";
@@ -202,7 +216,7 @@ var API = class extends HttpClient {
202
216
  ...params
203
217
  }),
204
218
  /**
205
- * No description
219
+ * @description Existing text stream by default; streamFormat=events opts into newline-delimited native text, complete tool-call, finish and sanitized error events. Tools execute in the caller, never in Luma.
206
220
  *
207
221
  * @tags Public - Require API Key
208
222
  * @name MentorChatApiPublicV1AiMentorChatPost
@@ -345,7 +359,7 @@ var API = class extends HttpClient {
345
359
  ...params
346
360
  }),
347
361
  /**
348
- * No description
362
+ * @description Embeds texts using the API key's Custom embeddings runtime. Optional dimensions requests a positive vector size. The response model identifies the same resolved runtime used to produce the validated vectors.
349
363
  *
350
364
  * @tags Public - Require API Key
351
365
  * @name CreateEmbeddingsApiPublicV1AiEmbeddingsPost
@@ -784,6 +798,7 @@ var LUMA_AI_MODEL_DOMAINS = {
784
798
  AI_JUDGE_CONFIGURATION_VALIDATOR: "aiJudgeConfigurationValidator" /* AiJudgeConfigurationValidator */,
785
799
  TRANSLATIONS: "translations" /* Translations */,
786
800
  COURSE_GENERATION: "courseGeneration" /* CourseGeneration */,
801
+ COURSE_GENERATION_VISION: "courseGenerationVision" /* CourseGenerationVision */,
787
802
  COURSE_GENERATION_VISUAL_ASSETS: "courseGenerationVisualAssets" /* CourseGenerationVisualAssets */,
788
803
  COURSE_GENERATION_EMBEDDINGS: "courseGenerationEmbeddings" /* CourseGenerationEmbeddings */,
789
804
  EMBEDDINGS: "embeddings" /* Embeddings */,
@@ -920,7 +935,9 @@ export {
920
935
  TurnStatus,
921
936
  TurnPartStatus,
922
937
  TurnPartKind,
938
+ TextToSpeechProvider,
923
939
  TaskKind,
940
+ TTSProvider,
924
941
  ReasoningEffort,
925
942
  AiModelProfileKind,
926
943
  AiModelDomain,