@observeone/cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +214 -0
  2. package/dist/README.md +214 -0
  3. package/dist/commands/ai-check.d.ts +9 -0
  4. package/dist/commands/ai-check.d.ts.map +1 -0
  5. package/dist/commands/ai-check.js +492 -0
  6. package/dist/commands/ai-check.js.map +1 -0
  7. package/dist/commands/apply.d.ts +6 -0
  8. package/dist/commands/apply.d.ts.map +1 -0
  9. package/dist/commands/apply.js +290 -0
  10. package/dist/commands/apply.js.map +1 -0
  11. package/dist/commands/check.d.ts +9 -0
  12. package/dist/commands/check.d.ts.map +1 -0
  13. package/dist/commands/check.js +267 -0
  14. package/dist/commands/check.js.map +1 -0
  15. package/dist/commands/export.d.ts +6 -0
  16. package/dist/commands/export.d.ts.map +1 -0
  17. package/dist/commands/export.js +95 -0
  18. package/dist/commands/export.js.map +1 -0
  19. package/dist/commands/heartbeat.d.ts +9 -0
  20. package/dist/commands/heartbeat.d.ts.map +1 -0
  21. package/dist/commands/heartbeat.js +264 -0
  22. package/dist/commands/heartbeat.js.map +1 -0
  23. package/dist/commands/list.d.ts +9 -0
  24. package/dist/commands/list.d.ts.map +1 -0
  25. package/dist/commands/list.js +42 -0
  26. package/dist/commands/list.js.map +1 -0
  27. package/dist/commands/login.d.ts +9 -0
  28. package/dist/commands/login.d.ts.map +1 -0
  29. package/dist/commands/login.js +192 -0
  30. package/dist/commands/login.js.map +1 -0
  31. package/dist/commands/monitor.d.ts +9 -0
  32. package/dist/commands/monitor.d.ts.map +1 -0
  33. package/dist/commands/monitor.js +292 -0
  34. package/dist/commands/monitor.js.map +1 -0
  35. package/dist/index.d.ts +5 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +125 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/interfaces/api-client.interface.d.ts +76 -0
  40. package/dist/interfaces/api-client.interface.d.ts.map +1 -0
  41. package/dist/interfaces/api-client.interface.js +2 -0
  42. package/dist/interfaces/api-client.interface.js.map +1 -0
  43. package/dist/interfaces/config.interface.d.ts +26 -0
  44. package/dist/interfaces/config.interface.d.ts.map +1 -0
  45. package/dist/interfaces/config.interface.js +2 -0
  46. package/dist/interfaces/config.interface.js.map +1 -0
  47. package/dist/interfaces/output.interface.d.ts +22 -0
  48. package/dist/interfaces/output.interface.d.ts.map +1 -0
  49. package/dist/interfaces/output.interface.js +2 -0
  50. package/dist/interfaces/output.interface.js.map +1 -0
  51. package/dist/interfaces/sse-client.interface.d.ts +18 -0
  52. package/dist/interfaces/sse-client.interface.d.ts.map +1 -0
  53. package/dist/interfaces/sse-client.interface.js +6 -0
  54. package/dist/interfaces/sse-client.interface.js.map +1 -0
  55. package/dist/package.json +42 -0
  56. package/dist/services/api-client.service.d.ts +82 -0
  57. package/dist/services/api-client.service.d.ts.map +1 -0
  58. package/dist/services/api-client.service.js +262 -0
  59. package/dist/services/api-client.service.js.map +1 -0
  60. package/dist/services/config.service.d.ts +32 -0
  61. package/dist/services/config.service.d.ts.map +1 -0
  62. package/dist/services/config.service.js +104 -0
  63. package/dist/services/config.service.js.map +1 -0
  64. package/dist/services/output.service.d.ts +28 -0
  65. package/dist/services/output.service.d.ts.map +1 -0
  66. package/dist/services/output.service.js +258 -0
  67. package/dist/services/output.service.js.map +1 -0
  68. package/dist/services/sse-client.service.d.ts +16 -0
  69. package/dist/services/sse-client.service.d.ts.map +1 -0
  70. package/dist/services/sse-client.service.js +80 -0
  71. package/dist/services/sse-client.service.js.map +1 -0
  72. package/dist/types/index.d.ts +106 -0
  73. package/dist/types/index.d.ts.map +1 -0
  74. package/dist/types/index.js +2 -0
  75. package/dist/types/index.js.map +1 -0
  76. package/dist/utils/live-progress.d.ts +23 -0
  77. package/dist/utils/live-progress.d.ts.map +1 -0
  78. package/dist/utils/live-progress.js +116 -0
  79. package/dist/utils/live-progress.js.map +1 -0
  80. package/dist/utils/log-writer.d.ts +13 -0
  81. package/dist/utils/log-writer.d.ts.map +1 -0
  82. package/dist/utils/log-writer.js +97 -0
  83. package/dist/utils/log-writer.js.map +1 -0
  84. package/package.json +66 -0
