lua-cli 3.9.3 → 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.
- package/dist/api/device.api.service.d.ts +61 -0
- package/dist/api/device.api.service.d.ts.map +1 -0
- package/dist/api/device.api.service.js +72 -0
- package/dist/api/device.api.service.js.map +1 -0
- package/dist/api/lazy-instances.d.ts +1 -0
- package/dist/api/lazy-instances.d.ts.map +1 -1
- package/dist/api/lazy-instances.js +12 -0
- package/dist/api/lazy-instances.js.map +1 -1
- package/dist/api-exports.d.ts +38 -2
- package/dist/api-exports.d.ts.map +1 -1
- package/dist/api-exports.js +45 -2
- package/dist/api-exports.js.map +1 -1
- package/dist/cli/command-definitions.d.ts.map +1 -1
- package/dist/cli/command-definitions.js +75 -11
- package/dist/cli/command-definitions.js.map +1 -1
- package/dist/commands/devices.d.ts +6 -0
- package/dist/commands/devices.d.ts.map +1 -0
- package/dist/commands/devices.js +266 -0
- package/dist/commands/devices.js.map +1 -0
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +2 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/models.d.ts +18 -0
- package/dist/commands/models.d.ts.map +1 -0
- package/dist/commands/models.js +206 -0
- package/dist/commands/models.js.map +1 -0
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +8 -4
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/pushBackup.d.ts.map +1 -1
- package/dist/commands/pushBackup.js +9 -1
- package/dist/commands/pushBackup.js.map +1 -1
- package/dist/commands/sync.d.ts +2 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +116 -17
- package/dist/commands/sync.js.map +1 -1
- package/dist/compiler/agent-traverser.d.ts.map +1 -1
- package/dist/compiler/agent-traverser.js +1 -0
- package/dist/compiler/agent-traverser.js.map +1 -1
- package/dist/compiler/index.d.ts +1 -1
- package/dist/compiler/index.d.ts.map +1 -1
- package/dist/compiler/index.js +1 -1
- package/dist/compiler/index.js.map +1 -1
- package/dist/compiler/plugins/device.plugin.d.ts +46 -0
- package/dist/compiler/plugins/device.plugin.d.ts.map +1 -0
- package/dist/compiler/plugins/device.plugin.js +279 -0
- package/dist/compiler/plugins/device.plugin.js.map +1 -0
- package/dist/compiler/plugins/registry.d.ts.map +1 -1
- package/dist/compiler/plugins/registry.js +2 -0
- package/dist/compiler/plugins/registry.js.map +1 -1
- package/dist/compiler/source-writer.d.ts +17 -1
- package/dist/compiler/source-writer.d.ts.map +1 -1
- package/dist/compiler/source-writer.js +92 -28
- package/dist/compiler/source-writer.js.map +1 -1
- package/dist/compiler/types.d.ts +44 -2
- package/dist/compiler/types.d.ts.map +1 -1
- package/dist/compiler/types.js +1 -0
- package/dist/compiler/types.js.map +1 -1
- package/dist/interfaces/devices.d.ts +75 -0
- package/dist/interfaces/devices.d.ts.map +1 -0
- package/dist/interfaces/devices.js +5 -0
- package/dist/interfaces/devices.js.map +1 -0
- package/dist/primitives/base.handler.d.ts.map +1 -1
- package/dist/primitives/base.handler.js +31 -7
- package/dist/primitives/base.handler.js.map +1 -1
- package/dist/primitives/device.handler.d.ts +43 -0
- package/dist/primitives/device.handler.d.ts.map +1 -0
- package/dist/primitives/device.handler.js +82 -0
- package/dist/primitives/device.handler.js.map +1 -0
- package/dist/primitives/index.d.ts +2 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +4 -0
- package/dist/primitives/index.js.map +1 -1
- package/dist/types/skill.d.ts +98 -0
- package/dist/types/skill.d.ts.map +1 -1
- package/dist/types/skill.js +21 -0
- package/dist/types/skill.js.map +1 -1
- package/dist/types/yaml.types.d.ts +8 -0
- package/dist/types/yaml.types.d.ts.map +1 -1
- package/dist/utils/backup-helpers.d.ts +41 -10
- package/dist/utils/backup-helpers.d.ts.map +1 -1
- package/dist/utils/backup-helpers.js +227 -15
- package/dist/utils/backup-helpers.js.map +1 -1
- package/dist/utils/init-agent.d.ts +8 -1
- package/dist/utils/init-agent.d.ts.map +1 -1
- package/dist/utils/init-agent.js +14 -1
- package/dist/utils/init-agent.js.map +1 -1
- package/dist/utils/init-prompts.d.ts +1 -1
- package/dist/utils/init-prompts.d.ts.map +1 -1
- package/dist/utils/init-prompts.js +7 -20
- package/dist/utils/init-prompts.js.map +1 -1
- package/dist/utils/sandbox-storage.d.ts +6 -0
- package/dist/utils/sandbox-storage.d.ts.map +1 -1
- package/dist/utils/sandbox-storage.js +32 -1
- package/dist/utils/sandbox-storage.js.map +1 -1
- package/dist/utils/sandbox.d.ts.map +1 -1
- package/dist/utils/sandbox.js +23 -0
- package/dist/utils/sandbox.js.map +1 -1
- package/docs/CLI_REFERENCE.md +152 -2
- package/docs/README.md +3 -1
- package/node_modules/@lua/shared-types/dist/index.d.mts +135 -2
- package/node_modules/@lua/shared-types/dist/index.d.ts +135 -2
- package/node_modules/@lua/shared-types/dist/index.js +57 -2
- package/node_modules/@lua/shared-types/dist/index.mjs +55 -1
- package/node_modules/@lua/shared-types/src/channel.type.ts +1 -0
- package/node_modules/@lua/shared-types/src/device.types.ts +172 -0
- package/node_modules/@lua/shared-types/src/index.ts +2 -0
- package/node_modules/@lua/shared-types/src/persona-defaults.ts +59 -0
- package/package.json +1 -1
- package/template/package.json +1 -1
package/docs/CLI_REFERENCE.md
CHANGED
|
@@ -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
|
|
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.
|
|
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.9.3. 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.9.3. 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
|
|
@@ -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.
|
|
@@ -119,6 +119,134 @@ declare const REQUIRED_ENUMS: {
|
|
|
119
119
|
};
|
|
120
120
|
declare const REQUIRED_UTILITIES: readonly ["env"];
|
|
121
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
|
+
|
|
122
250
|
/**
|
|
123
251
|
* Shared type definitions for the model registry.
|
|
124
252
|
*
|
|
@@ -142,4 +270,9 @@ interface ApprovedModelDef {
|
|
|
142
270
|
};
|
|
143
271
|
}
|
|
144
272
|
|
|
145
|
-
|
|
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.
|
|
@@ -119,6 +119,134 @@ declare const REQUIRED_ENUMS: {
|
|
|
119
119
|
};
|
|
120
120
|
declare const REQUIRED_UTILITIES: readonly ["env"];
|
|
121
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
|
+
|
|
122
250
|
/**
|
|
123
251
|
* Shared type definitions for the model registry.
|
|
124
252
|
*
|
|
@@ -142,4 +270,9 @@ interface ApprovedModelDef {
|
|
|
142
270
|
};
|
|
143
271
|
}
|
|
144
272
|
|
|
145
|
-
|
|
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 };
|
|
@@ -26,7 +26,8 @@ __export(index_exports, {
|
|
|
26
26
|
REQUIRED_PRIMITIVE_SHIMS: () => REQUIRED_PRIMITIVE_SHIMS,
|
|
27
27
|
REQUIRED_UTILITIES: () => REQUIRED_UTILITIES,
|
|
28
28
|
UNSTRUCTURED_SUPPORTED_MEDIA_TYPES: () => UNSTRUCTURED_SUPPORTED_MEDIA_TYPES,
|
|
29
|
-
aiGenerateInputFromSimplified: () => aiGenerateInputFromSimplified
|
|
29
|
+
aiGenerateInputFromSimplified: () => aiGenerateInputFromSimplified,
|
|
30
|
+
buildDefaultPersona: () => buildDefaultPersona
|
|
30
31
|
});
|
|
31
32
|
module.exports = __toCommonJS(index_exports);
|
|
32
33
|
|
|
@@ -206,6 +207,59 @@ var REQUIRED_ENUMS = {
|
|
|
206
207
|
var REQUIRED_UTILITIES = [
|
|
207
208
|
"env"
|
|
208
209
|
];
|
|
210
|
+
|
|
211
|
+
// src/persona-defaults.ts
|
|
212
|
+
var AGENT_NAME_TOKEN = "[Your Agent Name]";
|
|
213
|
+
var DEFAULT_PERSONA_GUIDE = `# ${AGENT_NAME_TOKEN} - Persona
|
|
214
|
+
|
|
215
|
+
This is a starting template to help you think about your agent's persona.
|
|
216
|
+
Use it as-is, rearrange it, or replace it entirely with your own format \u2014 whatever works best for your use case.
|
|
217
|
+
The sections below are suggestions, not requirements.
|
|
218
|
+
|
|
219
|
+
## Identity & Role
|
|
220
|
+
Who is your agent? What's their name and core purpose?
|
|
221
|
+
- Give it a name and a clear one-line role
|
|
222
|
+
- e.g. a customer support rep, a shopping assistant, an internal ops copilot, a scheduling bot
|
|
223
|
+
|
|
224
|
+
## Business Context
|
|
225
|
+
What company, product, or service does the agent represent? What does the business do?
|
|
226
|
+
- Describe the business in a sentence or two so the agent understands the world it operates in
|
|
227
|
+
- Include industry, value proposition, and anything the agent should "know" about the brand
|
|
228
|
+
|
|
229
|
+
## Tone & Communication Style
|
|
230
|
+
How should the agent sound?
|
|
231
|
+
- Formal or casual? Concise or detailed? Empathetic or matter-of-fact?
|
|
232
|
+
- Should it match a specific brand voice or adapt to the user's tone?
|
|
233
|
+
- Any language or cultural considerations (e.g. greetings, local expressions)?
|
|
234
|
+
|
|
235
|
+
## Target Audience
|
|
236
|
+
Who will the agent be talking to?
|
|
237
|
+
- Describe the typical user: consumers, business customers, internal team members, etc.
|
|
238
|
+
- What do they usually need help with? What matters most to them?
|
|
239
|
+
|
|
240
|
+
## Capabilities
|
|
241
|
+
What can the agent help with? List the main things it should handle.
|
|
242
|
+
- e.g. answering product questions, placing orders, looking up account info, scheduling meetings
|
|
243
|
+
- Be specific \u2014 this shapes which skills and tools the agent will use
|
|
244
|
+
|
|
245
|
+
## Boundaries
|
|
246
|
+
What should the agent NOT do? When should it escalate to a human?
|
|
247
|
+
- e.g. cannot process refunds, should not give medical/legal advice
|
|
248
|
+
- Define when to hand off: frustrated user, request outside scope, sensitive data
|
|
249
|
+
|
|
250
|
+
## Guidelines
|
|
251
|
+
Any rules for how the agent behaves?
|
|
252
|
+
- Response length limits (e.g. keep messages under 300 words)
|
|
253
|
+
- Formatting preferences (e.g. use bullet points, avoid jargon)
|
|
254
|
+
- Things to always or never do (e.g. always confirm before changes, never share internal IDs)
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
Feel free to add, remove, or rename sections. Your persona can be a single paragraph or a detailed playbook \u2014 whatever gives your agent the context it needs.
|
|
258
|
+
`;
|
|
259
|
+
function buildDefaultPersona(agentName) {
|
|
260
|
+
return DEFAULT_PERSONA_GUIDE.replace(AGENT_NAME_TOKEN, () => agentName || "My Agent");
|
|
261
|
+
}
|
|
262
|
+
__name(buildDefaultPersona, "buildDefaultPersona");
|
|
209
263
|
// Annotate the CommonJS export names for ESM import in node:
|
|
210
264
|
0 && (module.exports = {
|
|
211
265
|
REQUIRED_ENUMS,
|
|
@@ -214,5 +268,6 @@ var REQUIRED_UTILITIES = [
|
|
|
214
268
|
REQUIRED_PRIMITIVE_SHIMS,
|
|
215
269
|
REQUIRED_UTILITIES,
|
|
216
270
|
UNSTRUCTURED_SUPPORTED_MEDIA_TYPES,
|
|
217
|
-
aiGenerateInputFromSimplified
|
|
271
|
+
aiGenerateInputFromSimplified,
|
|
272
|
+
buildDefaultPersona
|
|
218
273
|
});
|
|
@@ -177,6 +177,59 @@ var REQUIRED_ENUMS = {
|
|
|
177
177
|
var REQUIRED_UTILITIES = [
|
|
178
178
|
"env"
|
|
179
179
|
];
|
|
180
|
+
|
|
181
|
+
// src/persona-defaults.ts
|
|
182
|
+
var AGENT_NAME_TOKEN = "[Your Agent Name]";
|
|
183
|
+
var DEFAULT_PERSONA_GUIDE = `# ${AGENT_NAME_TOKEN} - Persona
|
|
184
|
+
|
|
185
|
+
This is a starting template to help you think about your agent's persona.
|
|
186
|
+
Use it as-is, rearrange it, or replace it entirely with your own format \u2014 whatever works best for your use case.
|
|
187
|
+
The sections below are suggestions, not requirements.
|
|
188
|
+
|
|
189
|
+
## Identity & Role
|
|
190
|
+
Who is your agent? What's their name and core purpose?
|
|
191
|
+
- Give it a name and a clear one-line role
|
|
192
|
+
- e.g. a customer support rep, a shopping assistant, an internal ops copilot, a scheduling bot
|
|
193
|
+
|
|
194
|
+
## Business Context
|
|
195
|
+
What company, product, or service does the agent represent? What does the business do?
|
|
196
|
+
- Describe the business in a sentence or two so the agent understands the world it operates in
|
|
197
|
+
- Include industry, value proposition, and anything the agent should "know" about the brand
|
|
198
|
+
|
|
199
|
+
## Tone & Communication Style
|
|
200
|
+
How should the agent sound?
|
|
201
|
+
- Formal or casual? Concise or detailed? Empathetic or matter-of-fact?
|
|
202
|
+
- Should it match a specific brand voice or adapt to the user's tone?
|
|
203
|
+
- Any language or cultural considerations (e.g. greetings, local expressions)?
|
|
204
|
+
|
|
205
|
+
## Target Audience
|
|
206
|
+
Who will the agent be talking to?
|
|
207
|
+
- Describe the typical user: consumers, business customers, internal team members, etc.
|
|
208
|
+
- What do they usually need help with? What matters most to them?
|
|
209
|
+
|
|
210
|
+
## Capabilities
|
|
211
|
+
What can the agent help with? List the main things it should handle.
|
|
212
|
+
- e.g. answering product questions, placing orders, looking up account info, scheduling meetings
|
|
213
|
+
- Be specific \u2014 this shapes which skills and tools the agent will use
|
|
214
|
+
|
|
215
|
+
## Boundaries
|
|
216
|
+
What should the agent NOT do? When should it escalate to a human?
|
|
217
|
+
- e.g. cannot process refunds, should not give medical/legal advice
|
|
218
|
+
- Define when to hand off: frustrated user, request outside scope, sensitive data
|
|
219
|
+
|
|
220
|
+
## Guidelines
|
|
221
|
+
Any rules for how the agent behaves?
|
|
222
|
+
- Response length limits (e.g. keep messages under 300 words)
|
|
223
|
+
- Formatting preferences (e.g. use bullet points, avoid jargon)
|
|
224
|
+
- Things to always or never do (e.g. always confirm before changes, never share internal IDs)
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
Feel free to add, remove, or rename sections. Your persona can be a single paragraph or a detailed playbook \u2014 whatever gives your agent the context it needs.
|
|
228
|
+
`;
|
|
229
|
+
function buildDefaultPersona(agentName) {
|
|
230
|
+
return DEFAULT_PERSONA_GUIDE.replace(AGENT_NAME_TOKEN, () => agentName || "My Agent");
|
|
231
|
+
}
|
|
232
|
+
__name(buildDefaultPersona, "buildDefaultPersona");
|
|
180
233
|
export {
|
|
181
234
|
REQUIRED_ENUMS,
|
|
182
235
|
REQUIRED_NESTED_APIS,
|
|
@@ -184,5 +237,6 @@ export {
|
|
|
184
237
|
REQUIRED_PRIMITIVE_SHIMS,
|
|
185
238
|
REQUIRED_UTILITIES,
|
|
186
239
|
UNSTRUCTURED_SUPPORTED_MEDIA_TYPES,
|
|
187
|
-
aiGenerateInputFromSimplified
|
|
240
|
+
aiGenerateInputFromSimplified,
|
|
241
|
+
buildDefaultPersona
|
|
188
242
|
};
|