lua-cli 3.32.1 → 3.32.3

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.
@@ -18,7 +18,16 @@ import { SerializedWorkflowGraph } from '@lua/workflow-graph';
18
18
  import { TemplateBinding } from '@lua/workflow-graph';
19
19
  import { TypedRef } from '@lua/workflow-graph';
20
20
  import { UserContent } from 'ai';
21
+ import { WorkflowExecFn as WorkflowExec } from '@lua/shared-types/workflow-exec';
22
+ import { WorkflowExecBinary } from '@lua/shared-types/workflow-exec';
23
+ import { WorkflowExecError } from '@lua/shared-types/workflow-exec';
24
+ import { WorkflowExecErrorCode } from '@lua/shared-types/workflow-exec';
25
+ import { WorkflowExecOptions } from '@lua/shared-types/workflow-exec';
26
+ import { WorkflowExecRefusalReason } from '@lua/shared-types/workflow-exec';
27
+ import { WorkflowExecOutcome as WorkflowExecResult } from '@lua/shared-types/workflow-exec';
21
28
  import { WorkflowGraphEntry } from '@lua/workflow-graph';
29
+ import { WorkflowShellFn as WorkflowShell } from '@lua/shared-types/workflow-exec';
30
+ import { WorkflowShellValue } from '@lua/shared-types/workflow-exec';
22
31
  import { z } from 'zod';
23
32
  import { ZodType } from 'zod';
24
33
 
@@ -180,6 +189,34 @@ declare interface AgentInvocationInput {
180
189
  };
181
190
  }
182
191
 
