@dp-pcs/ogp 0.3.3 → 0.4.2

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 (95) hide show
  1. package/README.md +275 -49
  2. package/dist/cli/completion.d.ts +5 -0
  3. package/dist/cli/completion.d.ts.map +1 -0
  4. package/dist/cli/completion.js +148 -0
  5. package/dist/cli/completion.js.map +1 -0
  6. package/dist/cli/config.d.ts +3 -0
  7. package/dist/cli/config.d.ts.map +1 -0
  8. package/dist/cli/config.js +207 -0
  9. package/dist/cli/config.js.map +1 -0
  10. package/dist/cli/expose.d.ts.map +1 -1
  11. package/dist/cli/expose.js +20 -13
  12. package/dist/cli/expose.js.map +1 -1
  13. package/dist/cli/federation.d.ts.map +1 -1
  14. package/dist/cli/federation.js +182 -6
  15. package/dist/cli/federation.js.map +1 -1
  16. package/dist/cli/setup.d.ts +19 -0
  17. package/dist/cli/setup.d.ts.map +1 -1
  18. package/dist/cli/setup.js +507 -32
  19. package/dist/cli/setup.js.map +1 -1
  20. package/dist/cli.js +348 -32
  21. package/dist/cli.js.map +1 -1
  22. package/dist/daemon/agent-comms.d.ts.map +1 -1
  23. package/dist/daemon/agent-comms.js +14 -9
  24. package/dist/daemon/agent-comms.js.map +1 -1
  25. package/dist/daemon/intent-registry.d.ts.map +1 -1
  26. package/dist/daemon/intent-registry.js +7 -4
  27. package/dist/daemon/intent-registry.js.map +1 -1
  28. package/dist/daemon/keypair.d.ts.map +1 -1
  29. package/dist/daemon/keypair.js +34 -13
  30. package/dist/daemon/keypair.js.map +1 -1
  31. package/dist/daemon/message-handler.d.ts.map +1 -1
  32. package/dist/daemon/message-handler.js +7 -0
  33. package/dist/daemon/message-handler.js.map +1 -1
  34. package/dist/daemon/notify.d.ts +19 -0
  35. package/dist/daemon/notify.d.ts.map +1 -1
  36. package/dist/daemon/notify.js +329 -73
  37. package/dist/daemon/notify.js.map +1 -1
  38. package/dist/daemon/openclaw-bridge.d.ts +34 -0
  39. package/dist/daemon/openclaw-bridge.d.ts.map +1 -0
  40. package/dist/daemon/openclaw-bridge.js +261 -0
  41. package/dist/daemon/openclaw-bridge.js.map +1 -0
  42. package/dist/daemon/peers.d.ts +8 -0
  43. package/dist/daemon/peers.d.ts.map +1 -1
  44. package/dist/daemon/peers.js +48 -14
  45. package/dist/daemon/peers.js.map +1 -1
  46. package/dist/daemon/projects.d.ts.map +1 -1
  47. package/dist/daemon/projects.js +7 -4
  48. package/dist/daemon/projects.js.map +1 -1
  49. package/dist/daemon/server.d.ts +16 -0
  50. package/dist/daemon/server.d.ts.map +1 -1
  51. package/dist/daemon/server.js +147 -46
  52. package/dist/daemon/server.js.map +1 -1
  53. package/dist/shared/config.d.ts +52 -1
  54. package/dist/shared/config.d.ts.map +1 -1
  55. package/dist/shared/config.js +18 -11
  56. package/dist/shared/config.js.map +1 -1
  57. package/dist/shared/framework-detection.d.ts +31 -0
  58. package/dist/shared/framework-detection.d.ts.map +1 -0
  59. package/dist/shared/framework-detection.js +91 -0
  60. package/dist/shared/framework-detection.js.map +1 -0
  61. package/dist/shared/help.d.ts +5 -0
  62. package/dist/shared/help.d.ts.map +1 -0
  63. package/dist/shared/help.js +280 -0
  64. package/dist/shared/help.js.map +1 -0
  65. package/dist/shared/meta-config.d.ts +44 -0
  66. package/dist/shared/meta-config.d.ts.map +1 -0
  67. package/dist/shared/meta-config.js +89 -0
  68. package/dist/shared/meta-config.js.map +1 -0
  69. package/dist/shared/migration.d.ts +57 -0
  70. package/dist/shared/migration.d.ts.map +1 -0
  71. package/dist/shared/migration.js +255 -0
  72. package/dist/shared/migration.js.map +1 -0
  73. package/docs/CLI-REFERENCE.md +1360 -0
  74. package/docs/GETTING-STARTED.md +942 -0
  75. package/docs/MIGRATION.md +202 -0
  76. package/docs/MULTI-FRAMEWORK-DEMO.md +352 -0
  77. package/docs/MULTI-FRAMEWORK-DESIGN.md +378 -0
  78. package/docs/MULTI-FRAMEWORK-IMPL.md +197 -0
  79. package/docs/case-studies/CRASH_RESOLUTION_20260407.md +190 -0
  80. package/docs/case-studies/OpenClaw_Hermes_Status_Report_20260407.md +142 -0
  81. package/docs/case-studies/OpenClaw_Stability_Fix_Summary.md +209 -0
  82. package/docs/case-studies/README.md +40 -0
  83. package/docs/case-studies/crash_observations.md +250 -0
  84. package/docs/federation-flow.md +21 -31
  85. package/docs/hermes-implementation-checklist.md +4 -0
  86. package/docs/rendezvous.md +13 -14
  87. package/package.json +9 -3
  88. package/scripts/completion.bash +123 -0
  89. package/scripts/completion.zsh +372 -0
  90. package/scripts/test-migration-execute.js +74 -0
  91. package/scripts/test-migration.js +42 -0
  92. package/skills/ogp/SKILL.md +197 -64
  93. package/skills/ogp-agent-comms/SKILL.md +107 -41
  94. package/skills/ogp-expose/SKILL.md +84 -21
  95. package/skills/ogp-project/SKILL.md +66 -58
