clawdentity 0.0.23 → 0.0.24

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.
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawdentity",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -21,6 +21,17 @@
21
21
  "postinstall.mjs",
22
22
  "skill-bundle"
23
23
  ],
24
+ "scripts": {
25
+ "build": "pnpm -F @clawdentity/openclaw-skill build && pnpm run sync:skill-bundle && pnpm run verify:skill-bundle && tsup",
26
+ "format": "biome format .",
27
+ "lint": "biome lint .",
28
+ "prepack": "pnpm run build",
29
+ "postinstall": "node ./postinstall.mjs",
30
+ "sync:skill-bundle": "node ./scripts/sync-skill-bundle.mjs",
31
+ "verify:skill-bundle": "node ./scripts/verify-skill-bundle.mjs",
32
+ "test": "vitest run",
33
+ "typecheck": "tsc --noEmit"
34
+ },
24
35
  "dependencies": {
25
36
  "commander": "^13.1.0",
26
37
  "jsqr": "^1.4.0",
@@ -29,21 +40,11 @@
29
40
  "ws": "^8.19.0"
30
41
  },
31
42
  "devDependencies": {
43
+ "@clawdentity/connector": "workspace:*",
44
+ "@clawdentity/protocol": "workspace:*",
45
+ "@clawdentity/sdk": "workspace:*",
32
46
  "@types/node": "^22.18.11",
33
47
  "@types/pngjs": "^6.0.5",
34
- "@types/qrcode": "^1.5.6",
35
- "@clawdentity/protocol": "0.0.0",
36
- "@clawdentity/connector": "0.0.0",
37
- "@clawdentity/sdk": "0.0.0"
38
- },
39
- "scripts": {
40
- "build": "pnpm -F @clawdentity/openclaw-skill build && pnpm run sync:skill-bundle && pnpm run verify:skill-bundle && tsup",
41
- "format": "biome format .",
42
- "lint": "biome lint .",
43
- "postinstall": "node ./postinstall.mjs",
44
- "sync:skill-bundle": "node ./scripts/sync-skill-bundle.mjs",
45
- "verify:skill-bundle": "node ./scripts/verify-skill-bundle.mjs",
46
- "test": "vitest run",
47
- "typecheck": "tsc --noEmit"
48
+ "@types/qrcode": "^1.5.6"
48
49
  }
49
- }
50
+ }
package/postinstall.mjs CHANGED
@@ -1,15 +1,24 @@
1
+ import { existsSync } from "node:fs";
1
2
  import { dirname, join } from "node:path";
2
3
  import { fileURLToPath, pathToFileURL } from "node:url";
3
4
 
4
5
  const packageRoot = dirname(fileURLToPath(import.meta.url));
5
6
  const bundledPostinstallPath = join(packageRoot, "dist", "postinstall.js");
6
7
 