192
+ /**
193
+ * LUA-724 (PR 7) — the billed turn's pricing inputs, exactly as chat's settlement event carries
194
+ * them (`chat.service.trackLlmInferenceUsage`): the model that ACTUALLY served the turn (the
195
+ * resolver's code, not the caller's pin), the de-paged `contextInputTokens` (largest single
196
+ * step's prompt — never the whole-turn sum), the tool-call COUNT, and whether the turn ran on
197
+ * the org's own key. `chargedCredits` echoes the gate's answer (true ⇒ the legacy pool deducted
198
+ * in real time; false ⇒ seat org / free turn — settlement meters it).
199
+ *
200
+ * Stamped by the serving pod ONLY on internal-auth turns that carry a billing `operationId`
201
+ * (the workflow agent-step loopback), as the enumerable `luaMeter` top-level field of the
202
+ * generate envelope — never on a Bearer turn, so the public wire is byte-identical. The
203
+ * workflow executor prices the step's `run.budget.spent` from it with `priceModelCall`.
204
+ */
205
+ declare interface AgentInvocationMeter {
206
+ model?: string;
207
+ contextInputTokens?: number;
208
+ /** Tool-call COUNT (`toolNames.length`) — the tier's tool signal. */
209
+ toolsFired?: number;
210
+ /**
211
+ * The tool names fired, one entry per call (repeats kept), exactly as the usage event's
212
+ * `toolNames` — settlement intersects them with the pricing config's `docProcessingToolNames`
213
+ * to force the heavy tier (`hasDocProcessingTool`), so the workflow price must see them too.
214
+ */
215
+ toolNames?: string[];
216
+ byok?: boolean;
217
+ chargedCredits?: boolean;
218
+ }
219
+
183
220
  declare interface AgentInvocationOutput {
184
221
  /** Final response text (post-processor-modified, if applicable). */
185
222
  text: string;
@@ -202,6 +239,12 @@ declare interface AgentInvocationOutput {
202
239
  };
203
240
  /** Names of tools invoked during generation. */
204
241
  toolsUsed?: string[];
242
+ /**
243
+ * LUA-724 (PR 7) — the turn's pricing inputs (see `AgentInvocationMeter`). Present only when
244
+ * the serving pod stamped `luaMeter` (an `operationId`-bearing internal-auth turn); absent
245
+ * otherwise — legacy outputs are byte-identical.
246
+ */
247
+ meter?: AgentInvocationMeter;
205
248
  /** Trusted effects emitted by Lua-owned tool wrappers. This is intentionally
206
249
  * a small aggregate, not raw tool output: unattended task receipts use it
207
250
  * to report what happened without trusting model-authored prose. */
@@ -307,13 +350,13 @@ export declare interface AgentStepOptions {
307
350
  };
308
351
  timeoutSeconds?: number;
309
352
  retry?: RetryPolicy;
310
- onError?: 'fail' | 'continue' | 'park';
353
+ onError?: WorkflowOnError;
311
354
  requiredConnections?: string[];
312
355
  /** static-only persona override (§11 S3) */
313
356
  systemPrompt?: string;
314
- tier?: 'job';
357
+ tier?: WorkflowTier;
315
358
  workspace?: WorkflowStepWorkspace;
316
- jobResources?: 'small' | 'medium' | 'large';
359
+ jobResources?: WorkflowJobResources;
317
360
  harness?: WorkflowJobHarness;
318
361
  /** Coding-turn cap for a tier:'job' step (1..500); absent ⇒ the platform default. A monorepo change needs more than the default. */
319
362
  maxTurns?: number;
@@ -322,7 +365,8 @@ export declare interface AgentStepOptions {
322
365
  * attempt (every pass and resumed segment). Crossing one checkpoints the workspace and ends the attempt
323
366
  * `attempt_budget_exhausted` — retryable, so the step's `retry` policy continues from that tree with a fresh
324
367
  * session. `maxMessages` counts harness messages (one per content block; 1..5000, default 400),
325
- * `maxInputTokens` the attempt's input-side tokens (prompt + cache; 1M..500M, default 30M).
368
+ * `maxInputTokens` the attempt's input-side tokens (prompt + cache; 1M..500M, default 4M — LUA-708: the per-attempt
369
+ * cost bound, since `budget.maxCredits` counts attempts, not tokens).
326
370
  */
327
371
  maxMessages?: number;
328
372
  maxInputTokens?: number;
@@ -553,7 +597,7 @@ export declare interface ApprovalOptions {
553
597
  /** 'deny' (default) | 'cancel-run' | 'fail' | a chain of ≤ 3 hops ending in one terminal member */
554
598
  onTimeout?: WorkflowSuspendTimeoutChain;
555
599
  /** default 'continue' (denial is data unless 'fail') */
556
- onDeny?: 'fail' | 'continue';
600
+ onDeny?: WorkflowApprovalOnDeny;
557
601
  businessHours?: WorkflowBusinessHours;
558
602
  editable?: boolean;
559
603
  /** grammar: `drafts`, `drafts[*]`, `drafts[*].body`, `drafts[3].body`, `summary.title` */
@@ -909,11 +953,14 @@ declare interface BuiltWorkflow {
909
953
  }>;
910
954
  }
911
955
 
912
- /** R11 — `CancelRunVerdict` (PRO-979 vocabulary). */
956
+ /** R11 — `CancelRunVerdict` (PRO-979 vocabulary; §9.5.2 — a terminal run answers `state:'terminal'`, never an error). */
913
957
  declare interface CancelRunVerdict {
914
958
  status: WorkflowRunStatus;
915
959
  nextAction: string;
916
960
  forceAvailableAt?: string;
961
+ cancelRequested?: boolean;
962
+ state?: 'running' | 'cancellation_requested' | 'abandoned' | 'terminal';
963
+ transitioned?: boolean;
917
964
  }
918
965
 
919
966
  /**
@@ -1310,7 +1357,13 @@ export declare interface ChatHistoryMessage {
1310
1357
  */
1311
1358
  export declare type ChatMessage = TextMessage | ImageMessage | FileMessage;
1312
1359
 
1313
- /** A container arm: a `StepRef`, or (B14 — lands with WF-509) the two-element chain `[mapConfig, stepRef]`. */
1360
+ /**
1361
+ * A container arm: a `StepRef` — a `createStep` object, or a string naming an entry declared elsewhere in the chain
1362
+ * (`agentStep` / `specialistStep` / `toolStep` / `workflow`, and since LUA-684 `approval` / `waitForSignal`, so an
1363
+ * approval can run concurrently with another row) — or (B14 — lands with WF-509) the two-element chain
1364
+ * `[mapConfig, stepRef]`. A HITL arm takes the previous output as its payload, so it never heads a `[map, step]`
1365
+ * chain, and a `loop` body cannot be one until the engine proves it (`node-type-unsupported-in-container`).
1366
+ */
1314
1367
  export declare type ContainerArm = StepRef | [LuaMapConfig, StepRef];
1315
1368
 
1316
1369
  /**
@@ -3882,13 +3935,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3882
3935
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3883
3936
  }, "strip", z.ZodTypeAny, {
3884
3937
  voice?: string;
3885
- options?: Record<string, unknown>;
3886
3938
  kind?: "inference";
3939
+ options?: Record<string, unknown>;
3887
3940
  model?: string;
3888
3941
  }, {
3889
3942
  voice?: string;
3890
- options?: Record<string, unknown>;
3891
3943
  kind?: "inference";
3944
+ options?: Record<string, unknown>;
3892
3945
  model?: string;
3893
3946
  }>, z.ZodObject<{
3894
3947
  kind: z.ZodLiteral<"plugin">;
@@ -3903,13 +3956,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3903
3956
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3904
3957
  }, "strip", z.ZodTypeAny, {
3905
3958
  provider?: "deepgram" | "elevenlabs";
3906
- options?: Record<string, unknown>;
3907
3959
  kind?: "plugin";
3960
+ options?: Record<string, unknown>;
3908
3961
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3909
3962
  }, {
3910
3963
  provider?: "deepgram" | "elevenlabs";
3911
- options?: Record<string, unknown>;
3912
3964
  kind?: "plugin";
3965
+ options?: Record<string, unknown>;
3913
3966
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3914
3967
  }>, z.ZodObject<{
3915
3968
  kind: z.ZodLiteral<"realtime">;
@@ -3923,12 +3976,12 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3923
3976
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3924
3977
  }, "strip", z.ZodTypeAny, {
3925
3978
  provider?: "google" | "xai" | "openai";
3926
- options?: Record<string, unknown>;
3927
3979
  kind?: "realtime";
3980
+ options?: Record<string, unknown>;
3928
3981
  }, {
3929
3982
  provider?: "google" | "xai" | "openai";
3930
- options?: Record<string, unknown>;
3931
3983
  kind?: "realtime";
3984
+ options?: Record<string, unknown>;
3932
3985
  }>]>;
3933
3986
  stt: z.ZodOptional<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
3934
3987
  kind: z.ZodLiteral<"inference">;
@@ -3948,13 +4001,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3948
4001
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3949
4002
  }, "strip", z.ZodTypeAny, {
3950
4003
  voice?: string;
3951
- options?: Record<string, unknown>;
3952
4004
  kind?: "inference";
4005
+ options?: Record<string, unknown>;
3953
4006
  model?: string;
3954
4007
  }, {
3955
4008
  voice?: string;
3956
- options?: Record<string, unknown>;
3957
4009
  kind?: "inference";
4010
+ options?: Record<string, unknown>;
3958
4011
  model?: string;
3959
4012
  }>, z.ZodObject<{
3960
4013
  kind: z.ZodLiteral<"plugin">;
@@ -3969,13 +4022,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3969
4022
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3970
4023
  }, "strip", z.ZodTypeAny, {
3971
4024
  provider?: "deepgram" | "elevenlabs";
3972
- options?: Record<string, unknown>;
3973
4025
  kind?: "plugin";
4026
+ options?: Record<string, unknown>;
3974
4027
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3975
4028
  }, {
3976
4029
  provider?: "deepgram" | "elevenlabs";
3977
- options?: Record<string, unknown>;
3978
4030
  kind?: "plugin";
4031
+ options?: Record<string, unknown>;
3979
4032
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3980
4033
  }>, z.ZodObject<{
3981
4034
  kind: z.ZodLiteral<"realtime">;
@@ -3989,12 +4042,12 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3989
4042
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3990
4043
  }, "strip", z.ZodTypeAny, {
3991
4044
  provider?: "google" | "xai" | "openai";
3992
- options?: Record<string, unknown>;
3993
4045
  kind?: "realtime";
4046
+ options?: Record<string, unknown>;
3994
4047
  }, {
3995
4048
  provider?: "google" | "xai" | "openai";
3996
- options?: Record<string, unknown>;
3997
4049
  kind?: "realtime";
4050
+ options?: Record<string, unknown>;
3998
4051
  }>]>>;
3999
4052
  tts: z.ZodOptional<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
4000
4053
  kind: z.ZodLiteral<"inference">;
@@ -4014,13 +4067,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4014
4067
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
4015
4068
  }, "strip", z.ZodTypeAny, {
4016
4069
  voice?: string;
4017
- options?: Record<string, unknown>;
4018
4070
  kind?: "inference";
4071
+ options?: Record<string, unknown>;
4019
4072
  model?: string;
4020
4073
  }, {
4021
4074
  voice?: string;
4022
- options?: Record<string, unknown>;
4023
4075
  kind?: "inference";
4076
+ options?: Record<string, unknown>;
4024
4077
  model?: string;
4025
4078
  }>, z.ZodObject<{
4026
4079
  kind: z.ZodLiteral<"plugin">;
@@ -4035,13 +4088,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4035
4088
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4036
4089
  }, "strip", z.ZodTypeAny, {
4037
4090
  provider?: "deepgram" | "elevenlabs";
4038
- options?: Record<string, unknown>;
4039
4091
  kind?: "plugin";
4092
+ options?: Record<string, unknown>;
4040
4093
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4041
4094
  }, {
4042
4095
  provider?: "deepgram" | "elevenlabs";
4043
- options?: Record<string, unknown>;
4044
4096
  kind?: "plugin";
4097
+ options?: Record<string, unknown>;
4045
4098
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4046
4099
  }>, z.ZodObject<{
4047
4100
  kind: z.ZodLiteral<"realtime">;
@@ -4055,12 +4108,12 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4055
4108
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4056
4109
  }, "strip", z.ZodTypeAny, {
4057
4110
  provider?: "google" | "xai" | "openai";
4058
- options?: Record<string, unknown>;
4059
4111
  kind?: "realtime";
4112
+ options?: Record<string, unknown>;
4060
4113
  }, {
4061
4114
  provider?: "google" | "xai" | "openai";
4062
- options?: Record<string, unknown>;
4063
4115
  kind?: "realtime";
4116
+ options?: Record<string, unknown>;
4064
4117
  }>]>>;
4065
4118
  vad: z.ZodOptional<z.ZodString>;
4066
4119
  vadOptions: z.ZodOptional<z.ZodObject<{
@@ -4222,49 +4275,49 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4222
4275
  vad?: string;
4223
4276
  stt?: {
4224
4277
  voice?: string;
4225
- options?: Record<string, unknown>;
4226
4278
  kind?: "inference";
4279
+ options?: Record<string, unknown>;
4227
4280
  model?: string;
4228
4281
  } | {
4229
4282
  provider?: "deepgram" | "elevenlabs";
4230
- options?: Record<string, unknown>;
4231
4283
  kind?: "plugin";
4284
+ options?: Record<string, unknown>;
4232
4285
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4233
4286
  } | {
4234
4287
  provider?: "google" | "xai" | "openai";
4235
- options?: Record<string, unknown>;
4236
4288
  kind?: "realtime";
4289
+ options?: Record<string, unknown>;
4237
4290
  };
4238
4291
  volume?: number;
4239
4292
  llm?: {
4240
4293
  voice?: string;
4241
- options?: Record<string, unknown>;
4242
4294
  kind?: "inference";
4295
+ options?: Record<string, unknown>;
4243
4296
  model?: string;
4244
4297
  } | {
4245
4298
  provider?: "deepgram" | "elevenlabs";
4246
- options?: Record<string, unknown>;
4247
4299
  kind?: "plugin";
4300
+ options?: Record<string, unknown>;
4248
4301
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4249
4302
  } | {
4250
4303
  provider?: "google" | "xai" | "openai";
4251
- options?: Record<string, unknown>;
4252
4304
  kind?: "realtime";
4305
+ options?: Record<string, unknown>;
4253
4306
  };
4254
4307
  tts?: {
4255
4308
  voice?: string;
4256
- options?: Record<string, unknown>;
4257
4309
  kind?: "inference";
4310
+ options?: Record<string, unknown>;
4258
4311
  model?: string;
4259
4312
  } | {
4260
4313
  provider?: "deepgram" | "elevenlabs";
4261
- options?: Record<string, unknown>;
4262
4314
  kind?: "plugin";
4315
+ options?: Record<string, unknown>;
4263
4316
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4264
4317
  } | {
4265
4318
  provider?: "google" | "xai" | "openai";
4266
- options?: Record<string, unknown>;
4267
4319
  kind?: "realtime";
4320
+ options?: Record<string, unknown>;
4268
4321
  };
4269
4322
  vadOptions?: {
4270
4323
  minSpeechDuration?: number;
@@ -4316,49 +4369,49 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4316
4369
  vad?: string;
4317
4370
  stt?: {
4318
4371
  voice?: string;
4319
- options?: Record<string, unknown>;
4320
4372
  kind?: "inference";
4373
+ options?: Record<string, unknown>;
4321
4374
  model?: string;
4322
4375
  } | {
4323
4376
  provider?: "deepgram" | "elevenlabs";
4324
- options?: Record<string, unknown>;
4325
4377
  kind?: "plugin";
4378
+ options?: Record<string, unknown>;
4326
4379
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4327
4380
  } | {
4328
4381
  provider?: "google" | "xai" | "openai";
4329
- options?: Record<string, unknown>;
4330
4382
  kind?: "realtime";
4383
+ options?: Record<string, unknown>;
4331
4384
  };
4332
4385
  volume?: number;
4333
4386
  llm?: {
4334
4387
  voice?: string;
4335
- options?: Record<string, unknown>;
4336
4388
  kind?: "inference";
4389
+ options?: Record<string, unknown>;
4337
4390
  model?: string;
4338
4391
  } | {
4339
4392
  provider?: "deepgram" | "elevenlabs";
4340
- options?: Record<string, unknown>;
4341
4393
  kind?: "plugin";
4394
+ options?: Record<string, unknown>;
4342
4395
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4343
4396
  } | {
4344
4397
  provider?: "google" | "xai" | "openai";
4345
- options?: Record<string, unknown>;
4346
4398
  kind?: "realtime";
4399
+ options?: Record<string, unknown>;
4347
4400
  };
4348
4401
  tts?: {
4349
4402
  voice?: string;
4350
- options?: Record<string, unknown>;
4351
4403
  kind?: "inference";
4404
+ options?: Record<string, unknown>;
4352
4405
  model?: string;
4353
4406
  } | {
4354
4407
  provider?: "deepgram" | "elevenlabs";
4355
- options?: Record<string, unknown>;
4356
4408
  kind?: "plugin";
4409
+ options?: Record<string, unknown>;
4357
4410
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4358
4411
  } | {
4359
4412
  provider?: "google" | "xai" | "openai";
4360
- options?: Record<string, unknown>;
4361
4413
  kind?: "realtime";
4414
+ options?: Record<string, unknown>;
4362
4415
  };
4363
4416
  vadOptions?: {
4364
4417
  minSpeechDuration?: number;
@@ -4410,49 +4463,49 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4410
4463
  vad?: string;
4411
4464
  stt?: {
4412
4465
  voice?: string;
4413
- options?: Record<string, unknown>;
4414
4466
  kind?: "inference";
4467
+ options?: Record<string, unknown>;
4415
4468
  model?: string;
4416
4469
  } | {
4417
4470
  provider?: "deepgram" | "elevenlabs";
4418
- options?: Record<string, unknown>;
4419
4471
  kind?: "plugin";
4472
+ options?: Record<string, unknown>;
4420
4473
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4421
4474
  } | {
4422
4475
  provider?: "google" | "xai" | "openai";
4423
- options?: Record<string, unknown>;
4424
4476
  kind?: "realtime";
4477
+ options?: Record<string, unknown>;
4425
4478
  };
4426
4479
  volume?: number;
4427
4480
  llm?: {
4428
4481
  voice?: string;
4429
- options?: Record<string, unknown>;
4430
4482
  kind?: "inference";
4483
+ options?: Record<string, unknown>;
4431
4484
  model?: string;
4432
4485
  } | {
4433
4486
  provider?: "deepgram" | "elevenlabs";
4434
- options?: Record<string, unknown>;
4435
4487
  kind?: "plugin";
4488
+ options?: Record<string, unknown>;
4436
4489
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4437
4490
  } | {
4438
4491
  provider?: "google" | "xai" | "openai";
4439
- options?: Record<string, unknown>;
4440
4492
  kind?: "realtime";
4493
+ options?: Record<string, unknown>;
4441
4494
  };
4442
4495
  tts?: {
4443
4496
  voice?: string;
4444
- options?: Record<string, unknown>;
4445
4497
  kind?: "inference";
4498
+ options?: Record<string, unknown>;
4446
4499
  model?: string;
4447
4500
  } | {
4448
4501
  provider?: "deepgram" | "elevenlabs";
4449
- options?: Record<string, unknown>;
4450
4502
  kind?: "plugin";
4503
+ options?: Record<string, unknown>;
4451
4504
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4452
4505
  } | {
4453
4506
  provider?: "google" | "xai" | "openai";
4454
- options?: Record<string, unknown>;
4455
4507
  kind?: "realtime";
4508
+ options?: Record<string, unknown>;
4456
4509
  };
4457
4510
  vadOptions?: {
4458
4511
  minSpeechDuration?: number;
@@ -4504,49 +4557,49 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4504
4557
  vad?: string;
4505
4558
  stt?: {
4506
4559
  voice?: string;
4507
- options?: Record<string, unknown>;
4508
4560
  kind?: "inference";
4561
+ options?: Record<string, unknown>;
4509
4562
  model?: string;
4510
4563
  } | {
4511
4564
  provider?: "deepgram" | "elevenlabs";
4512
- options?: Record<string, unknown>;
4513
4565
  kind?: "plugin";
4566
+ options?: Record<string, unknown>;
4514
4567
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4515
4568
  } | {
4516
4569
  provider?: "google" | "xai" | "openai";
4517
- options?: Record<string, unknown>;
4518
4570
  kind?: "realtime";
4571
+ options?: Record<string, unknown>;
4519
4572
  };
4520
4573
  volume?: number;
4521
4574
  llm?: {
4522
4575
  voice?: string;
4523
- options?: Record<string, unknown>;
4524
4576
  kind?: "inference";
4577
+ options?: Record<string, unknown>;
4525
4578
  model?: string;
4526
4579
  } | {
4527
4580
  provider?: "deepgram" | "elevenlabs";
4528
- options?: Record<string, unknown>;
4529
4581
  kind?: "plugin";
4582
+ options?: Record<string, unknown>;
4530
4583
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4531
4584
  } | {
4532
4585
  provider?: "google" | "xai" | "openai";
4533
- options?: Record<string, unknown>;
4534
4586
  kind?: "realtime";
4587
+ options?: Record<string, unknown>;
4535
4588
  };
4536
4589
  tts?: {
4537
4590
  voice?: string;
4538
- options?: Record<string, unknown>;
4539
4591
  kind?: "inference";
4592
+ options?: Record<string, unknown>;
4540
4593
  model?: string;
4541
4594
  } | {
4542
4595
  provider?: "deepgram" | "elevenlabs";
4543
- options?: Record<string, unknown>;
4544
4596
  kind?: "plugin";
4597
+ options?: Record<string, unknown>;
4545
4598
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4546
4599
  } | {
4547
4600
  provider?: "google" | "xai" | "openai";
4548
- options?: Record<string, unknown>;
4549
4601
  kind?: "realtime";
4602
+ options?: Record<string, unknown>;
4550
4603
  };
4551
4604
  vadOptions?: {
4552
4605
  minSpeechDuration?: number;
@@ -4935,20 +4988,28 @@ export declare type LuaWorkflowBuildCode = 'duplicate-step-id' | 'unknown-step-r
4935
4988
  * verdict (deferred for an inherit child, 03 §3.1 table). Kept for one minor so a consumer switching on the union still
4936
4989
  * compiles; removed in the next.
4937
4990
  */
4938
- | 'workspace-not-declared' | 'workspace-inherit-without-parent-workspace' | 'workspace-inherit-conflict' | 'harness-requires-job-tier' | 'max-turns-requires-job-tier' | 'max-turns-invalid' | 'cap-exceeded' | 'chunk-size-invalid' | 'rate-limit-invalid' | 'backoff-invalid' | 'loop-interval-out-of-range' | 'mapping-placement' | 'container-arm-empty' | 'approval-inside-container' | 'empty-graph' | 'ephemeral-role-too-long' | 'role-ref-and-inline' | 'approver-excludes-only-candidate' | 'four-eyes-requires-editable' | 'escalation-chain-not-terminal' | 'escalation-chain-too-long' | 'editable-path-invalid' | 'env-template-secret-key' | 'invalid-envelope' | 'invalid-step' | 'invalid-step-id' | 'invalid-workflow-name' | 'schedule-input-required' | 'schedule-input-invalid' | 'hitl-duration-defaulted' | 'WORKFLOW_UNPLACED_STEP';
4991
+ | 'workspace-not-declared' | 'workspace-inherit-without-parent-workspace' | 'workspace-inherit-conflict' | 'harness-requires-job-tier' | 'max-turns-requires-job-tier' | 'max-turns-invalid' | 'cap-exceeded' | 'chunk-size-invalid' | 'rate-limit-invalid' | 'backoff-invalid' | 'loop-interval-out-of-range' | 'mapping-placement' | 'container-arm-empty'
4992
+ /**
4993
+ * @deprecated LUA-684 — the builder no longer throws it: an `approval` / `waitForSignal` IS a container arm
4994
+ * (`parallel(['approve', …])`). Where the engine cannot run one — a `loop` body, the step of a `[map, step]`
4995
+ * chain — the code is `node-type-unsupported-in-container`. Kept for one minor so a consumer switching on the
4996
+ * union still compiles; removed in the next.
4997
+ */
4998
+ | 'approval-inside-container' | 'node-type-unsupported-in-container' | 'empty-graph' | 'ephemeral-role-too-long' | 'role-ref-and-inline' | 'approver-excludes-only-candidate' | 'four-eyes-requires-editable' | 'escalation-chain-not-terminal' | 'escalation-chain-too-long' | 'editable-path-invalid' | 'env-template-secret-key' | 'invalid-envelope' | 'invalid-step' | 'invalid-step-id' | 'invalid-workflow-name' | 'schedule-input-required' | 'schedule-input-invalid' | 'hitl-duration-defaulted' | 'WORKFLOW_UNPLACED_STEP';
4939
4999
 
4940
5000
  export declare interface LuaWorkflowBuilder {
4941
5001
  then(step: StepRef): this;
4942
- /** 2..16 arms; output = { [stepId]: output } */
5002
+ /** 2..16 arms; output = { [stepId]: output }. An `approval` / `waitForSignal` arm (by id) parks beside its siblings. */
4943
5003
  parallel(steps: ContainerArm[], opts?: {
4944
5004
  merge?: WorkflowMergePolicy;
4945
5005
  }): this;
4946
- /** all-true arms run (Mastra); exclusive:true ≡ switch() */
5006
+ /** all-true arms run (Mastra); exclusive:true ≡ switch(). An arm may name a declared `approval` / `waitForSignal`. */
4947
5007
  branch(arms: Array<[LuaPredicate, StepRef]>, opts?: {
4948
5008
  exclusive?: boolean;
4949
5009
  }): this;
4950
5010
  /** first true arm only ⇒ conditional{ exclusive:true, otherwise } */
4951
5011
  switch(arms: Array<[LuaPredicate, StepRef]>, otherwise?: StepRef): this;
5012
+ /** one body run per item; an `approval` / `waitForSignal` body (by id) is one approval / wait per item */
4952
5013
  foreach(step: ContainerArm, opts?: ForeachOptions): this;
4953
5014
  dowhile(step: ContainerArm, predicate: LuaPredicate, opts?: LoopOptions): this;
4954
5015
  dountil(step: ContainerArm, predicate: LuaPredicate, opts?: LoopOptions): this;
@@ -4971,12 +5032,11 @@ export declare interface LuaWorkflowBuilder {
4971
5032
  /** D25 ephemeral specialist: runs AS THE OWNING AGENT (`agentId:'$self'`) with an additive role block. */
4972
5033
  specialistStep(id: string, opts: SpecialistStepOptions): this;
4973
5034
  toolStep(id: string, tool: LuaTool<any>, opts?: ToolStepOptions): this;
5035
+ /** a declaration like `agentStep` (LUA-684): placed where called unless a container claims the id — `parallel(['approve', …])` */
4974
5036
  approval(id: string, opts: ApprovalOptions): this;
4975
5037
  waitForSignal(id: string, opts: WaitForSignalOptions): this;
4976
5038
  /** nested run; depth ≤ 3 — declares `id`, so a container may place it by string ref (03 §3.2.0) */
4977
- workflow(id: string, ref: LuaWorkflow | string, input?: LuaMapConfig, opts?: {
4978
- workspace?: 'inherit';
4979
- }): this;
5039
+ workflow(id: string, ref: LuaWorkflow | string, input?: LuaMapConfig, opts?: NestedWorkflowOptions): this;
4980
5040
  commit(): LuaWorkflow;
4981
5041
  }
4982
5042
 
@@ -5004,12 +5064,23 @@ export declare interface LuaWorkflowConfig {
5004
5064
  concurrencyPolicy?: 'allow' | 'forbid';
5005
5065
  /** Who may READ this workflow's run outputs beyond `workflows:read-outputs` holders (B44). Envelope member outside `graphHash`. */
5006
5066
  outputVisibility?: WorkflowOutputVisibility;
5007
- /** `maxDurationSeconds` default 604 800; 2 592 000 when the graph contains an approval / waitForSignal / suspend-capable step (P1-4). */
5008
- budget?: {
5009
- maxCredits?: number;
5010
- maxSteps?: number;
5011
- maxDurationSeconds?: number;
5012
- };
5067
+ /**
5068
+ * `maxDurationSeconds` default 604 800; 2 592 000 when the graph contains an approval / waitForSignal / suspend-capable
5069
+ * step (P1-4). The three members the SDK forwards, spelled by the ONE definition budget (`WorkflowDefinitionBudget`).
5070
+ *
5071
+ * `maxCredits` never meters tokens (LUA-708). Flat metering (every run while `LUA_WORKFLOWS_METERING_V2` is off):
5072
+ * an inline agent step settles a flat 1 credit when it completes, a `tier:'job'` attempt a flat 4 at its first
5073
+ * claim (a retry is a new attempt) — so `maxCredits: 40` buys ten Job-tier attempts, and a value under 4 never
5074
+ * dispatches one. Priced metering (LUA-724, the flag on): an inline agent step settles what chat charged for the
5075
+ * turn — one credit per model call on the legacy plan, `tier × model multiplier` actions on a seat plan (then the
5076
+ * cap is compared in actions) — and `lua workflows status` says which mode a run used (`usage.metering`). Either
5077
+ * way the run parks on a budget gate (`nextAction:'raise_budget'`, `lua workflows raise-budget`) when what remains
5078
+ * is under the next agent step's reserve. Each Job-tier attempt then runs to its own wall (`timeoutSeconds`),
5079
+ * `maxInputTokens` (default 4M ≈ $1–13 on a Sonnet-class model), `maxMessages` and `maxTurns`; nothing meters its
5080
+ * tokens against the credits mid-attempt. Size `maxInputTokens` for what one attempt may cost and `maxCredits`
5081
+ * for how many attempts the run may make.
5082
+ */
5083
+ budget?: Pick<WorkflowDefinitionBudget, 'maxCredits' | 'maxSteps' | 'maxDurationSeconds'>;
5013
5084
  /** verbatim LuaJob union (D12) → Job{kind:'workflow'} on publish */
5014
5085
  schedule?: JobSchedule;
5015
5086
  backfillOnEnable?: {
@@ -5042,16 +5113,16 @@ export declare interface LuaWorkflowStep<TIn extends ZodType = ZodType, TOut ext
5042
5113
  /** 1..600 (D19); default 300 — on `tier:'job'` 1..86 400, default 3600. */
5043
5114
  timeoutSeconds?: number;
5044
5115
  /** Run this step as a k8s Job (hours tier). Implied by `workspace`. */
5045
- tier?: 'job';
5116
+ tier?: WorkflowTier;
5046
5117
  workspace?: WorkflowStepWorkspace;
5047
- jobResources?: 'small' | 'medium' | 'large';
5118
+ jobResources?: WorkflowJobResources;
5048
5119
  jobTools?: WorkflowJobToolId[];
5049
5120
  /** default { maxAttempts: 1 } */
5050
5121
  retry?: RetryPolicy;
5051
5122
  /** default 'none'; 'external' ⇒ park on platform-fault reclaim. */
5052
- sideEffects?: 'none' | 'external';
5123
+ sideEffects?: WorkflowSideEffects;
5053
5124
  /** What the FINAL failure of this step does to the run (default 'fail'). */
5054
- onError?: 'fail' | 'continue' | 'park';
5125
+ onError?: WorkflowOnError;
5055
5126
  requiredConnections?: string[];
5056
5127
  /** Deadline for a `ctx.suspend()` suspension; default 168, max 720. */
5057
5128
  resumeTimeoutHours?: number;
@@ -5174,6 +5245,18 @@ declare type Message = TextMessage_2 | ImageMessage_2 | FileMessage_2;
5174
5245
 
5175
5246
  export declare const ne: <T>(l: TypedRef<T>, r: TypedRef<T> | Literal<T>) => LuaPredicate;
5176
5247
 
5248
+ /** `.workflow(id, ref, input?, opts?)` — a nested run (a `subrun` row). */
5249
+ export declare interface NestedWorkflowOptions {
5250
+ /** Mount the PARENT's run workspace in the child (05 §5.17.5; LUA-650) — the parent must declare one. */
5251
+ workspace?: 'inherit';
5252
+ /**
5253
+ * LUA-669 (#2446): the same policy a code / agent / tool step carries — the row re-arms when the child run ends
5254
+ * `failed` or `timed_out` on its own (a child the parent side ended — cancelled, abandoned — is never retried),
5255
+ * behind the WF-222 backoff, and every attempt starts a FRESH child run. Default `{ maxAttempts: 1 }`.
5256
+ */
5257
+ retry?: RetryPolicy;
5258
+ }
5259
+
5177
5260
  export declare const not: (arg: LuaPredicate) => LuaPredicate;
5178
5261
 
5179
5262
  export declare const notExists: (ref: TypedRef<unknown>) => LuaPredicate;
@@ -6076,6 +6159,11 @@ declare interface RequestOverrides {
6076
6159
  timeoutMs?: number;
6077
6160
  }
6078
6161
 
6162
+ /**
6163
+ * R12 — `ResumeStepResult` (§9.5.3): the loser of a resume race gets the recorded outcome, never a 4xx. LUA-738
6164
+ * (desktop #1018): `recorded.by` is the spec's `WorkflowActorRef` — lua-api projects lua-core's `{ kind, id }` onto
6165
+ * it (`system:timed_out` for the timeout sweep, `system:<id>` with `source:'webhook'` for a webhook caller).
6166
+ */
6079
6167
  declare type ResumeStepResult = {
6080
6168
  resumed: true;
6081
6169
  runStatus: WorkflowRunStatus;
@@ -6085,22 +6173,18 @@ declare type ResumeStepResult = {
6085
6173
  recorded: {
6086
6174
  at: number;
6087
6175
  by?: {
6088
- kind: string;
6089
- id?: string;
6176
+ subjectType: string;
6177
+ subjectId: string;
6178
+ source: string;
6090
6179
  };
6091
6180
  };
6092
6181
  runStatus: WorkflowRunStatus;
6093
6182
  };
6094
6183
 
6095
- export declare interface RetryPolicy {
6096
- maxAttempts: number;
6097
- /** delay before attempt 2 (default 0 = immediate) */
6098
- backoffSeconds?: number;
6099
- /** 'fixed' (default) | 'exponential' — an engine timer, never a sleep inside the step VM (P1-10). */
6100
- backoff?: 'fixed' | 'exponential';
6101
- /** default 3600; only meaningful with 'exponential' (`backoff-invalid` otherwise). */
6102
- maxBackoffSeconds?: number;
6103
- }
6184
+ /** The ONE retry shape (`@lua/shared-types` `WorkflowRetryPolicy`): `maxAttempts` ≥ 1; `backoffSeconds` (default 0 =
6185
+ * immediate) — an engine timer, never a sleep inside the step VM (P1-10); `backoff` 'fixed' (default) | 'exponential';
6186
+ * `maxBackoffSeconds` (default 3600) only meaningful with 'exponential' (`backoff-invalid` otherwise). */
6187
+ export declare type RetryPolicy = WorkflowRetryPolicy;
6104
6188
 
6105
6189
  export declare const rows: (s: LuaWorkflowStep<any, any, any> | string, path: string, page: {
6106
6190
  offset: number;
@@ -6191,7 +6275,7 @@ export declare interface SpecialistStepOptions {
6191
6275
  toolScope?: AgentToolScope;
6192
6276
  timeoutSeconds?: number;
6193
6277
  retry?: RetryPolicy;
6194
- onError?: 'fail' | 'continue' | 'park';
6278
+ onError?: WorkflowOnError;
6195
6279
  requiredConnections?: string[];
6196
6280
  }
6197
6281
 
@@ -6202,12 +6286,23 @@ declare interface SseFrame {
6202
6286
  data: unknown;
6203
6287
  }
6204
6288
 
6205
- /** R8 — 202 `{ runId, status:'queued'|'gated', watchHint, idempotentReplay? }`, or 200 the run detail when `waitSeconds` elapsed on a terminal/suspended run. */
6289
+ /**
6290
+ * R8 — 202 `{ runId, status:'queued'|'gated', watchHint }`, 200 `{ …, idempotentReplay:true, deduplicated:true,
6291
+ * workflowId, workflowName, startedAt }` on an Idempotency-Key replay (LUA-739: the EXISTING run's identity,
6292
+ * real status and real start — no run was created), or 200 the run detail when `waitSeconds` elapsed on a
6293
+ * terminal/suspended run.
6294
+ */
6206
6295
  declare interface StartWorkflowRunResult {
6207
6296
  runId: string;
6208
6297
  status: WorkflowRunStatus;
6209
6298
  watchHint?: string;
6210
6299
  idempotentReplay?: boolean;
6300
+ /** `true` ⇒ no run was created — `workflowId` / `workflowName` / `startedAt` / `status` are the existing holder's. */
6301
+ deduplicated?: boolean;
6302
+ workflowId?: string;
6303
+ workflowName?: string;
6304
+ /** ISO — the existing run's creation time. */
6305
+ startedAt?: string;
6211
6306
  output?: unknown;
6212
6307
  }
6213
6308
 
@@ -6446,8 +6541,8 @@ export declare interface ToolStepOptions {
6446
6541
  input?: LuaMapConfig;
6447
6542
  timeoutSeconds?: number;
6448
6543
  retry?: RetryPolicy;
6449
- sideEffects?: 'none' | 'external';
6450
- onError?: 'fail' | 'continue' | 'park';
6544
+ sideEffects?: WorkflowSideEffects;
6545
+ onError?: WorkflowOnError;
6451
6546
  requiredConnections?: string[];
6452
6547
  }
6453
6548
 
@@ -6903,7 +6998,7 @@ export declare interface WaitForSignalOptions {
6903
6998
  schema?: ZodType;
6904
6999
  timeoutHours?: number | TemplateBinding;
6905
7000
  /** default 'fail'; 'continue' ⇒ output {received:false,timedOut:true} */
6906
- onTimeout?: 'fail' | 'continue';
7001
+ onTimeout?: WorkflowSignalOnTimeout;
6907
7002
  businessHours?: WorkflowBusinessHours;
6908
7003
  /** default ['webhook','api','user'] */
6909
7004
  acceptedSources?: Array<'webhook' | 'api' | 'user' | 'agent'>;
@@ -7032,6 +7127,32 @@ declare interface WhatsAppTemplateUrlButton {
7032
7127
  example?: string | string[];
7033
7128
  }
7034
7129
 
7130
+ /** `approval.onDeny` (§6.4.11 deny-as-data): `'fail'` fails the step on a denial; default `'continue'`. */
7131
+ declare const WORKFLOW_APPROVAL_ON_DENY: readonly ["fail", "continue"];
7132
+
7133
+ /** D19-r2 (B22; 05 §5.17.6 Harness row) — both behind one `CodingHarness { run(turn) }`. */
7134
+ declare const WORKFLOW_JOB_HARNESSES: readonly ["claude-code", "generic"];
7135
+
7136
+ /** `jobResources` (05 §5.17): the Job-tier pod size class. Default `'small'` at spawn. */
7137
+ declare const WORKFLOW_JOB_RESOURCES: readonly ["small", "medium", "large"];
7138
+
7139
+ /** What the FINAL failure of a step does to the run: `'park'` → the §06 §6.3.5 exception gate. Default `'fail'`. */
7140
+ declare const WORKFLOW_ON_ERROR: readonly ["fail", "continue", "park"];
7141
+
7142
+ /** `backoff` absent ⇒ `'fixed'`; `'exponential'` = backoffSeconds·2^(attempt−1) capped at `maxBackoffSeconds`. */
7143
+ declare const WORKFLOW_RETRY_BACKOFFS: readonly ["fixed", "exponential"];
7144
+
7145
+ /** `sideEffects` (03 §3.1): `'external'` ⇒ park on platform-fault reclaim instead of retrying. Default `'none'`. */
7146
+ declare const WORKFLOW_SIDE_EFFECTS: readonly ["none", "external"];
7147
+
7148
+ /** `waitForSignal.onTimeout`: default `'fail'`; `'continue'` ⇒ output `{received:false, timedOut:true}`. */
7149
+ declare const WORKFLOW_SIGNAL_ON_TIMEOUT: readonly ["fail", "continue"];
7150
+
7151
+ /** The only tier a node may DECLARE (`tier:'job'`, implied by `workspace`); the worker tier is the absence. */
7152
+ declare const WORKFLOW_TIERS: readonly ["job"];
7153
+
7154
+ declare type WorkflowApprovalOnDeny = (typeof WORKFLOW_APPROVAL_ON_DENY)[number];
7155
+
7035
7156
  export declare type WorkflowApproverSpec = 'creator' | 'org-admins' | {
7036
7157
  users: string[] | TemplateBinding;
7037
7158
  } | {
@@ -7075,15 +7196,51 @@ export declare interface WorkflowBusinessHours {
7075
7196
  };
7076
7197
  }
7077
7198
 
7078
- declare interface WorkflowConnectionDeclaration {
7199
+ /** The ONE `connections[]` declaration shape (`@lua/shared-types`): `key` /^[a-z][a-z0-9_-]{0,63}$/ unique per workflow,
7200
+ * `integrationType` the catalog type (`'github'`, `'linear'`, …), optional `required` / `description`. */
7201
+ declare type WorkflowConnectionDeclaration = WorkflowConnectionDeclaration_2;
7202
+
7203
+ declare interface WorkflowConnectionDeclaration_2 {
7079
7204
  /** /^[a-z][a-z0-9_-]{0,63}$/ — unique per workflow. */
7080
7205
  key: string;
7081
- /** Catalog integration type (`'github'`, `'linear'`, …). */
7206
+ /** Catalog integration type (`github`, `linear`, …) the key resolves within. */
7082
7207
  integrationType: string;
7083
7208
  required?: boolean;
7084
7209
  description?: string;
7085
7210
  }
7086
7211
 
7212
+ /** The declared budget (10 §10.7.1) — every member optional on the DEFINITION; the server resolves
7213
+ * `maxDurationSeconds` onto the version (`WorkflowVersion.budget`) and the run. */
7214
+ declare interface WorkflowDefinitionBudget {
7215
+ /**
7216
+ * The run's credit ceiling — it counts agent steps, never tokens (LUA-708). An inline agent step settles a flat
7217
+ * 1 credit when it completes; a `tier:'job'` attempt settles a flat 4 at its first claim (a retry is a new
7218
+ * attempt). The engine parks the run on a budget gate (`nextAction:'raise_budget'`) when what remains is under
7219
+ * the next agent step's reserve, so `maxCredits: 40` is ten Job-tier attempts and a value under 4 never
7220
+ * dispatches one. A Job-tier attempt's own spend is bounded by its wall / `maxInputTokens` / `maxMessages`.
7221
+ */
7222
+ maxCredits?: number;
7223
+ maxSteps?: number;
7224
+ /** Job-tier seconds across the run (05 §5.17). */
7225
+ maxJobSeconds?: number;
7226
+ /** default 604 800; 2 592 000 when the graph contains an approval / waitForSignal / suspend-capable step (P1-4). */
7227
+ maxDurationSeconds?: number;
7228
+ }
7229
+
7230
+ export { WorkflowExec }
7231
+
7232
+ export { WorkflowExecBinary }
7233
+
7234
+ export { WorkflowExecError }
7235
+
7236
+ export { WorkflowExecErrorCode }
7237
+
7238
+ export { WorkflowExecOptions }
7239
+
7240
+ export { WorkflowExecRefusalReason }
7241
+
7242
+ export { WorkflowExecResult }
7243
+
7087
7244
  export declare interface WorkflowFourEyes {
7088
7245
  edit: WorkflowApproverSpec;
7089
7246
  approve: WorkflowApproverSpec;
@@ -7103,7 +7260,11 @@ export declare interface WorkflowGoalEnvelope {
7103
7260
  initialState?: Record<string, unknown>;
7104
7261
  }
7105
7262
 
7106
- export declare type WorkflowJobHarness = 'claude-code' | 'generic';
7263
+ export declare type WorkflowJobHarness = WorkflowJobHarness_2;
7264
+
7265
+ declare type WorkflowJobHarness_2 = (typeof WORKFLOW_JOB_HARNESSES)[number];
7266
+
7267
+ declare type WorkflowJobResources = (typeof WORKFLOW_JOB_RESOURCES)[number];
7107
7268
 
7108
7269
  export declare type WorkflowJobToolId = 'shell' | 'read' | 'write' | 'edit' | 'glob' | 'grep' | 'git' | 'gh' | 'fetch';
7109
7270
 
@@ -7112,12 +7273,26 @@ export declare interface WorkflowMergePolicy {
7112
7273
  onConflict: 'fail' | 'agent';
7113
7274
  }
7114
7275
 
7276
+ declare type WorkflowOnError = (typeof WORKFLOW_ON_ERROR)[number];
7277
+
7115
7278
  export declare interface WorkflowOutputVisibility {
7116
7279
  roles: string[];
7117
7280
  users?: string[];
7118
7281
  ownerBypass?: boolean;
7119
7282
  }
7120
7283
 
7284
+ declare type WorkflowRetryBackoff = (typeof WORKFLOW_RETRY_BACKOFFS)[number];
7285
+
7286
+ declare interface WorkflowRetryPolicy {
7287
+ maxAttempts: number;
7288
+ /** delay before attempt 2 (default 0 = immediate) — an engine timer, never a sleep inside the step VM (P1-10). */
7289
+ backoffSeconds?: number;
7290
+ /** `'fixed'` (default) | `'exponential'` */
7291
+ backoff?: WorkflowRetryBackoff;
7292
+ /** default 3600; only meaningful with `'exponential'` (`backoff-invalid` otherwise). */
7293
+ maxBackoffSeconds?: number;
7294
+ }
7295
+
7121
7296
  /**
7122
7297
  * Matches WorkflowRunDto (R4 `fields:'summary'` — outputs are never inlined here).
7123
7298
  * The wire names the run `runId` (shared-types `WorkflowRunSummary`); `id` is the pre-R4 spelling some
@@ -7142,8 +7317,24 @@ declare interface WorkflowRun {
7142
7317
  reason?: string;
7143
7318
  since?: string;
7144
7319
  };
7320
+ /**
7321
+ * The pending / audited cancel request (`runCancelView`): who asked and when; `wall` when it was the run wall's
7322
+ * own (LUA-686); LUA-704: `forcedBy` / `forcedAt` / `forceReason` on a forced terminal (`abandoned`, or
7323
+ * `timed_out` when the wall's request was forced) — the run's own reason is the terminal's.
7324
+ */
7325
+ cancel?: {
7326
+ requestedAt: number;
7327
+ requestedBy: string;
7328
+ forceAvailableAt: number;
7329
+ wall?: boolean;
7330
+ forcedAt?: number;
7331
+ forcedBy?: string;
7332
+ forceReason?: string;
7333
+ };
7145
7334
  failureReason?: string;
7146
7335
  restricted?: boolean;
7336
+ /** R4 `fields:'full'` only (§9.3.1): the caller may not read this run's payloads — `output` / step outputs are withheld. */
7337
+ outputsHidden?: 'read-outputs' | 'cloud-task';
7147
7338
  /** LUA-623: the keys the run's version declares, and what each resolved to on its agent (`connection.resolved` rows). */
7148
7339
  connections?: {
7149
7340
  declared: Array<{
@@ -7165,6 +7356,39 @@ declare interface WorkflowRun {
7165
7356
  outputPreview?: string;
7166
7357
  /** LUA-643: every shape says whether a result exists; `--steps` (`fields:'full'`) serves it. */
7167
7358
  hasOutput?: boolean;
7359
+ /**
7360
+ * §08 §8.1 `usage` — the settled spend and, LUA-724 (PR 8), how it was metered: `metering` `'flat'` (1 credit per
7361
+ * inline agent step, 4 per Job-tier attempt — every run while `LUA_WORKFLOWS_METERING_V2` is off) or `'priced'`
7362
+ * (charged like chat: a credit per model call on the legacy plan, `tier × model multiplier` actions on a seat
7363
+ * plan — then `engine` names the plan and `actionsUsed` carries a seat run's actions).
7364
+ */
7365
+ usage?: {
7366
+ creditsUsed?: number;
7367
+ actionsEstimate?: number;
7368
+ actionsUsed?: number;
7369
+ metering?: 'flat' | 'priced';
7370
+ engine?: 'legacy' | 'seat';
7371
+ steps?: number;
7372
+ inputTokens?: number;
7373
+ outputTokens?: number;
7374
+ };
7375
+ /**
7376
+ * R4: the run's caps and settled spend. `maxCredits` and `remaining` are both absent on an uncapped run (`0` = unset);
7377
+ * `remaining` is the engine's pre-dispatch subtraction (priced actions and claimed-step holds count), floored at 0.
7378
+ */
7379
+ budget?: {
7380
+ maxCredits?: number;
7381
+ maxSteps?: number;
7382
+ maxDurationSeconds?: number;
7383
+ unit?: 'credits' | 'actions';
7384
+ spent?: {
7385
+ credits?: number;
7386
+ actionsEstimate?: number;
7387
+ steps?: number;
7388
+ };
7389
+ reserved?: number;
7390
+ remaining?: number;
7391
+ };
7168
7392
  createdAt: string;
7169
7393
  startedAt?: string;
7170
7394
  completedAt?: string;
@@ -7307,6 +7531,14 @@ export declare interface WorkflowsApi {
7307
7531
  };
7308
7532
  }
7309
7533
 
7534
+ export { WorkflowShell }
7535
+
7536
+ export { WorkflowShellValue }
7537
+
7538
+ declare type WorkflowSideEffects = (typeof WORKFLOW_SIDE_EFFECTS)[number];
7539
+
7540
+ declare type WorkflowSignalOnTimeout = (typeof WORKFLOW_SIGNAL_ON_TIMEOUT)[number];
7541
+
7310
7542
  export declare interface WorkflowSpecialistRole {
7311
7543
  name: string;
7312
7544
  instructions: string;
@@ -7330,7 +7562,11 @@ export declare interface WorkflowStepContext<TIn = unknown, TResume = unknown, T
7330
7562
  /** What the prior invocation passed to `suspend()`. */
7331
7563
  suspendData?: unknown;
7332
7564
  getInitData<T = unknown>(): T;
7333
- /** Output of an UPSTREAM step. Throws `WorkflowStepResultError{ code:'STEP_RESULT_NOT_ANCESTOR' }` for a non-ancestor. */
7565
+ /**
7566
+ * Output of an UPSTREAM step. Throws `WorkflowStepResultError` — `code:'STEP_RESULT_NOT_ANCESTOR'` for a
7567
+ * non-ancestor (or unknown) id, `'STEP_RESULT_TOO_LARGE'` / `'STEP_RESULT_OFFLOADED'` for an output the claim
7568
+ * could not carry (see the error's doc for `bytes` / `reason`) — never `undefined`, never a raw ref object.
7569
+ */
7334
7570
  getStepResult<T = unknown>(stepId: string): T;
7335
7571
  /** Run-scoped KV, ledger-backed, ≤ 64KB total. `set` is durable when the step terminalizes. */
7336
7572
  state: {
@@ -7349,17 +7585,65 @@ export declare interface WorkflowStepContext<TIn = unknown, TResume = unknown, T
7349
7585
  signal: AbortSignal;
7350
7586
  /** Sub-agent env, exactly as jobs receive it. */
7351
7587
  env: Record<string, string>;
7352
- /** EXACTLY-ONCE effect keyed on `{occurrenceId, key}` (P1-18). Claim → run `fn` → settle. */
7588
+ /**
7589
+ * EXACTLY-ONCE effect keyed on `{occurrenceId, key}` (P1-18). Claim → run `fn` → settle. Served on every tier:
7590
+ * worker-tier steps and the offline driver, and (LUA-722) Job-tier code steps — the pod relays the claim / settle
7591
+ * under its own attempt token, so the key is scoped to the step's run / row / attempt server-side. A replayed key
7592
+ * (a retried attempt, a repair run) returns the settled result without running `fn`; a key a previous attempt
7593
+ * claimed and never settled throws `EFFECT_IN_DOUBT` (fail closed — `fn` never runs on an unknown claim state).
7594
+ * The result is JSON-serialised on settle, exactly like a step output: a `Date` replays as its ISO string, a
7595
+ * `BigInt` (or a cycle) fails the settle — `EFFECT_SETTLE_FAILED`, the key stays claimed — and a result over the
7596
+ * platform's cap (32 KB) is `EFFECT_SETTLE_FAILED` naming `EFFECT_RESULT_TOO_LARGE`. Calling `once` again for the
7597
+ * same key while its `fn` is still running (re-entrantly) throws `EFFECT_KEY_INVALID` at once.
7598
+ */
7353
7599
  once<T>(key: string, fn: () => Promise<T>): Promise<T>;
7354
- /** Job-tier steps only: the mounted run workspace. */
7600
+ /**
7601
+ * Job-tier steps only: the mounted run workspace, exactly as the Job pod hands it to `execute` (`ctx.workspace` in
7602
+ * `packages/lua-workflow-job/src/code-step.ts`): `root` is the absolute directory of the checkout (`/workspace`),
7603
+ * `branch` the run branch it is on, `headSha` the commit it was restored at, `mount` this step's declared mount,
7604
+ * `isolation` whether the step got its own worktree. LUA-679: the name is `root` — the 3.32.1 type and both
7605
+ * `lua init` examples said `path`, the pod never served it, and a copied definition died `ENOENT /workspace/undefined`.
7606
+ */
7355
7607
  workspace?: {
7356
- path: string;
7608
+ root: string;
7357
7609
  mount: 'rw' | 'ro';
7358
7610
  branch?: string;
7611
+ headSha?: string;
7612
+ isolation?: 'shared' | 'worktree';
7613
+ /**
7614
+ * @deprecated LUA-679 — read `root`. The Job pod serves `path` as an alias (a getter that returns `root` and warns
7615
+ * once per step) for one minor after 3.32 and then removes it; it never appears on `Object.keys(ctx.workspace)`.
7616
+ */
7617
+ readonly path?: string;
7618
+ /**
7619
+ * The run workspace's stamps, served when the pod hands them to the step (LUA-706): `baseSha` is the commit the
7620
+ * run's base ref resolved to at provision (a git workspace — `headSha` is where THIS step's checkout is), `arm`
7621
+ * the worktree arm id when the step runs in its own worktree (`isolation:'worktree'`), `backend` the volume
7622
+ * backend. Absent on an `empty` workspace, a shared-mount step, or a pod that predates them.
7623
+ */
7359
7624
  baseSha?: string;
7360
7625
  arm?: string;
7361
7626
  backend?: WorkflowWorkspaceBackend;
7362
7627
  };
7628
+ /**
7629
+ * Job-tier steps only (LUA-682): run one of `WORKFLOW_EXEC_BINARIES` (`git`, `gh`, `pnpm`, `npm`, `npx`, `node`,
7630
+ * `yarn`, `python3`, `pytest`, `make`) in the workspace — `exec(['git', 'status'], { cwd?, timeoutMs?, env? })`.
7631
+ * Argv only, never a shell: no `&&`, pipes, globs or `$VAR`; `cwd` must stay inside the workspace; the timeout
7632
+ * (default 10 min) is capped by the step's remaining wall; stdout / stderr are kept to 1 MiB each (`truncated`);
7633
+ * one command at a time. A non-zero exit is RETURNED (`result.code`) — `exec.strict` throws `WorkflowExecError`.
7634
+ * The Job pod spawns the command itself with a scrubbed env (no token, no `LUA_WF_*`; git goes through the
7635
+ * credential proxy exactly as the coding turn's does); `child_process` is not available to a code step and fails
7636
+ * `lua compile` with `node-capability-unavailable`. Worker-tier steps have neither `exec` nor `$`. Offline,
7637
+ * `lua workflows run --workspace <dir>` provides both with the same allowlist against your own PATH.
7638
+ */
7639
+ exec?: WorkflowExec;
7640
+ /**
7641
+ * Job-tier steps only (LUA-682): `exec` as a tagged template — `$\`gh pr create --title ${title} --body ${body}\``.
7642
+ * Literal text splits on whitespace (with `'…'` / `"…"` quoting); every `${value}` is exactly ONE argument, never
7643
+ * re-parsed (a title with spaces, a body with newlines); an array spreads into one argument per item; `undefined`
7644
+ * is refused rather than stringified. `$.strict` throws on a non-zero exit.
7645
+ */
7646
+ $?: WorkflowShell;
7363
7647
  /** The run artefact store (P1-8). */
7364
7648
  artefacts: {
7365
7649
  put(name: string, data: Uint8Array | string | ReadableStream, opts: {
@@ -7394,7 +7678,12 @@ export declare interface WorkflowStepContext<TIn = unknown, TResume = unknown, T
7394
7678
  }>;
7395
7679
  list(): Promise<WorkflowArtefactMeta[]>;
7396
7680
  };
7397
- /** Stamped by the executor for observability; read-only. */
7681
+ /**
7682
+ * Stamped by the executor for observability; read-only (frozen). Served on both tiers from the run's stamps
7683
+ * (LUA-706): `trigger` / `principalKind`, plus `parentRunId` / `traceparent` / `correlationKey` / `tags` /
7684
+ * `replyTo` when the run carries them; `agentVersion` is not stamped today. A run created before the stamps
7685
+ * existed reads `{}`. Offline, `lua workflows run` serves `{ trigger:'sdk', principalKind:'user' }`.
7686
+ */
7398
7687
  runtime: {
7399
7688
  trigger: WorkflowRunTrigger;
7400
7689
  parentRunId?: string;
@@ -7410,10 +7699,26 @@ export declare interface WorkflowStepContext<TIn = unknown, TResume = unknown, T
7410
7699
  };
7411
7700
  }
7412
7701
 
7413
- /** Thrown by `ctx.getStepResult` for a non-ancestor / unknown id — never `undefined` (03 §3.1). */
7702
+ /**
7703
+ * Thrown by `ctx.getStepResult` — never `undefined`, never a raw ref object (03 §3.1). Check `err.code`, never
7704
+ * `instanceof` (a step runs in its own realm on every tier):
7705
+ * - `STEP_RESULT_NOT_ANCESTOR` — `stepId` is not an upstream step of this one (or is unknown);
7706
+ * - `STEP_RESULT_TOO_LARGE` — the ancestor's output could not ride the claim beside its siblings (the 4 MiB
7707
+ * `stepResults` wire budget, dropped largest-first); `bytes` is its serialized size;
7708
+ * - `STEP_RESULT_OFFLOADED` — the ledger holds the output offloaded (> 256 KB) and the claim could not carry it
7709
+ * hydrated; `bytes` is its size, `reason` why: `over_wire_cap` (it would break the budget), `hydrate_timeout`
7710
+ * (the per-claim hydration deadline passed), or the control plane's code (`CDN_REF_MISSING`, `CDN_REF_CORRUPT`,
7711
+ * `CDN_REF_FOREIGN`, …).
7712
+ * For the last two, bind the value through the step's input instead, or read it via `ctx.artefacts` /
7713
+ * `ctx.datasets`. The offline driver (`lua workflows execute`) only ever throws the first.
7714
+ */
7414
7715
  export declare interface WorkflowStepResultError extends Error {
7415
- code: 'STEP_RESULT_NOT_ANCESTOR';
7716
+ code: 'STEP_RESULT_NOT_ANCESTOR' | 'STEP_RESULT_TOO_LARGE' | 'STEP_RESULT_OFFLOADED';
7416
7717
  stepId: string;
7718
+ /** `STEP_RESULT_TOO_LARGE` / `STEP_RESULT_OFFLOADED`: the output's serialized size. */
7719
+ bytes?: number;
7720
+ /** `STEP_RESULT_OFFLOADED`: why the claim could not carry it. */
7721
+ reason?: string;
7417
7722
  }
7418
7723
 
7419
7724
  export declare interface WorkflowStepWorkspace {
@@ -7432,6 +7737,8 @@ export declare type WorkflowSuspendTimeoutChainMember = 'deny' | 'cancel-run' |
7432
7737
  timeoutHours: number;
7433
7738
  };
7434
7739
 
7740
+ declare type WorkflowTier = (typeof WORKFLOW_TIERS)[number];
7741
+
7435
7742
  export declare type WorkflowWorkspaceBackend = 'ebs' | 'efs' | 's3';
7436
7743
 
7437
7744
  export declare type WorkspaceSpec = {
@@ -7448,6 +7755,10 @@ export declare type WorkspaceSpec = {
7448
7755
  kind: 'empty';
7449
7756
  sizeGb?: number;
7450
7757
  ttlHours?: number;
7758
+ /**
7759
+ * Keep the volume after the run completes: held until `ttlHours` (24 h when undeclared), then expired. A kept
7760
+ * volume holds one of the organisation's workspace slots (`maxWorkspacesPerOrg`, 10 by default) until then.
7761
+ */
7451
7762
  keepArtefacts?: boolean;
7452
7763
  backend?: WorkflowWorkspaceBackend;
7453
7764
  };