dsh-cliworker-now 0.0.0-stage → 0.7.6
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/LICENSE +21 -0
- package/README.en.md +344 -0
- package/README.md +346 -2
- package/cordis.patch.yml +3 -0
- package/lib/account-models.mjs +259 -0
- package/lib/client.js +21542 -0
- package/lib/client.js.map +1 -0
- package/lib/grok-catalog.mjs +145 -0
- package/lib/hermes-native-entry.py +61 -0
- package/lib/index.js +12409 -0
- package/lib/index.js.map +1 -0
- package/lib/native-launch.mjs +179 -0
- package/lib/own-account-lease.mjs +105 -0
- package/lib/pi-installation.mjs +63 -0
- package/lib/pi-login.mjs +80 -0
- package/lib/pi-native-catalog.mjs +417 -0
- package/lib/pi-omp-bridge.mjs +602 -0
- package/lib/pi-omp-environment.mjs +15 -0
- package/lib/pi-omp-refresh.mjs +324 -0
- package/lib/private-launch.mjs +19 -0
- package/lib/terminal-bridge.mjs +18 -0
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +1358 -0
- package/lib/typert.remote-client.d.ts +70 -0
- package/lib/typert.remote-client.d.ts.map +1 -0
- package/lib/typert.remote-client.js +1190 -0
- package/lib/types/client/account-terminal-css.d.ts +1 -0
- package/lib/types/client/account-terminal-css.js +3 -0
- package/lib/types/client/account-terminal-css.js.map +1 -0
- package/lib/types/client/account-terminal.d.ts +13 -0
- package/lib/types/client/account-terminal.js +296 -0
- package/lib/types/client/account-terminal.js.map +1 -0
- package/lib/types/client/assets/antigravity.png +0 -0
- package/lib/types/client/assets/claude-code.png +0 -0
- package/lib/types/client/assets/cliworker-now-logo.png +0 -0
- package/lib/types/client/assets/codex.png +0 -0
- package/lib/types/client/assets/grok.png +0 -0
- package/lib/types/client/assets/hermes.png +0 -0
- package/lib/types/client/assets/kimi-dark.png +0 -0
- package/lib/types/client/assets/kimi-light.png +0 -0
- package/lib/types/client/assets/mimo-code.png +0 -0
- package/lib/types/client/assets/omp.png +0 -0
- package/lib/types/client/assets/opencode.png +0 -0
- package/lib/types/client/assets/pi.png +0 -0
- package/lib/types/client/assets/zcode.png +0 -0
- package/lib/types/client/composer-keymap.d.ts +18 -0
- package/lib/types/client/composer-keymap.js +49 -0
- package/lib/types/client/composer-keymap.js.map +1 -0
- package/lib/types/client/conversation-timeline.d.ts +6 -0
- package/lib/types/client/conversation-timeline.js +65 -0
- package/lib/types/client/conversation-timeline.js.map +1 -0
- package/lib/types/client/copy-text.d.ts +5 -0
- package/lib/types/client/copy-text.js +45 -0
- package/lib/types/client/copy-text.js.map +1 -0
- package/lib/types/client/icons.d.ts +21 -0
- package/lib/types/client/icons.js +68 -0
- package/lib/types/client/icons.js.map +1 -0
- package/lib/types/client/index.d.ts +3 -0
- package/lib/types/client/index.js +124 -0
- package/lib/types/client/index.js.map +1 -0
- package/lib/types/client/management-styles.d.ts +1 -0
- package/lib/types/client/management-styles.js +17 -0
- package/lib/types/client/management-styles.js.map +1 -0
- package/lib/types/client/name-copy.d.ts +5 -0
- package/lib/types/client/name-copy.js +107 -0
- package/lib/types/client/name-copy.js.map +1 -0
- package/lib/types/client/native-job-overlay.d.ts +11 -0
- package/lib/types/client/native-job-overlay.js +129 -0
- package/lib/types/client/native-job-overlay.js.map +1 -0
- package/lib/types/client/operation-error.d.ts +2 -0
- package/lib/types/client/operation-error.js +12 -0
- package/lib/types/client/operation-error.js.map +1 -0
- package/lib/types/client/panel.d.ts +8 -0
- package/lib/types/client/panel.js +310 -0
- package/lib/types/client/panel.js.map +1 -0
- package/lib/types/client/rename-copy-styles.d.ts +1 -0
- package/lib/types/client/rename-copy-styles.js +21 -0
- package/lib/types/client/rename-copy-styles.js.map +1 -0
- package/lib/types/client/rename-worker.d.ts +9 -0
- package/lib/types/client/rename-worker.js +53 -0
- package/lib/types/client/rename-worker.js.map +1 -0
- package/lib/types/client/role-presets.d.ts +6 -0
- package/lib/types/client/role-presets.js +111 -0
- package/lib/types/client/role-presets.js.map +1 -0
- package/lib/types/client/settings-dialog.d.ts +13 -0
- package/lib/types/client/settings-dialog.js +415 -0
- package/lib/types/client/settings-dialog.js.map +1 -0
- package/lib/types/client/stat-popover.d.ts +10 -0
- package/lib/types/client/stat-popover.js +32 -0
- package/lib/types/client/stat-popover.js.map +1 -0
- package/lib/types/client/styles.d.ts +9 -0
- package/lib/types/client/styles.js +221 -0
- package/lib/types/client/styles.js.map +1 -0
- package/lib/types/client/telemetry.d.ts +11 -0
- package/lib/types/client/telemetry.js +24 -0
- package/lib/types/client/telemetry.js.map +1 -0
- package/lib/types/client/worker-card.d.ts +10 -0
- package/lib/types/client/worker-card.js +75 -0
- package/lib/types/client/worker-card.js.map +1 -0
- package/lib/types/client/worker-model-menu.d.ts +9 -0
- package/lib/types/client/worker-model-menu.js +136 -0
- package/lib/types/client/worker-model-menu.js.map +1 -0
- package/lib/types/client/workers.d.ts +21 -0
- package/lib/types/client/workers.js +59 -0
- package/lib/types/client/workers.js.map +1 -0
- package/lib/types/host/account-identity.d.ts +16 -0
- package/lib/types/host/account-identity.js +126 -0
- package/lib/types/host/account-identity.js.map +1 -0
- package/lib/types/host/account-login.d.ts +10 -0
- package/lib/types/host/account-login.js +126 -0
- package/lib/types/host/account-login.js.map +1 -0
- package/lib/types/host/account-models.d.mts +19 -0
- package/lib/types/host/account-models.mjs +259 -0
- package/lib/types/host/accounts.d.ts +41 -0
- package/lib/types/host/accounts.js +838 -0
- package/lib/types/host/accounts.js.map +1 -0
- package/lib/types/host/adapters.d.ts +24 -0
- package/lib/types/host/adapters.js +331 -0
- package/lib/types/host/adapters.js.map +1 -0
- package/lib/types/host/agy-context.d.ts +8 -0
- package/lib/types/host/agy-context.js +122 -0
- package/lib/types/host/agy-context.js.map +1 -0
- package/lib/types/host/agy-models.d.ts +4 -0
- package/lib/types/host/agy-models.js +37 -0
- package/lib/types/host/agy-models.js.map +1 -0
- package/lib/types/host/authorized-catalog.d.ts +14 -0
- package/lib/types/host/authorized-catalog.js +26 -0
- package/lib/types/host/authorized-catalog.js.map +1 -0
- package/lib/types/host/bridge-protocol.d.ts +15 -0
- package/lib/types/host/bridge-protocol.js +80 -0
- package/lib/types/host/bridge-protocol.js.map +1 -0
- package/lib/types/host/cli-account-binding.d.ts +32 -0
- package/lib/types/host/cli-account-binding.js +502 -0
- package/lib/types/host/cli-account-binding.js.map +1 -0
- package/lib/types/host/cli-protocol.d.ts +27 -0
- package/lib/types/host/cli-protocol.js +212 -0
- package/lib/types/host/cli-protocol.js.map +1 -0
- package/lib/types/host/codex-account.d.ts +8 -0
- package/lib/types/host/codex-account.js +143 -0
- package/lib/types/host/codex-account.js.map +1 -0
- package/lib/types/host/codex-models.d.ts +6 -0
- package/lib/types/host/codex-models.js +165 -0
- package/lib/types/host/codex-models.js.map +1 -0
- package/lib/types/host/extended-adapters.d.ts +43 -0
- package/lib/types/host/extended-adapters.js +205 -0
- package/lib/types/host/extended-adapters.js.map +1 -0
- package/lib/types/host/first-party-account-context.d.ts +26 -0
- package/lib/types/host/first-party-account-context.js +55 -0
- package/lib/types/host/first-party-account-context.js.map +1 -0
- package/lib/types/host/first-party-models.d.ts +28 -0
- package/lib/types/host/first-party-models.js +370 -0
- package/lib/types/host/first-party-models.js.map +1 -0
- package/lib/types/host/grok-adapter.d.ts +44 -0
- package/lib/types/host/grok-adapter.js +293 -0
- package/lib/types/host/grok-adapter.js.map +1 -0
- package/lib/types/host/grok-models.d.ts +47 -0
- package/lib/types/host/grok-models.js +320 -0
- package/lib/types/host/grok-models.js.map +1 -0
- package/lib/types/host/harness-opencode-accounts.d.ts +17 -0
- package/lib/types/host/harness-opencode-accounts.js +80 -0
- package/lib/types/host/harness-opencode-accounts.js.map +1 -0
- package/lib/types/host/hermes-account-context.d.ts +8 -0
- package/lib/types/host/hermes-account-context.js +99 -0
- package/lib/types/host/hermes-account-context.js.map +1 -0
- package/lib/types/host/hermes-accounts.d.ts +19 -0
- package/lib/types/host/hermes-accounts.js +342 -0
- package/lib/types/host/hermes-accounts.js.map +1 -0
- package/lib/types/host/hermes-adapter.d.ts +90 -0
- package/lib/types/host/hermes-adapter.js +446 -0
- package/lib/types/host/hermes-adapter.js.map +1 -0
- package/lib/types/host/hermes-env.d.ts +4 -0
- package/lib/types/host/hermes-env.js +22 -0
- package/lib/types/host/hermes-env.js.map +1 -0
- package/lib/types/host/hermes-installation.d.ts +10 -0
- package/lib/types/host/hermes-installation.js +162 -0
- package/lib/types/host/hermes-installation.js.map +1 -0
- package/lib/types/host/hermes-models.d.ts +26 -0
- package/lib/types/host/hermes-models.js +328 -0
- package/lib/types/host/hermes-models.js.map +1 -0
- package/lib/types/host/hermes-native-entry.py +61 -0
- package/lib/types/host/hermes-nous.d.ts +49 -0
- package/lib/types/host/hermes-nous.js +343 -0
- package/lib/types/host/hermes-nous.js.map +1 -0
- package/lib/types/host/hermes-suppression.d.ts +7 -0
- package/lib/types/host/hermes-suppression.js +69 -0
- package/lib/types/host/hermes-suppression.js.map +1 -0
- package/lib/types/host/index.d.ts +138 -0
- package/lib/types/host/index.js +932 -0
- package/lib/types/host/index.js.map +1 -0
- package/lib/types/host/kimi-accounts.d.ts +15 -0
- package/lib/types/host/kimi-accounts.js +218 -0
- package/lib/types/host/kimi-accounts.js.map +1 -0
- package/lib/types/host/managed-agent.d.ts +4 -0
- package/lib/types/host/managed-agent.js +127 -0
- package/lib/types/host/managed-agent.js.map +1 -0
- package/lib/types/host/mimo-configuration.d.ts +22 -0
- package/lib/types/host/mimo-configuration.js +258 -0
- package/lib/types/host/mimo-configuration.js.map +1 -0
- package/lib/types/host/native-launch.d.mts +2 -0
- package/lib/types/host/native-launch.mjs +179 -0
- package/lib/types/host/native-process.d.ts +3 -0
- package/lib/types/host/native-process.js +26 -0
- package/lib/types/host/native-process.js.map +1 -0
- package/lib/types/host/opencode-adapter.d.ts +94 -0
- package/lib/types/host/opencode-adapter.js +507 -0
- package/lib/types/host/opencode-adapter.js.map +1 -0
- package/lib/types/host/opencode-native.d.ts +27 -0
- package/lib/types/host/opencode-native.js +403 -0
- package/lib/types/host/opencode-native.js.map +1 -0
- package/lib/types/host/own-account-lease.d.mts +5 -0
- package/lib/types/host/own-account-lease.mjs +105 -0
- package/lib/types/host/pi-installation.d.mts +7 -0
- package/lib/types/host/pi-installation.mjs +63 -0
- package/lib/types/host/pi-omp-accounts.d.ts +28 -0
- package/lib/types/host/pi-omp-accounts.js +175 -0
- package/lib/types/host/pi-omp-accounts.js.map +1 -0
- package/lib/types/host/pi-omp-adapter.d.ts +32 -0
- package/lib/types/host/pi-omp-adapter.js +176 -0
- package/lib/types/host/pi-omp-adapter.js.map +1 -0
- package/lib/types/host/pi-omp-environment.d.mts +1 -0
- package/lib/types/host/pi-omp-environment.mjs +15 -0
- package/lib/types/host/pi-omp-identity.d.ts +2 -0
- package/lib/types/host/pi-omp-identity.js +142 -0
- package/lib/types/host/pi-omp-identity.js.map +1 -0
- package/lib/types/host/pi-omp-logout.d.ts +3 -0
- package/lib/types/host/pi-omp-logout.js +152 -0
- package/lib/types/host/pi-omp-logout.js.map +1 -0
- package/lib/types/host/pi-omp-native.d.ts +71 -0
- package/lib/types/host/pi-omp-native.js +753 -0
- package/lib/types/host/pi-omp-native.js.map +1 -0
- package/lib/types/host/pi-omp-refresh.d.mts +7 -0
- package/lib/types/host/pi-omp-refresh.mjs +324 -0
- package/lib/types/host/process.d.ts +43 -0
- package/lib/types/host/process.js +134 -0
- package/lib/types/host/process.js.map +1 -0
- package/lib/types/host/protocol.d.ts +23 -0
- package/lib/types/host/protocol.js +112 -0
- package/lib/types/host/protocol.js.map +1 -0
- package/lib/types/host/roles.d.ts +34 -0
- package/lib/types/host/roles.js +80 -0
- package/lib/types/host/roles.js.map +1 -0
- package/lib/types/host/routing.d.ts +31 -0
- package/lib/types/host/routing.js +225 -0
- package/lib/types/host/routing.js.map +1 -0
- package/lib/types/host/runtime.d.ts +60 -0
- package/lib/types/host/runtime.js +586 -0
- package/lib/types/host/runtime.js.map +1 -0
- package/lib/types/host/storage.d.ts +48 -0
- package/lib/types/host/storage.js +449 -0
- package/lib/types/host/storage.js.map +1 -0
- package/lib/types/host/telemetry.d.ts +17 -0
- package/lib/types/host/telemetry.js +158 -0
- package/lib/types/host/telemetry.js.map +1 -0
- package/lib/types/host/zcode-account-models.d.ts +16 -0
- package/lib/types/host/zcode-account-models.js +114 -0
- package/lib/types/host/zcode-account-models.js.map +1 -0
- package/lib/types/host/zcode-adapter.d.ts +93 -0
- package/lib/types/host/zcode-adapter.js +804 -0
- package/lib/types/host/zcode-adapter.js.map +1 -0
- package/lib/types/host/zcode-grok-accounts.d.ts +28 -0
- package/lib/types/host/zcode-grok-accounts.js +359 -0
- package/lib/types/host/zcode-grok-accounts.js.map +1 -0
- package/lib/types/shared/accounts.d.ts +43 -0
- package/lib/types/shared/accounts.js +2 -0
- package/lib/types/shared/accounts.js.map +1 -0
- package/lib/types/shared/builtin-presets.d.ts +2 -0
- package/lib/types/shared/builtin-presets.js +231 -0
- package/lib/types/shared/builtin-presets.js.map +1 -0
- package/lib/types/shared/cli-settings.d.ts +5 -0
- package/lib/types/shared/cli-settings.js +2 -0
- package/lib/types/shared/cli-settings.js.map +1 -0
- package/lib/types/shared/model-presentation.d.ts +10 -0
- package/lib/types/shared/model-presentation.js +95 -0
- package/lib/types/shared/model-presentation.js.map +1 -0
- package/lib/types/shared/models.d.ts +7 -0
- package/lib/types/shared/models.js +35 -0
- package/lib/types/shared/models.js.map +1 -0
- package/lib/types/shared/telemetry.d.ts +18 -0
- package/lib/types/shared/telemetry.js +16 -0
- package/lib/types/shared/telemetry.js.map +1 -0
- package/lib/types/shared/types.d.ts +127 -0
- package/lib/types/shared/types.js +147 -0
- package/lib/types/shared/types.js.map +1 -0
- package/lib/zcode-resume.mjs +423 -0
- package/package.json +109 -4
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Native ACP initialize only: no session creation, auth request or prompt.
|
|
2
|
+
import { spawn } from 'node:child_process'
|
|
3
|
+
import { StringDecoder } from 'node:string_decoder'
|
|
4
|
+
import { nativeLaunchArgv } from './native-launch.mjs'
|
|
5
|
+
|
|
6
|
+
process.umask(0o077)
|
|
7
|
+
const [executable, cwd] = process.argv.slice(2)
|
|
8
|
+
if (!executable || !cwd || process.argv.length !== 4) throw new Error('Invalid catalog arguments')
|
|
9
|
+
const argv = nativeLaunchArgv([executable, 'agent', '--no-leader', 'stdio'])
|
|
10
|
+
const child = spawn(argv[0], argv.slice(1), {
|
|
11
|
+
cwd,
|
|
12
|
+
env: process.env,
|
|
13
|
+
detached: false,
|
|
14
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
15
|
+
})
|
|
16
|
+
const decoder = new StringDecoder('utf8')
|
|
17
|
+
let pending = '',
|
|
18
|
+
bytes = 0,
|
|
19
|
+
closed = false,
|
|
20
|
+
received = false,
|
|
21
|
+
models,
|
|
22
|
+
failure
|
|
23
|
+
let complete, reject
|
|
24
|
+
const reply = new Promise((resolve, fail) => {
|
|
25
|
+
complete = resolve
|
|
26
|
+
reject = fail
|
|
27
|
+
})
|
|
28
|
+
void reply.catch(() => {})
|
|
29
|
+
const done = new Promise((resolve) =>
|
|
30
|
+
child.once('close', (code, signal) => {
|
|
31
|
+
closed = true
|
|
32
|
+
if (!received) reject(new Error('Grok closed before initialize reply'))
|
|
33
|
+
resolve({ code, signal })
|
|
34
|
+
}),
|
|
35
|
+
)
|
|
36
|
+
function abort(message) {
|
|
37
|
+
failure ??= new Error(message)
|
|
38
|
+
reject(failure)
|
|
39
|
+
child.kill('SIGTERM')
|
|
40
|
+
}
|
|
41
|
+
child.on('error', () => abort('Unable to start Grok catalog'))
|
|
42
|
+
child.stdin.on('error', () => abort('Grok catalog input closed'))
|
|
43
|
+
const interrupt = () => abort('Grok catalog interrupted')
|
|
44
|
+
process.on('SIGTERM', interrupt)
|
|
45
|
+
process.on('SIGINT', interrupt)
|
|
46
|
+
const timeout = setTimeout(() => abort('Grok catalog timeout'), 10000)
|
|
47
|
+
const hardTimeout = setTimeout(() => child.kill('SIGKILL'), 12000)
|
|
48
|
+
function receive(chunk, stderr = false) {
|
|
49
|
+
bytes += chunk.length
|
|
50
|
+
if (bytes > 2097152) return abort('Grok catalog output exceeds limit')
|
|
51
|
+
if (stderr) return
|
|
52
|
+
pending += decoder.write(chunk)
|
|
53
|
+
if (Buffer.byteLength(pending) > 1048576) return abort('Grok catalog event exceeds limit')
|
|
54
|
+
let end
|
|
55
|
+
while ((end = pending.indexOf('\n')) >= 0) {
|
|
56
|
+
const line = pending.slice(0, end).trim()
|
|
57
|
+
pending = pending.slice(end + 1)
|
|
58
|
+
if (!line) continue
|
|
59
|
+
try {
|
|
60
|
+
const e = JSON.parse(line)
|
|
61
|
+
if (e.jsonrpc !== '2.0') throw new Error('Invalid ACP reply')
|
|
62
|
+
if (e.method && e.id !== undefined) {
|
|
63
|
+
child.stdin.write(
|
|
64
|
+
JSON.stringify({
|
|
65
|
+
jsonrpc: '2.0',
|
|
66
|
+
id: e.id,
|
|
67
|
+
error: { code: -32601, message: 'Catalog is read only' },
|
|
68
|
+
}) + '\n',
|
|
69
|
+
)
|
|
70
|
+
} else if (e.id !== undefined) {
|
|
71
|
+
if (received || e.id !== 1 || e.error || e.result?.protocolVersion !== 1)
|
|
72
|
+
throw new Error('Invalid initialize response')
|
|
73
|
+
received = true
|
|
74
|
+
const state = e.result?._meta?.modelState
|
|
75
|
+
if (!Array.isArray(state?.availableModels) || !state.availableModels.length)
|
|
76
|
+
throw new Error('Missing Grok models')
|
|
77
|
+
models = state.availableModels.map((model) => {
|
|
78
|
+
if (typeof model.modelId !== 'string' || !model.modelId) throw new Error('Missing Grok model ID')
|
|
79
|
+
const meta = model._meta
|
|
80
|
+
const efforts =
|
|
81
|
+
meta?.supportsReasoningEffort === false
|
|
82
|
+
? ['default']
|
|
83
|
+
: Array.isArray(meta?.reasoningEfforts)
|
|
84
|
+
? meta.reasoningEfforts.map((x) => x.id)
|
|
85
|
+
: []
|
|
86
|
+
if (
|
|
87
|
+
!efforts.length ||
|
|
88
|
+
efforts.some(
|
|
89
|
+
(x) =>
|
|
90
|
+
!['default', 'none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra'].includes(x),
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
throw new Error('Unsupported Grok reasoning directory')
|
|
94
|
+
return {
|
|
95
|
+
id: model.modelId,
|
|
96
|
+
label: typeof model.name === 'string' ? model.name : model.modelId,
|
|
97
|
+
efforts,
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
complete()
|
|
101
|
+
}
|
|
102
|
+
} catch {
|
|
103
|
+
abort('Invalid Grok ACP model directory')
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
child.stdout.on('data', (x) => receive(x))
|
|
108
|
+
child.stderr.on('data', (x) => receive(x, true))
|
|
109
|
+
try {
|
|
110
|
+
child.stdin.write(
|
|
111
|
+
JSON.stringify({
|
|
112
|
+
jsonrpc: '2.0',
|
|
113
|
+
id: 1,
|
|
114
|
+
method: 'initialize',
|
|
115
|
+
params: {
|
|
116
|
+
protocolVersion: 1,
|
|
117
|
+
clientCapabilities: {},
|
|
118
|
+
clientInfo: { name: 'cliworker-catalog', version: '1' },
|
|
119
|
+
},
|
|
120
|
+
}) + '\n',
|
|
121
|
+
)
|
|
122
|
+
await reply
|
|
123
|
+
child.stdin.end()
|
|
124
|
+
// Grok stdio may remain idle after EOF. Stop the read-only agent explicitly.
|
|
125
|
+
if (!closed) child.kill('SIGTERM')
|
|
126
|
+
const outcome = await done
|
|
127
|
+
if (failure || (![0, 143].includes(outcome.code) && outcome.signal !== 'SIGTERM') || pending.trim())
|
|
128
|
+
throw new Error('Grok catalog did not close cleanly')
|
|
129
|
+
process.stdout.write(JSON.stringify(models) + '\n')
|
|
130
|
+
} catch {
|
|
131
|
+
process.stderr.write('Grok 原生模型目录查询失败;请检查 CLI 版本。\n')
|
|
132
|
+
process.exitCode = 1
|
|
133
|
+
} finally {
|
|
134
|
+
child.stdin.end()
|
|
135
|
+
if (!closed) child.kill('SIGTERM')
|
|
136
|
+
const force = setTimeout(() => {
|
|
137
|
+
if (!closed) child.kill('SIGKILL')
|
|
138
|
+
}, 1000)
|
|
139
|
+
await done
|
|
140
|
+
clearTimeout(force)
|
|
141
|
+
clearTimeout(timeout)
|
|
142
|
+
clearTimeout(hardTimeout)
|
|
143
|
+
process.off('SIGTERM', interrupt)
|
|
144
|
+
process.off('SIGINT', interrupt)
|
|
145
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Use a verified current native venv with a separate account home, without installing.
|
|
2
|
+
|
|
3
|
+
The official launcher, checkout-derived install key and committed facts are checked by
|
|
4
|
+
Host. Recheck facts under the same install lock, then use Hermes' own generation lease.
|
|
5
|
+
No account/config content is copied, imported from another home, or printed here.
|
|
6
|
+
"""
|
|
7
|
+
import fcntl
|
|
8
|
+
import json
|
|
9
|
+
import os
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
import stat
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
checkout, facts, environment = map(Path, sys.argv[1:4])
|
|
15
|
+
arguments = sys.argv[4:]
|
|
16
|
+
if any(path.resolve() != path for path in (checkout, facts, environment)):
|
|
17
|
+
raise SystemExit("Hermes installation changed; reopen login settings")
|
|
18
|
+
|
|
19
|
+
def selected():
|
|
20
|
+
fd = os.open(facts, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK)
|
|
21
|
+
with os.fdopen(fd) as stream:
|
|
22
|
+
info = os.fstat(stream.fileno())
|
|
23
|
+
if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1 or info.st_size > 4 * 1024 * 1024:
|
|
24
|
+
raise RuntimeError("Invalid Hermes installation record")
|
|
25
|
+
return json.load(stream).get("packages", {}).get("venv", {}).get("environment") == str(environment)
|
|
26
|
+
|
|
27
|
+
release = None
|
|
28
|
+
try:
|
|
29
|
+
with open(facts.parent / ".install.lock", "a+b") as lock:
|
|
30
|
+
fcntl.flock(lock.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
31
|
+
if not selected():
|
|
32
|
+
raise RuntimeError("Hermes installation changed; reopen login settings")
|
|
33
|
+
sys.path.insert(0, str(checkout))
|
|
34
|
+
from hermes_cli.runtime_state import lease_generation
|
|
35
|
+
release = lease_generation(environment)
|
|
36
|
+
os.environ["HERMES_DISABLE_LAZY_INSTALLS"] = "1"
|
|
37
|
+
os.environ.pop("PYTHONHOME", None)
|
|
38
|
+
os.environ.pop("PYTHONPATH", None)
|
|
39
|
+
os.environ.pop("VIRTUAL_ENV", None)
|
|
40
|
+
sys.argv = [str(checkout / "hermes_cli/main.py"), *arguments]
|
|
41
|
+
# The native API exposes these boundaries, but main/run_agent pass the
|
|
42
|
+
# checkout's .env as a fallback. Pin its own home and disable that fallback
|
|
43
|
+
# and secret-manager hydration before either module imports the function.
|
|
44
|
+
# No parser or provider/login flow is replaced.
|
|
45
|
+
account_home = Path(os.environ["HERMES_HOME"])
|
|
46
|
+
if (account_home / ".cliworker-managed").exists() or (account_home / ".op.env").exists():
|
|
47
|
+
raise RuntimeError("Hermes plugin login cannot use additional account configuration layers")
|
|
48
|
+
from hermes_cli import env_loader
|
|
49
|
+
native_dotenv = env_loader.load_hermes_dotenv
|
|
50
|
+
def own_dotenv(**_options):
|
|
51
|
+
if (account_home / ".cliworker-managed").exists():
|
|
52
|
+
raise RuntimeError("Hermes plugin login cannot use an additional managed configuration")
|
|
53
|
+
if (account_home / ".op.env").exists():
|
|
54
|
+
raise RuntimeError("Hermes plugin login supports its own .env; external secret stores are unavailable")
|
|
55
|
+
return native_dotenv(hermes_home=account_home, project_env=None, load_external_secrets=False)
|
|
56
|
+
env_loader.load_hermes_dotenv = own_dotenv
|
|
57
|
+
from hermes_cli.main import main
|
|
58
|
+
raise SystemExit(main())
|
|
59
|
+
finally:
|
|
60
|
+
if release is not None:
|
|
61
|
+
release()
|