@zeph-to/hook-sdk 0.3.0 → 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.
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Zeph
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md CHANGED
@@ -10,6 +10,18 @@ npm install @zeph-to/hook-sdk
10
10
  npx @zeph-to/hook-sdk notify --title "Hello"
11
11
  ```
12
12
 
13
+ ## Quick Start
14
+
15
+ ```bash
16
+ # Interactive — detects agents, saves config, installs plugins
17
+ npx @zeph-to/hook-sdk install
18
+
19
+ # Non-interactive (one line from Zeph app)
20
+ npx @zeph-to/hook-sdk install --key ak_... --hook hook_...
21
+ ```
22
+
23
+ Saves to `~/.zeph/config.json`. All Zeph tools (CLI, MCP server, plugin hooks) read this file.
24
+
13
25
  ## CLI Usage
14
26
 
15
27
  ```bash
@@ -38,6 +50,7 @@ zeph notify --title "Hello" --json
38
50
 
39
51
  | Command | Description |
40
52
  |---------|-------------|
53
+ | `install` | One-command setup: detect agents, save config, install plugins |
41
54
  | `notify` | Send a push notification |
42
55
  | `list` | List recent push notifications |
43
56
  | `dismiss <id>` | Dismiss a push (or `--all`) |
@@ -151,4 +164,4 @@ try {
151
164
 
152
165
  ## License
153
166
 
154
- MIT
167
+ Apache-2.0
package/dist/cli.js CHANGED
@@ -1,22 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const fs_1 = require("fs");
5
- const path_1 = require("path");
6
- const readline_1 = require("readline");
7
4
  const zeph_hook_js_1 = require("./zeph-hook.js");
8
5
  const errors_js_1 = require("./errors.js");
9
- const CONFIG_DIR = (0, path_1.join)(process.env.HOME ?? '~', '.zeph');
10
- const CONFIG_FILE = (0, path_1.join)(CONFIG_DIR, 'config.json');
11
- const VERSION = (() => {
12
- try {
13
- const pkg = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '..', 'package.json'), 'utf-8'));
14
- return pkg.version;
15
- }
16
- catch {
17
- return '0.0.0';
18
- }
19
- })();
6
+ const installer_js_1 = require("./installer.js");
7
+ const config_js_1 = require("./config.js");
20
8
  // ── Arg Parser ──────────────────────────────────────────────────
