@wabery/cli 0.1.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wabery
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,199 @@
1
+ # Wabery CLI and MCP Server
2
+
3
+ Developer-facing CLI and MCP server for Wabery flows, automations, WhatsApp contacts, dispatches, and submissions.
4
+
5
+ ## Setup
6
+
7
+ Install the CLI, then sign in through your browser:
8
+
9
+ ```sh
10
+ npm i -g @wabery/cli
11
+ wabery login
12
+ ```
13
+
14
+ `wabery login` opens `app.wabery.com`, asks you to authorize the CLI, creates
15
+ an API key for your current Wabery organization, and stores it in your local
16
+ CLI config file. You can still override credentials explicitly:
17
+
18
+ ```sh
19
+ export WABERY_API_KEY="wab_live_..."
20
+ export WABERY_BASE_URL="https://app.wabery.com"
21
+ ```
22
+
23
+ Do not pass real keys to `wabery mcp-config --api-key`; generated MCP snippets
24
+ use a placeholder so credentials can live in your CLI config, shell, MCP client
25
+ secret storage, or another local secret manager. Public API keys support scoped
26
+ permissions. Use the smallest scope set the integration needs.
27
+
28
+ For local repository development, build the workspace package:
29
+
30
+ ```sh
31
+ pnpm --filter @wabery/cli build
32
+ ```
33
+
34
+ Run diagnostics and MCP config from the installed CLI:
35
+
36
+ ```sh
37
+ wabery login
38
+ wabery doctor
39
+ wabery mcp-config claude --raw
40
+ wabery mcp-config codex --raw
41
+ wabery mcp-config opencode --raw
42
+ wabery mcp
43
+ ```
44
+
45
+ MCP starts in read-only mode. To allow mutation tools for a trusted local
46
+ session, set `WABERY_MCP_MODE=write` or generate config with `--write`.
47
+ High-risk tools also require confirmation tokens:
48
+
49
+ - `wabery_apply_config`: `confirmation_token: "apply_config"`
50
+ - `wabery_publish_flow`: `confirmation_token: "publish:<flow_id>"`
51
+ - `wabery_unenroll_contact` with `erase=true`: `confirmation_token: "erase:<contact_id>"`
52
+
53
+ ## Claude Code
54
+
55
+ Add a Wabery MCP server to `.mcp.json`:
56
+
57
+ ```sh
58
+ wabery mcp-config claude --raw
59
+ ```
60
+
61
+ Installed CLI:
62
+
63
+ ```json
64
+ {
65
+ "mcpServers": {
66
+ "wabery": {
67
+ "command": "wabery",
68
+ "args": ["mcp"],
69
+ "env": {
70
+ "WABERY_API_KEY": "wab_live_...",
71
+ "WABERY_BASE_URL": "https://app.wabery.com"
72
+ }
73
+ }
74
+ }
75
+ }
76
+ ```
77
+
78
+ ## Codex
79
+
80
+ Add a Wabery MCP server to Codex `config.toml`:
81
+
82
+ ```sh
83
+ wabery mcp-config codex --raw
84
+ ```
85
+
86
+ Installed CLI:
87
+
88
+ ```toml
89
+ [mcp_servers.wabery]
90
+ command = "wabery"
91
+ args = ["mcp"]
92
+ env = { WABERY_API_KEY = "wab_live_...", WABERY_BASE_URL = "https://app.wabery.com" }
93
+ ```
94
+
95
+ ## OpenCode
96
+
97
+ Add a Wabery MCP server to OpenCode `opencode.json`:
98
+
99
+ ```sh
100
+ wabery mcp-config opencode --raw
101
+ ```
102
+
103
+ Installed CLI:
104
+
105
+ ```json
106
+ {
107
+ "$schema": "https://opencode.ai/config.json",
108
+ "mcp": {
109
+ "wabery": {
110
+ "type": "local",
111
+ "command": ["wabery", "mcp"],
112
+ "enabled": true,
113
+ "environment": {
114
+ "WABERY_API_KEY": "wab_live_...",
115
+ "WABERY_BASE_URL": "https://app.wabery.com"
116
+ }
117
+ }
118
+ }
119
+ }
120
+ ```
121
+
122
+ ## MCP Tools
123
+
124
+ - `wabery_get_config_schema`
125
+ - `wabery_get_config_example`
126
+ - `wabery_check_connection`
127
+ - `wabery_export_config`
128
+ - `wabery_validate_config`
129
+ - `wabery_preview_config_diff`
130
+ - `wabery_apply_config`
131
+ - `wabery_list_projects`
132
+ - `wabery_create_project`
133
+ - `wabery_list_channels`
134
+ - `wabery_list_flows`
135
+ - `wabery_get_flow`
136
+ - `wabery_publish_flow`
137
+ - `wabery_enroll_contact`
138
+ - `wabery_list_contacts`
139
+ - `wabery_get_contact`
140
+ - `wabery_unenroll_contact`
141
+ - `wabery_send_flow`
142
+ - `wabery_list_submissions`
143
+ - `wabery_list_dispatches`
144
+ - `wabery_get_dispatch`
145
+
146
+ ## Typical Developer Workflow
147
+
148
+ 1. List or create a project:
149
+
150
+ ```sh
151
+ wabery login
152
+ wabery doctor
153
+ wabery projects list
154
+ wabery projects create --name "Demo project"
155
+ ```
156
+
157
+ 2. Enroll a WhatsApp phone number and capture the returned `contact_id` and `channel_id`:
158
+
159
+ ```sh
160
+ wabery contacts enroll \
161
+ --project-id "proj_or_agent_id" \
162
+ --phone "+15555550123" \
163
+ --name "Jane Developer" \
164
+ --reference-id "user_123"
165
+ wabery contacts get "contact_id"
166
+ ```
167
+
168
+ 3. Generate and validate `wabery.config.json`:
169
+
170
+ ```sh
171
+ wabery config init wabery.config.json --project-id "proj_or_agent_id"
172
+ wabery config validate wabery.config.json
173
+ wabery config diff wabery.config.json
174
+ wabery config apply wabery.config.json
175
+ ```
176
+
177
+ 4. Publish a flow explicitly after review:
178
+
179
+ ```sh
180
+ wabery flows list
181
+ wabery flows publish "flow_id"
182
+ ```
183
+
184
+ 5. Send a published flow:
185
+
186
+ ```sh
187
+ wabery channels list
188
+ wabery flows send "flow_id" --channel-id "channel_id" --contact-id "contact_id"
189
+ ```
190
+
191
+ For sandbox projects, `wabery contacts enroll` returns the shared sandbox `channel_id` that is authorized for that phone number. Use that `channel_id` when sending a flow to the returned `contact_id`.
192
+
193
+ To remove a phone's sandbox authorization:
194
+
195
+ ```sh
196
+ wabery contacts unenroll "contact_id"
197
+ ```
198
+
199
+ `wabery config apply` intentionally does not publish flows to Meta. Agents should call `wabery_publish_flow` only after explicit user confirmation and with the required confirmation token.
@@ -0,0 +1,22 @@
1
+ export interface WaberyClientOptions {
2
+ apiKey?: string;
3
+ baseUrl?: string;
4
+ apiVersion?: string;
5
+ }
6
+ export declare class WaberyApiError extends Error {
7
+ readonly status: number;
8
+ readonly body: unknown;
9
+ constructor(message: string, status: number, body: unknown);
10
+ }
11
+ export declare class WaberyApiClient {
12
+ private readonly apiKey;
13
+ private readonly baseUrl;
14
+ private readonly apiVersion?;
15
+ constructor(options?: WaberyClientOptions);
16
+ get(path: string, query?: Record<string, string | number | undefined>): Promise<unknown>;
17
+ post(path: string, body?: unknown): Promise<unknown>;
18
+ put(path: string, body?: unknown): Promise<unknown>;
19
+ delete(path: string): Promise<unknown>;
20
+ private request;
21
+ }
22
+ //# sourceMappingURL=api-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,cAAe,SAAQ,KAAK;aAGvB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,OAAO;gBAF7B,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO;CAI9B;AAED,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAS;gBAEzB,OAAO,GAAE,mBAAwB;IAoBvC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAIrE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;IAIjC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;IAIhC,MAAM,CAAC,IAAI,EAAE,MAAM;YAIX,OAAO;CAuCrB"}
@@ -0,0 +1,86 @@
1
+ import { readLocalConfig } from "./local-config.js";
2
+ export class WaberyApiError extends Error {
3
+ status;
4
+ body;
5
+ constructor(message, status, body) {
6
+ super(message);
7
+ this.status = status;
8
+ this.body = body;
9
+ }
10
+ }
11
+ export class WaberyApiClient {
12
+ apiKey;
13
+ baseUrl;
14
+ apiVersion;
15
+ constructor(options = {}) {
16
+ const localConfig = readLocalConfig();
17
+ const apiKey = options.apiKey ?? process.env.WABERY_API_KEY ?? localConfig.apiKey;
18
+ if (!apiKey) {
19
+ throw new Error("Missing WABERY_API_KEY. Run `wabery login`, or create an API key in Wabery and pass it as an environment variable.");
20
+ }
21
+ this.apiKey = apiKey;
22
+ this.baseUrl = normalizeBaseUrl(options.baseUrl ??
23
+ process.env.WABERY_BASE_URL ??
24
+ localConfig.baseUrl ??
25
+ "https://app.wabery.com");
26
+ this.apiVersion = options.apiVersion ?? process.env.WABERY_API_VERSION;
27
+ }
28
+ async get(path, query) {
29
+ return this.request("GET", path, undefined, query);
30
+ }
31
+ async post(path, body) {
32
+ return this.request("POST", path, body);
33
+ }
34
+ async put(path, body) {
35
+ return this.request("PUT", path, body);
36
+ }
37
+ async delete(path) {
38
+ return this.request("DELETE", path);
39
+ }
40
+ async request(method, path, body, query) {
41
+ const url = new URL(`${this.baseUrl}${path.startsWith("/") ? path : `/${path}`}`);
42
+ for (const [key, value] of Object.entries(query ?? {})) {
43
+ if (value !== undefined)
44
+ url.searchParams.set(key, String(value));
45
+ }
46
+ const headers = {
47
+ authorization: `Bearer ${this.apiKey}`,
48
+ accept: "application/json",
49
+ };
50
+ if (this.apiVersion)
51
+ headers["wabery-version"] = this.apiVersion;
52
+ if (body !== undefined)
53
+ headers["content-type"] = "application/json";
54
+ const response = await fetch(url, {
55
+ method,
56
+ headers,
57
+ body: body === undefined ? undefined : JSON.stringify(body),
58
+ });
59
+ const responseBody = await readResponse(response);
60
+ if (!response.ok) {
61
+ const message = typeof responseBody === "object" &&
62
+ responseBody !== null &&
63
+ "message" in responseBody
64
+ ? String(responseBody.message)
65
+ : `Wabery API request failed with HTTP ${response.status}`;
66
+ throw new WaberyApiError(message, response.status, responseBody);
67
+ }
68
+ return responseBody;
69
+ }
70
+ }
71
+ function normalizeBaseUrl(value) {
72
+ const trimmed = value.replace(/\/+$/, "");
73
+ return trimmed.endsWith("/api/v1") ? trimmed : `${trimmed}/api/v1`;
74
+ }
75
+ async function readResponse(response) {
76
+ const text = await response.text();
77
+ if (!text)
78
+ return null;
79
+ try {
80
+ return JSON.parse(text);
81
+ }
82
+ catch {
83
+ return text;
84
+ }
85
+ }
86
+ //# sourceMappingURL=api-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAQpD,MAAM,OAAO,cAAe,SAAQ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