7
- try {
8
- await import(pathToFileURL(bundledPostinstallPath).href);
9
- } catch (error) {
10
- if (!(error && typeof error === "object" && error.code === "ENOENT")) {
11
- const message = error instanceof Error ? error.message : String(error);
12
- process.stderr.write(`[clawdentity] postinstall failed: ${message}\n`);
13
- process.exitCode = 1;
8
+ if (existsSync(bundledPostinstallPath)) {
9
+ try {
10
+ await import(pathToFileURL(bundledPostinstallPath).href);
11
+ } catch (error) {
12
+ if (
13
+ !(
14
+ error &&
15
+ typeof error === "object" &&
16
+ (error.code === "ENOENT" || error.code === "ERR_MODULE_NOT_FOUND")
17
+ )
18
+ ) {
19
+ const message = error instanceof Error ? error.message : String(error);
20
+ process.stderr.write(`[clawdentity] postinstall failed: ${message}\n`);
21
+ process.exitCode = 1;
22
+ }
14
23
  }
15
24
  }
@@ -16,6 +16,30 @@ After setup, this skill also covers lifecycle operations: token refresh, API key
16
16
 
17
17
  Relay invite codes are not part of this flow.
18
18
 
19
+ ## State Discovery First (required before asking for onboarding inputs)
20
+
21
+ Always detect existing local state before asking for invite code, API key, or peer setup.
22
+
23
+ 1. Resolve OpenClaw state root.
24
+ - Default: `~/.openclaw`
25
+ - Respect env overrides: `OPENCLAW_STATE_DIR`, legacy `CLAWDBOT_STATE_DIR`, `OPENCLAW_HOME`
26
+
27
+ 2. Resolve Clawdentity state root using this order.
28
+ - Primary: `~/.clawdentity`
29
+ - Fallback: `<openclaw-state>/.clawdentity`
30
+
31
+ 3. If fallback exists and primary is missing:
32
+ - Run all `clawdentity ...` commands with `HOME=<openclaw-state>` so CLI resolves the same state root as OpenClaw profile.
33
+
34
+ 4. Run readiness probe before asking questions:
35
+ - `clawdentity openclaw doctor --json`
36
+
37
+ 5. Behavior gate from doctor output:
38
+ - If doctor is healthy: do not ask for onboarding invite/API key; proceed directly with requested relay/pairing action.
39
+ - If doctor is unhealthy: ask only for the minimum missing input required by failed checks.
40
+
41
+ Never claim that no local relay setup exists until this discovery flow is complete.
42
+
19
43
  ## Filesystem Truth (must be used exactly)
20
44
 
21
45
  ### OpenClaw state files
@@ -176,9 +200,10 @@ Use `--no-runtime-start` when the connector runs as a separate container or proc
176
200
  - `npm install -g clawdentity@latest`
177
201
  - Confirm local agent name.
178
202
  - Confirm local human display name for onboarding.
179
- - Check local API key status with `clawdentity config get apiKey`.
180
- - If API key is missing, ask for onboarding invite `clw_inv_...` and continue with invite redeem.
181
- - Do not ask for raw API key unless the user explicitly says invite is unavailable.
203
+ - Check existing relay state first using **State Discovery First** above.
204
+ - Check local API key status with `clawdentity config get apiKey` only after state root resolution is confirmed.
205
+ - If API key is missing and doctor indicates onboarding is incomplete, ask for onboarding invite `clw_inv_...` and continue with invite redeem.
206
+ - Do not ask for raw API key unless the user explicitly says invite is unavailable and onboarding invite cannot be provided.
182
207
  - Confirm OpenClaw path/base URL only if non-default.
183
208
  - Do not ask for pairing inputs before onboarding is complete.
184
209
 
@@ -274,26 +299,38 @@ Use `--no-runtime-start` when the connector runs as a separate container or proc
274
299
  After pairing, agents receive relayed messages from their paired peers.
275
300
  Identity injection is enabled by default (`INJECT_IDENTITY_INTO_MESSAGE=true` on proxy).
276
301
 
302
+ **Do not reply to peer messages in chat.** Chat replies stay local and never reach the peer. All replies to a peer must be sent via the relay webhook with `"peer": "<alias>"` in the payload.
303
+
277
304
  ### Recognizing incoming messages
278
305
  - Relayed messages contain a `[Clawdentity Identity]` block prepended to the message body.
279
306
  - Extract `agentDid` from this block to identify the sender.
280
307
  - See `references/clawdentity-protocol.md` § Identity Injection for the exact block format and field definitions.
281
308
  - The connector `deliver` frame also exposes `fromAgentDid` for programmatic access.
309
+ - When you see a `[Clawdentity Identity]` block, the message is from a peer. Do not answer in chat. Follow the reply flow below.
282
310
 
283
311
  ### Looking up peer identity
284
312
  - Map sender `agentDid` to a known peer by matching against `did` in `~/.clawdentity/peers.json`.
285
313
  - Each peer entry contains:
286
314
  - `did` — the peer's agent DID (match key)
287
- - `agentName` — the peer's agent name (use for addressing)
288
- - `humanName` — the human behind the peer agent (use for context)
315
+ - `agentName` — the peer's agent name
316
+ - `humanName` — the human behind the peer agent
289
317
  - `proxyUrl` — the peer's proxy endpoint
290
- - Address the peer by `agentName` or `humanName` in responses for natural conversation.
318
+ - The peer alias is the key of that entry in `peers.json` (e.g., `"beta"`). Use this alias in the reply payload.
291
319
 
292
320
  ### Sending messages to a peer
321
+ This is the only way to reply to a peer or send a new message. Chat replies do not reach peers.
293
322
  - Include `"peer": "<alias>"` in the webhook payload to route via relay.
294
- - The alias is the key in `peers.json` (e.g., `"beta"`).
323
+ - Use the alias resolved from the lookup step above.
324
+ - Use `agentName` or `humanName` in the message text for natural addressing.
295
325
  - The relay transform strips `peer` from the payload and routes to the connector.
296
326
 
327
+ ### Reply flow
328
+ When a relayed peer message arrives:
329
+ 1. Extract `agentDid` from the `[Clawdentity Identity]` block.
330
+ 2. Look up the peer alias by matching `agentDid` against `did` in `~/.clawdentity/peers.json`.
331
+ 3. Compose a webhook payload with `"peer": "<alias>"` set to the resolved alias.
332
+ 4. The relay delivers the payload to the peer. Do not also reply in chat.
333
+
297
334
  ### Peer validation
298
335
  - `clawdentity openclaw doctor --peer <alias>` confirms a specific peer is reachable.
299
336
  - `clawdentity openclaw relay test --peer <alias>` sends a test probe to the peer.
@@ -21,6 +21,19 @@ Complete reference for CLI environment variable overrides. When env overrides ar
21
21
  | `OPENCLAW_STATE_DIR` | Override OpenClaw state directory | openclaw |
22
22
  | `OPENCLAW_HOME` | Override OpenClaw home directory (used when explicit config/state overrides are unset) | openclaw |
23
23
 
24
+ ## Profile-Local State Resolution
25
+
26
+ In profile-mounted/containerized OpenClaw environments, Clawdentity state may be stored at:
27
+ - `<openclaw-state>/.clawdentity`
28
+
29
+ instead of:
30
+ - `~/.clawdentity`
31
+
32
+ If `~/.clawdentity` is missing but `<openclaw-state>/.clawdentity` exists, run CLI commands with:
33
+ - `HOME=<openclaw-state>`
34
+
35
+ This makes `clawdentity` resolve the correct profile-local state root.
36
+
24
37
  ## Legacy Environment Variables
25
38
 
26
39
  | Variable | Replaced By |
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Ravi Kiran Vemula
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.