21
9
  const parseArgs = (argv) => {
22
10
  const result = {};
@@ -47,7 +35,7 @@ const printUsage = () => {
47
35
  console.log(`Usage: zeph <command> [options]
48
36
 
49
37
  Commands:
50
- setup Interactive configuration (API key, Hook ID)
38
+ install One-command setup: detect agents, save config, install plugins
51
39
  notify Send a push notification
52
40
  list List recent push notifications
53
41
  dismiss <id> Dismiss a push notification (or --all)
@@ -57,7 +45,7 @@ Notify options:
57
45
  --title <text> Push title
58
46
  --body <text> Push body
59
47
  --url <url> URL to include
60
- --type <type> Push type (note|link|file) [default: note]
48
+ --type <type> Push type (note|link|file|hook) [default: hook]
61
49
  --priority <p> Priority (low|normal|high|urgent) [default: normal]
62
50
  --device <id> Target device ID
63
51
 
@@ -68,6 +56,11 @@ List options:
68
56
  Dismiss options:
69
57
  --all Dismiss all notifications
70
58
 
59
+ Install options:
60
+ --key <api-key> API key (non-interactive)
61
+ --hook <hook-id> Hook ID (non-interactive)
62
+ --base-url <url> Base URL (non-interactive)
63
+
71
64
  Global options:
72
65
  --key <api-key> API key (or set ZEPH_API_KEY env)
73
66
  --base-url <url> API base URL (or set ZEPH_BASE_URL env)
@@ -89,34 +82,13 @@ const printError = (message, isJson) => {
89
82
  const printJson = (data) => {
90
83
  console.log(JSON.stringify(data, null, 2));
91
84
  };
92
- const loadConfig = () => {
93
- try {
94
- return JSON.parse((0, fs_1.readFileSync)(CONFIG_FILE, 'utf-8'));
95
- }
96
- catch {
97
- return {};
98
- }
99
- };
100
- const saveConfig = (config) => {
101
- (0, fs_1.mkdirSync)(CONFIG_DIR, { recursive: true });
102
- (0, fs_1.writeFileSync)(CONFIG_FILE, JSON.stringify(config, null, 2) + '\n');
103
- };
104
- const prompt = (question) => {
105
- const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
106
- return new Promise((resolve) => {
107
- rl.question(question, (answer) => {
108
- rl.close();
109
- resolve(answer.trim());
110
- });
111
- });
112
- };
113
85
  // ── Commands ────────────────────────────────────────────────────
114
86
  const createHook = (args) => {
115
- const config = loadConfig();
87
+ const config = (0, config_js_1.loadConfig)();
116
88
  const apiKey = args.key || process.env.ZEPH_API_KEY || config.apiKey;
117
89
  const isJson = args.json === true;
118
90
  if (!apiKey) {
119
- printError('API key required. Run "zeph setup" or set ZEPH_API_KEY', isJson);
91
+ printError('API key required. Run "zeph install" or set ZEPH_API_KEY', isJson);
120
92
  return null;
121
93
  }
122
94
  const baseUrl = args['base-url'] || process.env.ZEPH_BASE_URL || config.baseUrl;
@@ -135,7 +107,7 @@ const handleNotify = async (args) => {
135
107
  title: args.title,
136
108
  body: args.body,
137
109
  url: args.url,
138
- type: args.type || undefined,
110
+ type: args.type || 'hook',
139
111
  priority: args.priority || undefined,
140
112
  targetDeviceId: args.device,
141
113
  });
@@ -228,7 +200,7 @@ const handleTest = async (args) => {
228
200
  try {
229
201
  const result = await hook.notify({
230
202
  title: 'Zeph Test',
231
- body: `CLI connected successfully (v${VERSION})`,
203
+ body: `CLI connected successfully (v${config_js_1.VERSION})`,
232
204
  });
233
205
  if (isJson) {
234
206
  printJson({ pushId: result.pushId, status: 'ok', message: 'Test notification sent' });
@@ -242,57 +214,6 @@ const handleTest = async (args) => {
242
214
  return handleError(err, isJson);
243
215
  }
244
216
  };
245
- const handleSetup = async () => {
246
- console.log('\n Zeph Setup\n');
247
- const existing = loadConfig();
248
- // API Key
249
- const currentKey = process.env.ZEPH_API_KEY || existing.apiKey;
250
- if (currentKey) {
251
- console.log(` API Key: ${currentKey.slice(0, 12)}... (already set)`);
252
- }
253
- const keyInput = await prompt(currentKey
254
- ? ' New API Key (Enter to keep current): '
255
- : ' API Key (from Settings > API Keys): ');
256
- const apiKey = keyInput || currentKey;
257
- if (!apiKey) {
258
- console.error('\n Error: API key is required.');
259
- return 1;
260
- }
261
- // Hook ID
262
- const currentHook = process.env.ZEPH_HOOK_ID || existing.hookId;
263
- if (currentHook) {
264
- console.log(` Hook ID: ${currentHook} (already set)`);
265
- }
266
- const hookInput = await prompt(currentHook
267
- ? ' New Hook ID (Enter to keep, "none" to remove): '
268
- : ' Hook ID (optional, for prompt/input): ');
269
- const hookId = hookInput === 'none' ? undefined : (hookInput || currentHook);
270
- // Base URL
271
- const currentUrl = process.env.ZEPH_BASE_URL || existing.baseUrl;
272
- const urlInput = await prompt(` Base URL (Enter for ${currentUrl || 'https://api.zeph.to/v1'}): `);
273
- const baseUrl = urlInput || currentUrl;
274
- // Save config
275
- const config = { apiKey, ...(hookId && { hookId }), ...(baseUrl && { baseUrl }) };
276
- saveConfig(config);
277
- console.log(`\n Config saved to ${CONFIG_FILE}`);
278
- // Test connection
279
- console.log(' Testing connection...');
280
- try {
281
- const hook = new zeph_hook_js_1.ZephHook({ apiKey, ...(baseUrl && { baseUrl }) });
282
- const result = await hook.notify({
283
- title: 'Zeph Setup',
284
- body: `CLI configured successfully (v${VERSION})`,
285
- });
286
- console.log(` Test push sent: ${result.pushId}`);
287
- }
288
- catch (err) {
289
- console.error(` Test failed: ${err instanceof Error ? err.message : 'Unknown error'}`);
290
- console.error(' Config saved but connection failed. Check your API key.');
291
- return 1;
292
- }
293
- console.log('\n Done! Restart Claude Code to apply.\n');
294
- return 0;
295
- };
296
217
  // ── Error Handler ───────────────────────────────────────────────
297
218
  const handleError = (err, isJson) => {
298
219
  if (err instanceof errors_js_1.QuotaExceededError) {
@@ -315,7 +236,7 @@ const main = async () => {
315
236
  const args = parseArgs(process.argv);
316
237
  const command = args._command;
317
238
  if (args.version === true) {
318
- console.log(VERSION);
239
+ console.log(config_js_1.VERSION);
319
240
  return 0;
320
241
  }
321
242
  if (!command || command === 'help') {
@@ -323,8 +244,9 @@ const main = async () => {
323
244
  return 0;
324
245
  }
325
246
  switch (command) {
247
+ case 'install':
326
248
  case 'setup':
327
- return handleSetup();
249
+ return (0, installer_js_1.handleInstall)(args);
328
250
  case 'notify':
329
251
  return handleNotify(args);
330
252
  case 'list':
@@ -0,0 +1,12 @@
1
+ export declare const CONFIG_DIR: string;
2
+ export declare const CONFIG_FILE: string;
3
+ export interface ZephConfig {
4
+ apiKey?: string;
5
+ hookId?: string;
6
+ baseUrl?: string;
7
+ deviceId?: string;
8
+ }
9
+ export declare const loadConfig: () => ZephConfig;
10
+ export declare const saveConfig: (config: ZephConfig) => void;
11
+ export declare const VERSION: string;
12
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,QAAyC,CAAC;AACjE,eAAO,MAAM,WAAW,QAAkC,CAAC;AAE3D,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,UAAU,QAAO,UAM7B,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,QAAQ,UAAU,KAAG,IAG/C,CAAC;AAEF,eAAO,MAAM,OAAO,QAOhB,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VERSION = exports.saveConfig = exports.loadConfig = exports.CONFIG_FILE = exports.CONFIG_DIR = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ exports.CONFIG_DIR = (0, path_1.join)(process.env.HOME ?? '~', '.zeph');
7
+ exports.CONFIG_FILE = (0, path_1.join)(exports.CONFIG_DIR, 'config.json');
8
+ const loadConfig = () => {
9
+ try {
10
+ return JSON.parse((0, fs_1.readFileSync)(exports.CONFIG_FILE, 'utf-8'));
11
+ }
12
+ catch {
13
+ return {};
14
+ }
15
+ };
16
+ exports.loadConfig = loadConfig;
17
+ const saveConfig = (config) => {
18
+ (0, fs_1.mkdirSync)(exports.CONFIG_DIR, { recursive: true });
19
+ (0, fs_1.writeFileSync)(exports.CONFIG_FILE, JSON.stringify(config, null, 2) + '\n');
20
+ };
21
+ exports.saveConfig = saveConfig;
22
+ exports.VERSION = (() => {
23
+ try {
24
+ const pkg = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '..', 'package.json'), 'utf-8'));
25
+ return pkg.version;
26
+ }
27
+ catch {
28
+ return '0.0.0';
29
+ }
30
+ })();
@@ -0,0 +1,2 @@
1
+ export declare const handleInstall: (args: Record<string, string | boolean>) => Promise<number>;
2
+ //# sourceMappingURL=installer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":"AA0IA,eAAO,MAAM,aAAa,GAAU,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAG,OAAO,CAAC,MAAM,CAgH1F,CAAC"}
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleInstall = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ const readline_1 = require("readline");
8
+ const zeph_hook_js_1 = require("./zeph-hook.js");
9
+ const config_js_1 = require("./config.js");
10
+ const HOME = process.env.HOME ?? '~';
11
+ // ── Helpers ──────────────────────────────────────────────────────
12
+ const ok = (msg) => console.log(` + ${msg}`);
13
+ const fail = (msg) => console.log(` - ${msg}`);
14
+ const promptInput = (question) => {
15
+ const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
16
+ return new Promise((resolve) => {
17
+ rl.question(question, (answer) => {
18
+ rl.close();
19
+ resolve(answer.trim());
20
+ });
21
+ });
22
+ };
23
+ const hasCommand = (cmd) => {
24
+ try {
25
+ (0, child_process_1.execSync)(`which ${cmd}`, { stdio: 'pipe' });
26
+ return true;
27
+ }
28
+ catch {
29
+ return false;
30
+ }
31
+ };
32
+ // ── Agent Detection ──────────────────────────────────────────────
33
+ const detectAgents = () => [
34
+ { name: 'Claude Code', id: 'claude', detected: hasCommand('claude') },
35
+ { name: 'Cursor', id: 'cursor', detected: (0, fs_1.existsSync)((0, path_1.join)(HOME, '.cursor')) },
36
+ { name: 'Windsurf', id: 'windsurf', detected: (0, fs_1.existsSync)((0, path_1.join)(HOME, '.codeium')) },
37
+ { name: 'Gemini CLI', id: 'gemini', detected: hasCommand('gemini') },
38
+ ];
39
+ // ── Per-Agent Installers ─────────────────────────────────────────
40
+ const injectMcpJson = (filePath) => {
41
+ let data = {};
42
+ try {
43
+ data = JSON.parse((0, fs_1.readFileSync)(filePath, 'utf-8'));
44
+ }
45
+ catch { /* new file */ }
46
+ if (!data.mcpServers)
47
+ data.mcpServers = {};
48
+ data.mcpServers.zeph = {
49
+ command: 'npx',
50
+ args: ['-y', '@zeph-to/mcp-server'],
51
+ };
52
+ (0, fs_1.mkdirSync)((0, path_1.dirname)(filePath), { recursive: true });
53
+ (0, fs_1.writeFileSync)(filePath, JSON.stringify(data, null, 2) + '\n');
54
+ };
55
+ const installClaude = () => {
56
+ try {
57
+ (0, child_process_1.execSync)('claude plugin marketplace add zeph-to/plugin', { stdio: 'pipe' });
58
+ (0, child_process_1.execSync)('claude plugin install zeph@zeph', { stdio: 'pipe' });
59
+ ok('Plugin installed');
60
+ }
61
+ catch {
62
+ fail('Plugin install failed. Manual:');
63
+ console.log(' claude plugin marketplace add zeph-to/plugin');
64
+ console.log(' claude plugin install zeph@zeph');
65
+ }
66
+ };
67
+ const installCursor = () => {
68
+ try {
69
+ injectMcpJson((0, path_1.join)(HOME, '.cursor', 'mcp.json'));
70
+ ok('MCP server added to ~/.cursor/mcp.json');
71
+ }
72
+ catch {
73
+ fail('MCP injection failed. Manual: add zeph to ~/.cursor/mcp.json');
74
+ }
75
+ };
76
+ const installWindsurf = () => {
77
+ try {
78
+ injectMcpJson((0, path_1.join)(HOME, '.codeium', 'windsurf', 'mcp_config.json'));
79
+ ok('MCP server added to ~/.codeium/windsurf/mcp_config.json');
80
+ }
81
+ catch {
82
+ fail('MCP injection failed. Manual: add zeph to windsurf mcp_config.json');
83
+ }
84
+ };
85
+ const installGemini = () => {
86
+ try {
87
+ (0, child_process_1.execSync)('gemini mcp add zeph -- npx -y @zeph-to/mcp-server', { stdio: 'pipe' });
88
+ ok('MCP server added');
89
+ }
90
+ catch {
91
+ fail('MCP add failed. Manual: gemini mcp add zeph -- npx -y @zeph-to/mcp-server');
92
+ }
93
+ };
94
+ const AGENT_INSTALLERS = {
95
+ claude: installClaude,
96
+ cursor: installCursor,
97
+ windsurf: installWindsurf,
98
+ gemini: installGemini,
99
+ };
100
+ // ── Test Connection ──────────────────────────────────────────────
101
+ const testConnection = async (apiKey, baseUrl) => {
102
+ try {
103
+ const hook = new zeph_hook_js_1.ZephHook({ apiKey, ...(baseUrl && { baseUrl }) });
104
+ const result = await hook.notify({
105
+ title: 'Zeph Setup',
106
+ body: `Connected successfully (v${config_js_1.VERSION})`,
107
+ });
108
+ ok(`Test push sent: ${result.pushId}`);
109
+ return true;
110
+ }
111
+ catch (err) {
112
+ fail(`Test failed: ${err instanceof Error ? err.message : 'Unknown error'}`);
113
+ return false;
114
+ }
115
+ };
116
+ // ── Main Install Flow ────────────────────────────────────────────
117
+ const handleInstall = async (args) => {
118
+ const installArgs = {
119
+ key: args.key,
120
+ hook: args.hook,
121
+ 'base-url': args['base-url'],
122
+ };
123
+ const nonInteractive = !!(installArgs.key || installArgs.hook || installArgs['base-url']);
124
+ console.log(`\n Zeph v${config_js_1.VERSION}\n`);
125
+ // 1. Detect agents
126
+ console.log(' Detecting agents...');
127
+ const agents = detectAgents();
128
+ const detected = agents.filter((a) => a.detected);
129
+ for (const agent of agents) {
130
+ if (agent.detected) {
131
+ ok(agent.name);
132
+ }
133
+ else {
134
+ fail(`${agent.name} (not found)`);
135
+ }
136
+ }
137
+ if (detected.length === 0) {
138
+ console.log('\n No supported agents found. Config will still be saved.\n');
139
+ }
140
+ // 2. Collect credentials
141
+ const existing = (0, config_js_1.loadConfig)();
142
+ let apiKey;
143
+ let hookId;
144
+ let baseUrl;
145
+ if (nonInteractive) {
146
+ apiKey = installArgs.key || process.env.ZEPH_API_KEY || existing.apiKey;
147
+ hookId = installArgs.hook === 'none' ? undefined : (installArgs.hook || process.env.ZEPH_HOOK_ID || existing.hookId);
148
+ baseUrl = installArgs['base-url'] || process.env.ZEPH_BASE_URL || existing.baseUrl;
149
+ }
150
+ else {
151
+ console.log('');
152
+ const currentKey = process.env.ZEPH_API_KEY || existing.apiKey;
153
+ if (currentKey) {
154
+ console.log(` Current API Key: ${currentKey.slice(0, 12)}...`);
155
+ }
156
+ const keyInput = await promptInput(currentKey ? ' New API Key (Enter to keep): ' : ' API Key (from app > Settings > API Keys): ');
157
+ apiKey = keyInput || currentKey;
158
+ const currentHook = process.env.ZEPH_HOOK_ID || existing.hookId;
159
+ if (currentHook) {
160
+ console.log(` Current Hook ID: ${currentHook}`);
161
+ }
162
+ const hookInput = await promptInput(currentHook ? ' New Hook ID (Enter to keep, "none" to remove): ' : ' Hook ID (optional, for prompt/input): ');
163
+ hookId = hookInput === 'none' ? undefined : (hookInput || currentHook);
164
+ baseUrl = existing.baseUrl;
165
+ }
166
+ if (!apiKey) {
167
+ console.error('\n Error: API key is required.\n');
168
+ return 1;
169
+ }
170
+ // 3. Confirmation (interactive only)
171
+ if (!nonInteractive) {
172
+ console.log('\n Will do:');
173
+ console.log(' 1. Save config to ~/.zeph/config.json');
174
+ let step = 2;
175
+ for (const agent of detected) {
176
+ const labels = {
177
+ claude: 'Install Claude Code plugin',
178
+ cursor: 'Add MCP server to ~/.cursor/mcp.json',
179
+ windsurf: 'Add MCP server to windsurf mcp_config.json',
180
+ gemini: 'Add MCP server to Gemini CLI',
181
+ };
182
+ console.log(` ${step}. ${labels[agent.id] ?? `Install for ${agent.name}`}`);
183
+ step++;
184
+ }
185
+ console.log(` ${step}. Test connection`);
186
+ const confirm = await promptInput(' Continue? [Y/n] ');
187
+ if (confirm.toLowerCase() === 'n') {
188
+ console.log('\n Cancelled.\n');
189
+ return 0;
190
+ }
191
+ }
192
+ // 4. Save config
193
+ console.log('');
194
+ const config = {
195
+ apiKey,
196
+ ...(hookId && { hookId }),
197
+ ...(baseUrl && { baseUrl }),
198
+ };
199
+ (0, config_js_1.saveConfig)(config);
200
+ ok(`Config saved to ${config_js_1.CONFIG_FILE}`);
201
+ // 5. Install per-agent
202
+ for (const agent of detected) {
203
+ console.log(`\n Installing for ${agent.name}...`);
204
+ const installer = AGENT_INSTALLERS[agent.id];
205
+ if (installer)
206
+ installer();
207
+ }
208
+ // 6. Test connection
209
+ console.log('\n Testing connection...');
210
+ await testConnection(apiKey, baseUrl);
211
+ console.log('\n Done! Restart your agents.\n');
212
+ return 0;
213
+ };
214
+ exports.handleInstall = handleInstall;
package/dist/types.d.ts CHANGED
@@ -7,7 +7,7 @@ export interface NotifyPayload {
7
7
  title?: string;
8
8
  body?: string;
9
9
  url?: string;
10
- type?: 'note' | 'link' | 'file';
10
+ type?: 'note' | 'link' | 'file' | 'hook';
11
11
  priority?: 'low' | 'normal' | 'high' | 'urgent';
12
12
  targetDeviceId?: string;
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAChC,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;CACxD;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACzC,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;CACxD;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeph-to/hook-sdk",
3
- "version": "0.3.0",
3
+ "version": "1.0.0",
4
4
  "description": "Zeph push notification SDK + CLI — zero dependencies",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -21,15 +21,33 @@
21
21
  "!dist/**/*.tsbuildinfo"
22
22
  ],
23
23
  "scripts": {
24
- "build": "tsc -p tsconfig.lib.json",
24
+ "build": "tsc",
25
25
  "prepublishOnly": "npm run build"
26
26
  },
27
+ "devDependencies": {
28
+ "typescript": "^5.8.0",
29
+ "@types/node": "^22.0.0"
30
+ },
31
+ "release": {
32
+ "branches": [
33
+ "main"
34
+ ],
35
+ "plugins": [
36
+ "@semantic-release/commit-analyzer",
37
+ "@semantic-release/release-notes-generator",
38
+ "@semantic-release/npm",
39
+ "@semantic-release/github"
40
+ ]
41
+ },
42
+ "author": "Zeph <dev@zeph.to>",
27
43
  "repository": {
28
44
  "type": "git",
29
- "url": "https://github.com/tak-bro/encl",
30
- "directory": "libs/hook-sdk"
45
+ "url": "https://github.com/zeph-to/hook-sdk"
46
+ },
47
+ "homepage": "https://github.com/zeph-to/hook-sdk",
48
+ "bugs": {
49
+ "url": "https://github.com/zeph-to/hook-sdk/issues"
31
50
  },
32
- "homepage": "https://github.com/tak-bro/encl/tree/main/libs/hook-sdk",
33
51
  "keywords": [
34
52
  "zeph",
35
53
  "push",
@@ -41,5 +59,5 @@
41
59
  "claude",
42
60
  "devtools"
43
61
  ],
44
- "license": "MIT"
62
+ "license": "Apache-2.0"
45
63
  }