lua-cli 3.31.0 → 3.32.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.
Files changed (33) hide show
  1. package/dist/api-exports.d.ts +416 -103
  2. package/dist/api-exports.js +1992 -299
  3. package/dist/api-exports.js.map +1 -1
  4. package/dist/index.js +5262 -1914
  5. package/dist/index.js.map +1 -1
  6. package/dist/voice/test/index.d.ts +54 -54
  7. package/dist/workflow-builder.d.ts +257 -44
  8. package/dist/workflow-builder.js +1382 -265
  9. package/dist/workflow-builder.js.map +1 -1
  10. package/docs/README.md +2 -2
  11. package/docs/api/LuaWorkflow.md +44 -28
  12. package/docs/api/Workflows.md +12 -1
  13. package/docs/workflows/approvals.md +14 -1
  14. package/docs/workflows/connections-in-coding-turns.md +1 -0
  15. package/docs/workflows/correlation-keys.md +1 -0
  16. package/docs/workflows/git-credentials.md +22 -1
  17. package/docs/workflows/goals.md +46 -0
  18. package/docs/workflows/limits.md +6 -0
  19. package/docs/workflows/recovery.md +6 -2
  20. package/docs/workflows/replay-local.md +10 -10
  21. package/docs/workflows/schedules.md +15 -0
  22. package/docs/workflows/script-form.md +20 -10
  23. package/docs/workflows/testing-offline.md +25 -20
  24. package/docs/workflows/workspaces-and-long-steps.md +38 -2
  25. package/package.json +2 -2
  26. package/template/examples/workflows/CLAUDE.md +16 -13
  27. package/template/examples/workflows/pr-review-round.ts +61 -20
  28. package/template/examples/workflows/provision-tenant.ts +25 -8
  29. package/template/examples/workflows/refund-approval.ts +30 -17
  30. package/template/examples/workflows/support-triage.ts +59 -22
  31. package/template/examples/workflows/ticket-to-pr.ts +125 -46
  32. package/template/examples/workflows/vendor-invoices.ts +69 -16
  33. package/template/package.json +1 -1
@@ -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
 
@@ -121,6 +130,14 @@ declare interface AgentInvocationInput {
121
130
  /** Per-request model override ("provider/model" code). Unknown codes fall back per
122
131
  * approved-models policy server-side. */
123
132
  model?: string;
133
+ /**
134
+ * LUA-655 (review M2) — a platform re-ask the customer must not pay for: the workflow executor's
135
+ * output-repair turns. Honoured server-side ONLY on internally-authenticated turns
136
+ * (`buildChatRequest` drops a Bearer client's value): it rides `handleBilling` → lua-api's
137
+ * `deduct-credits` as `skipCredits`, which skips the legacy credit deduction (the seat gate and
138
+ * the settlement usage event still run, the skill-override posture).
139
+ */
140
+ skipCredits?: boolean;
124
141
  /** Task 14 (tasks-redesign) — per-task connector + skill scoping. See `AgentToolScope`. */
125
142
  toolScope?: AgentToolScope_2;
126
143
  /**
@@ -299,16 +316,26 @@ export declare interface AgentStepOptions {
299
316
  };
300
317
  timeoutSeconds?: number;
301
318
  retry?: RetryPolicy;
302
- onError?: 'fail' | 'continue' | 'park';
319
+ onError?: WorkflowOnError;
303
320
  requiredConnections?: string[];
304
321
  /** static-only persona override (§11 S3) */
305
322
  systemPrompt?: string;
306
- tier?: 'job';
323
+ tier?: WorkflowTier;
307
324
  workspace?: WorkflowStepWorkspace;
308
- jobResources?: 'small' | 'medium' | 'large';
325
+ jobResources?: WorkflowJobResources;
309
326
  harness?: WorkflowJobHarness;
310
327
  /** Coding-turn cap for a tier:'job' step (1..500); absent ⇒ the platform default. A monorepo change needs more than the default. */
311
328
  maxTurns?: number;
329
+ /**
330
+ * Per-ATTEMPT ceilings for a tier:'job' step (LUA-636): `maxTurns` bounds one harness query; these bound the whole
331
+ * attempt (every pass and resumed segment). Crossing one checkpoints the workspace and ends the attempt
332
+ * `attempt_budget_exhausted` — retryable, so the step's `retry` policy continues from that tree with a fresh
333
+ * session. `maxMessages` counts harness messages (one per content block; 1..5000, default 400),
334
+ * `maxInputTokens` the attempt's input-side tokens (prompt + cache; 1M..500M, default 4M — LUA-708: the per-attempt
335
+ * cost bound, since `budget.maxCredits` counts attempts, not tokens).
336
+ */
337
+ maxMessages?: number;
338
+ maxInputTokens?: number;
312
339
  }
313
340
 
314
341
  export declare interface AgentToolScope {
@@ -512,6 +539,15 @@ declare interface ApiResponse<T = any> {
512
539
  error?: string;
513
540
  oldAccountLabel?: string;
514
541
  newAccountLabel?: string;
542
+ /** Workflow envelope detail (09 §9.11 `{ statusCode, message, code, ...detail }` is spread top-level). */
543
+ issues?: Array<{
544
+ path?: string;
545
+ message?: string;
546
+ code?: string;
547
+ }>;
548
+ stepId?: string;
549
+ /** the live step status on 409 NOT_SUSPENDED (LUA-644) */
550
+ status?: string;
515
551
  };
516
552
  }
517
553
 