package/README.md CHANGED
@@ -46,6 +46,16 @@ ogp-install-skills
46
46
 
47
47
  This auto-discovers and installs all OGP skills from the `skills/` directory.
48
48
 
49
+ ### Multi-Framework Support
50
+
51
+ OGP supports running alongside multiple AI frameworks (OpenClaw, Hermes, etc.) with isolated configurations. During setup, OGP automatically detects installed frameworks and creates framework-specific configurations:
52
+
53
+ - **OpenClaw**: `~/.ogp-openclaw/`
54
+ - **Hermes**: `~/.ogp-hermes/`
55
+ - **Standalone**: `~/.ogp/`
56
+
57
+ All framework configurations are managed from a central meta-config at `~/.ogp-meta/config.json`.
58
+
49
59
  ## Quick Start
50
60
 
51
61
  ### 1. Setup
@@ -56,15 +66,33 @@ Run the interactive setup wizard:
56
66
  ogp setup
57
67
  ```
58
68
 
59
- You'll be prompted for:
60
- - **Agent ID** - Which OpenClaw agent owns this gateway (auto-discovers available agents from your OpenClaw config)
61
- - Daemon port (default: 18790)
62
- - OpenClaw URL (default: http://localhost:18789)
63
- - OpenClaw API token
64
- - Your public gateway URL (can update later, or use rendezvous)
69
+ The wizard automatically detects installed frameworks and guides you through configuration. You'll be prompted for:
70
+ - **Framework Selection** - Which AI frameworks to enable (OpenClaw, Hermes, or standalone)
71
+ - **Agent ID** - Which agent owns each gateway (auto-discovers from framework config)
72
+ - Daemon port (default: 18790 for OpenClaw, 18793 for Hermes)
73
+ - Framework URL and API credentials
74
+ - Your public gateway URL (can update later; rendezvous is optional discovery/invite sugar, not a replacement for reachability)
65
75
  - Rendezvous configuration (optional, v0.2.14+)
66
76
  - Display name and email
67
77
 
78
+ **Working with Multiple Frameworks:**
79
+
80
+ When multiple frameworks are configured, use the `--for` flag to specify which framework:
81
+
82
+ ```bash
83
+ # Use specific framework
84
+ ogp --for openclaw federation list
85
+ ogp --for hermes federation list
86
+
87
+ # Run on all frameworks
88
+ ogp --for all status
89
+
90
+ # Set a default framework (no --for needed)
91
+ ogp config set-default openclaw
92
+ ```
93
+
94
+ If only one framework is configured, it's automatically selected (no `--for` flag needed).
95
+
68
96
  ### 2. Start the Daemon
69
97
 
70
98
  ```bash
@@ -77,6 +105,17 @@ Or run in the background:
77
105
  ogp start --background
