@vibelet/cli 0.1.38 → 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/README.md +80 -0
- package/bin/cloudflared-quick-tunnel.mjs +11 -0
- package/bin/cloudflared-resolver.mjs +171 -0
- package/bin/vibelet-runtime-policy.mjs +36 -0
- package/bin/vibelet.cjs +12 -0
- package/bin/vibelet.mjs +1062 -0
- package/dist/index.cjs +126 -0
- package/package.json +24 -22
- package/app.json +0 -5
- package/dist/advertised-hosts.d.ts +0 -34
- package/dist/advertised-hosts.d.ts.map +0 -1
- package/dist/advertised-hosts.js +0 -176
- package/dist/advertised-hosts.js.map +0 -1
- package/dist/advertised-hosts.test.d.ts +0 -2
- package/dist/advertised-hosts.test.d.ts.map +0 -1
- package/dist/advertised-hosts.test.js +0 -96
- package/dist/advertised-hosts.test.js.map +0 -1
- package/dist/audit.d.ts +0 -30
- package/dist/audit.d.ts.map +0 -1
- package/dist/audit.js +0 -73
- package/dist/audit.js.map +0 -1
- package/dist/audit.test.d.ts +0 -2
- package/dist/audit.test.d.ts.map +0 -1
- package/dist/audit.test.js +0 -33
- package/dist/audit.test.js.map +0 -1
- package/dist/auth.d.ts +0 -6
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -27
- package/dist/auth.js.map +0 -1
- package/dist/claude-hooks.d.ts +0 -58
- package/dist/claude-hooks.d.ts.map +0 -1
- package/dist/claude-hooks.js +0 -129
- package/dist/claude-hooks.js.map +0 -1
- package/dist/cli-version.d.ts +0 -3
- package/dist/cli-version.d.ts.map +0 -1
- package/dist/cli-version.js +0 -35
- package/dist/cli-version.js.map +0 -1
- package/dist/cli-version.test.d.ts +0 -2
- package/dist/cli-version.test.d.ts.map +0 -1
- package/dist/cli-version.test.js +0 -38
- package/dist/cli-version.test.js.map +0 -1
- package/dist/config.d.ts +0 -30
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -327
- package/dist/config.js.map +0 -1
- package/dist/config.test.d.ts +0 -2
- package/dist/config.test.d.ts.map +0 -1
- package/dist/config.test.js +0 -184
- package/dist/config.test.js.map +0 -1
- package/dist/dev-auth.test.d.ts +0 -2
- package/dist/dev-auth.test.d.ts.map +0 -1
- package/dist/dev-auth.test.js +0 -154
- package/dist/dev-auth.test.js.map +0 -1
- package/dist/dev-script.test.d.ts +0 -2
- package/dist/dev-script.test.d.ts.map +0 -1
- package/dist/dev-script.test.js +0 -412
- package/dist/dev-script.test.js.map +0 -1
- package/dist/drivers/claude.d.ts +0 -34
- package/dist/drivers/claude.d.ts.map +0 -1
- package/dist/drivers/claude.js +0 -413
- package/dist/drivers/claude.js.map +0 -1
- package/dist/drivers/claude.test.d.ts +0 -2
- package/dist/drivers/claude.test.d.ts.map +0 -1
- package/dist/drivers/claude.test.js +0 -951
- package/dist/drivers/claude.test.js.map +0 -1
- package/dist/drivers/codex.d.ts +0 -38
- package/dist/drivers/codex.d.ts.map +0 -1
- package/dist/drivers/codex.js +0 -771
- package/dist/drivers/codex.js.map +0 -1
- package/dist/drivers/codex.test.d.ts +0 -2
- package/dist/drivers/codex.test.d.ts.map +0 -1
- package/dist/drivers/codex.test.js +0 -939
- package/dist/drivers/codex.test.js.map +0 -1
- package/dist/drivers/types.d.ts +0 -14
- package/dist/drivers/types.d.ts.map +0 -1
- package/dist/drivers/types.js +0 -2
- package/dist/drivers/types.js.map +0 -1
- package/dist/e2e.test.d.ts +0 -2
- package/dist/e2e.test.d.ts.map +0 -1
- package/dist/e2e.test.js +0 -111
- package/dist/e2e.test.js.map +0 -1
- package/dist/identity.d.ts +0 -10
- package/dist/identity.d.ts.map +0 -1
- package/dist/identity.js +0 -66
- package/dist/identity.js.map +0 -1
- package/dist/identity.test.d.ts +0 -2
- package/dist/identity.test.d.ts.map +0 -1
- package/dist/identity.test.js +0 -25
- package/dist/identity.test.js.map +0 -1
- package/dist/index-entry.test.d.ts +0 -2
- package/dist/index-entry.test.d.ts.map +0 -1
- package/dist/index-entry.test.js +0 -272
- package/dist/index-entry.test.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -707
- package/dist/index.js.map +0 -1
- package/dist/logger.d.ts +0 -31
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -75
- package/dist/logger.js.map +0 -1
- package/dist/metrics.d.ts +0 -52
- package/dist/metrics.d.ts.map +0 -1
- package/dist/metrics.js +0 -89
- package/dist/metrics.js.map +0 -1
- package/dist/pairing-store.d.ts +0 -29
- package/dist/pairing-store.d.ts.map +0 -1
- package/dist/pairing-store.js +0 -131
- package/dist/pairing-store.js.map +0 -1
- package/dist/pairing-store.test.d.ts +0 -2
- package/dist/pairing-store.test.d.ts.map +0 -1
- package/dist/pairing-store.test.js +0 -47
- package/dist/pairing-store.test.js.map +0 -1
- package/dist/paths.d.ts +0 -16
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js +0 -18
- package/dist/paths.js.map +0 -1
- package/dist/perf-compare.d.ts +0 -13
- package/dist/perf-compare.d.ts.map +0 -1
- package/dist/perf-compare.js +0 -125
- package/dist/perf-compare.js.map +0 -1
- package/dist/port-conflict.d.ts +0 -9
- package/dist/port-conflict.d.ts.map +0 -1
- package/dist/port-conflict.js +0 -33
- package/dist/port-conflict.js.map +0 -1
- package/dist/port-conflict.test.d.ts +0 -2
- package/dist/port-conflict.test.d.ts.map +0 -1
- package/dist/port-conflict.test.js +0 -38
- package/dist/port-conflict.test.js.map +0 -1
- package/dist/process-scanner.d.ts +0 -43
- package/dist/process-scanner.d.ts.map +0 -1
- package/dist/process-scanner.js +0 -453
- package/dist/process-scanner.js.map +0 -1
- package/dist/process-scanner.perf.test.d.ts +0 -2
- package/dist/process-scanner.perf.test.d.ts.map +0 -1
- package/dist/process-scanner.perf.test.js +0 -186
- package/dist/process-scanner.perf.test.js.map +0 -1
- package/dist/process-scanner.test.d.ts +0 -2
- package/dist/process-scanner.test.d.ts.map +0 -1
- package/dist/process-scanner.test.js +0 -399
- package/dist/process-scanner.test.js.map +0 -1
- package/dist/push-protocol.d.ts +0 -15
- package/dist/push-protocol.d.ts.map +0 -1
- package/dist/push-protocol.js +0 -23
- package/dist/push-protocol.js.map +0 -1
- package/dist/push-protocol.test.d.ts +0 -2
- package/dist/push-protocol.test.d.ts.map +0 -1
- package/dist/push-protocol.test.js +0 -57
- package/dist/push-protocol.test.js.map +0 -1
- package/dist/push-store.d.ts +0 -22
- package/dist/push-store.d.ts.map +0 -1
- package/dist/push-store.js +0 -103
- package/dist/push-store.js.map +0 -1
- package/dist/push-store.test.d.ts +0 -2
- package/dist/push-store.test.d.ts.map +0 -1
- package/dist/push-store.test.js +0 -79
- package/dist/push-store.test.js.map +0 -1
- package/dist/push.d.ts +0 -65
- package/dist/push.d.ts.map +0 -1
- package/dist/push.js +0 -202
- package/dist/push.js.map +0 -1
- package/dist/push.test.d.ts +0 -2
- package/dist/push.test.d.ts.map +0 -1
- package/dist/push.test.js +0 -199
- package/dist/push.test.js.map +0 -1
- package/dist/safe-stdio.d.ts +0 -3
- package/dist/safe-stdio.d.ts.map +0 -1
- package/dist/safe-stdio.js +0 -46
- package/dist/safe-stdio.js.map +0 -1
- package/dist/scanner.d.ts +0 -30
- package/dist/scanner.d.ts.map +0 -1
- package/dist/scanner.js +0 -859
- package/dist/scanner.js.map +0 -1
- package/dist/scanner.perf.test.d.ts +0 -2
- package/dist/scanner.perf.test.d.ts.map +0 -1
- package/dist/scanner.perf.test.js +0 -320
- package/dist/scanner.perf.test.js.map +0 -1
- package/dist/scanner.test.d.ts +0 -2
- package/dist/scanner.test.d.ts.map +0 -1
- package/dist/scanner.test.js +0 -948
- package/dist/scanner.test.js.map +0 -1
- package/dist/session-inventory.d.ts +0 -63
- package/dist/session-inventory.d.ts.map +0 -1
- package/dist/session-inventory.js +0 -525
- package/dist/session-inventory.js.map +0 -1
- package/dist/session-inventory.perf.test.d.ts +0 -2
- package/dist/session-inventory.perf.test.d.ts.map +0 -1
- package/dist/session-inventory.perf.test.js +0 -220
- package/dist/session-inventory.perf.test.js.map +0 -1
- package/dist/session-inventory.test.d.ts +0 -2
- package/dist/session-inventory.test.d.ts.map +0 -1
- package/dist/session-inventory.test.js +0 -712
- package/dist/session-inventory.test.js.map +0 -1
- package/dist/session-manager.d.ts +0 -75
- package/dist/session-manager.d.ts.map +0 -1
- package/dist/session-manager.js +0 -1515
- package/dist/session-manager.js.map +0 -1
- package/dist/session-manager.test.d.ts +0 -2
- package/dist/session-manager.test.d.ts.map +0 -1
- package/dist/session-manager.test.js +0 -2861
- package/dist/session-manager.test.js.map +0 -1
- package/dist/session-store.d.ts +0 -42
- package/dist/session-store.d.ts.map +0 -1
- package/dist/session-store.js +0 -163
- package/dist/session-store.js.map +0 -1
- package/dist/session-store.test.d.ts +0 -2
- package/dist/session-store.test.d.ts.map +0 -1
- package/dist/session-store.test.js +0 -236
- package/dist/session-store.test.js.map +0 -1
- package/dist/session-title.d.ts +0 -6
- package/dist/session-title.d.ts.map +0 -1
- package/dist/session-title.js +0 -105
- package/dist/session-title.js.map +0 -1
- package/dist/session-title.perf.test.d.ts +0 -2
- package/dist/session-title.perf.test.d.ts.map +0 -1
- package/dist/session-title.perf.test.js +0 -99
- package/dist/session-title.perf.test.js.map +0 -1
- package/dist/session-title.test.d.ts +0 -2
- package/dist/session-title.test.d.ts.map +0 -1
- package/dist/session-title.test.js +0 -199
- package/dist/session-title.test.js.map +0 -1
- package/dist/shutdown-endpoint.test.d.ts +0 -2
- package/dist/shutdown-endpoint.test.d.ts.map +0 -1
- package/dist/shutdown-endpoint.test.js +0 -93
- package/dist/shutdown-endpoint.test.js.map +0 -1
- package/dist/storage-housekeeping.d.ts +0 -28
- package/dist/storage-housekeeping.d.ts.map +0 -1
- package/dist/storage-housekeeping.js +0 -76
- package/dist/storage-housekeeping.js.map +0 -1
- package/dist/storage-housekeeping.test.d.ts +0 -2
- package/dist/storage-housekeeping.test.d.ts.map +0 -1
- package/dist/storage-housekeeping.test.js +0 -65
- package/dist/storage-housekeeping.test.js.map +0 -1
- package/dist/test-daemon-harness.d.ts +0 -31
- package/dist/test-daemon-harness.d.ts.map +0 -1
- package/dist/test-daemon-harness.js +0 -337
- package/dist/test-daemon-harness.js.map +0 -1
- package/dist/token-auth.test.d.ts +0 -2
- package/dist/token-auth.test.d.ts.map +0 -1
- package/dist/token-auth.test.js +0 -52
- package/dist/token-auth.test.js.map +0 -1
- package/dist/utils.d.ts +0 -4
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -40
- package/dist/utils.js.map +0 -1
- package/dist/utils.test.d.ts +0 -2
- package/dist/utils.test.d.ts.map +0 -1
- package/dist/utils.test.js +0 -54
- package/dist/utils.test.js.map +0 -1
- package/dist/ws-data.d.ts +0 -4
- package/dist/ws-data.d.ts.map +0 -1
- package/dist/ws-data.js +0 -20
- package/dist/ws-data.js.map +0 -1
- package/dist/ws-data.test.d.ts +0 -2
- package/dist/ws-data.test.d.ts.map +0 -1
- package/dist/ws-data.test.js +0 -17
- package/dist/ws-data.test.js.map +0 -1
- package/perf-reporter.mjs +0 -138
- package/scripts/build-release.mjs +0 -41
- package/scripts/dev.mjs +0 -537
- package/src/advertised-hosts.test.ts +0 -125
- package/src/advertised-hosts.ts +0 -225
- package/src/audit.test.ts +0 -38
- package/src/audit.ts +0 -117
- package/src/auth.ts +0 -31
- package/src/claude-hooks.ts +0 -195
- package/src/cli-version.test.ts +0 -36
- package/src/cli-version.ts +0 -46
- package/src/config.test.ts +0 -254
- package/src/config.ts +0 -324
- package/src/dev-auth.test.ts +0 -183
- package/src/dev-script.test.ts +0 -511
- package/src/drivers/claude.test.ts +0 -1186
- package/src/drivers/claude.ts +0 -443
- package/src/drivers/codex.test.ts +0 -1096
- package/src/drivers/codex.ts +0 -879
- package/src/drivers/types.ts +0 -15
- package/src/e2e.test.ts +0 -139
- package/src/identity.test.ts +0 -26
- package/src/identity.ts +0 -82
- package/src/index-entry.test.ts +0 -336
- package/src/index.ts +0 -781
- package/src/logger.ts +0 -112
- package/src/metrics.ts +0 -117
- package/src/pairing-store.test.ts +0 -53
- package/src/pairing-store.ts +0 -154
- package/src/paths.ts +0 -19
- package/src/perf-compare.ts +0 -164
- package/src/port-conflict.test.ts +0 -45
- package/src/port-conflict.ts +0 -44
- package/src/process-scanner.perf.test.ts +0 -222
- package/src/process-scanner.test.ts +0 -575
- package/src/process-scanner.ts +0 -514
- package/src/push-protocol.test.ts +0 -74
- package/src/push-protocol.ts +0 -36
- package/src/push-store.test.ts +0 -89
- package/src/push-store.ts +0 -126
- package/src/push.test.ts +0 -234
- package/src/push.ts +0 -318
- package/src/safe-stdio.ts +0 -51
- package/src/scanner.perf.test.ts +0 -359
- package/src/scanner.test.ts +0 -1045
- package/src/scanner.ts +0 -924
- package/src/session-inventory.perf.test.ts +0 -250
- package/src/session-inventory.test.ts +0 -1002
- package/src/session-inventory.ts +0 -721
- package/src/session-manager.test.ts +0 -3430
- package/src/session-manager.ts +0 -1775
- package/src/session-store.test.ts +0 -276
- package/src/session-store.ts +0 -202
- package/src/session-title.perf.test.ts +0 -118
- package/src/session-title.test.ts +0 -286
- package/src/session-title.ts +0 -108
- package/src/shutdown-endpoint.test.ts +0 -95
- package/src/storage-housekeeping.test.ts +0 -78
- package/src/storage-housekeeping.ts +0 -111
- package/src/test-daemon-harness.ts +0 -410
- package/src/token-auth.test.ts +0 -67
- package/src/utils.test.ts +0 -65
- package/src/utils.ts +0 -47
- package/src/ws-data.test.ts +0 -20
- package/src/ws-data.ts +0 -26
- package/tsconfig.json +0 -12
package/src/claude-hooks.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { mkdirSync, rmSync, writeFileSync } from 'fs';
|
|
2
|
-
import { tmpdir } from 'os';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
import { randomUUID } from 'crypto';
|
|
5
|
-
|
|
6
|
-
export const CLAUDE_HOOK_APPROVAL_PREFIX = 'claude-hook:';
|
|
7
|
-
export const CLAUDE_HOOK_SECRET_HEADER = 'x-vibelet-claude-hook-secret';
|
|
8
|
-
|
|
9
|
-
export type ClaudeSessionHookData = {
|
|
10
|
-
session_id?: string;
|
|
11
|
-
sessionId?: string;
|
|
12
|
-
transcript_path?: string;
|
|
13
|
-
transcriptPath?: string;
|
|
14
|
-
cwd?: string;
|
|
15
|
-
hook_event_name?: string;
|
|
16
|
-
hookEventName?: string;
|
|
17
|
-
source?: string;
|
|
18
|
-
[key: string]: unknown;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type ClaudePermissionHookData = {
|
|
22
|
-
session_id?: string;
|
|
23
|
-
sessionId?: string;
|
|
24
|
-
transcript_path?: string;
|
|
25
|
-
transcriptPath?: string;
|
|
26
|
-
cwd?: string;
|
|
27
|
-
hook_event_name?: string;
|
|
28
|
-
hookEventName?: string;
|
|
29
|
-
permission_mode?: string;
|
|
30
|
-
permissionMode?: string;
|
|
31
|
-
tool_name?: string;
|
|
32
|
-
toolName?: string;
|
|
33
|
-
tool_input?: unknown;
|
|
34
|
-
toolInput?: unknown;
|
|
35
|
-
tool_use_id?: string;
|
|
36
|
-
toolUseId?: string;
|
|
37
|
-
permission_suggestions?: unknown;
|
|
38
|
-
permissionSuggestions?: unknown;
|
|
39
|
-
[key: string]: unknown;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export type ClaudePermissionHookResponse = {
|
|
43
|
-
continue: boolean;
|
|
44
|
-
suppressOutput?: boolean;
|
|
45
|
-
stopReason?: string;
|
|
46
|
-
systemMessage?: string;
|
|
47
|
-
hookSpecificOutput?: {
|
|
48
|
-
hookEventName?: 'PreToolUse';
|
|
49
|
-
permissionDecision?: 'allow' | 'deny' | 'ask';
|
|
50
|
-
permissionDecisionReason?: string;
|
|
51
|
-
updatedInput?: unknown;
|
|
52
|
-
[key: string]: unknown;
|
|
53
|
-
};
|
|
54
|
-
[key: string]: unknown;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export type ClaudeHookFiles = {
|
|
58
|
-
secret: string;
|
|
59
|
-
dirPath: string;
|
|
60
|
-
settingsPath: string;
|
|
61
|
-
sessionScriptPath: string;
|
|
62
|
-
permissionScriptPath: string;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const DEFAULT_CLAUDE_PERMISSION_HOOK_RESPONSE: ClaudePermissionHookResponse = {
|
|
66
|
-
continue: true,
|
|
67
|
-
suppressOutput: true,
|
|
68
|
-
hookSpecificOutput: {
|
|
69
|
-
hookEventName: 'PreToolUse',
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
function buildSessionForwarderScript(port: number, secret: string): string {
|
|
74
|
-
return `#!/usr/bin/env node
|
|
75
|
-
const http = require('http');
|
|
76
|
-
const chunks = [];
|
|
77
|
-
process.stdin.on('data', (chunk) => chunks.push(chunk));
|
|
78
|
-
process.stdin.on('end', () => {
|
|
79
|
-
const body = Buffer.concat(chunks);
|
|
80
|
-
const req = http.request({
|
|
81
|
-
host: '127.0.0.1',
|
|
82
|
-
port: ${port},
|
|
83
|
-
method: 'POST',
|
|
84
|
-
path: '/hook/claude/session-start',
|
|
85
|
-
headers: {
|
|
86
|
-
'Content-Type': 'application/json',
|
|
87
|
-
'Content-Length': body.length,
|
|
88
|
-
'${CLAUDE_HOOK_SECRET_HEADER}': ${JSON.stringify(secret)}
|
|
89
|
-
}
|
|
90
|
-
}, (res) => { res.resume(); });
|
|
91
|
-
req.on('error', () => {});
|
|
92
|
-
req.end(body);
|
|
93
|
-
});
|
|
94
|
-
process.stdin.resume();
|
|
95
|
-
`;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function buildPermissionForwarderScript(port: number, secret: string): string {
|
|
99
|
-
return `#!/usr/bin/env node
|
|
100
|
-
const http = require('http');
|
|
101
|
-
const fallback = ${JSON.stringify(JSON.stringify(DEFAULT_CLAUDE_PERMISSION_HOOK_RESPONSE))};
|
|
102
|
-
const chunks = [];
|
|
103
|
-
process.stdin.on('data', (chunk) => chunks.push(chunk));
|
|
104
|
-
process.stdin.on('end', () => {
|
|
105
|
-
const body = Buffer.concat(chunks);
|
|
106
|
-
const req = http.request({
|
|
107
|
-
host: '127.0.0.1',
|
|
108
|
-
port: ${port},
|
|
109
|
-
method: 'POST',
|
|
110
|
-
path: '/hook/claude/permission-request',
|
|
111
|
-
headers: {
|
|
112
|
-
'Content-Type': 'application/json',
|
|
113
|
-
'Content-Length': body.length,
|
|
114
|
-
'${CLAUDE_HOOK_SECRET_HEADER}': ${JSON.stringify(secret)}
|
|
115
|
-
}
|
|
116
|
-
}, (res) => {
|
|
117
|
-
const responseChunks = [];
|
|
118
|
-
res.on('data', (chunk) => responseChunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)));
|
|
119
|
-
res.on('end', () => {
|
|
120
|
-
const statusCode = res.statusCode || 0;
|
|
121
|
-
if (statusCode < 200 || statusCode >= 300) {
|
|
122
|
-
process.stdout.write(fallback);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const payload = Buffer.concat(responseChunks).toString('utf8').trim();
|
|
126
|
-
process.stdout.write(payload || fallback);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
req.on('error', () => {
|
|
130
|
-
process.stdout.write(fallback);
|
|
131
|
-
});
|
|
132
|
-
req.end(body);
|
|
133
|
-
});
|
|
134
|
-
process.stdin.resume();
|
|
135
|
-
`;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function createClaudeHookFiles(port: number, secret: string): ClaudeHookFiles {
|
|
139
|
-
const dirPath = join(tmpdir(), `vibelet-claude-hooks-${process.pid}-${randomUUID()}`);
|
|
140
|
-
mkdirSync(dirPath, { recursive: true });
|
|
141
|
-
|
|
142
|
-
const settingsPath = join(dirPath, 'settings.json');
|
|
143
|
-
const sessionScriptPath = join(dirPath, 'session_hook_forwarder.cjs');
|
|
144
|
-
const permissionScriptPath = join(dirPath, 'permission_hook_forwarder.cjs');
|
|
145
|
-
|
|
146
|
-
writeFileSync(sessionScriptPath, buildSessionForwarderScript(port, secret), 'utf8');
|
|
147
|
-
writeFileSync(permissionScriptPath, buildPermissionForwarderScript(port, secret), 'utf8');
|
|
148
|
-
writeFileSync(
|
|
149
|
-
settingsPath,
|
|
150
|
-
JSON.stringify({
|
|
151
|
-
hooks: {
|
|
152
|
-
SessionStart: [
|
|
153
|
-
{
|
|
154
|
-
matcher: '*',
|
|
155
|
-
hooks: [
|
|
156
|
-
{
|
|
157
|
-
type: 'command',
|
|
158
|
-
command: `${JSON.stringify(process.execPath)} ${JSON.stringify(sessionScriptPath)}`,
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
},
|
|
162
|
-
],
|
|
163
|
-
PreToolUse: [
|
|
164
|
-
{
|
|
165
|
-
matcher: '*',
|
|
166
|
-
hooks: [
|
|
167
|
-
{
|
|
168
|
-
type: 'command',
|
|
169
|
-
command: `${JSON.stringify(process.execPath)} ${JSON.stringify(permissionScriptPath)}`,
|
|
170
|
-
},
|
|
171
|
-
],
|
|
172
|
-
},
|
|
173
|
-
],
|
|
174
|
-
},
|
|
175
|
-
}, null, 2),
|
|
176
|
-
'utf8',
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
secret,
|
|
181
|
-
dirPath,
|
|
182
|
-
settingsPath,
|
|
183
|
-
sessionScriptPath,
|
|
184
|
-
permissionScriptPath,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export function cleanupClaudeHookFiles(hookFiles: ClaudeHookFiles | null | undefined): void {
|
|
189
|
-
if (!hookFiles) return;
|
|
190
|
-
try {
|
|
191
|
-
rmSync(hookFiles.dirPath, { recursive: true, force: true });
|
|
192
|
-
} catch {
|
|
193
|
-
// best effort cleanup
|
|
194
|
-
}
|
|
195
|
-
}
|
package/src/cli-version.test.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { createRequire } from 'node:module';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { resolveCliVersion } from './cli-version.js';
|
|
6
|
-
|
|
7
|
-
const require = createRequire(import.meta.url);
|
|
8
|
-
const packageJson = require('../../../package.json') as { version?: string };
|
|
9
|
-
const daemonPackageDir = fileURLToPath(new URL('..', import.meta.url));
|
|
10
|
-
|
|
11
|
-
test('resolveCliVersion prefers VIBELET_CLI_VERSION when provided', () => {
|
|
12
|
-
const original = process.env.VIBELET_CLI_VERSION;
|
|
13
|
-
process.env.VIBELET_CLI_VERSION = '9.9.9-test';
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
assert.equal(resolveCliVersion(), '9.9.9-test');
|
|
17
|
-
} finally {
|
|
18
|
-
if (original === undefined) delete process.env.VIBELET_CLI_VERSION;
|
|
19
|
-
else process.env.VIBELET_CLI_VERSION = original;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('resolveCliVersion falls back to the root package version', () => {
|
|
24
|
-
const original = process.env.VIBELET_CLI_VERSION;
|
|
25
|
-
const originalCwd = process.cwd();
|
|
26
|
-
delete process.env.VIBELET_CLI_VERSION;
|
|
27
|
-
process.chdir(daemonPackageDir);
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
assert.equal(resolveCliVersion(), packageJson.version);
|
|
31
|
-
} finally {
|
|
32
|
-
process.chdir(originalCwd);
|
|
33
|
-
if (original === undefined) delete process.env.VIBELET_CLI_VERSION;
|
|
34
|
-
else process.env.VIBELET_CLI_VERSION = original;
|
|
35
|
-
}
|
|
36
|
-
});
|
package/src/cli-version.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { resolve } from 'node:path';
|
|
3
|
-
|
|
4
|
-
type RootPackageJson = {
|
|
5
|
-
name?: string;
|
|
6
|
-
version?: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const ROOT_PACKAGE_NAME = '@vibelet/cli';
|
|
10
|
-
|
|
11
|
-
function readVersionFromPackageJson(path: string): string | null {
|
|
12
|
-
try {
|
|
13
|
-
const packageJson = JSON.parse(readFileSync(path, 'utf8')) as RootPackageJson;
|
|
14
|
-
if (packageJson.name === ROOT_PACKAGE_NAME && typeof packageJson.version === 'string' && packageJson.version.length > 0) {
|
|
15
|
-
return packageJson.version;
|
|
16
|
-
}
|
|
17
|
-
} catch {
|
|
18
|
-
// Continue through the fallback chain.
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function resolveCliVersion(): string {
|
|
25
|
-
if (process.env.VIBELET_CLI_VERSION) {
|
|
26
|
-
return process.env.VIBELET_CLI_VERSION;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let currentDir = process.cwd();
|
|
30
|
-
for (let depth = 0; depth < 4; depth += 1) {
|
|
31
|
-
const version = readVersionFromPackageJson(resolve(currentDir, 'package.json'));
|
|
32
|
-
if (version) {
|
|
33
|
-
return version;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const parentDir = resolve(currentDir, '..');
|
|
37
|
-
if (parentDir === currentDir) {
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
currentDir = parentDir;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return '0.0.0';
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const CLI_VERSION = resolveCliVersion();
|
package/src/config.test.ts
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { execFileSync } from 'node:child_process';
|
|
4
|
-
import { join } from 'path';
|
|
5
|
-
import { homedir } from 'os';
|
|
6
|
-
import { isTransientPath, buildSanitizedEnv, execViaLoginShell, config } from './config.js';
|
|
7
|
-
|
|
8
|
-
const configModuleUrl = new URL('./config.ts', import.meta.url).href;
|
|
9
|
-
|
|
10
|
-
function buildChildEnv(overrides: Record<string, string | undefined>): NodeJS.ProcessEnv {
|
|
11
|
-
const nextEnv: NodeJS.ProcessEnv = { ...process.env };
|
|
12
|
-
for (const [key, value] of Object.entries(overrides)) {
|
|
13
|
-
if (value === undefined) {
|
|
14
|
-
delete nextEnv[key];
|
|
15
|
-
} else {
|
|
16
|
-
nextEnv[key] = value;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return nextEnv;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function readConfigValueInIsolatedProcess(
|
|
23
|
-
overrides: Record<string, string | undefined>,
|
|
24
|
-
expression: string,
|
|
25
|
-
): string {
|
|
26
|
-
return execFileSync(
|
|
27
|
-
process.execPath,
|
|
28
|
-
[
|
|
29
|
-
'--import',
|
|
30
|
-
'tsx',
|
|
31
|
-
'-e',
|
|
32
|
-
`import { config } from ${JSON.stringify(configModuleUrl)}; process.stdout.write(String(${expression}));`,
|
|
33
|
-
],
|
|
34
|
-
{
|
|
35
|
-
env: buildChildEnv(overrides),
|
|
36
|
-
encoding: 'utf8',
|
|
37
|
-
},
|
|
38
|
-
).trim();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
test('isTransientPath: detects fnm_multishells as transient', () => {
|
|
42
|
-
assert.equal(isTransientPath('/tmp/fnm_multishells/12345/bin/codex'), true);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('isTransientPath: returns false for normal paths', () => {
|
|
46
|
-
assert.equal(isTransientPath('/usr/local/bin/codex'), false);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('isTransientPath: returns false for home directory paths', () => {
|
|
50
|
-
assert.equal(isTransientPath('/Users/test/.local/bin/claude'), false);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('isTransientPath: returns false for empty string', () => {
|
|
54
|
-
assert.equal(isTransientPath(''), false);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// buildSanitizedEnv tests
|
|
58
|
-
|
|
59
|
-
test('buildSanitizedEnv: returns an object with PATH key', () => {
|
|
60
|
-
const env = buildSanitizedEnv();
|
|
61
|
-
assert.ok('PATH' in env);
|
|
62
|
-
assert.equal(typeof env.PATH, 'string');
|
|
63
|
-
assert.ok(env.PATH.length > 0);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('buildSanitizedEnv: PATH includes extra directories', () => {
|
|
67
|
-
const env = buildSanitizedEnv();
|
|
68
|
-
assert.ok(env.PATH.includes('/usr/local/bin'));
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test('buildSanitizedEnv: HOME is set', () => {
|
|
72
|
-
const env = buildSanitizedEnv();
|
|
73
|
-
assert.ok('HOME' in env);
|
|
74
|
-
assert.equal(typeof env.HOME, 'string');
|
|
75
|
-
assert.ok(env.HOME.length > 0);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test('buildSanitizedEnv: CLAUDE_CODE_ENTRYPOINT is removed', () => {
|
|
79
|
-
process.env.CLAUDE_CODE_ENTRYPOINT = 'test_value';
|
|
80
|
-
const env = buildSanitizedEnv();
|
|
81
|
-
assert.equal(env.CLAUDE_CODE_ENTRYPOINT, undefined);
|
|
82
|
-
delete process.env.CLAUDE_CODE_ENTRYPOINT;
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('buildSanitizedEnv: CLAUDECODE is removed', () => {
|
|
86
|
-
process.env.CLAUDECODE = 'test_value';
|
|
87
|
-
const env = buildSanitizedEnv();
|
|
88
|
-
assert.equal(env.CLAUDECODE, undefined);
|
|
89
|
-
delete process.env.CLAUDECODE;
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test('buildSanitizedEnv: contains process.env values', () => {
|
|
93
|
-
const testKey = 'VIBE_TEST_UNIQUE_KEY_' + Date.now();
|
|
94
|
-
process.env[testKey] = 'test_value_123';
|
|
95
|
-
const env = buildSanitizedEnv();
|
|
96
|
-
assert.equal(env[testKey], 'test_value_123');
|
|
97
|
-
delete process.env[testKey];
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// execViaLoginShell tests
|
|
101
|
-
|
|
102
|
-
test('execViaLoginShell: returns correct command (a shell path)', () => {
|
|
103
|
-
const result = execViaLoginShell('claude', ['--help']);
|
|
104
|
-
assert.equal(typeof result.command, 'string');
|
|
105
|
-
assert.ok(result.command.startsWith('/'));
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
test('execViaLoginShell: args contain -lc flag', () => {
|
|
109
|
-
const result = execViaLoginShell('claude', ['--help']);
|
|
110
|
-
assert.equal(result.args[0], '-lc');
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test('execViaLoginShell: includes the passed cmd in the shell command string', () => {
|
|
114
|
-
const result = execViaLoginShell('claude', ['--help', '--verbose']);
|
|
115
|
-
assert.ok(result.args[1].includes('claude'));
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
test('execViaLoginShell: includes the passed args after -- separator', () => {
|
|
119
|
-
const result = execViaLoginShell('claude', ['--help', '--verbose']);
|
|
120
|
-
const dashDashIndex = result.args.indexOf('--');
|
|
121
|
-
assert.ok(dashDashIndex >= 0);
|
|
122
|
-
assert.equal(result.args[dashDashIndex + 1], '--help');
|
|
123
|
-
assert.equal(result.args[dashDashIndex + 2], '--verbose');
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
// config object tests
|
|
127
|
-
|
|
128
|
-
test('config.port: defaults to 9876 when VIBE_PORT not set', () => {
|
|
129
|
-
assert.equal(config.port, 9876);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
test('config.legacyToken: defaults to an empty string', () => {
|
|
133
|
-
assert.equal(config.legacyToken, '');
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
test('config.legacyToken: respects VIBE_TOKEN env override on fresh import', async () => {
|
|
137
|
-
const original = process.env.VIBE_TOKEN;
|
|
138
|
-
process.env.VIBE_TOKEN = 'legacy-secret';
|
|
139
|
-
try {
|
|
140
|
-
const freshModule = await import(`./config.ts?test=${Date.now()}`);
|
|
141
|
-
assert.equal(freshModule.config.legacyToken, 'legacy-secret');
|
|
142
|
-
} finally {
|
|
143
|
-
if (original == null) {
|
|
144
|
-
delete process.env.VIBE_TOKEN;
|
|
145
|
-
} else {
|
|
146
|
-
process.env.VIBE_TOKEN = original;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
test('config.idleTimeoutMs: allows disabling idle sweep with 0', () => {
|
|
152
|
-
assert.equal(
|
|
153
|
-
readConfigValueInIsolatedProcess(
|
|
154
|
-
{ VIBE_IDLE_TIMEOUT_MS: '0' },
|
|
155
|
-
'config.idleTimeoutMs',
|
|
156
|
-
),
|
|
157
|
-
'0',
|
|
158
|
-
);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
test('config.turnStallTimeoutMs: defaults to 5 minutes', () => {
|
|
162
|
-
assert.equal(config.turnStallTimeoutMs, 5 * 60 * 1000);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
test('config.turnStallTimeoutMs: allows disabling stall sweep with 0', () => {
|
|
166
|
-
assert.equal(
|
|
167
|
-
readConfigValueInIsolatedProcess(
|
|
168
|
-
{ VIBE_TURN_STALL_TIMEOUT_MS: '0' },
|
|
169
|
-
'config.turnStallTimeoutMs',
|
|
170
|
-
),
|
|
171
|
-
'0',
|
|
172
|
-
);
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
test('config.turnStallTimeoutMs: respects env override on fresh import', () => {
|
|
176
|
-
assert.equal(
|
|
177
|
-
readConfigValueInIsolatedProcess(
|
|
178
|
-
{ VIBE_TURN_STALL_TIMEOUT_MS: '120000' },
|
|
179
|
-
'config.turnStallTimeoutMs',
|
|
180
|
-
),
|
|
181
|
-
'120000',
|
|
182
|
-
);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
test('config.isTransientPath: is the isTransientPath function', () => {
|
|
186
|
-
assert.equal(config.isTransientPath, isTransientPath);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
test('config.buildSanitizedEnv: is the buildSanitizedEnv function', () => {
|
|
190
|
-
assert.equal(config.buildSanitizedEnv, buildSanitizedEnv);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
// Binary detection / cached resolver tests
|
|
194
|
-
|
|
195
|
-
test('config.claudePath: returns a path string', () => {
|
|
196
|
-
// This may resolve to a real path or fall back to 'claude'
|
|
197
|
-
const path = config.claudePath;
|
|
198
|
-
assert.equal(typeof path, 'string');
|
|
199
|
-
assert.ok(path.length > 0);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
test('config.codexPath: returns a path string', () => {
|
|
203
|
-
const path = config.codexPath;
|
|
204
|
-
assert.equal(typeof path, 'string');
|
|
205
|
-
assert.ok(path.length > 0);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
test('config.claudePath: respects CLAUDE_PATH env override', () => {
|
|
209
|
-
assert.equal(
|
|
210
|
-
readConfigValueInIsolatedProcess(
|
|
211
|
-
{ CLAUDE_PATH: '/custom/path/to/claude' },
|
|
212
|
-
'config.claudePath',
|
|
213
|
-
),
|
|
214
|
-
'/custom/path/to/claude',
|
|
215
|
-
);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
test('config.codexPath: respects CODEX_PATH env override', () => {
|
|
219
|
-
assert.equal(
|
|
220
|
-
readConfigValueInIsolatedProcess(
|
|
221
|
-
{ CODEX_PATH: '/custom/path/to/codex' },
|
|
222
|
-
'config.codexPath',
|
|
223
|
-
),
|
|
224
|
-
'/custom/path/to/codex',
|
|
225
|
-
);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
test('buildSanitizedEnv: PATH includes all required extra directories', () => {
|
|
229
|
-
const env = buildSanitizedEnv();
|
|
230
|
-
const home = homedir();
|
|
231
|
-
const requiredDirs = [
|
|
232
|
-
'/usr/local/bin',
|
|
233
|
-
'/opt/homebrew/bin',
|
|
234
|
-
join(home, '.npm-global', 'bin'),
|
|
235
|
-
join(home, '.local', 'bin'),
|
|
236
|
-
join(home, '.claude', 'bin'),
|
|
237
|
-
];
|
|
238
|
-
for (const dir of requiredDirs) {
|
|
239
|
-
assert.ok(env.PATH.includes(dir), `PATH should include ${dir}`);
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
test('buildSanitizedEnv: includes home-relative paths', () => {
|
|
244
|
-
const env = buildSanitizedEnv();
|
|
245
|
-
const home = homedir();
|
|
246
|
-
assert.ok(env.PATH.includes(join(home, '.local', 'bin')) || env.PATH.includes('.local/bin'));
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
test('execViaLoginShell: works with codex command', () => {
|
|
250
|
-
const result = execViaLoginShell('codex', ['app-server', '--listen', 'stdio://']);
|
|
251
|
-
assert.ok(result.args[1].includes('codex'));
|
|
252
|
-
const dashDashIndex = result.args.indexOf('--');
|
|
253
|
-
assert.equal(result.args[dashDashIndex + 1], 'app-server');
|
|
254
|
-
});
|