lua-cli 3.38.0 → 3.39.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.
@@ -3139,6 +3139,46 @@ export declare const lit: <const V extends string | number | boolean | null>(v:
3139
3139
 
3140
3140
  export { Literal }
3141
3141
 
3142
+ /**
3143
+ * Structured logging: `log.debug/info/warn/error(message, fields?)`.
3144
+ *
3145
+ * One call writes one log row. The level becomes the row's severity, exactly as
3146
+ * the matching `console.*` call would, and `fields` travels BESIDE the message
3147
+ * rather than inside it — so a log drain delivers each field as its own
3148
+ * `app.<key>` attribute that the destination can filter and group on, instead
3149
+ * of a line someone has to parse.
3150
+ *
3151
+ * `console.*` is untouched: it still serialises every argument into the
3152
+ * message text.
3153
+ *
3154
+ * ```typescript
3155
+ * import { log } from 'lua-cli';
3156
+ *
3157
+ * log.error('Knowledge base search failed', {
3158
+ * tags: ['domain/search'], // → "domain/search" + tags.count: 1
3159
+ * conversation_id: conversationId,
3160
+ * error_type: 'timeout',
3161
+ * duration_ms: 1432,
3162
+ * });
3163
+ * ```
3164
+ *
3165
+ * The rules, all enforced at the call so `lua test` and production agree:
3166
+ * at most 32 keys (an array's `.count` sibling counts); a key must match
3167
+ * `^[a-z][a-z0-9_]{0,63}$` and may not look like an API key; values are
3168
+ * `string | number | boolean | string[]`; an array element may not contain a
3169
+ * comma. A value over 1 KiB or a map over 8 KiB is clamped, not refused.
3170
+ *
3171
+ * Available in skills, tools, webhooks, triggers, jobs and processors. Workflow
3172
+ * steps keep `ctx.log`.
3173
+ */
3174
+ export declare const log: LuaLog;
3175
+
3176
+ /** The `fields` argument of `log.debug/info/warn/error`. */
3177
+ export declare type LogFields = Record<string, LogFieldValue>;
3178
+
3179
+ /** What a skill author may put in a `log.*` field map. */
3180
+ declare type LogFieldValue = string | number | boolean | string[];
3181
+
3142
3182
  export declare interface LoopOptions {
3143
3183
  /** default 100 */
3144
3184
  maxIterations?: number;
@@ -3626,6 +3666,48 @@ export declare interface LuaJobConfig {
3626
3666
  metadata?: Record<string, any>;
3627
3667
  }
3628
3668
 
3669
+ /**
3670
+ * The `log` global skill code sees. One call = one log row; the level is the
3671
+ * row's `subType`, so a drain's `minSeverity` filter selects it exactly as it
3672
+ * selects the same primitive's `console.*` lines.
3673
+ */
3674
+ export declare interface LuaLog {
3675
+ /** `subType: 'debug'`. */
3676
+ debug(message: string, fields?: LogFields): void;
3677
+ /** `subType: 'info'`. */
3678
+ info(message: string, fields?: LogFields): void;
3679
+ /** `subType: 'warn'`. */
3680
+ warn(message: string, fields?: LogFields): void;
3681
+ /** `subType: 'error'`. */
3682
+ error(message: string, fields?: LogFields): void;
3683
+ }
3684
+
3685
+ /**
3686
+ * The error a `log.*` call throws when its fields are structurally invalid —
3687
+ * too many keys, a key the pattern refuses, a nested object, a bad value type,
3688
+ * or a comma inside an array element.
3689
+ *
3690
+ * Length is NOT structural: a value over 1 KiB, or a map over 8 KiB, is clamped
3691
+ * and marked with `lua_fields_clamped: true` rather than throwing. A log call
3692
+ * must never break a working tool.
3693
+ *
3694
+ * Deliberately a SHAPE, not the class: the class is not a sandbox global, and
3695
+ * `lua compile` strips every `lua-cli` import, so an `instanceof` check written
3696
+ * against it would type-check here and throw `ReferenceError` in the sandbox.
3697
+ * The stable identity is `name`:
3698
+ *
3699
+ * ```typescript
3700
+ * try {
3701
+ * log.info('searched', fields);
3702
+ * } catch (err: any) {
3703
+ * if (err?.name === 'LuaLogFieldsError') await fixTheFields();
3704
+ * }
3705
+ * ```
3706
+ */
3707
+ export declare type LuaLogFieldsError = Error & {
3708
+ name: 'LuaLogFieldsError';
3709
+ };
3710
+
3629
3711
  export { LuaMapConfig }
3630
3712
 
3631
3713
  /**
@@ -4140,14 +4222,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4140
4222
  */
4141
4223
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4142
4224
  }, "strip", z.ZodTypeAny, {
4225
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4143
4226
  provider?: "deepgram" | "elevenlabs";
4144
4227
  kind?: "plugin";
4145
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4146
4228
  options?: Record<string, unknown>;
4147
4229
  }, {
4230
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4148
4231
  provider?: "deepgram" | "elevenlabs";
4149
4232
  kind?: "plugin";
4150
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4151
4233
  options?: Record<string, unknown>;
4152
4234
  }>, z.ZodObject<{
4153
4235
  kind: z.ZodLiteral<"realtime">;
@@ -4206,14 +4288,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4206
4288
  */
4207
4289
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4208
4290
  }, "strip", z.ZodTypeAny, {
4291
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4209
4292
  provider?: "deepgram" | "elevenlabs";
4210
4293
  kind?: "plugin";
4211
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4212
4294
  options?: Record<string, unknown>;
4213
4295
  }, {
4296
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4214
4297
  provider?: "deepgram" | "elevenlabs";
4215
4298
  kind?: "plugin";
4216
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4217
4299
  options?: Record<string, unknown>;
4218
4300
  }>, z.ZodObject<{
4219
4301
  kind: z.ZodLiteral<"realtime">;
@@ -4272,14 +4354,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4272
4354
  */
4273
4355
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4274
4356
  }, "strip", z.ZodTypeAny, {
4357
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4275
4358
  provider?: "deepgram" | "elevenlabs";
4276
4359
  kind?: "plugin";
4277
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4278
4360
  options?: Record<string, unknown>;
4279
4361
  }, {
4362
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4280
4363
  provider?: "deepgram" | "elevenlabs";
4281
4364
  kind?: "plugin";
4282
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4283
4365
  options?: Record<string, unknown>;
4284
4366
  }>, z.ZodObject<{
4285
4367
  kind: z.ZodLiteral<"realtime">;
@@ -4464,9 +4546,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4464
4546
  options?: Record<string, unknown>;
4465
4547
  model?: string;
4466
4548
  } | {
4549
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4467
4550
  provider?: "deepgram" | "elevenlabs";
4468
4551
  kind?: "plugin";
4469
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4470
4552
  options?: Record<string, unknown>;
4471
4553
  } | {
4472
4554
  provider?: "google" | "xai" | "openai";
@@ -4480,9 +4562,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4480
4562
  options?: Record<string, unknown>;
4481
4563
  model?: string;
4482
4564
  } | {
4565
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4483
4566
  provider?: "deepgram" | "elevenlabs";
4484
4567
  kind?: "plugin";
4485
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4486
4568
  options?: Record<string, unknown>;
4487
4569
  } | {
4488
4570
  provider?: "google" | "xai" | "openai";
@@ -4495,9 +4577,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4495
4577
  options?: Record<string, unknown>;
4496
4578
  model?: string;
4497
4579
  } | {
4580
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4498
4581
  provider?: "deepgram" | "elevenlabs";
4499
4582
  kind?: "plugin";
4500
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4501
4583
  options?: Record<string, unknown>;
4502
4584
  } | {
4503
4585
  provider?: "google" | "xai" | "openai";
@@ -4558,9 +4640,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4558
4640
  options?: Record<string, unknown>;
4559
4641
  model?: string;
4560
4642
  } | {
4643
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4561
4644
  provider?: "deepgram" | "elevenlabs";
4562
4645
  kind?: "plugin";
4563
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4564
4646
  options?: Record<string, unknown>;
4565
4647
  } | {
4566
4648
  provider?: "google" | "xai" | "openai";
@@ -4574,9 +4656,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4574
4656
  options?: Record<string, unknown>;
4575
4657
  model?: string;
4576
4658
  } | {
4659
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4577
4660
  provider?: "deepgram" | "elevenlabs";
4578
4661
  kind?: "plugin";
4579
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4580
4662
  options?: Record<string, unknown>;
4581
4663
  } | {
4582
4664
  provider?: "google" | "xai" | "openai";
@@ -4589,9 +4671,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4589
4671
  options?: Record<string, unknown>;
4590
4672
  model?: string;
4591
4673
  } | {
4674
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4592
4675
  provider?: "deepgram" | "elevenlabs";
4593
4676
  kind?: "plugin";
4594
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4595
4677
  options?: Record<string, unknown>;
4596
4678
  } | {
4597
4679
  provider?: "google" | "xai" | "openai";
@@ -4652,9 +4734,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4652
4734
  options?: Record<string, unknown>;
4653
4735
  model?: string;
4654
4736
  } | {
4737
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4655
4738
  provider?: "deepgram" | "elevenlabs";
4656
4739
  kind?: "plugin";
4657
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4658
4740
  options?: Record<string, unknown>;
4659
4741
  } | {
4660
4742
  provider?: "google" | "xai" | "openai";
@@ -4668,9 +4750,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4668
4750
  options?: Record<string, unknown>;
4669
4751
  model?: string;
4670
4752
  } | {
4753
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4671
4754
  provider?: "deepgram" | "elevenlabs";
4672
4755
  kind?: "plugin";
4673
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4674
4756
  options?: Record<string, unknown>;
4675
4757
  } | {
4676
4758
  provider?: "google" | "xai" | "openai";
@@ -4683,9 +4765,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4683
4765
  options?: Record<string, unknown>;
4684
4766
  model?: string;
4685
4767
  } | {
4768
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4686
4769
  provider?: "deepgram" | "elevenlabs";
4687
4770
  kind?: "plugin";
4688
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4689
4771
  options?: Record<string, unknown>;
4690
4772
  } | {
4691
4773
  provider?: "google" | "xai" | "openai";
@@ -4746,9 +4828,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4746
4828
  options?: Record<string, unknown>;
4747
4829
  model?: string;
4748
4830
  } | {
4831
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4749
4832
  provider?: "deepgram" | "elevenlabs";
4750
4833
  kind?: "plugin";
4751
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4752
4834
  options?: Record<string, unknown>;
4753
4835
  } | {
4754
4836
  provider?: "google" | "xai" | "openai";
@@ -4762,9 +4844,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4762
4844
  options?: Record<string, unknown>;
4763
4845
  model?: string;
4764
4846
  } | {
4847
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4765
4848
  provider?: "deepgram" | "elevenlabs";
4766
4849
  kind?: "plugin";
4767
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4768
4850
  options?: Record<string, unknown>;
4769
4851
  } | {
4770
4852
  provider?: "google" | "xai" | "openai";
@@ -4777,9 +4859,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4777
4859
  options?: Record<string, unknown>;
4778
4860
  model?: string;
4779
4861
  } | {
4862
+ class?: "LLM" | "STT" | "STTv2" | "TTS";
4780
4863
  provider?: "deepgram" | "elevenlabs";
4781
4864
  kind?: "plugin";
4782
- class?: "LLM" | "STT" | "STTv2" | "TTS";
4783
4865
  options?: Record<string, unknown>;
4784
4866
  } | {
4785
4867
  provider?: "google" | "xai" | "openai";