@dp-pcs/ogp 0.3.3 → 0.4.3

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 (112) hide show
  1. package/README.md +317 -61
  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 +14 -0
  14. package/dist/cli/federation.d.ts.map +1 -1
  15. package/dist/cli/federation.js +347 -23
  16. package/dist/cli/federation.js.map +1 -1
  17. package/dist/cli/project.d.ts +4 -3
  18. package/dist/cli/project.d.ts.map +1 -1
  19. package/dist/cli/project.js +34 -24
  20. package/dist/cli/project.js.map +1 -1
  21. package/dist/cli/setup.d.ts +23 -0
  22. package/dist/cli/setup.d.ts.map +1 -1
  23. package/dist/cli/setup.js +560 -32
  24. package/dist/cli/setup.js.map +1 -1
  25. package/dist/cli.js +358 -35
  26. package/dist/cli.js.map +1 -1
  27. package/dist/daemon/agent-comms.d.ts.map +1 -1
  28. package/dist/daemon/agent-comms.js +15 -10
  29. package/dist/daemon/agent-comms.js.map +1 -1
  30. package/dist/daemon/heartbeat.d.ts +22 -0
  31. package/dist/daemon/heartbeat.d.ts.map +1 -0
  32. package/dist/daemon/heartbeat.js +119 -0
  33. package/dist/daemon/heartbeat.js.map +1 -0
  34. package/dist/daemon/intent-registry.d.ts.map +1 -1
  35. package/dist/daemon/intent-registry.js +19 -10
  36. package/dist/daemon/intent-registry.js.map +1 -1
  37. package/dist/daemon/keypair.d.ts +1 -0
  38. package/dist/daemon/keypair.d.ts.map +1 -1
  39. package/dist/daemon/keypair.js +151 -18
  40. package/dist/daemon/keypair.js.map +1 -1
  41. package/dist/daemon/message-handler.d.ts.map +1 -1
  42. package/dist/daemon/message-handler.js +30 -16
  43. package/dist/daemon/message-handler.js.map +1 -1
  44. package/dist/daemon/notify.d.ts +19 -0
  45. package/dist/daemon/notify.d.ts.map +1 -1
  46. package/dist/daemon/notify.js +376 -73
  47. package/dist/daemon/notify.js.map +1 -1
  48. package/dist/daemon/openclaw-bridge.d.ts +34 -0
  49. package/dist/daemon/openclaw-bridge.d.ts.map +1 -0
  50. package/dist/daemon/openclaw-bridge.js +261 -0
  51. package/dist/daemon/openclaw-bridge.js.map +1 -0
  52. package/dist/daemon/peers.d.ts +21 -0
  53. package/dist/daemon/peers.d.ts.map +1 -1
  54. package/dist/daemon/peers.js +125 -20
  55. package/dist/daemon/peers.js.map +1 -1
  56. package/dist/daemon/projects.d.ts +9 -6
  57. package/dist/daemon/projects.d.ts.map +1 -1
  58. package/dist/daemon/projects.js +30 -20
  59. package/dist/daemon/projects.js.map +1 -1
  60. package/dist/daemon/server.d.ts +17 -0
  61. package/dist/daemon/server.d.ts.map +1 -1
  62. package/dist/daemon/server.js +188 -77
  63. package/dist/daemon/server.js.map +1 -1
  64. package/dist/shared/config.d.ts +52 -1
  65. package/dist/shared/config.d.ts.map +1 -1
  66. package/dist/shared/config.js +18 -11
  67. package/dist/shared/config.js.map +1 -1
  68. package/dist/shared/framework-detection.d.ts +31 -0
  69. package/dist/shared/framework-detection.d.ts.map +1 -0
  70. package/dist/shared/framework-detection.js +91 -0
  71. package/dist/shared/framework-detection.js.map +1 -0
  72. package/dist/shared/help.d.ts +5 -0
  73. package/dist/shared/help.d.ts.map +1 -0
  74. package/dist/shared/help.js +281 -0
  75. package/dist/shared/help.js.map +1 -0
  76. package/dist/shared/meta-config.d.ts +44 -0
  77. package/dist/shared/meta-config.d.ts.map +1 -0
  78. package/dist/shared/meta-config.js +89 -0
  79. package/dist/shared/meta-config.js.map +1 -0
  80. package/dist/shared/migration.d.ts +57 -0
  81. package/dist/shared/migration.d.ts.map +1 -0
  82. package/dist/shared/migration.js +255 -0
  83. package/dist/shared/migration.js.map +1 -0
  84. package/docs/CLI-REFERENCE.md +1361 -0
  85. package/docs/GETTING-STARTED.md +953 -0
  86. package/docs/MIGRATION.md +202 -0
  87. package/docs/MULTI-FRAMEWORK-DEMO.md +352 -0
  88. package/docs/MULTI-FRAMEWORK-DESIGN.md +378 -0
  89. package/docs/MULTI-FRAMEWORK-IMPL.md +197 -0
  90. package/docs/case-studies/CRASH_RESOLUTION_20260407.md +190 -0
  91. package/docs/case-studies/OpenClaw_Hermes_Status_Report_20260407.md +142 -0
  92. package/docs/case-studies/OpenClaw_Stability_Fix_Summary.md +209 -0
  93. package/docs/case-studies/README.md +40 -0
  94. package/docs/case-studies/crash_observations.md +250 -0
  95. package/docs/cloudflare-named-tunnel-setup.md +126 -0
  96. package/docs/federation-flow.md +27 -37
  97. package/docs/hermes-implementation-checklist.md +4 -0
  98. package/docs/project-intent-testing.md +97 -0
  99. package/docs/quickstart.md +12 -4
  100. package/docs/rendezvous.md +13 -14
  101. package/docs/scopes.md +13 -13
  102. package/package.json +12 -6
  103. package/scripts/completion.bash +123 -0
  104. package/scripts/completion.zsh +372 -0
  105. package/scripts/install-skills.js +19 -1
  106. package/scripts/test-migration-execute.js +74 -0
  107. package/scripts/test-migration.js +42 -0
  108. package/scripts/test-project-intents.mjs +614 -0
  109. package/skills/ogp/SKILL.md +197 -64
  110. package/skills/ogp-agent-comms/SKILL.md +107 -41
  111. package/skills/ogp-expose/SKILL.md +183 -25
  112. package/skills/ogp-project/SKILL.md +110 -88
