@amaster.ai/runtime-cli 1.1.7 → 1.1.8

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/README.md CHANGED
@@ -1,15 +1,17 @@
1
1
  # @amaster.ai/runtime-cli
2
2
 
3
- Unified CLI for Amaster SDK and OpenClaw integration. Manage entities, BPM processes, workflows, S3 files, authentication, and OpenClaw skills from a single command-line interface.
3
+ CLI for Amaster SDK - Multi-app support for OpenClaw. Manage multiple Amaster applications, entities, BPM processes, workflows, and S3 files from a single command-line interface.
4
4
 
5
5
  ## Features
6
6
 
7
- - **Authentication**: Login, logout, register users, manage sessions
8
- - **Entity Management**: CRUD operations on entities with type-safe API
7
+ - **Multi-App Support**: Manage multiple Amaster applications simultaneously
8
+ - **Authentication**: Login/logout with per-app token storage
9
+ - **Structured Output**: `json`, `pretty`, `table`, `ndjson`, and `csv`
10
+ - **Entity Management**: CRUD, options lookup, and bulk operations on entities
9
11
  - **BPM**: Manage Camunda processes, tasks, and instances
10
12
  - **Workflow**: Execute and monitor workflows
11
13
  - **S3 Storage**: Upload, download, list, and manage files
12
- - **OpenClaw Integration**: Initialize app-specific skills and MCP servers for AI assistants
14
+ - **OpenClaw Integration**: Initialize app-specific skills and MCP servers
13
15
 
14
16
  ## Installation
15
17
 
@@ -25,11 +27,11 @@ npx @amaster.ai/runtime-cli
25
27
 
26
28
  ### Automatic Cleanup
27
29
 
28
- When you uninstall `@amaster.ai/runtime-cli`, it will automatically clean up the OpenClaw integration for the configured app:
30
+ When you uninstall `@amaster.ai/runtime-cli`, it will automatically clean up:
29
31
 
30
32
  ```bash
31
33
  npm uninstall -g @amaster.ai/runtime-cli
32
- # Automatically removes skills and MCP servers
34
+ # Automatically removes auth sessions
33
35
  ```
34
36
 
35
37
  To skip automatic cleanup:
@@ -40,206 +42,394 @@ npm_config_ignore_scripts=1 npm uninstall -g @amaster.ai/runtime-cli
40
42
 
41
43
  ## Quick Start
42
44
 
43
- ### 1. Configure the CLI
45
+ ### 1. Initialize an App
44
46
 
45
47
  ```bash
46
- # Set your API key
47
- amaster config set apiKey YOUR_API_KEY
48
+ # Initialize a new app
49
+ amaster init --app-code myapp --url https://myapp.helige.cn
48
50
 
49
- # Set base URL (optional, defaults to https://api.amaster.ai)
50
- amaster config set baseURL https://api.amaster.ai
51
+ # With API key for OSS access
52
+ amaster init --app-code myapp --url https://myapp.helige.cn --api-key YOUR_API_KEY
53
+ ```
54
+
55
+ ### 2. Set Default App (Optional)
51
56
 
52
- # View configuration
53
- amaster config list
57
+ ```bash
58
+ # Set default app for subsequent commands
59
+ amaster use myapp
60
+
61
+ # List all configured apps
62
+ amaster apps
54
63
  ```
55
64
 
56
- ### 2. Authenticate
65
+ ### 3. Authenticate
57
66
 
58
67
  ```bash
59
- # Login
60
- amaster login
68
+ # Login (interactive - will prompt for username/email and password)
69
+ amaster login --app myapp
61
70
 
62
- # Or with options
63
- amaster login --email user@example.com --password secret
71
+ # Login with email
72
+ amaster login --app myapp -e user@example.com -p secret
64
73
 
65
- # Check who you are
66
- amaster whoami
74
+ # Login with username
75
+ amaster login --app myapp -u admin -p secret
76
+
77
+ # Check current user
78
+ amaster whoami --app myapp
79
+
80
+ # Logout
81
+ amaster logout --app myapp
67
82
  ```
68
83
 
69
- ### 3. Use SDK Features
84
+ ### 4. Use SDK Features
70
85
 
