lua-cli 3.29.1 → 3.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/api-exports.d.ts +1185 -77
  2. package/dist/api-exports.js +5032 -137
  3. package/dist/api-exports.js.map +1 -1
  4. package/dist/index.js +25610 -14399
  5. package/dist/index.js.map +1 -1
  6. package/dist/voice/test/index.d.ts +40 -40
  7. package/dist/workflow-builder.d.ts +766 -0
  8. package/dist/workflow-builder.js +5732 -0
  9. package/dist/workflow-builder.js.map +1 -0
  10. package/docs/API_INDEX.md +2 -0
  11. package/docs/README.md +27 -9
  12. package/docs/api/Jobs.md +10 -10
  13. package/docs/api/LuaWorkflow.md +73 -0
  14. package/docs/api/Workflows.md +110 -0
  15. package/docs/workflows/approvals.md +28 -0
  16. package/docs/workflows/artefacts-and-datasets.md +19 -0
  17. package/docs/workflows/coding-harness.md +12 -0
  18. package/docs/workflows/compliance-gates.md +16 -0
  19. package/docs/workflows/connections-in-coding-turns.md +9 -0
  20. package/docs/workflows/correlation-keys.md +11 -0
  21. package/docs/workflows/env-overlays.md +12 -0
  22. package/docs/workflows/evidence-bundles.md +11 -0
  23. package/docs/workflows/exports.md +5 -0
  24. package/docs/workflows/external-content-and-toolscope.md +11 -0
  25. package/docs/workflows/git-credentials.md +11 -0
  26. package/docs/workflows/knowledge-bindings.md +13 -0
  27. package/docs/workflows/limits.md +11 -0
  28. package/docs/workflows/long-steps-and-checkpoints.md +13 -0
  29. package/docs/workflows/migrating-cloud-tasks.md +9 -0
  30. package/docs/workflows/migrating-runs.md +13 -0
  31. package/docs/workflows/output-visibility.md +9 -0
  32. package/docs/workflows/per-item-approvals.md +9 -0
  33. package/docs/workflows/private-network-sources.md +12 -0
  34. package/docs/workflows/recovery.md +28 -0
  35. package/docs/workflows/replay-local.md +35 -0
  36. package/docs/workflows/reply-channels.md +11 -0
  37. package/docs/workflows/retention-and-archival.md +82 -0
  38. package/docs/workflows/roles.md +12 -0
  39. package/docs/workflows/schedules.md +11 -0
  40. package/docs/workflows/script-form.md +50 -0
  41. package/docs/workflows/testing-offline.md +46 -0
  42. package/docs/workflows/workspace-backends.md +11 -0
  43. package/docs/workflows/workspaces-and-long-steps.md +27 -0
  44. package/package.json +7 -2
  45. package/scripts/run-api-extractor.mjs +1 -1
  46. package/template/.gitignore +2 -0
  47. package/template/examples/workflows/CLAUDE.md +24 -0
  48. package/template/examples/workflows/adversarial-verify.workflow.script.js +48 -0
  49. package/template/examples/workflows/github-review.webhook.ts +19 -0
  50. package/template/examples/workflows/linear-ready.trigger.ts +21 -0
  51. package/template/examples/workflows/outreach.ts +55 -0
  52. package/template/examples/workflows/pr-review-round.ts +38 -0
  53. package/template/examples/workflows/provision-tenant.ts +18 -0
  54. package/template/examples/workflows/refund-approval.ts +44 -0
  55. package/template/examples/workflows/research-brief.ts +42 -0
  56. package/template/examples/workflows/reviewed-brief.ts +19 -0
  57. package/template/examples/workflows/support-triage.ts +44 -0
  58. package/template/examples/workflows/ticket-to-pr.ts +65 -0
  59. package/template/examples/workflows/vendor-invoices.ts +30 -0
  60. package/template/lua.skill.yaml +1 -0
  61. package/template/package.json +1 -1
@@ -1,9 +1,24 @@
1
+ import { ArtefactRef } from '@lua/workflow-graph';
1
2
  import { CallWarning } from 'ai';
3
+ import { DatasetRef } from '@lua/workflow-graph';
4
+ import { EnvRefBinding } from '@lua/workflow-graph';
2
5
  import { FinishReason } from 'ai';
6
+ import { fromKnowledge as fromKnowledge_2 } from '@lua/workflow-graph';
7
+ import { JsonSchema } from '@lua/workflow-graph';
8
+ import { KnowledgeBindingSpec } from '@lua/workflow-graph';
3
9
  import { LanguageModelUsage } from 'ai';
10
+ import { Literal } from '@lua/workflow-graph';
11
+ import { LuaMapConfig } from '@lua/workflow-graph';
12
+ import { LuaPredicate } from '@lua/workflow-graph';
13
+ import { MapDescriptor } from '@lua/workflow-graph';
4
14
  import { ModelMessage } from 'ai';
15
+ import { PathOrLiteral } from '@lua/workflow-graph';
5
16
  import { ReasoningOutput } from 'ai';
17
+ import { SerializedWorkflowGraph } from '@lua/workflow-graph';
18
+ import { TemplateBinding } from '@lua/workflow-graph';
19
+ import { TypedRef } from '@lua/workflow-graph';
6
20
  import { UserContent } from 'ai';
21
+ import { WorkflowGraphEntry } from '@lua/workflow-graph';
7
22
  import { z } from 'zod';
8
23
  import { ZodType } from 'zod';
9
24
 
@@ -13,8 +28,11 @@ import { ZodType } from 'zod';
13
28
  * not exposed to skill code.
14
29
  */
15
30
  declare interface AgentInvocationEffects {
16
- reviewDraftsCreated: number;
17
- storage: 'lua_inbox';
31
+ reviewDraftsCreated?: number;
32
+ storage?: 'lua_inbox';
33
+ /** Set once per run when the agent reported it could not finish. Trusted
34
+ * side channel: the run's own account of why, not a regex over its prose. */
35
+ blocker?: TaskRunBlocker;
18
36
  }
19
37
 
20
38
  /**
@@ -104,21 +122,66 @@ declare interface AgentInvocationInput {
104
122
  * approved-models policy server-side. */
105
123
  model?: string;
106
124
  /** Task 14 (tasks-redesign) — per-task connector + skill scoping. See `AgentToolScope`. */
107
- toolScope?: AgentToolScope;
108
- /**
109
- * PRO-979 (A3) — cooperative mid-run cancellation. Honored where the
110
- * transport boundary supports it (the loopback HTTP call is aborted); the
111
- * in-flight server-side turn is NOT hard-killed callers that abort must
112
- * treat still-landing side effects as possible and record them (the job
113
- * runner's ledger does, via postFence). NOT serialized on the wire — this
114
- * field exists only on in-process invocations.
125
+ toolScope?: AgentToolScope_2;
126
+ /**
127
+ * PRO-979 (A3) — cooperative mid-run cancellation. Aborting tears down the
128
+ * loopback HTTP call AND propagates to the server-side turn: the serving
129
+ * pod's `ActiveChatTurnRegistry` sees the socket close and aborts the turn
130
+ * signal (`'client_disconnected'`), which flows through
131
+ * `ChatRequest.clientAbortSignal` into Mastra's
132
+ * `agent.generate({ abortSignal })` loop, so the in-flight turn stops
133
+ * generating (the D4 abort chain, pinned by the Phase-0
134
+ * `chat-generate-abort.contract` spec). Propagation is asynchronous:
135
+ * callers that abort must still treat side effects already dispatched at
136
+ * abort time (e.g. an in-flight tool call) as possible and record them (the
137
+ * job runner's ledger does, via postFence). NOT serialized on the wire —
138
+ * this field exists only on in-process invocations.
115
139
  */
116
140
  signal?: AbortSignal;
141
+ /**
142
+ * Workflows D10 (WF-003) — JSON Schema for a typed structured output on
143
+ * this turn. Honored server-side ONLY on internally-authenticated turns
144
+ * (`X-Internal-Auth`): `ChatService.buildChatRequest` copies it onto the
145
+ * `ChatRequest` and `AgentService.generate` forwards it as Mastra
146
+ * `structuredOutput`, so the result carries a schema-shaped `object`. A
147
+ * Bearer client's value is dropped before it can reach the model — same
148
+ * posture as `toolScope`.
149
+ */
150
+ outputSchema?: Record<string, unknown>;
151
+ /**
152
+ * Workflows D11 (WF-003) — retry-stable billing identity for the turn
153
+ * (e.g. `wf:<runId>:<stepId>:<billingEpoch>`), letting the credit deduction
154
+ * be idempotent across step retries. Internal-auth-only, same posture as
155
+ * `outputSchema`/`toolScope`; a Bearer client's value is dropped.
156
+ */
157
+ operationId?: string;
158
+ /**
159
+ * Workflows D25 (WF-216, 04 §4.2.7 runtime 3) — the ephemeral specialist's
160
+ * additive role for THIS turn: `name` (the role name; attribution key
161
+ * `luaWorkflowRole`), `block` (the rendered `<lua-workflow-role>` block
162
+ * `PromptService` appends AFTER the owner's own persona/instructions) and
163
+ * `tools` (the explicit tool-id allowlist `DynamicToolService` intersects
164
+ * with the owner's toolset). Internal-auth-only, same posture as
165
+ * `outputSchema`/`toolScope`: a Bearer client's value is dropped. Never a
166
+ * `systemPrompt` — the persona is the owner's.
167
+ */
168
+ workflowRole?: {
169
+ name: string;
170
+ block: string;
171
+ tools: string[];
172
+ };
117
173
  }
118
174
 
