@filsilva/helios-cli 0.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 (39) hide show
  1. package/README.md +171 -0
  2. package/bin/helios.js +34 -0
  3. package/dist/client/assets/HeliosSessionWorker.browser-BYYjDIKH.js +3 -0
  4. package/dist/client/assets/HeliosSessionWorker.browser-BYYjDIKH.js.map +1 -0
  5. package/dist/client/assets/d3force3dWorker-BKANL9of.js +2 -0
  6. package/dist/client/assets/d3force3dWorker-BKANL9of.js.map +1 -0
  7. package/dist/client/assets/index-CP7mSmLx.js +9530 -0
  8. package/dist/client/assets/index-CP7mSmLx.js.map +1 -0
  9. package/dist/client/assets/layoutWorker-Lc8iIdmf.js +2 -0
  10. package/dist/client/assets/layoutWorker-Lc8iIdmf.js.map +1 -0
  11. package/dist/client/index.html +27 -0
  12. package/package.json +40 -0
  13. package/skills/helios-cli/SKILL.md +118 -0
  14. package/skills/helios-cli/references/behaviors.md +47 -0
  15. package/skills/helios-cli/references/layouts.md +77 -0
  16. package/skills/helios-cli/references/mappers.md +119 -0
  17. package/skills/helios-cli/references/metrics.md +83 -0
  18. package/skills/helios-cli/references/networks.md +53 -0
  19. package/skills/helios-cli/references/persistence.md +136 -0
  20. package/skills/helios-cli/references/positions.md +63 -0
  21. package/skills/helios-cli/references/rendering-export.md +56 -0
  22. package/skills/helios-cli/references/rpc-methods.md +83 -0
  23. package/src/cli.js +488 -0
  24. package/src/client/index.html +27 -0
  25. package/src/client/main.js +2210 -0
  26. package/src/daemon/SessionDaemon.js +1065 -0
  27. package/src/daemon/entry.js +36 -0
  28. package/src/protocol/jsonl.js +88 -0
  29. package/src/shared/cliConfig.js +52 -0
  30. package/src/shared/fileSessionStore.js +202 -0
  31. package/src/shared/fs.js +59 -0
  32. package/src/shared/networkFormats.js +55 -0
  33. package/src/shared/networkInspect.js +81 -0
  34. package/src/shared/paths.js +43 -0
  35. package/src/shared/sessionClient.js +88 -0
  36. package/src/shared/sessionId.js +5 -0
  37. package/src/shared/sessionRegistry.js +53 -0
  38. package/src/shared/sessionSurfaces.js +199 -0
  39. package/vite.config.js +47 -0