71
86
  ```bash
72
- # List entities
73
- amaster entity list myapp users
87
+ # List entities - full JSON output (default)
88
+ amaster entity list default products --app myapp
74
89
 
75
- # Get a specific entity
76
- amaster entity get myapp users 123
90
+ # Human-friendly output
91
+ amaster entity list default products --app myapp --format pretty
77
92
 
78
- # Create an entity
79
- amaster entity create myapp users --data '{"name":"John","email":"john@example.com"}'
93
+ # Table output
94
+ amaster entity list default products --app myapp --format table
80
95
 
81
- # List BPM processes
82
- amaster bpm processes
96
+ # Newline-delimited JSON
97
+ amaster entity list default products --app myapp --format ndjson
83
98
 
84
- # Start a process
85
- amaster bpm start my-process --variables '{"key":"value"}'
99
+ # CSV output
100
+ amaster entity list default products --app myapp --format csv
86
101
 
87
- # List workflows
88
- amaster workflow list
102
+ # List entities with pagination
103
+ amaster entity list default products --app myapp --page 1 --page-size 10
89
104
 
90
- # Execute a workflow
91
- amaster workflow execute my-workflow --input '{"data":"value"}'
105
+ # List entities with explicit query params
106
+ amaster entity list default products --app myapp \
107
+ --fields id,name,price \
108
+ --relations category \
109
+ --order-by created_at \
110
+ --order-dir desc
92
111
 
93
- # List S3 files
94
- amaster s3 list
112
+ # Multi-order sorting
113
+ amaster entity list default products --app myapp \
114
+ --orders created_at:desc,name:asc
95
115
 
96
- # Upload a file
97
- amaster s3 upload ./myfile.pdf --bucket mybucket --key documents/myfile.pdf
98
- ```
116
+ # Keyword search in specific fields
117
+ amaster entity list default products --app myapp \
118
+ --keyword keyboard \
119
+ --keyword-fields name,description
99
120
 
100
- ### 4. Setup OpenClaw Integration
121
+ # Advanced filter via JSON or @file
122
+ amaster entity list default products --app myapp \
123
+ --filter '{"conjunction":"and","children":[]}'
101
124
 
102
- Initialize OpenClaw integration for a specific app (downloads app-specific skills and MCP servers):
125
+ # Offset/limit pagination
126
+ amaster entity list default products --app myapp --limit 20 --offset 40
103
127
 
104
- ```bash
105
- # Initialize for an app
106
- amaster init --app-code myapp
128
+ # Raw query escape hatch for any remaining EntityQueryParams
129
+ amaster entity list default products --app myapp \
130
+ --query '{"status":"active","orderBy":"created_at","orderDir":"desc"}'
107
131
 
108
- # With API key
109
- amaster init --app-code myapp --api-key YOUR_API_KEY
132
+ # Get a specific entity
133
+ amaster entity get default products 123 --app myapp
110
134
 
111
- # Force reinitialize
112
- amaster init --app-code myapp --force
113
- ```
135
+ # Create from inline JSON
136
+ amaster entity create default products --app myapp \
137
+ --data '{"name":"Mechanical Keyboard","price":399}'
114
138
 
115
- Check integration status:
139
+ # Create from @file
140
+ amaster entity create default products --app myapp \
141
+ --data @./product-create.json
116
142
 
117
- ```bash
118
- amaster doctor
119
- ```
143
+ # Update from inline JSON
144
+ amaster entity update default products 123 --app myapp \
145
+ --data '{"price":499}'
120
146
 
121
- List installed components:
147
+ # Update from @file
148
+ amaster entity update default products 123 --app myapp \
149
+ --data @./product-update.json
122
150
 
123
- ```bash
124
- amaster list
151
+ # Delete by ID
152
+ amaster entity delete default products 123 --app myapp
153
+
154
+ # Get select options with selected fields
155
+ amaster entity options default categories --app myapp --fields id,name
156
+
157
+ # Bulk update from inline JSON
158
+ amaster entity bulk-update default products --app myapp \
159
+ --items '[{"id":1,"status":"active"},{"id":2,"status":"inactive"}]'
160
+
161
+ # Bulk update from @file
162
+ amaster entity bulk-update default products --app myapp \
163
+ --items @./products-bulk-update.json
164
+
165
+ # Bulk delete by comma-separated IDs
166
+ amaster entity bulk-delete default products --app myapp --ids 1,2,3
167
+
168
+ # Bulk delete by JSON array
169
+ amaster entity bulk-delete default products --app myapp --ids '[1,2,3]'
125
170
  ```
126
171
 
127
- Switch to a different app:
172
+ For `amaster entity list`, explicit options such as `--fields`, `--relations`, and `--order-by` override the same keys inside `--query`.
173
+
174
+ ## Commands
175
+
176
+ ### Output Formats
177
+
178
+ Most commands support:
128
179
 