119
175
  declare interface AgentInvocationOutput {
120
176
  /** Final response text (post-processor-modified, if applicable). */
121
177
  text: string;
178
+ /**
179
+ * Workflows D10 (WF-003/WF-108) — the schema-shaped structured result of a
180
+ * turn that carried `outputSchema`. Present ONLY when the turn ran with
181
+ * Mastra `structuredOutput` (internal-auth-only, so Bearer callers can never
182
+ * receive it); absent otherwise — legacy outputs are byte-identical.
183
+ */
184
+ object?: unknown;
122
185
  /** AI SDK `FinishReason` (or `'preprocessor_blocked'` / `'governance_blocked'`). */
123
186
  finishReason?: string;
124
187
  /** Token usage summary. */
@@ -226,6 +289,34 @@ export declare interface AgentsApi {
226
289
  invoke(targetAgentId: string, input: AgentInvocationInput): Promise<AgentInvocationOutput>;
227
290
  }
228
291
 
292
+ export declare interface AgentStepOptions {
293
+ agentId: string | EnvRefBinding;
294
+ prompt: TemplateLike;
295
+ outputSchema?: ZodType;
296
+ model?: string;
297
+ toolScope?: AgentToolScope & {
298
+ jobTools?: WorkflowJobToolId[];
299
+ };
300
+ timeoutSeconds?: number;
301
+ retry?: RetryPolicy;
302
+ onError?: 'fail' | 'continue' | 'park';
303
+ requiredConnections?: string[];
304
+ /** static-only persona override (§11 S3) */
305
+ systemPrompt?: string;
306
+ tier?: 'job';
307
+ workspace?: WorkflowStepWorkspace;
308
+ jobResources?: 'small' | 'medium' | 'large';
309
+ harness?: WorkflowJobHarness;
310
+ /** Coding-turn cap for a tier:'job' step (1..500); absent ⇒ the platform default. A monorepo change needs more than the default. */
311
+ maxTurns?: number;
312
+ }
313
+
314
+ export declare interface AgentToolScope {
315
+ connectionIds?: string[];
316
+ skillIds?: string[];
317
+ toolIds?: string[];
318
+ }
319
+
229
320
  /**
230
321
  * Task 14 (tasks-redesign) — per-task connector + skill scoping for a scheduled
231
322
  * agent run. Non-empty `connectionIds` restricts the turn's MCP servers to the
@@ -236,7 +327,7 @@ export declare interface AgentsApi {
236
327
  * `X-Internal-Auth` agent-invoke path used by the server-side job runner) —
237
328
  * lua-core drops it from any client-authenticated `/chat/*` request.
238
329
  */
239
- declare interface AgentToolScope {
330
+ declare interface AgentToolScope_2 {
240
331
  /** Allowlisted agent connection ids (UnifiedTo `unifiedId`s). */
241
332
  connectionIds?: string[];
242
333
  /** Allowlisted skill ids (from the agent's `subAgent.skills`). */
@@ -384,6 +475,8 @@ export declare interface AiGenerateToolResult {
384
475
  isError?: boolean;
385
476
  }
386
477
 
478
+ export declare const and: (...args: LuaPredicate[]) => LuaPredicate;
479
+
387
480
  /**
388
481
  * Common Interfaces
389
482
  * Shared interfaces used across multiple modules
@@ -422,6 +515,33 @@ declare interface ApiResponse<T = any> {
422
515
  };
423
516
  }
424
517
 
518
+ export declare interface ApprovalOptions {
519
+ title: string;
520
+ details?: TemplateBinding;
521
+ /** default 'creator' */
522
+ approver?: WorkflowApproverSpec;
523
+ excludeInitiator?: boolean;
524
+ fourEyes?: WorkflowFourEyes;
525
+ /** default 168; a binding is resolved at suspend time and must yield 1..720 */
526
+ timeoutHours?: number | TemplateBinding;
527
+ /** 'deny' (default) | 'cancel-run' | 'fail' | a chain of ≤ 3 hops ending in one terminal member */
528
+ onTimeout?: WorkflowSuspendTimeoutChain;
529
+ /** default 'continue' (denial is data unless 'fail') */
530
+ onDeny?: 'fail' | 'continue';
531
+ businessHours?: WorkflowBusinessHours;
532
+ editable?: boolean;
533
+ /** grammar: `drafts`, `drafts[*]`, `drafts[*].body`, `drafts[3].body`, `summary.title` */
534
+ editablePaths?: string[];
535
+ editedPayloadSchema?: ZodType;
536
+ itemsPath?: string;
537
+ itemApprover?: WorkflowApproverSpec | {
538
+ fromItem: string;
539
+ };
540
+ itemTimeout?: WorkflowSuspendOnTimeout;
541
+ }
542
+
543
+ export { ArtefactRef }
544
+
425
545
  /**
426
546
  * Complete basket entity.
427
547
  * Full basket object as stored in the database.
@@ -748,6 +868,26 @@ declare interface BrowserSwitchConfig {
748
868
  maxSessionMinutes?: number;
749
869
  }
750
870
 
871
+ /** What `.commit()` hands to `LuaWorkflow` — internal; never `new LuaWorkflow({...})` by users. */
872
+ declare interface BuiltWorkflow {
873
+ config: LuaWorkflowConfig;
874
+ graph: WorkflowGraphEntry[];
875
+ steps: Record<string, LuaWorkflowStep<any, any, any>>;
876
+ warnings: LuaWorkflowBuildWarning[];
877
+ envTemplateKeys: string[];
878
+ nestedRefs: Array<{
879
+ id: string;
880
+ name: string;
881
+ }>;
882
+ }
883
+
884
+ /** R11 — `CancelRunVerdict` (PRO-979 vocabulary). */
885
+ declare interface CancelRunVerdict {
886
+ status: WorkflowRunStatus;
887
+ nextAction: string;
888
+ forceAvailableAt?: string;
889
+ }
890
+
751
891
  /**
752
892
  * CDN API
753
893
  * Upload and retrieve files from the Lua CDN
@@ -934,6 +1074,31 @@ export declare interface ChannelsApi {
934
1074
  */
935
1075
  send(input: EmailSendInput): Promise<ChannelSendOutput>;
936
1076
  };
1077
+ /**
1078
+ * Read the delivery status of one outbound message.
1079
+ *
1080
+ * Pass the `deliveryId` any send returned. The record moves
1081
+ * `queued -> accepted -> sent -> delivered -> read`, or terminates on
1082
+ * `failed`, and a failure carries a canonical `error.category`, the vendor
1083
+ * code and a remediation link.
1084
+ *
1085
+ * @example
1086
+ * ```typescript
1087
+ * const sent = await Channels.send({ channel: 'whatsapp', to: { phoneNumber: '+15551234567' }, text: 'Hi' });
1088
+ * const delivery = await Channels.getStatus(sent.deliveryId);
1089
+ * if (delivery.status === 'failed') console.error(delivery.error?.category, delivery.error?.title);
1090
+ * ```
1091
+ */
1092
+ getStatus(deliveryId: string): Promise<DeliveryView>;
1093
+ /**
1094
+ * List the agent's recent deliveries, newest first.
1095
+ *
1096
+ * @example
1097
+ * ```typescript
1098
+ * const failures = await Channels.listDeliveries({ status: 'failed', since: '2026-09-01T00:00:00Z', limit: 50 });
1099
+ * ```
1100
+ */
1101
+ listDeliveries(filter?: DeliveryListFilter): Promise<DeliveryView[]>;
937
1102
  }
938
1103
 
939
1104
  export declare type ChannelSendChannel = (typeof CHANNEL_SEND_CHANNELS)[number];