@@ -0,0 +1,53 @@
1
+ # Networks
2
+
3
+ The CLI works with Helios portable network formats:
4
+
5
+ - `.bxnet`
6
+ - `.zxnet`
7
+ - `.xnet`
8
+
9
+ The daemon infers format from file extension when `format` is omitted.
10
+
11
+ ## Start With A File
12
+
13
+ ```sh
14
+ helios session start --renderer webgpu --network ./graph.bxnet
15
+ ```
16
+
17
+ ## Load Or Replace In A Running Session
18
+
19
+ ```sh
20
+ helios call "$SESSION" network.load --json '{"path":"./graph.xnet"}'
21
+ ```
22
+
23
+ or:
24
+
25
+ ```sh
26
+ helios call "$SESSION" network.replace --json '{"path":"./graph.bxnet","options":{"keepCamera":false}}'
27
+ ```
28
+
29
+ ## Synthetic Network
30
+
31
+ Synthetic networks are useful for smoke tests when no dataset is available:
32
+
33
+ ```sh
34
+ helios call "$SESSION" network.replace --json '{
35
+ "synthetic": {
36
+ "nodeCount": 1000,
37
+ "mode": "2d",
38
+ "layout": "gpu-force"
39
+ }
40
+ }'
41
+ ```
42
+
43
+ ## Save
44
+
45
+ ```sh
46
+ helios call "$SESSION" network.save --json '{"format":"bxnet","outputPath":"./out.bxnet"}'
47
+ ```
48
+
49
+ When `outputPath` is omitted, the response contains a base64 payload.
50
+
51
+ ## WASM Buffer Rule
52
+
53
+ When writing code that creates Helios networks before loading them into the CLI, allocate first and take WASM-backed typed-array views second. Use `withBufferAccess(...)` for direct buffer writes so allocation-prone calls cannot silently invalidate views.
@@ -0,0 +1,136 @@
1
+ # Persistence
2
+
3
+ Helios CLI sessions persist sparse overrides and a readable change journal through `helios.states` and `helios.storage`. The CLI daemon owns durable storage; browser localStorage and IndexedDB are not used for CLI session persistence. The CLI mirrors sparse runtime state for agents:
4
+
5
+ ```text
6
+ ~/.helios/runtime/session-state/<sessionId>.json
7
+ ```
8
+
9
+ Durable session records live under `~/.helios/sessions`. Session envelopes are JSON, network side records are saved as `.zxnet`/`.bxnet`/`.xnet`, and position side records are saved as binary files. Use `--storage-dir <path>` or `HELIOS_CLI_STORAGE_DIR` for another root.
10
+
11
+ The persistence id is the raw CLI session id:
12
+
13
+ ```text
14
+ <sessionId>
15
+ ```
16
+
17
+ ## Automatic Saves And Journaling
18
+
19
+ State writes are recorded with `source: "cli"` before the response is returned. Manual UI changes are recorded with `source: "ui"` when the underlying Helios behavior emits a durable state change.
20
+
21
+ Runtime events also schedule lightweight saves:
22
+
23
+ - behavior, mode, filter, camera, mapper, and layout changes schedule sparse override snapshots
24
+ - page unload attempts a final lightweight storage flush
25
+
26
+ Read changes since the last agent checkpoint:
27
+
28
+ ```sh
29
+ helios call <sessionId> persistence.changes
30
+ ```
31
+
32
+ Read all recent CLI-origin changes:
33
+
34
+ ```sh
35
+ helios call <sessionId> persistence.changes --json '{"source":"cli","sinceCheckpoint":false,"limit":25}'
36
+ ```
37
+
38
+ Mark the current journal position as seen by the agent:
39
+
40
+ ```sh
41
+ helios call <sessionId> persistence.checkpoint
42
+ ```
43
+
44
+ Inspect sparse overrides and dirty state:
45
+
46
+ ```sh
47
+ helios state get <sessionId>
48
+ helios state set <sessionId> appearance.shaded.enabled true
49
+ helios state reset <sessionId> appearance.shaded.enabled
50
+ helios call <sessionId> persistence.overrides
51
+ helios call <sessionId> persistence.status
52
+ helios session state <sessionId>
53
+ ```
54
+
55
+ Reset a single override or a section:
56
+
57
+ ```sh
58
+ helios call <sessionId> persistence.reset --json '{"path":"appearance.nodeStyle.sizeScale"}'
59
+ helios call <sessionId> persistence.reset --json '{"scope":"appearance.nodeStyle"}'
60
+ ```
61
+
62
+ ## Manual Save
63
+
64
+ Use `persistence.save` before reloads, screenshots, handoff points, or multi-step workflows where recovering exactly the current state matters:
65
+
66
+ ```sh
67
+ helios call <sessionId> persistence.save --json '{"fullSession":true}'
68
+ ```
69
+
70
+ `fullSession: true` writes the network plus sparse visualization state through CLI filesystem storage. `fullSession: false` writes only sparse overrides. To force `helios.storage` to flush pending state and optionally save the network blob:
71
+
72
+ ```sh
73
+ helios call <sessionId> persistence.flush --json '{"includeNetwork":true}'
74
+ ```
75
+
76
+ ## Reload Recovery
77
+
78
+ In a managed headed or headless browser session, reload the page and wait for the bridge to reconnect:
79
+
80
+ ```sh
81
+ helios call <sessionId> browser.reload
82
+ helios call <sessionId> scene.getState
83
+ ```
84
+
85
+ On page load, Web Next restores the active CLI session through the remote storage client backed by the daemon filesystem store. Reload recovery does not depend on browser storage.
86
+
87
+ ## Explicit Restore And Clear
88
+
89
+ Restore the current checkpoint without reloading:
90
+
91
+ ```sh
92
+ helios call <sessionId> persistence.restore
93
+ ```
94
+
95
+ Clear the saved CLI session:
96
+
97
+ ```sh
98
+ helios call <sessionId> persistence.clear
99
+ ```
100
+
101
+ Inspect the persistence id and storage status:
102
+
103
+ ```sh
104
+ helios call <sessionId> persistence.get
105
+ ```
106
+
107
+ ## Daemon Storage API
108
+
109
+ Managed and server sessions expose the remote storage API used by the browser client:
110
+
111
+ ```text
112
+ GET /api/storage/sessions
113
+ POST /api/storage/session
114
+ GET /api/storage/session/<id>
115
+ DELETE /api/storage/session/<id>
116
+ GET /api/storage/unfinished?workspaceId=<workspaceId>
117
+ PUT /api/storage/unfinished
118
+ ```
119
+
120
+ The API is loopback-only with the session daemon and writes into the active storage root. It stores normal session envelopes under `sessions/records`, network side records under `sessions/networks`, and position side records under `sessions/positions`.
121
+
122
+ Use server mode plus `--storage-dir` for fast persistence API checks that do not need a browser bridge:
123
+
124
+ ```sh
125
+ helios --storage-dir /tmp/helios-store session start --mode server
126
+ ```
127
+
128
+ ## What Persists
129
+
130
+ Sparse overrides cover changed values only, using stable paths such as `appearance.nodeStyle.sizeScale`, `appearance.shaded.enabled`, `layout.parameters.outputScale`, and `mappers.node.channels.color`. Full checkpoints additionally cover the network data, mode, camera, layout and behavior state, mapper descriptors, filters, density, labels, legends, and other Helios Web visualization state exposed by `serializeVisualizationState`.
131
+
132
+ Layout runtime is persisted separately from sparse overrides. It captures current positions from the active source, including delegate-backed and GPU-force layouts, plus layout type, run state, temperature/alpha, center, and encoded positions. Restore writes positions back to the active delegate when possible and mirrors them to the hidden network position attribute so interpolation, renderer buffers, and saved files agree.
133
+
134
+ When saving a network with visualization state, Helios stores sparse config and layout runtime in the graph-private `_helios_visualization_state` attribute and mirrors current positions in the node-private `_helios_visuals_position` attribute. The private convention is the leading underscore.
135
+
136
+ For function-backed mappers and custom code descriptors, persist the descriptor source that created them. A browser reload can restore function-like mapper descriptors that are serializable, but external closures or runtime-only JavaScript objects cannot be reconstructed from storage.
@@ -0,0 +1,63 @@
1
+ # Positions
2
+
3
+ Inspect the active position source:
4
+
5
+ ```sh
6
+ helios call "$SESSION" positions.get
7
+ ```
8
+
9
+ Snapshot positions. Delegate-backed GPU layouts are read back when possible:
10
+
11
+ ```sh
12
+ helios call "$SESSION" positions.snapshot --json '{"limit":10}'
13
+ ```
14
+
15
+ ## Set Custom Positions
16
+
17
+ Write explicit 3D positions into `_helios_visuals_position` and apply them:
18
+
19
+ ```sh
20
+ helios call "$SESSION" positions.set --json '{
21
+ "values": [[0, 0, 0], [10, 5, 0], [20, 10, 0]],
22
+ "dimension": 3,
23
+ "stopLayout": true
24
+ }'
25
+ ```
26
+
27
+ For large arrays, use a flat array and set `dimension`:
28
+
29
+ ```sh
30
+ helios call "$SESSION" positions.set --json '{
31
+ "values": [0, 0, 0, 10, 5, 0, 20, 10, 0],
32
+ "dimension": 3,
33
+ "indexBy": "auto"
34
+ }'
35
+ ```
36
+
37
+ ## Build Positions From Code
38
+
39
+ Create a position attribute using a JS-like callback, then apply it:
40
+
41
+ ```sh
42
+ helios call "$SESSION" network.attributeSet --json '{
43
+ "scope": "node",
44
+ "name": "agent_position",
45
+ "functionCode": "return [ordinal * 2, Math.sin(ordinal / 10) * 50, 0];",
46
+ "options": { "type": "float", "dimension": 3 }
47
+ }'
48
+
49
+ helios call "$SESSION" positions.fromAttribute --json '{
50
+ "attribute": "agent_position",
51
+ "stopLayout": true
52
+ }'
53
+ ```
54
+
55
+ ## Positions From Existing Attributes
56
+
57
+ Any numeric 2D or 3D node attribute can seed layout positions:
58
+
59
+ ```sh
60
+ helios call "$SESSION" positions.fromAttribute --json '{"attribute":"umap_position"}'
61
+ ```
62
+
63
+ Use `layout.start` after applying an attribute when the layout should continue from the custom seed.
@@ -0,0 +1,56 @@
1
+ # Rendering And Export
2
+
3
+ ## Session Modes
4
+
5
+ - `--mode headless`: managed bundled Chromium, suitable for automated tests and exports.
6
+ - default / `--mode server --open`: serves the client and opens the OS/default browser, suitable for interactive visual inspection.
7
+ - `--mode server --no-open`: serves the client and control socket without launching or opening a browser.
8
+ - `--mode headed`: managed visible bundled Chromium, intended only for Playwright-managed debugging.
9
+
10
+ Plain `helios session start` uses the platform browser opener instead of Playwright's bundled "Chrome for Testing". Managed browser sessions use Playwright's bundled Chromium by default. Add `--browser-channel chrome` only when you explicitly need an installed Chrome channel. UI-triggered downloads from managed sessions are copied to `~/Downloads` using the suggested filename.
11
+
12
+ Initialize the default managed browser once with:
13
+
14
+ ```sh
15
+ helios browser install
16
+ ```
17
+
18
+ This installs bundled Chromium. On Linux, use `helios browser install --with-deps` if system browser dependencies are missing.
19
+
20
+ ## Renderer
21
+
22
+ Use:
23
+
24
+ ```sh
25
+ helios session start --mode headless --renderer webgpu
26
+ ```
27
+
28
+ Renderer options:
29
+
30
+ - `webgpu`: require hardware WebGPU, except headless sessions may fall back to hardware WebGL2 when WebGPU is unavailable.
31
+ - `webgl`: require hardware WebGL2.
32
+ - `auto`: accept the initialized hardware backend.
33
+
34
+ By default, software-only rendering is rejected. Use `--no-gpu` only when explicitly acceptable for the task.
35
+
36
+ ## Figure Export
37
+
38
+ ```sh
39
+ helios call "$SESSION" export.figure --json '{
40
+ "format": "png",
41
+ "preset": "window",
42
+ "outputPath": "./figure.png"
43
+ }'
44
+ ```
45
+
46
+ Call `scene.getState` first to confirm renderer, camera, layout, filters, density, labels, legends, and mappers before exporting.
47
+
48
+ ## Events
49
+
50
+ Stream events while another process manipulates a session:
51
+
52
+ ```sh
53
+ helios events "$SESSION"
54
+ ```
55
+
56
+ Useful event types include `browser.console`, `browser.pageerror`, `browser.gpu`, `helios.layoutStart`, `helios.layoutStop`, `helios.cameraMove`, and `helios.networkReplaced`.
@@ -0,0 +1,83 @@
1
+ # RPC Methods
2
+
3
+ Call methods with:
4
+
5
+ ```sh
6
+ helios call <sessionId> <method> --json '<payload>'
7
+ ```
8
+
9
+ Omit `--json` when the method takes no payload.
10
+
11
+ ## Scene
12
+
13
+ - `scene.getState`: returns mode, renderer, network stats, camera, labels, legends, density, filter, layout, and mapper snapshots.
14
+ - `scene.requestRender`: requests a render and returns scene state.
15
+ - `scene.setMode`: payload `{ "mode": "2d" }` or `{ "mode": "3d" }`.
16
+
17
+ ## Network
18
+
19
+ - `network.stats`: returns node count, edge count, node attributes, and edge attributes.
20
+ - `network.load`: daemon-side file load. Payload `{ "path": "./graph.bxnet", "format": "bxnet" }`.
21
+ - `network.attributeSet`: writes node, edge, or network attributes. Supports scalar values, arrays, and `functionCode`.
22
+ - `network.replace`: accepts either a file payload like `network.load` or a synthetic descriptor:
23
+
24
+ ```json
25
+ {
26
+ "synthetic": {
27
+ "nodeCount": 500,
28
+ "mode": "2d",
29
+ "layout": "gpu-force"
30
+ }
31
+ }
32
+ ```
33
+
34
+ - `network.save`: payload `{ "format": "bxnet", "outputPath": "./out.bxnet" }`.
35
+
36
+ ## Camera
37
+
38
+ - `camera.getPose`: returns the current camera pose.
39
+ - `camera.setPose`: payload `{ "pose": { ... }, "options": { ... } }`.
40
+ - `camera.transition`: payload `{ "pose": { ... }, "options": { "durationMs": 750 } }`.
41
+ - `camera.frame`: payload can include `{ "animate": true, "durationMs": 500, "resetOrientation": true }`.
42
+ - `camera.controls`: reads controls with `{}` or patches controls, for example `{ "orbit": false, "autoFit": true }`.
43
+ - `camera.targetNodes`: get or set target nodes with `{ "nodeIndices": [1, 2, 3], "options": { "follow": true } }`.
44
+
45
+ ## Layout
46
+
47
+ - `layout.get`: returns current layout key, run state, and parameter descriptor.
48
+ - `layout.set`: payload `{ "layout": "gpu-force" }`, `{ "layout": "static" }`, `{ "layout": "d3force3d" }`, `{ "layout": "worker:jitter" }`, or `{ "layout": "worker:force3d" }`.
49
+ - `layout.setParameters`: patches writable parameters exposed by `layout.get`, for example `{ "outputScale": 7, "linkDistance": 1.2 }`.
50
+ - `layout.applyPositionAttribute`: copies a numeric 2D/3D node attribute into current layout positions.
51
+ - `layout.start`: starts layout execution.
52
+ - `layout.stop`: payload `{ "reason": "agent" }`.
53
+
54
+ ## Visual State
55
+
56
+ - `mappers.get`, `mappers.set`, `mappers.reset`
57
+ - `behaviors.get`, `behaviors.use`, `behaviors.update`, `behaviors.setEnabled`, `behaviors.detach`, `behaviors.restore`, `behaviors.call`
58
+ - `positions.get`, `positions.snapshot`, `positions.set`, `positions.fromAttribute`
59
+ - `filters.get`, `filters.set`, `filters.clear`
60
+ - `labels.get`, `labels.set`
61
+ - `legends.get`, `legends.set`
62
+ - `density.get`, `density.set`
63
+ - `metrics.measure`, `aesthetic.measure`: run graph/aesthetic measurements such as degree, strength, clustering, coreness, centralities, connected components, dimension, and Leiden.
64
+
65
+ ## Persistence
66
+
67
+ - `state.get`, `state.set`, `state.reset`: read, write, or reset Web Next tracked state paths through `helios.states` with CLI-origin writes.
68
+ - `persistence.get`: returns the CLI persistence id, storage status, and availability.
69
+ - `persistence.save`: payload can include `{ "fullSession": true, "networkFormat": "bxnet", "captureThumbnail": true }`. Full saves persist network data plus sparse visualization state and capture a PNG thumbnail by default; lightweight saves persist sparse overrides only and use throttled automatic thumbnail capture.
70
+ - `persistence.restore`: restores the current session checkpoint without reloading the page.
71
+ - `persistence.clear`: removes the CLI filesystem session checkpoint.
72
+ - `persistence.changes`: returns journal entries since the last checkpoint by default. Payload can include `{ "since": 12, "limit": 25, "source": "user", "sinceCheckpoint": false }`.
73
+ - `persistence.checkpoint`: marks changes through a sequence id as seen. Omit `seq` to checkpoint through the latest entry.
74
+ - `persistence.overrides`: returns sparse overrides and dirty state.
75
+ - `persistence.reset`: payload `{ "path": "appearance.nodeStyle.sizeScale" }` or `{ "scope": "appearance.nodeStyle" }`.
76
+ - `persistence.flush`: payload `{ "includeNetwork": true, "captureThumbnail": "auto" }` writes pending overrides and optionally network data if size limits allow. Use `captureThumbnail: false` to preserve the existing thumbnail or provide a `thumbnail` object with a `dataUrl`.
77
+ - `persistence.status`: returns session id, override counts, journal counts, dirty state, and network persistence status.
78
+ - `browser.reload`: reloads the managed browser page, waits for the Helios runtime and bridge to reconnect, then returns runtime and session metadata.
79
+
80
+ ## Picking And Export
81
+
82
+ - `picking.pick`: payload `{ "x": 400, "y": 300 }`.
83
+ - `export.figure`: payload `{ "format": "png", "preset": "window", "outputPath": "./figure.png" }`.