qwen-audio-agent 0.9.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/CONTRIBUTING.md +58 -0
- package/LICENSE +201 -0
- package/NOTICE +5 -0
- package/PRIVACY.md +34 -0
- package/README.md +282 -0
- package/README_EN.md +316 -0
- package/SECURITY.md +32 -0
- package/THIRD_PARTY_NOTICES.md +26 -0
- package/cli/bin/qwenaudio.mjs +10 -0
- package/cli/package.json +13 -0
- package/cli/src/arguments.mjs +247 -0
- package/cli/src/gateway-service.mjs +386 -0
- package/cli/src/instance-lock.mjs +65 -0
- package/cli/src/launcher.mjs +217 -0
- package/cli/src/runtime.mjs +356 -0
- package/cli/src/webui.mjs +61 -0
- package/config/acp/workspace/AGENTS.md +13 -0
- package/config/codebuddy/workspace/.codebuddy/models.json +19 -0
- package/config/codebuddy/workspace/AGENTS.md +13 -0
- package/config/codex/workspace/AGENTS.md +13 -0
- package/config/frontend-agent/PROMPT.md +127 -0
- package/config/hermes/workspace/AGENTS.md +13 -0
- package/config/openclaw/openclaw.json5 +50 -0
- package/config/openclaw/workspace/AGENTS.md +9 -0
- package/config/opencode/agents/qwen-audio-agent-backend.md +65 -0
- package/config/opencode/workspace/AGENTS.md +16 -0
- package/config/qoder/workspace/AGENTS.md +16 -0
- package/docs/architecture-overview-en.png +0 -0
- package/docs/architecture-overview.png +0 -0
- package/docs/architecture.md +332 -0
- package/docs/configuration.md +386 -0
- package/docs/desktop-fluid-orb-thinking.gif +0 -0
- package/docs/desktop-goo-orb-thinking.gif +0 -0
- package/docs/qwen-audio-agent-three-layer-architecture-en.png +0 -0
- package/docs/qwen-audio-agent-three-layer-architecture.png +0 -0
- package/package.json +126 -0
- package/scripts/audit-dependencies.mjs +109 -0
- package/scripts/check-desktop-release-env.mjs +41 -0
- package/scripts/codex-acp +58 -0
- package/scripts/install-global.mjs +66 -0
- package/scripts/openclaw +194 -0
- package/scripts/openclaw-gateway +8 -0
- package/scripts/opencode-acp +6 -0
- package/scripts/opencode-server +179 -0
- package/scripts/prepare-build.mjs +38 -0
- package/scripts/release-check +182 -0
- package/scripts/set-version.mjs +133 -0
- package/scripts/start.mjs +43 -0
- package/scripts/verify-package.mjs +109 -0
- package/server/package.json +18 -0
- package/server/src/agent/acp-backend-adapter.mjs +1138 -0
- package/server/src/agent/acp-backend-profile.mjs +35 -0
- package/server/src/agent/acp-backend-session-utils.mjs +139 -0
- package/server/src/agent/acp-process-client.mjs +447 -0
- package/server/src/agent/acp-session-registry.mjs +106 -0
- package/server/src/agent/acp-session-tools.mjs +257 -0
- package/server/src/agent/agent-client.mjs +218 -0
- package/server/src/agent/backend-adapter.mjs +15 -0
- package/server/src/agent/backend-agent-instructions.mjs +8 -0
- package/server/src/agent/backends/codebuddy.mjs +47 -0
- package/server/src/agent/backends/codex.mjs +62 -0
- package/server/src/agent/backends/generic-acp.mjs +46 -0
- package/server/src/agent/backends/hermes.mjs +29 -0
- package/server/src/agent/backends/openclaw.mjs +101 -0
- package/server/src/agent/backends/opencode.mjs +36 -0
- package/server/src/agent/backends/qoder.mjs +47 -0
- package/server/src/agent/backends/registry.mjs +32 -0
- package/server/src/agent/backends/shared.mjs +46 -0
- package/server/src/agent/coordinator.mjs +308 -0
- package/server/src/agent/openclaw-adapter.mjs +245 -0
- package/server/src/app/bootstrap.mjs +244 -0
- package/server/src/conversation/conversation-sync.mjs +183 -0
- package/server/src/conversation/frontend-agent-context.mjs +162 -0
- package/server/src/conversation/frontend-memory.mjs +328 -0
- package/server/src/conversation/profiled-memory-store.mjs +87 -0
- package/server/src/conversation/task-result-projector.mjs +18 -0
- package/server/src/conversation/user-profile.mjs +234 -0
- package/server/src/core/config.mjs +388 -0
- package/server/src/core/identity.mjs +93 -0
- package/server/src/core/install-paths.mjs +8 -0
- package/server/src/core/package-version.mjs +10 -0
- package/server/src/core/request-security.mjs +80 -0
- package/server/src/index.mjs +67 -0
- package/server/src/process/backend-drivers/codebuddy.mjs +15 -0
- package/server/src/process/backend-drivers/codex.mjs +15 -0
- package/server/src/process/backend-drivers/generic-acp.mjs +18 -0
- package/server/src/process/backend-drivers/hermes.mjs +15 -0
- package/server/src/process/backend-drivers/openclaw.mjs +35 -0
- package/server/src/process/backend-drivers/opencode.mjs +75 -0
- package/server/src/process/backend-drivers/qoder.mjs +15 -0
- package/server/src/process/backend-drivers/registry.mjs +24 -0
- package/server/src/process/backend-drivers/shared.mjs +46 -0
- package/server/src/process/managed-backend.mjs +188 -0
- package/server/src/task/task-manager.mjs +704 -0
- package/server/src/task/task-scheduler.mjs +44 -0
- package/server/src/task/task-store.mjs +167 -0
- package/server/src/voice/active-voice-clients.mjs +58 -0
- package/server/src/voice/announcement/announcement-manager.mjs +402 -0
- package/server/src/voice/announcement/announcement-window.mjs +89 -0
- package/server/src/voice/input-transcript.mjs +9 -0
- package/server/src/voice/realtime-errors.mjs +6 -0
- package/server/src/voice/realtime-gateway.mjs +1366 -0
- package/server/src/voice/realtime-provider.mjs +771 -0
- package/server/src/voice/reconnect-backoff.mjs +30 -0
- package/server/src/voice/response-context.mjs +41 -0
- package/server/src/voice/session-permission-policy.mjs +56 -0
- package/server/src/voice/tools/tool-call-handler.mjs +823 -0
- package/server/src/voice/tools/turn-transcripts.mjs +59 -0
- package/server/src/voice/turn-correlation.mjs +41 -0
- package/shared/backend-catalog.mjs +56 -0
- package/shared/gateway-client.mjs +13 -0
- package/shared/realtime-events.mjs +55 -0
- package/shared/runtime-environment.mjs +422 -0
- package/tui/native/macos-voice-io.swift +552 -0
- package/tui/native/portaudio-voice-io.py +240 -0
- package/tui/package.json +13 -0
- package/tui/src/index.mjs +1217 -0
- package/tui/src/macos-voice-io.mjs +186 -0
- package/tui/src/portaudio-voice-io.mjs +158 -0
- package/web/dist/assets/index-BeamDvsE.js +38 -0
- package/web/dist/assets/index-BuB0EFih.css +1 -0
- package/web/dist/index.html +14 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
QWEN_AUDIO_AGENT_ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
5
|
+
CODEX_ACP_RUNTIME=${CODEX_ACP_RUNTIME:-auto}
|
|
6
|
+
CODEX_ACP_PACKAGE=${CODEX_ACP_PACKAGE:-@agentclientprotocol/codex-acp@1.1.7}
|
|
7
|
+
|
|
8
|
+
if [ "${QWEN_AUDIO_AGENT_ENV_LOADED:-}" != "1" ]; then
|
|
9
|
+
if [ -f "$QWEN_AUDIO_AGENT_ROOT/.env.local" ]; then
|
|
10
|
+
set -a
|
|
11
|
+
. "$QWEN_AUDIO_AGENT_ROOT/.env.local"
|
|
12
|
+
set +a
|
|
13
|
+
elif [ -f "$QWEN_AUDIO_AGENT_ROOT/.env" ]; then
|
|
14
|
+
set -a
|
|
15
|
+
. "$QWEN_AUDIO_AGENT_ROOT/.env"
|
|
16
|
+
set +a
|
|
17
|
+
fi
|
|
18
|
+
export QWEN_AUDIO_AGENT_ENV_LOADED=1
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
export CODEX_API_KEY=${CODEX_API_KEY:-${DASHSCOPE_API_KEY:-}}
|
|
22
|
+
export NO_BROWSER=${NO_BROWSER:-1}
|
|
23
|
+
|
|
24
|
+
run_binary() {
|
|
25
|
+
exec "$CODEX_ACP_BIN" "$@"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
run_package() {
|
|
29
|
+
if ! command -v npx >/dev/null 2>&1; then
|
|
30
|
+
echo "codex-acp package mode requires npx." >&2
|
|
31
|
+
exit 1
|
|
32
|
+
fi
|
|
33
|
+
exec npx -y "$CODEX_ACP_PACKAGE" "$@"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
case "$CODEX_ACP_RUNTIME" in
|
|
37
|
+
binary)
|
|
38
|
+
CODEX_ACP_BIN=${CODEX_ACP_BIN:-codex-acp}
|
|
39
|
+
run_binary "$@"
|
|
40
|
+
;;
|
|
41
|
+
package)
|
|
42
|
+
run_package "$@"
|
|
43
|
+
;;
|
|
44
|
+
auto)
|
|
45
|
+
if [ -n "${CODEX_ACP_BIN:-}" ]; then
|
|
46
|
+
run_binary "$@"
|
|
47
|
+
elif command -v codex-acp >/dev/null 2>&1; then
|
|
48
|
+
CODEX_ACP_BIN=$(command -v codex-acp)
|
|
49
|
+
run_binary "$@"
|
|
50
|
+
else
|
|
51
|
+
run_package "$@"
|
|
52
|
+
fi
|
|
53
|
+
;;
|
|
54
|
+
*)
|
|
55
|
+
echo "Unsupported CODEX_ACP_RUNTIME: $CODEX_ACP_RUNTIME" >&2
|
|
56
|
+
exit 1
|
|
57
|
+
;;
|
|
58
|
+
esac
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from 'node:child_process'
|
|
4
|
+
import {
|
|
5
|
+
mkdtempSync,
|
|
6
|
+
readdirSync,
|
|
7
|
+
rmSync,
|
|
8
|
+
} from 'node:fs'
|
|
9
|
+
import { tmpdir } from 'node:os'
|
|
10
|
+
import { dirname, join, resolve } from 'node:path'
|
|
11
|
+
import { fileURLToPath } from 'node:url'
|
|
12
|
+
|
|
13
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
14
|
+
const stagingDirectory = mkdtempSync(join(tmpdir(), 'qwen-audio-agent-install-'))
|
|
15
|
+
|
|
16
|
+
function runNpm(args) {
|
|
17
|
+
const npmExecutable = process.env.npm_execpath
|
|
18
|
+
const command = npmExecutable ? process.execPath : (
|
|
19
|
+
process.platform === 'win32' ? 'npm.cmd' : 'npm'
|
|
20
|
+
)
|
|
21
|
+
const commandArgs = npmExecutable
|
|
22
|
+
? [npmExecutable, ...args]
|
|
23
|
+
: args
|
|
24
|
+
const result = spawnSync(command, commandArgs, {
|
|
25
|
+
cwd: root,
|
|
26
|
+
env: process.env,
|
|
27
|
+
stdio: 'inherit',
|
|
28
|
+
})
|
|
29
|
+
if (result.error) throw result.error
|
|
30
|
+
if (result.status !== 0) {
|
|
31
|
+
throw new Error(`npm ${args.join(' ')} 执行失败`)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function verifyPackage() {
|
|
36
|
+
const result = spawnSync(
|
|
37
|
+
process.execPath,
|
|
38
|
+
[resolve(root, 'scripts/verify-package.mjs')],
|
|
39
|
+
{
|
|
40
|
+
cwd: root,
|
|
41
|
+
env: process.env,
|
|
42
|
+
stdio: 'inherit',
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
if (result.error) throw result.error
|
|
46
|
+
if (result.status !== 0) throw new Error('npm 成品自检失败')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
runNpm(['pack', '--pack-destination', stagingDirectory])
|
|
51
|
+
verifyPackage()
|
|
52
|
+
const archives = readdirSync(stagingDirectory)
|
|
53
|
+
.filter(name => name.endsWith('.tgz'))
|
|
54
|
+
if (archives.length !== 1) {
|
|
55
|
+
throw new Error('无法确定 qwen-audio-agent 安装包')
|
|
56
|
+
}
|
|
57
|
+
runNpm(['install', '--global', join(stagingDirectory, archives[0])])
|
|
58
|
+
process.stdout.write(
|
|
59
|
+
'qwen-audio-agent 已作为独立成品安装;运行 qwenaudio config 开始配置。\n',
|
|
60
|
+
)
|
|
61
|
+
} catch (error) {
|
|
62
|
+
process.stderr.write(`全局安装失败:${error.message}\n`)
|
|
63
|
+
process.exitCode = 1
|
|
64
|
+
} finally {
|
|
65
|
+
rmSync(stagingDirectory, { recursive: true, force: true })
|
|
66
|
+
}
|
package/scripts/openclaw
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
QWEN_AUDIO_AGENT_ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
5
|
+
export QWEN_AUDIO_AGENT_ROOT
|
|
6
|
+
|
|
7
|
+
if [ "${QWEN_AUDIO_AGENT_ENV_LOADED:-}" != "1" ]; then
|
|
8
|
+
if [ -f "$QWEN_AUDIO_AGENT_ROOT/.env.local" ]; then
|
|
9
|
+
set -a
|
|
10
|
+
. "$QWEN_AUDIO_AGENT_ROOT/.env.local"
|
|
11
|
+
set +a
|
|
12
|
+
elif [ -f "$QWEN_AUDIO_AGENT_ROOT/.env" ]; then
|
|
13
|
+
set -a
|
|
14
|
+
. "$QWEN_AUDIO_AGENT_ROOT/.env"
|
|
15
|
+
set +a
|
|
16
|
+
fi
|
|
17
|
+
export QWEN_AUDIO_AGENT_ENV_LOADED=1
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
if [ -n "${QWAUDIO_CONFIG_DIR:-}" ]; then
|
|
21
|
+
QWEN_AUDIO_AGENT_USER_DIR=$QWAUDIO_CONFIG_DIR
|
|
22
|
+
elif [ -n "${XDG_CONFIG_HOME:-}" ]; then
|
|
23
|
+
QWEN_AUDIO_AGENT_USER_DIR="$XDG_CONFIG_HOME/qwaudio"
|
|
24
|
+
elif [ -n "${HOME:-}" ]; then
|
|
25
|
+
QWEN_AUDIO_AGENT_USER_DIR="$HOME/.config/qwaudio"
|
|
26
|
+
else
|
|
27
|
+
echo "OpenClaw requires QWAUDIO_CONFIG_DIR, XDG_CONFIG_HOME, or HOME." >&2
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
export OPENCLAW_STATE_DIR=${OPENCLAW_STATE_DIR:-"$QWEN_AUDIO_AGENT_USER_DIR/backends/openclaw/state"}
|
|
31
|
+
export QWEN_AUDIO_AGENT_OPENCLAW_WORKSPACE=${QWEN_AUDIO_AGENT_OPENCLAW_WORKSPACE:-"$QWEN_AUDIO_AGENT_USER_DIR/workspaces/openclaw"}
|
|
32
|
+
mkdir -p "$OPENCLAW_STATE_DIR" "$QWEN_AUDIO_AGENT_OPENCLAW_WORKSPACE"
|
|
33
|
+
if [ ! -f "$QWEN_AUDIO_AGENT_OPENCLAW_WORKSPACE/AGENTS.md" ]; then
|
|
34
|
+
cp "$QWEN_AUDIO_AGENT_ROOT/config/openclaw/workspace/AGENTS.md" "$QWEN_AUDIO_AGENT_OPENCLAW_WORKSPACE/AGENTS.md"
|
|
35
|
+
fi
|
|
36
|
+
if [ -z "${OPENCLAW_CONFIG_PATH:-}" ]; then
|
|
37
|
+
QWEN_AUDIO_AGENT_OPENCLAW_CONFIG_DIR="$QWEN_AUDIO_AGENT_USER_DIR/backends/openclaw"
|
|
38
|
+
mkdir -p "$QWEN_AUDIO_AGENT_OPENCLAW_CONFIG_DIR"
|
|
39
|
+
cp "$QWEN_AUDIO_AGENT_ROOT/config/openclaw/openclaw.json5" "$QWEN_AUDIO_AGENT_OPENCLAW_CONFIG_DIR/openclaw.json5"
|
|
40
|
+
export OPENCLAW_CONFIG_PATH="$QWEN_AUDIO_AGENT_OPENCLAW_CONFIG_DIR/openclaw.json5"
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
export OPENCLAW_GATEWAY_TOKEN=${OPENCLAW_GATEWAY_TOKEN:-${AGENT_API_KEY:-${QWEN_AUDIO_AGENT_AUTH_SECRET:-}}}
|
|
44
|
+
OPENCLAW_GATEWAY_TOKEN_FILE=${OPENCLAW_GATEWAY_TOKEN_FILE:-"$OPENCLAW_STATE_DIR/gateway-token"}
|
|
45
|
+
if [ -n "$OPENCLAW_GATEWAY_TOKEN" ]; then
|
|
46
|
+
OPENCLAW_GATEWAY_TOKEN_TMP="$OPENCLAW_GATEWAY_TOKEN_FILE.tmp.$$"
|
|
47
|
+
umask 077
|
|
48
|
+
printf '%s\n' "$OPENCLAW_GATEWAY_TOKEN" > "$OPENCLAW_GATEWAY_TOKEN_TMP"
|
|
49
|
+
chmod 600 "$OPENCLAW_GATEWAY_TOKEN_TMP"
|
|
50
|
+
mv -f "$OPENCLAW_GATEWAY_TOKEN_TMP" "$OPENCLAW_GATEWAY_TOKEN_FILE"
|
|
51
|
+
fi
|
|
52
|
+
export OPENCLAW_GATEWAY_TOKEN_FILE
|
|
53
|
+
OPENCLAW_RUNTIME=${OPENCLAW_RUNTIME:-auto}
|
|
54
|
+
OPENCLAW_PACKAGE=${OPENCLAW_PACKAGE:-openclaw@2026.6.33}
|
|
55
|
+
OPENCLAW_BUNDLE_BIN=${OPENCLAW_BUNDLE_BIN-${HOME:+$HOME/.openclaw-bundle/wrapper/openclaw}}
|
|
56
|
+
COMMON_BACKEND_MODEL=${QWEN_AUDIO_AGENT_BACKEND_MODEL:-qwen3.7-max}
|
|
57
|
+
|
|
58
|
+
if [ -n "${OPENCLAW_MODEL:-}" ]; then
|
|
59
|
+
BACKEND_MODEL=$OPENCLAW_MODEL
|
|
60
|
+
else
|
|
61
|
+
BACKEND_MODEL="bailian/${COMMON_BACKEND_MODEL#*/}"
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
case "$BACKEND_MODEL" in
|
|
65
|
+
*/*)
|
|
66
|
+
QWEN_AUDIO_AGENT_OPENCLAW_MODEL="$BACKEND_MODEL"
|
|
67
|
+
QWEN_AUDIO_AGENT_OPENCLAW_MODEL_ID=${BACKEND_MODEL#*/}
|
|
68
|
+
;;
|
|
69
|
+
*)
|
|
70
|
+
QWEN_AUDIO_AGENT_OPENCLAW_MODEL="bailian/$BACKEND_MODEL"
|
|
71
|
+
QWEN_AUDIO_AGENT_OPENCLAW_MODEL_ID="$BACKEND_MODEL"
|
|
72
|
+
;;
|
|
73
|
+
esac
|
|
74
|
+
export QWEN_AUDIO_AGENT_OPENCLAW_MODEL
|
|
75
|
+
export QWEN_AUDIO_AGENT_OPENCLAW_MODEL_ID
|
|
76
|
+
|
|
77
|
+
run_binary() {
|
|
78
|
+
exec "$OPENCLAW_BIN" "$@"
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
run_installed() {
|
|
82
|
+
exec openclaw "$@"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
run_bundle() {
|
|
86
|
+
exec "$OPENCLAW_BUNDLE_BIN" "$@"
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
bundle_available() {
|
|
90
|
+
[ -n "$OPENCLAW_BUNDLE_BIN" ] && [ -x "$OPENCLAW_BUNDLE_BIN" ]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
installed_matches_package() {
|
|
94
|
+
OPENCLAW_EXPECTED_VERSION=${OPENCLAW_PACKAGE##*@}
|
|
95
|
+
OPENCLAW_INSTALLED_VERSION=$(
|
|
96
|
+
openclaw --version 2>/dev/null || true
|
|
97
|
+
)
|
|
98
|
+
case "$OPENCLAW_INSTALLED_VERSION" in
|
|
99
|
+
*"$OPENCLAW_EXPECTED_VERSION"*) return 0 ;;
|
|
100
|
+
*) return 1 ;;
|
|
101
|
+
esac
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
run_source() {
|
|
105
|
+
SOURCE_DIR=${OPENCLAW_SOURCE_DIR:-}
|
|
106
|
+
if [ -z "$SOURCE_DIR" ]; then
|
|
107
|
+
echo "OPENCLAW_RUNTIME=source requires OPENCLAW_SOURCE_DIR." >&2
|
|
108
|
+
exit 1
|
|
109
|
+
fi
|
|
110
|
+
if [ ! -f "$SOURCE_DIR/package.json" ]; then
|
|
111
|
+
echo "OpenClaw source directory is unavailable: $SOURCE_DIR" >&2
|
|
112
|
+
exit 1
|
|
113
|
+
fi
|
|
114
|
+
if ! command -v corepack >/dev/null 2>&1; then
|
|
115
|
+
echo "OpenClaw source mode requires corepack." >&2
|
|
116
|
+
exit 1
|
|
117
|
+
fi
|
|
118
|
+
cd "$SOURCE_DIR"
|
|
119
|
+
exec corepack pnpm openclaw "$@"
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
run_package() {
|
|
123
|
+
if ! command -v npx >/dev/null 2>&1; then
|
|
124
|
+
echo "OpenClaw package mode requires npx." >&2
|
|
125
|
+
exit 1
|
|
126
|
+
fi
|
|
127
|
+
OPENCLAW_PACKAGE_BIN=$(
|
|
128
|
+
npx --yes --package "$OPENCLAW_PACKAGE" -- which openclaw
|
|
129
|
+
)
|
|
130
|
+
if [ -z "$OPENCLAW_PACKAGE_BIN" ] || [ ! -x "$OPENCLAW_PACKAGE_BIN" ]; then
|
|
131
|
+
echo "Unable to resolve OpenClaw package binary: $OPENCLAW_PACKAGE" >&2
|
|
132
|
+
exit 1
|
|
133
|
+
fi
|
|
134
|
+
# npx normally remains as a parent process for the complete OpenClaw
|
|
135
|
+
# lifetime. Resolve the pinned package once, then exec its binary directly
|
|
136
|
+
# to avoid retaining an extra Node/npm process for both Gateway and ACP.
|
|
137
|
+
exec "$OPENCLAW_PACKAGE_BIN" "$@"
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
case "$OPENCLAW_RUNTIME" in
|
|
141
|
+
binary)
|
|
142
|
+
if [ -z "${OPENCLAW_BIN:-}" ]; then
|
|
143
|
+
echo "OPENCLAW_RUNTIME=binary requires OPENCLAW_BIN." >&2
|
|
144
|
+
exit 1
|
|
145
|
+
fi
|
|
146
|
+
run_binary "$@"
|
|
147
|
+
;;
|
|
148
|
+
installed)
|
|
149
|
+
if ! command -v openclaw >/dev/null 2>&1; then
|
|
150
|
+
echo "OPENCLAW_RUNTIME=installed requires openclaw on PATH." >&2
|
|
151
|
+
exit 1
|
|
152
|
+
fi
|
|
153
|
+
run_installed "$@"
|
|
154
|
+
;;
|
|
155
|
+
bundle)
|
|
156
|
+
if ! bundle_available; then
|
|
157
|
+
echo "OPENCLAW_RUNTIME=bundle requires the enterprise OpenClaw bundle or OPENCLAW_BUNDLE_BIN." >&2
|
|
158
|
+
exit 1
|
|
159
|
+
fi
|
|
160
|
+
run_bundle "$@"
|
|
161
|
+
;;
|
|
162
|
+
source)
|
|
163
|
+
run_source "$@"
|
|
164
|
+
;;
|
|
165
|
+
package)
|
|
166
|
+
run_package "$@"
|
|
167
|
+
;;
|
|
168
|
+
auto) ;;
|
|
169
|
+
*)
|
|
170
|
+
echo "Unknown OPENCLAW_RUNTIME: $OPENCLAW_RUNTIME" >&2
|
|
171
|
+
exit 1
|
|
172
|
+
;;
|
|
173
|
+
esac
|
|
174
|
+
|
|
175
|
+
if [ -n "${OPENCLAW_BIN:-}" ]; then
|
|
176
|
+
run_binary "$@"
|
|
177
|
+
fi
|
|
178
|
+
|
|
179
|
+
if [ -n "${OPENCLAW_SOURCE_DIR:-}" ]; then
|
|
180
|
+
run_source "$@"
|
|
181
|
+
fi
|
|
182
|
+
|
|
183
|
+
# OpenClaw Enterprise installs its policy-enforcing wrapper outside the normal
|
|
184
|
+
# npm PATH. Prefer that explicit installation over unrelated global packages
|
|
185
|
+
# and over downloading the public package at runtime.
|
|
186
|
+
if bundle_available; then
|
|
187
|
+
run_bundle "$@"
|
|
188
|
+
fi
|
|
189
|
+
|
|
190
|
+
if command -v openclaw >/dev/null 2>&1 && installed_matches_package; then
|
|
191
|
+
run_installed "$@"
|
|
192
|
+
fi
|
|
193
|
+
|
|
194
|
+
run_package "$@"
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
QWEN_AUDIO_AGENT_ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
5
|
+
OPENCODE_PORT=${OPENCODE_PORT:-4096}
|
|
6
|
+
OPENCODE_RUNTIME=${OPENCODE_RUNTIME:-auto}
|
|
7
|
+
OPENCODE_PACKAGE=${OPENCODE_PACKAGE:-opencode-ai@1.18.5}
|
|
8
|
+
OPENCODE_MIN_VERSION=${OPENCODE_MIN_VERSION:-1.18.0}
|
|
9
|
+
OPENCODE_COMMAND=${OPENCODE_COMMAND:-serve}
|
|
10
|
+
QWEN_AUDIO_AGENT_NODE=${QWEN_AUDIO_AGENT_NODE:-node}
|
|
11
|
+
BACKEND_MODEL=${QWEN_AUDIO_AGENT_BACKEND_MODEL:-qwen3.7-max}
|
|
12
|
+
|
|
13
|
+
if [ -z "${OPENCODE_MODEL:-}" ]; then
|
|
14
|
+
MODEL_ID=${BACKEND_MODEL#*/}
|
|
15
|
+
export OPENCODE_MODEL="alibaba-cn/$MODEL_ID"
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
if [ "${QWEN_AUDIO_AGENT_ENV_LOADED:-}" != "1" ]; then
|
|
19
|
+
if [ -f "$QWEN_AUDIO_AGENT_ROOT/.env.local" ]; then
|
|
20
|
+
set -a
|
|
21
|
+
. "$QWEN_AUDIO_AGENT_ROOT/.env.local"
|
|
22
|
+
set +a
|
|
23
|
+
elif [ -f "$QWEN_AUDIO_AGENT_ROOT/.env" ]; then
|
|
24
|
+
set -a
|
|
25
|
+
. "$QWEN_AUDIO_AGENT_ROOT/.env"
|
|
26
|
+
set +a
|
|
27
|
+
fi
|
|
28
|
+
export QWEN_AUDIO_AGENT_ENV_LOADED=1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
export OPENCODE_CONFIG_DIR=${OPENCODE_CONFIG_DIR:-"$QWEN_AUDIO_AGENT_ROOT/config/opencode"}
|
|
32
|
+
# OpenCode merges this qwen-audio-agent overlay with the user's normal global config,
|
|
33
|
+
# preserving their MCP servers, skills, permissions and plugins. Isolation is
|
|
34
|
+
# available as an explicit troubleshooting option for conflicting user config.
|
|
35
|
+
if [ -n "${QWEN_AUDIO_AGENT_OPENCODE_XDG_CONFIG_HOME:-}" ]; then
|
|
36
|
+
export XDG_CONFIG_HOME="$QWEN_AUDIO_AGENT_OPENCODE_XDG_CONFIG_HOME"
|
|
37
|
+
elif [ "${QWEN_AUDIO_AGENT_OPENCODE_ISOLATE_USER_CONFIG:-false}" = "true" ]; then
|
|
38
|
+
export XDG_CONFIG_HOME="$QWEN_AUDIO_AGENT_ROOT/runtime/opencode-xdg"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
run_binary() {
|
|
42
|
+
if [ "$OPENCODE_COMMAND" = "serve" ]; then
|
|
43
|
+
exec "$OPENCODE_BIN" serve --hostname 127.0.0.1 --port "$OPENCODE_PORT" "$@"
|
|
44
|
+
fi
|
|
45
|
+
exec "$OPENCODE_BIN" "$OPENCODE_COMMAND" "$@"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
source_bun() {
|
|
49
|
+
if [ -n "${BUN_BIN:-}" ]; then
|
|
50
|
+
printf '%s\n' "$BUN_BIN"
|
|
51
|
+
elif command -v bun >/dev/null 2>&1; then
|
|
52
|
+
command -v bun
|
|
53
|
+
fi
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
run_source() {
|
|
57
|
+
SOURCE_DIR=${OPENCODE_SOURCE_DIR:-}
|
|
58
|
+
if [ -z "$SOURCE_DIR" ]; then
|
|
59
|
+
echo "OPENCODE_RUNTIME=source requires OPENCODE_SOURCE_DIR." >&2
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
if [ ! -f "$SOURCE_DIR/packages/opencode/src/index.ts" ]; then
|
|
63
|
+
echo "OpenCode source directory is unavailable: $SOURCE_DIR" >&2
|
|
64
|
+
exit 1
|
|
65
|
+
fi
|
|
66
|
+
BUN_COMMAND=$(source_bun)
|
|
67
|
+
if [ -z "$BUN_COMMAND" ]; then
|
|
68
|
+
echo "OpenCode source mode requires Bun. Set BUN_BIN or install bun." >&2
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
if [ ! -e "$SOURCE_DIR/node_modules/@opencode-ai/tui" ]; then
|
|
72
|
+
echo "OpenCode source dependencies are missing. Run 'bun install' in $SOURCE_DIR." >&2
|
|
73
|
+
exit 1
|
|
74
|
+
fi
|
|
75
|
+
cd "$SOURCE_DIR/packages/opencode"
|
|
76
|
+
if [ "$OPENCODE_COMMAND" = "serve" ]; then
|
|
77
|
+
exec "$BUN_COMMAND" run --conditions=browser ./src/index.ts serve \
|
|
78
|
+
--hostname 127.0.0.1 \
|
|
79
|
+
--port "$OPENCODE_PORT" \
|
|
80
|
+
"$@"
|
|
81
|
+
fi
|
|
82
|
+
exec "$BUN_COMMAND" run --conditions=browser ./src/index.ts \
|
|
83
|
+
"$OPENCODE_COMMAND" "$@"
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
run_package() {
|
|
87
|
+
if ! command -v npx >/dev/null 2>&1; then
|
|
88
|
+
echo "OpenCode package mode requires npx." >&2
|
|
89
|
+
exit 1
|
|
90
|
+
fi
|
|
91
|
+
if [ "$OPENCODE_COMMAND" = "serve" ]; then
|
|
92
|
+
exec npx --yes "$OPENCODE_PACKAGE" serve \
|
|
93
|
+
--hostname 127.0.0.1 \
|
|
94
|
+
--port "$OPENCODE_PORT" \
|
|
95
|
+
"$@"
|
|
96
|
+
fi
|
|
97
|
+
exec npx --yes "$OPENCODE_PACKAGE" "$OPENCODE_COMMAND" "$@"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
installed_version() {
|
|
101
|
+
opencode --version 2>/dev/null | head -n 1
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
version_supported() {
|
|
105
|
+
"$QWEN_AUDIO_AGENT_NODE" -e '
|
|
106
|
+
const parse = value => {
|
|
107
|
+
const match = String(value).match(/(\d+)\.(\d+)\.(\d+)/)
|
|
108
|
+
return match ? match.slice(1).map(Number) : null
|
|
109
|
+
}
|
|
110
|
+
const actual = parse(process.argv[1])
|
|
111
|
+
const minimum = parse(process.argv[2])
|
|
112
|
+
if (!actual || !minimum) process.exit(1)
|
|
113
|
+
for (let index = 0; index < 3; index += 1) {
|
|
114
|
+
if (actual[index] > minimum[index]) process.exit(0)
|
|
115
|
+
if (actual[index] < minimum[index]) process.exit(1)
|
|
116
|
+
}
|
|
117
|
+
' "$1" "$OPENCODE_MIN_VERSION"
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
run_installed() {
|
|
121
|
+
if ! command -v opencode >/dev/null 2>&1; then
|
|
122
|
+
echo "OPENCODE_RUNTIME=installed requires opencode on PATH." >&2
|
|
123
|
+
exit 1
|
|
124
|
+
fi
|
|
125
|
+
VERSION=$(installed_version)
|
|
126
|
+
if ! version_supported "$VERSION"; then
|
|
127
|
+
echo "Installed OpenCode $VERSION is older than the supported minimum $OPENCODE_MIN_VERSION." >&2
|
|
128
|
+
exit 1
|
|
129
|
+
fi
|
|
130
|
+
if [ "$OPENCODE_COMMAND" = "serve" ]; then
|
|
131
|
+
exec opencode serve --hostname 127.0.0.1 --port "$OPENCODE_PORT" "$@"
|
|
132
|
+
fi
|
|
133
|
+
exec opencode "$OPENCODE_COMMAND" "$@"
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
case "$OPENCODE_RUNTIME" in
|
|
137
|
+
binary)
|
|
138
|
+
if [ -z "${OPENCODE_BIN:-}" ]; then
|
|
139
|
+
echo "OPENCODE_RUNTIME=binary requires OPENCODE_BIN." >&2
|
|
140
|
+
exit 1
|
|
141
|
+
fi
|
|
142
|
+
run_binary "$@"
|
|
143
|
+
;;
|
|
144
|
+
source)
|
|
145
|
+
run_source "$@"
|
|
146
|
+
;;
|
|
147
|
+
package)
|
|
148
|
+
run_package "$@"
|
|
149
|
+
;;
|
|
150
|
+
installed)
|
|
151
|
+
run_installed "$@"
|
|
152
|
+
;;
|
|
153
|
+
auto) ;;
|
|
154
|
+
*)
|
|
155
|
+
echo "Unknown OPENCODE_RUNTIME: $OPENCODE_RUNTIME" >&2
|
|
156
|
+
exit 1
|
|
157
|
+
;;
|
|
158
|
+
esac
|
|
159
|
+
|
|
160
|
+
if [ -n "${OPENCODE_BIN:-}" ]; then
|
|
161
|
+
run_binary "$@"
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
if [ -n "${OPENCODE_SOURCE_DIR:-}" ]; then
|
|
165
|
+
run_source "$@"
|
|
166
|
+
fi
|
|
167
|
+
|
|
168
|
+
if command -v opencode >/dev/null 2>&1; then
|
|
169
|
+
VERSION=$(installed_version)
|
|
170
|
+
if version_supported "$VERSION"; then
|
|
171
|
+
if [ "$OPENCODE_COMMAND" = "serve" ]; then
|
|
172
|
+
exec opencode serve --hostname 127.0.0.1 --port "$OPENCODE_PORT" "$@"
|
|
173
|
+
fi
|
|
174
|
+
exec opencode "$OPENCODE_COMMAND" "$@"
|
|
175
|
+
fi
|
|
176
|
+
echo "Skipping incompatible OpenCode $VERSION; using $OPENCODE_PACKAGE instead." >&2
|
|
177
|
+
fi
|
|
178
|
+
|
|
179
|
+
run_package "$@"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Builds web/dist for npm lifecycle "prepare". Global installs from git
|
|
3
|
+
// (npm install -g git+...) leak npm_config_global and other npm_config_*
|
|
4
|
+
// values into nested npm processes, which breaks --workspace commands and
|
|
5
|
+
// skips the local node_modules this build needs. This script therefore runs
|
|
6
|
+
// npm with a sanitized environment and installs dependencies itself when the
|
|
7
|
+
// preparation environment did not provide them.
|
|
8
|
+
import { spawnSync } from 'node:child_process'
|
|
9
|
+
import { existsSync } from 'node:fs'
|
|
10
|
+
import { dirname, resolve } from 'node:path'
|
|
11
|
+
import { fileURLToPath } from 'node:url'
|
|
12
|
+
|
|
13
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
14
|
+
|
|
15
|
+
// The nested npm install below triggers "prepare" again; the guard keeps the
|
|
16
|
+
// recursion to a single level.
|
|
17
|
+
if (process.env.QWEN_AUDIO_AGENT_PREPARE === '1') process.exit(0)
|
|
18
|
+
|
|
19
|
+
const environment = { ...process.env, QWEN_AUDIO_AGENT_PREPARE: '1' }
|
|
20
|
+
for (const key of Object.keys(environment)) {
|
|
21
|
+
if (key.toLowerCase().startsWith('npm_config_')) delete environment[key]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'
|
|
25
|
+
function run(args) {
|
|
26
|
+
const result = spawnSync(npm, args, {
|
|
27
|
+
cwd: root,
|
|
28
|
+
env: environment,
|
|
29
|
+
stdio: 'inherit',
|
|
30
|
+
shell: process.platform === 'win32',
|
|
31
|
+
})
|
|
32
|
+
if (result.status !== 0) process.exit(result.status || 1)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!existsSync(resolve(root, 'node_modules/.bin/vite'))) {
|
|
36
|
+
run(['install', '--no-save', '--no-audit', '--include=dev'])
|
|
37
|
+
}
|
|
38
|
+
run(['run', 'build'])
|