129
180
  ```bash
130
- amaster switch another-app
181
+ --format json # Full JSON response (default)
182
+ --format pretty # Human-friendly output
183
+ --format table # Readable table
184
+ --format ndjson # Newline-delimited JSON
185
+ --format csv # Comma-separated values
131
186
  ```
132
187
 
133
- Remove integration for current app:
188
+ ### App Management
134
189
 
135
190
  ```bash
136
- amaster uninstall --yes
191
+ amaster apps # List all configured apps
192
+ amaster use <app-code> # Set the default app
137
193
  ```
138
194
 
139
- ## Commands
140
-
141
- ### Configuration
195
+ ### Initialization
142
196
 
143
197
  ```bash
144
- amaster config set <key> <value> # Set config value
145
- amaster config get <key> # Get config value
146
- amaster config list # List all config
198
+ amaster init # Initialize an app for OpenClaw
199
+ --app-code <code> # Required: Application code (e.g., bleulig7o)
200
+ --url <url> # Required: Base URL (e.g., https://app.helige.cn)
201
+ --api-key <key> # Optional: API Key for OSS access
202
+ --oss-endpoint <endpoint> # Optional: OSS endpoint
147
203
  ```
148
204
 
149
205
  ### Authentication
150
206
 
151
207
  ```bash
152
- amaster login [options] # Login with email/password
153
- amaster logout # Logout
154
- amaster whoami # Show current user
155
- amaster register [options] # Register new user
156
- amaster users [options] # List users
208
+ amaster login [options] # Login with username/email and password
209
+ --app <app-code> # App code (uses default if not specified)
210
+ -u, --username <username> # Username
211
+ -e, --email <email> # Email address
212
+ -p, --password <password> # Password
213
+
214
+ amaster logout [options] # Logout from an app
215
+ --app <app-code> # App code (uses default if not specified)
216
+
217
+ amaster whoami [options] # Show current user information
218
+ --app <app-code> # App code (uses default if not specified)
157
219
  ```
158
220
 
159
221
  ### Entity Management
160
222
 
161
223
  ```bash
162
- amaster entity list <app> <entity> [options]
163
- amaster entity get <app> <entity> <id>
164
- amaster entity create <app> <entity> [options]
165
- amaster entity update <app> <entity> <id> [options]
166
- amaster entity delete <app> <entity> <id>
167
- amaster entity types <app>
224
+ amaster entity list <namespace> <entity> [options]
225
+ --app <app-code> # App code (uses default if not specified)
226
+ --page <page> # Page number (default: 1)
227
+ --page-size <size> # Page size (default: 10)
228
+ -f, --fields <fields> # Comma-separated fields to return
229
+ -r, --relations <relations> # Comma-separated relations to load
230
+ -k, --keyword <keyword> # Keyword to search
231
+ --keyword-fields <fields> # Comma-separated fields for keyword search
232
+ --order-by <field> # Field to sort by
233
+ --order-dir <dir> # Sort direction: asc | desc
234
+ --orders <orders> # Multi-order expression
235
+ --filter <json> # Advanced __filter JSON or @file
236
+ --limit <limit> # Limit number of records
237
+ --offset <offset> # Offset number of records
238
+ -q, --query <json> # Additional EntityQueryParams as JSON or @file
239
+ --format <format> # json | pretty | table | ndjson | csv
240
+
241
+ amaster entity get <namespace> <entity> <id> [options]
242
+ --app <app-code> # App code (uses default if not specified)
243
+
244
+ amaster entity create <namespace> <entity> [options]
245
+ --app <app-code> # App code (uses default if not specified)
246
+ -d, --data <json> # Entity data as JSON or @file
247
+
248
+ amaster entity update <namespace> <entity> <id> [options]
249
+ --app <app-code> # App code (uses default if not specified)
250
+ -d, --data <json> # Entity data as JSON or @file
251
+
252
+ amaster entity delete <namespace> <entity> <id> [options]
253
+ --app <app-code> # App code (uses default if not specified)
254
+
255
+ amaster entity options <namespace> <entity> [options]
256
+ --app <app-code> # App code (uses default if not specified)
257
+ -f, --fields <fields> # Comma-separated fields to return
258
+
259
+ amaster entity bulk-update <namespace> <entity> [options]
260
+ --app <app-code> # App code (uses default if not specified)
261
+ -i, --items <json> # Items array as JSON or @file
262
+
263
+ amaster entity bulk-delete <namespace> <entity> [options]
264
+ --app <app-code> # App code (uses default if not specified)
265
+ --ids <ids> # Comma-separated IDs, JSON array, or @file
168
266
  ```