78
106
  ```
79
107
 
108
+ **Multi-framework usage:**
109
+
110
+ ```bash
111
+ # Start daemon for specific framework
112
+ ogp --for openclaw start --background
113
+ ogp --for hermes start --background
114
+
115
+ # Start all framework daemons
116
+ ogp --for all start --background
117
+ ```
118
+
80
119
  ### 3. Making Your Gateway Reachable
81
120
 
82
121
  For OGP federation to work, peers need to be able to reach your gateway over the internet. If you already have a publicly accessible URL (cloud server, VPS, Clawporate gateway), just set it as your `gatewayUrl` in `~/.ogp/config.json` and you're done. Skip to step 4.
@@ -174,15 +213,39 @@ https://your-gateway-url.com/.well-known/ogp
174
213
 
175
214
  ## All Commands
176
215
 
216
+ All commands support the `--for <framework>` flag to specify which framework configuration to use. Use `--for all` to run commands across all configured frameworks.
217
+
218
+ **Quick Help:** Add `?` to any command for context-sensitive help:
219
+
220
+ ```bash
221
+ ogp ? # Show all commands
222
+ ogp federation ? # Show federation commands
223
+ ogp federation send ? # Show send usage with examples
224
+ ```
225
+
226
+ ### Tab Completion
227
+
228
+ Install shell completion for faster command entry:
229
+
230
+ ```bash
231
+ # Bash
232
+ ogp completion install bash
233
+
234
+ # Zsh
235
+ ogp completion install zsh
236
+ ```
237
+
238
+ After installation, restart your shell or run `source ~/.bashrc` (bash) or `source ~/.zshrc` (zsh).
239
+
177
240
  ### Daemon Management
178
241
 
179
242
  | Command | Description |
180
243
  |---------|-------------|
181
- | `ogp setup` | Interactive setup wizard |
182
- | `ogp start` | Start daemon in foreground |
183
- | `ogp start --background` | Start daemon as background process |
184
- | `ogp stop` | Stop the daemon |
185
- | `ogp status` | Show daemon status and configuration |
244
+ | `ogp setup` | Interactive setup wizard (auto-detects frameworks) |
245
+ | `ogp start [--for <framework>]` | Start daemon in foreground |
246
+ | `ogp start --background [--for <framework>]` | Start daemon as background process |
247
+ | `ogp stop [--for <framework>]` | Stop the daemon |
248
+ | `ogp status [--for <framework>]` | Show daemon status and configuration |
186
249
 
187
250
  ### Tunnel Management
188
251
 
@@ -200,11 +263,21 @@ https://your-gateway-url.com/.well-known/ogp
200
263
  | `ogp install` | Install LaunchAgent for auto-start on login |
201
264
  | `ogp uninstall` | Remove LaunchAgent |
202
265
 
266
+ ### Configuration Management
267
+
268
+ | Command | Description |
269
+ |---------|-------------|
270
+ | `ogp config list` | List all configured frameworks |
271
+ | `ogp config set-default <framework>` | Set default framework (no --for needed) |
272
+ | `ogp config enable <framework>` | Enable a framework |
273
+ | `ogp config disable <framework>` | Disable a framework |
274
+ | `ogp config show [--for <framework>]` | Show current configuration |
275
+
203
276
  ### Federation Management
204
277
 
205
278
  | Command | Description |
206
279
  |---------|-------------|
207
- | `ogp federation list` | List all peers |
280
+ | `ogp federation list [--for <framework>]` | List all peers |
208
281
  | `ogp federation list --status pending` | List pending federation requests |
209
282
  | `ogp federation list --status approved` | List approved peers |
210
283
  | `ogp federation request <url> [alias]` | Request federation (alias auto-resolves if omitted) |
@@ -255,6 +328,7 @@ When approving or granting scopes:
255
328
 
256
329
  | Command | Description |
257
330
  |---------|-------------|
331
+ | `ogp agent-comms interview` | Re-run the delegated-authority / human-delivery interview |
258
332
  | `ogp agent-comms policies [peer-id]` | Show response policies |
259
333
  | `ogp agent-comms configure [peer-ids] [options]` | Configure response policies |
260
334
  | `ogp agent-comms add-topic <peer> <topic> [options]` | Add topic policy |
@@ -271,54 +345,57 @@ When approving or granting scopes:
271
345
  ogp federation request https://peer.example.com
272
346
 
273
347
  # Or specify a custom alias for easier reference
274
- ogp federation request https://peer.example.com --alias big-papa
348
+ ogp federation request https://peer.example.com --alias apollo
349
+
350
+ # Multi-framework: Request from specific framework
351
+ ogp --for openclaw federation request https://hermes.example.com --alias hermes-gateway
275
352
 
276
353
  # Check pending requests
277
354
  ogp federation list --status pending
278
355
 
279
356
  # Approve a peer (v0.1 mode - no scope restrictions)
280
- ogp federation approve alice
357
+ ogp federation approve apollo
281
358
 
282
359
  # Approve with scope grants (v0.2.0+)
283
- ogp federation approve alice \
360
+ ogp federation approve apollo \
284
361
  --intents message,agent-comms \
285
362
  --rate 100/3600 \
286
363
  --topics memory-management,task-delegation
287
364
 
288
365
  # View peer scopes
289
- ogp federation scopes alice
366
+ ogp federation scopes apollo
290
367
 
291
368
  # Update grants for an existing peer
292
- ogp federation grant alice \
369
+ ogp federation grant apollo \
293
370
  --intents agent-comms \
294
371
  --topics project-planning
295
372
 
296
373
  # Remove a peer from federation (asymmetric tear-down)
297
- ogp federation remove alice
374
+ ogp federation remove apollo
298
375
 
299
376
  # Test connectivity
300
377
  ogp federation ping https://peer.example.com
301
378
 
302
379
  # Send a simple message
303
- ogp federation send alice message '{"text":"Hello!"}'
380
+ ogp federation send apollo message '{"text":"Hello!"}'
304
381
 
305
382
  # Send agent-comms (v0.2.0+)
306
- ogp federation agent alice memory-management "How do you persist context?"
383
+ ogp federation agent apollo memory-management "How do you persist context?"
307
384
 
308
385
  # Send agent-comms with priority
309
- ogp federation agent alice task-delegation "Schedule standup" --priority high
386
+ ogp federation agent apollo task-delegation "Schedule standup" --priority high
310
387
 
311
388
  # Send agent-comms and wait for reply
312
- ogp federation agent alice queries "What's the status?" --wait --timeout 60000
389
+ ogp federation agent apollo queries "What's the status?" --wait --timeout 60000
313
390
 
314
391
  # Send a task request
315
- ogp federation send alice task-request '{
392
+ ogp federation send apollo task-request '{
316
393
  "taskType": "analysis",
317
394
  "description": "Analyze recent logs"
318
395
  }'
319
396
 
320
397
  # Send a status update
321
- ogp federation send alice status-update '{
398
+ ogp federation send apollo status-update '{
322
399
  "status": "completed",
323
400
  "message": "Task finished"
324
401
  }'
@@ -399,6 +476,8 @@ ogp agent-comms activity stan --last 20
399
476
 
400
477
  ## How Federation Works
401
478
 
479
+ ### Single Framework Architecture
480
+
402
481
  ```
