|
| 1 | +--- |
| 2 | +title: Agent Action |
| 3 | +description: Agent Action protocol schemas |
| 4 | +--- |
| 5 | + |
| 6 | +# Agent Action |
| 7 | + |
| 8 | +<Callout type="info"> |
| 9 | +**Source:** `packages/spec/src/ai/agent-action.zod.ts` |
| 10 | +</Callout> |
| 11 | + |
| 12 | +## TypeScript Usage |
| 13 | + |
| 14 | +```typescript |
| 15 | +import { AgentActionSchema, AgentActionResultSchema, AgentActionSequenceSchema, AgentActionSequenceResultSchema, ComponentActionParamsSchema, ComponentActionTypeSchema, DataActionParamsSchema, DataActionTypeSchema, FormActionParamsSchema, FormActionTypeSchema, IntentActionMappingSchema, NavigationActionParamsSchema, NavigationActionTypeSchema, UIActionTypeSchema, ViewActionParamsSchema, ViewActionTypeSchema, WorkflowActionParamsSchema, WorkflowActionTypeSchema } from '@objectstack/spec/ai'; |
| 16 | +import type { AgentAction, AgentActionResult, AgentActionSequence, AgentActionSequenceResult, ComponentActionParams, ComponentActionType, DataActionParams, DataActionType, FormActionParams, FormActionType, IntentActionMapping, NavigationActionParams, NavigationActionType, UIActionType, ViewActionParams, ViewActionType, WorkflowActionParams, WorkflowActionType } from '@objectstack/spec/ai'; |
| 17 | + |
| 18 | +// Validate data |
| 19 | +const result = AgentActionSchema.parse(data); |
| 20 | +``` |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## AgentAction |
| 25 | + |
| 26 | +### Properties |
| 27 | + |
| 28 | +| Property | Type | Required | Description | |
| 29 | +| :--- | :--- | :--- | :--- | |
| 30 | +| **id** | `string` | optional | Unique action ID | |
| 31 | +| **type** | `Enum<'navigate_to_object_list' \| 'navigate_to_object_form' \| 'navigate_to_record_detail' \| 'navigate_to_dashboard' \| 'navigate_to_report' \| 'navigate_to_app' \| 'navigate_back' \| 'navigate_home' \| 'open_tab' \| 'close_tab' \| 'change_view_mode' \| 'apply_filter' \| 'clear_filter' \| 'apply_sort' \| 'change_grouping' \| 'show_columns' \| 'expand_record' \| 'collapse_record' \| 'refresh_view' \| 'export_data' \| 'create_record' \| 'update_record' \| 'delete_record' \| 'fill_field' \| 'clear_field' \| 'submit_form' \| 'cancel_form' \| 'validate_form' \| 'save_draft' \| 'select_record' \| 'deselect_record' \| 'select_all' \| 'deselect_all' \| 'bulk_update' \| 'bulk_delete' \| 'bulk_export' \| 'trigger_flow' \| 'trigger_approval' \| 'trigger_webhook' \| 'run_report' \| 'send_email' \| 'send_notification' \| 'schedule_task' \| 'open_modal' \| 'close_modal' \| 'open_sidebar' \| 'close_sidebar' \| 'show_notification' \| 'hide_notification' \| 'open_dropdown' \| 'close_dropdown' \| 'toggle_section'>` | ✅ | Type of UI action to perform | |
| 32 | +| **params** | `object \| object \| object \| object \| object \| object` | ✅ | Action-specific parameters | |
| 33 | +| **requireConfirmation** | `boolean` | optional | Require user confirmation before executing | |
| 34 | +| **confirmationMessage** | `string` | optional | Message to show in confirmation dialog | |
| 35 | +| **successMessage** | `string` | optional | Message to show on success | |
| 36 | +| **onError** | `Enum<'retry' \| 'skip' \| 'abort'>` | optional | Error handling strategy | |
| 37 | +| **metadata** | `object` | optional | | |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## AgentActionResult |
| 42 | + |
| 43 | +### Properties |
| 44 | + |
| 45 | +| Property | Type | Required | Description | |
| 46 | +| :--- | :--- | :--- | :--- | |
| 47 | +| **actionId** | `string` | ✅ | ID of the executed action | |
| 48 | +| **status** | `Enum<'success' \| 'error' \| 'cancelled' \| 'pending'>` | ✅ | Execution status | |
| 49 | +| **data** | `any` | optional | Action result data | |
| 50 | +| **error** | `object` | optional | Error details if status is "error" | |
| 51 | +| **metadata** | `object` | optional | | |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## AgentActionSequence |
| 56 | + |
| 57 | +### Properties |
| 58 | + |
| 59 | +| Property | Type | Required | Description | |
| 60 | +| :--- | :--- | :--- | :--- | |
| 61 | +| **id** | `string` | optional | Unique sequence ID | |
| 62 | +| **actions** | `object[]` | ✅ | Ordered list of actions | |
| 63 | +| **mode** | `Enum<'sequential' \| 'parallel'>` | optional | Execution mode | |
| 64 | +| **stopOnError** | `boolean` | optional | Stop sequence on first error | |
| 65 | +| **atomic** | `boolean` | optional | Rollback all changes if any action fails | |
| 66 | +| **metadata** | `object` | optional | | |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## AgentActionSequenceResult |
| 71 | + |
| 72 | +### Properties |
| 73 | + |
| 74 | +| Property | Type | Required | Description | |
| 75 | +| :--- | :--- | :--- | :--- | |
| 76 | +| **sequenceId** | `string` | ✅ | ID of the executed sequence | |
| 77 | +| **status** | `Enum<'success' \| 'partial_success' \| 'error' \| 'cancelled'>` | ✅ | Overall execution status | |
| 78 | +| **results** | `object[]` | ✅ | Results for each action | |
| 79 | +| **summary** | `object` | ✅ | | |
| 80 | +| **metadata** | `object` | optional | | |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## ComponentActionParams |
| 85 | + |
| 86 | +### Properties |
| 87 | + |
| 88 | +| Property | Type | Required | Description | |
| 89 | +| :--- | :--- | :--- | :--- | |
| 90 | +| **componentId** | `string` | optional | Component ID | |
| 91 | +| **modalConfig** | `object` | optional | | |
| 92 | +| **notificationConfig** | `object` | optional | | |
| 93 | +| **sidebarConfig** | `object` | optional | | |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +## ComponentActionType |
| 98 | + |
| 99 | +### Allowed Values |
| 100 | + |
| 101 | +* `open_modal` |
| 102 | +* `close_modal` |
| 103 | +* `open_sidebar` |
| 104 | +* `close_sidebar` |
| 105 | +* `show_notification` |
| 106 | +* `hide_notification` |
| 107 | +* `open_dropdown` |
| 108 | +* `close_dropdown` |
| 109 | +* `toggle_section` |
| 110 | + |
| 111 | +--- |
| 112 | + |
| 113 | +## DataActionParams |
| 114 | + |
| 115 | +### Properties |
| 116 | + |
| 117 | +| Property | Type | Required | Description | |
| 118 | +| :--- | :--- | :--- | :--- | |
| 119 | +| **recordIds** | `string[]` | optional | Record IDs to select/operate on | |
| 120 | +| **filters** | `Record<string, any>` | optional | Filter for bulk operations | |
| 121 | +| **updateData** | `Record<string, any>` | optional | Data for bulk update | |
| 122 | +| **exportFormat** | `Enum<'csv' \| 'xlsx' \| 'pdf' \| 'json'>` | optional | | |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +## DataActionType |
| 127 | + |
| 128 | +### Allowed Values |
| 129 | + |
| 130 | +* `select_record` |
| 131 | +* `deselect_record` |
| 132 | +* `select_all` |
| 133 | +* `deselect_all` |
| 134 | +* `bulk_update` |
| 135 | +* `bulk_delete` |
| 136 | +* `bulk_export` |
| 137 | + |
| 138 | +--- |
| 139 | + |
| 140 | +## FormActionParams |
| 141 | + |
| 142 | +### Properties |
| 143 | + |
| 144 | +| Property | Type | Required | Description | |
| 145 | +| :--- | :--- | :--- | :--- | |
| 146 | +| **object** | `string` | optional | Object name | |
| 147 | +| **recordId** | `string` | optional | Record ID (for edit/delete) | |
| 148 | +| **fieldValues** | `Record<string, any>` | optional | Field name-value pairs | |
| 149 | +| **fieldName** | `string` | optional | Specific field to fill/clear | |
| 150 | +| **fieldValue** | `any` | optional | Value to set | |
| 151 | +| **validateOnly** | `boolean` | optional | Validate without saving | |
| 152 | + |
| 153 | +--- |
| 154 | + |
| 155 | +## FormActionType |
| 156 | + |
| 157 | +### Allowed Values |
| 158 | + |
| 159 | +* `create_record` |
| 160 | +* `update_record` |
| 161 | +* `delete_record` |
| 162 | +* `fill_field` |
| 163 | +* `clear_field` |
| 164 | +* `submit_form` |
| 165 | +* `cancel_form` |
| 166 | +* `validate_form` |
| 167 | +* `save_draft` |
| 168 | + |
| 169 | +--- |
| 170 | + |
| 171 | +## IntentActionMapping |
| 172 | + |
| 173 | +### Properties |
| 174 | + |
| 175 | +| Property | Type | Required | Description | |
| 176 | +| :--- | :--- | :--- | :--- | |
| 177 | +| **intent** | `string` | ✅ | Intent pattern (e.g., "open_new_record_form") | |
| 178 | +| **examples** | `string[]` | optional | Example user queries | |
| 179 | +| **actionTemplate** | `object` | ✅ | Action to execute | |
| 180 | +| **paramExtraction** | `Record<string, object>` | optional | Rules for extracting parameters from user input | |
| 181 | +| **minConfidence** | `number` | optional | Minimum confidence to execute | |
| 182 | + |
| 183 | +--- |
| 184 | + |
| 185 | +## NavigationActionParams |
| 186 | + |
| 187 | +### Properties |
| 188 | + |
| 189 | +| Property | Type | Required | Description | |
| 190 | +| :--- | :--- | :--- | :--- | |
| 191 | +| **object** | `string` | optional | Object name (for object-specific navigation) | |
| 192 | +| **recordId** | `string` | optional | Record ID (for detail page) | |
| 193 | +| **viewType** | `Enum<'list' \| 'form' \| 'detail' \| 'kanban' \| 'calendar' \| 'gantt'>` | optional | | |
| 194 | +| **dashboardId** | `string` | optional | Dashboard ID | |
| 195 | +| **reportId** | `string` | optional | Report ID | |
| 196 | +| **appName** | `string` | optional | App name | |
| 197 | +| **mode** | `Enum<'new' \| 'edit' \| 'view'>` | optional | Form mode | |
| 198 | +| **openInNewTab** | `boolean` | optional | Open in new tab | |
| 199 | + |
| 200 | +--- |
| 201 | + |
| 202 | +## NavigationActionType |
| 203 | + |
| 204 | +### Allowed Values |
| 205 | + |
| 206 | +* `navigate_to_object_list` |
| 207 | +* `navigate_to_object_form` |
| 208 | +* `navigate_to_record_detail` |
| 209 | +* `navigate_to_dashboard` |
| 210 | +* `navigate_to_report` |
| 211 | +* `navigate_to_app` |
| 212 | +* `navigate_back` |
| 213 | +* `navigate_home` |
| 214 | +* `open_tab` |
| 215 | +* `close_tab` |
| 216 | + |
| 217 | +--- |
| 218 | + |
| 219 | +## UIActionType |
| 220 | + |
| 221 | +### Allowed Values |
| 222 | + |
| 223 | +* `navigate_to_object_list` |
| 224 | +* `navigate_to_object_form` |
| 225 | +* `navigate_to_record_detail` |
| 226 | +* `navigate_to_dashboard` |
| 227 | +* `navigate_to_report` |
| 228 | +* `navigate_to_app` |
| 229 | +* `navigate_back` |
| 230 | +* `navigate_home` |
| 231 | +* `open_tab` |
| 232 | +* `close_tab` |
| 233 | +* `change_view_mode` |
| 234 | +* `apply_filter` |
| 235 | +* `clear_filter` |
| 236 | +* `apply_sort` |
| 237 | +* `change_grouping` |
| 238 | +* `show_columns` |
| 239 | +* `expand_record` |
| 240 | +* `collapse_record` |
| 241 | +* `refresh_view` |
| 242 | +* `export_data` |
| 243 | +* `create_record` |
| 244 | +* `update_record` |
| 245 | +* `delete_record` |
| 246 | +* `fill_field` |
| 247 | +* `clear_field` |
| 248 | +* `submit_form` |
| 249 | +* `cancel_form` |
| 250 | +* `validate_form` |
| 251 | +* `save_draft` |
| 252 | +* `select_record` |
| 253 | +* `deselect_record` |
| 254 | +* `select_all` |
| 255 | +* `deselect_all` |
| 256 | +* `bulk_update` |
| 257 | +* `bulk_delete` |
| 258 | +* `bulk_export` |
| 259 | +* `trigger_flow` |
| 260 | +* `trigger_approval` |
| 261 | +* `trigger_webhook` |
| 262 | +* `run_report` |
| 263 | +* `send_email` |
| 264 | +* `send_notification` |
| 265 | +* `schedule_task` |
| 266 | +* `open_modal` |
| 267 | +* `close_modal` |
| 268 | +* `open_sidebar` |
| 269 | +* `close_sidebar` |
| 270 | +* `show_notification` |
| 271 | +* `hide_notification` |
| 272 | +* `open_dropdown` |
| 273 | +* `close_dropdown` |
| 274 | +* `toggle_section` |
| 275 | + |
| 276 | +--- |
| 277 | + |
| 278 | +## ViewActionParams |
| 279 | + |
| 280 | +### Properties |
| 281 | + |
| 282 | +| Property | Type | Required | Description | |
| 283 | +| :--- | :--- | :--- | :--- | |
| 284 | +| **viewMode** | `Enum<'list' \| 'kanban' \| 'calendar' \| 'gantt' \| 'pivot'>` | optional | | |
| 285 | +| **filters** | `Record<string, any>` | optional | Filter conditions | |
| 286 | +| **sort** | `object[]` | optional | | |
| 287 | +| **groupBy** | `string` | optional | Field to group by | |
| 288 | +| **columns** | `string[]` | optional | Columns to show/hide | |
| 289 | +| **recordId** | `string` | optional | Record to expand/collapse | |
| 290 | +| **exportFormat** | `Enum<'csv' \| 'xlsx' \| 'pdf' \| 'json'>` | optional | | |
| 291 | + |
| 292 | +--- |
| 293 | + |
| 294 | +## ViewActionType |
| 295 | + |
| 296 | +### Allowed Values |
| 297 | + |
| 298 | +* `change_view_mode` |
| 299 | +* `apply_filter` |
| 300 | +* `clear_filter` |
| 301 | +* `apply_sort` |
| 302 | +* `change_grouping` |
| 303 | +* `show_columns` |
| 304 | +* `expand_record` |
| 305 | +* `collapse_record` |
| 306 | +* `refresh_view` |
| 307 | +* `export_data` |
| 308 | + |
| 309 | +--- |
| 310 | + |
| 311 | +## WorkflowActionParams |
| 312 | + |
| 313 | +### Properties |
| 314 | + |
| 315 | +| Property | Type | Required | Description | |
| 316 | +| :--- | :--- | :--- | :--- | |
| 317 | +| **flowName** | `string` | optional | Flow/workflow name | |
| 318 | +| **approvalProcessName** | `string` | optional | Approval process name | |
| 319 | +| **webhookUrl** | `string` | optional | Webhook URL | |
| 320 | +| **reportName** | `string` | optional | Report name | |
| 321 | +| **emailTemplate** | `string` | optional | Email template | |
| 322 | +| **recipients** | `string[]` | optional | Email recipients | |
| 323 | +| **subject** | `string` | optional | Email subject | |
| 324 | +| **message** | `string` | optional | Notification/email message | |
| 325 | +| **taskData** | `Record<string, any>` | optional | Task creation data | |
| 326 | +| **scheduleTime** | `string` | optional | Schedule time (ISO 8601) | |
| 327 | +| **contextData** | `Record<string, any>` | optional | Additional context data | |
| 328 | + |
| 329 | +--- |
| 330 | + |
| 331 | +## WorkflowActionType |
| 332 | + |
| 333 | +### Allowed Values |
| 334 | + |
| 335 | +* `trigger_flow` |
| 336 | +* `trigger_approval` |
| 337 | +* `trigger_webhook` |
| 338 | +* `run_report` |
| 339 | +* `send_email` |
| 340 | +* `send_notification` |
| 341 | +* `schedule_task` |
| 342 | + |
0 commit comments