@lincyaw/studio 0.2.0-rc.92 → 0.2.0-rc.93
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/package.json +4 -4
- package/src/cli.ts +24 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincyaw/studio",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.93",
|
|
4
4
|
"description": "presmium studio: Presmium's workbench on DeepSeek Harness in one command, with the workspace service of a directory (experimental)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"@deepseek-ai/dsh": "0.2.1-alpha.4",
|
|
40
40
|
"http-proxy-3": "2.0.1",
|
|
41
41
|
"jiti": "^2.7.0",
|
|
42
|
-
"@lincyaw/dsh": "0.2.0-rc.
|
|
43
|
-
"@lincyaw/kernel": "1.0.0-rc.
|
|
42
|
+
"@lincyaw/dsh": "0.2.0-rc.93",
|
|
43
|
+
"@lincyaw/kernel": "1.0.0-rc.94"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@lincyaw/cli": "1.0.0-rc.
|
|
46
|
+
"@lincyaw/cli": "1.0.0-rc.94"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/src/cli.ts
CHANGED
|
@@ -27,6 +27,24 @@ function portOf(value: string | undefined): number | undefined {
|
|
|
27
27
|
return n
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/** Desktop owns the input pipe; closing it must stop Studio even when the app cannot run cleanup. */
|
|
31
|
+
function watchParentPipe(onEnd: () => void): () => void {
|
|
32
|
+
if (process.env.PRESMIUM_STUDIO_PARENT_PIPE !== '1') return () => {}
|
|
33
|
+
delete process.env.PRESMIUM_STUDIO_PARENT_PIPE
|
|
34
|
+
let ended = false
|
|
35
|
+
const end = () => {
|
|
36
|
+
if (ended) return
|
|
37
|
+
ended = true
|
|
38
|
+
onEnd()
|
|
39
|
+
}
|
|
40
|
+
process.stdin.on('end', end).on('close', end).on('error', end)
|
|
41
|
+
process.stdin.resume()
|
|
42
|
+
return () => {
|
|
43
|
+
process.stdin.off('end', end).off('close', end).off('error', end)
|
|
44
|
+
process.stdin.pause()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
30
48
|
export async function main(argv: string[], options: MainOptions = {}): Promise<number> {
|
|
31
49
|
let values: { port?: string, host?: string, 'public-url'?: string, 'preview-url'?: string, 'preview-port'?: string, help?: boolean }
|
|
32
50
|
let dir: string
|
|
@@ -53,10 +71,14 @@ export async function main(argv: string[], options: MainOptions = {}): Promise<n
|
|
|
53
71
|
const model = modelEnv(process.env)
|
|
54
72
|
if (model.warning) process.stderr.write(`presmium studio: ${model.warning}\n`)
|
|
55
73
|
|
|
74
|
+
// During startup, exiting closes the watchdog pipes; once ready, use Studio's graceful close path.
|
|
75
|
+
let parentStop: () => void = () => process.exit(0)
|
|
76
|
+
const unwatchParent = watchParentPipe(() => parentStop())
|
|
56
77
|
let studio
|
|
57
78
|
try {
|
|
58
79
|
studio = await startStudio({ dir, port: portOf(values.port), onServiceOutput: text => process.stderr.write(text), ...values.host ? { listenAddress: values.host } : {}, ...values['public-url'] ? { publicUrl: urlOf('--public-url', values['public-url']) } : {}, ...values['preview-url'] ? { previewUrl: urlOf('--preview-url', values['preview-url']) } : {}, ...values['preview-port'] ? { previewPort: portOf(values['preview-port']) } : {}, ...options.presmium ? { presmium: options.presmium } : {} })
|
|
59
80
|
} catch (error) {
|
|
81
|
+
unwatchParent()
|
|
60
82
|
process.stderr.write(`presmium studio: ${error instanceof Error ? error.message : String(error)}\n`)
|
|
61
83
|
return 2
|
|
62
84
|
}
|
|
@@ -75,8 +97,10 @@ export async function main(argv: string[], options: MainOptions = {}): Promise<n
|
|
|
75
97
|
const signals = ['SIGINT', 'SIGTERM', 'SIGHUP'] as const
|
|
76
98
|
let stop = () => {}
|
|
77
99
|
const stopped = new Promise<void>(done => stop = done)
|
|
100
|
+
parentStop = stop
|
|
78
101
|
for (const signal of signals) process.once(signal, stop)
|
|
79
102
|
const ended = await Promise.race([stopped.then(() => undefined), studio.ended])
|
|
103
|
+
unwatchParent()
|
|
80
104
|
for (const signal of signals) process.off(signal, stop)
|
|
81
105
|
await studio.close()
|
|
82
106
|
if (ended === undefined) return 0
|