lua-cli 3.17.0 → 3.17.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.
@@ -78,6 +78,36 @@ declare interface AgentInvocationOutput {
78
78
  threadId?: string;
79
79
  }
80
80
 
81
+ /**
82
+ * Per-agent LLM call settings. Maps directly onto Mastra's
83
+ * `agent.stream({ modelSettings })` / `agent.generate({ modelSettings })`,
84
+ * which in turn maps onto the AI SDK's `CallSettings`. Pass-through:
85
+ * we don't validate ranges here; the provider will reject invalid combos
86
+ * (e.g. topP > 1, presencePenalty out of provider range).
87
+ *
88
+ * Deliberately excludes `abortSignal` (not serializable), `headers`
89
+ * (security — could exfiltrate credentials), and `maxRetries` (platform
90
+ * concern, not customer-tunable).
91
+ */
92
+ export declare interface AgentModelSettings {
93
+ /** Sampling temperature. Range depends on provider (typically 0..2 for Anthropic/OpenAI). */
94
+ temperature?: number;
95
+ /** Nucleus sampling. 0..1. Recommended: set either `temperature` or `topP`, not both. */
96
+ topP?: number;
97
+ /** Top-K sampling. Advanced. */
98
+ topK?: number;
99
+ /** Maximum tokens to generate. */
100
+ maxOutputTokens?: number;
101
+ /** Presence penalty. -2..2 (OpenAI); not all providers support. */
102
+ presencePenalty?: number;
103
+ /** Frequency penalty. -2..2 (OpenAI); not all providers support. */
104
+ frequencyPenalty?: number;
105
+ /** Stop sequences. Generation halts when the model emits one of these. */
106
+ stopSequences?: string[];
107
+ /** Random seed for deterministic sampling (provider support varies). */
108
+ seed?: number;
109
+ }
110
+
81
111
  export declare const Agents: AgentsApi;
82
112
 
83
113
  /**
@@ -158,7 +188,7 @@ export declare interface AiApi {
158
188
  * Serializable subset of AI SDK `generateText` parameters.
159
189
  * `messages` is untyped over HTTP; callers typically send AI SDK `ModelMessage[]`.
160
190
  */