@@ -971,6 +1136,18 @@ export declare interface ChannelSendOptions {
971
1136
  * `warning` — never an error status for a delivered message.
972
1137
  */
973
1138
  export declare interface ChannelSendOutput {
1139
+ /** Delivery record id. Stable across the send's whole lifecycle; query it for status. */
1140
+ deliveryId: string;
1141
+ /**
1142
+ * Where the delivery stands the moment the send returns. `queued` means the
1143
+ * WhatsApp window was closed and the text flushes when the user replies.
1144
+ * Receipts move it further (delivered, read, failed) after this call.
1145
+ *
1146
+ * A live send returns `queued`, `accepted` or `sent`. Replaying an
1147
+ * `X-Idempotency-Key` returns wherever the first send's delivery has since
1148
+ * got to, so any status is possible there.
1149
+ */
1150
+ status: DeliveryStatus;
974
1151
  delivered: boolean;
975
1152
  /** False for conversation-scoped sends: a shared conversation has no single
976
1153
  * user to attribute the message to, so nothing is written to agent memory. */
@@ -1105,6 +1282,9 @@ export declare interface ChatHistoryMessage {
1105
1282
  */
1106
1283
  export declare type ChatMessage = TextMessage | ImageMessage | FileMessage;
1107
1284
 
1285
+ /** A container arm: a `StepRef`, or (B14 — lands with WF-509) the two-element chain `[mapConfig, stepRef]`. */
1286
+ export declare type ContainerArm = StepRef | [LuaMapConfig, StepRef];
1287
+
1108
1288
  /**
1109
1289
  * Options for creating a custom data entry.
1110
1290
  */
@@ -1159,6 +1339,10 @@ declare interface CreateOrderRequest {
1159
1339
  };
1160
1340
  }
1161
1341
 
1342
+ export declare function createStep<TIn extends ZodType, TOut extends ZodType, TResume extends ZodType = ZodType>(s: LuaWorkflowStep<TIn, TOut, TResume>): LuaWorkflowStep<TIn, TOut, TResume>;
1343
+
1344
+ export declare function createWorkflow(cfg: LuaWorkflowConfig): LuaWorkflowBuilder;
1345
+
1162
1346
  /**
1163
1347
  * Custom Data API contract.
1164
1348
  * Defines operations for managing custom data collections with vector search.
@@ -1422,6 +1606,8 @@ export declare class DataEntryInstance {
1422
1606
  save(searchText?: string): Promise<boolean>;
1423
1607
  }
1424
1608
 
1609
+ export { DatasetRef }
1610
+
1425
1611
  /**
1426
1612
  * Define a device that an agent can communicate with.
1427
1613
  *
@@ -1519,6 +1705,8 @@ export declare function defineTrigger<T = any>(config: LuaTriggerConfig<T>): Lua
1519
1705
  */
1520
1706
  export declare function defineVoice(config: LuaVoiceConfig): LuaVoice;
1521
1707
 
1708
+ export declare function defineWorkflow(cfg: LuaWorkflowConfig, build: (wf: LuaWorkflowBuilder) => LuaWorkflow): LuaWorkflow;
1709
+
1522
1710
  /**
1523
1711
  * Response from deleting custom data entry.
1524
1712
  */
@@ -1543,6 +1731,100 @@ declare interface DeleteProductResponse {
1543
1731
  deleted: boolean;
1544
1732
  }
1545
1733
 
1734
+ /** Canonical, cross-vendor failure reason. Vendor codes map onto these. */
1735
+ declare const DELIVERY_ERROR_CATEGORIES: readonly ["window_closed", "unreachable", "billing", "opted_out", "throttled", "auth", "template", "media", "invalid_request", "compliance", "experiment", "provider", "unknown"];
1736
+
1737
+ declare const DELIVERY_ORIGINS: readonly ["agent_reply", "channels_send", "template", "system_template", "queued_flush", "admin_template", "notification", "unknown"];
1738
+
1739
+ declare const DELIVERY_PROVIDERS: readonly ["meta", "vonage", "bird", "ses", "agentmail", "slack", "front", "teams", "pusher"];
1740
+
1741
+ /**
1742
+ * Outbound delivery record contracts.
1743
+ *
1744
+ * One outbound message is one delivery document moving through a monotone
1745
+ * status rank with a single terminal failure. Vendor callbacks are normalised
1746
+ * into `ProviderStatusUpdate` by a per-provider mapper, so vendor vocabulary
1747
+ * stops at the mapper and everything downstream speaks these types.
1748
+ */
1749
+ declare const DELIVERY_STATUSES: readonly ["queued", "accepted", "sent", "delivered", "read", "failed", "expired"];
1750
+
1751
+ export declare interface DeliveryError {
1752
+ category: DeliveryErrorCategory;
1753
+ provider: DeliveryProvider;
1754
+ /** Vendor code as a string. '131042', '1240', 'Permanent/General'. */
1755
+ code: string;
1756
+ title: string;
1757
+ detail?: string;
1758
+ href?: string;
1759
+ retryable: boolean;
1760
+ owner: DeliveryErrorOwner;
1761
+ }
1762
+
1763
+ export declare type DeliveryErrorCategory = (typeof DELIVERY_ERROR_CATEGORIES)[number];
1764
+
1765
+ /** Who has to act on a failure. Drives the operator surface, not retry logic. */
1766
+ declare type DeliveryErrorOwner = 'customer' | 'recipient' | 'lua' | 'vendor';
1767
+
1768
+ declare type DeliveryEventSource = 'send' | 'callback' | 'sweep';
1769
+
1770
+ declare interface DeliveryEventView {
1771
+ status: DeliveryStatus;
1772
+ at: string;
1773
+ source: DeliveryEventSource;
1774
+ }
1775
+
1776
+ /** Query filter accepted by the delivery list read APIs. */
1777
+ export declare interface DeliveryListFilter {
1778
+ userId?: string;
1779
+ status?: DeliveryStatus;
1780
+ channel?: string;
1781
+ /** Only deliveries created at or after this instant. */
1782
+ since?: string | Date;
1783
+ /** 1..200, defaults to 50. */
1784
+ limit?: number;
1785
+ }
1786
+
1787
+ declare type DeliveryOrigin = (typeof DELIVERY_ORIGINS)[number];
1788
+
1789
+ /** Vendor-reported cost metadata. Meta only today. */
1790
+ declare interface DeliveryPricing {
1791
+ billable: boolean;
1792
+ category?: string;
1793
+ model?: string;
1794
+ }
1795
+
1796
+ declare type DeliveryProvider = (typeof DELIVERY_PROVIDERS)[number];
1797
+
1798
+ export declare type DeliveryStatus = (typeof DELIVERY_STATUSES)[number];
1799
+
1800
+ /** Wire shape of a delivery as returned by read APIs (dates as ISO strings). */
1801
+ export declare interface DeliveryView {
1802
+ id: string;
1803
+ agentId: string;
1804
+ userId?: string;
1805
+ /** `ChannelSendChannel | 'rcs' | 'messagebird' | 'slack' | 'front' | 'webchat' | 'sms'`. */
1806
+ channel: string;
1807
+ provider: DeliveryProvider;
1808
+ channelIdentifier: string;
1809
+ recipient: string;
1810
+ providerMessageId?: string;
1811
+ conversationMessageId?: string;
1812
+ origin: DeliveryOrigin;
1813
+ templateName?: string;
1814
+ idempotencyKey?: string;
1815
+ status: DeliveryStatus;
1816
+ error?: DeliveryError;
1817
+ events: DeliveryEventView[];
1818
+ pricing?: DeliveryPricing;
1819
+ createdAt: string;
1820
+ updatedAt: string;
1821
+ deliveredAt?: string;
1822
+ readAt?: string;
1823
+ failedAt?: string;
1824
+ }
1825
+
1826
+ declare type Depth = [never, 0, 1, 2, 3, 4];
1827
+
1546
1828
  /** Configuration for a single device command (agent → device) */
1547
1829
  export declare interface DeviceCommandConfig {
1548
1830
  /** Description of what this command does */
@@ -1606,6 +1888,11 @@ export declare interface DirectoryTarget {
1606
1888
  validated: boolean;
1607
1889
  }
1608
1890
 
1891
+ /** Template-literal walk of T's object keys, depth ≤ 4 (P1-21). */
1892
+ export declare type DotPath<T, D extends number = 4> = [D] extends [never] ? never : T extends readonly unknown[] ? never : T extends object ? {
1893
+ [K in keyof T & string]: NonNullable<T[K]> extends object ? K | `${K}.${DotPath<NonNullable<T[K]>, Depth[D]>}` : K;
1894
+ }[keyof T & string] : never;
1895
+
1609
1896
  /** A single email attachment, referenced by URL — lua-email fetches the bytes
1610
1897
  * server-side and attaches them, keeping large files off the SDK→API hops. */
1611
1898
  declare interface EmailAttachmentInput {
@@ -1652,21 +1939,31 @@ export declare interface EmailSendInput {
1652
1939
  }
1653
1940
 
1654
1941
  /**
1655
- * Safe environment variable access function.
1656
- * Gets injected at runtime with skill-specific environment variables.
1657
- *
1658
- * Checks process environment variables (.env file)
1659
- *
1660
- * @param key - The environment variable key to retrieve
1661
- * @returns The environment variable value or undefined if not found
1942
+ * Read a sub-agent env key.
1662
1943
  *
1663
- * @example
1664
- * ```typescript
1665
- * const baseUrl = env('BASE_URL');
1666
- * const apiKey = env('API_KEY');
1667
- * ```
1668
- */
1669
- export declare const env: (key: string) => string | undefined;
1944
+ * Workflows (03 §3.1, WF-201): at MODULE TOP LEVEL of a workflow file the
1945
+ * compiler's tier-1 sandbox replaces this with a stub that returns `''` and
1946
+ * records the key into `ManifestWorkflow.envKeys[]`; inside `execute` it is
1947
+ * `ctx.env[key]`. `env.template(KEY)` (Cluster K — B33) returns the
1948
+ * `{ __envRef: KEY }` placeholder legal wherever a `template(...)` binding is —
1949
+ * never a value at construction time — and `lua push` resolves it from the
1950
+ * TARGET agent env into the version's `envOverlay`.
1951
+ */
1952
+ export declare const env: ((key: string, opts?: {
1953
+ manifest?: boolean;
1954
+ }) => string | undefined) & {
1955
+ template: (key: string) => {
1956
+ __envRef: string;
1957
+ };
1958
+ };
1959
+
1960
+ export { EnvRefBinding }
1961
+
1962
+ export declare const eq: <T>(l: TypedRef<T>, r: TypedRef<T> | Literal<T>) => LuaPredicate;
1963
+
1964
+ export declare const exists: (ref: TypedRef<unknown>) => LuaPredicate;
1965
+
1966
+ export declare const falsy: (ref: TypedRef<unknown>) => LuaPredicate;
1670
1967
 
1671
1968
  export declare interface FileMessage {
1672
1969
  type: 'file';
@@ -1680,6 +1977,37 @@ declare type FileMessage_2 = {
1680
1977
  mediaType: string;
1681
1978
  };
1682
1979
 
1980
+ export declare interface ForeachOptions {
1981
+ /** Cluster G (B34): PURE builder lowering — emits `{ type:'mapping', id:'<foreachId>_items', mapConfig:{'': items} }` before the foreach entry. */
1982
+ items?: TypedRef<unknown[]> | {
1983
+ step: string;
1984
+ path: string;
1985
+ } | {
1986
+ initData: true;
1987
+ path?: string;
1988
+ };
1989
+ /** default 4, max 16 */
1990
+ concurrency?: number;
1991
+ /** default 256 — a FAIL-FAST bound at runtime, never a truncation (P0-6). */
1992
+ maxItems?: number;
1993
+ chunk?: {
1994
+ size: number;
1995
+ };
1996
+ rateLimit?: {
1997
+ perSecond?: number;
1998
+ perMinute?: number;
1999
+ };
2000
+ }
2001
+
2002
+ export declare const fromInit: (path: string) => MapDescriptor;
2003
+
2004
+ export declare const fromKnowledge: typeof fromKnowledge_2;
2005
+
2006
+ export declare const fromRequest: (path: string) => MapDescriptor;
2007
+
2008
+ /** path default '' = whole output */
2009
+ export declare const fromStep: (s: LuaWorkflowStep<any, any, any> | string | Array<LuaWorkflowStep<any, any, any> | string>, path?: string) => MapDescriptor;
2010
+
1683
2011
  /**
1684
2012
  * Response from getting custom data entries.
1685
2013
  * Includes pagination information.
@@ -1758,6 +2086,10 @@ declare interface GovernanceConfig {
1758
2086
  serverUrl?: string;
1759
2087
  }
1760
2088
 
2089
+ export declare const gt: (l: TypedRef<number> | number, r: TypedRef<number> | Literal<number> | number) => LuaPredicate;
2090
+
2091
+ export declare const gte: (l: TypedRef<number> | number, r: TypedRef<number> | Literal<number> | number) => LuaPredicate;
2092
+
1761
2093
  /**
1762
2094
  * Function type for resolving headers at runtime.
1763
2095
  * Use env() inside to access agent environment variables.
@@ -1791,6 +2123,13 @@ declare abstract class HttpClient {
1791
2123
  * @private
1792
2124
  */
1793
2125
  private request;
2126
+ /**
2127
+ * Non-2xx classification shared by `request` and `httpStream` (WF-204): 401s become
2128
+ * `AuthenticationError` (ownership vs credential), 403s throw, everything else returns the
2129
+ * `{ success:false, error }` envelope with the server body spread in.
2130
+ * @private
2131
+ */
2132
+ private classifyErrorResponse;
1794
2133
  /**
1795
2134
  * Checks if an HTTP status code is retryable
1796
2135
  * @param statusCode - The HTTP status code (0 for network errors)
@@ -1832,7 +2171,7 @@ declare abstract class HttpClient {
1832
2171
  * @returns Promise resolving to an ApiResponse with typed data
1833
2172
  * @protected
1834
2173
  */
1835
- protected httpPost<T>(url: string, data?: any, headers?: Record<string, string>): Promise<ApiResponse<T>>;
2174
+ protected httpPost<T>(url: string, data?: any, headers?: Record<string, string>, overrides?: RequestOverrides): Promise<ApiResponse<T>>;
1836
2175
  /**
1837
2176
  * Performs one HTTP POST attempt.
1838
2177
  *
@@ -1867,6 +2206,25 @@ declare abstract class HttpClient {
1867
2206
  * @protected
1868
2207
  */
1869
2208
  protected httpPatch<T>(url: string, data?: any, headers?: Record<string, string>): Promise<ApiResponse<T>>;
2209
+ /**
2210
+ * Opens a Server-Sent Events stream (WF-204 — 03 §3.10 `watch`; 09 §9.10 `watchEvents`).
2211
+ *
2212
+ * The ONLY deliberately timeout-free request in the client: an SSE tail lives as long as
2213
+ * the run (the server heartbeats every 15 s). Cancellation is the caller's `signal`.
2214
+ * Non-2xx responses go through the same 401/403 classification as `request` — a 401 is
2215
+ * an `AuthenticationError`, a 403 throws — and every other status resolves the returned
2216
+ * `ApiResponse` with `success:false` (no retry: the caller decides whether to reconnect,
2217
+ * passing `Last-Event-ID` for a resume).
2218
+ *
2219
+ * @param url - relative URL path (appended to baseUrl)
2220
+ * @param headers - headers (auth); `Last-Event-ID` when resuming
2221
+ * @param opts.signal - abort to close the stream
2222
+ * @returns `{ success:true, data: AsyncIterable<SseFrame> }` or the error envelope
2223
+ * @protected
2224
+ */
2225
+ protected httpStream(url: string, headers?: Record<string, string>, opts?: {
2226
+ signal?: AbortSignal;
2227
+ }): Promise<ApiResponse<AsyncIterable<SseFrame>>>;
1870
2228
  }
1871
2229
 
1872
2230
  /**
@@ -1965,6 +2323,10 @@ declare interface InboxPushReceipt {
1965
2323
  reason?: string;
1966
2324
  }
1967
2325
 
2326
+ export declare const init: <T = unknown>(path: string) => TypedRef<T>;
2327
+
2328
+ export declare const inSet: <T extends string | number | boolean | null>(v: TypedRef<T>, set: T[]) => LuaPredicate;
2329
+
1968
2330
  /** HTTP methods the passthrough relay accepts. */
1969
2331
  declare const INTEGRATION_PASSTHROUGH_METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"];
1970
2332
 
@@ -2527,12 +2889,31 @@ declare interface JobVersion {
2527
2889
  metadata?: Record<string, any>;
2528
2890
  }
2529
2891
 
2892
+ export { JsonSchema }
2893
+
2894
+ export { KnowledgeBindingSpec }
2895
+
2530
2896
  export declare interface ListTemplatesOptions {
2531
2897
  page?: number;
2532
2898
  limit?: number;
2533
2899
  search?: string;
2534
2900
  }
2535
2901
 
2902
+ export declare const lit: <const V extends string | number | boolean | null>(v: V) => Literal<V>;
2903
+
2904
+ export { Literal }
2905
+
2906
+ export declare interface LoopOptions {
2907
+ /** default 100 */
2908
+ maxIterations?: number;
2909
+ /** engine timer between iterations, 1..86 400 (B24) */
2910
+ intervalSeconds?: number;
2911
+ }
2912
+
2913
+ export declare const lt: (l: TypedRef<number> | number, r: TypedRef<number> | Literal<number> | number) => LuaPredicate;
2914
+
2915
+ export declare const lte: (l: TypedRef<number> | number, r: TypedRef<number> | Literal<number> | number) => LuaPredicate;
2916
+
2536
2917
  /**
2537
2918
  * Lua Runtime API
2538
2919
  * Access request-level runtime information in your tools, conditions, and processors.
@@ -2594,6 +2975,7 @@ export declare class LuaAgent {
2594
2975
  private readonly webhooks;
2595
2976
  private readonly triggers;
2596
2977
  private readonly jobs;
2978
+ private readonly workflows;
2597
2979
  private readonly preProcessors;
2598
2980
  private readonly postProcessors;
2599
2981
  private readonly mcpServers;
@@ -2632,6 +3014,7 @@ export declare class LuaAgent {
2632
3014
  getWebhooks(): LuaWebhook[];
2633
3015
  getTriggers(): LuaTrigger[];
2634
3016
  getJobs(): LuaJob[];
3017
+ getWorkflows(): LuaWorkflow[];
2635
3018
  getPreProcessors(): PreProcessor[];
2636
3019
  getPostProcessors(): PostProcessor[];
2637
3020
  getMCPServers(): LuaMCPServer[];
@@ -2674,6 +3057,8 @@ export declare interface LuaAgentConfig {
2674
3057
  triggers?: LuaTrigger[];
2675
3058
  /** Array of scheduled jobs */
2676
3059
  jobs?: LuaJob[];
3060
+ /** Array of workflows (createWorkflow / defineWorkflow) — 03 §3.1; resolved by the compiler traverser, dropped from the agent bundle */
3061
+ workflows?: LuaWorkflow[];
2677
3062
  /** Array of preprocessors (run before messages reach the agent) */
2678
3063
  preProcessors?: PreProcessor[];
2679
3064
  /** Array of postprocessors (run after agent generates responses) */
@@ -2998,6 +3383,8 @@ export declare interface LuaJobConfig {
2998
3383
  metadata?: Record<string, any>;
2999
3384
  }
3000
3385
 
3386
+ export { LuaMapConfig }
3387
+
3001
3388
  /**
3002
3389
  * LuaMCPServer class.
3003
3390
  * Defines an MCP (Model Context Protocol) server connection.
@@ -3055,6 +3442,8 @@ export declare class LuaMCPServer {
3055
3442
  */
3056
3443
  export declare type LuaMCPServerConfig = MCPSSEServerConfig | MCPStreamableHttpServerConfig;
3057
3444
 
3445
+ export { LuaPredicate }
3446
+
3058
3447
  /**
3059
3448
  * The entity-independent, bounded Mongo-style filter accepted by Lua APIs.
3060
3449
  * Root `$and`/`$or` branches and nested data fields share this recursive shape;
@@ -3285,7 +3674,7 @@ export declare class LuaTrigger<T = any> {
3285
3674
  readonly inputSchema?: ZodType;
3286
3675
  readonly verify?: (ctx: TriggerContext<T>) => boolean | Promise<boolean>;
3287
3676
  readonly filter?: (ctx: TriggerContext<T>) => boolean | Promise<boolean>;
3288
- readonly transform?: (ctx: TriggerContext<T>) => string | AgentInvocationInput | Promise<string | AgentInvocationInput>;
3677
+ readonly transform?: (ctx: TriggerContext<T>) => string | AgentInvocationInput | TriggerStartWorkflow | Promise<string | AgentInvocationInput | TriggerStartWorkflow>;
3289
3678
  readonly tool?: {
3290
3679
  name: string;
3291
3680
  input?: (ctx: TriggerContext<T>) => Record<string, unknown> | Promise<Record<string, unknown>>;
@@ -3328,7 +3717,7 @@ export declare interface LuaTriggerConfig<T = any> {
3328
3717
  * whose payload is capped at ~50k chars (like a no-code trigger); return a
3329
3718
  * transform to forward larger or hand-picked fields as the message.
3330
3719
  */
3331
- transform?: (ctx: TriggerContext<T>) => string | AgentInvocationInput | Promise<string | AgentInvocationInput>;
3720
+ transform?: (ctx: TriggerContext<T>) => string | AgentInvocationInput | TriggerStartWorkflow | Promise<string | AgentInvocationInput | TriggerStartWorkflow>;
3332
3721
  /**
3333
3722
  * Direct tool binding: after `verify`/`filter` pass, the platform executes
3334
3723
  * this named skill tool DIRECTLY — no chat turn, no LLM, no visible
@@ -3485,14 +3874,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3485
3874
  */
3486
3875
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3487
3876
  }, "strip", z.ZodTypeAny, {
3877
+ provider?: "deepgram" | "elevenlabs";
3488
3878
  options?: Record<string, unknown>;
3489
3879
  kind?: "plugin";
3490
- provider?: "deepgram" | "elevenlabs";
3491
3880
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3492
3881
  }, {
3882
+ provider?: "deepgram" | "elevenlabs";
3493
3883
  options?: Record<string, unknown>;
3494
3884
  kind?: "plugin";
3495
- provider?: "deepgram" | "elevenlabs";
3496
3885
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3497
3886
  }>, z.ZodObject<{
3498
3887
  kind: z.ZodLiteral<"realtime">;
@@ -3505,13 +3894,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3505
3894
  */
3506
3895
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3507
3896
  }, "strip", z.ZodTypeAny, {
3897
+ provider?: "google" | "xai" | "openai";
3508
3898
  options?: Record<string, unknown>;
3509
3899
  kind?: "realtime";
3510
- provider?: "google" | "xai" | "openai";
3511
3900
  }, {
3901
+ provider?: "google" | "xai" | "openai";
3512
3902
  options?: Record<string, unknown>;
3513
3903
  kind?: "realtime";
3514
- provider?: "google" | "xai" | "openai";
3515
3904
  }>]>;
3516
3905
  stt: z.ZodOptional<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
3517
3906
  kind: z.ZodLiteral<"inference">;
@@ -3551,14 +3940,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3551
3940
  */
3552
3941
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3553
3942
  }, "strip", z.ZodTypeAny, {
3943
+ provider?: "deepgram" | "elevenlabs";
3554
3944
  options?: Record<string, unknown>;
3555
3945
  kind?: "plugin";
3556
- provider?: "deepgram" | "elevenlabs";
3557
3946
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3558
3947
  }, {
3948
+ provider?: "deepgram" | "elevenlabs";
3559
3949
  options?: Record<string, unknown>;
3560
3950
  kind?: "plugin";
3561
- provider?: "deepgram" | "elevenlabs";
3562
3951
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3563
3952
  }>, z.ZodObject<{
3564
3953
  kind: z.ZodLiteral<"realtime">;
@@ -3571,13 +3960,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3571
3960
  */
3572
3961
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3573
3962
  }, "strip", z.ZodTypeAny, {
3963
+ provider?: "google" | "xai" | "openai";
3574
3964
  options?: Record<string, unknown>;
3575
3965
  kind?: "realtime";
3576
- provider?: "google" | "xai" | "openai";
3577
3966
  }, {
3967
+ provider?: "google" | "xai" | "openai";
3578
3968
  options?: Record<string, unknown>;
3579
3969
  kind?: "realtime";
3580
- provider?: "google" | "xai" | "openai";
3581
3970
  }>]>>;
