@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
@@ -0,0 +1,250 @@
1
+ # OpenClaw Crash Observations - April 7, 2026
2
+
3
+ > **Note:** This document is a sanitized version of internal debugging notes. API key fragments, file paths, and system-specific details have been removed or generalized. Created during OGP development to document OpenClaw regression analysis.
4
+
5
+ ---
6
+
7
+ ## Timeline Summary
8
+
9
+ User reported that OpenClaw has been crashing non-stop for the last 24 hours after previously working without issues. Multiple agents were affected, with the gateway itself crashing repeatedly.
10
+
11
+ ---
12
+
13
+ ## Issues Identified & Fixed
14
+
15
+ ### 1. Cascading Authentication Failures (8:00 AM)
16
+
17
+ **Symptoms:**
18
+ - Agent failing with all configured model providers
19
+ - Error sequence: Multiple providers failing in sequence
20
+ - "All models failed" errors in logs
21
+
22
+ **Root Causes:**
23
+ - Kimi API: HTTP 401 - Invalid/expired API key
24
+ - Anthropic API: HTTP 401 - Invalid API key (rate limits also hit)
25
+ - OpenAI API: 401 - Malformed API key (env var expansion failing)
26
+
27
+ **Analysis:**
28
+ The `openclaw doctor` command appeared to have modified the configuration file, simplifying the env section and causing environment variable expansion to fail. The OpenAI provider had a misconfigured API key reference.
29
+
30
+ **Fix Applied:**
31
+ - Restored proper API key references in env section
32
+ - Changed OpenAI provider to use environment variable references
33
+
34
+ ### 2. Model Configuration Corruption (Multiple Occurrences)
35
+
36
+ **Symptoms:**
37
+ - Agent configuration simplified to only primary model, no fallbacks
38
+ - Default model referencing non-existent model ID
39
+ - Invalid model IDs causing 404 errors
40
+
41
+ **Root Cause:**
42
+ Configuration file was being modified (likely by `openclaw doctor` command or auto-formatting) which:
43
+ - Removed fallback models from agent configurations
44
+ - Simplified environment variable definitions
45
+ - Changed model references
46
+
47
+ **Example Configuration Issue:**
48
+ ```json
49
+ // Broken (no fallbacks)
50
+ "model": {
51
+ "primary": "anthropic/claude-sonnet-4-6"
52
+ }
53
+
54
+ // Restored (with fallbacks)
55
+ "model": {
56
+ "primary": "openai/gpt-5.4",
57
+ "fallbacks": [
58
+ "anthropic/claude-sonnet-4-6",
59
+ "openai/gpt-4o",
60
+ "fireworks/accounts/fireworks/models/kimi-k2p5"
61
+ ]
62
+ }
63
+ ```
64
+
65
+ ### 3. OpenAI API 404 Errors (9:00-9:50 AM)
66
+
67
+ **Symptoms:**
68
+ - Continuous 404 errors on OpenAI models
69
+ - All OpenAI models failing despite being available via API
70
+
71
+ **Root Cause:**
72
+ GPT-5.4 and newer models require the **Responses API** endpoint (`/v1/responses`) instead of the Chat Completions API endpoint (`/v1/chat/completions`). OpenClaw was using the wrong endpoint.
73
+
74
+ **Evidence:**
75
+ - Manual API query confirmed models exist: `gpt-5.4`, `gpt-5.4-2026-03-05`, `gpt-4o` all available
76
+ - OpenAI documentation confirmed GPT-5.4 requires Responses API
77
+ - Error pattern: 404 with no body = wrong endpoint
78
+
79
+ **Fix Applied:**
80
+ Added `"api": "openai-responses"` to OpenAI provider configuration:
81
+ ```json
82
+ "openai": {
83
+ "baseUrl": "https://api.openai.com/v1",
84
+ "apiKey": "${PERSONAL_OPENAI_API_KEY}",
85
+ "api": "openai-responses",
86
+ "models": [...]
87
+ }
88
+ ```
89
+
90
+ **References:**
91
+ - GitHub Issue: openclaw/openclaw#38706 - "GPT-5.4 via openai-codex OAuth uses wrong API"
92
+ - OpenAI Docs: Responses API required for GPT-5.4+
93
+
94
+ ### 4. Gateway Crash - "Agent listener invoked outside active run" (12:08 PM)
95
+
96
+ **Symptoms:**
97
+ - Gateway completely unreachable
98
+ - LaunchAgent exit status: -1
99
+ - Error: `Unhandled promise rejection: Error: Agent listener invoked outside active run`
100
+
101
+ **Stack Trace:**
102
+ ```
103
+ at Agent.processEvents (pi-agent-core/src/agent.ts:533:10)
104
+ at emitUpdate (exec-defaults-*.js:1524:8)
105
+ at handleStdout (exec-defaults-*.js:1546:4)
106
+ ```
107
+
108
+ **Context:**
109
+ Crash occurred during OGP federation testing operations. Preceding log entries show:
110
+ - Edit operations failing
111
+ - Read operations failing for config files
112
+ - Multiple edit retry attempts
113
+
114
+ **Hypothesis:**
115
+ The crash may be related to:
116
+ 1. OGP operations triggering edge cases in the exec/agent framework
117
+ 2. File operations failing and causing state inconsistencies
118
+ 3. Agent event processing happening outside the expected execution context
119
+
120
+ **Fix Applied:**
121
+ Gateway restart resolved the immediate issue, but underlying cause remained unclear at the time.
122
+
123
+ ---
124
+
125
+ ## Configuration Stability Concerns
126
+
127
+ ### Observed Pattern:
128
+ 1. Manual configuration changes applied
129
+ 2. Gateway restart
130
+ 3. Configuration file modified by unknown process
131
+ 4. Settings reverted or simplified
132
+ 5. Agents fail again
133
+
134
+ ### Suspected Culprits:
135
+ - `openclaw doctor` command
136
+ - Auto-formatting/validation on config reload
137
+ - Hot reload mechanism modifying config
138
+
139
+ ---
140
+
141
+ ## Gateway Stability Observations
142
+
143
+ ### Crash Frequency:
144
+ - Multiple gateway restarts required during debugging session
145
+ - Many restarts over 4-hour period
146
+ - One complete crash requiring manual intervention
147
+
148
+ ### Memory/CPU Usage:
149
+ - Gateway process consistently using high CPU during startup
150
+ - Process ID changing frequently
151
+
152
+ ### LaunchAgent Behavior:
153
+ - LaunchAgent showing status `-1` during crashes
154
+ - Sometimes showing status `0` but process not actually running
155
+ - Restart command occasionally reports "stale process" and force-kills
156
+
157
+ ---
158
+
159
+ ## OGP-Related Observations
160
+
161
+ ### Timing Correlation:
162
+ User mentioned doing OGP work and the timeline suggests:
163
+ - OpenClaw was stable before OGP work
164
+ - Issues began within last 24 hours
165
+ - Gateway crash occurred during OGP federation operations
166
+
167
+ ### OGP Operations Observed in Logs:
168
+ - Federation requests to Clawporate gateway
169
+ - Agent-to-agent communication attempts
170
+ - File operations on OGP-related files
171
+ - Attempts to read OGP config (file not found)
172
+
173
+ ### Potential OGP-Related Issues:
174
+ 1. **File Operation Failures**: Multiple edit/read failures on OGP-related files
175
+ 2. **Agent Event Processing**: Crash occurred during stdout handling from supervised process
176
+ 3. **Missing Config Files**: OGP config expected but not found in multiple locations
177
+
178
+ ---
179
+
180
+ ## Mitigation Steps Applied - 5:56 PM
181
+
182
+ ### Changes Made to Test Crash Prevention:
183
+
184
+ **1. Disabled Heartbeat Tasks**
185
+ - Removed `heartbeat` configurations from agent defaults
186
+ - **Hypothesis**: Hourly heartbeats triggering cron jobs that hit API failures and crashed the gateway
187
+
188
+ **2. Replaced Keychain Lookups with Direct API Keys**
189
+ - Changed from: `$(security find-generic-password ...)`
190
+ - Changed to: Direct environment variable references
191
+ - **Reason**: Keychain lookups repeatedly failing with env var expansion errors
192
+
193
+ **3. BrainLift Plugin**
194
+ - Already disabled (enabled: false)
195
+ - No changes needed
196
+
197
+ ---
198
+
199
+ ## Current Working Configuration
200
+
201
+ ### Models:
202
+ - **Primary**: openai/gpt-5.4 (via Responses API)
203
+ - **Fallbacks**: anthropic/claude-sonnet-4-6, openai/gpt-4o, fireworks/kimi-k2p5
204
+
205
+ ### API Keys (via environment variables):
206
+ - ANTHROPIC_API_KEY: Working
207
+ - OPENAI_API_KEY: Working (via Responses API)
208
+ - FIREWORKS_API_KEY: Working
209
+
210
+ ### Critical Config Settings:
211
+ ```json
212
+ {
213
+ "models": {
214
+ "providers": {
215
+ "openai": {
216
+ "api": "openai-responses",
217
+ "baseUrl": "https://api.openai.com/v1",
218
+ "apiKey": "${PERSONAL_OPENAI_API_KEY}"
219
+ }
220
+ }
221
+ }
222
+ }
223
+ ```
224
+
225
+ ---
226
+
227
+ ## Open Questions
228
+
229
+ 1. **What triggers config file modifications?** Is it automatic or user-initiated?
230
+ 2. **Is OGP plugin causing instability?** Correlation suggests possible connection
231
+ 3. **Why are keychain lookups failing intermittently?** Sometimes work, sometimes fail
232
+ 4. **What is the expected behavior for "Agent listener invoked outside active run"?** Is this a known edge case?
233
+
234
+ ---
235
+
236
+ ## Files Modified During Session
237
+
238
+ - `$HOME/.openclaw/openclaw.json` (multiple times)
239
+ - API key configurations
240
+ - Model provider settings
241
+ - Agent model configurations
242
+ - Environment variables
243
+
244
+ ---
245
+
246
+ **Session Date**: April 7, 2026
247
+ **OpenClaw Version**: 2026.4.5
248
+ **Total Crashes**: Multiple
249
+ **Average Uptime Between Crashes**: 10-20 minutes
250
+ **Sanitized for Publication**: April 8, 2026
@@ -290,7 +290,7 @@ Bob's OGP daemon (doorman):
290
290
  3. **Checks rate limits** - Has Alice exceeded their quota? (v0.2.0+)
