lua-cli 3.38.0 → 3.39.0

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
  /**