3582
3971
  tts: z.ZodOptional<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
3583
3972
  kind: z.ZodLiteral<"inference">;
@@ -3617,14 +4006,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3617
4006
  */
3618
4007
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3619
4008
  }, "strip", z.ZodTypeAny, {
4009
+ provider?: "deepgram" | "elevenlabs";
3620
4010
  options?: Record<string, unknown>;
3621
4011
  kind?: "plugin";
3622
- provider?: "deepgram" | "elevenlabs";
3623
4012
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3624
4013
  }, {
4014
+ provider?: "deepgram" | "elevenlabs";
3625
4015
  options?: Record<string, unknown>;
3626
4016
  kind?: "plugin";
3627
- provider?: "deepgram" | "elevenlabs";
3628
4017
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3629
4018
  }>, z.ZodObject<{
3630
4019
  kind: z.ZodLiteral<"realtime">;
@@ -3637,13 +4026,13 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3637
4026
  */
3638
4027
  options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3639
4028
  }, "strip", z.ZodTypeAny, {
4029
+ provider?: "google" | "xai" | "openai";
3640
4030
  options?: Record<string, unknown>;
3641
4031
  kind?: "realtime";
3642
- provider?: "google" | "xai" | "openai";
3643
4032
  }, {
4033
+ provider?: "google" | "xai" | "openai";
3644
4034
  options?: Record<string, unknown>;
3645
4035
  kind?: "realtime";
3646
- provider?: "google" | "xai" | "openai";
3647
4036
  }>]>>;
3648
4037
  vad: z.ZodOptional<z.ZodString>;
3649
4038
  vadOptions: z.ZodOptional<z.ZodObject<{
@@ -3809,14 +4198,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3809
4198
  kind?: "inference";
3810
4199
  model?: string;
3811
4200
  } | {
4201
+ provider?: "deepgram" | "elevenlabs";
3812
4202
  options?: Record<string, unknown>;
3813
4203
  kind?: "plugin";
3814
- provider?: "deepgram" | "elevenlabs";
3815
4204
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3816
4205
  } | {
4206
+ provider?: "google" | "xai" | "openai";
3817
4207
  options?: Record<string, unknown>;
3818
4208
  kind?: "realtime";
3819
- provider?: "google" | "xai" | "openai";
3820
4209
  };
3821
4210
  volume?: number;
3822
4211
  llm?: {
@@ -3825,14 +4214,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3825
4214
  kind?: "inference";
3826
4215
  model?: string;
3827
4216
  } | {
4217
+ provider?: "deepgram" | "elevenlabs";
3828
4218
  options?: Record<string, unknown>;
3829
4219
  kind?: "plugin";
3830
- provider?: "deepgram" | "elevenlabs";
3831
4220
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3832
4221
  } | {
4222
+ provider?: "google" | "xai" | "openai";
3833
4223
  options?: Record<string, unknown>;
3834
4224
  kind?: "realtime";
3835
- provider?: "google" | "xai" | "openai";
3836
4225
  };
3837
4226
  tts?: {
3838
4227
  voice?: string;
@@ -3840,14 +4229,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3840
4229
  kind?: "inference";
3841
4230
  model?: string;
3842
4231
  } | {
4232
+ provider?: "deepgram" | "elevenlabs";
3843
4233
  options?: Record<string, unknown>;
3844
4234
  kind?: "plugin";
3845
- provider?: "deepgram" | "elevenlabs";
3846
4235
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3847
4236
  } | {
4237
+ provider?: "google" | "xai" | "openai";
3848
4238
  options?: Record<string, unknown>;
3849
4239
  kind?: "realtime";
3850
- provider?: "google" | "xai" | "openai";
3851
4240
  };
3852
4241
  vadOptions?: {
3853
4242
  minSpeechDuration?: number;
@@ -3855,7 +4244,7 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3855
4244
  prefixPaddingDuration?: number;
3856
4245
  activationThreshold?: number;
3857
4246
  };
3858
- turnDetection?: "multilingual" | "english" | "vad" | "stt" | "manual";
4247
+ turnDetection?: "manual" | "multilingual" | "english" | "vad" | "stt";
3859
4248
  greeting?: string;
3860
4249
  maxToolSteps?: number;
3861
4250
  userAwayTimeout?: number;
@@ -3903,14 +4292,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3903
4292
  kind?: "inference";
3904
4293
  model?: string;
3905
4294
  } | {
4295
+ provider?: "deepgram" | "elevenlabs";
3906
4296
  options?: Record<string, unknown>;
3907
4297
  kind?: "plugin";
3908
- provider?: "deepgram" | "elevenlabs";
3909
4298
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3910
4299
  } | {
4300
+ provider?: "google" | "xai" | "openai";
3911
4301
  options?: Record<string, unknown>;
3912
4302
  kind?: "realtime";
3913
- provider?: "google" | "xai" | "openai";
3914
4303
  };