403
482
  ┌─────────────┐ ┌──────────────┐ ┌─────────────┐
404
483
  │ OpenClaw │◄────────│ OGP Daemon │◄────────│ Remote │
@@ -407,26 +486,55 @@ ogp agent-comms activity stan --last 20
407
486
  └─────────────┘ └──────────────┘ └─────────────┘
408
487
  ```
409
488
 
489
+ ### Multi-Framework Architecture
490
+
491
+ ```
492
+ ┌─────────────┐ ┌──────────────────┐ ┌─────────────┐
493
+ │ OpenClaw │◄────────│ OGP Daemon │◄────────│ Remote │
494
+ │ :18789 │ webhook│ :18790 │ signed │ Peer │
495
+ └─────────────┘ │ (~/.ogp-openclaw)│ message│ (OGP) │
496
+ └──────────────────┘ └─────────────┘
497
+
498
+ ┌─────────────┐ │
499
+ │ Hermes │◄────────┌──────────────────┐ ┌─────────────┐
500
+ │ :18792 │ webhook│ OGP Daemon │◄────────│ Remote │
501
+ └─────────────┘ │ :18793 │ signed │ Peer │
502
+ │ (~/.ogp-hermes) │ message│ (OGP) │
503
+ └──────────────────┘ └─────────────┘
504
+
505
+
506
+ ┌──────────────────┐
507
+ │ Meta Config │
508
+ │ (~/.ogp-meta/) │
509
+ │ - Framework list │
510
+ │ - Default │
511
+ │ - Aliases │
512
+ └──────────────────┘
513
+ ```
514
+
515
+ ### Federation Flow
516
+
410
517
  1. **Discovery**: Peers discover each other via `/.well-known/ogp` endpoint or rendezvous server
411
518
  2. **Request**: Alice requests federation with Bob's OGP instance
412
519
  3. **Approval**: Bob approves (or rejects) the federation request
413
520
  4. **Messaging**: Approved peers can send cryptographically signed messages
414
521
  5. **Verification**: Recipient OGP daemon verifies signatures using sender's public key
415
- 6. **Relay**: Valid messages are forwarded to the local OpenClaw agent via webhook
522
+ 6. **Relay**: Valid messages are forwarded to the local AI agent via webhook
416
523
 
417
524
  All messages are signed with Ed25519 cryptographic signatures to prevent tampering and impersonation.
418
525
 
419
- ## Rendezvous — Zero-Config Peer Discovery (v0.2.14+)
526
+ ## Rendezvous — Optional Discovery And Invite Layer (v0.2.14+)
527
+
528
+ Rendezvous is an optional convenience layer for pubkey lookup and short invite codes. It is useful when you want easier onboarding for gateways that are already publicly reachable.
420
529
 
421
- OGP's rendezvous service eliminates the need for manual URL exchange and tunnel configuration. Gateways auto-register by public key, enabling peers to discover and connect to each other with a single command.
530
+ ### What It Actually Solves
422
531
 
423
- ### The Problem It Solves
532
+ Traditional federation still requires the peer you are trying to reach to be publicly reachable. Rendezvous helps with:
533
+ - pubkey discovery
534
+ - short invite codes instead of sharing long URLs or raw pubkeys
535
+ - reducing manual coordination once each gateway already has a stable public endpoint
424
536
 
425
- Traditional federation requires both peers to be publicly reachable and manually exchange gateway URLs. With rendezvous:
426
- - No tunnel setup required (ngrok, Cloudflare Tunnel, port forwarding)
427
- - No manual URL sharing
428
- - No URL rotation issues (free ngrok tiers)
429
- - Automatic peer discovery by public key
537
+ Rendezvous does **not** provide NAT traversal, hole punching, or message relay.
430
538
 
431
539
  ### How It Works
432
540
 
@@ -435,7 +543,7 @@ Traditional federation requires both peers to be publicly reachable and manually
435
543
  3. Peers can look you up by public key (`GET /peer/:pubkey`) and connect directly
436
544
  4. On shutdown, your daemon auto-deregisters (`DELETE /peer/:pubkey`)
437
545
 
438
- The rendezvous server **never touches message content** — it only stores connection hints (IP + port). All OGP messages remain end-to-end signed between peers.
546
+ The rendezvous server **never touches message content** — it only stores connection hints. All OGP messages remain end-to-end signed between peers.
439
547
 
440
548
  ### Configuration
441
549
 
@@ -453,7 +561,7 @@ Add the `rendezvous` block to `~/.ogp/config.json`:
453
561
  }
454
562
  ```
