dsh-cliworker-now 0.7.6 → 0.7.7
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.en.md +29 -9
- package/README.md +31 -9
- package/lib/account-models.mjs +16 -13
- package/lib/client.js +658 -61
- package/lib/client.js.map +1 -1
- package/lib/grok-catalog.mjs +2 -2
- package/lib/hermes-native-entry.py +48 -13
- package/lib/hermes-nous-refresh.py +331 -0
- package/lib/index.js +3724 -1589
- package/lib/index.js.map +1 -1
- package/lib/native-launch.mjs +62 -7
- package/lib/native-spawn.mjs +32 -0
- package/lib/pi-installation.mjs +27 -3
- package/lib/pi-native-catalog.mjs +2 -2
- package/lib/pi-omp-bridge.mjs +2 -2
- package/lib/private-launch.mjs +6 -2
- package/lib/terminal-bridge.mjs +2 -2
- package/lib/typert.host.js +83 -11
- package/lib/typert.remote-client.d.ts +2 -0
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +77 -11
- package/lib/types/client/account-query-queue.d.ts +16 -0
- package/lib/types/client/account-query-queue.js +61 -0
- package/lib/types/client/account-query-queue.js.map +1 -0
- package/lib/types/client/account-terminal.d.ts +6 -2
- package/lib/types/client/account-terminal.js +260 -31
- package/lib/types/client/account-terminal.js.map +1 -1
- package/lib/types/client/settings-dialog.js +65 -38
- package/lib/types/client/settings-dialog.js.map +1 -1
- package/lib/types/client/zcode-login-link-provider.d.ts +9 -0
- package/lib/types/client/zcode-login-link-provider.js +105 -0
- package/lib/types/client/zcode-login-link-provider.js.map +1 -0
- package/lib/types/client/zcode-login-link.d.ts +16 -0
- package/lib/types/client/zcode-login-link.js +194 -0
- package/lib/types/client/zcode-login-link.js.map +1 -0
- package/lib/types/host/account-models.d.mts +3 -1
- package/lib/types/host/account-models.mjs +16 -13
- package/lib/types/host/accounts.d.ts +3 -2
- package/lib/types/host/accounts.js +129 -22
- package/lib/types/host/accounts.js.map +1 -1
- package/lib/types/host/adapters.d.ts +1 -1
- package/lib/types/host/adapters.js +60 -11
- package/lib/types/host/adapters.js.map +1 -1
- package/lib/types/host/agy-models.d.ts +2 -1
- package/lib/types/host/agy-models.js +6 -6
- package/lib/types/host/agy-models.js.map +1 -1
- package/lib/types/host/agy-windows-account.d.ts +14 -0
- package/lib/types/host/agy-windows-account.js +104 -0
- package/lib/types/host/agy-windows-account.js.map +1 -0
- package/lib/types/host/authorized-catalog.js +13 -4
- package/lib/types/host/authorized-catalog.js.map +1 -1
- package/lib/types/host/claude-native-oauth.d.ts +17 -0
- package/lib/types/host/claude-native-oauth.js +272 -0
- package/lib/types/host/claude-native-oauth.js.map +1 -0
- package/lib/types/host/claude-own-route.d.ts +33 -0
- package/lib/types/host/claude-own-route.js +250 -0
- package/lib/types/host/claude-own-route.js.map +1 -0
- package/lib/types/host/cli-account-binding.d.ts +2 -1
- package/lib/types/host/cli-account-binding.js +59 -21
- package/lib/types/host/cli-account-binding.js.map +1 -1
- package/lib/types/host/codex-models.js +4 -0
- package/lib/types/host/codex-models.js.map +1 -1
- package/lib/types/host/extended-adapters.d.ts +3 -2
- package/lib/types/host/extended-adapters.js +9 -7
- package/lib/types/host/extended-adapters.js.map +1 -1
- package/lib/types/host/first-party-models.d.ts +1 -0
- package/lib/types/host/first-party-models.js +136 -47
- package/lib/types/host/first-party-models.js.map +1 -1
- package/lib/types/host/hermes-accounts.js +15 -1
- package/lib/types/host/hermes-accounts.js.map +1 -1
- package/lib/types/host/hermes-adapter.d.ts +3 -0
- package/lib/types/host/hermes-adapter.js +13 -4
- package/lib/types/host/hermes-adapter.js.map +1 -1
- package/lib/types/host/hermes-installation.js +54 -35
- package/lib/types/host/hermes-installation.js.map +1 -1
- package/lib/types/host/hermes-native-entry.py +48 -13
- package/lib/types/host/hermes-nous-refresh.py +331 -0
- package/lib/types/host/hermes-nous.d.ts +5 -1
- package/lib/types/host/hermes-nous.js +5 -5
- package/lib/types/host/hermes-nous.js.map +1 -1
- package/lib/types/host/hermes-renewal.d.ts +27 -0
- package/lib/types/host/hermes-renewal.js +292 -0
- package/lib/types/host/hermes-renewal.js.map +1 -0
- package/lib/types/host/hermes-windows-installation.d.ts +5 -0
- package/lib/types/host/hermes-windows-installation.js +91 -0
- package/lib/types/host/hermes-windows-installation.js.map +1 -0
- package/lib/types/host/index.d.ts +2 -0
- package/lib/types/host/index.js +17 -2
- package/lib/types/host/index.js.map +1 -1
- package/lib/types/host/kimi-accounts.d.ts +2 -0
- package/lib/types/host/kimi-accounts.js +4 -2
- package/lib/types/host/kimi-accounts.js.map +1 -1
- package/lib/types/host/kimi-oauth-models.d.ts +14 -0
- package/lib/types/host/kimi-oauth-models.js +246 -0
- package/lib/types/host/kimi-oauth-models.js.map +1 -0
- package/lib/types/host/mimo-metadata-cache.d.ts +22 -0
- package/lib/types/host/mimo-metadata-cache.js +121 -0
- package/lib/types/host/mimo-metadata-cache.js.map +1 -0
- package/lib/types/host/native-capability-cache.d.ts +11 -0
- package/lib/types/host/native-capability-cache.js +94 -0
- package/lib/types/host/native-capability-cache.js.map +1 -0
- package/lib/types/host/native-launch.mjs +62 -7
- package/lib/types/host/native-process.d.ts +3 -1
- package/lib/types/host/native-process.js +18 -3
- package/lib/types/host/native-process.js.map +1 -1
- package/lib/types/host/native-spawn.mjs +32 -0
- package/lib/types/host/pi-installation.d.mts +1 -1
- package/lib/types/host/pi-installation.mjs +27 -3
- package/lib/types/host/pi-omp-adapter.js +15 -1
- package/lib/types/host/pi-omp-adapter.js.map +1 -1
- package/lib/types/host/private-launch.mjs +23 -0
- package/lib/types/host/routing.js +25 -2
- package/lib/types/host/routing.js.map +1 -1
- package/lib/types/host/runtime.js +17 -5
- package/lib/types/host/runtime.js.map +1 -1
- package/lib/types/host/windows-account-bootstrap.ps1 +44 -0
- package/lib/types/host/windows-account-launch.mjs +47 -0
- package/lib/types/host/windows-account-owner.ps1 +137 -0
- package/lib/types/host/windows-account-stdio.mjs +19 -0
- package/lib/types/host/windows-account-terminal.d.ts +17 -0
- package/lib/types/host/windows-account-terminal.js +208 -0
- package/lib/types/host/windows-account-terminal.js.map +1 -0
- package/lib/types/host/windows-agy-account.ps1 +81 -0
- package/lib/types/host/windows-cli-installation.d.ts +31 -0
- package/lib/types/host/windows-cli-installation.js +157 -0
- package/lib/types/host/windows-cli-installation.js.map +1 -0
- package/lib/types/host/windows-hidden-launch.mjs +49 -0
- package/lib/types/host/windows-hidden-process.d.ts +12 -0
- package/lib/types/host/windows-hidden-process.js +116 -0
- package/lib/types/host/windows-hidden-process.js.map +1 -0
- package/lib/types/host/zcode-adapter.js +5 -1
- package/lib/types/host/zcode-adapter.js.map +1 -1
- package/lib/types/host/zcode-grok-accounts.d.ts +3 -1
- package/lib/types/host/zcode-grok-accounts.js +60 -11
- package/lib/types/host/zcode-grok-accounts.js.map +1 -1
- package/lib/types/shared/accounts.d.ts +4 -0
- package/lib/windows-account-bootstrap.ps1 +44 -0
- package/lib/windows-account-launch.mjs +47 -0
- package/lib/windows-account-owner.ps1 +137 -0
- package/lib/windows-account-stdio.mjs +19 -0
- package/lib/windows-agy-account.ps1 +81 -0
- package/lib/windows-hidden-launch.mjs +49 -0
- package/lib/zcode-resume.mjs +2 -2
- package/package.json +1 -1
package/lib/native-launch.mjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// Inspect fixed launcher data; never ask a shell to interpret CLI arguments.
|
|
2
2
|
import { openSync, readSync, fstatSync, closeSync, realpathSync, statSync, existsSync } from 'node:fs'
|
|
3
|
-
import { dirname, extname, isAbsolute, resolve, sep, delimiter, join } from 'node:path'
|
|
3
|
+
import { basename, dirname, extname, isAbsolute, relative, resolve, sep, delimiter, join } from 'node:path'
|
|
4
4
|
import { homedir, userInfo } from 'node:os'
|
|
5
5
|
|
|
6
|
-
const invalid = () =>
|
|
6
|
+
const invalid = () => Object.assign(
|
|
7
|
+
new Error('CLI 启动入口无法确认,请配置原生程序或固定 Node/Bun 入口'),
|
|
8
|
+
{ code: 'CLI_LAUNCHER_UNSUPPORTED' },
|
|
9
|
+
)
|
|
7
10
|
const batch = (value) => /\.(?:cmd|bat)$/i.test(value)
|
|
8
11
|
function text(path, limit = 128 * 1024) {
|
|
9
12
|
const descriptor = openSync(path, 'r')
|
|
@@ -73,6 +76,45 @@ function runtimeProgram(runtime, platform, launcherDirectory) {
|
|
|
73
76
|
if (!candidate) throw new Error('未找到 Bun,请安装该 CLI 所需的 Bun 运行时')
|
|
74
77
|
return file(candidate)
|
|
75
78
|
}
|
|
79
|
+
/** npm's native bin shim is data, not a batch program to execute. */
|
|
80
|
+
function nativePackageBin(shim, suffix) {
|
|
81
|
+
const parts = suffix.replace(/\\/g, '/').split('/')
|
|
82
|
+
if (parts[0] !== 'node_modules' || parts.some((part) => !part || part === '.' || part === '..'))
|
|
83
|
+
throw invalid()
|
|
84
|
+
const scoped = parts[1]?.startsWith('@')
|
|
85
|
+
const name = parts.slice(1, scoped ? 3 : 2).join('/')
|
|
86
|
+
if (!/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/.test(name)) throw invalid()
|
|
87
|
+
const root = fileDirectory(resolve(dirname(shim), ...parts.slice(0, scoped ? 3 : 2)))
|
|
88
|
+
const entry = file(resolve(dirname(shim), ...parts))
|
|
89
|
+
const inside = relative(root, entry)
|
|
90
|
+
if (!inside || inside === '..' || inside.startsWith('..' + sep) || isAbsolute(inside)) throw invalid()
|
|
91
|
+
const manifest = JSON.parse(text(join(root, 'package.json')))
|
|
92
|
+
const command = basename(shim, extname(shim))
|
|
93
|
+
const declared = typeof manifest.bin === 'string'
|
|
94
|
+
? name.split('/').at(-1) === command ? manifest.bin : undefined
|
|
95
|
+
: manifest.bin?.[command]
|
|
96
|
+
if (manifest.name !== name || typeof declared !== 'string' || isAbsolute(declared) ||
|
|
97
|
+
declared.replace(/\\/g, '/').split('/').includes('..') || file(resolve(root, declared)) !== entry)
|
|
98
|
+
throw invalid()
|
|
99
|
+
const descriptor = openSync(entry, 'r')
|
|
100
|
+
try {
|
|
101
|
+
const header = Buffer.alloc(64), signature = Buffer.alloc(4)
|
|
102
|
+
const size = fstatSync(descriptor).size
|
|
103
|
+
if (readSync(descriptor, header, 0, 64, 0) !== 64 || header.toString('ascii', 0, 2) !== 'MZ')
|
|
104
|
+
throw invalid()
|
|
105
|
+
const offset = header.readUInt32LE(0x3c)
|
|
106
|
+
if (offset < 64 || offset + 4 > size || readSync(descriptor, signature, 0, 4, offset) !== 4 ||
|
|
107
|
+
signature.toString('hex') !== '50450000') throw invalid()
|
|
108
|
+
} finally {
|
|
109
|
+
closeSync(descriptor)
|
|
110
|
+
}
|
|
111
|
+
return entry
|
|
112
|
+
}
|
|
113
|
+
function fileDirectory(path) {
|
|
114
|
+
const canonical = realpathSync(path)
|
|
115
|
+
if (!statSync(canonical).isDirectory()) throw invalid()
|
|
116
|
+
return canonical
|
|
117
|
+
}
|
|
76
118
|
function inspectBatch(executable, platform) {
|
|
77
119
|
const source = text(file(executable)).trim().replace(/\r\n/g, '\n')
|
|
78
120
|
// Nous' official fallback contains just a fixed interpreter and its encoded
|
|
@@ -101,8 +143,14 @@ function inspectBatch(executable, platform) {
|
|
|
101
143
|
// npm cmd-shim's standard final control prefix is launcher boilerplate;
|
|
102
144
|
// it is discarded, and nothing from it is executed by this module.
|
|
103
145
|
line = line.replace(/^endLocal & goto #_undefined_# 2>NUL \|\| title [^&\n]+ & /i, '')
|
|
146
|
+
const native = /^@?"%(?:~dp0[\\/]?|dp0%[\\/])([^"\n%]+\.exe)"\s+%\*$/i.exec(line)
|
|
147
|
+
if (native) {
|
|
148
|
+
entries.add(nativePackageBin(executable, native[1]))
|
|
149
|
+
runtimes.add('native')
|
|
150
|
+
continue
|
|
151
|
+
}
|
|
104
152
|
const command =
|
|
105
|
-
/^@?(?:(node|bun)|"%_prog%"|"%(?:~dp0
|
|
153
|
+
/^@?(?:(node|bun)|"%_prog%"|"%(?:~dp0[\\/]?|dp0%[\\/])(node|bun)\.exe")\s+"%(?:~dp0[\\/]?|dp0%[\\/])([^"\n%]+)"\s+%\*$/i.exec(
|
|
106
154
|
line,
|
|
107
155
|
)
|
|
108
156
|
if (command) {
|
|
@@ -112,7 +160,7 @@ function inspectBatch(executable, platform) {
|
|
|
112
160
|
if (command[1] || command[2]) runtimes.add((command[1] || command[2]).toLowerCase())
|
|
113
161
|
continue
|
|
114
162
|
}
|
|
115
|
-
const program = /^@?set "?_prog=(?:%(?:~dp0
|
|
163
|
+
const program = /^@?set "?_prog=(?:%(?:~dp0[\\/]?|dp0%[\\/]))?(node|bun)(?:\.exe)?"?$/i.exec(line)
|
|
116
164
|
if (program) {
|
|
117
165
|
runtimes.add(program[1].toLowerCase())
|
|
118
166
|
continue
|
|
@@ -121,7 +169,7 @@ function inspectBatch(executable, platform) {
|
|
|
121
169
|
/^@?(?:goto start|:find_dp0|:start|set dp0=%~dp0|exit \/b|setlocal|endlocal|call :find_dp0)$/i.test(
|
|
122
170
|
line,
|
|
123
171
|
) ||
|
|
124
|
-
/^@?if (?:not )?exist "%(?:~dp0
|
|
172
|
+
/^@?if (?:not )?exist "%(?:~dp0[\\/]?|dp0%[\\/])(?:node|bun)\.exe" \($/i.test(line) ||
|
|
125
173
|
/^\)(?: else \()?$/i.test(line) ||
|
|
126
174
|
/^@?set pathext=%pathext:;\.js;=;%$/i.test(line) ||
|
|
127
175
|
/^@?if (?:not )?defined node_path \($/i.test(line) ||
|
|
@@ -133,6 +181,7 @@ function inspectBatch(executable, platform) {
|
|
|
133
181
|
if (entries.size !== 1 || runtimes.size !== 1) throw invalid()
|
|
134
182
|
const entry = [...entries][0],
|
|
135
183
|
runtime = [...runtimes][0]
|
|
184
|
+
if (runtime === 'native') return { kind: 'native', argv: [entry] }
|
|
136
185
|
if (scriptRuntime(entry) !== runtime) throw invalid()
|
|
137
186
|
return { kind: runtime, argv: [runtimeProgram(runtime, platform, dirname(executable)), entry] }
|
|
138
187
|
}
|
|
@@ -151,10 +200,16 @@ export function resolveNativeEntry(executable, platform = process.platform) {
|
|
|
151
200
|
if (candidate) executable = candidate
|
|
152
201
|
}
|
|
153
202
|
if (!batch(executable)) return executable
|
|
154
|
-
|
|
203
|
+
let inspected
|
|
204
|
+
try {
|
|
205
|
+
inspected = inspectBatch(executable, platform)
|
|
206
|
+
} catch {
|
|
207
|
+
// A present but invalid shim is not an absent CLI. Never forward raw paths or script text.
|
|
208
|
+
throw invalid()
|
|
209
|
+
}
|
|
155
210
|
// Keep Bun's fixed shim identity: it may pin a bundled bun.exe beside the
|
|
156
211
|
// shim which cannot be recovered from only the package's JS path.
|
|
157
|
-
return inspected.kind === 'node' ? inspected.argv[1] : executable
|
|
212
|
+
return inspected.kind === 'node' ? inspected.argv[1] : inspected.kind === 'native' ? inspected.argv[0] : executable
|
|
158
213
|
}
|
|
159
214
|
|
|
160
215
|
/** Windows CreateProcess accepts real programs, not npm command files. */
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process'
|
|
2
|
+
|
|
3
|
+
/** Native CLI descendants keep their pipes/ConPTY and the enclosing Host Job.
|
|
4
|
+
* Window presentation is per child: hiding a wrapper does not hide its children.
|
|
5
|
+
* Node ignores windowsHide on POSIX, so both platforms use this one boundary.
|
|
6
|
+
*/
|
|
7
|
+
export function spawnNativeProcess(executable, argv, options) {
|
|
8
|
+
return spawn(executable, argv, { ...options, windowsHide: true })
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Relay ordinary background pipes as bytes with Node's stream backpressure.
|
|
12
|
+
* Numeric/inherited descriptors make libuv omit CREATE_NO_WINDOW on Windows.
|
|
13
|
+
* This must never be used for a ConPTY: its console handles stay inherited. */
|
|
14
|
+
export function forwardNativeStdio(child) {
|
|
15
|
+
const stopInput = () => {
|
|
16
|
+
process.stdin.unpipe(child.stdin)
|
|
17
|
+
process.stdin.destroy()
|
|
18
|
+
}
|
|
19
|
+
const fail = () => { child.kill('SIGTERM'); process.exitCode = 1 }
|
|
20
|
+
child.stdin.on('error', error => { stopInput(); if (error.code !== 'EPIPE') fail() })
|
|
21
|
+
child.stdin.once('close', stopInput)
|
|
22
|
+
child.once('exit', stopInput)
|
|
23
|
+
child.once('error', stopInput)
|
|
24
|
+
process.stdin.on('error', fail)
|
|
25
|
+
process.stdout.on('error', fail)
|
|
26
|
+
process.stderr.on('error', fail)
|
|
27
|
+
child.stdout.on('error', fail)
|
|
28
|
+
child.stderr.on('error', fail)
|
|
29
|
+
process.stdin.pipe(child.stdin)
|
|
30
|
+
child.stdout.pipe(process.stdout, { end: false })
|
|
31
|
+
child.stderr.pipe(process.stderr, { end: false })
|
|
32
|
+
}
|
package/lib/pi-installation.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// One verified Pi package for the Host, account UI, native catalog and RPC entry.
|
|
2
2
|
// Resolve installation metadata only; never execute an arbitrary shell launcher.
|
|
3
3
|
import { readFileSync, realpathSync, statSync } from 'node:fs'
|
|
4
|
-
import {
|
|
4
|
+
import { createHash } from 'node:crypto'
|
|
5
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
5
6
|
import { resolveNativeEntry } from './native-launch.mjs'
|
|
6
7
|
|
|
7
|
-
const versions = new Set(['1.0.2', '1.0.4'])
|
|
8
|
+
const versions = new Set(['1.0.2', '1.0.4', '1.1.0'])
|
|
8
9
|
const failure = () =>
|
|
9
10
|
Object.assign(
|
|
10
|
-
new Error('Pi 安装身份或原生接口不匹配;需要 Pi Coding Agent 1.0.2 或 1.0
|
|
11
|
+
new Error('Pi 安装身份或原生接口不匹配;需要 Pi Coding Agent 1.0.2、1.0.4 或 1.1.0,不能使用 OMP 入口'),
|
|
11
12
|
{ code: 'CLI_IDENTITY_MISMATCH' },
|
|
12
13
|
)
|
|
13
14
|
function metadata(path) {
|
|
@@ -15,6 +16,27 @@ function metadata(path) {
|
|
|
15
16
|
if (!info.isFile() || info.size > 128 * 1024) throw failure()
|
|
16
17
|
return readFileSync(path, 'utf8')
|
|
17
18
|
}
|
|
19
|
+
// Exact official Windows managed launcher inspected from Pi 1.1.0. It is read as
|
|
20
|
+
// installation metadata, never evaluated. Unknown bootstrap code fails closed.
|
|
21
|
+
const managedWindowsLauncherSHA256 = '3d8b27bb3f5c07543303b0ee774ce215e4d6ae2b0ae43311c4acf51f517ffd13'
|
|
22
|
+
function windowsManagedEntry(launcher) {
|
|
23
|
+
const source = metadata(launcher).trim().replace(/\r\n/g, '\n')
|
|
24
|
+
if (createHash('sha256').update(source).digest('hex') !== managedWindowsLauncherSHA256) throw failure()
|
|
25
|
+
const install = join(dirname(dirname(launcher)), 'install')
|
|
26
|
+
const version = metadata(join(install, 'current-version')).trim()
|
|
27
|
+
if (!versions.has(version)) throw failure()
|
|
28
|
+
const directory = resolve(install, 'releases', version, 'node_modules/@earendil-works/pi-coding-agent')
|
|
29
|
+
// A version pointer/package symlink must not select code outside this release.
|
|
30
|
+
if (realpathSync(directory) !== directory) throw failure()
|
|
31
|
+
const manifest = JSON.parse(metadata(join(directory, 'package.json')))
|
|
32
|
+
const bin = typeof manifest.bin === 'string' ? manifest.bin : manifest.bin?.pi
|
|
33
|
+
if (manifest.name !== '@earendil-works/pi-coding-agent' || manifest.version !== version ||
|
|
34
|
+
!['dist/cli.js', 'dist/bundle/cli.js'].includes(bin)) throw failure()
|
|
35
|
+
const entry = realpathSync(resolve(directory, bin))
|
|
36
|
+
const inside = relative(directory, entry)
|
|
37
|
+
if (!inside || inside === '..' || inside.startsWith('..' + sep) || isAbsolute(inside)) throw failure()
|
|
38
|
+
return entry
|
|
39
|
+
}
|
|
18
40
|
|
|
19
41
|
export function inspectPiInstallation(entry) {
|
|
20
42
|
try {
|
|
@@ -34,6 +56,8 @@ export function inspectPiInstallation(entry) {
|
|
|
34
56
|
}
|
|
35
57
|
}
|
|
36
58
|
executable = realpathSync(resolveNativeEntry(executable))
|
|
59
|
+
if (basename(executable).toLowerCase() === 'pi-launcher.js' && basename(dirname(executable)) === 'bin')
|
|
60
|
+
executable = windowsManagedEntry(executable)
|
|
37
61
|
let directory = dirname(executable)
|
|
38
62
|
for (let depth = 0; depth < 5; depth++, directory = dirname(directory)) {
|
|
39
63
|
let manifest
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Native metadata only. No prompts, API keys, OAuth objects, headers or raw errors leave this boundary.
|
|
2
2
|
import { join } from 'node:path'
|
|
3
3
|
import { pathToFileURL } from 'node:url'
|
|
4
|
-
import {
|
|
4
|
+
import { spawnNativeProcess } from './native-spawn.mjs'
|
|
5
5
|
import { inspectPiInstallation } from './pi-installation.mjs'
|
|
6
6
|
import { nativeLaunchArgv } from './native-launch.mjs'
|
|
7
7
|
|
|
@@ -144,7 +144,7 @@ async function nativeCandidates(
|
|
|
144
144
|
}
|
|
145
145
|
const args = ['models', '--json', '--no-extensions', '--config', join(directory, 'config.yml')]
|
|
146
146
|
const nativeArgs = nativeLaunchArgv([executable, ...args])
|
|
147
|
-
const child =
|
|
147
|
+
const child = spawnNativeProcess(nativeArgs[0], nativeArgs.slice(1), {
|
|
148
148
|
cwd: directory,
|
|
149
149
|
env,
|
|
150
150
|
stdio: ['ignore', 'pipe', 'pipe'],
|
package/lib/pi-omp-bridge.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Subprocess protocol bridge. The Host owns the external sandbox, credentials,
|
|
2
2
|
// deadlines, directory/session locks, and descendant cleanup. No shell is used.
|
|
3
|
-
import {
|
|
3
|
+
import { spawnNativeProcess } from './native-spawn.mjs'
|
|
4
4
|
import { createHash, randomBytes } from 'node:crypto'
|
|
5
5
|
import { mkdir, writeFile, rename, realpath, unlink, rmdir, lstat, open, rm } from 'node:fs/promises'
|
|
6
6
|
import { constants } from 'node:fs'
|
|
@@ -360,7 +360,7 @@ try {
|
|
|
360
360
|
]
|
|
361
361
|
const launch = nativeLaunchArgv([config.executable, ...nativeArgs])
|
|
362
362
|
if (stopped) throw new Error('任务已停止')
|
|
363
|
-
child =
|
|
363
|
+
child = spawnNativeProcess(launch[0], launch.slice(1), {
|
|
364
364
|
cwd: config.project,
|
|
365
365
|
env,
|
|
366
366
|
detached: false,
|
package/lib/private-launch.mjs
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
// Set a private file-creation mask without mutating the shared Harness process.
|
|
2
|
-
import {
|
|
2
|
+
import { forwardNativeStdio, spawnNativeProcess } from './native-spawn.mjs'
|
|
3
3
|
import { nativeLaunchArgv } from './native-launch.mjs'
|
|
4
4
|
process.umask(0o077)
|
|
5
5
|
const [executable, ...argv] = nativeLaunchArgv(process.argv.slice(2))
|
|
6
|
-
|
|
6
|
+
// This helper is also used under POSIX PTYs, whose original handles must stay.
|
|
7
|
+
// Windows ConPTY account launch unwraps it in windows-account-launch.mjs.
|
|
8
|
+
const backgroundPipes = process.platform === 'win32'
|
|
9
|
+
const child = spawnNativeProcess(executable, argv, { env: process.env, stdio: backgroundPipes ? ['pipe', 'pipe', 'pipe'] : 'inherit' })
|
|
10
|
+
if (backgroundPipes) forwardNativeStdio(child)
|
|
7
11
|
let stopped = false
|
|
8
12
|
for (const signal of ['SIGTERM', 'SIGINT'])
|
|
9
13
|
process.on(signal, () => {
|
package/lib/terminal-bridge.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// The native terminal owner tracks descendants across their own process groups.
|
|
2
2
|
// Keep this root alive until the Host acknowledges cleanup; never merge stderr
|
|
3
3
|
// into the CLI JSON protocol. Envelopes are transport only, not agent events.
|
|
4
|
-
import {
|
|
4
|
+
import { spawnNativeProcess } from './native-spawn.mjs'
|
|
5
5
|
import { nativeLaunchArgv } from './native-launch.mjs'
|
|
6
6
|
const [executable, ...args] = nativeLaunchArgv(process.argv.slice(2))
|
|
7
7
|
const send = (channel, fields) => process.stdout.write(JSON.stringify({ channel, ...fields }) + '\n')
|
|
8
8
|
const keepAlive = setInterval(() => {}, 60000)
|
|
9
|
-
const child =
|
|
9
|
+
const child = spawnNativeProcess(executable, args, { stdio: ['ignore', 'pipe', 'pipe'] })
|
|
10
10
|
child.stdout.on('data', (bytes) => send('stdout', { bytes: bytes.toString('base64') }))
|
|
11
11
|
child.stderr.on('data', (bytes) => send('stderr', { bytes: bytes.toString('base64') }))
|
|
12
12
|
child.on('error', (error) => send('error', { message: error.message }))
|
package/lib/typert.host.js
CHANGED
|
@@ -19,6 +19,16 @@ let dsh_cliworker_now_cliworker_accountStart_parameter_2$schema$value
|
|
|
19
19
|
const dsh_cliworker_now_cliworker_accountStart_parameter_2$schema = () => (dsh_cliworker_now_cliworker_accountStart_parameter_2$schema$value ??= z.string())
|
|
20
20
|
let dsh_cliworker_now_cliworker_accountStart_result$schema$value
|
|
21
21
|
const dsh_cliworker_now_cliworker_accountStart_result$schema = () => (dsh_cliworker_now_cliworker_accountStart_result$schema$value ??= z.string())
|
|
22
|
+
let dsh_cliworker_now_cliworker_accountStartForProvider_parameter_0$schema$value
|
|
23
|
+
const dsh_cliworker_now_cliworker_accountStartForProvider_parameter_0$schema = () => (dsh_cliworker_now_cliworker_accountStartForProvider_parameter_0$schema$value ??= z.string())
|
|
24
|
+
let dsh_cliworker_now_cliworker_accountStartForProvider_parameter_1$schema$value
|
|
25
|
+
const dsh_cliworker_now_cliworker_accountStartForProvider_parameter_1$schema = () => (dsh_cliworker_now_cliworker_accountStartForProvider_parameter_1$schema$value ??= z.string())
|
|
26
|
+
let dsh_cliworker_now_cliworker_accountStartForProvider_parameter_2$schema$value
|
|
27
|
+
const dsh_cliworker_now_cliworker_accountStartForProvider_parameter_2$schema = () => (dsh_cliworker_now_cliworker_accountStartForProvider_parameter_2$schema$value ??= z.string())
|
|
28
|
+
let dsh_cliworker_now_cliworker_accountStartForProvider_parameter_3$schema$value
|
|
29
|
+
const dsh_cliworker_now_cliworker_accountStartForProvider_parameter_3$schema = () => (dsh_cliworker_now_cliworker_accountStartForProvider_parameter_3$schema$value ??= z.string())
|
|
30
|
+
let dsh_cliworker_now_cliworker_accountStartForProvider_result$schema$value
|
|
31
|
+
const dsh_cliworker_now_cliworker_accountStartForProvider_result$schema = () => (dsh_cliworker_now_cliworker_accountStartForProvider_result$schema$value ??= z.string())
|
|
22
32
|
let dsh_cliworker_now_cliworker_accountStartForSource_parameter_0$schema$value
|
|
23
33
|
const dsh_cliworker_now_cliworker_accountStartForSource_parameter_0$schema = () => (dsh_cliworker_now_cliworker_accountStartForSource_parameter_0$schema$value ??= z.string())
|
|
24
34
|
let dsh_cliworker_now_cliworker_accountStartForSource_parameter_1$schema$value
|
|
@@ -233,7 +243,7 @@ export const TYPERT = {
|
|
|
233
243
|
typeSymbol: 'dsh-cliworker-now#cliworker/accountResize:result',
|
|
234
244
|
create: dsh_cliworker_now_cliworker_accountResize_result$schema,
|
|
235
245
|
},
|
|
236
|
-
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":
|
|
246
|
+
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":942,"column":9},
|
|
237
247
|
},
|
|
238
248
|
{
|
|
239
249
|
id: 'dsh-cliworker-now#cliworker/accountStart',
|
|
@@ -281,6 +291,62 @@ export const TYPERT = {
|
|
|
281
291
|
},
|
|
282
292
|
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":838,"column":9},
|
|
283
293
|
},
|
|
294
|
+
{
|
|
295
|
+
id: 'dsh-cliworker-now#cliworker/accountStartForProvider',
|
|
296
|
+
service: 'cliworker',
|
|
297
|
+
namespace: 'cliworker',
|
|
298
|
+
method: 'accountStartForProvider',
|
|
299
|
+
invocation: { kind: 'direct' },
|
|
300
|
+
parameters: [
|
|
301
|
+
{
|
|
302
|
+
name: 'parentSessionId',
|
|
303
|
+
wire: 'parentSessionId',
|
|
304
|
+
source: 'json',
|
|
305
|
+
codec: {
|
|
306
|
+
mode: 'strict',
|
|
307
|
+
typeSymbol: 'dsh-cliworker-now#cliworker/accountStartForProvider:parentSessionId',
|
|
308
|
+
create: dsh_cliworker_now_cliworker_accountStartForProvider_parameter_0$schema,
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: 'cli',
|
|
313
|
+
wire: 'cli',
|
|
314
|
+
source: 'json',
|
|
315
|
+
codec: {
|
|
316
|
+
mode: 'strict',
|
|
317
|
+
typeSymbol: 'dsh-cliworker-now#cliworker/accountStartForProvider:cli',
|
|
318
|
+
create: dsh_cliworker_now_cliworker_accountStartForProvider_parameter_1$schema,
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
name: 'action',
|
|
323
|
+
wire: 'action',
|
|
324
|
+
source: 'json',
|
|
325
|
+
codec: {
|
|
326
|
+
mode: 'strict',
|
|
327
|
+
typeSymbol: 'dsh-cliworker-now#cliworker/accountStartForProvider:action',
|
|
328
|
+
create: dsh_cliworker_now_cliworker_accountStartForProvider_parameter_2$schema,
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
name: 'provider',
|
|
333
|
+
wire: 'provider',
|
|
334
|
+
source: 'json',
|
|
335
|
+
codec: {
|
|
336
|
+
mode: 'strict',
|
|
337
|
+
typeSymbol: 'dsh-cliworker-now#cliworker/accountStartForProvider:provider',
|
|
338
|
+
create: dsh_cliworker_now_cliworker_accountStartForProvider_parameter_3$schema,
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
cancellation: { parameter: 'signal' },
|
|
343
|
+
result: {
|
|
344
|
+
mode: 'strict',
|
|
345
|
+
typeSymbol: 'dsh-cliworker-now#cliworker/accountStartForProvider:result',
|
|
346
|
+
create: dsh_cliworker_now_cliworker_accountStartForProvider_result$schema,
|
|
347
|
+
},
|
|
348
|
+
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":866,"column":9},
|
|
349
|
+
},
|
|
284
350
|
{
|
|
285
351
|
id: 'dsh-cliworker-now#cliworker/accountStartForSource',
|
|
286
352
|
service: 'cliworker',
|
|
@@ -406,7 +472,7 @@ export const TYPERT = {
|
|
|
406
472
|
typeSymbol: 'dsh-cliworker-now#cliworker/accountStop:result',
|
|
407
473
|
create: dsh_cliworker_now_cliworker_accountStop_result$schema,
|
|
408
474
|
},
|
|
409
|
-
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":
|
|
475
|
+
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":958,"column":9},
|
|
410
476
|
},
|
|
411
477
|
{
|
|
412
478
|
id: 'dsh-cliworker-now#cliworker/accountWatch',
|
|
@@ -443,7 +509,7 @@ export const TYPERT = {
|
|
|
443
509
|
typeSymbol: 'dsh-cliworker-now#cliworker/accountWatch:result',
|
|
444
510
|
create: dsh_cliworker_now_cliworker_accountWatch_result$schema,
|
|
445
511
|
},
|
|
446
|
-
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":
|
|
512
|
+
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":916,"column":10},
|
|
447
513
|
},
|
|
448
514
|
{
|
|
449
515
|
id: 'dsh-cliworker-now#cliworker/accountWrite',
|
|
@@ -488,7 +554,7 @@ export const TYPERT = {
|
|
|
488
554
|
typeSymbol: 'dsh-cliworker-now#cliworker/accountWrite:result',
|
|
489
555
|
create: dsh_cliworker_now_cliworker_accountWrite_result$schema,
|
|
490
556
|
},
|
|
491
|
-
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":
|
|
557
|
+
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":931,"column":9},
|
|
492
558
|
},
|
|
493
559
|
{
|
|
494
560
|
id: 'dsh-cliworker-now#cliworker/catalog',
|
|
@@ -514,7 +580,7 @@ export const TYPERT = {
|
|
|
514
580
|
typeSymbol: 'dsh-cliworker-now#cliworker/catalog:result',
|
|
515
581
|
create: dsh_cliworker_now_cliworker_catalog_result$schema,
|
|
516
582
|
},
|
|
517
|
-
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":
|
|
583
|
+
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":968,"column":9},
|
|
518
584
|
},
|
|
519
585
|
{
|
|
520
586
|
id: 'dsh-cliworker-now#cliworker/catalogForCli',
|
|
@@ -550,7 +616,7 @@ export const TYPERT = {
|
|
|
550
616
|
typeSymbol: 'dsh-cliworker-now#cliworker/catalogForCli:result',
|
|
551
617
|
create: dsh_cliworker_now_cliworker_catalogForCli_result$schema,
|
|
552
618
|
},
|
|
553
|
-
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":
|
|
619
|
+
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":973,"column":9},
|
|
554
620
|
},
|
|
555
621
|
{
|
|
556
622
|
id: 'dsh-cliworker-now#cliworker/cliSettings',
|
|
@@ -612,7 +678,7 @@ export const TYPERT = {
|
|
|
612
678
|
typeSymbol: 'dsh-cliworker-now#cliworker/configure:result',
|
|
613
679
|
create: dsh_cliworker_now_cliworker_configure_result$schema,
|
|
614
680
|
},
|
|
615
|
-
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":
|
|
681
|
+
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":991,"column":9},
|
|
616
682
|
},
|
|
617
683
|
{
|
|
618
684
|
id: 'dsh-cliworker-now#cliworker/configureWorker',
|
|
@@ -658,7 +724,7 @@ export const TYPERT = {
|
|
|
658
724
|
typeSymbol: 'dsh-cliworker-now#cliworker/configureWorker:result',
|
|
659
725
|
create: dsh_cliworker_now_cliworker_configureWorker_result$schema,
|
|
660
726
|
},
|
|
661
|
-
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":
|
|
727
|
+
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":1018,"column":9},
|
|
662
728
|
},
|
|
663
729
|
{
|
|
664
730
|
id: 'dsh-cliworker-now#cliworker/deleteRolePreset',
|
|
@@ -776,7 +842,7 @@ export const TYPERT = {
|
|
|
776
842
|
typeSymbol: 'dsh-cliworker-now#cliworker/followup:result',
|
|
777
843
|
create: dsh_cliworker_now_cliworker_followup_result$schema,
|
|
778
844
|
},
|
|
779
|
-
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":
|
|
845
|
+
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":1052,"column":9},
|
|
780
846
|
},
|
|
781
847
|
{
|
|
782
848
|
id: 'dsh-cliworker-now#cliworker/history',
|
|
@@ -969,7 +1035,7 @@ export const TYPERT = {
|
|
|
969
1035
|
typeSymbol: 'dsh-cliworker-now#cliworker/restartWorker:result',
|
|
970
1036
|
create: dsh_cliworker_now_cliworker_restartWorker_result$schema,
|
|
971
1037
|
},
|
|
972
|
-
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":
|
|
1038
|
+
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":1080,"column":9},
|
|
973
1039
|
},
|
|
974
1040
|
{
|
|
975
1041
|
id: 'dsh-cliworker-now#cliworker/restoreWorker',
|
|
@@ -1148,7 +1214,7 @@ export const TYPERT = {
|
|
|
1148
1214
|
typeSymbol: 'dsh-cliworker-now#cliworker/stop:result',
|
|
1149
1215
|
create: dsh_cliworker_now_cliworker_stop_result$schema,
|
|
1150
1216
|
},
|
|
1151
|
-
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":
|
|
1217
|
+
sourceLocation: {"file":"packages/cliworker/src/host/index.ts","line":1109,"column":9},
|
|
1152
1218
|
},
|
|
1153
1219
|
{
|
|
1154
1220
|
id: 'dsh-cliworker-now#cliworker/watch',
|
|
@@ -1282,6 +1348,12 @@ export const TYPERT = {
|
|
|
1282
1348
|
"signature": "@Remote('accountStartForSource') async accountStartForSource( parentSessionId: string, cli: string, action: string, source: string, signal: AbortSignal, ): Promise<string>",
|
|
1283
1349
|
"jsDoc": "/** @param source - One current CLI-native source, never a filesystem path. */"
|
|
1284
1350
|
},
|
|
1351
|
+
{
|
|
1352
|
+
"kind": "method",
|
|
1353
|
+
"name": "accountStartForProvider",
|
|
1354
|
+
"signature": "@Remote('accountStartForProvider') async accountStartForProvider( parentSessionId: string, cli: string, action: string, provider: string, signal: AbortSignal, ): Promise<string>",
|
|
1355
|
+
"jsDoc": "/** @param provider - Explicit ZCode native login provider, never a URL or logout source. */"
|
|
1356
|
+
},
|
|
1285
1357
|
{
|
|
1286
1358
|
"kind": "method",
|
|
1287
1359
|
"name": "accountWatch",
|
|
@@ -9,6 +9,7 @@ declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
|
9
9
|
interface TypertRemoteNamespace$636c69776f726b6572 {
|
|
10
10
|
accountResize: (parentSessionId: string, accountId: string, cols: number, rows: number) => Promise<RemoteResult<boolean>>
|
|
11
11
|
accountStart: (parentSessionId: string, cli: string, action: string, signal?: AbortSignal) => Promise<RemoteResult<string>>
|
|
12
|
+
accountStartForProvider: (parentSessionId: string, cli: string, action: string, provider: string, signal?: AbortSignal) => Promise<RemoteResult<string>>
|
|
12
13
|
accountStartForSource: (parentSessionId: string, cli: string, action: string, source: string, signal?: AbortSignal) => Promise<RemoteResult<string>>
|
|
13
14
|
accountStatus: (parentSessionId: string, cli: string, signal?: AbortSignal) => Promise<RemoteResult<string>>
|
|
14
15
|
accountStop: (parentSessionId: string, accountId: string) => Promise<RemoteResult<boolean>>
|
|
@@ -36,6 +37,7 @@ declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
|
36
37
|
interface TypertRemoteMap {
|
|
37
38
|
'cliworker/accountResize': (parentSessionId: string, accountId: string, cols: number, rows: number) => Promise<RemoteResult<boolean>>
|
|
38
39
|
'cliworker/accountStart': (parentSessionId: string, cli: string, action: string, signal?: AbortSignal) => Promise<RemoteResult<string>>
|
|
40
|
+
'cliworker/accountStartForProvider': (parentSessionId: string, cli: string, action: string, provider: string, signal?: AbortSignal) => Promise<RemoteResult<string>>
|
|
39
41
|
'cliworker/accountStartForSource': (parentSessionId: string, cli: string, action: string, source: string, signal?: AbortSignal) => Promise<RemoteResult<string>>
|
|
40
42
|
'cliworker/accountStatus': (parentSessionId: string, cli: string, signal?: AbortSignal) => Promise<RemoteResult<string>>
|
|
41
43
|
'cliworker/accountStop': (parentSessionId: string, accountId: string) => Promise<RemoteResult<boolean>>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typert.remote-client.d.ts","names":["accountResize","accountStart","accountStartForSource","accountStatus","accountStop","accountWatch","accountWrite","catalog","catalogForCli","cliSettings","configure","configureWorker","deleteRolePreset","deleteWorker","followup","history","renameWorker","renameWorkerTitle","restartWorker","restoreWorker","rolePresets","saveRolePreset","setCliEnabled","stop","watch"],"sources":["../src/host/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"typert.remote-client.d.ts","names":["accountResize","accountStart","accountStartForProvider","accountStartForSource","accountStatus","accountStop","accountWatch","accountWrite","catalog","catalogForCli","cliSettings","configure","configureWorker","deleteRolePreset","deleteWorker","followup","history","renameWorker","renameWorkerTitle","restartWorker","restoreWorker","rolePresets","saveRolePreset","setCliEnabled","stop","watch"],"sources":["../src/host/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;IA66BQA,a;IAxGAC,Y;IA4BAC,uB;IAjBAC,qB;IA3BAC,a;IAwIAC,W;IA1CCC,Y;IAeDC,Y;IAqCAC,O;IAKAC,a;IAnRAC,W;IAqSAC,S;IA2BAC,e;IA7RAC,gB;IA4CAC,Y;IAmRAC,Q;IAhXAC,O;IA6DAC,Y;IAgBAC,iB;IA+TAC,a;IApSAC,a;IA/EAC,W;IAWAC,c;IA+EAC,a;IAsTAC,I;IAxcCC,K;;;IAiSDzB,yB;IAxGAC,wB;IA4BAC,mC;IAjBAC,iC;IA3BAC,yB;IAwIAC,uB;IA1CCC,wB;IAeDC,wB;IAqCAC,mB;IAKAC,yB;IAnRAC,uB;IAqSAC,qB;IA2BAC,2B;IA7RAC,4B;IA4CAC,wB;IAmRAC,oB;IAhXAC,mB;IA6DAC,wB;IAgBAC,6B;IA+TAC,yB;IApSAC,yB;IA/EAC,uB;IAWAC,0B;IA+EAC,yB;IAsTAC,gB;IAxcCC,iB","ignoreList":[]}
|