3915
4304
  volume?: number;
3916
4305
  llm?: {
@@ -3919,14 +4308,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3919
4308
  kind?: "inference";
3920
4309
  model?: string;
3921
4310
  } | {
4311
+ provider?: "deepgram" | "elevenlabs";
3922
4312
  options?: Record<string, unknown>;
3923
4313
  kind?: "plugin";
3924
- provider?: "deepgram" | "elevenlabs";
3925
4314
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3926
4315
  } | {
4316
+ provider?: "google" | "xai" | "openai";
3927
4317
  options?: Record<string, unknown>;
3928
4318
  kind?: "realtime";
3929
- provider?: "google" | "xai" | "openai";
3930
4319
  };
3931
4320
  tts?: {
3932
4321
  voice?: string;
@@ -3934,14 +4323,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3934
4323
  kind?: "inference";
3935
4324
  model?: string;
3936
4325
  } | {
4326
+ provider?: "deepgram" | "elevenlabs";
3937
4327
  options?: Record<string, unknown>;
3938
4328
  kind?: "plugin";
3939
- provider?: "deepgram" | "elevenlabs";
3940
4329
  class?: "LLM" | "STT" | "STTv2" | "TTS";
3941
4330
  } | {
4331
+ provider?: "google" | "xai" | "openai";
3942
4332
  options?: Record<string, unknown>;
3943
4333
  kind?: "realtime";
3944
- provider?: "google" | "xai" | "openai";
3945
4334
  };
3946
4335
  vadOptions?: {
3947
4336
  minSpeechDuration?: number;
@@ -3949,7 +4338,7 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3949
4338
  prefixPaddingDuration?: number;
3950
4339
  activationThreshold?: number;
3951
4340
  };
3952
- turnDetection?: "multilingual" | "english" | "vad" | "stt" | "manual";
4341
+ turnDetection?: "manual" | "multilingual" | "english" | "vad" | "stt";
3953
4342
  greeting?: string;
3954
4343
  maxToolSteps?: number;
3955
4344
  userAwayTimeout?: number;
@@ -3997,14 +4386,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
3997
4386
  kind?: "inference";
3998
4387
  model?: string;
3999
4388
  } | {
4389
+ provider?: "deepgram" | "elevenlabs";
4000
4390
  options?: Record<string, unknown>;
4001
4391
  kind?: "plugin";
4002
- provider?: "deepgram" | "elevenlabs";
4003
4392
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4004
4393
  } | {
4394
+ provider?: "google" | "xai" | "openai";
4005
4395
  options?: Record<string, unknown>;
4006
4396
  kind?: "realtime";
4007
- provider?: "google" | "xai" | "openai";
4008
4397
  };
4009
4398
  volume?: number;
4010
4399
  llm?: {
@@ -4013,14 +4402,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4013
4402
  kind?: "inference";
4014
4403
  model?: string;
4015
4404
  } | {
4405
+ provider?: "deepgram" | "elevenlabs";
4016
4406
  options?: Record<string, unknown>;
4017
4407
  kind?: "plugin";
4018
- provider?: "deepgram" | "elevenlabs";
4019
4408
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4020
4409
  } | {
4410
+ provider?: "google" | "xai" | "openai";
4021
4411
  options?: Record<string, unknown>;
4022
4412
  kind?: "realtime";
4023
- provider?: "google" | "xai" | "openai";
4024
4413
  };
4025
4414
  tts?: {
4026
4415
  voice?: string;
@@ -4028,14 +4417,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4028
4417
  kind?: "inference";
4029
4418
  model?: string;
4030
4419
  } | {
4420
+ provider?: "deepgram" | "elevenlabs";
4031
4421
  options?: Record<string, unknown>;
4032
4422
  kind?: "plugin";
4033
- provider?: "deepgram" | "elevenlabs";
4034
4423
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4035
4424
  } | {
4425
+ provider?: "google" | "xai" | "openai";
4036
4426
  options?: Record<string, unknown>;
4037
4427
  kind?: "realtime";
4038
- provider?: "google" | "xai" | "openai";
4039
4428
  };
4040
4429
  vadOptions?: {
4041
4430
  minSpeechDuration?: number;
@@ -4043,7 +4432,7 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4043
4432
  prefixPaddingDuration?: number;
4044
4433
  activationThreshold?: number;
4045
4434
  };
4046
- turnDetection?: "multilingual" | "english" | "vad" | "stt" | "manual";
4435
+ turnDetection?: "manual" | "multilingual" | "english" | "vad" | "stt";
4047
4436
  greeting?: string;
4048
4437
  maxToolSteps?: number;
4049
4438
  userAwayTimeout?: number;
@@ -4091,14 +4480,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4091
4480
  kind?: "inference";
4092
4481
  model?: string;
4093
4482
  } | {
4483
+ provider?: "deepgram" | "elevenlabs";
4094
4484
  options?: Record<string, unknown>;
4095
4485
  kind?: "plugin";
4096
- provider?: "deepgram" | "elevenlabs";
4097
4486
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4098
4487
  } | {
4488
+ provider?: "google" | "xai" | "openai";
4099
4489
  options?: Record<string, unknown>;
4100
4490
  kind?: "realtime";
4101
- provider?: "google" | "xai" | "openai";
4102
4491
  };
4103
4492
  volume?: number;
4104
4493
  llm?: {
@@ -4107,14 +4496,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4107
4496
  kind?: "inference";
4108
4497
  model?: string;
4109
4498
  } | {
4499
+ provider?: "deepgram" | "elevenlabs";
4110
4500
  options?: Record<string, unknown>;
4111
4501
  kind?: "plugin";
4112
- provider?: "deepgram" | "elevenlabs";
4113
4502
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4114
4503
  } | {
4504
+ provider?: "google" | "xai" | "openai";
4115
4505
  options?: Record<string, unknown>;
4116
4506
  kind?: "realtime";
4117
- provider?: "google" | "xai" | "openai";
4118
4507
  };
4119
4508
  tts?: {
4120
4509
  voice?: string;
@@ -4122,14 +4511,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4122
4511
  kind?: "inference";
4123
4512
  model?: string;
4124
4513
  } | {
4514
+ provider?: "deepgram" | "elevenlabs";
4125
4515
  options?: Record<string, unknown>;
4126
4516
  kind?: "plugin";
4127
- provider?: "deepgram" | "elevenlabs";
4128
4517
  class?: "LLM" | "STT" | "STTv2" | "TTS";
4129
4518
  } | {
4519
+ provider?: "google" | "xai" | "openai";
4130
4520
  options?: Record<string, unknown>;
4131
4521
  kind?: "realtime";
4132
- provider?: "google" | "xai" | "openai";
4133
4522
  };
4134
4523
  vadOptions?: {
4135
4524
  minSpeechDuration?: number;
@@ -4137,7 +4526,7 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
4137
4526
  prefixPaddingDuration?: number;
4138
4527
  activationThreshold?: number;
4139
4528
  };
4140
- turnDetection?: "multilingual" | "english" | "vad" | "stt" | "manual";
4529
+ turnDetection?: "manual" | "multilingual" | "english" | "vad" | "stt";
4141
4530
  greeting?: string;
4142
4531
  maxToolSteps?: number;
4143
4532
  userAwayTimeout?: number;
@@ -4492,6 +4881,144 @@ declare interface LuaWebhookEvent {
4492
4881
  timestamp: string;
4493
4882
  }
4494
4883
 
4884
+ export declare class LuaWorkflow {
4885
+ private readonly built;
4886
+ constructor(built: BuiltWorkflow);
4887
+ getName(): string;
4888
+ getConfig(): LuaWorkflowConfig;
4889
+ getSteps(): Record<string, LuaWorkflowStep<any, any, any>>;
4890
+ /** Builder warnings (`map-id-required`, `hitl-duration-defaulted`, `schedule-input-*`) — the compiler prints them. */
4891
+ getBuildWarnings(): LuaWorkflowBuildWarning[];
4892
+ /** Every `env.template(KEY)` placeholder key the graph carries (sorted, deduped) — `ManifestWorkflow.envTemplateKeys`. */
4893
+ getEnvTemplateKeys(): string[];
4894
+ /** `.workflow(id, ref)` targets by name — `ManifestWorkflow.workflowRefs`. */
4895
+ getNestedWorkflowRefs(): Array<{
4896
+ id: string;
4897
+ name: string;
4898
+ }>;
4899
+ /** Pure: no I/O, no env, no time. Called by the compiler in the VM tier and by `lua test`. */
4900
+ __serializeGraph(): SerializedWorkflowGraph;
4901
+ }
4902
+
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';
4904
+
4905
+ export declare interface LuaWorkflowBuilder {
4906
+ then(step: StepRef): this;
4907
+ /** 2..16 arms; output = { [stepId]: output } */
4908
+ parallel(steps: ContainerArm[], opts?: {
4909
+ merge?: WorkflowMergePolicy;
4910
+ }): this;
4911
+ /** all-true arms run (Mastra); exclusive:true ≡ switch() */
4912
+ branch(arms: Array<[LuaPredicate, StepRef]>, opts?: {
4913
+ exclusive?: boolean;
4914
+ }): this;
4915
+ /** first true arm only ⇒ conditional{ exclusive:true, otherwise } */
4916
+ switch(arms: Array<[LuaPredicate, StepRef]>, otherwise?: StepRef): this;
4917
+ foreach(step: ContainerArm, opts?: ForeachOptions): this;
4918
+ dowhile(step: ContainerArm, predicate: LuaPredicate, opts?: LoopOptions): this;
4919
+ dountil(step: ContainerArm, predicate: LuaPredicate, opts?: LoopOptions): this;
4920
+ /** top-level only. `id` is REQUIRED once the workflow has ≥ 2 maps (`map-id-required`). */
4921
+ map(mapping: LuaMapConfig, opts?: {
4922
+ id?: string;
4923
+ }): this;
4924
+ /** literal only; engine-side wait, no lease */
4925
+ sleep(ms: number, opts?: {
4926
+ id?: string;
4927
+ businessHours?: WorkflowBusinessHours;
4928
+ }): this;
4929
+ /** a TemplateBinding lowers to `<id>_at` mapping + `sleepUntil{dateFrom}` (D6-r1) */
4930
+ sleepUntil(iso: string | TemplateBinding, opts?: {
4931
+ id?: string;
4932
+ businessHours?: WorkflowBusinessHours;
4933
+ round?: 'next-open' | 'next-close';
4934
+ }): this;
4935
+ agentStep(id: string, opts: AgentStepOptions): this;
4936
+ /** D25 ephemeral specialist: runs AS THE OWNING AGENT (`agentId:'$self'`) with an additive role block. */
4937
+ specialistStep(id: string, opts: SpecialistStepOptions): this;
4938
+ toolStep(id: string, tool: LuaTool<any>, opts?: ToolStepOptions): this;
4939
+ approval(id: string, opts: ApprovalOptions): this;
4940
+ 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;
4945
+ commit(): LuaWorkflow;
4946
+ }
4947
+
4948
+ export declare class LuaWorkflowBuildError extends Error {
4949
+ readonly code: LuaWorkflowBuildCode;
4950
+ readonly hint?: string | undefined;
4951
+ constructor(code: LuaWorkflowBuildCode, message: string, hint?: string | undefined);
4952
+ }
4953
+
4954
+ export declare interface LuaWorkflowBuildWarning {
4955
+ code: LuaWorkflowBuildCode;
4956
+ message: string;
4957
+ stepId?: string;
4958
+ }
4959
+
4960
+ export declare interface LuaWorkflowConfig {
4961
+ /** /^[a-z][a-z0-9-_]*$/ — server identifier */
4962
+ name: string;
4963
+ description?: string;
4964
+ inputSchema: ZodType;
4965
+ outputSchema?: ZodType;
4966
+ /** types `ctx.state`; ≤ 64KB at runtime */
4967
+ stateSchema?: ZodType;
4968
+ /** 'forbid' = jobs-style overlap guard per workflow (D21-r1) — every start path gets 409 `RUNS_IN_FLIGHT`. */
4969
+ concurrencyPolicy?: 'allow' | 'forbid';
4970
+ /** Who may READ this workflow's run outputs beyond `workflows:read-outputs` holders (B44). Envelope member outside `graphHash`. */
4971
+ 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
+ };
4978
+ /** verbatim LuaJob union (D12) → Job{kind:'workflow'} on publish */
4979
+ schedule?: JobSchedule;
4980
+ backfillOnEnable?: {
4981
+ maxOccurrences?: number;
4982
+ };
4983
+ /** Literal JSON passed as run input on every scheduled fire; must validate against `inputSchema` (P0-5e). */
4984
+ scheduleInput?: Record<string, unknown>;
4985
+ goal?: WorkflowGoalEnvelope;
4986
+ /** NEVER set by hand — the compiler derives it from the source file. */
4987
+ form?: 'graph' | 'script';
4988
+ workspace?: WorkspaceSpec;
4989
+ }
4990
+
4991
+ export declare interface LuaWorkflowStep<TIn extends ZodType = ZodType, TOut extends ZodType = ZodType, TResume extends ZodType = ZodType> {
4992
+ /** /^[a-z][a-zA-Z0-9_-]{0,63}$/ — unique per workflow; `[`, `#`, `.`, `:` reserved. */
4993
+ id: string;
4994
+ description?: string;
4995
+ inputSchema: TIn;
4996
+ outputSchema: TOut;
4997
+ suspendSchema?: ZodType;
4998
+ resumeSchema?: TResume;
4999
+ execute: (ctx: WorkflowStepContext<z.infer<TIn>, z.infer<TResume>>) => Promise<z.infer<TOut>>;
5000
+ /** 1..600 (D19); default 300 — on `tier:'job'` 1..86 400, default 3600. */
5001
+ timeoutSeconds?: number;
5002
+ /** Run this step as a k8s Job (hours tier). Implied by `workspace`. */
5003
+ tier?: 'job';
5004
+ workspace?: WorkflowStepWorkspace;
5005
+ jobResources?: 'small' | 'medium' | 'large';
5006
+ jobTools?: WorkflowJobToolId[];
5007
+ /** default { maxAttempts: 1 } */
5008
+ retry?: RetryPolicy;
5009
+ /** default 'none'; 'external' ⇒ park on platform-fault reclaim. */
5010
+ sideEffects?: 'none' | 'external';
5011
+ /** What the FINAL failure of this step does to the run (default 'fail'). */
5012
+ onError?: 'fail' | 'continue' | 'park';
5013
+ requiredConnections?: string[];
5014
+ /** Deadline for a `ctx.suspend()` suspension; default 168, max 720. */
5015
+ resumeTimeoutHours?: number;
5016
+ businessHours?: WorkflowBusinessHours;
5017
+ onSuspendTimeout?: 'fail' | 'cancel-run';
5018
+ }
5019
+
5020
+ export { MapDescriptor }
5021
+
4495
5022
  /**
4496
5023
  * Base configuration for all MCP servers.
4497
5024
  */