@@ -1,28 +1,27 @@
1
- # Rendezvous — Zero-Config Peer Discovery
1
+ # Rendezvous — Optional Discovery And Invite Layer
2
2
 
3
3
  > Available in v0.2.14+
4
4
 
5
- OGP's rendezvous service lets gateways discover each other by public key no port forwarding, no third-party tunnels, no manual URL exchange required.
5
+ OGP's rendezvous service is an optional convenience layer for pubkey lookup and invite codes. It helps peers find each other more easily once each gateway is already publicly reachable.
6
6
 
7
- ## The Problem It Solves
7
+ ## What It Solves
8
8
 
9
- For two OGP gateways to federate, both need to be publicly reachable. Without rendezvous, that means:
9
+ For two OGP gateways to federate, both still need to be publicly reachable. Rendezvous helps by reducing coordination overhead:
10
10
 
11
- - Signing up for ngrok or Cloudflare Tunnel
12
- - Manually sharing your tunnel URL with each peer
13
- - Re-sharing every time the URL rotates (free tier ngrok rotates on restart)
14
- - Opening router ports or dealing with NAT
11
+ - peer discovery by public key
12
+ - invite-code UX
13
+ - avoiding manual URL/pubkey exchange when a peer is already advertising a reachable endpoint
15
14
 
16
- Rendezvous collapses all of that to zero config.
15
+ Rendezvous does **not** provide NAT traversal, UDP hole punching, or relay delivery.
17
16
 
18
17
  ## How It Works
19
18
 
20
- 1. Your OGP daemon starts and auto-registers with the rendezvous server (`POST /register`) using your public key and current IP:port
19
+ 1. Your OGP daemon starts and auto-registers with the rendezvous server (`POST /register`) using your public key and connection hints
21
20
  2. A 30-second heartbeat keeps your registration alive (90-second TTL on the server)
22
21
  3. When you want to connect to a peer, your daemon looks them up by public key (`GET /peer/:pubkey`) and connects directly
