lua-cli 3.9.2 → 3.10.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 (170) hide show
  1. package/README.md +90 -2
  2. package/dist/api/agent.api.service.d.ts +8 -0
  3. package/dist/api/agent.api.service.d.ts.map +1 -1
  4. package/dist/api/agent.api.service.js +12 -0
  5. package/dist/api/agent.api.service.js.map +1 -1
  6. package/dist/api/device.api.service.d.ts +61 -0
  7. package/dist/api/device.api.service.d.ts.map +1 -0
  8. package/dist/api/device.api.service.js +72 -0
  9. package/dist/api/device.api.service.js.map +1 -0
  10. package/dist/api/lazy-instances.d.ts +1 -0
  11. package/dist/api/lazy-instances.d.ts.map +1 -1
  12. package/dist/api/lazy-instances.js +12 -0
  13. package/dist/api/lazy-instances.js.map +1 -1
  14. package/dist/api-exports.d.ts +38 -2
  15. package/dist/api-exports.d.ts.map +1 -1
  16. package/dist/api-exports.js +45 -2
  17. package/dist/api-exports.js.map +1 -1
  18. package/dist/cli/command-definitions.d.ts.map +1 -1
  19. package/dist/cli/command-definitions.js +100 -33
  20. package/dist/cli/command-definitions.js.map +1 -1
  21. package/dist/commands/agents.d.ts.map +1 -1
  22. package/dist/commands/agents.js +2 -11
  23. package/dist/commands/agents.js.map +1 -1
  24. package/dist/commands/apiKey.d.ts +1 -21
  25. package/dist/commands/apiKey.d.ts.map +1 -1
  26. package/dist/commands/apiKey.js +7 -25
  27. package/dist/commands/apiKey.js.map +1 -1
  28. package/dist/commands/compile.d.ts.map +1 -1
  29. package/dist/commands/compile.js +11 -3
  30. package/dist/commands/compile.js.map +1 -1
  31. package/dist/commands/configure.d.ts +2 -2
  32. package/dist/commands/configure.js +2 -2
  33. package/dist/commands/destroy.d.ts +0 -24
  34. package/dist/commands/destroy.d.ts.map +1 -1
  35. package/dist/commands/destroy.js +8 -30
  36. package/dist/commands/destroy.js.map +1 -1
  37. package/dist/commands/devices.d.ts +6 -0
  38. package/dist/commands/devices.d.ts.map +1 -0
  39. package/dist/commands/devices.js +266 -0
  40. package/dist/commands/devices.js.map +1 -0
  41. package/dist/commands/index.d.ts +2 -0
  42. package/dist/commands/index.d.ts.map +1 -1
  43. package/dist/commands/index.js +2 -0
  44. package/dist/commands/index.js.map +1 -1
  45. package/dist/commands/init.d.ts +1 -0
  46. package/dist/commands/init.d.ts.map +1 -1
  47. package/dist/commands/init.js +102 -39
  48. package/dist/commands/init.js.map +1 -1
  49. package/dist/commands/jobs.js +29 -9
  50. package/dist/commands/jobs.js.map +1 -1
  51. package/dist/commands/models.d.ts +18 -0
  52. package/dist/commands/models.d.ts.map +1 -0
  53. package/dist/commands/models.js +206 -0
  54. package/dist/commands/models.js.map +1 -0
  55. package/dist/commands/push.d.ts.map +1 -1
  56. package/dist/commands/push.js +8 -4
  57. package/dist/commands/push.js.map +1 -1
  58. package/dist/commands/pushBackup.d.ts.map +1 -1
  59. package/dist/commands/pushBackup.js +9 -1
  60. package/dist/commands/pushBackup.js.map +1 -1
  61. package/dist/commands/sync.d.ts +2 -0
  62. package/dist/commands/sync.d.ts.map +1 -1
  63. package/dist/commands/sync.js +116 -17
  64. package/dist/commands/sync.js.map +1 -1
  65. package/dist/compiler/agent-traverser.d.ts.map +1 -1
  66. package/dist/compiler/agent-traverser.js +1 -0
  67. package/dist/compiler/agent-traverser.js.map +1 -1
  68. package/dist/compiler/index.d.ts +1 -1
  69. package/dist/compiler/index.d.ts.map +1 -1
  70. package/dist/compiler/index.js +1 -1
  71. package/dist/compiler/index.js.map +1 -1
  72. package/dist/compiler/plugins/device.plugin.d.ts +46 -0
  73. package/dist/compiler/plugins/device.plugin.d.ts.map +1 -0
  74. package/dist/compiler/plugins/device.plugin.js +279 -0
  75. package/dist/compiler/plugins/device.plugin.js.map +1 -0
  76. package/dist/compiler/plugins/registry.d.ts.map +1 -1
  77. package/dist/compiler/plugins/registry.js +2 -0
  78. package/dist/compiler/plugins/registry.js.map +1 -1
  79. package/dist/compiler/source-writer.d.ts +17 -1
  80. package/dist/compiler/source-writer.d.ts.map +1 -1
  81. package/dist/compiler/source-writer.js +114 -29
  82. package/dist/compiler/source-writer.js.map +1 -1
  83. package/dist/compiler/types.d.ts +44 -2
  84. package/dist/compiler/types.d.ts.map +1 -1
  85. package/dist/compiler/types.js +1 -0
  86. package/dist/compiler/types.js.map +1 -1
  87. package/dist/config/constants.d.ts +7 -11
  88. package/dist/config/constants.d.ts.map +1 -1
  89. package/dist/config/constants.js +7 -11
  90. package/dist/config/constants.js.map +1 -1
  91. package/dist/index.js +0 -0
  92. package/dist/interfaces/agent.d.ts +11 -0
  93. package/dist/interfaces/agent.d.ts.map +1 -1
  94. package/dist/interfaces/devices.d.ts +75 -0
  95. package/dist/interfaces/devices.d.ts.map +1 -0
  96. package/dist/interfaces/devices.js +5 -0
  97. package/dist/interfaces/devices.js.map +1 -0
  98. package/dist/primitives/base.handler.d.ts.map +1 -1
  99. package/dist/primitives/base.handler.js +31 -7
  100. package/dist/primitives/base.handler.js.map +1 -1
  101. package/dist/primitives/device.handler.d.ts +43 -0
  102. package/dist/primitives/device.handler.d.ts.map +1 -0
  103. package/dist/primitives/device.handler.js +82 -0
  104. package/dist/primitives/device.handler.js.map +1 -0
  105. package/dist/primitives/index.d.ts +2 -0
  106. package/dist/primitives/index.d.ts.map +1 -1
  107. package/dist/primitives/index.js +4 -0
  108. package/dist/primitives/index.js.map +1 -1
  109. package/dist/services/analytics.d.ts.map +1 -1
  110. package/dist/services/analytics.js +6 -2
  111. package/dist/services/analytics.js.map +1 -1
  112. package/dist/services/auth.d.ts +16 -26
  113. package/dist/services/auth.d.ts.map +1 -1
  114. package/dist/services/auth.js +45 -101
  115. package/dist/services/auth.js.map +1 -1
  116. package/dist/types/skill.d.ts +98 -0
  117. package/dist/types/skill.d.ts.map +1 -1
  118. package/dist/types/skill.js +21 -0
  119. package/dist/types/skill.js.map +1 -1
  120. package/dist/types/yaml.types.d.ts +8 -0
  121. package/dist/types/yaml.types.d.ts.map +1 -1
  122. package/dist/utils/auth-flows.d.ts.map +1 -1
  123. package/dist/utils/auth-flows.js +8 -12
  124. package/dist/utils/auth-flows.js.map +1 -1
  125. package/dist/utils/backup-helpers.d.ts +41 -10
  126. package/dist/utils/backup-helpers.d.ts.map +1 -1
  127. package/dist/utils/backup-helpers.js +227 -15
  128. package/dist/utils/backup-helpers.js.map +1 -1
  129. package/dist/utils/cli.d.ts.map +1 -1
  130. package/dist/utils/cli.js +2 -3
  131. package/dist/utils/cli.js.map +1 -1
  132. package/dist/utils/command-utils.d.ts +4 -3
  133. package/dist/utils/command-utils.d.ts.map +1 -1
  134. package/dist/utils/command-utils.js +9 -20
  135. package/dist/utils/command-utils.js.map +1 -1
  136. package/dist/utils/init-agent.d.ts +37 -1
  137. package/dist/utils/init-agent.d.ts.map +1 -1
  138. package/dist/utils/init-agent.js +69 -1
  139. package/dist/utils/init-agent.js.map +1 -1
  140. package/dist/utils/init-helpers.d.ts +2 -1
  141. package/dist/utils/init-helpers.d.ts.map +1 -1
  142. package/dist/utils/init-helpers.js +3 -2
  143. package/dist/utils/init-helpers.js.map +1 -1
  144. package/dist/utils/init-prompts.d.ts +11 -1
  145. package/dist/utils/init-prompts.d.ts.map +1 -1
  146. package/dist/utils/init-prompts.js +49 -22
  147. package/dist/utils/init-prompts.js.map +1 -1
  148. package/dist/utils/sandbox-storage.d.ts +24 -18
  149. package/dist/utils/sandbox-storage.d.ts.map +1 -1
  150. package/dist/utils/sandbox-storage.js +108 -101
  151. package/dist/utils/sandbox-storage.js.map +1 -1
  152. package/dist/utils/sandbox.d.ts.map +1 -1
  153. package/dist/utils/sandbox.js +23 -0
  154. package/dist/utils/sandbox.js.map +1 -1
  155. package/docs/CLI_REFERENCE.md +152 -2
  156. package/docs/README.md +5 -3
  157. package/node_modules/@lua/shared-types/dist/index.d.mts +188 -2
  158. package/node_modules/@lua/shared-types/dist/index.d.ts +188 -2
  159. package/node_modules/@lua/shared-types/dist/index.js +171 -2
  160. package/node_modules/@lua/shared-types/dist/index.mjs +164 -1
  161. package/node_modules/@lua/shared-types/src/channel.type.ts +1 -0
  162. package/node_modules/@lua/shared-types/src/device.types.ts +172 -0
  163. package/node_modules/@lua/shared-types/src/index.ts +2 -0
  164. package/node_modules/@lua/shared-types/src/persona-defaults.ts +59 -0
  165. package/package.json +5 -7
  166. package/template/package.json +1 -1
  167. package/dist/utils/keytar-loader.d.ts +0 -20
  168. package/dist/utils/keytar-loader.d.ts.map +0 -1
  169. package/dist/utils/keytar-loader.js +0 -35
  170. package/dist/utils/keytar-loader.js.map +0 -1