@@ -4603,6 +5130,16 @@ export declare type MCPTransport = 'sse' | 'streamable-http';
4603
5130
 
4604
5131
  declare type Message = TextMessage_2 | ImageMessage_2 | FileMessage_2;
4605
5132
 
5133
+ export declare const ne: <T>(l: TypedRef<T>, r: TypedRef<T> | Literal<T>) => LuaPredicate;
5134
+
5135
+ export declare const not: (arg: LuaPredicate) => LuaPredicate;
5136
+
5137
+ export declare const notExists: (ref: TypedRef<unknown>) => LuaPredicate;
5138
+
5139
+ export declare const notIn: <T extends string | number | boolean | null>(v: TypedRef<T>, set: T[]) => LuaPredicate;
5140
+
5141
+ export declare const or: (...args: LuaPredicate[]) => LuaPredicate;
5142
+
4606
5143
  /**
4607
5144
  * Order API contract.
4608
5145
  * Defines operations for managing orders.
@@ -4855,6 +5392,11 @@ declare interface Pagination {
4855
5392
  prevPage: number | null;
4856
5393
  }
4857
5394
 
5395
+ export { PathOrLiteral }
5396
+
5397
+ /** P split on '.' walked into T; `unknown` past depth 4 or through an index. */
5398
+ export declare type PathValue<T, P extends string> = P extends `${infer H}.${infer R}` ? H extends keyof T ? PathValue<NonNullable<T[H]>, R> : unknown : P extends keyof T ? T[P] : unknown;
5399
+
4858
5400
  /**
4859
5401
  * Polymorphic shape used by `LuaAgent.persona`. String form is the legacy
4860
5402
  * single-channel persona; object form lets the customer split prose per
@@ -5464,6 +6006,8 @@ declare const REASONING_EFFORT_VALUES: readonly ["off", "minimal", "low", "mediu
5464
6006
 
5465
6007
  declare type ReasoningEffort = (typeof REASONING_EFFORT_VALUES)[number];
5466
6008
 
6009
+ export declare type ReplyChannel = 'whatsapp' | 'sms' | 'email' | 'webchat' | 'slack';
6010
+
5467
6011
  declare interface RequestCredential {
5468
6012
  readonly descriptor: RequestCredentialDescriptor;
5469
6013
  bearer(): Promise<string>;
@@ -5480,6 +6024,47 @@ declare type RequestCredentialDescriptor = {
5480
6024
 
5481
6025
  declare type RequestCredentialInput = string | RequestCredential;
5482
6026
 
6027
+ /**
6028
+ * Optional per-request overrides (WF-202, 03 §3.7 client-deadline rule). Today only
6029
+ * `timeoutMs`: `WorkflowApi.startRun` long-polls with `waitSeconds ≤ 55` and raises
6030
+ * its deadline to `(waitSeconds + 10) s` so the 30 s default abort never races the
6031
+ * server. Every other call site is untouched (undefined ⇒ the 30 s default).
6032
+ */
6033
+ declare interface RequestOverrides {
6034
+ timeoutMs?: number;
6035
+ }
6036
+
6037
+ declare type ResumeStepResult = {
6038
+ resumed: true;
6039
+ runStatus: WorkflowRunStatus;
6040
+ } | {
6041
+ resumed: false;
6042
+ reason: 'already_resumed';
6043
+ recorded: {
6044
+ at: number;
6045
+ by?: {
6046
+ kind: string;
6047
+ id?: string;
6048
+ };
6049
+ };
6050
+ runStatus: WorkflowRunStatus;
6051
+ };
6052
+
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
+ }
6062
+
6063
+ export declare const rows: (s: LuaWorkflowStep<any, any, any> | string, path: string, page: {
6064
+ offset: number;
6065
+ limit: number;
6066
+ }) => MapDescriptor;
6067
+
5483
6068
  /**
5484
6069
  * Additive field on primitive publish responses. When the agent is under
5485
6070
  * versioning the server performs a scoped promote and returns the newly
@@ -5531,6 +6116,18 @@ export declare interface SendTemplateValues {
5531
6116
  buttons?: SendTemplateButtonValue[];
5532
6117
  }
5533
6118
 
6119
+ export { SerializedWorkflowGraph }
6120
+
6121
+ /** R14 — 202 `{ accepted:true, signalId, consumed, stepId? }` · 200 `{ accepted:true, duplicate:true }` · 202 `{ accepted:false, reason }`. */
6122
+ declare interface SignalRunResult {
6123
+ accepted: boolean;
6124
+ signalId?: string;
6125
+ consumed?: boolean;
6126
+ stepId?: string;
6127
+ duplicate?: boolean;
6128
+ reason?: string;
6129
+ }
6130
+
5534
6131
  /**
5535
6132
  * Same shape as `PersonaText`, exported separately because skill `context`
5536
6133
  * and agent `persona` play different semantic roles. Sharing the structural
@@ -5542,6 +6139,77 @@ declare type SkillContextText = string | {
5542
6139
  text?: string;
5543
6140
  };
5544
6141
 
6142
+ export declare interface SpecialistStepOptions {
6143
+ role: WorkflowSpecialistRole | {
6144
+ ref: string;
6145
+ };
6146
+ prompt: TemplateLike;
6147
+ outputSchema?: ZodType;
6148
+ model?: string;
6149
+ toolScope?: AgentToolScope;
6150
+ timeoutSeconds?: number;
6151
+ retry?: RetryPolicy;
6152
+ onError?: 'fail' | 'continue' | 'park';
6153
+ requiredConnections?: string[];
6154
+ }
6155
+
6156
+ /** One parsed SSE frame (`id:` / `event:` / `data:` — `data` JSON-parsed when it parses, else the raw string). */
6157
+ declare interface SseFrame {
6158
+ id?: string;
6159
+ event: string;
6160
+ data: unknown;
6161
+ }
6162
+
6163
+ /** R8 — 202 `{ runId, status:'queued'|'gated', watchHint, idempotentReplay? }`, or 200 the run detail when `waitSeconds` elapsed on a terminal/suspended run. */
6164
+ declare interface StartWorkflowRunResult {
6165
+ runId: string;
6166
+ status: WorkflowRunStatus;
6167
+ watchHint?: string;
6168
+ idempotentReplay?: boolean;
6169
+ output?: unknown;
6170
+ }
6171
+
6172
+ export declare const state: <T = unknown>(path: string) => TypedRef<T>;
6173
+
6174
+ /** `step(x).path('confidence')` is `TypedRef<number>` when `x.outputSchema` says so; a string id yields `TypedRef<unknown>`. */
6175
+ export declare function step<TOut extends ZodType>(s: LuaWorkflowStep<any, TOut, any>): StepPathRef<z.infer<TOut>>;
6176
+
6177
+ export declare function step(id: string): {
6178
+ path(p: string): TypedRef<unknown>;
6179
+ };
6180
+
6181
+ /** Typed string ref for `agentStep`/`toolStep` ids: `stepOf<typeof angle>('techAngle').path('confidence')`. */
6182
+ export declare function stepOf<TOut extends ZodType>(id: string): StepPathRef<z.infer<TOut>>;
6183
+
6184
+ export declare interface StepPathRef<TOut> {
6185
+ path<P extends DotPath<TOut>>(p: P): TypedRef<PathValue<TOut, P>>;
6186
+ }
6187
+
6188
+ /** An inline step object, or a string naming an entry declared by an `agentStep`/`specialistStep`/`toolStep`/`map` call in the same chain (03 §3.2.0). */
6189
+ export declare type StepRef = LuaWorkflowStep<any, any, any> | string;
6190
+
6191
+ /**
6192
+ * Why an unattended run could not finish, reported by the agent itself instead
6193
+ * of being guessed from its prose. The platform — not the agent — writes every
6194
+ * user-facing string from this; `whatWouldUnblock` and `detail` are agent text
6195
+ * and never reach a headline, preview, push body or email subject.
6196
+ */
6197
+ declare const TASK_RUN_BLOCKER_KINDS: readonly ["missing_connection", "resource_not_found", "needs_input", "permission_denied", "other"];
6198
+
6199
+ declare interface TaskRunBlocker {
6200
+ kind: TaskRunBlockerKind;
6201
+ /** Catalog slug when known ('googlemail', 'asana'). Never a guess. */
6202
+ integrationType?: string;
6203
+ /** What it was reaching for, in the user's words ('the agent-all-west repo'). */
6204
+ resourceLabel?: string;
6205
+ /** One sentence, the agent's own: what would make this run work next time. */
6206
+ whatWouldUnblock: string;
6207
+ /** Longer technical account. Expandable detail only — never a headline. */
6208
+ detail?: string;
6209
+ }
6210
+
6211
+ declare type TaskRunBlockerKind = (typeof TASK_RUN_BLOCKER_KINDS)[number];
6212
+
5545
6213
  export declare const Team: TeamApi;