291
291
  4. Verifies signature using Alice's public key
292
292
  5. Checks intent exists in registry
293
- 6. Forwards to Bob's OpenClaw via webhook or sessions_send (v0.2.3+)
293
+ 6. Forwards to Bob's OpenClaw via the local platform delivery backend
294
294
 
295
295
  If scope check fails:
296
296
  - Response: `403 Forbidden`
@@ -303,51 +303,41 @@ If rate limit exceeded:
303
303
 
304
304
  ### OpenClaw Notification
305
305
 
306
- v0.2.3+ prioritizes **sessions_send** over system events for better Telegram integration:
306
+ For human-facing federated work, the OpenClaw reference path is now an agent-turn hook rather than raw session injection:
307
307
 
308
308
  ```http
309
- POST /api/sessions/send HTTP/1.1
309
+ POST /hooks/agent HTTP/1.1
310
310
  Host: bob-openclaw.local:18789
311
- Authorization: Bearer bob-token
311
+ Authorization: Bearer <hooks-token>
312
312
  Content-Type: application/json
313
313
 
314
314
  {
315
- "sessionKey": "agent:main:main",
316
- "message": "[OGP] Message from Alice: Hello, Bob!",
317
- "ogp": {
318
- "from": "peer-alice",
319
- "intent": "message",
320
- "nonce": "550e8400-e29b-41d4-a716-446655440000",
321
- "payload": {
322
- "text": "Hello, Bob!"
315
+ "agentId": "main",
316
+ "text": "[OGP Federation] Alice says: Hello, Bob!",
317
+ "metadata": {
318
+ "ogp": {
319
+ "from": "peer-alice",
320
+ "intent": "message",
321
+ "nonce": "550e8400-e29b-41d4-a716-446655440000",
322
+ "payload": {
323
+ "text": "Hello, Bob!"
324
+ }
323
325
  }
324
326
  }
325
327
  }
326
328
  ```