161
- declare interface AiGenerateInput {
191
+ export declare interface AiGenerateInput {
162
192
  model?: string;
163
193
  system?: string;
164
194
  prompt?: string;
@@ -178,14 +208,14 @@ declare interface AiGenerateInput {
178
208
  * Kept as `Record<string, unknown>` to avoid pulling `@types/json-schema` into the
179
209
  * published lua-cli surface; callers typically produce this via `zodToJsonSchema`.
180
210
  */
181
- declare type AiGenerateJsonSchema = Record<string, unknown>;
211
+ export declare type AiGenerateJsonSchema = Record<string, unknown>;
182
212
 
183
213
  /**
184
214
  * Wire-format output from `AI.generate` / `POST .../generate`.
185
215
  * Fields mirror AI SDK `GenerateTextResult` — uses AI SDK types where exported.
186
216
  * See https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-text
187
217
  */
188
- declare interface AiGenerateOutput {
218
+ export declare interface AiGenerateOutput {
189
219
  text: string;
190
220
  /** AI SDK `FinishReason` */
191
221
  finishReason: FinishReason;
@@ -214,7 +244,7 @@ declare interface AiGenerateOutput {
214
244
  * URL source from Google Search grounding.
215
245
  * Mirrors `LanguageModelV2Source` (AI SDK `Source` type — not exported from `ai` as of v5).
216
246
  */
217
- declare interface AiGenerateSource {
247
+ export declare interface AiGenerateSource {
218
248
  sourceType: 'url';
219
249
  id: string;
220
250
  url: string;
@@ -225,7 +255,7 @@ declare interface AiGenerateSource {
225
255
  * Structured-output spec. Maps to AI SDK `output: Output.object({ schema })` on `generateText`.
226
256
  * Result lands on `AiGenerateOutput.output`.
227
257
  */
228
- declare interface AiGenerateStructuredOutput {
258
+ export declare interface AiGenerateStructuredOutput {
229
259
  /** JSON Schema 7 describing the expected object shape. */
230
260
  schema: AiGenerateJsonSchema;
231
261
  }
@@ -234,7 +264,7 @@ declare interface AiGenerateStructuredOutput {
234
264
  * Serializable tool call. Mirrors `TypedToolCall` without generics.
235
265
  * `input` matches the AI SDK field name (renamed from `args` in v5).
236
266
  */
237
- declare interface AiGenerateToolCall {
267
+ export declare interface AiGenerateToolCall {
238
268
  type: 'tool-call';
239
269
  toolCallId: string;
240
270
  toolName: string;
@@ -245,7 +275,7 @@ declare interface AiGenerateToolCall {
245
275
  * Serializable tool result. Mirrors `TypedToolResult` without generics.
246
276
  * `output` matches the AI SDK field name.
247
277
  */
248
- declare interface AiGenerateToolResult {
278
+ export declare interface AiGenerateToolResult {
249
279
  type: 'tool-result';
250
280
  toolCallId: string;
251
281
  toolName: string;
@@ -1796,6 +1826,7 @@ export declare class LuaAgent {
1796
1826
  private readonly name;
1797
1827
  private readonly persona;
1798
1828
  private readonly model?;
1829
+ private readonly modelSettings?;
1799
1830
  private readonly skills;
1800
1831
  private readonly webhooks;
1801
1832
  private readonly jobs;
@@ -1827,6 +1858,7 @@ export declare class LuaAgent {
1827
1858
  getName(): string;
1828
1859
  getPersona(): PersonaText;
1829
1860
  getModel(): LuaAgentModel | undefined;
1861
+ getModelSettings(): AgentModelSettings | undefined;
1830
1862
  getSkills(): LuaSkill[];
1831
1863
  getWebhooks(): LuaWebhook[];
1832
1864
  getJobs(): LuaJob[];
@@ -1845,6 +1877,15 @@ export declare interface LuaAgentConfig {
1845
1877
  persona: PersonaText;
1846
1878
  /** LLM model to use — 'provider/model' string or resolver function */
1847
1879
  model?: LuaAgentModel;
1880
+ /**
1881
+ * Per-call sampling settings (temperature, topP, maxOutputTokens, etc.).
1882
+ * Passed straight through to Mastra / AI SDK on every `chat/stream` and
1883
+ * `chat/generate`. Undefined leaves provider defaults in place.
1884
+ *
1885
+ * @example
1886
+ * modelSettings: { temperature: 0.2, maxOutputTokens: 4096 }
1887
+ */
1888
+ modelSettings?: AgentModelSettings;
1848
1889
  /** Array of skills (each with tools) */
1849
1890
  skills?: LuaSkill[];
1850
1891
  /** Array of webhooks */
@@ -2824,6 +2865,7 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
2824
2865
  volume: z.ZodOptional<z.ZodNumber>;
2825
2866
  pronunciations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2826
2867
  persistTranscript: z.ZodOptional<z.ZodBoolean>;
2868
+ onToolFailureSay: z.ZodOptional<z.ZodString>;
2827
2869
  }, "strip", z.ZodTypeAny, {
2828
2870
  vad?: string;
2829
2871
  stt?: {
@@ -2916,6 +2958,7 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
2916
2958
  };
2917
2959
  pronunciations?: Record<string, string>;
2918
2960
  persistTranscript?: boolean;
2961
+ onToolFailureSay?: string;
2919
2962
  }, {
2920
2963
  vad?: string;
2921
2964
  stt?: {
@@ -3008,6 +3051,7 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3008
3051
  };
3009
3052
  pronunciations?: Record<string, string>;
3010
3053
  persistTranscript?: boolean;
3054
+ onToolFailureSay?: string;
3011
3055
  }>, {
3012
3056
  vad?: string;
3013
3057
  stt?: {
@@ -3100,6 +3144,7 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3100
3144
  };
3101
3145
  pronunciations?: Record<string, string>;
3102
3146
  persistTranscript?: boolean;
3147
+ onToolFailureSay?: string;
3103
3148
  }, {
3104
3149
  vad?: string;
3105
3150
  stt?: {
@@ -3192,6 +3237,7 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3192
3237
  };
3193
3238
  pronunciations?: Record<string, string>;
3194
3239
  persistTranscript?: boolean;
3240
+ onToolFailureSay?: string;
3195
3241
  }>;
3196
3242
 
3197
3243
  /**
@@ -3307,6 +3353,21 @@ export declare interface LuaVoiceToolCtx {
3307
3353
  mode?: 'bridge' | 'refer';
3308
3354
  announce?: string;
3309
3355
  }): Promise<void>;
3356
+ /**
3357
+ * End the live call. When `announce` is set, the agent speaks it and
3358
+ * waits for playout before closing the session — useful for a sign-off
3359
+ * like "Thanks for calling, goodbye." Without `announce`, the session
3360
+ * closes immediately (any in-flight TTS finishes via the SDK's
3361
+ * graceful `close()`).
3362
+ *
3363
+ * @example
3364
+ * ```typescript
3365
+ * await ctx.voice?.endCall({ announce: 'Thanks for calling. Goodbye.' });
3366
+ * ```
3367
+ */
3368
+ endCall?(opts?: {
3369
+ announce?: string;
3370
+ }): Promise<void>;
3310
3371
  /**
3311
3372
  * @experimental Reserved for Phase 5 (BAC-213). Optional because
3312
3373
  * unimplemented — the actual "lock the assistant's current
@@ -27,7 +27,7 @@ var init_baskets = __esm({
27
27
  // src/config/constants.ts
28
28
  import { join } from "path";
29
29
  import { homedir } from "os";
30
- var CLI_CONFIG_DIR, VERSION_CHECK_FILE, TELEMETRY_FILE, CLI_CACHE_FILE, BASE_URLS, CREDENTIALS_FILE, SANDBOX_STORAGE_FILE;
30
+ var CLI_CONFIG_DIR, VERSION_CHECK_FILE, TELEMETRY_FILE, CLI_CACHE_FILE, BASE_URLS, CREDENTIALS_FILE, SANDBOX_STORAGE_FILE, AUTH_STORAGE_FILE;
31
31
  var init_constants = __esm({
32
32
  "src/config/constants.ts"() {
33
33
  "use strict";
@@ -44,6 +44,7 @@ var init_constants = __esm({
44
44
  };
45
45
  CREDENTIALS_FILE = join(CLI_CONFIG_DIR, "credentials");
46
46
  SANDBOX_STORAGE_FILE = join(CLI_CONFIG_DIR, "sandbox.json");
47
+ AUTH_STORAGE_FILE = join(CLI_CONFIG_DIR, "auth.json");
47
48
  }
48
49
  });
49
50
 
@@ -788,7 +789,14 @@ Feel free to add, remove, or rename sections. Your persona can be a single parag
788
789
  // `Data.get('call:<sessionId>')` to drive post-call analytics, follow-ups,
789
790
  // or QA workflows. Defaults to false — most calls don't need to keep
790
791
  // a transcript copy.
791
- persistTranscript: z.boolean().optional()
792
+ persistTranscript: z.boolean().optional(),
793
+ // Spoken acknowledgement played when a tool call fails. When a tool
794
+ // throws, times out, or returns an unsupported result, the adapter calls
795
+ // `session.say(text)` once per failed call before surfacing the error
796
+ // to the LLM as a ToolError — fills the 2–3s gap before the LLM's own
797
+ // recovery response. Persona-specific (keep it short and on-brand);
798
+ // absent → no spoken fallback (the LLM's recovery is the only signal).
799
+ onToolFailureSay: z.string().min(1).max(200).optional()
792
800
  });
793
801
  LuaVoiceConfigSchema = LuaVoiceConfigInnerSchema.superRefine((cfg, ctx) => {
794
802
  const isRealtime = cfg.llm.kind === "realtime";
@@ -5662,6 +5670,38 @@ var LuaMCPServer = class {
5662
5670
  return base;
5663
5671
  }
5664
5672
  };
5673
+ function validateModelSettings(settings) {
5674
+ const finiteNumberKeys = [
5675
+ "temperature",
5676
+ "topP",
5677
+ "topK",
5678
+ "maxOutputTokens",
5679
+ "presencePenalty",
5680
+ "frequencyPenalty",
5681
+ "seed"
5682
+ ];
5683
+ for (const key of finiteNumberKeys) {
5684
+ const value = settings[key];
5685
+ if (value !== void 0 && (typeof value !== "number" || !Number.isFinite(value))) {
5686
+ throw new Error(`Agent modelSettings.${key} must be a finite number`);
5687
+ }
5688
+ }
5689
+ if (settings.temperature !== void 0 && (settings.temperature < 0 || settings.temperature > 2)) {
5690
+ throw new Error("Agent modelSettings.temperature must be between 0 and 2");
5691
+ }
5692
+ if (settings.topP !== void 0 && (settings.topP < 0 || settings.topP > 1)) {
5693
+ throw new Error("Agent modelSettings.topP must be between 0 and 1");
5694
+ }
5695
+ if (settings.maxOutputTokens !== void 0 && settings.maxOutputTokens < 1) {
5696
+ throw new Error("Agent modelSettings.maxOutputTokens must be >= 1");
5697
+ }
5698
+ if (settings.stopSequences !== void 0) {
5699
+ if (!Array.isArray(settings.stopSequences) || !settings.stopSequences.every((v) => typeof v === "string")) {
5700
+ throw new Error("Agent modelSettings.stopSequences must be a string array");
5701
+ }
5702
+ }
5703
+ }
5704
+ __name(validateModelSettings, "validateModelSettings");
5665
5705
  var LuaAgent = class {
5666
5706
  static {
5667
5707
  __name(this, "LuaAgent");
@@ -5669,6 +5709,7 @@ var LuaAgent = class {
5669
5709
  name;
5670
5710
  persona;
5671
5711
  model;
5712
+ modelSettings;
5672
5713
  skills;
5673
5714
  webhooks;
5674
5715
  jobs;
@@ -5700,6 +5741,10 @@ var LuaAgent = class {
5700
5741
  this.name = config.name;
5701
5742
  this.persona = config.persona;
5702
5743
  this.model = config.model;
5744
+ if (config.modelSettings !== void 0) {
5745
+ validateModelSettings(config.modelSettings);
5746
+ }
5747
+ this.modelSettings = config.modelSettings;
5703
5748
  if (typeof this.persona === "object") {
5704
5749
  if (!this.persona.base && !this.persona.voice && !this.persona.text) {
5705
5750
  throw new Error("Agent persona object must have at least one of: base, voice, text");
@@ -5726,6 +5771,9 @@ var LuaAgent = class {
5726
5771
  getModel() {
5727
5772
  return this.model;
5728
5773
  }
5774
+ getModelSettings() {
5775
+ return this.modelSettings;
5776
+ }
5729
5777
  getSkills() {
5730
5778
  return this.skills;
5731
5779
  }