package/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # ObserveOne CLI
2
+
3
+ AI-powered website monitoring, synthetic testing, and infrastructure-as-code from your terminal.
4
+
5
+ The `obs` CLI allows developers and AI Agents to manage URL Monitors, API Checks, Heartbeats, and AI Browser tests using simple commands or declarative JSON configuration files.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install -g @observe1/cli
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ 1. **Login to ObserveOne**
16
+ ```bash
17
+ obs login
18
+ ```
19
+
20
+ 2. **Pull your existing configuration**
21
+ ```bash
22
+ obs export
23
+ ```
24
+
25
+ 3. **Manage a monitor**
26
+ ```bash
27
+ obs monitor create --name "My Website" --url "https://example.com" --interval "*/5 * * * *"
28
+ obs monitor list
29
+ ```
30
+
31
+ ---
32
+
33
+ ## 🏗️ Config-as-Code (Declarative Workflow)
34
+
35
+ ObserveOne supports an Infrastructure-as-Code (IaC) workflow using JSON. You can define all your monitors, API checks, and heartbeats in a single `observeone.json` file and sync them to your account.
36
+
37
+ ### `obs export`
38
+ Fetch all your existing remote resources from the ObserveOne backend and save them locally.
39
+ ```bash
40
+ # Generates observeone.json in the current directory
41
+ obs export
42
+
43
+ # Save to a custom file
44
+ obs export -f my-stack.json
45
+ ```
46
+
47
+ ### `obs apply`
48
+ Sync your local JSON configuration to the ObserveOne backend. The CLI will automatically detect matching resources and perform surgical `create` and `update` API calls.
49
+ ```bash
50
+ # Sync observeone.json
51
+ obs apply
52
+
53
+ # Sync a custom file
54
+ obs apply -f my-stack.json
55
+ ```
56
+
57
+ **Example `observeone.json` schema:**
58
+ ```json
59
+ {
60
+ "monitors": [
61
+ {
62
+ "name": "Production Website",
63
+ "url": "https://example.com",
64
+ "interval": "*/5 * * * *",
65
+ "alert_on_failure": true
66
+ }
67
+ ],
68
+ "api_checks": [
69
+ {
70
+ "name": "Health API",
71
+ "url": "https://api.example.com/health",
72
+ "method": "GET"
73
+ }
74
+ ],
75
+ "heartbeats": [
76
+ {
77
+ "name": "Database Backup Job",
78
+ "period": 86400
79
+ }
80
+ ]
81
+ }
82
+ ```
83
+
84
+ ---
85
+
86
+ ## 🛠️ Resource Management (CRUD)
87
+
88
+ You can manually create, read, update, delete, and toggle individual resources directly from the terminal.
89
+
90
+ ### URL Monitors
91
+ Manage basic HTTP ping monitors.
92
+ ```bash
93
+ obs monitor create --name "Frontend" --url "https://example.com" --interval "*/5 * * * *"
94
+ obs monitor list
95
+ obs monitor get <id>
96
+ obs monitor update <id> --name "Updated Frontend" --interval "*/10 * * * *"
97
+ obs monitor toggle <id>
98
+ obs monitor delete <id> -y
99
+ ```
100
+
101
+ ### API Checks
102
+ Manage complex API health checks.
103
+ ```bash
104
+ obs check create --name "Auth API" --url "https://api.example.com/auth" --method "POST"
105
+ obs check list
106
+ obs check update <id> --method "GET"
107
+ obs check toggle <id>
108
+ obs check delete <id> -y
109
+ ```
110
+
111
+ ### Heartbeats (Cron Monitoring)
112
+ Manage heartbeat checks (for monitoring background jobs or cron tasks).
113
+ ```bash
114
+ obs heartbeat create --name "Daily Backup" --period 86400
115
+ obs heartbeat list
116
+ obs heartbeat update <id> --period 43200
117
+ obs heartbeat toggle <id>
118
+ obs heartbeat delete <id> -y
119
+ ```
120
+
121
+ ### AI Browser Checks
122
+ Manage and execute intelligent Playwright-driven browser tests using natural language prompts.
123
+ ```bash
124
+ obs ai-check create --name "Login Flow" --url "https://app.com" --prompt "Login with test@example.com"
125
+ obs ai-check list
126
+ obs ai-check get <id>
127
+ obs ai-check delete <id> -y
128
+ ```
129
+
130
+ #### Running AI Checks
131
+ You can execute pre-configured checks or run them "ad-hoc" on the fly.
132
+ ```bash
133
+ # Run an existing test by name or ID
134
+ obs ai-check run "Login Flow"
135
+ obs ai-check run 123
136
+
137
+ # Run multiple tests sequentially
138
+ obs ai-check run test1 test2 test3
139
+
140
+ # Run an ad-hoc test without saving it to the database
141
+ obs ai-check run --adhoc --url https://example.com --prompt "Verify the hero section exists"
142
+ ```
143
+
144
+ ---
145
+
146
+ ## 🤖 AI Agent Integration (Headless Mode)
147
+
148
+ The `obs` CLI is explicitly designed to be used by AI coding agents (like Cursor, GitHub Copilot, Claude Code, or custom bots).
149
+
150
+ ### The `--json` Flag
151
+ Append `--json` to **any** command. The CLI will automatically suppress all human-readable output (chalk colors, loading spinners, raw logs) and return a strict, machine-readable `JsonEnvelope`.
152
+
153
+ ```bash
154
+ obs monitor list --json
155
+ obs apply -f my-stack.json --json
156
+ ```
157
+
158
+ **Guaranteed Agent Response Schema:**
159
+ ```json
160
+ {
161
+ "status": "SUCCESS",
162
+ "data": { ... },
163
+ "metadata": {
164
+ "timestamp": "2026-03-11T12:00:00.000Z"
165
+ }
166
+ }
167
+ ```
168
+ *(If an error occurs, `status` will be `"ERROR"` and the envelope will contain a strict `error` object, preventing the agent's JSON parser from crashing).*
169
+
170
+ ### Headless Authentication
171
+ Agents can authenticate securely using environment variables without interactive browser prompts:
172
+ ```bash
173
+ export OBS_EMAIL="agent@company.com"
174
+ export OBS_PASSWORD="secure-password"
175
+
176
+ # Automatically provisions and saves an API key to local config
177
+ obs login --headless
178
+ ```
179
+
180
+ Alternatively, inject an existing API key directly into the environment:
181
+ ```bash
182
+ export OBS_API_KEY="your_api_key_here"
183
+ ```
184
+
185
+ ---
186
+
187
+ ## ⚙️ Global Configuration
188
+
189
+ Available for all commands:
190
+ ```bash
191
+ obs <command> [options]
192
+ ```
193
+
194
+ **Options:**
195
+ - `-v, --verbose` - Enable verbose output and stack traces
196
+ - `--json` - Output in strict JSON format
197
+ - `--api-url <url>` - Override API URL
198
+ - `--api-key <key>` - Override API key
199
+ - `--version` - Show version number
200
+ - `--help` - Show help
201
+
202
+ ### Environment Variables
203
+ ```bash
204
+ export OBS_API_URL=https://api.observeone.com
205
+ export OBS_API_KEY=your-api-key
206
+ export OBS_VERBOSE=true
207
+ export OBS_JSON_OUTPUT=true
208
+ ```
209
+
210
+ ## License
211
+ MIT
212
+
213
+ ---
214
+ **Happy Testing! 🚀**
package/dist/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # ObserveOne CLI
2
+
3
+ AI-powered website monitoring, synthetic testing, and infrastructure-as-code from your terminal.
4
+
5
+ The `obs` CLI allows developers and AI Agents to manage URL Monitors, API Checks, Heartbeats, and AI Browser tests using simple commands or declarative JSON configuration files.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install -g @observe1/cli
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ 1. **Login to ObserveOne**
16
+ ```bash
17
+ obs login
18
+ ```
19
+
20
+ 2. **Pull your existing configuration**
21
+ ```bash
22
+ obs export
23
+ ```
24
+
25
+ 3. **Manage a monitor**
26
+ ```bash
27
+ obs monitor create --name "My Website" --url "https://example.com" --interval "*/5 * * * *"
28
+ obs monitor list
29
+ ```
30
+
31
+ ---
32
+
33
+ ## 🏗️ Config-as-Code (Declarative Workflow)
34
+
35
+ ObserveOne supports an Infrastructure-as-Code (IaC) workflow using JSON. You can define all your monitors, API checks, and heartbeats in a single `observeone.json` file and sync them to your account.
36
+
37
+ ### `obs export`
38
+ Fetch all your existing remote resources from the ObserveOne backend and save them locally.
39
+ ```bash
40
+ # Generates observeone.json in the current directory
41
+ obs export
42
+
43
+ # Save to a custom file
44
+ obs export -f my-stack.json
45
+ ```
46
+
47
+ ### `obs apply`
48
+ Sync your local JSON configuration to the ObserveOne backend. The CLI will automatically detect matching resources and perform surgical `create` and `update` API calls.
49
+ ```bash
50
+ # Sync observeone.json
51
+ obs apply
52
+
53
+ # Sync a custom file
54
+ obs apply -f my-stack.json
55
+ ```
56
+
57
+ **Example `observeone.json` schema:**
58
+ ```json
59
+ {
60
+ "monitors": [
61
+ {
62
+ "name": "Production Website",
63
+ "url": "https://example.com",
64
+ "interval": "*/5 * * * *",
65
+ "alert_on_failure": true
66
+ }
67
+ ],
68
+ "api_checks": [
69
+ {
70
+ "name": "Health API",
71
+ "url": "https://api.example.com/health",
72
+ "method": "GET"
73
+ }
74
+ ],
75
+ "heartbeats": [
76
+ {
77
+ "name": "Database Backup Job",
78
+ "period": 86400
79
+ }
80
+ ]
81
+ }
82
+ ```
83
+
84
+ ---
85
+
86
+ ## 🛠️ Resource Management (CRUD)
87
+
88
+ You can manually create, read, update, delete, and toggle individual resources directly from the terminal.
89
+
90
+ ### URL Monitors
91
+ Manage basic HTTP ping monitors.
92
+ ```bash
93
+ obs monitor create --name "Frontend" --url "https://example.com" --interval "*/5 * * * *"
94
+ obs monitor list
95
+ obs monitor get <id>
96
+ obs monitor update <id> --name "Updated Frontend" --interval "*/10 * * * *"
97
+ obs monitor toggle <id>
98
+ obs monitor delete <id> -y
99
+ ```
100
+
101
+ ### API Checks
102
+ Manage complex API health checks.
103
+ ```bash
104
+ obs check create --name "Auth API" --url "https://api.example.com/auth" --method "POST"
105
+ obs check list
106
+ obs check update <id> --method "GET"
107
+ obs check toggle <id>
108
+ obs check delete <id> -y
109
+ ```
110
+
111
+ ### Heartbeats (Cron Monitoring)
112
+ Manage heartbeat checks (for monitoring background jobs or cron tasks).
113
+ ```bash
114
+ obs heartbeat create --name "Daily Backup" --period 86400
115
+ obs heartbeat list
116
+ obs heartbeat update <id> --period 43200
117
+ obs heartbeat toggle <id>
118
+ obs heartbeat delete <id> -y
119
+ ```
120
+
121
+ ### AI Browser Checks
122
+ Manage and execute intelligent Playwright-driven browser tests using natural language prompts.
123
+ ```bash
124
+ obs ai-check create --name "Login Flow" --url "https://app.com" --prompt "Login with test@example.com"
125
+ obs ai-check list
126
+ obs ai-check get <id>
127
+ obs ai-check delete <id> -y
128
+ ```
129
+
130
+ #### Running AI Checks
131
+ You can execute pre-configured checks or run them "ad-hoc" on the fly.
132
+ ```bash
133
+ # Run an existing test by name or ID
134
+ obs ai-check run "Login Flow"
135
+ obs ai-check run 123
136
+
137
+ # Run multiple tests sequentially
138
+ obs ai-check run test1 test2 test3
139
+
140
+ # Run an ad-hoc test without saving it to the database
141
+ obs ai-check run --adhoc --url https://example.com --prompt "Verify the hero section exists"
142
+ ```
143
+
144
+ ---
145
+
146
+ ## 🤖 AI Agent Integration (Headless Mode)
147
+
148
+ The `obs` CLI is explicitly designed to be used by AI coding agents (like Cursor, GitHub Copilot, Claude Code, or custom bots).
149
+
150
+ ### The `--json` Flag
151
+ Append `--json` to **any** command. The CLI will automatically suppress all human-readable output (chalk colors, loading spinners, raw logs) and return a strict, machine-readable `JsonEnvelope`.
152
+
153
+ ```bash
154
+ obs monitor list --json
155
+ obs apply -f my-stack.json --json
156
+ ```
157
+
158
+ **Guaranteed Agent Response Schema:**
159
+ ```json
160
+ {
161
+ "status": "SUCCESS",
162
+ "data": { ... },
163
+ "metadata": {
164
+ "timestamp": "2026-03-11T12:00:00.000Z"
165
+ }
166
+ }
167
+ ```
168
+ *(If an error occurs, `status` will be `"ERROR"` and the envelope will contain a strict `error` object, preventing the agent's JSON parser from crashing).*
169
+
170
+ ### Headless Authentication
171
+ Agents can authenticate securely using environment variables without interactive browser prompts:
172
+ ```bash
173
+ export OBS_EMAIL="agent@company.com"
174
+ export OBS_PASSWORD="secure-password"
175
+
176
+ # Automatically provisions and saves an API key to local config
177
+ obs login --headless
178
+ ```
179
+
180
+ Alternatively, inject an existing API key directly into the environment:
181
+ ```bash
182
+ export OBS_API_KEY="your_api_key_here"
183
+ ```
184
+
185
+ ---
186
+
187
+ ## ⚙️ Global Configuration
188
+
189
+ Available for all commands:
190
+ ```bash
191
+ obs <command> [options]
192
+ ```
193
+
194
+ **Options:**
195
+ - `-v, --verbose` - Enable verbose output and stack traces
196
+ - `--json` - Output in strict JSON format
197
+ - `--api-url <url>` - Override API URL
198
+ - `--api-key <key>` - Override API key
199
+ - `--version` - Show version number
200
+ - `--help` - Show help
201
+
202
+ ### Environment Variables
203
+ ```bash
204
+ export OBS_API_URL=https://api.observeone.com
205
+ export OBS_API_KEY=your-api-key
206
+ export OBS_VERBOSE=true
207
+ export OBS_JSON_OUTPUT=true
208
+ ```
209
+
210
+ ## License
211
+ MIT
212
+
213
+ ---
214
+ **Happy Testing! 🚀**
@@ -0,0 +1,9 @@
1
+ import { Command } from 'commander';
2
+ import { IConfigService } from '../interfaces/config.interface.js';
3
+ import { IApiClient } from '../interfaces/api-client.interface.js';
4
+ import { IOutputService } from '../interfaces/output.interface.js';
5
+ /**
6
+ * Factory function to create ai-check command with direct service injection
7
+ */
8
+ export declare function createAiCheckCommand(configService: IConfigService, apiClient: IApiClient, outputService: IOutputService): Command;
9
+ //# sourceMappingURL=ai-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-check.d.ts","sourceRoot":"","sources":["../../src/commands/ai-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAMnE;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,cAAc,EAC7B,SAAS,EAAE,UAAU,EACrB,aAAa,EAAE,cAAc,GAC5B,OAAO,CAiQT"}