23
22
  4. On shutdown, your daemon deregisters (`DELETE /peer/:pubkey`)
24
23
 
25
- The rendezvous server **never touches message content** — it only stores connection hints (IP + port). All OGP messages remain end-to-end signed between peers.
24
+ The rendezvous server **never touches message content** — it only stores connection hints. All OGP messages remain end-to-end signed between peers.
26
25
 
27
26
  ## Configuration
28
27
 
@@ -40,7 +39,7 @@ Add the `rendezvous` block to `~/.ogp/config.json`:
40
39
  }
41
40
  ```
42
41
 
43
- The OGP setup wizard (`ogp setup`) will prompt for rendezvous configuration going forward.
42
+ Rendezvous is optional. If you already have stable public URLs or are happy sharing them directly, you do not need it.
44
43
 
45
44
  ## Federation Invite Flow (v0.2.15+)
46
45
 
@@ -69,7 +68,7 @@ Output:
69
68
  Connected to a3f7k2... via rendezvous ✅
70
69
  ```
71
70
 
72
- That's the full flow. No pubkey, no URL, no coordination overhead.
71
+ That's the full flow. No pubkey exchange and less coordination overhead, but the peer still needs a reachable gateway endpoint behind the lookup.
73
72
 
74
73
  ### How invite codes work
75
74
 
@@ -102,7 +101,7 @@ Public instance: `https://rendezvous.elelem.expert`
102
101
 
103
102
  ## Privacy & Trust
104
103
 
105
- - The rendezvous server stores only: public key, IP address, port, and last-seen timestamp
104
+ - The rendezvous server stores only: public key, connection hints, and last-seen timestamp
106
105
  - No message content ever passes through rendezvous
107
106
  - Registrations expire after 90 seconds without a heartbeat
108
107
  - The server is open source — you can self-host if you prefer
package/docs/scopes.md CHANGED
@@ -19,8 +19,8 @@ Your gateway advertises its capabilities in the federation card at `/.well-known
19
19
  "version": "0.2.3",
20
20
  "displayName": "David's Gateway",
21
21
  "capabilities": {
22
- "intents": ["message", "task-request", "status-update", "agent-comms", "project"],
23
- "features": ["scope-negotiation", "reply-callback", "project-intent"]
22
+ "intents": ["message", "task-request", "status-update", "agent-comms", "project.join", "project.contribute", "project.query", "project.status"],
23
+ "features": ["scope-negotiation", "reply-callback"]
24
24
  }
25
25
  }
26
26
  ```
@@ -28,7 +28,7 @@ Your gateway advertises its capabilities in the federation card at `/.well-known
28
28
  This tells other gateways what you **can** support, not what you **will** grant.
29
29
 
30
30
  Capabilities are automatically populated from:
31
- - **Built-in intents**: `message`, `task-request`, `status-update`, `agent-comms`, `project`
31
+ - **Built-in intents**: `message`, `task-request`, `status-update`, `agent-comms`, `project.join`, `project.contribute`, `project.query`, `project.status`
32
32
  - **Custom intents**: Registered via `ogp intent register`
33
33
  - **Features**: Protocol features your gateway supports
34
34
 
@@ -205,25 +205,25 @@ ogp federation approve alice \
205
205
  --rate 50/3600
206
206
  ```
207
207
 
208
- ## Project Intent
208
+ ## Project Intents
209
209
 
210
- The `project` intent enables collaborative project management across federated peers.
210
+ Project collaboration is enforced through four exact runtime intents, not a singular `project` scope.
211
211
 
212
212
  ### Project Actions
213
213
 
214
214
  | Action | Description | Rate Limit Recommended |
215
215
  |--------|-------------|------------------------|
216
- | `contribute` | Send contribution to peer's project | 100/hour |
217
- | `query` | Query peer's project contributions | 50/hour |
218
- | `request-join` | Request to join peer's project | 10/hour |
219
- | `status` | Get project status from peer | 20/hour |
216
+ | `project.join` | Join or create a shared project context | 10/hour |
217
+ | `project.contribute` | Send a contribution to a peer's project | 100/hour |
218
+ | `project.query` | Query peer project contributions | 50/hour |
219
+ | `project.status` | Get peer project status | 20/hour |
220
220
 
