@seeed-studio/solution-cli 0.0.0-stage → 0.2.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.
@@ -0,0 +1,78 @@
1
+ # Deploy where there is no internet (offline package)
2
+
3
+ Prepare on a computer that has internet, deploy on site without it. The unit
4
+ is **step × target**: you can prepare one step only, or several device models
5
+ for the same step. The engine has no separate command for this; use
6
+ `sensecraft-engine api` (run `sensecraft-engine api --help` for the same notes).
7
+
8
+ Ask the user first: preparing downloads container images and files, which can
9
+ take several GB of disk space.
10
+
11
+ ## 1. Plan: what is needed, what is already here
12
+
13
+ Write the request to a file, e.g. `./.sensecraft-work/plan.json`:
14
+
15
+ ```json
16
+ {
17
+ "solution_id": "<id>",
18
+ "preset_id": "<preset>",
19
+ "targets": {"<step_id>": "<target_id>"},
20
+ "arch": {"<step_id>": "aarch64"},
21
+ "params": {"username": "<the username the deploy will use>"},
22
+ "lang": "en"
23
+ }
24
+ ```
25
+
26
+ - `targets`: only the steps listed are prepared; leave it out for every step.
27
+ - `arch`: needed when the target names no device type (`aarch64` for
28
+ ARM boards such as Jetson, Raspberry Pi, RK3588).
29
+ - `params`: **the same connection values the later deploy will use** (from
30
+ `deploy-info`'s `request_template`, e.g. `username`). The package records
31
+ them; a deploy with different values is refused before anything runs on the
32
+ device (`the offline package was prepared with different values: ...`), and
33
+ you have to plan and prepare again with the right `params`.
34
+
35
+ ```
36
+ sensecraft-engine api POST /api/staging/plan --data "$(cat ./.sensecraft-work/plan.json)"
37
+ ```
38
+
39
+ The response lists each item and whether it is already here. Items marked
40
+ `partial` still need internet on site (for example a model the container
41
+ downloads at start); tell the user which.
42
+
43
+ ## 2. Prepare: download it here
44
+
45
+ ```
46
+ sensecraft-engine api POST /api/staging/prepare --data "$(cat ./.sensecraft-work/plan.json)"
47
+ sensecraft-engine api GET /api/staging/jobs/<id> # repeat every 5–10 s until status is not "running"
48
+ ```
49
+
50
+ `prepare` returns a job with `id` and `status: running`. Cancel it with
51
+ `sensecraft-engine api POST /api/staging/jobs/<id>/cancel`.
52
+
53
+ ## 3. Check, carry, clean up
54
+
55
+ ```
56
+ sensecraft-engine api GET /api/staging/entries # what is prepared
57
+ sensecraft-engine api POST /api/staging/export --data '{"path": "/path/kit.tar"}' # pack it
58
+ sensecraft-engine api POST /api/staging/import --data '{"path": "/path/kit.tar"}' # on the deploying computer
59
+ ```
60
+
61
+ Deleting prepared entries (`POST /api/staging/entries/delete`) frees disk space;
62
+ ask the user first.
63
+
64
+ ## 4. Deploy on site
65
+
66
+ Deploy as in `deploy.md`, with `"force_offline": true` in the step's
67
+ connection:
68
+
69
+ ```json
70
+ "device_connections": {
71
+ "<step_id>": {"target": "<target_id>", "target_type": "remote",
72
+ "host": "<ip>", "username": "<same as params>",
73
+ "password": "<password>", "force_offline": true}
74
+ }
75
+ ```
76
+
77
+ The engine checks the offline package before connecting to the device and
78
+ stops with a list of what is missing.
@@ -0,0 +1,136 @@
1
+ # Finish a `verify_required` step
2
+
3
+ The engine does not run verification steps that need a person or a browser.
4
+ When a deployment reaches one, it writes a `verify_required` event to the
5
+ deployment's log, marks that step `step_skipped` (`reason: verify_required`)
6
+ and carries on. Read the events with
7
+ `sensecraft-engine logs <deployment_id> --since <N>`.
8
+
9
+ Fields every `verify_required` event has:
10
+
11
+ | Field | Content |
12
+ |---|---|
13
+ | `device_id` / `step_id` | The step |
14
+ | `kind` | The step type (`web_dashboard`, `serial_camera`, `serial_wizard`, `robot_inspect`, `preview`, `image_predict`, ...) |
15
+ | `name`, `required` | Display name; whether the solution counts it as required |
16
+ | `url`, `endpoint` | Where to check, with `{{host}}` already filled in (may be null) |
17
+ | `sample_request` | Request to send to `endpoint`: `{method, url, headers?, content_type?, file_field?, body?, curl}`, `curl` being a ready command line (may be null) |
18
+ | `mode` | Steps with several check modes: the mode the event describes (the step's default) |
19
+ | `instructions` | What to check, in the solution's words |
20
+ | `expected_status` | `web_dashboard` only: 200 |
21
+
22
+ Steps for hardware sessions add `port` / `db_port` / `host` (filled from the
23
+ step that flashed or deployed the device; null when the connection did not
24
+ include it), `commands {...}` with the exact CLI commands, and `confirm`
25
+ (how to tell it worked). `deploy-info` lists the same commands in advance as
26
+ `counting_cli`, `face_cli`, `wizard_cli` or `robot_cli` on that step.
27
+
28
+ General rules:
29
+
30
+ - Replace `<PORT>`, `<DB_PORT>`, `<HOST>` in `commands` with the event's `port`,
31
+ `db_port`, `host`. If one is null, take it from the connection you gave the
32
+ step named in `port_from_device` / `db_port_from_device` /
33
+ `host_from_device`, or ask the user (`sensecraft-engine device ports` lists
34
+ serial ports).
35
+ - Anything a person must do with their hands — plugging a cable, connecting a
36
+ servo, sitting in front of a camera, walking past it, standing clear of a
37
+ robot arm — is the user's job. Say exactly what to do, then **wait for the
38
+ user to confirm** before running the next command.
39
+ - These commands print a JSON result on stdout. Exit codes: 0 confirmed by the
40
+ device; 1 the device did not confirm (timeout, error, read-back mismatch);
41
+ 2 bad arguments; 3 port busy or cannot be opened, or (robot) the status
42
+ service is unreachable; 5 internal error. On 3 with `port_busy`, another
43
+ deployment or session holds the port: wait for it, do not force it.
44
+ - At most 3 rounds per problem, as in `SKILL.md`.
45
+
46
+ ## 1. Dashboards and interactive checks (`web_dashboard`, `preview`, `image_predict`, `text_chat`, `voice_chat`, ...)
47
+
48
+ - `web_dashboard`: `curl -s -o /dev/null -w "%{http_code}" <url>` must return
49
+ `expected_status` (200). Then give the user the `url` to open.
50
+ - `endpoint` + `sample_request` present: run `sample_request.curl` and show
51
+ the user the relevant part of the response. In a multipart request
52
+ (`-F <file_field>=@IMAGE.jpg`) replace `IMAGE.jpg` with a real picture
53
+ (a photo the user gave you, or one downloaded into `./.sensecraft-work/`);
54
+ a JSON response with results (for example detections with labels and
55
+ scores, possibly an empty list for a picture without matching objects)
56
+ means the service works. An HTTP error or no answer goes to `diagnose.md`.
57
+ These events also come for verify steps that only describe a check in the
58
+ guide (no separate config file), with the default mode's endpoint.
59
+ - Otherwise follow `instructions`. When they say to run the check in the
60
+ SenseCraft Solution app, tell the user: that check needs the desktop app.
61
+
62
+ ## 2. People counting lines (`serial_camera` with `counting_cli`)
63
+
64
+ 1. Ask the user where the counting lines / zones should be, in camera
65
+ coordinates 0–1000 (0,0 top left, 1000,1000 bottom right): a line is two
66
+ points `X1,Y1,X2,Y2`, a zone four corners. Direction: crossing from the
67
+ right side of the line (looking from point 1 to point 2) to the left counts
68
+ as `in`; swap the two points to reverse it.
69
+ 2. Write them:
70
+ `sensecraft-engine counting set --port <PORT> --line 0=100,500,900,500 [--roi 1=X1,Y1,...,X4,Y4] [--anchor-mode foot]`
71
+ (`foot` for a camera tilted down from above, `center` otherwise). The result
72
+ must have `verified: true`; `mismatches[]` lists slots that read back
73
+ differently.
74
+ 3. Start counting from zero and keep the camera running:
75
+ `sensecraft-engine counting reset --port <PORT> --keep-running`.
76
+ 4. Ask the user to walk across each line (and into each zone) and tell you when
77
+ done.
78
+ 5. `sensecraft-engine counting get --port <PORT>`: each line's `in` / `out` and
79
+ each zone's `cur` / `entered` must have changed as expected. Show the user.
80
+
81
+ ## 3. Face enrollment (`serial_camera` with `face_cli`, SenseCAP Watcher)
82
+
83
+ The Watcher has two USB serial ports: the camera (`--port`) and the face
84
+ database (`--db-port`).
85
+
86
+ 1. Ask the user whose face to enroll (name: ASCII up to 31 characters, Chinese
87
+ up to 4 characters).
88
+ 2. Ask that person to sit in front of the camera, facing it, and to tell you
89
+ when ready.
90
+ 3. `sensecraft-engine face enroll --port <PORT> --db-port <DB_PORT> --name <NAME> --no-prompt`.
91
+ Success: `stored: true`, `verified: true`. Too few samples
92
+ (`samples_collected` below the minimum): ask for better light / a closer,
93
+ straight-on face, then run it again.
94
+ 4. `sensecraft-engine face list --db-port <DB_PORT>` and show the names to the
95
+ user. Fix mistakes with `face rename --db-port <DB_PORT> --name OLD --new-name NEW`
96
+ or `face delete --db-port <DB_PORT> --name NAME` (deleting needs the user's OK).
97
+ 5. Ask an enrolled person to stand in front of the camera and confirm the
98
+ device recognizes them by name.
99
+
100
+ ## 4. Servo ID setup (`serial_wizard` with `wizard_cli`)
101
+
102
+ The firmware sets one servo ID at a time and prints prompts.
103
+
104
+ 1. Tell the user to connect **only** the servo for the current ID (the
105
+ event's `instructions` name them, e.g. ID 1 front wheel, 2 left rear, 3 right
106
+ rear) and to confirm.
107
+ 2. `sensecraft-engine wizard action --port <PORT> --name enter`. Pass the
108
+ firmware's `prompt` text on to the user.
109
+ 3. `step_error` set: ask the user to check the wiring, then
110
+ `sensecraft-engine wizard action --port <PORT> --name retry`.
111
+ 4. Repeat for each servo until the result has `step_done: true`
112
+ (`wizard read --port <PORT> --until done` waits for it). Then ask the user
113
+ to power off, connect all servos and power on again.
114
+
115
+ ## 5. Robot arm check (`robot_inspect` with `robot_cli`)
116
+
117
+ Commands that move the arm need the user's OK each time.
118
+
119
+ 1. `sensecraft-engine robot observe --host <HOST>`: every joint has a value.
120
+ 2. Ask the user's OK, then `robot torque off --host <HOST>`; ask the user to
121
+ turn one joint by hand; `robot observe` again — the reading must follow.
122
+ Show the user the numbers.
123
+ 3. Recording a motion: for each pose the user sets by hand, run `robot observe`
124
+ and add the `observation` to a frame file
125
+ (`[{"joints": {...}, "delay": 0.4}, ...]`).
126
+ 4. Before `robot actions test --host <HOST> --frames <file>`, ask the user to
127
+ stand clear of the arm and confirm. Afterwards ask whether the motion was
128
+ right.
129
+ 5. Only after the user approves it:
130
+ `robot actions save --host <HOST> --name <name> --frames <file>`.
131
+ `robot actions cancel --host <HOST>` stops a running motion.
132
+
133
+ ## 6. Report
134
+
135
+ For each verify step tell the user: what you checked, the command result
136
+ (the relevant fields, not the whole JSON), and anything left for them to do.