kimaki 0.4.99 → 0.4.100
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/dist/commands/vscode.js +5 -20
- package/package.json +4 -4
- package/src/commands/vscode.ts +4 -29
package/dist/commands/vscode.js
CHANGED
|
@@ -11,30 +11,20 @@ const MAX_SESSION_MINUTES = 30;
|
|
|
11
11
|
const MAX_SESSION_MS = MAX_SESSION_MINUTES * 60 * 1000;
|
|
12
12
|
const TUNNEL_BASE_DOMAIN = 'kimaki.dev';
|
|
13
13
|
const TUNNEL_ID_BYTES = 16;
|
|
14
|
-
const CONNECTION_TOKEN_BYTES = 16;
|
|
15
14
|
const READY_TIMEOUT_MS = 60_000;
|
|
16
15
|
const LOCAL_HOST = '127.0.0.1';
|
|
17
16
|
const activeSessions = new Map();
|
|
18
17
|
export function createVscodeTunnelId() {
|
|
19
18
|
return crypto.randomBytes(TUNNEL_ID_BYTES).toString('hex');
|
|
20
19
|
}
|
|
21
|
-
export function
|
|
22
|
-
return crypto.randomBytes(CONNECTION_TOKEN_BYTES).toString('hex');
|
|
23
|
-
}
|
|
24
|
-
export function buildVscodeUrl({ tunnelUrl, connectionToken, }) {
|
|
25
|
-
const url = new URL(tunnelUrl);
|
|
26
|
-
url.searchParams.set('tkn', connectionToken);
|
|
27
|
-
return url.toString();
|
|
28
|
-
}
|
|
29
|
-
export function buildCoderaftArgs({ port, connectionToken, workingDirectory, }) {
|
|
20
|
+
export function buildCoderaftArgs({ port, workingDirectory, }) {
|
|
30
21
|
return [
|
|
31
22
|
'coderaft',
|
|
32
23
|
'--port',
|
|
33
24
|
String(port),
|
|
34
25
|
'--host',
|
|
35
26
|
LOCAL_HOST,
|
|
36
|
-
'--connection-token',
|
|
37
|
-
connectionToken,
|
|
27
|
+
'--without-connection-token',
|
|
38
28
|
'--disable-workspace-trust',
|
|
39
29
|
'--default-folder',
|
|
40
30
|
workingDirectory,
|
|
@@ -122,11 +112,9 @@ export async function startVscode({ sessionKey, startedBy, workingDirectory, })
|
|
|
122
112
|
return existing;
|
|
123
113
|
}
|
|
124
114
|
const port = await getAvailablePort();
|
|
125
|
-
const connectionToken = createVscodeConnectionToken();
|
|
126
115
|
const tunnelId = createVscodeTunnelId();
|
|
127
116
|
const args = buildCoderaftArgs({
|
|
128
117
|
port,
|
|
129
|
-
connectionToken,
|
|
130
118
|
workingDirectory,
|
|
131
119
|
});
|
|
132
120
|
const coderaftProcess = spawn('bunx', args, {
|
|
@@ -179,10 +167,7 @@ export async function startVscode({ sessionKey, startedBy, workingDirectory, })
|
|
|
179
167
|
}
|
|
180
168
|
throw error;
|
|
181
169
|
}
|
|
182
|
-
const url =
|
|
183
|
-
tunnelUrl: tunnelClient.url,
|
|
184
|
-
connectionToken,
|
|
185
|
-
});
|
|
170
|
+
const url = tunnelClient.url;
|
|
186
171
|
const timeoutTimer = setTimeout(() => {
|
|
187
172
|
logger.log(`VS Code auto-stopped after ${MAX_SESSION_MINUTES} minutes (key: ${sessionKey})`);
|
|
188
173
|
stopVscode({ sessionKey });
|
|
@@ -247,7 +232,7 @@ export async function handleVscodeCommand({ command, }) {
|
|
|
247
232
|
if (existing) {
|
|
248
233
|
await command.editReply({
|
|
249
234
|
content: `VS Code is already running for this thread. ` +
|
|
250
|
-
`
|
|
235
|
+
`This unique tunnel auto-stops after ${MAX_SESSION_MINUTES} minutes from startup.\n` +
|
|
251
236
|
`${existing.url}`,
|
|
252
237
|
});
|
|
253
238
|
return;
|
|
@@ -260,7 +245,7 @@ export async function handleVscodeCommand({ command, }) {
|
|
|
260
245
|
});
|
|
261
246
|
await command.editReply({
|
|
262
247
|
content: `VS Code started for \`${session.workingDirectory}\`. ` +
|
|
263
|
-
`This
|
|
248
|
+
`This unique tunnel auto-stops after ${MAX_SESSION_MINUTES} minutes, so open it before it expires.\n` +
|
|
264
249
|
`${session.url}`,
|
|
265
250
|
});
|
|
266
251
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "kimaki",
|
|
3
3
|
"module": "index.ts",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.4.
|
|
5
|
+
"version": "0.4.100",
|
|
6
6
|
"repository": "https://github.com/remorses/kimaki",
|
|
7
7
|
"bin": "bin.js",
|
|
8
8
|
"files": [
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"prisma": "7.4.2",
|
|
26
26
|
"tsx": "^4.20.5",
|
|
27
27
|
"undici": "^8.0.2",
|
|
28
|
+
"opencode-deterministic-provider": "^0.0.1",
|
|
28
29
|
"opencode-cached-provider": "^0.0.1",
|
|
29
30
|
"discord-digital-twin": "^0.1.0",
|
|
30
|
-
"opencode-deterministic-provider": "^0.0.1",
|
|
31
31
|
"db": "^0.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"zod": "^4.3.6",
|
|
66
66
|
"zustand": "^5.0.11",
|
|
67
67
|
"errore": "^0.14.1",
|
|
68
|
-
"opencode-injection-guard": "^0.2.1",
|
|
69
68
|
"libsqlproxy": "^0.1.0",
|
|
70
|
-
"traforo": "^0.2.5"
|
|
69
|
+
"traforo": "^0.2.5",
|
|
70
|
+
"opencode-injection-guard": "^0.2.1"
|
|
71
71
|
},
|
|
72
72
|
"optionalDependencies": {
|
|
73
73
|
"@snazzah/davey": "^0.1.10",
|
package/src/commands/vscode.ts
CHANGED
|
@@ -21,7 +21,6 @@ const MAX_SESSION_MINUTES = 30
|
|
|
21
21
|
const MAX_SESSION_MS = MAX_SESSION_MINUTES * 60 * 1000
|
|
22
22
|
const TUNNEL_BASE_DOMAIN = 'kimaki.dev'
|
|
23
23
|
const TUNNEL_ID_BYTES = 16
|
|
24
|
-
const CONNECTION_TOKEN_BYTES = 16
|
|
25
24
|
const READY_TIMEOUT_MS = 60_000
|
|
26
25
|
const LOCAL_HOST = '127.0.0.1'
|
|
27
26
|
|
|
@@ -41,29 +40,11 @@ export function createVscodeTunnelId(): string {
|
|
|
41
40
|
return crypto.randomBytes(TUNNEL_ID_BYTES).toString('hex')
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
export function createVscodeConnectionToken(): string {
|
|
45
|
-
return crypto.randomBytes(CONNECTION_TOKEN_BYTES).toString('hex')
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function buildVscodeUrl({
|
|
49
|
-
tunnelUrl,
|
|
50
|
-
connectionToken,
|
|
51
|
-
}: {
|
|
52
|
-
tunnelUrl: string
|
|
53
|
-
connectionToken: string
|
|
54
|
-
}): string {
|
|
55
|
-
const url = new URL(tunnelUrl)
|
|
56
|
-
url.searchParams.set('tkn', connectionToken)
|
|
57
|
-
return url.toString()
|
|
58
|
-
}
|
|
59
|
-
|
|
60
43
|
export function buildCoderaftArgs({
|
|
61
44
|
port,
|
|
62
|
-
connectionToken,
|
|
63
45
|
workingDirectory,
|
|
64
46
|
}: {
|
|
65
47
|
port: number
|
|
66
|
-
connectionToken: string
|
|
67
48
|
workingDirectory: string
|
|
68
49
|
}): string[] {
|
|
69
50
|
return [
|
|
@@ -72,8 +53,7 @@ export function buildCoderaftArgs({
|
|
|
72
53
|
String(port),
|
|
73
54
|
'--host',
|
|
74
55
|
LOCAL_HOST,
|
|
75
|
-
'--connection-token',
|
|
76
|
-
connectionToken,
|
|
56
|
+
'--without-connection-token',
|
|
77
57
|
'--disable-workspace-trust',
|
|
78
58
|
'--default-folder',
|
|
79
59
|
workingDirectory,
|
|
@@ -186,11 +166,9 @@ export async function startVscode({
|
|
|
186
166
|
}
|
|
187
167
|
|
|
188
168
|
const port = await getAvailablePort()
|
|
189
|
-
const connectionToken = createVscodeConnectionToken()
|
|
190
169
|
const tunnelId = createVscodeTunnelId()
|
|
191
170
|
const args = buildCoderaftArgs({
|
|
192
171
|
port,
|
|
193
|
-
connectionToken,
|
|
194
172
|
workingDirectory,
|
|
195
173
|
})
|
|
196
174
|
const coderaftProcess = spawn('bunx', args, {
|
|
@@ -246,10 +224,7 @@ export async function startVscode({
|
|
|
246
224
|
throw error
|
|
247
225
|
}
|
|
248
226
|
|
|
249
|
-
const url =
|
|
250
|
-
tunnelUrl: tunnelClient.url,
|
|
251
|
-
connectionToken,
|
|
252
|
-
})
|
|
227
|
+
const url = tunnelClient.url
|
|
253
228
|
|
|
254
229
|
const timeoutTimer = setTimeout(() => {
|
|
255
230
|
logger.log(`VS Code auto-stopped after ${MAX_SESSION_MINUTES} minutes (key: ${sessionKey})`)
|
|
@@ -326,7 +301,7 @@ export async function handleVscodeCommand({
|
|
|
326
301
|
await command.editReply({
|
|
327
302
|
content:
|
|
328
303
|
`VS Code is already running for this thread. ` +
|
|
329
|
-
`
|
|
304
|
+
`This unique tunnel auto-stops after ${MAX_SESSION_MINUTES} minutes from startup.\n` +
|
|
330
305
|
`${existing.url}`,
|
|
331
306
|
})
|
|
332
307
|
return
|
|
@@ -341,7 +316,7 @@ export async function handleVscodeCommand({
|
|
|
341
316
|
await command.editReply({
|
|
342
317
|
content:
|
|
343
318
|
`VS Code started for \`${session.workingDirectory}\`. ` +
|
|
344
|
-
`This
|
|
319
|
+
`This unique tunnel auto-stops after ${MAX_SESSION_MINUTES} minutes, so open it before it expires.\n` +
|
|
345
320
|
`${session.url}`,
|
|
346
321
|
})
|
|
347
322
|
} catch (error) {
|