221
221
  ### Grant Project Access
222
222
 
223
223
  ```bash
224
- # Grant project collaboration access
224
+ # Grant full project collaboration access
225
225
  ogp federation approve alice \
226
- --intents project \
226
+ --intents project.join,project.contribute,project.query,project.status \
227
227
  --rate 100/3600
228
228
  ```
229
229
 
@@ -260,9 +260,9 @@ ogp federation approve bob \
260
260
  ### Project Collaboration
261
261
 
262
262
  ```bash
263
- # Grant project and agent-comms for team collaboration
263
+ # Grant project collaboration intents plus agent-comms for team coordination
264
264
  ogp federation approve charlie \
265
- --intents agent-comms,project \
265
+ --intents agent-comms,project.join,project.contribute,project.query,project.status \
266
266
  --topics project-updates,planning \
267
267
  --rate 200/3600
268
268
  ```
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "@dp-pcs/ogp",
3
- "version": "0.3.3",
3
+ "version": "0.4.3",
4
4
  "description": "Open Gateway Protocol (OGP) - Peer-to-peer federation daemon for OpenClaw AI gateways with cryptographic signatures",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "bin": {
9
- "ogp": "./dist/cli.js",
10
- "ogp-install-skills": "./scripts/install-skills.js"
9
+ "ogp": "dist/cli.js",
10
+ "ogp-install-skills": "scripts/install-skills.js"
11
11
  },
12
12
  "scripts": {
13
13
  "build": "tsc",
14
14
  "dev": "tsc --watch",
15
+ "test": "vitest",
16
+ "test:coverage": "vitest --coverage",
15
17
  "prepublishOnly": "npm run build",
16
18
  "postinstall": "node scripts/install-skills.js || echo 'Note: Run ogp-install-skills to install OGP skills for your AI agent'"
17
19
  },
@@ -29,7 +31,7 @@
29
31
  "license": "MIT",
30
32
  "repository": {
31
33
  "type": "git",
32
- "url": "https://github.com/dp-pcs/ogp.git"
34
+ "url": "git+https://github.com/dp-pcs/ogp.git"
33
35
  },
34
36
  "homepage": "https://github.com/dp-pcs/ogp#readme",
35
37
  "bugs": {
@@ -44,13 +46,17 @@
44
46
  "package.json"
45
47
  ],
46
48
  "dependencies": {
49
+ "@types/ws": "^8.18.1",
47
50
  "commander": "^12.0.0",
48
- "express": "^4.18.2"
51
+ "express": "^4.18.2",
52
+ "ws": "^8.20.0"
49
53
  },
50
54
  "devDependencies": {
51
55
  "@types/express": "^4.17.21",
52
56
  "@types/node": "^20.11.0",
53
- "typescript": "^5.3.3"
57
+ "@vitest/coverage-v8": "^4.1.3",
58
+ "typescript": "^5.3.3",
59
+ "vitest": "^4.1.3"
54
60
  },