455
563
 
456
- The setup wizard (`ogp setup`) prompts for rendezvous configuration.
564
+ Rendezvous is optional. OGP works without it if peers can share public URLs directly.
457
565
 
458
566
  **For cloud/ECS gateways behind load balancers**, set the `OGP_PUBLIC_URL` environment variable to override automatic IP detection:
459
567
 
@@ -476,7 +584,7 @@ Or add `publicUrl` to the rendezvous config:
476
584
 
477
585
  ### Federation Invite Flow (v0.2.15+)
478
586
 
479
- The invite flow removes the need to exchange public keys. One command generates a short-lived token; your peer uses it to connect instantly.
587
+ The invite flow removes the need to exchange public keys manually. One command generates a short-lived token; your peer uses it to connect instantly.
480
588
 
481
589
  **Generate an invite:**
482
590
  ```bash
@@ -512,7 +620,7 @@ Connect to any peer registered on rendezvous by their public key:
512
620
  ogp federation connect <pubkey>
513
621
  ```
514
622
 
515
- This looks up the peer on the rendezvous server and establishes federation directly.
623
+ This looks up the peer on the rendezvous server and establishes federation directly. The peer still needs a reachable gateway endpoint behind that lookup.
516
624
 
517
625
  ### Privacy & Self-Hosting
518
626
 
@@ -667,9 +775,26 @@ ogp federation request https://peer.example.com --alias alice
667
775
  ogp federation request https://peer.example.com
668
776
  ```
669
777
 
670
- ### 6. Telegram Integration (v0.2.3+)
778
+ ### 6. OpenClaw Human Delivery (v0.2.3+, refined in v0.4.2+)
671
779
 
672
- Federation requests fire OpenClaw notifications via sessions_send, delivering directly to Telegram.
780
+ For OpenClaw-backed agents, OGP now prefers `POST /hooks/agent` for inbound federated work that should be interpreted and surfaced by the local agent. This lets OpenClaw run a real agent turn, apply the configured human-delivery policy, and deliver through the correct channel surface (Telegram, iMessage, etc.).
781
+
782
+ When OGP needs direct session injection, it uses Gateway RPC with the correct secure WebSocket transport (`wss://`) when the OpenClaw gateway is TLS-enabled.
783
+
784
+ ### 6.1 Delegated-Authority Precedence (v0.4.2)
785
+
786
+ Policy evaluation now follows a fixed order so more specific rules cannot be silently overwritten. The runtime in `src/daemon/notify.ts` applies:
787
+ 1. Legacy `inboundFederationPolicy` mode as a safety fallback
788
+ 2. Global default rule from the delegated-authority config
789
+ 3. Peer-specific default rule (per-peer overrides)
790
+ 4. Global message-class rule (e.g., `agent-work`, `human-relay`, `approval-request`, `status-update`)
791
+ 5. Peer message-class override for that same class
792
+ 6. Global topic-level rule
793
+ 7. Peer topic-level override
794
+
795
+ Approval requests receive immediate `approval-required` handling and `human-relay` obligations are treated according to their relay mode (deliver, summarize, or approval) before human delivery is asserted. This ordering guarantees peer defaults cannot erase more specific class/topic safeguards, so `human-relay` stays strict even when a trusted peer asks for more autonomy and topic overrides continue to behave predictably.
796
+
797
+ OGP now tries to pin `/hooks/agent` to the actual human session key when the local OpenClaw `hooks.allowRequestSessionKey` setting allows it (see `~/.openclaw/openclaw.json`). If the value is `false` or the requested key does not match the allowed prefixes, the hook still runs but falls back to the default hook session, so downstream heuristics must still parse peer identity from the injected payload. Native sender identity parity in Telegram therefore remains a known limitation for `v0.4.2`; the runtime will log a warning whenever it cannot request a session override so that the human knows the limitation is intentional.
673
798
 
