@calimero-network/agent-skills 0.3.0 → 0.4.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/README.md +137 -17
- package/SKILL.md +31 -28
- package/package.json +1 -1
- package/scripts/install.js +3 -3
- package/scripts/test.js +6 -15
- package/skills/calimero-abi-codegen/SKILL.md +121 -22
- package/skills/calimero-abi-codegen/references/abi-format.md +3 -5
- package/skills/calimero-abi-codegen/references/generated-output.md +12 -4
- package/skills/calimero-abi-codegen/rules/schema-version.md +11 -4
- package/skills/calimero-abi-codegen/rules/unique-names.md +2 -6
- package/skills/calimero-client-js/SKILL.md +126 -31
- package/skills/calimero-client-js/references/auth.md +18 -10
- package/skills/calimero-client-js/references/rpc-calls.md +15 -21
- package/skills/calimero-client-js/references/sso.md +9 -9
- package/skills/calimero-client-js/references/websocket-events.md +73 -92
- package/skills/calimero-client-js/rules/camelcase-api.md +10 -7
- package/skills/calimero-client-js/rules/token-refresh.md +11 -11
- package/skills/calimero-client-py/SKILL.md +25 -13
- package/skills/calimero-client-py/references/api.md +41 -43
- package/skills/calimero-client-py/references/auth.md +7 -7
- package/skills/calimero-client-py/rules/async-usage.md +27 -31
- package/skills/calimero-client-py/rules/stable-node-name.md +7 -7
- package/skills/calimero-core/SKILL.md +135 -0
- package/skills/calimero-core/references/architecture.md +101 -0
- package/skills/calimero-core/references/jsonrpc-protocol.md +192 -0
- package/skills/calimero-core/references/namespaces-groups.md +94 -0
- package/skills/calimero-core/references/storage-types.md +118 -0
- package/skills/calimero-core/references/websocket-events.md +142 -0
- package/skills/calimero-core/rules/context-is-not-app.md +35 -0
- package/skills/calimero-core/rules/crdt-types-only.md +55 -0
- package/skills/calimero-desktop/SKILL.md +24 -19
- package/skills/calimero-desktop/references/sso-integration.md +2 -2
- package/skills/calimero-desktop/rules/sso-fallback.md +3 -2
- package/skills/calimero-merobox/SKILL.md +255 -28
- package/skills/calimero-merobox/references/ci-integration.md +3 -2
- package/skills/calimero-merobox/references/workflow-files.md +7 -5
- package/skills/calimero-merobox/rules/docker-required.md +7 -6
- package/skills/calimero-meroctl/SKILL.md +68 -0
- package/skills/calimero-meroctl/references/commands.md +177 -0
- package/skills/calimero-meroctl/references/scripting.md +80 -0
- package/skills/calimero-meroctl/rules/call-view-flag.md +28 -0
- package/skills/calimero-meroctl/rules/register-node-once.md +34 -0
- package/skills/calimero-merod/SKILL.md +49 -0
- package/skills/calimero-merod/references/health-endpoints.md +90 -0
- package/skills/calimero-merod/references/init-flags.md +84 -0
- package/skills/calimero-merod/rules/init-before-run.md +40 -0
- package/skills/calimero-merod/rules/port-assignments.md +33 -0
- package/skills/calimero-node/SKILL.md +50 -39
- package/skills/calimero-node/references/context-lifecycle.md +34 -17
- package/skills/calimero-node/references/meroctl-commands.md +89 -99
- package/skills/calimero-node/rules/app-vs-context.md +4 -4
- package/skills/calimero-registry/SKILL.md +110 -31
- package/skills/calimero-registry/references/bundle-and-push.md +99 -34
- package/skills/calimero-registry/references/manifest-format.md +56 -35
- package/skills/calimero-registry/references/mero-sign.md +10 -9
- package/skills/calimero-registry/rules/key-security.md +3 -2
- package/skills/calimero-registry/rules/sign-before-pack.md +5 -5
- package/skills/calimero-rust-sdk/SKILL.md +154 -44
- package/skills/calimero-rust-sdk/references/blob-api.md +119 -0
- package/skills/calimero-rust-sdk/references/event-handlers.md +122 -0
- package/skills/calimero-rust-sdk/references/events.md +2 -1
- package/skills/calimero-rust-sdk/references/examples.md +81 -29
- package/skills/calimero-rust-sdk/references/migrations.md +123 -0
- package/skills/calimero-rust-sdk/references/nested-crdts.md +113 -0
- package/skills/calimero-rust-sdk/references/private-storage.md +76 -34
- package/skills/calimero-rust-sdk/references/state-collections.md +106 -21
- package/skills/calimero-rust-sdk/references/user-and-frozen-storage.md +169 -0
- package/skills/calimero-rust-sdk/rules/app-macro-placement.md +5 -2
- package/skills/calimero-rust-sdk/rules/no-std-collections.md +5 -2
- package/skills/calimero-rust-sdk/rules/state-derives.md +9 -10
- package/skills/calimero-rust-sdk/rules/wasm-constraints.md +12 -10
- package/skills/calimero-sdk-js/SKILL.md +34 -26
- package/skills/calimero-sdk-js/references/build-pipeline.md +6 -6
- package/skills/calimero-sdk-js/references/collections.md +11 -11
- package/skills/calimero-sdk-js/references/events.md +7 -3
- package/skills/calimero-sdk-js/rules/crdt-only-state.md +18 -18
- package/skills/calimero-sdk-js/rules/no-console-log.md +6 -6
- package/skills/calimero-sdk-js/rules/view-decorator.md +6 -4
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Rule: Understand Port Assignments
|
|
2
|
+
|
|
3
|
+
**`merod` uses two distinct ports with different roles. Both matter.**
|
|
4
|
+
|
|
5
|
+
## Port roles
|
|
6
|
+
|
|
7
|
+
| Flag | Default | Connected by |
|
|
8
|
+
| --------------- | ------- | ----------------------------------------------------------------------- |
|
|
9
|
+
| `--server-port` | `2428` | `meroctl`, app clients (browser, Python, JS), all HTTP/WS API consumers |
|
|
10
|
+
| `--swarm-port` | `2528` | Other `merod` nodes — P2P state sync, namespace invite protocol |
|
|
11
|
+
|
|
12
|
+
## What fails when a port is wrong or blocked
|
|
13
|
+
|
|
14
|
+
| Problem | Symptom |
|
|
15
|
+
| ----------------------- | ------------------------------------------------------------------------------------ |
|
|
16
|
+
| Server port unreachable | `meroctl` cannot connect; clients get connection refused; apps cannot make API calls |
|
|
17
|
+
| Swarm port unreachable | Multi-node sync silently fails; namespaces cannot be joined; nodes appear isolated |
|
|
18
|
+
|
|
19
|
+
## Multiple nodes on the same machine
|
|
20
|
+
|
|
21
|
+
Each `merod` instance needs unique ports:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
merod --home ./data --node node1 init --server-port 2428 --swarm-port 2528
|
|
25
|
+
merod --home ./data --node node2 init --server-port 2429 --swarm-port 2529
|
|
26
|
+
merod --home ./data --node node3 init --server-port 2430 --swarm-port 2530
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Ports are set at init time
|
|
30
|
+
|
|
31
|
+
Port assignments are written into the config file during `merod init`. You cannot change them with
|
|
32
|
+
`merod run` flags — edit `config.toml` in the node home or re-init if you need different ports
|
|
33
|
+
(re-init destroys the node identity, so prefer editing `config.toml`).
|
|
@@ -4,7 +4,8 @@ You are helping a developer manage a **Calimero node** using `merod` and `meroct
|
|
|
4
4
|
|
|
5
5
|
## Key concepts
|
|
6
6
|
|
|
7
|
-
- `merod` — the node runtime. Runs as a daemon. Hosts WASM apps, manages storage, exposes JSON-RPC +
|
|
7
|
+
- `merod` — the node runtime. Runs as a daemon. Hosts WASM apps, manages storage, exposes JSON-RPC +
|
|
8
|
+
WebSocket
|
|
8
9
|
- `meroctl` — the CLI for administrating a running node (contexts, apps, identities)
|
|
9
10
|
- **Context** — an isolated application instance with its own members, state, and storage
|
|
10
11
|
- **Application** — the WASM code; one app can power many contexts
|
|
@@ -13,66 +14,76 @@ You are helping a developer manage a **Calimero node** using `merod` and `meroct
|
|
|
13
14
|
## Node setup (first time)
|
|
14
15
|
|
|
15
16
|
```bash
|
|
16
|
-
# Initialize node
|
|
17
|
-
merod --
|
|
17
|
+
# Initialize node (creates key material and config)
|
|
18
|
+
merod --node node1 init --server-port 2428 --swarm-port 2528
|
|
18
19
|
|
|
19
20
|
# Start the node
|
|
20
|
-
merod --
|
|
21
|
+
merod --node node1 run
|
|
21
22
|
# Node listens on http://localhost:2428 by default
|
|
22
23
|
```
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
`--home <PATH>` is optional; defaults to the system config directory. Use it to specify a custom
|
|
26
|
+
data directory: `merod --home ./data --node node1 init`.
|
|
27
|
+
|
|
28
|
+
## Connecting meroctl to a node
|
|
25
29
|
|
|
26
30
|
```bash
|
|
27
|
-
#
|
|
28
|
-
meroctl
|
|
29
|
-
--path myapp.mpk
|
|
30
|
-
# → prints app-id
|
|
31
|
+
# Register a local node by name (one-time)
|
|
32
|
+
meroctl node add node1 /path/to/calimero/home
|
|
31
33
|
|
|
32
|
-
#
|
|
33
|
-
meroctl
|
|
34
|
-
--app-id <app-id>
|
|
35
|
-
# → prints context-id
|
|
34
|
+
# Or register a remote node
|
|
35
|
+
meroctl node add mynode http://node.example.com
|
|
36
36
|
|
|
37
|
-
#
|
|
38
|
-
meroctl
|
|
39
|
-
--args '{"key":"hello","value":"world"}'
|
|
37
|
+
# Set as default (so you don't need --node on every command)
|
|
38
|
+
meroctl node use node1
|
|
40
39
|
|
|
41
|
-
#
|
|
42
|
-
meroctl
|
|
43
|
-
|
|
40
|
+
# List configured nodes
|
|
41
|
+
meroctl node ls
|
|
42
|
+
```
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
After setup, use `--node node1` or rely on the active node:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
meroctl --node node1 context ls # explicit
|
|
48
|
+
meroctl context ls # uses active node
|
|
47
49
|
```
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
Alternatively, pass a direct URL without registering:
|
|
50
52
|
|
|
51
53
|
```bash
|
|
52
|
-
|
|
53
|
-
meroctl --node-url http://localhost:2428 context invite \
|
|
54
|
-
<context-id> --identity <identity-on-node-A>
|
|
55
|
-
# → prints invitation payload (JSON)
|
|
56
|
-
|
|
57
|
-
# On node B — accept the invitation
|
|
58
|
-
meroctl --node-url http://localhost:2429 context join \
|
|
59
|
-
--invitation '<paste-invitation-payload>'
|
|
60
|
-
# → node B syncs state from node A
|
|
54
|
+
meroctl --api http://localhost:2428 context ls
|
|
61
55
|
```
|
|
62
56
|
|
|
63
|
-
##
|
|
57
|
+
## Complete workflow: app → context → call
|
|
64
58
|
|
|
65
59
|
```bash
|
|
66
|
-
meroctl
|
|
67
|
-
|
|
60
|
+
# (Assumes: meroctl node add node1 ... && meroctl node use node1 already done)
|
|
61
|
+
|
|
62
|
+
# 1. Install an app
|
|
63
|
+
meroctl app install --path myapp.wasm
|
|
64
|
+
# → prints application-id
|
|
65
|
+
|
|
66
|
+
# 2. Create a context (instantiate the app — init() is called)
|
|
67
|
+
meroctl context create --application-id <application-id>
|
|
68
|
+
# → prints context-id
|
|
69
|
+
|
|
70
|
+
# 3. Call a mutation (changes state)
|
|
71
|
+
meroctl call <context-id> set --args '{"key":"hello","value":"world"}'
|
|
72
|
+
|
|
73
|
+
# 4. Call a view (read-only)
|
|
74
|
+
meroctl call <context-id> get --args '{"key":"hello"}' --view
|
|
68
75
|
```
|
|
69
76
|
|
|
70
|
-
|
|
71
|
-
the node's key material, and local storage. Each node must have its own home directory.
|
|
77
|
+
## Related skills
|
|
72
78
|
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
- **`calimero-merod`** — deep-dive on `merod` daemon: all init flags, config file schema, health
|
|
80
|
+
endpoints, Docker setup
|
|
81
|
+
- **`calimero-meroctl`** — complete `meroctl` CLI reference: every subcommand, every flag, scripting
|
|
82
|
+
patterns, multi-node namespace/group workflow
|
|
83
|
+
- **`calimero-core`** — context/app/identity model, JSON-RPC protocol, WebSocket events, CRDT
|
|
84
|
+
storage types
|
|
75
85
|
|
|
76
86
|
## References
|
|
77
87
|
|
|
78
|
-
See `references/` for
|
|
88
|
+
See `references/` for context lifecycle detail and multi-node namespace/group setup. For the full
|
|
89
|
+
`meroctl` command reference, use the `calimero-meroctl` skill.
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
# Context Lifecycle
|
|
2
2
|
|
|
3
|
-
A **context** is an isolated instance of an application with its own members, CRDT state, and
|
|
3
|
+
A **context** is an isolated instance of an application with its own members, CRDT state, and
|
|
4
|
+
storage.
|
|
4
5
|
|
|
5
6
|
## App vs Context
|
|
6
7
|
|
|
7
|
-
| Concept
|
|
8
|
-
|
|
|
9
|
-
| Application | WASM binary + manifest
|
|
10
|
-
| Context
|
|
8
|
+
| Concept | What it is | Analogy |
|
|
9
|
+
| ----------- | -------------------------- | -------------------- |
|
|
10
|
+
| Application | WASM binary + manifest | A class / template |
|
|
11
|
+
| Context | Running instance of an app | An object / instance |
|
|
11
12
|
|
|
12
13
|
One application can power many independent contexts. Each context has completely isolated state.
|
|
13
14
|
|
|
14
15
|
## Lifecycle
|
|
15
16
|
|
|
16
|
-
```
|
|
17
|
+
```text
|
|
17
18
|
App installed on node
|
|
18
19
|
│
|
|
19
20
|
▼
|
|
20
21
|
Context created (init() called → initial state set)
|
|
21
22
|
│
|
|
22
23
|
▼
|
|
23
|
-
Members
|
|
24
|
+
Members join via namespace/group membership
|
|
24
25
|
│
|
|
25
26
|
├─ Methods called (mutations + views)
|
|
26
27
|
├─ Events emitted to members
|
|
@@ -33,23 +34,38 @@ Context deleted (state and storage wiped)
|
|
|
33
34
|
## Creating a context
|
|
34
35
|
|
|
35
36
|
```bash
|
|
36
|
-
meroctl context create --
|
|
37
|
+
meroctl --node node1 context create --application-id <application-id>
|
|
37
38
|
# Returns: context-id
|
|
38
39
|
```
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
Dev mode — auto-reinstalls when the WASM file changes:
|
|
41
42
|
|
|
42
43
|
```bash
|
|
43
|
-
|
|
44
|
-
meroctl context invite <context-id> --identity <identity-on-node-A>
|
|
45
|
-
# Returns: invitation payload (share this with the new member)
|
|
46
|
-
|
|
47
|
-
# On node B — accept the invitation
|
|
48
|
-
meroctl context join --invitation <paste-invitation-payload>
|
|
44
|
+
meroctl --node node1 context create --watch path/to/app.wasm
|
|
49
45
|
```
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
## Multi-node participation (namespace + group model)
|
|
48
|
+
|
|
49
|
+
Nodes join a context via **namespaces** (root groups). The inviting node creates a namespace
|
|
50
|
+
invitation; joining nodes accept it, then join the context via group membership.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# ── Node A (creator) ──
|
|
54
|
+
meroctl --node node1 namespace create
|
|
55
|
+
# → <namespace-id>
|
|
56
|
+
|
|
57
|
+
meroctl --node node1 context create --application-id <app-id>
|
|
58
|
+
# → <context-id>
|
|
59
|
+
|
|
60
|
+
meroctl --node node1 namespace invite <namespace-id>
|
|
61
|
+
# → invitation JSON — share with Node B
|
|
62
|
+
|
|
63
|
+
# ── Node B (joiner) ──
|
|
64
|
+
meroctl --node node2 namespace join <namespace-id> '<invitation-json>'
|
|
65
|
+
|
|
66
|
+
meroctl --node node2 group join-context <context-id>
|
|
67
|
+
# Node B now participates and syncs CRDT state from Node A
|
|
68
|
+
```
|
|
53
69
|
|
|
54
70
|
## State synchronization
|
|
55
71
|
|
|
@@ -57,3 +73,4 @@ participate in CRDT state synchronization.
|
|
|
57
73
|
- All context members receive mutations from all other members
|
|
58
74
|
- Conflicts are resolved deterministically by the CRDT engine
|
|
59
75
|
- Sync works offline — changes queue up and merge when reconnected
|
|
76
|
+
- Manual sync: `meroctl --node node1 context sync <context-id>`
|
|
@@ -5,17 +5,39 @@ Full CLI for managing a running Calimero node.
|
|
|
5
5
|
## Global flags
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
meroctl --node
|
|
9
|
-
meroctl --
|
|
8
|
+
meroctl --node node1 <command> # use registered node by name
|
|
9
|
+
meroctl --api http://localhost:2428 <command> # connect directly by URL
|
|
10
|
+
meroctl --home ~/.calimero <command> # alternate config path
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Register a node once, then use by name:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
meroctl node add node1 /path/to/home # local node
|
|
17
|
+
meroctl node add mynode http://node.com # remote node
|
|
18
|
+
meroctl node use node1 # set as active (default)
|
|
10
19
|
```
|
|
11
20
|
|
|
12
21
|
---
|
|
13
22
|
|
|
14
|
-
## Node commands
|
|
23
|
+
## Node management commands
|
|
15
24
|
|
|
16
25
|
```bash
|
|
17
|
-
#
|
|
18
|
-
meroctl
|
|
26
|
+
# Add / connect to a node
|
|
27
|
+
meroctl node add node1 /path/to/calimero/home
|
|
28
|
+
meroctl node add remote1 http://node.example.com
|
|
29
|
+
|
|
30
|
+
# Set active node
|
|
31
|
+
meroctl node use node1
|
|
32
|
+
|
|
33
|
+
# List configured nodes
|
|
34
|
+
meroctl node ls
|
|
35
|
+
|
|
36
|
+
# Remove a node connection
|
|
37
|
+
meroctl node remove node1
|
|
38
|
+
|
|
39
|
+
# Show node peer identity
|
|
40
|
+
meroctl node identity
|
|
19
41
|
```
|
|
20
42
|
|
|
21
43
|
---
|
|
@@ -23,22 +45,22 @@ meroctl --node-url http://localhost:2428 node health
|
|
|
23
45
|
## App commands
|
|
24
46
|
|
|
25
47
|
```bash
|
|
26
|
-
# Install app from local
|
|
27
|
-
meroctl --node
|
|
28
|
-
meroctl --node
|
|
48
|
+
# Install app from local file (.wasm or .mpk)
|
|
49
|
+
meroctl --node node1 app install --path myapp.wasm
|
|
50
|
+
meroctl --node node1 app install --path myapp.mpk
|
|
29
51
|
|
|
30
52
|
# Install app from registry URL
|
|
31
|
-
meroctl --node
|
|
32
|
-
--url https://
|
|
53
|
+
meroctl --node node1 app install \
|
|
54
|
+
--url https://apps.calimero.network/com.yourorg.myapp/1.0.0
|
|
33
55
|
|
|
34
56
|
# List installed apps
|
|
35
|
-
meroctl --node
|
|
57
|
+
meroctl --node node1 app ls
|
|
36
58
|
|
|
37
59
|
# Get details of a specific app
|
|
38
|
-
meroctl --node
|
|
60
|
+
meroctl --node node1 app get <application-id>
|
|
39
61
|
|
|
40
|
-
# Remove an app
|
|
41
|
-
meroctl --node
|
|
62
|
+
# Remove an app
|
|
63
|
+
meroctl --node node1 app remove <application-id>
|
|
42
64
|
```
|
|
43
65
|
|
|
44
66
|
---
|
|
@@ -47,44 +69,23 @@ meroctl --node-url http://localhost:2428 app remove <app-id>
|
|
|
47
69
|
|
|
48
70
|
```bash
|
|
49
71
|
# Create a context (instantiates the app — calls init())
|
|
50
|
-
meroctl --node
|
|
72
|
+
meroctl --node node1 context create --application-id <application-id>
|
|
51
73
|
# Returns: context-id
|
|
52
74
|
|
|
75
|
+
# Dev mode — watch a WASM file for changes and hot-reload
|
|
76
|
+
meroctl --node node1 context create --watch path/to/app.wasm
|
|
77
|
+
|
|
53
78
|
# List all contexts on this node
|
|
54
|
-
meroctl --node
|
|
79
|
+
meroctl --node node1 context ls
|
|
55
80
|
|
|
56
81
|
# Get details of a specific context
|
|
57
|
-
meroctl --node
|
|
58
|
-
|
|
59
|
-
# Delete a context (wipes all state and storage for this context)
|
|
60
|
-
meroctl --node-url http://localhost:2428 context delete <context-id>
|
|
82
|
+
meroctl --node node1 context get <context-id>
|
|
61
83
|
|
|
62
|
-
#
|
|
63
|
-
meroctl --node
|
|
84
|
+
# Delete a context (wipes all state and storage)
|
|
85
|
+
meroctl --node node1 context delete <context-id>
|
|
64
86
|
|
|
65
|
-
#
|
|
66
|
-
meroctl --node
|
|
67
|
-
<context-id> --identity <identity>
|
|
68
|
-
# Returns: invitation payload JSON — share this with the invitee
|
|
69
|
-
|
|
70
|
-
# Join a context using an invitation payload (run on the joining node)
|
|
71
|
-
meroctl --node-url http://localhost:2428 context join \
|
|
72
|
-
--invitation '<invitation-payload-json>'
|
|
73
|
-
# After this, the node syncs state from the inviting node
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### Full invite + join example
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
# ── Node A (inviter) ──
|
|
80
|
-
meroctl --node-url http://localhost:2428 context invite \
|
|
81
|
-
abc123ctx --identity ed25519:AAAA...
|
|
82
|
-
# Prints: {"payload":"..."}
|
|
83
|
-
|
|
84
|
-
# ── Node B (joiner) ──
|
|
85
|
-
meroctl --node-url http://localhost:2429 context join \
|
|
86
|
-
--invitation '{"payload":"..."}'
|
|
87
|
-
# Node B now participates in the context and syncs CRDT state
|
|
87
|
+
# Sync a context with peers
|
|
88
|
+
meroctl --node node1 context sync <context-id>
|
|
88
89
|
```
|
|
89
90
|
|
|
90
91
|
---
|
|
@@ -92,16 +93,16 @@ meroctl --node-url http://localhost:2429 context join \
|
|
|
92
93
|
## Calling app methods
|
|
93
94
|
|
|
94
95
|
```bash
|
|
95
|
-
# Mutation — changes shared state
|
|
96
|
-
meroctl --node
|
|
96
|
+
# Mutation — changes shared state
|
|
97
|
+
meroctl --node node1 call <context-id> set \
|
|
97
98
|
--args '{"key":"hello","value":"world"}'
|
|
98
99
|
|
|
99
100
|
# View — read-only, does NOT change state
|
|
100
|
-
meroctl --node
|
|
101
|
+
meroctl --node node1 call <context-id> get \
|
|
101
102
|
--args '{"key":"hello"}' --view
|
|
102
103
|
|
|
103
104
|
# Method with no arguments
|
|
104
|
-
meroctl --node
|
|
105
|
+
meroctl --node node1 call <context-id> list_all \
|
|
105
106
|
--args '{}' --view
|
|
106
107
|
```
|
|
107
108
|
|
|
@@ -110,74 +111,63 @@ meroctl --node-url http://localhost:2428 call <context-id> list_all \
|
|
|
110
111
|
## Identity commands
|
|
111
112
|
|
|
112
113
|
```bash
|
|
113
|
-
# Create a new identity
|
|
114
|
-
meroctl --node
|
|
114
|
+
# Create a new identity
|
|
115
|
+
meroctl --node node1 identity create
|
|
115
116
|
|
|
116
|
-
# List all identities
|
|
117
|
-
meroctl --node
|
|
117
|
+
# List all identities
|
|
118
|
+
meroctl --node node1 identity ls
|
|
118
119
|
|
|
119
120
|
# Get details of a specific identity
|
|
120
|
-
meroctl --node
|
|
121
|
+
meroctl --node node1 identity get <identity>
|
|
121
122
|
```
|
|
122
123
|
|
|
123
124
|
---
|
|
124
125
|
|
|
125
|
-
##
|
|
126
|
+
## Multi-node context sharing (namespace + group model)
|
|
126
127
|
|
|
127
|
-
|
|
128
|
-
# 1. Build the WASM app
|
|
129
|
-
cargo build --target wasm32-unknown-unknown --release
|
|
128
|
+
Multi-node participation uses namespaces (root groups) and group membership.
|
|
130
129
|
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
```bash
|
|
131
|
+
# ── Node A: create a namespace and context ──
|
|
132
|
+
meroctl --node node1 namespace create
|
|
133
|
+
# → <namespace-id>
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
--path target/wasm32-unknown-unknown/release/myapp.wasm
|
|
137
|
-
# Copy the app-id from output
|
|
135
|
+
meroctl --node node1 context create --application-id <app-id>
|
|
136
|
+
# → <context-id>
|
|
138
137
|
|
|
139
|
-
#
|
|
140
|
-
meroctl --node
|
|
141
|
-
#
|
|
138
|
+
# Generate an invitation for another node to join
|
|
139
|
+
meroctl --node node1 namespace invite <namespace-id>
|
|
140
|
+
# → invitation JSON payload
|
|
142
141
|
|
|
143
|
-
#
|
|
144
|
-
meroctl --node
|
|
145
|
-
--args '{"key":"foo","value":"bar"}'
|
|
142
|
+
# ── Node B: join via invitation ──
|
|
143
|
+
meroctl --node node2 namespace join <namespace-id> '<invitation-json>'
|
|
146
144
|
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
# ── Node B: join the context (after joining namespace/group) ──
|
|
146
|
+
meroctl --node node2 group join-context <context-id>
|
|
149
147
|
```
|
|
150
148
|
|
|
151
149
|
---
|
|
152
150
|
|
|
153
|
-
## Step-by-step:
|
|
151
|
+
## Step-by-step: full local development flow
|
|
154
152
|
|
|
155
153
|
```bash
|
|
156
|
-
#
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
#
|
|
154
|
+
# 1. Initialize and start a node
|
|
155
|
+
merod --node node1 init --server-port 2428 --swarm-port 2528
|
|
156
|
+
merod --node node1 run & # run in background
|
|
157
|
+
|
|
158
|
+
# 2. Register the node in meroctl
|
|
159
|
+
meroctl node add node1 ~/.calimero/node1
|
|
160
|
+
meroctl node use node1
|
|
161
|
+
|
|
162
|
+
# 3. Install the app
|
|
163
|
+
meroctl app install --path target/wasm32-unknown-unknown/release/myapp.wasm
|
|
164
|
+
# → copy the application-id
|
|
161
165
|
|
|
162
|
-
# Create
|
|
163
|
-
meroctl --
|
|
164
|
-
# →
|
|
165
|
-
|
|
166
|
-
#
|
|
167
|
-
meroctl
|
|
168
|
-
|
|
169
|
-
# → <invitation-payload>
|
|
170
|
-
|
|
171
|
-
# ── Node B (port 2429) ──
|
|
172
|
-
# Accept invitation
|
|
173
|
-
meroctl --node-url http://localhost:2429 context join \
|
|
174
|
-
--invitation '<invitation-payload>'
|
|
175
|
-
# Node B syncs all existing state from node A
|
|
176
|
-
|
|
177
|
-
# Both nodes can now call methods and see each other's mutations:
|
|
178
|
-
meroctl --node-url http://localhost:2428 call <context-id> set \
|
|
179
|
-
--args '{"key":"shared","value":"data"}'
|
|
180
|
-
meroctl --node-url http://localhost:2429 call <context-id> get \
|
|
181
|
-
--args '{"key":"shared"}' --view
|
|
182
|
-
# → "data" (synced from node A)
|
|
166
|
+
# 4. Create a context
|
|
167
|
+
meroctl context create --application-id <application-id>
|
|
168
|
+
# → copy the context-id
|
|
169
|
+
|
|
170
|
+
# 5. Interact with the app
|
|
171
|
+
meroctl call <context-id> set --args '{"key":"foo","value":"bar"}'
|
|
172
|
+
meroctl call <context-id> get --args '{"key":"foo"}' --view
|
|
183
173
|
```
|
|
@@ -26,8 +26,8 @@ meroctl call <context-id> get --args '{"key":"hello"}' --view
|
|
|
26
26
|
|
|
27
27
|
## Why this matters
|
|
28
28
|
|
|
29
|
-
API calls take a `context-id`, not an `app-id`. If you try to call a method with an
|
|
30
|
-
|
|
29
|
+
API calls take a `context-id`, not an `app-id`. If you try to call a method with an `app-id` instead
|
|
30
|
+
of a `context-id` you will get a "context not found" error.
|
|
31
31
|
|
|
32
|
-
One app can have multiple independent contexts — each with its own members and state.
|
|
33
|
-
|
|
32
|
+
One app can have multiple independent contexts — each with its own members and state. For example, a
|
|
33
|
+
chat app might have one context per chat room.
|