55
61
  "engines": {
56
62
  "node": ">=18.0.0"
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # OGP bash completion script
4
+ # Auto-generated by ogp completion install
5
+
6
+ _ogp_completion() {
7
+ local cur prev opts
8
+ COMPREPLY=()
9
+ cur="${COMP_WORDS[COMP_CWORD]}"
10
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
11
+
12
+ # Get the first command (after ogp)
13
+ local cmd=""
14
+ if [ $COMP_CWORD -ge 1 ]; then
15
+ cmd="${COMP_WORDS[1]}"
16
+ fi
17
+
18
+ # Get the second command (for subcommands)
19
+ local subcmd=""
20
+ if [ $COMP_CWORD -ge 2 ]; then
21
+ subcmd="${COMP_WORDS[2]}"
22
+ fi
23
+
24
+ # --for flag completion (can appear anywhere)
25
+ if [ "$prev" = "--for" ]; then
26
+ local frameworks=$(ogp config list --quiet 2>/dev/null || echo "")
27
+ COMPREPLY=( $(compgen -W "${frameworks} all" -- ${cur}) )
28
+ return 0
29
+ fi
30
+
31
+ # Top-level commands
32
+ if [ $COMP_CWORD -eq 1 ]; then
33
+ opts="setup start stop status federation agent-comms config expose expose-stop shutdown install uninstall intent project completion"
34
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
35
+ return 0
36
+ fi
37
+
38
+ # federation subcommands
39
+ if [ "$cmd" = "federation" ]; then
40
+ if [ $COMP_CWORD -eq 2 ]; then
41
+ opts="list status request connect invite accept approve reject remove alias ping send scopes grant agent"
42
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
43
+ return 0
44
+ fi
45
+
46
+ # For federation commands that need peer-id, we could add dynamic peer completion here
47
+ # TODO: ogp federation list --quiet to get peer IDs/aliases
48
+ return 0
49
+ fi
50
+
51
+ # agent-comms subcommands
52
+ if [ "$cmd" = "agent-comms" ]; then
53
+ if [ $COMP_CWORD -eq 2 ]; then
54
+ opts="policies configure add-topic set-topic set-default remove-topic reset activity default logging"
55
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
56
+ return 0
57
+ fi
58
+ return 0
59
+ fi
60
+
61
+ # config subcommands
62
+ if [ "$cmd" = "config" ]; then
63
+ if [ $COMP_CWORD -eq 2 ]; then
64
+ opts="show set-default list enable disable frameworks"
65
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
66
+ return 0
67
+ fi
68
+
69
+ # For config commands that need framework ID
70
+ if [[ "$subcmd" == "set-default" || "$subcmd" == "enable" || "$subcmd" == "disable" ]]; then
71
+ if [ $COMP_CWORD -eq 3 ]; then
72
+ local frameworks=$(ogp config list --quiet 2>/dev/null || echo "")
73
+ COMPREPLY=( $(compgen -W "${frameworks}" -- ${cur}) )
74
+ return 0
75
+ fi
76
+ fi
77
+ return 0
78
+ fi
79
+
80
+ # intent subcommands
81
+ if [ "$cmd" = "intent" ]; then
82
+ if [ $COMP_CWORD -eq 2 ]; then
83
+ opts="register list remove"
84
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
85
+ return 0
86
+ fi
87
+ return 0
88
+ fi
89
+
90
+ # project subcommands
91
+ if [ "$cmd" = "project" ]; then
92
+ if [ $COMP_CWORD -eq 2 ]; then
93
+ opts="create join list remove contribute query status request-join send-contribution query-peer status-peer delete"
94
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
95
+ return 0
96
+ fi
97
+ return 0
98
+ fi
99
+
100
+ # completion subcommands
101
+ if [ "$cmd" = "completion" ]; then
102
+ if [ $COMP_CWORD -eq 2 ]; then
103
+ opts="install"
104
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
105
+ return 0
106
+ fi
107
+ return 0
108
+ fi
109
+
110
+ # expose subcommands
111
+ if [ "$cmd" = "expose" ]; then
112
+ if [ "$prev" = "-m" ] || [ "$prev" = "--method" ]; then
113
+ opts="cloudflared ngrok"
114
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
115
+ return 0
116
+ fi
117
+ return 0
118
+ fi
119
+
120
+ return 0
121
+ }
122
+
123
+ complete -F _ogp_completion ogp
@@ -0,0 +1,372 @@
1
+ #compdef ogp
2
+
3
+ # OGP zsh completion script
4
+ # Auto-generated by ogp completion install
5
+
6
+ _ogp() {
7
+ local -a frameworks peers
8
+ local curcontext="$curcontext" state line
9
+ typeset -A opt_args
10
+
11
+ # Get frameworks for --for flag
12
+ frameworks=(${(f)"$(ogp config list --quiet 2>/dev/null)"} all)
13
+
14
+ _arguments -C \
15
+ '(- *)'{-h,--help}'[Show help]' \
16
+ '(- *)'{-v,--version}'[Show version]' \
17
+ '--for[Select framework]:framework:($frameworks)' \
18
+ '1: :->command' \
19
+ '*::arg:->args'
20
+
21
+ case "$state" in
22
+ command)
23
+ _arguments '1:command:((
24
+ setup\:"Initialize OGP configuration"
25
+ start\:"Start OGP daemon"
26
+ stop\:"Stop OGP daemon"
27
+ status\:"Show daemon status"
28
+ federation\:"Manage federation"
29
+ agent-comms\:"Configure agent-to-agent messaging"
30
+ config\:"Manage configuration"
31
+ expose\:"Expose daemon via tunnel"
32
+ expose-stop\:"Stop background tunnel"
33
+ shutdown\:"Stop daemon and tunnel"
34
+ install\:"Install LaunchAgent (macOS)"
35
+ uninstall\:"Uninstall LaunchAgent (macOS)"
36
+ intent\:"Manage custom intents"
37
+ project\:"Manage project contexts"
38
+ completion\:"Install completion scripts"
39
+ ))'
40
+ ;;
41
+ args)
42
+ case ${words[1]} in
43
+ federation)
44
+ _ogp_federation
45
+ ;;
46
+ agent-comms)
47
+ _ogp_agent_comms
48
+ ;;
49
+ config)
50
+ _ogp_config
51
+ ;;
52
+ intent)
53
+ _ogp_intent
54
+ ;;
55
+ project)
56
+ _ogp_project
57
+ ;;
58
+ completion)
59
+ _ogp_completion
60
+ ;;
61
+ expose)
62
+ _ogp_expose
63
+ ;;
64
+ esac
65
+ ;;
66
+ esac
67
+ }
68
+
69
+ _ogp_federation() {
70
+ local curcontext="$curcontext" state line
71
+ typeset -A opt_args
72
+
73
+ _arguments '1:subcommand:((
74
+ list\:"List all peers"
75
+ status\:"Show federation status and alias mappings"
76
+ request\:"Send federation request to a peer"
77
+ connect\:"Connect to peer by public key via rendezvous"
78
+ invite\:"Generate invite token to share with peer"
79
+ accept\:"Accept peer invite token and connect"
80
+ approve\:"Approve pending federation request"
81
+ reject\:"Reject pending federation request"
82
+ remove\:"Remove peer from federation list"
83
+ alias\:"Set user-friendly alias for peer"
84
+ ping\:"Ping peer gateway to test connectivity"
85
+ send\:"Send message to federated peer"
86
+ scopes\:"Show scope grants for peer"
87
+ grant\:"Update scope grants for approved peer"
88
+ agent\:"Send agent-comms message to peer"
89
+ ))' \
90
+ '*::arg:->args'
91
+
92
+ case "$state" in
93
+ args)
94
+ case ${words[1]} in
95
+ list)
96
+ _arguments \
97
+ '(-s --status)'{-s,--status}'[Filter by status]:status:(pending approved rejected removed)'
98
+ ;;
99
+ request)
100
+ _arguments \
101
+ '1:peer-url:' \
102
+ '2:peer-id::' \
103
+ '(-a --alias)'{-a,--alias}'[User-friendly alias]:alias:' \
104
+ '--petname[Deprecated - use --alias]:petname:'
105
+ ;;
106
+ connect|accept)
107
+ _arguments \
108
+ '1:identifier:' \
109
+ '(-a --alias)'{-a,--alias}'[User-friendly alias]:alias:' \
110
+ '--petname[Deprecated - use --alias]:petname:'
111
+ ;;
112
+ approve)
113
+ _arguments \
114
+ '1:peer-id:' \
115
+ '--intents[Comma-separated intents to grant]:intents:' \
116
+ '--rate[Rate limit as requests/seconds]:rate:' \
117
+ '--topics[Comma-separated topics for agent-comms]:topics:'
118
+ ;;
119
+ reject|remove|scopes|alias)
120
+ _arguments '1:peer-id:'
121
+ ;;
122
+ send)
123
+ _arguments \
124
+ '1:peer-id:' \
125
+ '2:intent:' \
126
+ '3:payload:'
127
+ ;;
128
+ grant)
129
+ _arguments \
130
+ '1:peer-id:' \
131
+ '--intents[Comma-separated intents to grant]:intents:' \
132
+ '--rate[Rate limit as requests/seconds]:rate:' \
133
+ '--topics[Comma-separated topics for agent-comms]:topics:'
134
+ ;;
135
+ agent)
136
+ _arguments \
137
+ '1:peer-id:' \
138
+ '2:topic:' \
139
+ '3:message:' \
140
+ '(-p --priority)'{-p,--priority}'[Priority level]:priority:(low normal high)' \
141
+ '(-c --conversation)'{-c,--conversation}'[Conversation ID]:conversation-id:' \
142
+ '(-w --wait)'{-w,--wait}'[Wait for reply]' \
143
+ '(-t --timeout)'{-t,--timeout}'[Reply timeout in milliseconds]:timeout:'
144
+ ;;
145
+ esac
146
+ ;;
147
+ esac
148
+ }
149
+
150
+ _ogp_agent_comms() {
151
+ local curcontext="$curcontext" state line
152
+ typeset -A opt_args
153
+
154
+ _arguments '1:subcommand:((
155
+ policies\:"Show response policies"
156
+ configure\:"Configure response policies"
157
+ add-topic\:"Add topic to peer response policy"
158
+ set-topic\:"Set topic policy for peer"
159
+ set-default\:"Set per-peer default level"
160
+ remove-topic\:"Remove topic from peer policy"
161
+ reset\:"Reset peer policy to global defaults"
162
+ activity\:"Show agent-comms activity log"
163
+ default\:"Set default response level for unknown topics"
164
+ logging\:"Enable or disable activity logging"
165
+ ))' \
166
+ '*::arg:->args'
167
+
168
+ case "$state" in
169
+ args)
170
+ case ${words[1]} in
171
+ policies|activity)
172
+ _arguments '1:peer-id::'
173
+ ;;
174
+ configure)
175
+ _arguments \
176
+ '1:peer-ids::' \
177
+ '--global[Configure global default policies]' \
178
+ '--topics[Comma-separated topics]:topics:' \
179
+ '--level[Response level]:level:(full summary escalate deny off)' \
180
+ '--notes[Policy notes]:notes:'
181
+ ;;
182
+ add-topic)
183
+ _arguments \
184
+ '1:peer-id:' \
185
+ '2:topic:' \
186
+ '--level[Response level]:level:(full summary escalate deny off)' \
187
+ '--notes[Topic notes]:notes:'
188
+ ;;
189
+ set-topic)
190
+ _arguments \
191
+ '1:peer-id:' \
192
+ '2:topic:' \
193
+ '3:level:(full summary escalate deny off)' \
194
+ '--notes[Topic notes]:notes:'
195
+ ;;
196
+ set-default)
197
+ _arguments \
198
+ '1:peer-id:' \
199
+ '2:level:(full summary escalate deny off)'
200
+ ;;
201
+ remove-topic|reset)
202
+ _arguments '1:peer-id:' '2:topic::'
203
+ ;;
204
+ default)
205
+ _arguments '1:level:(full summary escalate deny off)'
206
+ ;;
207
+ logging)
208
+ _arguments '1:state:(on off true false enable disable)'
209
+ ;;
210
+ esac
211
+ ;;
212
+ esac
213
+ }
214
+
215
+ _ogp_config() {
216
+ local curcontext="$curcontext" state line
217
+ typeset -A opt_args
218
+ local -a frameworks
219
+ frameworks=(${(f)"$(ogp config list --quiet 2>/dev/null)"})
220
+
221
+ _arguments '1:subcommand:((
222
+ show\:"Show all configured frameworks and default"
223
+ set-default\:"Set default framework"
224
+ list\:"List all frameworks"
225
+ enable\:"Enable a framework"
226
+ disable\:"Disable a framework"
227
+ frameworks\:"Show all detected frameworks"
228
+ ))' \
229
+ '*::arg:->args'
230
+
231
+ case "$state" in
232
+ args)
233
+ case ${words[1]} in
234
+ set-default|enable|disable)
235
+ _arguments "1:framework:($frameworks)"
236
+ ;;
237
+ list)
238
+ _arguments '(-q --quiet)'{-q,--quiet}'[Output framework IDs only]'
239
+ ;;
240
+ esac
241
+ ;;
242
+ esac
243
+ }
244
+
245
+ _ogp_intent() {
246
+ _arguments '1:subcommand:((
247
+ register\:"Register new intent handler"
248
+ list\:"List all registered intents"
249
+ remove\:"Remove registered intent"
250
+ ))' \
251
+ '*::arg:->args'
252
+
253
+ case "$state" in
254
+ args)
255
+ case ${words[1]} in
256
+ register)
257
+ _arguments \
258
+ '1:name:' \
259
+ '--script[Path to handler script]:script:_files' \
260
+ '--description[Intent description]:description:'
261
+ ;;
262
+ remove)
263
+ _arguments '1:name:'
264
+ ;;
265
+ esac
266
+ ;;
267
+ esac
268
+ }
269
+
270
+ _ogp_project() {
271
+ _arguments '1:subcommand:((
272
+ create\:"Create new project locally"
273
+ join\:"Join existing project"
274
+ list\:"List all local projects"
275
+ remove\:"Remove local project"
276
+ contribute\:"Add contribution to project"
277
+ query\:"Query project contributions"
278
+ status\:"Show project status overview"
279
+ request-join\:"Request to join project from peer"
280
+ send-contribution\:"Send contribution to peer project"
281
+ query-peer\:"Query peer project contributions"
282
+ status-peer\:"Request project status from peer"
283
+ delete\:"Delete local project and all contributions"
284
+ ))' \
285
+ '*::arg:->args'
286
+
287
+ case "$state" in
288
+ args)
289
+ case ${words[1]} in
290
+ create)
291
+ _arguments \
292
+ '1:project-id:' \
293
+ '2:project-name:' \
294
+ '--description[Project description]:description:'
295
+ ;;
296
+ join)
297
+ _arguments \
298
+ '1:project-id:' \
299
+ '2:project-name::' \
300
+ '--create[Create project if not exists]' \
301
+ '--description[Project description]:description:'
302
+ ;;
303
+ remove|status|delete)
304
+ _arguments \
305
+ '1:project-id:' \
306
+ '--force[Skip confirmation prompt]'
307
+ ;;
308
+ contribute)
309
+ _arguments \
310
+ '1:project-id:' \
311
+ '2:type:' \
312
+ '3:summary:' \
313
+ '--metadata[Additional structured data as JSON]:metadata:' \
314
+ '--local-only[Skip auto-push to federated peers]'
315
+ ;;
316
+ query)
317
+ _arguments \
318
+ '1:project-id:' \
319
+ '--type[Filter by entry type]:type:' \
320
+ '--topic[Filter by entry type (alias)]:topic:' \
321
+ '--author[Filter by author]:author:' \
322
+ '--search[Search by text content]:search:' \
323
+ '--limit[Maximum results]:limit:'
324
+ ;;
325
+ request-join)
326
+ _arguments \
327
+ '1:peer-id:' \
328
+ '2:project-id:' \
329
+ '3:project-name:' \
330
+ '--description[Project description]:description:'
331
+ ;;
332
+ send-contribution)
333
+ _arguments \
334
+ '1:peer-id:' \
335
+ '2:project-id:' \
336
+ '3:type:' \
337
+ '4:summary:' \
338
+ '--metadata[Additional structured data as JSON]:metadata:'
339
+ ;;
340
+ query-peer)
341
+ _arguments \
342
+ '1:peer-id:' \
343
+ '2:project-id:' \
344
+ '--type[Filter by entry type]:type:' \
345
+ '--topic[Filter by entry type (alias)]:topic:' \
346
+ '--author[Filter by author]:author:' \
347
+ '--limit[Maximum results]:limit:' \
348
+ '--timeout[Response timeout in milliseconds]:timeout:'
349
+ ;;
350
+ status-peer)
351
+ _arguments \
352
+ '1:peer-id:' \
353
+ '2:project-id:'
354
+ ;;
355
+ esac
356
+ ;;
357
+ esac
358
+ }
359
+
360
+ _ogp_completion() {
361
+ _arguments '1:subcommand:((
362
+ install\:"Install completion scripts for current shell"
363
+ ))'
364
+ }
365
+
366
+ _ogp_expose() {
367
+ _arguments \
368
+ '(-m --method)'{-m,--method}'[Tunnel method]:method:(cloudflared ngrok)' \
369
+ '(-b --background)'{-b,--background}'[Run in background]'
370
+ }
371
+
372
+ _ogp