5546
6214
 
5547
6215
  /**
@@ -5569,6 +6237,14 @@ export declare interface TeamApi {
5569
6237
  findMember(name: string): Promise<DirectoryResolveResult>;
5570
6238
  }
5571
6239
 
6240
+ /** placeholders: ${initData.*} ${stepResults.<id>.*} ${state.*} */
6241
+ export declare const template: (s: string) => TemplateBinding;
6242
+
6243
+ export { TemplateBinding }
6244
+
6245
+ /** A prompt / literal slot: a string, a `template(...)` binding, or an `env.template(KEY)` placeholder (B33). */
6246
+ export declare type TemplateLike = string | TemplateBinding | EnvRefBinding;
6247
+
5572
6248
  /**
5573
6249
  * Templates API
5574
6250
  *
@@ -5724,15 +6400,15 @@ export declare enum ToolFlag {
5724
6400
  DISALLOW_INTERRUPTION = "disallow_interruption"
5725
6401
  }
5726
6402
 
5727
- /**
5728
- * Context delivered to a trigger's verify / filter / transform slots.
5729
- *
5730
- * Unlike a webhook event, `rawBody` carries the EXACT unparsed request bytes
5731
- * (utf8) — HMAC signature schemes (Stripe `t=…,v1=…`, GitHub `sha256=…`, Slack
5732
- * `v0:…`) are computed over the wire bytes, which `JSON.stringify(body)` does
5733
- * not reproduce. `headers` keys arrive lowercased (Express), e.g.
5734
- * `ctx.headers['x-hub-signature-256']`.
5735
- */
6403
+ export declare interface ToolStepOptions {
6404
+ input?: LuaMapConfig;
6405
+ timeoutSeconds?: number;
6406
+ retry?: RetryPolicy;
6407
+ sideEffects?: 'none' | 'external';
6408
+ onError?: 'fail' | 'continue' | 'park';
6409
+ requiredConnections?: string[];
6410
+ }
6411
+
5736
6412
  export declare interface TriggerContext<T = any> {
5737
6413
  /** Parsed request body (typed by `inputSchema` when provided). */
5738
6414
  body: T;
@@ -5748,6 +6424,39 @@ export declare interface TriggerContext<T = any> {
5748
6424
  source: string;
5749
6425
  }
5750
6426
 
6427
+ /**
6428
+ * Context delivered to a trigger's verify / filter / transform slots.
6429
+ *
6430
+ * Unlike a webhook event, `rawBody` carries the EXACT unparsed request bytes
6431
+ * (utf8) — HMAC signature schemes (Stripe `t=…,v1=…`, GitHub `sha256=…`, Slack
6432
+ * `v0:…`) are computed over the wire bytes, which `JSON.stringify(body)` does
6433
+ * not reproduce. `headers` keys arrive lowercased (Express), e.g.
6434
+ * `ctx.headers['x-hub-signature-256']`.
6435
+ */
6436
+ /**
6437
+ * `transform` may start a workflow run instead of a chat turn (03 §3.7 / 07 — WF-205):
6438
+ * `{ startWorkflow: { name, input?, idempotencyKey?, correlationKey?, tags? } }`.
6439
+ * `name` is the agent-local workflow name; `correlationKey` accepts a literal or a
6440
+ * `'${input.<field>}'` template the trigger fills.
6441
+ */
6442
+ declare interface TriggerStartWorkflow {
6443
+ startWorkflow: {
6444
+ name: string;
6445
+ input?: unknown;
6446
+ idempotencyKey?: string;
6447
+ correlationKey?: string;
6448
+ tags?: string[];
6449
+ replyTo?: {
6450
+ channel: string;
6451
+ threadId: string;
6452
+ };
6453
+ };
6454
+ }
6455
+
6456
+ export declare const truthy: (ref: TypedRef<unknown>) => LuaPredicate;
6457
+
6458
+ export { TypedRef }
6459
+
5751
6460
  /**
5752
6461
  * Response from updating custom data entry.
5753
6462
  */
@@ -5967,6 +6676,8 @@ export declare interface UserLookupOptions {
5967
6676
  phone?: string;
5968
6677
  }
5969
6678
 
6679
+ export declare const value: (v: unknown) => MapDescriptor;
6680
+
5970
6681
  export declare const Voice: VoiceApi;
5971
6682
 
5972
6683
  /**
@@ -6145,6 +6856,17 @@ declare interface VoiceSessionOutput {
6145
6856
  agentName: string;
6146
6857
  }
6147
6858
 
6859
+ export declare interface WaitForSignalOptions {
6860
+ signal: string;
6861
+ schema?: ZodType;
6862
+ timeoutHours?: number | TemplateBinding;
6863
+ /** default 'fail'; 'continue' ⇒ output {received:false,timedOut:true} */
6864
+ onTimeout?: 'fail' | 'continue';
6865
+ businessHours?: WorkflowBusinessHours;
6866
+ /** default ['webhook','api','user'] */
6867
+ acceptedSources?: Array<'webhook' | 'api' | 'user' | 'agent'>;
6868
+ }
6869
+
6148
6870
  /**
6149
6871
  * Webhook request information from channel integrations.
6150
6872
  * Contains the raw webhook payload from the channel provider.
@@ -6268,4 +6990,390 @@ declare interface WhatsAppTemplateUrlButton {
6268
6990
  example?: string | string[];
6269
6991
  }
6270
6992
 
6993
+ export declare type WorkflowApproverSpec = 'creator' | 'org-admins' | {
6994
+ users: string[] | TemplateBinding;
6995
+ } | {
6996
+ role: string | TemplateBinding | MapDescriptor;
6997
+ } | {
6998
+ group: string | TemplateBinding;
6999
+ } | {
7000
+ governance: {
7001
+ policyId: string;
7002
+ };
7003
+ };
7004
+
7005
+ export declare interface WorkflowArtefactMeta {
7006
+ artefactId: string;
7007
+ name: string;
7008
+ contentType: string;
7009
+ bytes: number;
7010
+ kind: 'file' | 'dataset' | 'image' | 'document';
7011
+ datasetSchema?: JsonSchema;
7012
+ rowCount?: number;
7013
+ producer: {
7014
+ stepId: string;
7015
+ attempt: number;
7016
+ source: 'turn' | 'ctx' | 'input';
7017
+ };
7018
+ previewCdnRef?: string;
7019
+ title?: string;
7020
+ source?: {
7021
+ kind: 'step' | 'input' | 'url' | 'connection' | 'upload';
7022
+ ref?: string;
7023
+ };
7024
+ }
7025
+
7026
+ export declare interface WorkflowBusinessHours {
7027
+ tz: string;
7028
+ calendar?: 'mon-fri' | {
7029
+ days: number[];
7030
+ start: string;
7031
+ end: string;
7032
+ holidays?: string[];
7033
+ };
7034
+ }
7035
+
7036
+ export declare interface WorkflowFourEyes {
7037
+ edit: WorkflowApproverSpec;
7038
+ approve: WorkflowApproverSpec;
7039
+ }
7040
+
7041
+ export declare interface WorkflowGoalEnvelope {
7042
+ objective: string;
7043
+ judge: {
7044
+ agentId: string | '$self';
7045
+ role?: WorkflowSpecialistRole;
7046
+ schema: ZodType;
7047
+ };
7048
+ cadence: JobSchedule[];
7049
+ maxRuns: number;
7050
+ budget?: LuaWorkflowConfig['budget'];
7051
+ maxTotalCredits?: number;
7052
+ initialState?: Record<string, unknown>;
7053
+ }
7054
+
7055
+ export declare type WorkflowJobHarness = 'claude-code' | 'generic';
7056
+
7057
+ export declare type WorkflowJobToolId = 'shell' | 'read' | 'write' | 'edit' | 'glob' | 'grep' | 'git' | 'gh' | 'fetch';
7058
+
7059
+ export declare interface WorkflowMergePolicy {
7060
+ strategy: 'rebase' | 'merge';
7061
+ onConflict: 'fail' | 'agent';
7062
+ }
7063
+
7064
+ export declare interface WorkflowOutputVisibility {
7065
+ roles: string[];
7066
+ users?: string[];
7067
+ ownerBypass?: boolean;
7068
+ }
7069
+
7070
+ /** Matches WorkflowRunDto (R4 `fields:'summary'` — outputs are never inlined here). */
7071
+ declare interface WorkflowRun {
7072
+ id: string;
7073
+ workflowId: string;
7074
+ workflowVersionId: string;
7075
+ agentId: string;
7076
+ orgId: string;
7077
+ status: WorkflowRunStatus;
7078
+ trigger: 'chat' | 'sdk' | 'api' | 'schedule' | 'webhook' | 'template' | 'workflow' | 'device';
7079
+ graphHash: string;
7080
+ lineageId?: string;
7081
+ parentRunId?: string;
7082
+ correlationKey?: string;
7083
+ tags?: string[];
7084
+ gate?: {
7085
+ kind: string;
7086
+ reason?: string;
7087
+ since?: string;
7088
+ };
7089
+ failureReason?: string;
7090
+ restricted?: boolean;
7091
+ output?: unknown;
7092
+ createdAt: string;
7093
+ startedAt?: string;
7094
+ completedAt?: string;
7095
+ updatedAt: string;
7096
+ }
7097
+
7098
+ /** §02 §2.4 run statuses (one union across every section). */
7099
+ declare type WorkflowRunStatus = 'queued' | 'running' | 'cancellation_requested' | 'gated' | 'suspended' | 'waiting' | 'completed' | 'failed' | 'cancelled' | 'abandoned' | 'timed_out';
7100
+
7101
+ export declare type WorkflowRunTrigger = 'chat' | 'sdk' | 'api' | 'schedule' | 'webhook' | 'template' | 'workflow' | 'device';
7102
+
7103
+ /**
7104
+ * @example
7105
+ * ```typescript
7106
+ * const { runId, status } = await Workflows.start('outreach', { leads }, { idempotencyKey: `outreach:${batchId}` });
7107
+ * const run = await Workflows.get(runId);
7108
+ * await Workflows.signal(runId, 'review', { approved: true });
7109
+ * ```
7110
+ */
7111
+ export declare const Workflows: WorkflowsApi;
7112
+
7113
+ /**
7114
+ * Workflows API — start, inspect and steer workflow runs from tools, jobs, webhooks,
7115
+ * triggers, other workflows' code steps and scripts.
7116
+ *
7117
+ * - `start` is ALWAYS fire-and-return: it never awaits execution. `waitSeconds` (≤ 55) is
7118
+ * a server long-poll that returns early terminal state when the run finishes inside the
7119
+ * window — it changes the response, never the execution model. From a code step,
7120
+ * `start` creates a DETACHED run; use the `workflow()` node to wait on a nested run.
7121
+ * - A `concurrencyPolicy:'forbid'` workflow with a run in flight throws
7122
+ * `WorkflowApiError{ code:'RUNS_IN_FLIGHT', blockingRunId }` — never a 429, never a gate.
7123
+ * - `status:'gated'` from `start` means the run holds no org slot (quota/billing/consent).
7124
+ * - `nameOrId` resolves the agent-local `workflow.name` first, then a workflow id.
7125
+ * - `get`/`list` honour output ACLs: a restricted run comes back with `restricted:true`
7126
+ * and no `output` — never an error.
7127
+ *
7128
+ * `startBatch`, `signalByKey`, `raiseBudget`, `setGoal` and `goals.*` are part of the
7129
+ * frozen member list and throw `WORKFLOWS_API_UNAVAILABLE` until their routes ship.
7130
+ */
7131
+ export declare interface WorkflowsApi {
7132
+ start(nameOrId: string, input?: unknown, opts?: {
7133
+ idempotencyKey?: string;
7134
+ budget?: {
7135
+ maxCredits?: number;
7136
+ maxSteps?: number;
7137
+ maxDurationSeconds?: number;
7138
+ };
7139
+ waitSeconds?: number;
7140
+ initialState?: Record<string, unknown>;
7141
+ correlationKey?: string;
7142
+ tags?: string[];
7143
+ replyTo?: {
7144
+ channel: string;
7145
+ threadId: string;
7146
+ };
7147
+ onBehalfOf?: {
7148
+ userId: string;
7149
+ };
7150
+ workflowVersionId?: string;
7151
+ }): Promise<StartWorkflowRunResult>;
7152
+ get(runId: string): Promise<WorkflowRun>;
7153
+ list(opts?: {
7154
+ limit?: number;
7155
+ status?: WorkflowRunStatus | string;
7156
+ workflow?: string;
7157
+ correlationKey?: string;
7158
+ tags?: string[];
7159
+ sort?: string;
7160
+ }): Promise<WorkflowRun[]>;
7161
+ cancel(runId: string, opts?: {
7162
+ mode?: 'request' | 'force';
7163
+ reason?: string;
7164
+ }): Promise<CancelRunVerdict>;
7165
+ resume(runId: string, stepId: string, resumeData: unknown): Promise<ResumeStepResult>;
7166
+ signal(runId: string, name: string, payload?: unknown, opts?: {
7167
+ dedupeKey?: string;
7168
+ }): Promise<SignalRunResult>;
7169
+ signalByKey(nameOrId: string, correlationKey: string, name: string, payload?: unknown, opts?: {
7170
+ dedupeKey?: string;
7171
+ allowMultiple?: boolean;
7172
+ }): Promise<{
7173
+ runIds: string[];
7174
+ delivered: number;
7175
+ }>;
7176
+ startBatch(nameOrId: string, items: Array<{
7177
+ input: unknown;
7178
+ idempotencyKey: string;
7179
+ budget?: {
7180
+ maxCredits?: number;
7181
+ maxSteps?: number;
7182
+ maxDurationSeconds?: number;
7183
+ };
7184
+ tags?: string[];
7185
+ correlationKey?: string;
7186
+ initialState?: Record<string, unknown>;
7187
+ }>, opts?: {
7188
+ mode?: 'reject' | 'gate';
7189
+ budget?: {
7190
+ maxCredits?: number;
7191
+ maxSteps?: number;
7192
+ maxDurationSeconds?: number;
7193
+ };
7194
+ }): Promise<{
7195
+ batchId: string;
7196
+ accepted: number;
7197
+ items: Array<{
7198
+ idempotencyKey: string;
7199
+ runId?: string;
7200
+ status: 'queued' | 'gated' | 'replayed' | 'rejected';
7201
+ code?: string;
7202
+ }>;
7203
+ }>;
7204
+ raiseBudget(runId: string, patch: {
7205
+ maxCredits?: number;
7206
+ maxSteps?: number;
7207
+ maxJobSeconds?: number;
7208
+ maxDurationSeconds?: number;
7209
+ note?: string;
7210
+ }): Promise<{
7211
+ raised: true;
7212
+ budget: Record<string, number>;
7213
+ runStatus: WorkflowRunStatus;
7214
+ resumed: boolean;
7215
+ } | {
7216
+ raised: false;
7217
+ reason: 'already_raised';
7218
+ }>;
7219
+ setGoal(agentId: string, goal: Record<string, unknown>): Promise<Record<string, unknown>>;
7220
+ goals: {
7221
+ list(agentId: string, opts?: {
7222
+ status?: 'active' | 'paused' | 'done' | 'closed';
7223
+ workflowId?: string;
7224
+ }): Promise<Record<string, unknown>[]>;
7225
+ get(agentId: string, goalId: string): Promise<Record<string, unknown>>;
7226
+ pause(agentId: string, goalId: string): Promise<Record<string, unknown>>;
7227
+ resume(agentId: string, goalId: string): Promise<Record<string, unknown>>;
7228
+ close(agentId: string, goalId: string, opts?: {
7229
+ note?: string;
7230
+ }): Promise<Record<string, unknown>>;
7231
+ };
7232
+ }
7233
+
7234
+ export declare interface WorkflowSpecialistRole {
7235
+ name: string;
7236
+ instructions: string;
7237
+ tools: string[];
7238
+ }
7239
+
7240
+ export declare interface WorkflowStepContext<TIn = unknown, TResume = unknown, TState = Record<string, unknown>> {
7241
+ runId: string;
7242
+ workflowId: string;
7243
+ workflowVersionId: string;
7244
+ stepId: string;
7245
+ attempt: number;
7246
+ /** `${lineageId}:${stepId}` — stable across retries, resumes, `retry-step` AND repair runs. THE key for side-effect dedup. */
7247
+ occurrenceId: string;
7248
+ /** The run's recovery lineage: the first run's id in a repair chain; `=== runId` for a non-repair run. */
7249
+ lineageId: string;
7250
+ /** Resolved bindings snapshot (mapping descriptors applied by the advancer). Plain JSON. */
7251
+ inputData: TIn;
7252
+ /** Present only when re-invoked after resume. `execute` RE-RUNS FROM THE TOP (Mastra semantics). */
7253
+ resumeData?: TResume;
7254
+ /** What the prior invocation passed to `suspend()`. */
7255
+ suspendData?: unknown;
7256
+ getInitData<T = unknown>(): T;
7257
+ /** Output of an UPSTREAM step. Throws `WorkflowStepResultError{ code:'STEP_RESULT_NOT_ANCESTOR' }` for a non-ancestor. */
7258
+ getStepResult<T = unknown>(stepId: string): T;
7259
+ /** Run-scoped KV, ledger-backed, ≤ 64KB total. `set` is durable when the step terminalizes. */
7260
+ state: {
7261
+ get<K extends keyof TState>(k: K): TState[K] | undefined;
7262
+ set<K extends keyof TState>(k: K, v: TState[K]): Promise<void>;
7263
+ };
7264
+ /** Terminal for this invocation → step `suspended` kind:'input'. Never returns. */
7265
+ suspend(payload: unknown): Promise<never>;
7266
+ /** Early successful exit with `result` as the step output. Never returns. */
7267
+ bail<T>(result: T): never;
7268
+ /** Early successful exit for the WHOLE RUN (Cluster G, B8). Never returns. */
7269
+ bailRun<T>(output: T): never;
7270
+ /** → `step.progress` event (≤ 1000 per attempt; 1KB each). */
7271
+ log(message: string): void;
7272
+ /** Aborts on run cancel and on the sandbox wall. */
7273
+ signal: AbortSignal;
7274
+ /** Sub-agent env, exactly as jobs receive it. */
7275
+ env: Record<string, string>;
7276
+ /** EXACTLY-ONCE effect keyed on `{occurrenceId, key}` (P1-18). Claim → run `fn` → settle. */
7277
+ once<T>(key: string, fn: () => Promise<T>): Promise<T>;
7278
+ /** Job-tier steps only: the mounted run workspace. */
7279
+ workspace?: {
7280
+ path: string;
7281
+ mount: 'rw' | 'ro';
7282
+ branch?: string;
7283
+ baseSha?: string;
7284
+ arm?: string;
7285
+ backend?: WorkflowWorkspaceBackend;
7286
+ };
7287
+ /** The run artefact store (P1-8). */
7288
+ artefacts: {
7289
+ put(name: string, data: Uint8Array | string | ReadableStream, opts: {
7290
+ contentType: string;
7291
+ kind?: 'file' | 'dataset' | 'image' | 'document';
7292
+ datasetSchema?: JsonSchema;
7293
+ title?: string;
7294
+ source?: {
7295
+ kind: 'step' | 'input' | 'url' | 'connection' | 'upload';
7296
+ ref?: string;
7297
+ };
7298
+ }): Promise<{
7299
+ artefactId: string;
7300
+ }>;
7301
+ get(artefactId: string): Promise<{
7302
+ url: string;
7303
+ meta: WorkflowArtefactMeta;
7304
+ stream(opts?: {
7305
+ range?: {
7306
+ start: number;
7307
+ end?: number;
7308
+ };
7309
+ }): Promise<ReadableStream>;
7310
+ rows(page: {
7311
+ offset: number;
7312
+ limit: number;
7313
+ }): Promise<{
7314
+ rows: unknown[];
7315
+ rowCount: number;
7316
+ nextOffset?: number;
7317
+ }>;
7318
+ }>;
7319
+ list(): Promise<WorkflowArtefactMeta[]>;
7320
+ };
7321
+ /** Stamped by the executor for observability; read-only. */
7322
+ runtime: {
7323
+ trigger: WorkflowRunTrigger;
7324
+ parentRunId?: string;
7325
+ agentVersion?: number;
7326
+ traceparent?: string;
7327
+ correlationKey?: string;
7328
+ tags?: string[];
7329
+ principalKind: 'user' | 'service' | 'customer';
7330
+ replyTo?: {
7331
+ channel: ReplyChannel;
7332
+ threadId: string;
7333
+ };
7334
+ };
7335
+ }
7336
+
7337
+ /** Thrown by `ctx.getStepResult` for a non-ancestor / unknown id — never `undefined` (03 §3.1). */
7338
+ export declare interface WorkflowStepResultError extends Error {
7339
+ code: 'STEP_RESULT_NOT_ANCESTOR';
7340
+ stepId: string;
7341
+ }
7342
+
7343
+ export declare interface WorkflowStepWorkspace {
7344
+ mount: 'rw' | 'ro';
7345
+ isolation?: 'shared' | 'worktree';
7346
+ }
7347
+
7348
+ export declare interface WorkflowSuspendOnTimeout {
7349
+ timeoutHours: number | TemplateBinding;
7350
+ }
7351
+
7352
+ export declare type WorkflowSuspendTimeoutChain = WorkflowSuspendTimeoutChainMember | WorkflowSuspendTimeoutChainMember[];
7353
+
7354
+ export declare type WorkflowSuspendTimeoutChainMember = 'deny' | 'cancel-run' | 'fail' | 'continue' | {
7355
+ escalateTo: WorkflowApproverSpec;
7356
+ timeoutHours: number;
7357
+ };
7358
+
7359
+ export declare type WorkflowWorkspaceBackend = 'ebs' | 'efs' | 's3';
7360
+
7361
+ export declare type WorkspaceSpec = {
7362
+ kind: 'git';
7363
+ repo: string | TemplateBinding;
7364
+ ref?: string | TemplateBinding;
7365
+ credentialsRef?: string;
7366
+ sizeGb?: number;
7367
+ ttlHours?: number;
7368
+ verify?: string;
7369
+ keepArtefacts?: boolean;
7370
+ backend?: WorkflowWorkspaceBackend;
7371
+ } | {
7372
+ kind: 'empty';
7373
+ sizeGb?: number;
7374
+ ttlHours?: number;
7375
+ keepArtefacts?: boolean;
7376
+ backend?: WorkflowWorkspaceBackend;
7377
+ };
7378
+
6271
7379
  export { }