@@ -527,7 +563,7 @@ export declare interface ApprovalOptions {
527
563
  /** 'deny' (default) | 'cancel-run' | 'fail' | a chain of ≤ 3 hops ending in one terminal member */
528
564
  onTimeout?: WorkflowSuspendTimeoutChain;
529
565
  /** default 'continue' (denial is data unless 'fail') */
530
- onDeny?: 'fail' | 'continue';
566
+ onDeny?: WorkflowApprovalOnDeny;
531
567
  businessHours?: WorkflowBusinessHours;
532
568
  editable?: boolean;
533
569
  /** grammar: `drafts`, `drafts[*]`, `drafts[*].body`, `drafts[3].body`, `summary.title` */
@@ -875,9 +911,11 @@ declare interface BuiltWorkflow {
875
911
  steps: Record<string, LuaWorkflowStep<any, any, any>>;
876
912
  warnings: LuaWorkflowBuildWarning[];
877
913
  envTemplateKeys: string[];
914
+ /** `.workflow(id, ref, …, { workspace })` targets; `workspace:'inherit'` marks an inherit child — the compiler defers `workspace-not-declared` for it (03 §3.1). */
878
915
  nestedRefs: Array<{
879
916
  id: string;
880
917
  name: string;
918
+ workspace?: 'inherit';
881
919
  }>;
882
920
  }
883
921
 
@@ -1282,7 +1320,13 @@ export declare interface ChatHistoryMessage {
1282
1320
  */
1283
1321
  export declare type ChatMessage = TextMessage | ImageMessage | FileMessage;
1284
1322
 
1285
- /** A container arm: a `StepRef`, or (B14 — lands with WF-509) the two-element chain `[mapConfig, stepRef]`. */
1323
+ /**
1324
+ * A container arm: a `StepRef` — a `createStep` object, or a string naming an entry declared elsewhere in the chain
1325
+ * (`agentStep` / `specialistStep` / `toolStep` / `workflow`, and since LUA-684 `approval` / `waitForSignal`, so an
1326
+ * approval can run concurrently with another row) — or (B14 — lands with WF-509) the two-element chain
1327
+ * `[mapConfig, stepRef]`. A HITL arm takes the previous output as its payload, so it never heads a `[map, step]`
1328
+ * chain, and a `loop` body cannot be one until the engine proves it (`node-type-unsupported-in-container`).
1329
+ */
1286
1330
  export declare type ContainerArm = StepRef | [LuaMapConfig, StepRef];
1287
1331
 
1288
1332
  /**
@@ -3854,13 +3898,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3854
3898
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3855
3899
  }, "strip", z.ZodTypeAny, {
3856
3900
  voice?: string;
3857
- options?: Record<string, unknown>;
3858
3901
  kind?: "inference";
3902
+ options?: Record<string, unknown>;
3859
3903
  model?: string;
3860
3904
  }, {
3861
3905
  voice?: string;
3862
- options?: Record<string, unknown>;
3863
3906
  kind?: "inference";
3907
+ options?: Record<string, unknown>;
3864
3908
  model?: string;
3865
3909
  }>, z.ZodObject<{
3866
3910
  kind: z.ZodLiteral<"plugin">;
@@ -3875,13 +3919,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3875
3919
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3876
3920
  }, "strip", z.ZodTypeAny, {
3877
3921
  provider?: "deepgram" | "elevenlabs";
3878
- options?: Record<string, unknown>;
3879
3922
  kind?: "plugin";
3923
+ options?: Record<string, unknown>;
3880
3924
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3881
3925
  }, {
3882
3926
  provider?: "deepgram" | "elevenlabs";
3883
- options?: Record<string, unknown>;
3884
3927
  kind?: "plugin";
3928
+ options?: Record<string, unknown>;
3885
3929
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3886
3930
  }>, z.ZodObject<{
3887
3931
  kind: z.ZodLiteral<"realtime">;
@@ -3895,12 +3939,12 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3895
3939
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3896
3940
  }, "strip", z.ZodTypeAny, {
3897
3941
  provider?: "google" | "xai" | "openai";
3898
- options?: Record<string, unknown>;
3899
3942
  kind?: "realtime";
3943
+ options?: Record<string, unknown>;
3900
3944
  }, {
3901
3945
  provider?: "google" | "xai" | "openai";
3902
- options?: Record<string, unknown>;
3903
3946
  kind?: "realtime";
3947
+ options?: Record<string, unknown>;
3904
3948
  }>]>;
3905
3949
  stt: z.ZodOptional<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
3906
3950
  kind: z.ZodLiteral<"inference">;
@@ -3920,13 +3964,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3920
3964
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3921
3965
  }, "strip", z.ZodTypeAny, {
3922
3966
  voice?: string;
3923
- options?: Record<string, unknown>;
3924
3967
  kind?: "inference";
3968
+ options?: Record<string, unknown>;
3925
3969
  model?: string;
3926
3970
  }, {
3927
3971
  voice?: string;
3928
- options?: Record<string, unknown>;
3929
3972
  kind?: "inference";
3973
+ options?: Record<string, unknown>;
3930
3974
  model?: string;
3931
3975
  }>, z.ZodObject<{
3932
3976
  kind: z.ZodLiteral<"plugin">;
@@ -3941,13 +3985,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3941
3985
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3942
3986
  }, "strip", z.ZodTypeAny, {
3943
3987
  provider?: "deepgram" | "elevenlabs";
3944
- options?: Record<string, unknown>;
3945
3988
  kind?: "plugin";
3989
+ options?: Record<string, unknown>;
3946
3990
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3947
3991
  }, {
3948
3992
  provider?: "deepgram" | "elevenlabs";
3949
- options?: Record<string, unknown>;
3950
3993
  kind?: "plugin";
3994
+ options?: Record<string, unknown>;
3951
3995
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3952
3996
  }>, z.ZodObject<{
3953
3997
  kind: z.ZodLiteral<"realtime">;
@@ -3961,12 +4005,12 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3961
4005
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3962
4006
  }, "strip", z.ZodTypeAny, {
3963
4007
  provider?: "google" | "xai" | "openai";
3964
- options?: Record<string, unknown>;
3965
4008
  kind?: "realtime";
4009
+ options?: Record<string, unknown>;
3966
4010
  }, {
3967
4011
  provider?: "google" | "xai" | "openai";
3968
- options?: Record<string, unknown>;
3969
4012
  kind?: "realtime";
4013
+ options?: Record<string, unknown>;
3970
4014
  }>]>>;
3971
4015
  tts: z.ZodOptional<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
3972
4016
  kind: z.ZodLiteral<"inference">;
@@ -3986,13 +4030,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3986
4030
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3987
4031
  }, "strip", z.ZodTypeAny, {
3988
4032
  voice?: string;
3989
- options?: Record<string, unknown>;
3990
4033
  kind?: "inference";
4034
+ options?: Record<string, unknown>;
3991
4035
  model?: string;
3992
4036
  }, {
3993
4037
  voice?: string;
3994
- options?: Record<string, unknown>;
3995
4038
  kind?: "inference";
4039
+ options?: Record<string, unknown>;
3996
4040
  model?: string;
3997
4041
  }>, z.ZodObject<{
3998
4042
  kind: z.ZodLiteral<"plugin">;
@@ -4007,13 +4051,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4007
4051
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4008
4052
  }, "strip", z.ZodTypeAny, {
4009
4053
  provider?: "deepgram" | "elevenlabs";
4010
- options?: Record<string, unknown>;
4011
4054
  kind?: "plugin";
4055
+ options?: Record<string, unknown>;
4012
4056
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4013
4057
  }, {
4014
4058
  provider?: "deepgram" | "elevenlabs";
4015
- options?: Record<string, unknown>;
4016
4059
  kind?: "plugin";
4060
+ options?: Record<string, unknown>;
4017
4061
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4018
4062
  }>, z.ZodObject<{
4019
4063
  kind: z.ZodLiteral<"realtime">;
@@ -4027,12 +4071,12 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4027
4071
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4028
4072
  }, "strip", z.ZodTypeAny, {
4029
4073
  provider?: "google" | "xai" | "openai";
4030
- options?: Record<string, unknown>;
4031
4074
  kind?: "realtime";
4075
+ options?: Record<string, unknown>;
4032
4076
  }, {
4033
4077
  provider?: "google" | "xai" | "openai";
4034
- options?: Record<string, unknown>;
4035
4078
  kind?: "realtime";
4079
+ options?: Record<string, unknown>;
4036
4080
  }>]>>;
4037
4081
  vad: z.ZodOptional<z.ZodString>;
4038
4082
  vadOptions: z.ZodOptional<z.ZodObject<{
@@ -4194,49 +4238,49 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4194
4238
  vad?: string;
4195
4239
  stt?: {
4196
4240
  voice?: string;
4197
- options?: Record<string, unknown>;
4198
4241
  kind?: "inference";
4242
+ options?: Record<string, unknown>;
4199
4243
  model?: string;
4200
4244
  } | {
4201
4245
  provider?: "deepgram" | "elevenlabs";
4202
- options?: Record<string, unknown>;
4203
4246
  kind?: "plugin";
4247
+ options?: Record<string, unknown>;
4204
4248
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4205
4249
  } | {
4206
4250
  provider?: "google" | "xai" | "openai";
4207
- options?: Record<string, unknown>;
4208
4251
  kind?: "realtime";
4252
+ options?: Record<string, unknown>;
4209
4253
  };
4210
4254
  volume?: number;
4211
4255
  llm?: {
4212
4256
  voice?: string;
4213
- options?: Record<string, unknown>;
4214
4257
  kind?: "inference";
4258
+ options?: Record<string, unknown>;
4215
4259
  model?: string;
4216
4260
  } | {
4217
4261
  provider?: "deepgram" | "elevenlabs";
4218
- options?: Record<string, unknown>;
4219
4262
  kind?: "plugin";
4263
+ options?: Record<string, unknown>;
4220
4264
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4221
4265
  } | {
4222
4266
  provider?: "google" | "xai" | "openai";
4223
- options?: Record<string, unknown>;
4224
4267
  kind?: "realtime";
4268
+ options?: Record<string, unknown>;
4225
4269
  };
4226
4270
  tts?: {
4227
4271
  voice?: string;
4228
- options?: Record<string, unknown>;
4229
4272
  kind?: "inference";
4273
+ options?: Record<string, unknown>;
4230
4274
  model?: string;
4231
4275
  } | {
4232
4276
  provider?: "deepgram" | "elevenlabs";
4233
- options?: Record<string, unknown>;
4234
4277
  kind?: "plugin";
4278
+ options?: Record<string, unknown>;
4235
4279
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4236
4280
  } | {
4237
4281
  provider?: "google" | "xai" | "openai";
4238
- options?: Record<string, unknown>;
4239
4282
  kind?: "realtime";
4283
+ options?: Record<string, unknown>;
4240
4284
  };
4241
4285
  vadOptions?: {
4242
4286
  minSpeechDuration?: number;
@@ -4288,49 +4332,49 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4288
4332
  vad?: string;
4289
4333
  stt?: {
4290
4334
  voice?: string;
4291
- options?: Record<string, unknown>;
4292
4335
  kind?: "inference";
4336
+ options?: Record<string, unknown>;
4293
4337
  model?: string;
4294
4338
  } | {
4295
4339
  provider?: "deepgram" | "elevenlabs";
4296
- options?: Record<string, unknown>;
4297
4340
  kind?: "plugin";
4341
+ options?: Record<string, unknown>;
4298
4342
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4299
4343
  } | {
4300
4344
  provider?: "google" | "xai" | "openai";
4301
- options?: Record<string, unknown>;
4302
4345
  kind?: "realtime";
4346
+ options?: Record<string, unknown>;
4303
4347
  };
4304
4348
  volume?: number;
4305
4349
  llm?: {
4306
4350
  voice?: string;
4307
- options?: Record<string, unknown>;
4308
4351
  kind?: "inference";
4352
+ options?: Record<string, unknown>;
4309
4353
  model?: string;
4310
4354
  } | {
4311
4355
  provider?: "deepgram" | "elevenlabs";
4312
- options?: Record<string, unknown>;
4313
4356
  kind?: "plugin";
4357
+ options?: Record<string, unknown>;
4314
4358
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4315
4359
  } | {
4316
4360
  provider?: "google" | "xai" | "openai";
4317
- options?: Record<string, unknown>;
4318
4361
  kind?: "realtime";
4362
+ options?: Record<string, unknown>;
4319
4363
  };
4320
4364
  tts?: {
4321
4365
  voice?: string;
4322
- options?: Record<string, unknown>;
4323
4366
  kind?: "inference";
4367
+ options?: Record<string, unknown>;
4324
4368
  model?: string;
4325
4369
  } | {
4326
4370
  provider?: "deepgram" | "elevenlabs";
4327
- options?: Record<string, unknown>;
4328
4371
  kind?: "plugin";
4372
+ options?: Record<string, unknown>;
4329
4373
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4330
4374
  } | {
4331
4375
  provider?: "google" | "xai" | "openai";
4332
- options?: Record<string, unknown>;
4333
4376
  kind?: "realtime";
4377
+ options?: Record<string, unknown>;
4334
4378
  };
4335
4379
  vadOptions?: {
4336
4380
  minSpeechDuration?: number;
@@ -4382,49 +4426,49 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4382
4426
  vad?: string;
4383
4427
  stt?: {
4384
4428
  voice?: string;
4385
- options?: Record<string, unknown>;
4386
4429
  kind?: "inference";
4430
+ options?: Record<string, unknown>;
4387
4431
  model?: string;
4388
4432
  } | {
4389
4433
  provider?: "deepgram" | "elevenlabs";
4390
- options?: Record<string, unknown>;
4391
4434
  kind?: "plugin";
4435
+ options?: Record<string, unknown>;
4392
4436
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4393
4437
  } | {
4394
4438
  provider?: "google" | "xai" | "openai";
4395
- options?: Record<string, unknown>;
4396
4439
  kind?: "realtime";
4440
+ options?: Record<string, unknown>;
4397
4441
  };
4398
4442
  volume?: number;
4399
4443
  llm?: {
4400
4444
  voice?: string;
4401
- options?: Record<string, unknown>;
4402
4445
  kind?: "inference";
4446
+ options?: Record<string, unknown>;
4403
4447
  model?: string;
4404
4448
  } | {
4405
4449
  provider?: "deepgram" | "elevenlabs";
4406
- options?: Record<string, unknown>;
4407
4450
  kind?: "plugin";
4451
+ options?: Record<string, unknown>;
4408
4452
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4409
4453
  } | {
4410
4454
  provider?: "google" | "xai" | "openai";
4411
- options?: Record<string, unknown>;
4412
4455
  kind?: "realtime";
4456
+ options?: Record<string, unknown>;
4413
4457
  };
4414
4458
  tts?: {
4415
4459
  voice?: string;
4416
- options?: Record<string, unknown>;
4417
4460
  kind?: "inference";
4461
+ options?: Record<string, unknown>;
4418
4462
  model?: string;
4419
4463
  } | {
4420
4464
  provider?: "deepgram" | "elevenlabs";
4421
- options?: Record<string, unknown>;
4422
4465
  kind?: "plugin";
4466
+ options?: Record<string, unknown>;
4423
4467
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4424
4468
  } | {
4425
4469
  provider?: "google" | "xai" | "openai";
4426
- options?: Record<string, unknown>;
4427
4470
  kind?: "realtime";
4471
+ options?: Record<string, unknown>;
4428
4472
  };
4429
4473
  vadOptions?: {
4430
4474
  minSpeechDuration?: number;
@@ -4476,49 +4520,49 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4476
4520
  vad?: string;
4477
4521
  stt?: {
4478
4522
  voice?: string;
4479
- options?: Record<string, unknown>;
4480
4523
  kind?: "inference";
4524
+ options?: Record<string, unknown>;
4481
4525
  model?: string;
4482
4526
  } | {
4483
4527
  provider?: "deepgram" | "elevenlabs";
4484
- options?: Record<string, unknown>;
4485
4528
  kind?: "plugin";
4529
+ options?: Record<string, unknown>;
4486
4530
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4487
4531
  } | {
4488
4532
  provider?: "google" | "xai" | "openai";
4489
- options?: Record<string, unknown>;
4490
4533
  kind?: "realtime";
4534
+ options?: Record<string, unknown>;
4491
4535
  };
4492
4536
  volume?: number;
4493
4537
  llm?: {
4494
4538
  voice?: string;
4495
- options?: Record<string, unknown>;
4496
4539
  kind?: "inference";
4540
+ options?: Record<string, unknown>;
4497
4541
  model?: string;
4498
4542
  } | {
4499
4543
  provider?: "deepgram" | "elevenlabs";
4500
- options?: Record<string, unknown>;
4501
4544
  kind?: "plugin";
4545
+ options?: Record<string, unknown>;
4502
4546
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4503
4547
  } | {
4504
4548
  provider?: "google" | "xai" | "openai";
4505
- options?: Record<string, unknown>;
4506
4549
  kind?: "realtime";
4550
+ options?: Record<string, unknown>;
4507
4551
  };
4508
4552
  tts?: {
4509
4553
  voice?: string;
4510
- options?: Record<string, unknown>;
4511
4554
  kind?: "inference";
4555
+ options?: Record<string, unknown>;
4512
4556
  model?: string;
4513
4557
  } | {
4514
4558
  provider?: "deepgram" | "elevenlabs";
4515
- options?: Record<string, unknown>;
4516
4559
  kind?: "plugin";
4560
+ options?: Record<string, unknown>;
4517
4561
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4518
4562
  } | {
4519
4563
  provider?: "google" | "xai" | "openai";
4520
- options?: Record<string, unknown>;
4521
4564
  kind?: "realtime";
4565
+ options?: Record<string, unknown>;
4522
4566
  };
4523
4567
  vadOptions?: {
4524
4568
  minSpeechDuration?: number;
@@ -4891,29 +4935,44 @@ export declare class LuaWorkflow {
4891
4935
  getBuildWarnings(): LuaWorkflowBuildWarning[];
4892
4936
  /** Every `env.template(KEY)` placeholder key the graph carries (sorted, deduped) — `ManifestWorkflow.envTemplateKeys`. */
4893
4937
  getEnvTemplateKeys(): string[];
4894
- /** `.workflow(id, ref)` targets by name — `ManifestWorkflow.workflowRefs`. */
4938
+ /** `.workflow(id, ref)` targets by name — `ManifestWorkflow.workflowRefs`; `workspace:'inherit'` marks the inherit children the compiler defers `workspace-not-declared` for. */
4895
4939
  getNestedWorkflowRefs(): Array<{
4896
4940
  id: string;
4897
4941
  name: string;
4942
+ workspace?: 'inherit';
4898
4943
  }>;
4899
4944
  /** Pure: no I/O, no env, no time. Called by the compiler in the VM tier and by `lua test`. */
4900
4945
  __serializeGraph(): SerializedWorkflowGraph;
4901
4946
  }
4902
4947
 
4903
- export declare type LuaWorkflowBuildCode = 'duplicate-step-id' | 'unknown-step-ref' | 'map-id-required' | 'closure-predicate' | 'closure-binding' | 'timeout-out-of-range' | 'timeout-exceeds-tier' | 'job-timeout-exceeds-cap' | 'long-job-requires-workspace' | 'workspace-requires-job-tier' | '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';
4948
+ export declare type LuaWorkflowBuildCode = 'duplicate-step-id' | 'unknown-step-ref' | 'map-id-required' | 'closure-predicate' | 'closure-binding' | 'timeout-out-of-range' | 'timeout-exceeds-tier' | 'job-timeout-exceeds-cap' | 'long-job-requires-workspace' | 'workspace-requires-job-tier'
4949
+ /**
4950
+ * @deprecated LUA-635 — the builder no longer throws it: a mount with no envelope `workspace` is the SHARED validator's
4951
+ * verdict (deferred for an inherit child, 03 §3.1 table). Kept for one minor so a consumer switching on the union still
4952
+ * compiles; removed in the next.
4953
+ */
4954
+ | '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'
4955
+ /**
4956
+ * @deprecated LUA-684 — the builder no longer throws it: an `approval` / `waitForSignal` IS a container arm
4957
+ * (`parallel(['approve', …])`). Where the engine cannot run one — a `loop` body, the step of a `[map, step]`
4958
+ * chain — the code is `node-type-unsupported-in-container`. Kept for one minor so a consumer switching on the
4959
+ * union still compiles; removed in the next.
4960
+ */
4961
+ | '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';
4904
4962
 
4905
4963
  export declare interface LuaWorkflowBuilder {
4906
4964
  then(step: StepRef): this;
4907
- /** 2..16 arms; output = { [stepId]: output } */
4965
+ /** 2..16 arms; output = { [stepId]: output }. An `approval` / `waitForSignal` arm (by id) parks beside its siblings. */
4908
4966
  parallel(steps: ContainerArm[], opts?: {
4909
4967
  merge?: WorkflowMergePolicy;
4910
4968
  }): this;
4911
- /** all-true arms run (Mastra); exclusive:true ≡ switch() */
4969
+ /** all-true arms run (Mastra); exclusive:true ≡ switch(). An arm may name a declared `approval` / `waitForSignal`. */
4912
4970
  branch(arms: Array<[LuaPredicate, StepRef]>, opts?: {
4913
4971
  exclusive?: boolean;
4914
4972
  }): this;
4915
4973
  /** first true arm only ⇒ conditional{ exclusive:true, otherwise } */
4916
4974
  switch(arms: Array<[LuaPredicate, StepRef]>, otherwise?: StepRef): this;
4975
+ /** one body run per item; an `approval` / `waitForSignal` body (by id) is one approval / wait per item */
4917
4976
  foreach(step: ContainerArm, opts?: ForeachOptions): this;
4918
4977
  dowhile(step: ContainerArm, predicate: LuaPredicate, opts?: LoopOptions): this;
4919
4978
  dountil(step: ContainerArm, predicate: LuaPredicate, opts?: LoopOptions): this;
@@ -4936,12 +4995,11 @@ export declare interface LuaWorkflowBuilder {
4936
4995
  /** D25 ephemeral specialist: runs AS THE OWNING AGENT (`agentId:'$self'`) with an additive role block. */
4937
4996
  specialistStep(id: string, opts: SpecialistStepOptions): this;
4938
4997
  toolStep(id: string, tool: LuaTool<any>, opts?: ToolStepOptions): this;
4998
+ /** a declaration like `agentStep` (LUA-684): placed where called unless a container claims the id — `parallel(['approve', …])` */
4939
4999
  approval(id: string, opts: ApprovalOptions): this;
4940
5000
  waitForSignal(id: string, opts: WaitForSignalOptions): this;
4941
- /** nested run; depth ≤ 3 */
4942
- workflow(id: string, ref: LuaWorkflow | string, input?: LuaMapConfig, opts?: {
4943
- workspace?: 'inherit';
4944
- }): this;
5001
+ /** nested run; depth ≤ 3 — declares `id`, so a container may place it by string ref (03 §3.2.0) */
5002
+ workflow(id: string, ref: LuaWorkflow | string, input?: LuaMapConfig, opts?: NestedWorkflowOptions): this;
4945
5003
  commit(): LuaWorkflow;
4946
5004
  }
4947
5005
 
@@ -4969,12 +5027,19 @@ export declare interface LuaWorkflowConfig {
4969
5027
  concurrencyPolicy?: 'allow' | 'forbid';
4970
5028
  /** Who may READ this workflow's run outputs beyond `workflows:read-outputs` holders (B44). Envelope member outside `graphHash`. */
4971
5029
  outputVisibility?: WorkflowOutputVisibility;
4972
- /** `maxDurationSeconds` default 604 800; 2 592 000 when the graph contains an approval / waitForSignal / suspend-capable step (P1-4). */
4973
- budget?: {
4974
- maxCredits?: number;
4975
- maxSteps?: number;
4976
- maxDurationSeconds?: number;
4977
- };
5030
+ /**
5031
+ * `maxDurationSeconds` default 604 800; 2 592 000 when the graph contains an approval / waitForSignal / suspend-capable
5032
+ * step (P1-4). The three members the SDK forwards, spelled by the ONE definition budget (`WorkflowDefinitionBudget`).
5033
+ *
5034
+ * `maxCredits` counts agent steps, never tokens (LUA-708): an inline agent step settles a flat 1 credit when it
5035
+ * completes, a `tier:'job'` attempt a flat 4 at its first claim (a retry is a new attempt). The run parks on a
5036
+ * budget gate (`nextAction:'raise_budget'`, `lua workflows raise-budget`) when what remains is under the next agent
5037
+ * step's reserve — so `maxCredits: 40` buys ten Job-tier attempts, and a value under 4 never dispatches one. Each
5038
+ * attempt then runs to its own wall (`timeoutSeconds`), `maxInputTokens` (default 4M ≈ $1–13 on a Sonnet-class
5039
+ * model), `maxMessages` and `maxTurns`; nothing meters its tokens against the credits mid-attempt. Size
5040
+ * `maxInputTokens` for what one attempt may cost and `maxCredits` for how many attempts the run may make.
5041
+ */
5042
+ budget?: Pick<WorkflowDefinitionBudget, 'maxCredits' | 'maxSteps' | 'maxDurationSeconds'>;
4978
5043
  /** verbatim LuaJob union (D12) → Job{kind:'workflow'} on publish */
4979
5044
  schedule?: JobSchedule;
4980
5045
  backfillOnEnable?: {
@@ -4986,6 +5051,13 @@ export declare interface LuaWorkflowConfig {
4986
5051
  /** NEVER set by hand — the compiler derives it from the source file. */
4987
5052
  form?: 'graph' | 'script';
4988
5053
  workspace?: WorkspaceSpec;
5054
+ /**
5055
+ * Declared connection keys. `workspace.credentialsRef` and a step's `requiredConnections` may name a
5056
+ * `key` instead of a connection id; the engine resolves it against the owner agent's own connections
5057
+ * at run time (agent-scoped first, then org-scoped — never a user's), so the same definition runs on
5058
+ * a template install, a hand-built agent and a duplicate without a frozen id.
5059
+ */
5060
+ connections?: WorkflowConnectionDeclaration[];
4989
5061
  }
4990
5062
 
4991
5063
  export declare interface LuaWorkflowStep<TIn extends ZodType = ZodType, TOut extends ZodType = ZodType, TResume extends ZodType = ZodType> {
@@ -5000,16 +5072,16 @@ export declare interface LuaWorkflowStep<TIn extends ZodType = ZodType, TOut ext
5000
5072
  /** 1..600 (D19); default 300 — on `tier:'job'` 1..86 400, default 3600. */
5001
5073
  timeoutSeconds?: number;
5002
5074
  /** Run this step as a k8s Job (hours tier). Implied by `workspace`. */
5003
- tier?: 'job';
5075
+ tier?: WorkflowTier;
5004
5076
  workspace?: WorkflowStepWorkspace;
5005
- jobResources?: 'small' | 'medium' | 'large';
5077
+ jobResources?: WorkflowJobResources;
5006
5078
  jobTools?: WorkflowJobToolId[];
5007
5079
  /** default { maxAttempts: 1 } */
5008
5080
  retry?: RetryPolicy;
5009
5081
  /** default 'none'; 'external' ⇒ park on platform-fault reclaim. */
5010
- sideEffects?: 'none' | 'external';
5082
+ sideEffects?: WorkflowSideEffects;
5011
5083
  /** What the FINAL failure of this step does to the run (default 'fail'). */
5012
- onError?: 'fail' | 'continue' | 'park';
5084
+ onError?: WorkflowOnError;
5013
5085
  requiredConnections?: string[];
5014
5086
  /** Deadline for a `ctx.suspend()` suspension; default 168, max 720. */
5015
5087
  resumeTimeoutHours?: number;
@@ -5132,6 +5204,18 @@ declare type Message = TextMessage_2 | ImageMessage_2 | FileMessage_2;
5132
5204
 
5133
5205
  export declare const ne: <T>(l: TypedRef<T>, r: TypedRef<T> | Literal<T>) => LuaPredicate;
5134
5206
 
5207
+ /** `.workflow(id, ref, input?, opts?)` — a nested run (a `subrun` row). */
5208
+ export declare interface NestedWorkflowOptions {
5209
+ /** Mount the PARENT's run workspace in the child (05 §5.17.5; LUA-650) — the parent must declare one. */
5210
+ workspace?: 'inherit';
5211
+ /**
5212
+ * LUA-669 (#2446): the same policy a code / agent / tool step carries — the row re-arms when the child run ends
5213
+ * `failed` or `timed_out` on its own (a child the parent side ended — cancelled, abandoned — is never retried),
5214
+ * behind the WF-222 backoff, and every attempt starts a FRESH child run. Default `{ maxAttempts: 1 }`.
5215
+ */
5216
+ retry?: RetryPolicy;
5217
+ }
5218
+
5135
5219
  export declare const not: (arg: LuaPredicate) => LuaPredicate;
5136
5220
 
5137
5221
  export declare const notExists: (ref: TypedRef<unknown>) => LuaPredicate;
@@ -6034,6 +6118,11 @@ declare interface RequestOverrides {
6034
6118
  timeoutMs?: number;
6035
6119
  }
6036
6120
 
6121
+ /**
6122
+ * R12 — `ResumeStepResult` (§9.5.3): the loser of a resume race gets the recorded outcome, never a 4xx. LUA-738
6123
+ * (desktop #1018): `recorded.by` is the spec's `WorkflowActorRef` — lua-api projects lua-core's `{ kind, id }` onto
6124
+ * it (`system:timed_out` for the timeout sweep, `system:<id>` with `source:'webhook'` for a webhook caller).
6125
+ */
6037
6126
  declare type ResumeStepResult = {
6038
6127
  resumed: true;
6039
6128
  runStatus: WorkflowRunStatus;
@@ -6043,22 +6132,18 @@ declare type ResumeStepResult = {
6043
6132
  recorded: {
6044
6133
  at: number;
6045
6134
  by?: {
6046
- kind: string;
6047
- id?: string;
6135
+ subjectType: string;
6136
+ subjectId: string;
6137
+ source: string;
6048
6138
  };
6049
6139
  };
6050
6140
  runStatus: WorkflowRunStatus;
6051
6141
  };
6052
6142
 
6053
- export declare interface RetryPolicy {
6054
- maxAttempts: number;
6055
- /** delay before attempt 2 (default 0 = immediate) */
6056
- backoffSeconds?: number;
6057
- /** 'fixed' (default) | 'exponential' — an engine timer, never a sleep inside the step VM (P1-10). */
6058
- backoff?: 'fixed' | 'exponential';
6059
- /** default 3600; only meaningful with 'exponential' (`backoff-invalid` otherwise). */
6060
- maxBackoffSeconds?: number;
6061
- }
6143
+ /** The ONE retry shape (`@lua/shared-types` `WorkflowRetryPolicy`): `maxAttempts` ≥ 1; `backoffSeconds` (default 0 =
6144
+ * immediate) — an engine timer, never a sleep inside the step VM (P1-10); `backoff` 'fixed' (default) | 'exponential';
6145
+ * `maxBackoffSeconds` (default 3600) only meaningful with 'exponential' (`backoff-invalid` otherwise). */
6146
+ export declare type RetryPolicy = WorkflowRetryPolicy;
6062
6147
 
6063
6148
  export declare const rows: (s: LuaWorkflowStep<any, any, any> | string, path: string, page: {
6064
6149
  offset: number;
@@ -6149,7 +6234,7 @@ export declare interface SpecialistStepOptions {
6149
6234
  toolScope?: AgentToolScope;
6150
6235
  timeoutSeconds?: number;
6151
6236
  retry?: RetryPolicy;
6152
- onError?: 'fail' | 'continue' | 'park';
6237
+ onError?: WorkflowOnError;
6153
6238
  requiredConnections?: string[];
6154
6239
  }
6155
6240
 
@@ -6160,12 +6245,23 @@ declare interface SseFrame {
6160
6245
  data: unknown;
6161
6246
  }
6162
6247
 
6163
- /** R8 — 202 `{ runId, status:'queued'|'gated', watchHint, idempotentReplay? }`, or 200 the run detail when `waitSeconds` elapsed on a terminal/suspended run. */
6248
+ /**
6249
+ * R8 — 202 `{ runId, status:'queued'|'gated', watchHint }`, 200 `{ …, idempotentReplay:true, deduplicated:true,
6250
+ * workflowId, workflowName, startedAt }` on an Idempotency-Key replay (LUA-739: the EXISTING run's identity,
6251
+ * real status and real start — no run was created), or 200 the run detail when `waitSeconds` elapsed on a
6252
+ * terminal/suspended run.
6253
+ */
6164
6254
  declare interface StartWorkflowRunResult {
6165
6255
  runId: string;
6166
6256
  status: WorkflowRunStatus;
6167
6257
  watchHint?: string;
6168
6258
  idempotentReplay?: boolean;
6259
+ /** `true` ⇒ no run was created — `workflowId` / `workflowName` / `startedAt` / `status` are the existing holder's. */
6260
+ deduplicated?: boolean;
6261
+ workflowId?: string;
6262
+ workflowName?: string;
6263
+ /** ISO — the existing run's creation time. */
6264
+ startedAt?: string;
6169
6265
  output?: unknown;
6170
6266
  }
6171
6267
 
@@ -6404,8 +6500,8 @@ export declare interface ToolStepOptions {
6404
6500
  input?: LuaMapConfig;
6405
6501
  timeoutSeconds?: number;
6406
6502
  retry?: RetryPolicy;
6407
- sideEffects?: 'none' | 'external';
6408
- onError?: 'fail' | 'continue' | 'park';
6503
+ sideEffects?: WorkflowSideEffects;
6504
+ onError?: WorkflowOnError;
6409
6505
  requiredConnections?: string[];
6410
6506
  }
6411
6507
 
@@ -6861,7 +6957,7 @@ export declare interface WaitForSignalOptions {
6861
6957
  schema?: ZodType;
6862
6958
  timeoutHours?: number | TemplateBinding;
6863
6959
  /** default 'fail'; 'continue' ⇒ output {received:false,timedOut:true} */
6864
- onTimeout?: 'fail' | 'continue';
6960
+ onTimeout?: WorkflowSignalOnTimeout;
6865
6961
  businessHours?: WorkflowBusinessHours;
6866
6962
  /** default ['webhook','api','user'] */
6867
6963
  acceptedSources?: Array<'webhook' | 'api' | 'user' | 'agent'>;
@@ -6990,6 +7086,32 @@ declare interface WhatsAppTemplateUrlButton {
6990
7086
  example?: string | string[];
6991
7087
  }
6992
7088
 
7089
+ /** `approval.onDeny` (§6.4.11 deny-as-data): `'fail'` fails the step on a denial; default `'continue'`. */
7090
+ declare const WORKFLOW_APPROVAL_ON_DENY: readonly ["fail", "continue"];
7091
+
7092
+ /** D19-r2 (B22; 05 §5.17.6 Harness row) — both behind one `CodingHarness { run(turn) }`. */
7093
+ declare const WORKFLOW_JOB_HARNESSES: readonly ["claude-code", "generic"];
7094
+
7095
+ /** `jobResources` (05 §5.17): the Job-tier pod size class. Default `'small'` at spawn. */
7096
+ declare const WORKFLOW_JOB_RESOURCES: readonly ["small", "medium", "large"];
7097
+
7098
+ /** What the FINAL failure of a step does to the run: `'park'` → the §06 §6.3.5 exception gate. Default `'fail'`. */
7099
+ declare const WORKFLOW_ON_ERROR: readonly ["fail", "continue", "park"];
7100
+
7101
+ /** `backoff` absent ⇒ `'fixed'`; `'exponential'` = backoffSeconds·2^(attempt−1) capped at `maxBackoffSeconds`. */
7102
+ declare const WORKFLOW_RETRY_BACKOFFS: readonly ["fixed", "exponential"];
7103
+
7104
+ /** `sideEffects` (03 §3.1): `'external'` ⇒ park on platform-fault reclaim instead of retrying. Default `'none'`. */
7105
+ declare const WORKFLOW_SIDE_EFFECTS: readonly ["none", "external"];
7106
+
7107
+ /** `waitForSignal.onTimeout`: default `'fail'`; `'continue'` ⇒ output `{received:false, timedOut:true}`. */
7108
+ declare const WORKFLOW_SIGNAL_ON_TIMEOUT: readonly ["fail", "continue"];
7109
+
7110
+ /** The only tier a node may DECLARE (`tier:'job'`, implied by `workspace`); the worker tier is the absence. */
7111
+ declare const WORKFLOW_TIERS: readonly ["job"];
7112
+
7113
+ declare type WorkflowApprovalOnDeny = (typeof WORKFLOW_APPROVAL_ON_DENY)[number];
7114
+
6993
7115
  export declare type WorkflowApproverSpec = 'creator' | 'org-admins' | {
6994
7116
  users: string[] | TemplateBinding;
6995
7117
  } | {
@@ -7033,6 +7155,51 @@ export declare interface WorkflowBusinessHours {
7033
7155
  };
7034
7156
  }
7035
7157
 
7158
+ /** The ONE `connections[]` declaration shape (`@lua/shared-types`): `key` /^[a-z][a-z0-9_-]{0,63}$/ unique per workflow,
7159
+ * `integrationType` the catalog type (`'github'`, `'linear'`, …), optional `required` / `description`. */
7160
+ declare type WorkflowConnectionDeclaration = WorkflowConnectionDeclaration_2;
7161
+
7162
+ declare interface WorkflowConnectionDeclaration_2 {
7163
+ /** /^[a-z][a-z0-9_-]{0,63}$/ — unique per workflow. */
7164
+ key: string;
7165
+ /** Catalog integration type (`github`, `linear`, …) the key resolves within. */
7166
+ integrationType: string;
7167
+ required?: boolean;
7168
+ description?: string;
7169
+ }
7170
+
7171
+ /** The declared budget (10 §10.7.1) — every member optional on the DEFINITION; the server resolves
7172
+ * `maxDurationSeconds` onto the version (`WorkflowVersion.budget`) and the run. */
7173
+ declare interface WorkflowDefinitionBudget {
7174
+ /**
7175
+ * The run's credit ceiling — it counts agent steps, never tokens (LUA-708). An inline agent step settles a flat
7176
+ * 1 credit when it completes; a `tier:'job'` attempt settles a flat 4 at its first claim (a retry is a new
7177
+ * attempt). The engine parks the run on a budget gate (`nextAction:'raise_budget'`) when what remains is under
7178
+ * the next agent step's reserve, so `maxCredits: 40` is ten Job-tier attempts and a value under 4 never
7179
+ * dispatches one. A Job-tier attempt's own spend is bounded by its wall / `maxInputTokens` / `maxMessages`.
7180
+ */
7181
+ maxCredits?: number;
7182
+ maxSteps?: number;
7183
+ /** Job-tier seconds across the run (05 §5.17). */
7184
+ maxJobSeconds?: number;
7185
+ /** default 604 800; 2 592 000 when the graph contains an approval / waitForSignal / suspend-capable step (P1-4). */
7186
+ maxDurationSeconds?: number;
7187
+ }
7188
+
7189
+ export { WorkflowExec }
7190
+
7191
+ export { WorkflowExecBinary }
7192
+
7193
+ export { WorkflowExecError }
7194
+
7195
+ export { WorkflowExecErrorCode }
7196
+
7197
+ export { WorkflowExecOptions }
7198
+
7199
+ export { WorkflowExecRefusalReason }
7200
+
7201
+ export { WorkflowExecResult }
7202
+
7036
7203
  export declare interface WorkflowFourEyes {
7037
7204
  edit: WorkflowApproverSpec;
7038
7205
  approve: WorkflowApproverSpec;
@@ -7052,7 +7219,11 @@ export declare interface WorkflowGoalEnvelope {
7052
7219
  initialState?: Record<string, unknown>;
7053
7220
  }
7054
7221
 
7055
- export declare type WorkflowJobHarness = 'claude-code' | 'generic';
7222
+ export declare type WorkflowJobHarness = WorkflowJobHarness_2;
7223
+
7224
+ declare type WorkflowJobHarness_2 = (typeof WORKFLOW_JOB_HARNESSES)[number];
7225
+
7226
+ declare type WorkflowJobResources = (typeof WORKFLOW_JOB_RESOURCES)[number];
7056
7227
 
7057
7228
  export declare type WorkflowJobToolId = 'shell' | 'read' | 'write' | 'edit' | 'glob' | 'grep' | 'git' | 'gh' | 'fetch';
7058
7229
 
@@ -7061,15 +7232,34 @@ export declare interface WorkflowMergePolicy {
7061
7232
  onConflict: 'fail' | 'agent';
7062
7233
  }
7063
7234
 
7235
+ declare type WorkflowOnError = (typeof WORKFLOW_ON_ERROR)[number];
7236
+
7064
7237
  export declare interface WorkflowOutputVisibility {
7065
7238
  roles: string[];
7066
7239
  users?: string[];
7067
7240
  ownerBypass?: boolean;
7068
7241
  }
7069
7242
 
7070
- /** Matches WorkflowRunDto (R4 `fields:'summary'` — outputs are never inlined here). */
7243
+ declare type WorkflowRetryBackoff = (typeof WORKFLOW_RETRY_BACKOFFS)[number];
7244
+
7245
+ declare interface WorkflowRetryPolicy {
7246
+ maxAttempts: number;
7247
+ /** delay before attempt 2 (default 0 = immediate) — an engine timer, never a sleep inside the step VM (P1-10). */
7248
+ backoffSeconds?: number;
7249
+ /** `'fixed'` (default) | `'exponential'` */
7250
+ backoff?: WorkflowRetryBackoff;
7251
+ /** default 3600; only meaningful with `'exponential'` (`backoff-invalid` otherwise). */
7252
+ maxBackoffSeconds?: number;
7253
+ }
7254
+
7255
+ /**
7256
+ * Matches WorkflowRunDto (R4 `fields:'summary'` — outputs are never inlined here).
7257
+ * The wire names the run `runId` (shared-types `WorkflowRunSummary`); `id` is the pre-R4 spelling some
7258
+ * envelopes still carry — read through `runIdOf()` (LUA-668: `status` printed "Run undefined").
7259
+ */
7071
7260
  declare interface WorkflowRun {
7072
- id: string;
7261
+ id?: string;
7262
+ runId?: string;
7073
7263
  workflowId: string;
7074
7264
  workflowVersionId: string;
7075
7265
  agentId: string;
@@ -7086,9 +7276,45 @@ declare interface WorkflowRun {
7086
7276
  reason?: string;
7087
7277
  since?: string;
7088
7278
  };
7279
+ /**
7280
+ * The pending / audited cancel request (`runCancelView`): who asked and when; `wall` when it was the run wall's
7281
+ * own (LUA-686); LUA-704: `forcedBy` / `forcedAt` / `forceReason` on a forced terminal (`abandoned`, or
7282
+ * `timed_out` when the wall's request was forced) — the run's own reason is the terminal's.
7283
+ */
7284
+ cancel?: {
7285
+ requestedAt: number;
7286
+ requestedBy: string;
7287
+ forceAvailableAt: number;
7288
+ wall?: boolean;
7289
+ forcedAt?: number;
7290
+ forcedBy?: string;
7291
+ forceReason?: string;
7292
+ };
7089
7293
  failureReason?: string;
7090
7294
  restricted?: boolean;
7295
+ /** R4 `fields:'full'` only (§9.3.1): the caller may not read this run's payloads — `output` / step outputs are withheld. */
7296
+ outputsHidden?: 'read-outputs' | 'cloud-task';
7297
+ /** LUA-623: the keys the run's version declares, and what each resolved to on its agent (`connection.resolved` rows). */
7298
+ connections?: {
7299
+ declared: Array<{
7300
+ key: string;
7301
+ integrationType: string;
7302
+ required?: boolean;
7303
+ }>;
7304
+ resolved: Array<{
7305
+ key: string;
7306
+ connectionId: string;
7307
+ integrationType: string;
7308
+ scope: 'agent' | 'org';
7309
+ at: number;
7310
+ }>;
7311
+ };
7312
+ /** R4 `fields:'full'` only: the payload inline, else the `{__cdnRef}` it was offloaded under (LUA-643). */
7091
7313
  output?: unknown;
7314
+ /** LUA-643: ≤ 2 KB preview beside an offloaded `output`. */
7315
+ outputPreview?: string;
7316
+ /** LUA-643: every shape says whether a result exists; `--steps` (`fields:'full'`) serves it. */
7317
+ hasOutput?: boolean;
7092
7318
  createdAt: string;
7093
7319
  startedAt?: string;
7094
7320
  completedAt?: string;
@@ -7231,6 +7457,14 @@ export declare interface WorkflowsApi {
7231
7457
  };
7232
7458
  }
7233
7459
 
7460
+ export { WorkflowShell }
7461
+
7462
+ export { WorkflowShellValue }
7463
+
7464
+ declare type WorkflowSideEffects = (typeof WORKFLOW_SIDE_EFFECTS)[number];
7465
+
7466
+ declare type WorkflowSignalOnTimeout = (typeof WORKFLOW_SIGNAL_ON_TIMEOUT)[number];
7467
+
7234
7468
  export declare interface WorkflowSpecialistRole {
7235
7469
  name: string;
7236
7470
  instructions: string;
@@ -7254,7 +7488,11 @@ export declare interface WorkflowStepContext<TIn = unknown, TResume = unknown, T
7254
7488
  /** What the prior invocation passed to `suspend()`. */
7255
7489
  suspendData?: unknown;
7256
7490
  getInitData<T = unknown>(): T;
7257
- /** Output of an UPSTREAM step. Throws `WorkflowStepResultError{ code:'STEP_RESULT_NOT_ANCESTOR' }` for a non-ancestor. */
7491
+ /**
7492
+ * Output of an UPSTREAM step. Throws `WorkflowStepResultError` — `code:'STEP_RESULT_NOT_ANCESTOR'` for a
7493
+ * non-ancestor (or unknown) id, `'STEP_RESULT_TOO_LARGE'` / `'STEP_RESULT_OFFLOADED'` for an output the claim
7494
+ * could not carry (see the error's doc for `bytes` / `reason`) — never `undefined`, never a raw ref object.
7495
+ */
7258
7496
  getStepResult<T = unknown>(stepId: string): T;
7259
7497
  /** Run-scoped KV, ledger-backed, ≤ 64KB total. `set` is durable when the step terminalizes. */
7260
7498
  state: {
@@ -7273,17 +7511,65 @@ export declare interface WorkflowStepContext<TIn = unknown, TResume = unknown, T
7273
7511
  signal: AbortSignal;
7274
7512
  /** Sub-agent env, exactly as jobs receive it. */
7275
7513
  env: Record<string, string>;
7276
- /** EXACTLY-ONCE effect keyed on `{occurrenceId, key}` (P1-18). Claim → run `fn` → settle. */
7514
+ /**
7515
+ * EXACTLY-ONCE effect keyed on `{occurrenceId, key}` (P1-18). Claim → run `fn` → settle. Served on every tier:
7516
+ * worker-tier steps and the offline driver, and (LUA-722) Job-tier code steps — the pod relays the claim / settle
7517
+ * under its own attempt token, so the key is scoped to the step's run / row / attempt server-side. A replayed key
7518
+ * (a retried attempt, a repair run) returns the settled result without running `fn`; a key a previous attempt
7519
+ * claimed and never settled throws `EFFECT_IN_DOUBT` (fail closed — `fn` never runs on an unknown claim state).
7520
+ * The result is JSON-serialised on settle, exactly like a step output: a `Date` replays as its ISO string, a
7521
+ * `BigInt` (or a cycle) fails the settle — `EFFECT_SETTLE_FAILED`, the key stays claimed — and a result over the
7522
+ * platform's cap (32 KB) is `EFFECT_SETTLE_FAILED` naming `EFFECT_RESULT_TOO_LARGE`. Calling `once` again for the
7523
+ * same key while its `fn` is still running (re-entrantly) throws `EFFECT_KEY_INVALID` at once.
7524
+ */
7277
7525
  once<T>(key: string, fn: () => Promise<T>): Promise<T>;
7278
- /** Job-tier steps only: the mounted run workspace. */
7526
+ /**
7527
+ * Job-tier steps only: the mounted run workspace, exactly as the Job pod hands it to `execute` (`ctx.workspace` in
7528
+ * `packages/lua-workflow-job/src/code-step.ts`): `root` is the absolute directory of the checkout (`/workspace`),
7529
+ * `branch` the run branch it is on, `headSha` the commit it was restored at, `mount` this step's declared mount,
7530
+ * `isolation` whether the step got its own worktree. LUA-679: the name is `root` — the 3.32.1 type and both
7531
+ * `lua init` examples said `path`, the pod never served it, and a copied definition died `ENOENT /workspace/undefined`.
7532
+ */
7279
7533
  workspace?: {
7280
- path: string;
7534
+ root: string;
7281
7535
  mount: 'rw' | 'ro';
7282
7536
  branch?: string;
7537
+ headSha?: string;
7538
+ isolation?: 'shared' | 'worktree';
7539
+ /**
7540
+ * @deprecated LUA-679 — read `root`. The Job pod serves `path` as an alias (a getter that returns `root` and warns
7541
+ * once per step) for one minor after 3.32 and then removes it; it never appears on `Object.keys(ctx.workspace)`.
7542
+ */
7543
+ readonly path?: string;
7544
+ /**
7545
+ * The run workspace's stamps, served when the pod hands them to the step (LUA-706): `baseSha` is the commit the
7546
+ * run's base ref resolved to at provision (a git workspace — `headSha` is where THIS step's checkout is), `arm`
7547
+ * the worktree arm id when the step runs in its own worktree (`isolation:'worktree'`), `backend` the volume
7548
+ * backend. Absent on an `empty` workspace, a shared-mount step, or a pod that predates them.
7549
+ */
7283
7550
  baseSha?: string;
7284
7551
  arm?: string;
7285
7552
  backend?: WorkflowWorkspaceBackend;
7286
7553
  };
7554
+ /**
7555
+ * Job-tier steps only (LUA-682): run one of `WORKFLOW_EXEC_BINARIES` (`git`, `gh`, `pnpm`, `npm`, `npx`, `node`,
7556
+ * `yarn`, `python3`, `pytest`, `make`) in the workspace — `exec(['git', 'status'], { cwd?, timeoutMs?, env? })`.
7557
+ * Argv only, never a shell: no `&&`, pipes, globs or `$VAR`; `cwd` must stay inside the workspace; the timeout
7558
+ * (default 10 min) is capped by the step's remaining wall; stdout / stderr are kept to 1 MiB each (`truncated`);
7559
+ * one command at a time. A non-zero exit is RETURNED (`result.code`) — `exec.strict` throws `WorkflowExecError`.
7560
+ * The Job pod spawns the command itself with a scrubbed env (no token, no `LUA_WF_*`; git goes through the
7561
+ * credential proxy exactly as the coding turn's does); `child_process` is not available to a code step and fails
7562
+ * `lua compile` with `node-capability-unavailable`. Worker-tier steps have neither `exec` nor `$`. Offline,
7563
+ * `lua workflows run --workspace <dir>` provides both with the same allowlist against your own PATH.
7564
+ */
7565
+ exec?: WorkflowExec;
7566
+ /**
7567
+ * Job-tier steps only (LUA-682): `exec` as a tagged template — `$\`gh pr create --title ${title} --body ${body}\``.
7568
+ * Literal text splits on whitespace (with `'…'` / `"…"` quoting); every `${value}` is exactly ONE argument, never
7569
+ * re-parsed (a title with spaces, a body with newlines); an array spreads into one argument per item; `undefined`
7570
+ * is refused rather than stringified. `$.strict` throws on a non-zero exit.
7571
+ */
7572
+ $?: WorkflowShell;
7287
7573
  /** The run artefact store (P1-8). */
7288
7574
  artefacts: {
7289
7575
  put(name: string, data: Uint8Array | string | ReadableStream, opts: {
@@ -7318,7 +7604,12 @@ export declare interface WorkflowStepContext<TIn = unknown, TResume = unknown, T
7318
7604
  }>;
7319
7605
  list(): Promise<WorkflowArtefactMeta[]>;
7320
7606
  };
7321
- /** Stamped by the executor for observability; read-only. */
7607
+ /**
7608
+ * Stamped by the executor for observability; read-only (frozen). Served on both tiers from the run's stamps
7609
+ * (LUA-706): `trigger` / `principalKind`, plus `parentRunId` / `traceparent` / `correlationKey` / `tags` /
7610
+ * `replyTo` when the run carries them; `agentVersion` is not stamped today. A run created before the stamps
7611
+ * existed reads `{}`. Offline, `lua workflows run` serves `{ trigger:'sdk', principalKind:'user' }`.
7612
+ */
7322
7613
  runtime: {
7323
7614
  trigger: WorkflowRunTrigger;
7324
7615
  parentRunId?: string;
@@ -7334,10 +7625,26 @@ export declare interface WorkflowStepContext<TIn = unknown, TResume = unknown, T
7334
7625
  };
7335
7626
  }
7336
7627
 
7337
- /** Thrown by `ctx.getStepResult` for a non-ancestor / unknown id — never `undefined` (03 §3.1). */
7628
+ /**
7629
+ * Thrown by `ctx.getStepResult` — never `undefined`, never a raw ref object (03 §3.1). Check `err.code`, never
7630
+ * `instanceof` (a step runs in its own realm on every tier):
7631
+ * - `STEP_RESULT_NOT_ANCESTOR` — `stepId` is not an upstream step of this one (or is unknown);
7632
+ * - `STEP_RESULT_TOO_LARGE` — the ancestor's output could not ride the claim beside its siblings (the 4 MiB
7633
+ * `stepResults` wire budget, dropped largest-first); `bytes` is its serialized size;
7634
+ * - `STEP_RESULT_OFFLOADED` — the ledger holds the output offloaded (> 256 KB) and the claim could not carry it
7635
+ * hydrated; `bytes` is its size, `reason` why: `over_wire_cap` (it would break the budget), `hydrate_timeout`
7636
+ * (the per-claim hydration deadline passed), or the control plane's code (`CDN_REF_MISSING`, `CDN_REF_CORRUPT`,
7637
+ * `CDN_REF_FOREIGN`, …).
7638
+ * For the last two, bind the value through the step's input instead, or read it via `ctx.artefacts` /
7639
+ * `ctx.datasets`. The offline driver (`lua workflows execute`) only ever throws the first.
7640
+ */
7338
7641
  export declare interface WorkflowStepResultError extends Error {
7339
- code: 'STEP_RESULT_NOT_ANCESTOR';
7642
+ code: 'STEP_RESULT_NOT_ANCESTOR' | 'STEP_RESULT_TOO_LARGE' | 'STEP_RESULT_OFFLOADED';
7340
7643
  stepId: string;
7644
+ /** `STEP_RESULT_TOO_LARGE` / `STEP_RESULT_OFFLOADED`: the output's serialized size. */
7645
+ bytes?: number;
7646
+ /** `STEP_RESULT_OFFLOADED`: why the claim could not carry it. */
7647
+ reason?: string;
7341
7648
  }
7342
7649
 
7343
7650
  export declare interface WorkflowStepWorkspace {
@@ -7356,6 +7663,8 @@ export declare type WorkflowSuspendTimeoutChainMember = 'deny' | 'cancel-run' |
7356
7663
  timeoutHours: number;
7357
7664
  };
7358
7665
 
7666
+ declare type WorkflowTier = (typeof WORKFLOW_TIERS)[number];
7667
+
7359
7668
  export declare type WorkflowWorkspaceBackend = 'ebs' | 'efs' | 's3';
7360
7669
 
7361
7670
  export declare type WorkspaceSpec = {
@@ -7372,6 +7681,10 @@ export declare type WorkspaceSpec = {
7372
7681
  kind: 'empty';
7373
7682
  sizeGb?: number;
7374
7683
  ttlHours?: number;
7684
+ /**
7685
+ * Keep the volume after the run completes: held until `ttlHours` (24 h when undeclared), then expired. A kept
7686
+ * volume holds one of the organisation's workspace slots (`maxWorkspacesPerOrg`, 10 by default) until then.
7687
+ */
7375
7688
  keepArtefacts?: boolean;
7376
7689
  backend?: WorkflowWorkspaceBackend;
7377
7690
  };