@zeph-to/hook-sdk 1.1.0 → 1.2.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/README.md +14 -0
- package/dist/installer.js +2 -2
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/zeph-hook.d.ts +8 -1
- package/dist/zeph-hook.d.ts.map +1 -1
- package/dist/zeph-hook.js +46 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -157,6 +157,20 @@ try {
|
|
|
157
157
|
}
|
|
158
158
|
```
|
|
159
159
|
|
|
160
|
+
## Supported Agents
|
|
161
|
+
|
|
162
|
+
`zeph install` detects and configures these agents automatically:
|
|
163
|
+
|
|
164
|
+
| Agent | What gets installed |
|
|
165
|
+
|-------|-------------------|
|
|
166
|
+
| Claude Code | Plugin (hooks + MCP server) |
|
|
167
|
+
| Cursor | MCP server + stop hook + rules |
|
|
168
|
+
| Windsurf | MCP server + response hook |
|
|
169
|
+
| Gemini CLI | MCP server + AfterAgent hook |
|
|
170
|
+
| Codex CLI | Stop hook |
|
|
171
|
+
| Copilot CLI | Session end hook |
|
|
172
|
+
| Cline | Rules file |
|
|
173
|
+
|
|
160
174
|
## Requirements
|
|
161
175
|
|
|
162
176
|
- Node.js >= 18 (uses native `fetch`)
|
package/dist/installer.js
CHANGED
|
@@ -71,13 +71,13 @@ const injectMcpJson = (filePath) => {
|
|
|
71
71
|
};
|
|
72
72
|
const installClaude = () => {
|
|
73
73
|
try {
|
|
74
|
-
(0, child_process_1.execSync)('claude plugin marketplace add zeph-to/
|
|
74
|
+
(0, child_process_1.execSync)('claude plugin marketplace add zeph-to/plugin', { stdio: 'pipe' });
|
|
75
75
|
(0, child_process_1.execSync)('claude plugin install zeph@zeph', { stdio: 'pipe' });
|
|
76
76
|
ok('Plugin installed');
|
|
77
77
|
}
|
|
78
78
|
catch {
|
|
79
79
|
fail('Plugin install failed. Manual:');
|
|
80
|
-
console.log(' claude plugin marketplace add zeph-to/
|
|
80
|
+
console.log(' claude plugin marketplace add zeph-to/plugin');
|
|
81
81
|
console.log(' claude plugin install zeph@zeph');
|
|
82
82
|
}
|
|
83
83
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -13,6 +13,19 @@ export interface NotifyPayload {
|
|
|
13
13
|
}
|
|
14
14
|
export interface NotifyResult {
|
|
15
15
|
pushId: string;
|
|
16
|
+
fileKey?: string;
|
|
17
|
+
autoFile?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface FileAttachment {
|
|
20
|
+
fileKey: string;
|
|
21
|
+
fileName: string;
|
|
22
|
+
fileSize: number;
|
|
23
|
+
fileType: string;
|
|
24
|
+
}
|
|
25
|
+
export interface UploadRequestResult {
|
|
26
|
+
fileId: string;
|
|
27
|
+
fileKey: string;
|
|
28
|
+
uploadUrl: string;
|
|
16
29
|
}
|
|
17
30
|
export interface ListParams {
|
|
18
31
|
limit?: number;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -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,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;
|
|
1
|
+
{"version":3,"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,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/dist/zeph-hook.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import type { ZephOptions, NotifyPayload, NotifyResult, ListParams, ListResult, DismissOneResult, DismissAllResult } from './types.js';
|
|
1
|
+
import type { ZephOptions, NotifyPayload, NotifyResult, ListParams, ListResult, DismissOneResult, DismissAllResult, UploadRequestResult } from './types.js';
|
|
2
2
|
export declare class ZephHook {
|
|
3
3
|
private readonly apiKey;
|
|
4
4
|
private readonly baseUrl;
|
|
5
5
|
private readonly timeoutMs;
|
|
6
6
|
constructor(options: ZephOptions);
|
|
7
7
|
notify(payload: NotifyPayload): Promise<NotifyResult>;
|
|
8
|
+
private notifyWithFile;
|
|
9
|
+
requestUpload(params: {
|
|
10
|
+
fileName: string;
|
|
11
|
+
fileType: string;
|
|
12
|
+
fileSize: number;
|
|
13
|
+
}): Promise<UploadRequestResult>;
|
|
14
|
+
uploadToS3(url: string, content: string, contentType: string): Promise<void>;
|
|
8
15
|
list(params?: ListParams): Promise<ListResult>;
|
|
9
16
|
dismiss(pushId: string): Promise<DismissOneResult>;
|
|
10
17
|
dismissAll(): Promise<DismissAllResult>;
|
package/dist/zeph-hook.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zeph-hook.d.ts","sourceRoot":"","sources":["../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 0;
|
|
|
4
4
|
const errors_js_1 = require("./errors.js");
|
|
5
5
|
const DEFAULT_BASE_URL = 'https://api.zeph.to/v1';
|
|
6
6
|
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
7
|
+
const BODY_FILE_THRESHOLD = 1024;
|
|
8
|
+
const PREVIEW_LENGTH = 200;
|
|
9
|
+
const inferMimeType = (fileName) => {
|
|
10
|
+
const ext = fileName.split('.').pop()?.toLowerCase();
|
|
11
|
+
const map = { md: 'text/markdown', txt: 'text/plain', json: 'application/json' };
|
|
12
|
+
return map[ext ?? ''] ?? 'text/plain';
|
|
13
|
+
};
|
|
7
14
|
class ZephHook {
|
|
8
15
|
apiKey;
|
|
9
16
|
baseUrl;
|
|
@@ -17,6 +24,12 @@ class ZephHook {
|
|
|
17
24
|
this.timeoutMs = options.timeout ?? DEFAULT_TIMEOUT_MS;
|
|
18
25
|
}
|
|
19
26
|
async notify(payload) {
|
|
27
|
+
const body = payload.body;
|
|
28
|
+
const bodyBytes = body ? new TextEncoder().encode(body).byteLength : 0;
|
|
29
|
+
const isLongBody = bodyBytes > BODY_FILE_THRESHOLD;
|
|
30
|
+
if (isLongBody && body) {
|
|
31
|
+
return this.notifyWithFile(payload, body, bodyBytes);
|
|
32
|
+
}
|
|
20
33
|
const json = await this.request('POST', '/pushes/send', payload);
|
|
21
34
|
const pushId = json.data?.pushId;
|
|
22
35
|
if (!pushId) {
|
|
@@ -24,6 +37,39 @@ class ZephHook {
|
|
|
24
37
|
}
|
|
25
38
|
return { pushId };
|
|
26
39
|
}
|
|
40
|
+
async notifyWithFile(payload, body, fileSize) {
|
|
41
|
+
const fileName = 'response.md';
|
|
42
|
+
const fileType = inferMimeType(fileName);
|
|
43
|
+
const upload = await this.requestUpload({ fileName, fileType, fileSize });
|
|
44
|
+
await this.uploadToS3(upload.uploadUrl, body, fileType);
|
|
45
|
+
const preview = body.length > PREVIEW_LENGTH ? body.slice(0, PREVIEW_LENGTH) + '...' : body;
|
|
46
|
+
const json = await this.request('POST', '/pushes/send', {
|
|
47
|
+
...payload,
|
|
48
|
+
body: preview,
|
|
49
|
+
type: 'file',
|
|
50
|
+
files: [{ fileKey: upload.fileKey, fileName, fileSize, fileType }],
|
|
51
|
+
});
|
|
52
|
+
const pushId = json.data?.pushId;
|
|
53
|
+
if (!pushId) {
|
|
54
|
+
throw new errors_js_1.ZephError('Server returned no pushId', 'INVALID_RESPONSE', 500);
|
|
55
|
+
}
|
|
56
|
+
return { pushId, fileKey: upload.fileKey, autoFile: true };
|
|
57
|
+
}
|
|
58
|
+
async requestUpload(params) {
|
|
59
|
+
const json = await this.request('POST', '/files/upload-request', params);
|
|
60
|
+
return json.data;
|
|
61
|
+
}
|
|
62
|
+
async uploadToS3(url, content, contentType) {
|
|
63
|
+
const response = await fetch(url, {
|
|
64
|
+
method: 'PUT',
|
|
65
|
+
headers: { 'Content-Type': contentType },
|
|
66
|
+
body: content,
|
|
67
|
+
signal: AbortSignal.timeout(this.timeoutMs),
|
|
68
|
+
});
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
throw new errors_js_1.ZephError(`S3 upload failed with status ${response.status}`, 'UPLOAD_FAILED', response.status);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
27
73
|
async list(params) {
|
|
28
74
|
const query = new URLSearchParams();
|
|
29
75
|
if (params?.limit)
|