327
329
 
328
- Fallback to system event if sessions_send is unavailable:
330
+ That lets OpenClaw run a real agent turn, apply the configured human-delivery policy, and decide how to surface the result to the human.
329
331
 
330
- ```http
331
- POST /api/system-event HTTP/1.1
332
- Host: bob-openclaw.local:18789
333
- Authorization: Bearer bob-token
334
- Content-Type: application/json
332
+ If OGP needs direct session injection for fallback or synchronization, it uses Gateway RPC against the TLS-enabled local gateway:
335
333
 
336
- {
337
- "text": "[OGP] Message from Alice: Hello, Bob!",
338
- "sessionKey": "agent:main:main",
339
- "ogp": {
340
- "from": "peer-alice",
341
- "intent": "message",
342
- "nonce": "550e8400-e29b-41d4-a716-446655440000",
343
- "payload": {
344
- "text": "Hello, Bob!"
345
- }
346
- }
347
- }
334
+ ```bash
335
+ openclaw gateway call --url wss://localhost:18789 sessions.send ...
348
336
  ```
349
337
 
350
- Bob's OpenClaw agent sees (via Telegram or system notification):
338
+ `sessions.send` is still useful, but it is not the primary delivery primitive for human-facing federated work.
339
+
340
+ Bob's OpenClaw agent sees the resulting human-facing output in the configured channel:
351
341
 
352
342
  ```
353
343
  [OGP] Message from Alice: Hello, Bob!
@@ -1,6 +1,10 @@
1
1
  # Hermes Integration Implementation Checklist
2
2
 
3
3
  > Developer checklist for adding Hermes support to OGP
4
+ >
5
+ > Historical note, April 9, 2026: this file is retained as an implementation artifact.
6
+ > Many unchecked boxes below were never backfilled after the sidecar work landed.
7
+ > Do not use this file as the canonical current backlog. Use `CURRENT_WORK.md` and Beads instead.
4
8
 
5
9
  ## Phase 1: Sidecar Integration (Week 1)
6
10
 
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dp-pcs/ogp",
3
- "version": "0.3.3",
3
+ "version": "0.4.2",
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",
@@ -12,6 +12,8 @@
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
  },
@@ -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