169
267
 
170
- ### BPM
268
+ #### Entity Parameter Examples
171
269
 
172
270
  ```bash
173
- amaster bpm processes # List process definitions
174
- amaster bpm start <key> [options] # Start process instance
175
- amaster bpm tasks [options] # List tasks
176
- amaster bpm complete <id> [options] # Complete task
177
- amaster bpm claim <id> [options] # Claim task
178
- amaster bpm instances # List process instances
179
- amaster bpm instance <id> # Get instance details
271
+ # --app
272
+ amaster entity list default products --app myapp
273
+
274
+ # --page
275
+ amaster entity list default products --app myapp --page 2
276
+
277
+ # --page-size
278
+ amaster entity list default products --app myapp --page-size 50
279
+
280
+ # --fields
281
+ amaster entity list default products --app myapp --fields id,name,price
282
+
283
+ # --relations
284
+ amaster entity list default products --app myapp --relations category,owner
285
+
286
+ # --keyword
287
+ amaster entity list default products --app myapp --keyword keyboard
288
+
289
+ # --keyword-fields
290
+ amaster entity list default products --app myapp \
291
+ --keyword keyboard \
292
+ --keyword-fields name,description
293
+
294
+ # --order-by
295
+ amaster entity list default products --app myapp --order-by created_at
296
+
297
+ # --order-dir
298
+ amaster entity list default products --app myapp \
299
+ --order-by created_at \
300
+ --order-dir desc
301
+
302
+ # --orders
303
+ amaster entity list default products --app myapp \
304
+ --orders created_at:desc,name:asc
305
+
306
+ # --filter
307
+ amaster entity list default products --app myapp \
308
+ --filter '{"conjunction":"and","children":[]}'
309
+
310
+ # --limit
311
+ amaster entity list default products --app myapp --limit 10
312
+
313
+ # --offset
314
+ amaster entity list default products --app myapp --offset 20
315
+
316
+ # --query
317
+ amaster entity list default products --app myapp \
318
+ --query '{"status":"active","price[ge]":100}'
319
+
320
+ # create --data
321
+ amaster entity create default products --app myapp \
322
+ --data '{"name":"Mechanical Keyboard","price":399}'
323
+
324
+ # update --data
325
+ amaster entity update default products 123 --app myapp \
326
+ --data '{"price":499}'
327
+
328
+ # options --fields
329
+ amaster entity options default categories --app myapp --fields id,name
330
+
331
+ # bulk-update --items
332
+ amaster entity bulk-update default products --app myapp \
333
+ --items '[{"id":1,"status":"active"}]'
334
+
335
+ # bulk-delete --ids
336
+ amaster entity bulk-delete default products --app myapp --ids 1,2,3
180
337
  ```
181
338
 
182
- ### Workflow
339
+ ### BPM (Business Process Management)
183
340
 
184
341
  ```bash
185
- amaster workflow list # List workflows
186
- amaster workflow get <id> # Get workflow details
187
- amaster workflow execute <id> [options]
188
- amaster workflow executions [options]
189
- amaster workflow execution <id>
342
+ amaster bpm processes [options] # List process definitions
343
+ --app <app-code> # App code (uses default if not specified)
344
+
345
+ amaster bpm start <key> [options] # Start a process instance
346
+ --app <app-code> # App code (uses default if not specified)
347
+ -v, --variables <json> # Process variables as JSON
348
+
349
+ amaster bpm tasks [options] # List tasks
350
+ --app <app-code> # App code (uses default if not specified)
351
+ -a, --assignee <assignee> # Filter by assignee
352
+
353
+ amaster bpm complete <id> [options] # Complete a task
354
+ --app <app-code> # App code (uses default if not specified)
355
+ -v, --variables <json> # Task variables as JSON
190
356
  ```
191
357
 
192
- ### S3 Storage
358
+ ### Workflow
193
359
 
194
360
  ```bash
195
- amaster s3 list [options] # List files
196
- amaster s3 upload <file> [options] # Upload file
197
- amaster s3 download <key> [options] # Download file
198
- amaster s3 delete <key> [options] # Delete file
199
- amaster s3 url <key> [options] # Get file URL
361
+ amaster workflow list [options] # List workflows
362
+ --app <app-code> # App code (uses default if not specified)
363
+
364
+ amaster workflow execute <id> [options] # Execute a workflow
365
+ --app <app-code> # App code (uses default if not specified)
366
+ -i, --input <json> # Workflow input as JSON
200
367
  ```