@@ -14,6 +14,9 @@ Complete reference for all lua-cli commands.
14
14
  - [Marketplace](#marketplace)
15
15
  - [Utilities](#utilities)
16
16
  - [Global Flags](#global-flags)
17
+ - [Models](#models)
18
+ - [Devices](#devices)
19
+ - [Sync](#sync)
17
20
 
18
21
  ---
19
22
 
@@ -29,7 +32,7 @@ lua auth configure
29
32
  ```
30
33
 
31
34
  **Description:**
32
- Prompts for your API key and stores it securely in the system keychain (macOS Keychain, Windows Credential Vault, Linux libsecret).
35
+ Prompts for your API key and stores it in `~/.lua-cli/credentials` (file-based, works on all platforms including headless Linux and Docker).
33
36
 
34
37
  **Example:**
35
38
  ```bash
@@ -229,7 +232,7 @@ lua push [type] [options]
229
232
  ```
230
233
 
231
234
  **Arguments:**
232
- - `type` - Primitive type to push: `skill`, `webhook`, `job`, `preprocessor`, `postprocessor`, `mcp`, `all`
235
+ - `type` - Primitive type to push: `skill`, `webhook`, `job`, `preprocessor`, `postprocessor`, `mcp`, `device`, `all`
233
236
 
234
237
  **Options:**
235
238
  - `--name <name>` - Specific primitive name
@@ -912,6 +915,153 @@ lua deploy skill --name my-skill --version 1.0.0
912
915
 
913
916
  ---
914
917
 
918
+ ## Models
919
+
920
+ ### `lua models`
921
+
922
+ Manage the LLM model for your agent.
923
+
924
+ **Usage:**
925
+ ```bash
926
+ lua models [action] [options]
927
+ ```
928
+
929
+ **Actions:**
930
+ - `list` (default) — list all approved models grouped by provider, highlighting the current model
931
+ - `set` — interactively select or non-interactively specify a model; writes it to `src/index.ts` and pushes to server
932
+ - `unset` — remove the model from source and clear it on the server (reverts to platform default)
933
+
934
+ **Options:**
935
+ - `--model <code>` - Model code to set non-interactively (e.g. `openai/gpt-4o`)
936
+ - `--json` - Output model list as JSON
937
+
938
+ **Examples:**
939
+ ```bash
940
+ # List all available models
941
+ lua models
942
+ lua models list
943
+
944
+ # Set model interactively
945
+ lua models set
946
+
947
+ # Set model non-interactively
948
+ lua models set --model openai/gpt-4o
949
+ lua models set --model anthropic/claude-3-5-sonnet
950
+
951
+ # Revert to platform default
952
+ lua models unset
953
+
954
+ # Machine-readable output
955
+ lua models list --json
956
+ ```
957
+
958
+ ---
959
+
960
+ ## Devices
961
+
962
+ ### `lua devices`
963
+
964
+ Manage bidirectional agent-device communication.
965
+
966
+ **Usage:**
967
+ ```bash
968
+ lua devices [action] [options]
969
+ ```
970
+
971
+ **Actions:**
972
+ - `list` — list all registered devices
973
+ - `status` — check if a device is online, offline, or disabled
974
+ - `enable` — re-enable a disabled device
975
+ - `disable` — disable a device
976
+ - `remove` — remove a device (prompts for confirmation unless `--force`)
977
+ - `test` — send a test command to a device and display the response
978
+ - `test-trigger` — simulate an inbound trigger from a device
979
+
980
+ **Options:**
981
+ - `--device-name <name>` - Target device name (interactive picker shown when omitted)
982
+ - `--group <name>` - Filter devices by group (for `list`)
983
+ - `--payload <json>` - JSON payload to send with the command (default: `{}`)
984
+ - `--timeout <ms>` - Command timeout in milliseconds (default: `30000`)
985
+ - `--force` - Skip confirmation prompt (for `remove`)
986
+
987
+ **Examples:**
988
+ ```bash
989
+ # List all devices
990
+ lua devices list
991
+
992
+ # Filter by group
993
+ lua devices list --group production
994
+
995
+ # Check device status
996
+ lua devices status --device-name my-sensor
997
+
998
+ # Enable / disable a device
999
+ lua devices enable --device-name my-sensor
1000
+ lua devices disable --device-name my-sensor
1001
+
1002
+ # Remove a device
1003
+ lua devices remove --device-name my-sensor
1004
+ lua devices remove --device-name my-sensor --force # skip confirmation
1005
+
1006
+ # Send a test command
1007
+ lua devices test --device-name my-sensor
1008
+ lua devices test --device-name my-sensor --payload '{"temp": 22}' --timeout 5000
1009
+
1010
+ # Simulate an inbound trigger
1011
+ lua devices test-trigger --device-name my-sensor
1012
+ ```
1013
+
1014
+ **Pushing device definitions:**
1015
+ ```bash
1016
+ lua push device # push device configurations to the server
1017
+ lua push all # includes devices in full push
1018
+ ```
1019
+
1020
+ ---
1021
+
1022
+ ## Sync
1023
+
1024
+ ### `lua sync`
1025
+
1026
+ Detect and resolve drift between local and server state.
1027
+
1028
+ **Usage:**
1029
+ ```bash
1030
+ lua sync [options]
1031
+ ```
1032
+
1033
+ **Options:**
1034
+ - `--check` - Report drift and exit 1 if any drift is found (CI/CD use)
1035
+ - `--accept` - Auto-pull all server state to local (non-interactive)
1036
+ - `--push` - Auto-push all local changes to server (non-interactive)
1037
+ - `--force` - Bypass the local conflict guard when pulling
1038
+
1039
+ **Description:**
1040
+ Compares your local YAML config and source files against the server state. Detects drift for agent fields (name, persona, model) and all primitive types (skills, webhooks, jobs, preprocessors, postprocessors, MCP servers, devices).
1041
+
1042
+ **Conflict Guard:**
1043
+ `lua sync --pull` (and `--accept`) guards against overwriting local changes made since the last `lua push backup`. If modified files are detected, the pull is refused with a list of conflicted files. Use `--force` to bypass.
1044
+
1045
+ **Examples:**
1046
+ ```bash
1047
+ # Interactive drift resolution
1048
+ lua sync
1049
+
1050
+ # Report drift only (CI check)
1051
+ lua sync --check
1052
+
1053
+ # Pull all server state to local (non-interactive)
1054
+ lua sync --accept
1055
+
1056
+ # Pull, bypassing the conflict guard
1057
+ lua sync --accept --force
1058
+
1059
+ # Push all local state to server (non-interactive)
1060
+ lua sync --push
1061
+ ```
1062
+
1063
+ ---
1064
+
915
1065
  ## See Also
916
1066
 
917
1067
  - [Getting Started Guide](./GETTING_STARTED.md) - Step-by-step tutorial
package/docs/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Lua CLI - Complete API Documentation
2
2
 
3
- Welcome to the comprehensive API documentation for lua-cli v3.7.1. This guide covers every API, class, and function exported by the package.
3
+ Welcome to the comprehensive API documentation for lua-cli v3.10.0. This guide covers every API, class, and function exported by the package.
4
4
 
5
5
  ## 📚 Documentation Index
6
6
 
@@ -13,6 +13,7 @@ Welcome to the comprehensive API documentation for lua-cli v3.7.1. This guide co
13
13
  - [PreProcessor](./api/PreProcessor.md) - Message preprocessing (block/modify messages)
14
14
  - [PostProcessor](./api/PostProcessor.md) - Response postprocessing (format/enhance responses)
15
15
  - LuaMCPServer - MCP server integration (also auto-created via `lua integrations` command)
16
+ - LuaDevice - Bidirectional device communication (send commands, receive triggers)
16
17
 
17
18
  ### Runtime APIs
18
19
  - [User API](./api/User.md) - User data management
@@ -24,6 +25,7 @@ Welcome to the comprehensive API documentation for lua-cli v3.7.1. This guide co
24
25
  - [Orders API](./api/Orders.md) - Order management and fulfillment
25
26
  - [Templates API](./api/Templates.md) - WhatsApp template messages
26
27
  - [CDN API](./api/CDN.md) - File upload/download
28
+ - Device API - Send commands to and receive triggers from physical/virtual devices
27
29
  - Lua Runtime - Channel detection (`import { Lua } from 'lua-cli'`)
28
30
 
29
31
  ### Utilities
@@ -245,8 +247,8 @@ Each API doc includes:
245
247
 
246
248
  ---
247
249
 
248
- **Version:** 3.7.0
249
- **Last Updated:** March 2026
250
+ **Version:** 3.9.3
251
+ **Last Updated:** April 2026
250
252
 
251
253
  ---
252
254
 
@@ -5,7 +5,7 @@ import { FinishReason, LanguageModelUsage, ReasoningOutput, CallWarning, UserCon
5
5
  * Represents the communication channel through which a request originated.
6
6
  * Known channels are typed as string literals, unrecognized channels are unknown.
7
7
  */
8
- type Channel = 'web' | 'whatsapp' | 'facebook' | 'instagram' | 'slack' | 'teams' | 'messagebird' | 'front' | 'api' | 'dev' | 'email' | 'rcs' | 'sms' | 'mms' | string;
8
+ type Channel = 'web' | 'whatsapp' | 'facebook' | 'instagram' | 'slack' | 'teams' | 'messagebird' | 'front' | 'api' | 'dev' | 'email' | 'rcs' | 'sms' | 'mms' | 'device' | string;
9
9
 
10
10
  /**
11
11
  * MIME types supported by Unstructured.io for document text extraction.
@@ -89,4 +89,190 @@ interface AiGenerateOutput {
89
89
  */
90
90
  declare function aiGenerateInputFromSimplified(prompt: string, content?: UserContent): AiGenerateInput;
91
91
 
92
- export { type AiGenerateInput, type AiGenerateOutput, type AiGenerateSource, type AiGenerateToolCall, type AiGenerateToolResult, type Channel, UNSTRUCTURED_SUPPORTED_MEDIA_TYPES, aiGenerateInputFromSimplified };
92
+ /**
93
+ * Sandbox contract: defines what every sandbox MUST expose.
94
+ * Both lua-cli and lua-core test against this contract.
95
+ * Update this file when adding new globals or primitives.
96
+ */
97
+ declare const REQUIRED_PRIMITIVE_SHIMS: readonly ["LuaTool", "LuaSkill", "LuaJob", "LuaWebhook", "PreProcessor", "LuaPreprocessor", "PostProcessor", "LuaPostprocessor", "LuaMCPServer", "defineTool", "defineSkill", "defineJob", "defineWebhook", "definePreProcessor", "definePostProcessor", "defineMCPServer"];
98
+ declare const REQUIRED_PLATFORM_APIS: {
99
+ readonly User: readonly ["get", "getChatHistory"];
100
+ readonly Products: readonly ["get", "create", "delete", "search", "getById"];
101
+ readonly Baskets: readonly ["create", "get", "addItem", "removeItem", "clear", "updateStatus", "updateMetadata", "placeOrder", "getById"];
102
+ readonly Orders: readonly ["create", "updateStatus", "updateData", "get", "getById"];
103
+ readonly Data: readonly ["create", "get", "getEntry", "update", "search", "delete"];
104
+ readonly Jobs: readonly ["create", "getJob", "getAll"];
105
+ readonly AI: readonly ["generate"];
106
+ readonly CDN: readonly ["upload", "get"];
107
+ };
108
+ declare const REQUIRED_NESTED_APIS: {
109
+ readonly Templates: {
110
+ readonly whatsapp: readonly ["list", "get", "send"];
111
+ };
112
+ readonly Lua: {
113
+ readonly request: readonly ["channel"];
114
+ };
115
+ };
116
+ declare const REQUIRED_ENUMS: {
117
+ readonly BasketStatus: readonly ["ACTIVE", "CHECKED_OUT", "ABANDONED", "EXPIRED"];
118
+ readonly OrderStatus: readonly ["PENDING", "CONFIRMED", "FULFILLED", "CANCELLED"];
119
+ };
120
+ declare const REQUIRED_UTILITIES: readonly ["env"];
121
+
122
+ /**
123
+ * Device Gateway Types
124
+ *
125
+ * Types for bidirectional communication between AI agents and external devices.
126
+ * Used across lua-api (gateway), lua-core (runtime), and lua-cli (compilation).
127
+ */
128
+ /** Command message sent from the server to a device */
129
+ interface DeviceCommandMessage {
130
+ /** Unique identifier for this command (UUID). Used for idempotency. */
131
+ commandId: string;
132
+ /** Command name (must match a command defined in defineDevice) */
133
+ command: string;
134
+ /** Command payload (validated against inputSchema if defined) */
135
+ payload: any;
136
+ /** Timeout in milliseconds (defaults to 30000) */
137
+ timeout?: number;
138
+ }
139
+ /** Response message sent from a device back to the server */
140
+ interface DeviceResponseMessage {
141
+ /** Must match the commandId of the original command */
142
+ commandId: string;
143
+ /** Whether the command executed successfully on the device */
144
+ success: boolean;
145
+ /** Response data (present when success=true) */
146
+ data?: any;
147
+ /** Error message (present when success=false) */
148
+ error?: string;
149
+ }
150
+ /** Trigger message sent from a device to the server */
151
+ interface DeviceTriggerMessage {
152
+ /** Trigger name (must match a trigger defined in defineDevice) */
153
+ triggerName: string;
154
+ /** Trigger payload (validated against payloadSchema if defined) */
155
+ payload: any;
156
+ }
157
+ /** Acknowledgment sent from the server back to the device after receiving a trigger */
158
+ interface DeviceTriggerAckMessage {
159
+ /** Server-generated unique identifier for this trigger event */
160
+ triggerId: string;
161
+ /** Whether the trigger was received and queued for processing */
162
+ received: boolean;
163
+ /** Error details if the trigger was rejected */
164
+ error?: string;
165
+ }
166
+ /** Device connection status */
167
+ type DeviceStatus = 'online' | 'offline' | 'registered' | 'disabled';
168
+ /** State of a command in the Valkey state machine */
169
+ type CommandState = 'PENDING' | 'SENT' | 'ACK' | 'COMPLETED' | 'FAILED' | 'TIMED_OUT';
170
+ /** Device information returned by API endpoints */
171
+ interface DeviceInfo {
172
+ /** Unique device name within the agent */
173
+ name: string;
174
+ /** Agent this device belongs to */
175
+ agentId: string;
176
+ /** Current connection status */
177
+ status: DeviceStatus;
178
+ /** Device group (optional, for fan-out commands) */
179
+ group?: string;
180
+ /** Device capabilities */
181
+ capabilities: string[];
182
+ /** Free-form device metadata */
183
+ metadata: Record<string, any>;
184
+ /** Last time the device was seen (heartbeat or connect) */
185
+ lastSeenAt: Date | null;
186
+ }
187
+ /** Entry written to the device command stream */
188
+ interface CommandStreamEntry {
189
+ commandId: string;
190
+ command: string;
191
+ payload: string;
192
+ originPodId: string;
193
+ agentId: string;
194
+ deviceName: string;
195
+ }
196
+ /** Entry written to the device response stream */
197
+ interface ResponseStreamEntry {
198
+ commandId: string;
199
+ success: string;
200
+ data?: string;
201
+ error?: string;
202
+ }
203
+ /** Entry written to the device trigger stream */
204
+ interface TriggerStreamEntry {
205
+ triggerId: string;
206
+ agentId: string;
207
+ deviceName: string;
208
+ deviceId: string;
209
+ triggerName: string;
210
+ payload: string;
211
+ timestamp: string;
212
+ }
213
+ /** Data stored in the Valkey hash for a command's state */
214
+ interface CommandHashData {
215
+ status: CommandState;
216
+ agentId: string;
217
+ deviceName: string;
218
+ originPodId: string;
219
+ timestamp: number;
220
+ }
221
+ /** Device definition as stored in Redis cache */
222
+ interface CachedDeviceDefinition {
223
+ name: string;
224
+ description?: string;
225
+ group?: string;
226
+ commands: CachedDeviceCommand[];
227
+ triggers: CachedDeviceTrigger[];
228
+ /** Compressed (gzip + base64) compiled artifact containing trigger handlers */
229
+ artifact: string;
230
+ /** Environment variables for the device */
231
+ env: Record<string, string>;
232
+ }
233
+ interface CachedDeviceCommand {
234
+ name: string;
235
+ description: string;
236
+ inputSchema?: Record<string, any>;
237
+ retry?: {
238
+ maxAttempts: number;
239
+ backoffMs: number;
240
+ };
241
+ timeoutMs?: number;
242
+ }
243
+ interface CachedDeviceTrigger {
244
+ name: string;
245
+ description: string;
246
+ payloadSchema?: Record<string, any>;
247
+ hasExecute: boolean;
248
+ }
249
+
250
+ /**
251
+ * Shared type definitions for the model registry.
252
+ *
253
+ * Runtime data (provider configs, context windows, approved model list) lives
254
+ * exclusively in the MongoDB `approvedModels` collection. lua-core loads it at
255
+ * startup via initModelRegistry() in mastra/common/model-registry.ts.
256
+ */
257
+ interface ApprovedModelDef {
258
+ provider: string;
259
+ /** Full user-facing model string, e.g. "zhipuai/glm-5". */
260
+ code: string;
261
+ /** Model ID portion for display, e.g. "glm-5". */
262
+ model: string;
263
+ description: string;
264
+ /** Advertised input token context window (raw, from provider docs). */
265
+ contextWindow?: number;
266
+ /** If set, route requests through a gateway instead of calling the provider directly. */
267
+ gateway?: {
268
+ via: string;
269
+ modelPrefix: string;
270
+ };
271
+ }
272
+
273
+ /**
274
+ * Build a default persona guide with the agent name filled in.
275
+ */
276
+ declare function buildDefaultPersona(agentName: string): string;
277
+
278
+ export { type AiGenerateInput, type AiGenerateOutput, type AiGenerateSource, type AiGenerateToolCall, type AiGenerateToolResult, type ApprovedModelDef, type CachedDeviceCommand, type CachedDeviceDefinition, type CachedDeviceTrigger, type Channel, type CommandHashData, type CommandState, type CommandStreamEntry, type DeviceCommandMessage, type DeviceInfo, type DeviceResponseMessage, type DeviceStatus, type DeviceTriggerAckMessage, type DeviceTriggerMessage, REQUIRED_ENUMS, REQUIRED_NESTED_APIS, REQUIRED_PLATFORM_APIS, REQUIRED_PRIMITIVE_SHIMS, REQUIRED_UTILITIES, type ResponseStreamEntry, type TriggerStreamEntry, UNSTRUCTURED_SUPPORTED_MEDIA_TYPES, aiGenerateInputFromSimplified, buildDefaultPersona };
@@ -5,7 +5,7 @@ import { FinishReason, LanguageModelUsage, ReasoningOutput, CallWarning, UserCon
5
5
  * Represents the communication channel through which a request originated.
6
6
  * Known channels are typed as string literals, unrecognized channels are unknown.
7
7
  */
8
- type Channel = 'web' | 'whatsapp' | 'facebook' | 'instagram' | 'slack' | 'teams' | 'messagebird' | 'front' | 'api' | 'dev' | 'email' | 'rcs' | 'sms' | 'mms' | string;
8
+ type Channel = 'web' | 'whatsapp' | 'facebook' | 'instagram' | 'slack' | 'teams' | 'messagebird' | 'front' | 'api' | 'dev' | 'email' | 'rcs' | 'sms' | 'mms' | 'device' | string;
9
9
 
10
10
  /**
11
11
  * MIME types supported by Unstructured.io for document text extraction.
@@ -89,4 +89,190 @@ interface AiGenerateOutput {
89
89
  */
90
90
  declare function aiGenerateInputFromSimplified(prompt: string, content?: UserContent): AiGenerateInput;
91
91
 
92
- export { type AiGenerateInput, type AiGenerateOutput, type AiGenerateSource, type AiGenerateToolCall, type AiGenerateToolResult, type Channel, UNSTRUCTURED_SUPPORTED_MEDIA_TYPES, aiGenerateInputFromSimplified };
92
+ /**
93
+ * Sandbox contract: defines what every sandbox MUST expose.
94
+ * Both lua-cli and lua-core test against this contract.
95
+ * Update this file when adding new globals or primitives.
96
+ */
97
+ declare const REQUIRED_PRIMITIVE_SHIMS: readonly ["LuaTool", "LuaSkill", "LuaJob", "LuaWebhook", "PreProcessor", "LuaPreprocessor", "PostProcessor", "LuaPostprocessor", "LuaMCPServer", "defineTool", "defineSkill", "defineJob", "defineWebhook", "definePreProcessor", "definePostProcessor", "defineMCPServer"];
98
+ declare const REQUIRED_PLATFORM_APIS: {
99
+ readonly User: readonly ["get", "getChatHistory"];
100
+ readonly Products: readonly ["get", "create", "delete", "search", "getById"];
101
+ readonly Baskets: readonly ["create", "get", "addItem", "removeItem", "clear", "updateStatus", "updateMetadata", "placeOrder", "getById"];
102
+ readonly Orders: readonly ["create", "updateStatus", "updateData", "get", "getById"];
103
+ readonly Data: readonly ["create", "get", "getEntry", "update", "search", "delete"];
104
+ readonly Jobs: readonly ["create", "getJob", "getAll"];
105
+ readonly AI: readonly ["generate"];
106
+ readonly CDN: readonly ["upload", "get"];
107
+ };
108
+ declare const REQUIRED_NESTED_APIS: {
109
+ readonly Templates: {
110
+ readonly whatsapp: readonly ["list", "get", "send"];
111
+ };
112
+ readonly Lua: {
113
+ readonly request: readonly ["channel"];
114
+ };
115
+ };
116
+ declare const REQUIRED_ENUMS: {
117
+ readonly BasketStatus: readonly ["ACTIVE", "CHECKED_OUT", "ABANDONED", "EXPIRED"];
118
+ readonly OrderStatus: readonly ["PENDING", "CONFIRMED", "FULFILLED", "CANCELLED"];
119
+ };
120
+ declare const REQUIRED_UTILITIES: readonly ["env"];
121
+
122
+ /**
123
+ * Device Gateway Types
124
+ *
125
+ * Types for bidirectional communication between AI agents and external devices.
126
+ * Used across lua-api (gateway), lua-core (runtime), and lua-cli (compilation).
127
+ */
128
+ /** Command message sent from the server to a device */
129
+ interface DeviceCommandMessage {
130
+ /** Unique identifier for this command (UUID). Used for idempotency. */
131
+ commandId: string;
132
+ /** Command name (must match a command defined in defineDevice) */
133
+ command: string;
134
+ /** Command payload (validated against inputSchema if defined) */
135
+ payload: any;
136
+ /** Timeout in milliseconds (defaults to 30000) */
137
+ timeout?: number;
138
+ }
139
+ /** Response message sent from a device back to the server */
140
+ interface DeviceResponseMessage {
141
+ /** Must match the commandId of the original command */
142
+ commandId: string;
143
+ /** Whether the command executed successfully on the device */
144
+ success: boolean;
145
+ /** Response data (present when success=true) */
146
+ data?: any;
147
+ /** Error message (present when success=false) */
148
+ error?: string;
149
+ }
150
+ /** Trigger message sent from a device to the server */
151
+ interface DeviceTriggerMessage {
152
+ /** Trigger name (must match a trigger defined in defineDevice) */
153
+ triggerName: string;
154
+ /** Trigger payload (validated against payloadSchema if defined) */
155
+ payload: any;
156
+ }
157
+ /** Acknowledgment sent from the server back to the device after receiving a trigger */
158
+ interface DeviceTriggerAckMessage {
159
+ /** Server-generated unique identifier for this trigger event */
160
+ triggerId: string;
161
+ /** Whether the trigger was received and queued for processing */
162
+ received: boolean;
163
+ /** Error details if the trigger was rejected */
164
+ error?: string;
165
+ }
166
+ /** Device connection status */
167
+ type DeviceStatus = 'online' | 'offline' | 'registered' | 'disabled';
168
+ /** State of a command in the Valkey state machine */
169
+ type CommandState = 'PENDING' | 'SENT' | 'ACK' | 'COMPLETED' | 'FAILED' | 'TIMED_OUT';
170
+ /** Device information returned by API endpoints */
171
+ interface DeviceInfo {
172
+ /** Unique device name within the agent */
173
+ name: string;
174
+ /** Agent this device belongs to */
175
+ agentId: string;
176
+ /** Current connection status */
177
+ status: DeviceStatus;
178
+ /** Device group (optional, for fan-out commands) */
179
+ group?: string;
180
+ /** Device capabilities */
181
+ capabilities: string[];
182
+ /** Free-form device metadata */
183
+ metadata: Record<string, any>;
184
+ /** Last time the device was seen (heartbeat or connect) */
185
+ lastSeenAt: Date | null;
186
+ }
187
+ /** Entry written to the device command stream */
188
+ interface CommandStreamEntry {
189
+ commandId: string;
190
+ command: string;
191
+ payload: string;
192
+ originPodId: string;
193
+ agentId: string;
194
+ deviceName: string;
195
+ }
196
+ /** Entry written to the device response stream */
197
+ interface ResponseStreamEntry {
198
+ commandId: string;
199
+ success: string;
200
+ data?: string;
201
+ error?: string;
202
+ }
203
+ /** Entry written to the device trigger stream */
204
+ interface TriggerStreamEntry {
205
+ triggerId: string;
206
+ agentId: string;
207
+ deviceName: string;
208
+ deviceId: string;
209
+ triggerName: string;
210
+ payload: string;
211
+ timestamp: string;
212
+ }
213
+ /** Data stored in the Valkey hash for a command's state */
214
+ interface CommandHashData {
215
+ status: CommandState;
216
+ agentId: string;
217
+ deviceName: string;
218
+ originPodId: string;
219
+ timestamp: number;
220
+ }
221
+ /** Device definition as stored in Redis cache */
222
+ interface CachedDeviceDefinition {
223
+ name: string;
224
+ description?: string;
225
+ group?: string;
226
+ commands: CachedDeviceCommand[];
227
+ triggers: CachedDeviceTrigger[];
228
+ /** Compressed (gzip + base64) compiled artifact containing trigger handlers */
229
+ artifact: string;
230
+ /** Environment variables for the device */
231
+ env: Record<string, string>;
232
+ }
233
+ interface CachedDeviceCommand {
234
+ name: string;
235
+ description: string;
236
+ inputSchema?: Record<string, any>;
237
+ retry?: {
238
+ maxAttempts: number;
239
+ backoffMs: number;
240
+ };
241
+ timeoutMs?: number;
242
+ }
243
+ interface CachedDeviceTrigger {
244
+ name: string;
245
+ description: string;
246
+ payloadSchema?: Record<string, any>;
247
+ hasExecute: boolean;
248
+ }
249
+
250
+ /**
251
+ * Shared type definitions for the model registry.
252
+ *
253
+ * Runtime data (provider configs, context windows, approved model list) lives
254
+ * exclusively in the MongoDB `approvedModels` collection. lua-core loads it at
255
+ * startup via initModelRegistry() in mastra/common/model-registry.ts.
256
+ */
257
+ interface ApprovedModelDef {
258
+ provider: string;
259
+ /** Full user-facing model string, e.g. "zhipuai/glm-5". */
260
+ code: string;
261
+ /** Model ID portion for display, e.g. "glm-5". */
262
+ model: string;
263
+ description: string;
264
+ /** Advertised input token context window (raw, from provider docs). */
265
+ contextWindow?: number;
266
+ /** If set, route requests through a gateway instead of calling the provider directly. */
267
+ gateway?: {
268
+ via: string;
269
+ modelPrefix: string;
270
+ };
271
+ }
272
+
273
+ /**
274
+ * Build a default persona guide with the agent name filled in.
275
+ */
276
+ declare function buildDefaultPersona(agentName: string): string;
277
+
278
+ export { type AiGenerateInput, type AiGenerateOutput, type AiGenerateSource, type AiGenerateToolCall, type AiGenerateToolResult, type ApprovedModelDef, type CachedDeviceCommand, type CachedDeviceDefinition, type CachedDeviceTrigger, type Channel, type CommandHashData, type CommandState, type CommandStreamEntry, type DeviceCommandMessage, type DeviceInfo, type DeviceResponseMessage, type DeviceStatus, type DeviceTriggerAckMessage, type DeviceTriggerMessage, REQUIRED_ENUMS, REQUIRED_NESTED_APIS, REQUIRED_PLATFORM_APIS, REQUIRED_PRIMITIVE_SHIMS, REQUIRED_UTILITIES, type ResponseStreamEntry, type TriggerStreamEntry, UNSTRUCTURED_SUPPORTED_MEDIA_TYPES, aiGenerateInputFromSimplified, buildDefaultPersona };