674
799
  ### 7. Enhanced Daemon Status (v0.2.3+)
675
800
 
@@ -774,6 +899,9 @@ The `off` level enables a default-deny security posture. When a topic hits `off`
774
899
  # View all policies
775
900
  ogp agent-comms policies
776
901
 
902
+ # Re-run the delegated-authority / human-delivery interview
903
+ ogp agent-comms interview
904
+
777
905
  # View policies for a specific peer
778
906
  ogp agent-comms policies stan
779
907
 
@@ -828,6 +956,10 @@ Configuration is stored in `~/.ogp/config.json`:
828
956
  "email": "you@example.com",
829
957
  "stateDir": "~/.ogp",
830
958
  "agentId": "main",
959
+ "humanDeliveryTarget": "telegram:123456789",
960
+ "inboundFederationPolicy": {
961
+ "mode": "summarize"
962
+ },
831
963
  "notifyTarget": "telegram:123456789",
832
964
  "notifyTargets": {
833
965
  "main": "telegram:123456789",
@@ -863,6 +995,55 @@ Which agent owns this gateway? (number or ID) [1]:
863
995
  You can also specify a custom agent ID if needed.
864
996
  ```
865
997
 
998
+ ### Human Delivery Preferences (v0.4.2+)
999
+
1000
+ OGP has two separate questions to answer for inbound federation traffic:
1001
+
1002
+ 1. **Where should human-facing followups go?**
1003
+ 2. **How should the agent behave when a peer asks it to do something?**
1004
+
1005
+ Those should not be inferred from the currently active conversation.
1006
+
1007
+ **Configuration fields:**
1008
+ - **`humanDeliveryTarget`**: Explicit human-facing destination for OGP-triggered followups. Examples: `telegram:123456789` or a raw session key like `agent:main:telegram:direct:123456789`.
1009
+ - **`inboundFederationPolicy.mode`**: Default behavior for how the local agent should handle inbound federated requests.
1010
+
1011
+ For OpenClaw specifically, this configuration feeds the `/hooks/agent` delivery path. In other words:
1012
+ - `humanDeliveryTarget` tells OGP where human-facing followups should go
1013
+ - `inboundFederationPolicy.mode` tells the local agent how to treat federated requests once they arrive
1014
+ - OGP should not infer either of those from "whatever session is active right now"
1015
+
1016
+ **Supported behavior modes:**
1017
+ - **`forward`**: Tell me everything. Forward inbound federated items to my configured channel.
1018
+ - **`summarize`**: Summarize and surface only important, actionable, or uncertain items.
1019
+ - **`autonomous`**: Act autonomously when possible, but surface blockers, approvals, or explicit relay requests.
1020
+ - **`approval-required`**: Do not act on or reply to federated requests until I explicitly approve.
1021
+
1022
+ **Example configuration:**
1023
+
1024
+ ```json
1025
+ {
1026
+ "agentId": "main",
1027
+ "humanDeliveryTarget": "telegram:123456789",
1028
+ "inboundFederationPolicy": {
1029
+ "mode": "autonomous"
1030
+ }
1031
+ }
1032
+ ```
1033
+
1034
+ When you run `ogp setup`, the wizard asks for both:
1035
+ - the primary human delivery target for OGP followups
1036
+ - the default inbound federation handling mode
1037
+
1038
+ If the user wants to revisit just this part later, use:
1039
+
1040
+ ```bash
1041
+ ogp --for openclaw agent-comms interview
1042
+ ogp --for hermes agent-comms interview
1043
+ ```
1044
+
1045
+ That command re-runs the delegated-authority / human-delivery interview for the active framework without repeating the rest of first-time setup.
1046
+
866
1047
  ### Notification Routing (v0.2.28+)
867
1048
 
868
1049
  The `notifyTargets` field enables per-agent notification routing. When OGP sends notifications to your OpenClaw instance, it routes to specific agents based on the message context.
@@ -870,6 +1051,7 @@ The `notifyTargets` field enables per-agent notification routing. When OGP sends
870
1051
  **Configuration fields:**
871
1052
  - **`notifyTarget`** (legacy, string): Single notification target for all messages. Maintained for backward compatibility.
872
1053
  - **`notifyTargets`** (object): Map of agent names to notification targets. Example: `{"main": "telegram:...", "scribe": "telegram:..."}`
1054
+ - **`humanDeliveryTarget`** (preferred for human-facing followups): Explicit destination for OGP-triggered notifications and relay obligations.
873
1055
 
874
1056
  **Example configuration with multiple agents:**
875
1057
 
@@ -883,6 +1065,10 @@ The `notifyTargets` field enables per-agent notification routing. When OGP sends
883
1065
  "email": "alice@example.com",
884
1066
  "stateDir": "~/.ogp",
885
1067
  "notifyTarget": "telegram:123456789",
1068
+ "humanDeliveryTarget": "telegram:123456789",
1069
+ "inboundFederationPolicy": {
1070
+ "mode": "summarize"
1071
+ },
886
1072
  "notifyTargets": {
887
1073
  "main": "telegram:123456789",
888
1074
  "scribe": "telegram:987654321",
@@ -896,15 +1082,25 @@ The `notifyTargets` field enables per-agent notification routing. When OGP sends
896
1082
 
897
1083
  When routing notifications, OGP resolves the target in this order:
898
1084
 
899
- 1. **`notifyTargets[agent]`** — If the agent is specified and exists in `notifyTargets`, use that target
900
- 2. **`notifyTarget`** — Fall back to the legacy single target for backward compatibility
901
- 3. **Default**If neither is set, the notification is sent without a specific target (OpenClaw routes to the default channel)
1085
+ 1. **`humanDeliveryTarget`** — If set, use it as the explicit human-facing OGP destination
1086
+ 2. **`notifyTargets[agent]`** — If the agent is specified and exists in `notifyTargets`, use that target
1087
+ 3. **`notifyTarget`**Fall back to the legacy single target for backward compatibility
1088
+ 4. **Default** — If none are set, OGP falls back to the agent's default session
902
1089
 
903
1090
  This allows you to:
904
1091
  - Route federation messages to different agents based on context
1092
+ - Explicitly separate "the agent that owns this gateway" from "the human-facing channel for OGP followups"
905
1093
  - Maintain backward compatibility with existing single-agent setups
906
1094
  - Gradually migrate to multi-agent routing without breaking existing configurations
907
1095
 
1096
+ ### OpenClaw Transport Notes
1097
+
1098
+ If you are debugging OpenClaw integration directly:
1099
+
1100
+ - **Hooks path**: `https://localhost:18789/hooks/agent` is the preferred local delivery path for human-facing federated work.
1101
+ - **Gateway RPC path**: when using `openclaw gateway call` against a TLS-enabled local gateway, use `wss://localhost:18789`, not `ws://localhost:18789`.
1102
+ - A plain session injection succeeding does not necessarily mean the agent has interpreted the task the way you want; `/hooks/agent` is the path designed for that agentic behavior.
1103
+
908
1104
  ### Environment Variables
909
1105
 
910
1106
  - `OGP_PUBLIC_URL` (v0.2.17+): Override automatic IP detection for rendezvous registration. Use this for cloud/ECS gateways behind load balancers where the detected IP differs from the public endpoint.
@@ -918,12 +1114,14 @@ This allows you to:
918
1114
 
919
1115
  ### State Files
920
1116
 
921
- - `~/.ogp/keypair.json` - Ed25519 keypair (keep secure! migrated to macOS Keychain on v0.2.13+)
1117
+ - `~/.ogp/keypair.json` - Public key cache for the OpenClaw instance. On macOS the private key lives in an instance-specific Keychain entry; on non-macOS the file contains the full keypair.
922
1118
  - `~/.ogp/peers.json` - Federated peer list with scope grants
923
1119
  - `~/.ogp/intents.json` - Intent registry (built-in + custom)
924
1120
  - `~/.ogp/projects.json` - Project contexts and contributions
925
1121
  - `~/.ogp/agent-comms-config.json` - Response policies and activity log
926
1122
 
1123
+ On macOS, deleting `keypair.json` by itself does **not** rotate the gateway identity if the matching private key is still present in Keychain. Use `ogp setup --reset-keypair` when you intentionally want a new identity.
1124
+
927
1125
  ## Skills (Claude Code)
928
1126
 
929
1127
  OGP includes skills for Claude Code agents. Install them with:
@@ -938,18 +1136,28 @@ ogp-install-skills
938
1136
  |-------|---------|
939
1137
  | **ogp** | Core protocol: federation setup, peer management, sending messages |
940
1138
  | **ogp-expose** | Tunnel setup: cloudflared/ngrok configuration |
941
- | **ogp-agent-comms** | Interactive wizard: configure response policies per-peer |
1139
+ | **ogp-agent-comms** | Interactive wizard: configure response policies plus delegated-authority / human-delivery interview |
942
1140
  | **ogp-project** | Agent-aware project context: interviews, logging, cross-peer summarization |
943
1141
 
944
- Skills auto-install from the `skills/` directory. The `ogp-agent-comms` skill provides an interactive wizard for multi-peer policy configuration. The `ogp-project` skill enables conversational project management with context interviews and proactive logging.
1142
+ Skills auto-install from the `skills/` directory. The `ogp-agent-comms` skill now uses `ogp agent-comms interview` as the canonical conversational path for delegated-authority / human-delivery configuration, plus the existing per-peer policy commands. The `ogp-project` skill enables conversational project management with context interviews and proactive logging.
945
1143
 
946
1144
  ## Documentation
947
1145
 
948
- - [Quick Start Guide](./docs/quickstart.md) - Detailed step-by-step setup
1146
+ ### Getting Started
1147
+ - [Getting Started Guide](./docs/GETTING-STARTED.md) - Comprehensive setup guide for single and multi-framework setups
1148
+ - [Quick Start Guide](./docs/quickstart.md) - Fast-track setup for single framework
1149
+ - [CLI Reference](./docs/CLI-REFERENCE.md) - Complete command reference with examples
1150
+ - [Migration Guide](./docs/MIGRATION.md) - Upgrading from single to multi-framework setup
1151
+
1152
+ ### Core Features
949
1153
  - [Federation Flow](./docs/federation-flow.md) - How federation works internally
950
1154
  - [Scope Negotiation](./docs/scopes.md) - Per-peer scope configuration (v0.2.0)
951
1155
  - [Agent Communications](./docs/agent-comms.md) - Agent-to-agent messaging (v0.2.0)
952
- - [Rendezvous & Invite Flow](./docs/rendezvous.md) - Zero-config peer discovery (v0.2.14+)
1156
+ - [Rendezvous & Invite Flow](./docs/rendezvous.md) - Optional discovery and invite service (v0.2.14+)
1157
+
1158
+ ### Advanced
1159
+ - [Multi-Framework Design](./docs/MULTI-FRAMEWORK-DESIGN.md) - Design principles for multi-framework support
1160
+ - [Multi-Framework Implementation](./docs/MULTI-FRAMEWORK-IMPL.md) - Implementation details
953
1161
  - [Protocol Specification](https://github.com/dp-pcs/openclaw-federation) - Full OGP protocol spec
954
1162
 
955
1163
  ## Security
@@ -961,7 +1169,9 @@ Skills auto-install from the `skills/` directory. The `ogp-agent-comms` skill pr
961
1169
  - **Nonce tracking**: Prevents replay attacks
962
1170
 
963
1171
  **Best practices:**
964
- - Keep `~/.ogp/keypair.json` secure with proper file permissions (`chmod 600`)
1172
+ - Treat `~/.ogp/keypair.json` as identity material even when it contains only the public key cache on macOS.
1173
+ - On macOS, remember the private key source of truth is the instance-specific Keychain entry, not `keypair.json`; use `ogp setup --reset-keypair` for intentional rotation.
1174
+ - On non-macOS, keep `~/.ogp/keypair.json` secure with proper file permissions (`chmod 600`)
965
1175
  - Verify peer identity out-of-band before approving federation requests
966
1176
  - Always use HTTPS tunnels (never expose raw HTTP)
967
1177
  - Monitor OpenClaw logs for suspicious peer activity
@@ -994,7 +1204,7 @@ src/
994
1204
  projects.ts # Project storage and management (v0.2.0+)
995
1205
  intent-registry.ts # Intent definitions and custom registry
996
1206
  message-handler.ts # Message verification and routing
997
- notify.ts # OpenClaw integration (sessions_send + webhooks)
1207
+ notify.ts # OpenClaw/Hermes delivery backends
998
1208
  cli/
999
1209
  setup.ts # Setup wizard
1000
1210
  federation.ts # Federation commands (scopes, agent-comms)
@@ -1011,6 +1221,22 @@ skills/
1011
1221
  ogp-project/ # Project context management skill
1012
1222
  ```
1013
1223
 
1224
+ ## Known Issues
1225
+
1226
+ ### OpenClaw Delivery Model
1227
+
1228
+ **Current implementation:**
1229
+ - **Primary:** `POST /hooks/agent` for inbound federated requests that should be processed by the local OpenClaw agent
1230
+ - **Fallback / sync:** `openclaw gateway call ... sessions.send` over `wss://` when direct session injection is needed
1231
+
1232
+ Why this split exists:
1233
+ - `/hooks/agent` is the right primitive for "an external federated task arrived; let the agent interpret it, act on it, and deliver the result through the configured human channel."
1234
+ - `sessions.send` is still useful for direct session injection and compact synchronization notes, but it is not the primary delivery mechanism for human-facing federated work.
1235
+
1236
+ Important nuance:
1237
+ - OpenClaw may still render direct session injections with sender metadata like `cli`, so OGP continues to include peer identity in message content where needed.
1238
+ - Hook-run awareness and human-DM continuity are related but not identical. OGP can mirror a compact sync note into the DM session, but the important success criterion is correct delivery and behavior, not whether raw internal transport artifacts are visible in the user-facing transcript.
1239
+
1014
1240
  ## License
1015
1241
 
1016
1242
  MIT
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Install completion for current shell
3
+ */
4
+ export declare function installCompletion(): Promise<void>;
5
+ //# sourceMappingURL=completion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/cli/completion.ts"],"names":[],"mappings":"AAqJA;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAiBvD"}