201
368
 
202
- ### OpenClaw Integration
369
+ ### S3 Storage
203
370
 
204
371
  ```bash
205
- amaster init [options] # Initialize integration for an app
206
- amaster doctor # Check integration status
207
- amaster list # List installed skills and MCP servers
208
- amaster switch <app-code> [options] # Switch to a different app
209
- amaster uninstall [options] # Remove integration for current app
372
+ amaster s3 list [options] # List files
373
+ --app <app-code> # App code (uses default if not specified)
374
+ -b, --bucket <bucket> # Bucket name
375
+
376
+ amaster s3 upload <file> [options] # Upload a file
377
+ --app <app-code> # App code (uses default if not specified)
378
+ -b, --bucket <bucket> # Bucket name
379
+ -k, --key <key> # Object key
210
380
  ```
211
381
 
212
382
  ## Configuration
213
383
 
214
- Configuration is stored in `~/.amaster/cli-config.json`.
384
+ Configuration files are stored in `~/.amaster/`:
215
385
 
216
- ### Environment Variables
386
+ ### File Locations
217
387
 
218
- - `AMASTER_API_KEY` - Your Amaster API key
219
- - `AMASTER_BASE_URL` - Base URL for API (default: https://api.amaster.ai)
388
+ - **App Config**: `~/.amaster/config.json`
389
+ ```json
390
+ {
391
+ "apps": {
392
+ "myapp": {
393
+ "baseURL": "https://myapp.helige.cn",
394
+ "initializedAt": "2025-03-26T..."
395
+ }
396
+ },
397
+ "currentApp": "myapp"
398
+ }
399
+ ```
400
+
401
+ - **Auth Sessions**: `~/.amaster/auth-{appCode}.json`
402
+ ```json
403
+ {
404
+ "accessToken": "...",
405
+ "refreshToken": "...",
406
+ "loggedInAt": "2025-03-26T...",
407
+ "expiresIn": 86400
408
+ }
409
+ ```
410
+
411
+ ## Multi-App Workflow
220
412
 
221
- ### File Locations
413
+ ```bash
414
+ # Initialize multiple apps
415
+ amaster init --app-code app1 --url https://app1.helige.cn
416
+ amaster init --app-code app2 --url https://app2.helige.cn
222
417
 
223
- - CLI Config: `~/.amaster/cli-config.json`
224
- - OpenClaw Config: `~/.openclaw/config.json`
225
- - Installed Skills: `~/.openclaw/skills/{appCode}/`
226
- - Amaster Config: `~/.amaster/openclaw-config.json`
418
+ # List all apps
419
+ amaster apps
227
420
 
228
- ## OSS Structure
421
+ # Work with app1 (explicit)
422
+ amaster entity list default products --app app1
229
423
 
230
- The CLI expects skills and MCP configurations to be organized by app code in OSS:
424
+ # Set app2 as default
425
+ amaster use app2
231
426
 
232
- ```
233
- /openclaw/
234
- ├── apps/
235
- │ ├── {appCode1}/
236
- │ │ ├── skills/
237
- │ │ │ ├── manifest.json # Skills manifest for this app
238
- │ │ │ └── {skill-id}.zip # Skill packages
239
- │ │ └── mcp-config.yaml # MCP server config for this app
240
- │ └── {appCode2}/
241
- │ ├── skills/
242
- │ └── mcp-config.yaml
427
+ # Now commands use app2 by default
428
+ amaster entity list default users # Uses app2
429
+ amaster whoami # Uses app2
430
+
431
+ # Override default for single command
432
+ amaster whoami --app app1 # Uses app1
243
433
  ```
244
434
 
245
435
  ## Development
@@ -256,6 +446,27 @@ pnpm run dev
256
446
 
257
447
  # Type check
258
448
  pnpm run type-check
449
+
450
+ # Run tests
451
+ pnpm test
452
+
453
+ # Run tests with coverage
454
+ pnpm test:coverage
455
+ ```
456
+
457
+ ## Testing Example
458
+
459
+ Using `bleulig7o` app as an example:
460
+
461
+ ```bash
462
+ # Login
463
+ amaster login --app bleulig7o -e admin@example.com -p Admin@123456
464
+
465
+ # View products
466
+ amaster entity list default products --app bleulig7o --page 1 --page-size 10
467
+
468
+ # Get specific product
469
+ amaster entity get default products 1 --app bleulig7o
259
470
  ```
260
471
 
261
472
  ## Architecture