qwen-audio-agent 2.0.1 → 2.2.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/README.md +21 -10
- package/README_ZH.md +19 -10
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/cli/package.json +1 -1
- package/cli/src/arguments.mjs +4 -1
- package/cli/src/config-command.mjs +36 -6
- package/cli/src/gateway-service.mjs +7 -1
- package/cli/src/launcher.mjs +13 -0
- package/config/frontend-agent/LIVE_PROMPT.md +64 -0
- package/config/frontend-agent/PROMPT.md +29 -26
- package/desktop/src/i18n.mjs +6 -1
- package/desktop/src/settings-config.mjs +32 -40
- package/desktop/src/settings-store.mjs +19 -28
- package/docs/architecture/deep-dive.md +103 -66
- package/docs/architecture/deep-dive.zh.md +73 -50
- package/docs/backends/configuration.md +4 -4
- package/docs/backends/configuration.zh.md +4 -4
- package/docs/backends/overview.md +3 -0
- package/docs/backends/overview.zh.md +3 -0
- package/docs/configuration/backend.md +15 -1
- package/docs/configuration/backend.zh.md +15 -1
- package/docs/configuration/frontend.md +78 -28
- package/docs/configuration/frontend.zh.md +76 -28
- package/docs/configuration.md +1 -1
- package/docs/configuration.zh.md +1 -1
- package/docs/contract.md +24 -2
- package/docs/contract.zh.md +20 -2
- package/docs/extensions.md +14 -0
- package/docs/extensions.zh.md +11 -0
- package/docs/gateway-protocol.md +26 -0
- package/docs/gateway-protocol.zh.md +22 -0
- package/docs/gateway-webrtc-client.md +3 -3
- package/docs/gateway-webrtc-client.zh.md +3 -3
- package/docs/getting-started/install.md +4 -1
- package/docs/getting-started/install.zh.md +4 -1
- package/docs/getting-started/mobile.md +8 -2
- package/docs/getting-started/mobile.zh.md +5 -0
- package/docs/getting-started/quickstart.md +2 -2
- package/docs/getting-started/quickstart.zh.md +2 -2
- package/docs/getting-started/webui.md +2 -0
- package/docs/getting-started/webui.zh.md +2 -0
- package/docs/guides/knowledge.md +8 -5
- package/docs/guides/knowledge.zh.md +4 -3
- package/docs/guides/tasks.md +63 -2
- package/docs/guides/tasks.zh.md +45 -1
- package/docs/guides/web-search.md +32 -1
- package/docs/guides/web-search.zh.md +28 -1
- package/docs/operations/troubleshooting.md +30 -0
- package/docs/operations/troubleshooting.zh.md +26 -0
- package/docs/reference/backend-adapter-sdk.md +33 -2
- package/docs/reference/backend-adapter-sdk.zh.md +29 -2
- package/docs/reference/cli.md +3 -3
- package/docs/reference/cli.zh.md +3 -3
- package/docs/scenarios/lightrag.md +2 -2
- package/docs/scenarios/lightrag.zh.md +2 -2
- package/docs/scenarios/x-omni.md +5 -2
- package/docs/scenarios/x-omni.zh.md +5 -2
- package/docs/voice-agent-architecture-presentation.zh.md +34 -37
- package/docs/voice-frontends/custom-provider.md +22 -4
- package/docs/voice-frontends/custom-provider.zh.md +22 -4
- package/docs/voice-frontends/google-live.md +14 -8
- package/docs/voice-frontends/google-live.zh.md +13 -8
- package/docs/voice-frontends/gpt-live-1.md +149 -0
- package/docs/voice-frontends/gpt-live-1.zh.md +114 -0
- package/docs/voice-frontends/minicpm-o.md +8 -4
- package/docs/voice-frontends/minicpm-o.zh.md +7 -4
- package/docs/voice-frontends/{gpt-live.md → openai-realtime.md} +19 -10
- package/docs/voice-frontends/{gpt-live.zh.md → openai-realtime.zh.md} +18 -10
- package/docs/voice-frontends/qwen-audio-live.md +164 -0
- package/docs/voice-frontends/qwen-audio-live.zh.md +122 -0
- package/docs/voice-frontends/qwen-audio-realtime.md +41 -15
- package/docs/voice-frontends/qwen-audio-realtime.zh.md +34 -12
- package/docs/voice-frontends/qwen-omni-realtime.md +12 -9
- package/docs/voice-frontends/qwen-omni-realtime.zh.md +12 -9
- package/docs/voice-frontends/speech-to-speech.md +8 -4
- package/docs/voice-frontends/speech-to-speech.zh.md +7 -3
- package/docs/voice-frontends/stepfun.md +7 -4
- package/docs/voice-frontends/stepfun.zh.md +7 -4
- package/examples/webrtc/start.mjs +2 -1
- package/package.json +34 -16
- package/scripts/audit-dependencies.mjs +3 -25
- package/scripts/electron-smoke.mjs +5 -5
- package/scripts/patch-build-node-gyp.mjs +63 -0
- package/scripts/prepare-build.mjs +2 -0
- package/scripts/release-check +2 -2
- package/scripts/runtime/claude-code-acp.mjs +5 -5
- package/scripts/verify-package.mjs +3 -0
- package/server/package.json +5 -5
- package/server/src/app/gateway-application.mjs +3 -0
- package/server/src/app/gateway-http-routes.mjs +3 -0
- package/server/src/app/session-conversation-history.mjs +9 -1
- package/server/src/backend/adapters/a2a/backend-adapter.mjs +32 -26
- package/server/src/backend/adapters/acp/backend-adapter.mjs +703 -251
- package/server/src/backend/adapters/acp/coordinator-contract.mjs +2 -13
- package/server/src/backend/adapters/acp/coordinator-instructions.mjs +29 -8
- package/server/src/backend/adapters/acp/coordinator-queue.mjs +58 -0
- package/server/src/backend/adapters/acp/drivers/codex.mjs +1 -1
- package/server/src/backend/adapters/acp/drivers/openclaw.mjs +1 -2
- package/server/src/backend/adapters/acp/input-broker.mjs +2 -0
- package/server/src/backend/adapters/acp/process-client.mjs +111 -16
- package/server/src/backend/adapters/acp/session-configuration.mjs +2 -19
- package/server/src/backend/adapters/acp/session-registry.mjs +9 -0
- package/server/src/backend/adapters/acp/session-tools.mjs +1 -1
- package/server/src/backend/adapters/acp/turn-updates.mjs +188 -0
- package/server/src/backend/adapters/acp/work-continuation.mjs +48 -0
- package/server/src/backend/adapters/agent-client.mjs +24 -1
- package/server/src/backend/adapters/llm/backend-adapter.mjs +393 -0
- package/server/src/backend/adapters/muse/backend-adapter.mjs +2 -0
- package/server/src/backend/availability.mjs +12 -3
- package/server/src/backend/backend-adapter-sdk.mjs +3 -0
- package/server/src/backend/backend-port.mjs +13 -0
- package/server/src/backend/backend-work-runtime.mjs +23 -0
- package/server/src/client/client-command-runtime.mjs +14 -0
- package/server/src/conversation/conversation-sync.mjs +26 -2
- package/server/src/conversation/frontend-agent-context.mjs +18 -5
- package/server/src/conversation/frontend-notes.mjs +7 -5
- package/server/src/conversation/task-result-projector.mjs +1 -1
- package/server/src/core/backend-events.mjs +4 -0
- package/server/src/core/citation.mjs +8 -2
- package/server/src/core/config.mjs +46 -54
- package/server/src/core/gateway-protocol.mjs +4 -1
- package/server/src/core/request-security.mjs +7 -1
- package/server/src/core/work-conversation-context.mjs +138 -0
- package/server/src/core/work-input-request.mjs +1 -0
- package/server/src/frontend/frontend-tools.mjs +20 -7
- package/server/src/frontend/retrieval/providers/bing.mjs +23 -12
- package/server/src/frontend/retrieval/providers/factory.mjs +18 -1
- package/server/src/frontend/retrieval/providers/mcp.mjs +30 -11
- package/server/src/frontend/retrieval/providers/so360.mjs +23 -12
- package/server/src/frontend/tools/agent-task-runtime.mjs +119 -99
- package/server/src/frontend/tools/features/agent-task-tools.mjs +23 -42
- package/server/src/frontend/tools/frontend-tool-context.mjs +2 -2
- package/server/src/frontend/tools/spawn-thinking-tool.mjs +2 -2
- package/server/src/frontend/tools/tool-call-handler.mjs +166 -86
- package/server/src/knowledge/providers/local/library.mjs +26 -6
- package/server/src/knowledge/providers/local/provider.mjs +25 -6
- package/server/src/memory/providers/markdown/context-store.mjs +24 -11
- package/server/src/orchestration/session-task-coordinator.mjs +13 -3
- package/server/src/orchestration/task-operations.mjs +54 -12
- package/server/src/orchestration/task-updates.mjs +82 -0
- package/server/src/task/reminder-scheduler.mjs +5 -1
- package/server/src/task/task-manager.mjs +72 -15
- package/server/src/task/task-recovery.mjs +12 -2
- package/server/src/task/task-scheduler.mjs +5 -5
- package/server/src/task/task-state.mjs +13 -0
- package/server/src/transport/gateway-client-transport.mjs +35 -0
- package/server/src/transport/webrtc/protocol.mjs +1 -1
- package/server/src/voice/announcement/announcement-manager.mjs +3 -0
- package/server/src/voice/audio-stream-diagnostics.mjs +139 -0
- package/server/src/voice/native-delegation-runtime.mjs +360 -0
- package/server/src/voice/providers/dashscope-live.mjs +93 -0
- package/server/src/voice/providers/dashscope.mjs +45 -33
- package/server/src/voice/providers/doubao-seeduplex-protocol.mjs +54 -0
- package/server/src/voice/providers/doubao-seeduplex.mjs +16 -11
- package/server/src/voice/providers/ga-protocol.mjs +7 -2
- package/server/src/voice/providers/google-live-protocol.mjs +124 -34
- package/server/src/voice/providers/google-live.mjs +20 -14
- package/server/src/voice/providers/gpt-live-1-protocol.mjs +597 -0
- package/server/src/voice/providers/gpt-live-1.mjs +3 -0
- package/server/src/voice/providers/gpt-live-client-context.mjs +182 -0
- package/server/src/voice/providers/minicpm-o.mjs +9 -7
- package/server/src/voice/providers/openai-live.mjs +150 -0
- package/server/src/voice/providers/{gpt-live.mjs → openai-realtime.mjs} +23 -19
- package/server/src/voice/providers/provider-registry.mjs +11 -1
- package/server/src/voice/providers/qwen-live-protocol.mjs +399 -0
- package/server/src/voice/providers/registry.mjs +47 -12
- package/server/src/voice/providers/runtime-configuration.mjs +34 -0
- package/server/src/voice/providers/s2s.mjs +9 -7
- package/server/src/voice/providers/stepfun.mjs +14 -11
- package/server/src/voice/realtime-input-runtime.mjs +58 -20
- package/server/src/voice/realtime-presentation-runtime.mjs +111 -27
- package/server/src/voice/realtime-provider-session.mjs +59 -14
- package/server/src/voice/realtime-provider.mjs +358 -45
- package/server/src/voice/realtime-session-runtime.mjs +282 -35
- package/server/src/voice/realtime-task-presentation.mjs +8 -2
- package/server/src/voice/realtime-turn-state.mjs +33 -2
- package/shared/backend/catalog.mjs +26 -2
- package/shared/backend/install.mjs +3 -1
- package/shared/backend/setup.mjs +43 -0
- package/shared/gateway/client-sdk.mjs +21 -6
- package/shared/gateway/setup.mjs +13 -1
- package/shared/gateway/websocket-auth.mjs +2 -1
- package/shared/protocol/gateway-client-protocol.mjs +14 -0
- package/shared/protocol/gateway-events.mjs +39 -1
- package/shared/realtime-legacy-environment.mjs +81 -0
- package/shared/realtime-model-catalog.mjs +68 -194
- package/shared/realtime-models/README.md +33 -0
- package/shared/realtime-models/dashscope.mjs +57 -0
- package/shared/realtime-models/google.mjs +10 -0
- package/shared/realtime-models/openai.mjs +24 -0
- package/shared/realtime-models/profile.mjs +38 -0
- package/shared/realtime-models/stepfun.mjs +10 -0
- package/shared/realtime-models/volcengine.mjs +12 -0
- package/shared/realtime-provider-catalog.mjs +23 -11
- package/shared/realtime-provider-definitions.mjs +168 -235
- package/shared/runtime-environment.mjs +23 -30
- package/shared/skill-library.mjs +49 -13
- package/shared/web-search-configuration.mjs +25 -2
- package/tui/package.json +2 -2
- package/tui/src/index.mjs +14 -9
- package/tui/src/runtime-configuration.mjs +2 -0
- package/tui/src/terminal-commands.mjs +40 -0
- package/tui/src/text-cli.mjs +10 -1
- package/web/dist/assets/index-Bc2Q04J9.css +1 -0
- package/web/dist/assets/index-bY4DFXKT.js +96 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-BRaiI-dW.js +0 -91
- package/web/dist/assets/index-D9k8R2JY.css +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Temporary, development-only bridge until node-gyp adopts tar 8's input API.
|
|
2
|
+
// Keep the original pipeline (including its checksum transform) intact. Only
|
|
3
|
+
// its final sink changes from a Writable to an async consumer. No archive
|
|
4
|
+
// validation or download/checksum policy is disabled.
|
|
5
|
+
import { createHash } from 'node:crypto'
|
|
6
|
+
import { readFileSync, realpathSync, writeFileSync } from 'node:fs'
|
|
7
|
+
import { createRequire } from 'node:module'
|
|
8
|
+
import { dirname, join, relative, isAbsolute, sep } from 'node:path'
|
|
9
|
+
|
|
10
|
+
const ORIGINAL_SHA256 = 'f0a0017fec48692a8eb8922b6eaff8d12f4a4eb1af4e42f23efa3e8797dff2c3'
|
|
11
|
+
const digest = text => createHash('sha256').update(text).digest('hex')
|
|
12
|
+
const originalSink = ` tar.extract({
|
|
13
|
+
strip: 1,
|
|
14
|
+
cwd: tarExtractDir,
|
|
15
|
+
filter: isValid,
|
|
16
|
+
onwarn
|
|
17
|
+
})`
|
|
18
|
+
const patchedSink = ` async source => {
|
|
19
|
+
const iterator = source[Symbol.asyncIterator]()
|
|
20
|
+
// tar may stop at end-of-archive; hash the entire download.
|
|
21
|
+
await tar.extract({
|
|
22
|
+
input: { [Symbol.asyncIterator]: () => ({ next: () => iterator.next() }) },
|
|
23
|
+
strip: 1,
|
|
24
|
+
cwd: tarExtractDir,
|
|
25
|
+
filter: isValid,
|
|
26
|
+
onwarn
|
|
27
|
+
})
|
|
28
|
+
while (!(await iterator.next()).done) {}
|
|
29
|
+
}`
|
|
30
|
+
|
|
31
|
+
export function patchBuildNodeGyp(root) {
|
|
32
|
+
const require = createRequire(join(root, 'package.json'))
|
|
33
|
+
let builderPath
|
|
34
|
+
try { builderPath = require.resolve('app-builder-lib/package.json') } catch (error) {
|
|
35
|
+
// Published/production-only installs do not contain this build dependency.
|
|
36
|
+
if (error.code === 'MODULE_NOT_FOUND') return false
|
|
37
|
+
throw error
|
|
38
|
+
}
|
|
39
|
+
const builderRequire = createRequire(builderPath)
|
|
40
|
+
const rebuildRequire = createRequire(builderRequire.resolve('@electron/rebuild'))
|
|
41
|
+
const manifestPath = rebuildRequire.resolve('node-gyp/package.json')
|
|
42
|
+
const nodeGypRequire = createRequire(manifestPath)
|
|
43
|
+
const nodeGyp = nodeGypRequire('./package.json')
|
|
44
|
+
const tar = nodeGypRequire('tar/package.json')
|
|
45
|
+
if (nodeGyp.version !== '12.4.0' || tar.version !== '8.0.5') {
|
|
46
|
+
throw new Error('Build archive dependencies changed; review/remove the temporary node-gyp tar 8 patch before building.')
|
|
47
|
+
}
|
|
48
|
+
const path = realpathSync(join(dirname(manifestPath), 'lib/install.js'))
|
|
49
|
+
const within = relative(realpathSync(root), path)
|
|
50
|
+
if (within === '..' || within.startsWith(`..${sep}`) || isAbsolute(within)) {
|
|
51
|
+
throw new Error('Refusing to patch a build dependency outside this checkout.')
|
|
52
|
+
}
|
|
53
|
+
const source = readFileSync(path, 'utf8')
|
|
54
|
+
// Reverse only this exact patch to recognize an already prepared install.
|
|
55
|
+
if (source.includes(patchedSink) && digest(source.replace(patchedSink, originalSink)) === ORIGINAL_SHA256) return false
|
|
56
|
+
if (digest(source) !== ORIGINAL_SHA256) {
|
|
57
|
+
throw new Error('Unexpected node-gyp install.js; refusing to patch unreviewed source.')
|
|
58
|
+
}
|
|
59
|
+
const patched = source.replace(originalSink, patchedSink)
|
|
60
|
+
if (patched === source) throw new Error('Build archive patch verification failed.')
|
|
61
|
+
writeFileSync(path, patched)
|
|
62
|
+
return true
|
|
63
|
+
}
|
|
@@ -9,6 +9,7 @@ import { spawnSync } from 'node:child_process'
|
|
|
9
9
|
import { existsSync } from 'node:fs'
|
|
10
10
|
import { dirname, resolve } from 'node:path'
|
|
11
11
|
import { fileURLToPath } from 'node:url'
|
|
12
|
+
import { patchBuildNodeGyp } from './patch-build-node-gyp.mjs'
|
|
12
13
|
|
|
13
14
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
14
15
|
|
|
@@ -35,4 +36,5 @@ function run(args) {
|
|
|
35
36
|
if (!existsSync(resolve(root, 'node_modules/.bin/vite'))) {
|
|
36
37
|
run(['install', '--no-save', '--no-audit', '--include=dev'])
|
|
37
38
|
}
|
|
39
|
+
patchBuildNodeGyp(root)
|
|
38
40
|
run(['run', 'build'])
|
package/scripts/release-check
CHANGED
|
@@ -82,7 +82,7 @@ for (const [launcher, packageName] of [
|
|
|
82
82
|
['opencode', 'opencode-ai'],
|
|
83
83
|
['openclaw', 'openclaw'],
|
|
84
84
|
['codex-acp', '@agentclientprotocol/codex-acp'],
|
|
85
|
-
['claude-code-acp', '@
|
|
85
|
+
['claude-code-acp', '@agentclientprotocol/claude-agent-acp'],
|
|
86
86
|
['pi-acp', 'pi-acp'],
|
|
87
87
|
]) {
|
|
88
88
|
if (!readFileSync(`scripts/runtime/${launcher}.mjs`, 'utf8').includes(`${packageName}@latest`)) {
|
|
@@ -90,7 +90,7 @@ for (const [launcher, packageName] of [
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
if (
|
|
93
|
-
manifest.devDependencies?.['electron-builder'] !== '26.
|
|
93
|
+
manifest.devDependencies?.['electron-builder'] !== '26.17.0'
|
|
94
94
|
|| manifest.overrides?.['@electron/asar'] !== '4.2.1'
|
|
95
95
|
|| manifest.overrides?.['@electron/universal'] !== '3.0.6'
|
|
96
96
|
) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { spawnAndProxy, commandAvailable, findExecutable } from './launcher.mjs'
|
|
4
4
|
|
|
5
5
|
const RUNTIME = process.env.CLAUDE_CODE_ACP_RUNTIME || 'auto'
|
|
6
|
-
const PKG = process.env.CLAUDE_CODE_ACP_PACKAGE || '@
|
|
6
|
+
const PKG = process.env.CLAUDE_CODE_ACP_PACKAGE || '@agentclientprotocol/claude-agent-acp@latest'
|
|
7
7
|
const DESKTOP_INSTALLED_ONLY = process.env.QWEN_AUDIO_AGENT_DESKTOP_INSTALLED_ONLY
|
|
8
8
|
const ARGS = process.argv.slice(2)
|
|
9
9
|
|
|
@@ -24,13 +24,13 @@ if (!process.env.CLAUDE_CODE_EXECUTABLE) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async function runBinary() {
|
|
27
|
-
const bin = process.env.CLAUDE_CODE_ACP_BIN || 'claude-
|
|
27
|
+
const bin = process.env.CLAUDE_CODE_ACP_BIN || 'claude-agent-acp'
|
|
28
28
|
await spawnAndProxy(bin, ARGS)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
async function runPackage() {
|
|
32
32
|
if (DESKTOP_INSTALLED_ONLY === '1') {
|
|
33
|
-
fatal('claude-
|
|
33
|
+
fatal('claude-agent-acp is not installed. Install it before selecting Claude Code.')
|
|
34
34
|
}
|
|
35
35
|
if (!commandAvailable('npx')) fatal('Claude Code ACP package mode requires npx.')
|
|
36
36
|
await spawnAndProxy('npx', ['-y', PKG, ...ARGS])
|
|
@@ -42,8 +42,8 @@ switch (RUNTIME) {
|
|
|
42
42
|
case 'auto':
|
|
43
43
|
if (process.env.CLAUDE_CODE_ACP_BIN) {
|
|
44
44
|
await runBinary()
|
|
45
|
-
} else if (commandAvailable('claude-
|
|
46
|
-
await spawnAndProxy('claude-
|
|
45
|
+
} else if (commandAvailable('claude-agent-acp')) {
|
|
46
|
+
await spawnAndProxy('claude-agent-acp', ARGS)
|
|
47
47
|
} else {
|
|
48
48
|
await runPackage()
|
|
49
49
|
}
|
|
@@ -192,6 +192,9 @@ if (isMain) {
|
|
|
192
192
|
'server/src/backend/backend-adapter-sdk.mjs',
|
|
193
193
|
'server/src/backend/backend-adapter-conformance.mjs',
|
|
194
194
|
'server/src/core/package-version.mjs',
|
|
195
|
+
'config/frontend-agent/PROMPT.md',
|
|
196
|
+
'config/frontend-agent/LIVE_PROMPT.md',
|
|
197
|
+
'config/frontend-agent/ASSISTANT.md',
|
|
195
198
|
'server/src/index.mjs',
|
|
196
199
|
'shared/runtime-environment.mjs',
|
|
197
200
|
'tui/src/index.mjs',
|
package/server/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qwen-audio-agent/server",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "node --watch src/index.mjs",
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
"test": "node --test"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@agentclientprotocol/sdk": "1.
|
|
13
|
-
"@modelcontextprotocol/sdk": "1.
|
|
12
|
+
"@agentclientprotocol/sdk": "1.8.0",
|
|
13
|
+
"@modelcontextprotocol/sdk": "1.32.1",
|
|
14
14
|
"@qwen-code/open-computer-use": "^0.2.3",
|
|
15
15
|
"express": "^4.22.2",
|
|
16
|
-
"ws": "^8.
|
|
17
|
-
"yaml": "2.9.
|
|
16
|
+
"ws": "^8.23.1",
|
|
17
|
+
"yaml": "2.9.1",
|
|
18
18
|
"zod": "^4.5.4"
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -127,6 +127,9 @@ const taskOperations = new TaskOperations({
|
|
|
127
127
|
taskManager,
|
|
128
128
|
backendRuntime: workBackend,
|
|
129
129
|
permissionPolicy,
|
|
130
|
+
conversationSnapshot: ({ ownerId, sessionId = 'main', turnId }) => conversationSync.coordinatorSnapshot({
|
|
131
|
+
ownerId, sessionId, excludeTurnId: turnId,
|
|
132
|
+
}),
|
|
130
133
|
respondAuthorization,
|
|
131
134
|
respondInput: (taskId, id, response, options) => agent.respondInput(taskId, id, response, options),
|
|
132
135
|
})
|
|
@@ -265,6 +265,9 @@ export function registerGatewayHttpRoutes(app, {
|
|
|
265
265
|
error: null,
|
|
266
266
|
},
|
|
267
267
|
inputSuspension: inputArbitration.status(),
|
|
268
|
+
voiceInput: getGateway()?.inputStatus?.({
|
|
269
|
+
ownerId: req.identity.access === 'local' ? undefined : req.identity.ownerId,
|
|
270
|
+
}) || { inputEnabled: null, inputActive: false, clients: [] },
|
|
268
271
|
voiceConfigured: realtime.configured,
|
|
269
272
|
realtimeProvider: realtime.provider,
|
|
270
273
|
realtimeLabel: realtime.label,
|
|
@@ -45,7 +45,14 @@ export class SessionConversationHistory {
|
|
|
45
45
|
const messages = projectFrontendConversation(replay.messages, {
|
|
46
46
|
limit: this.limit,
|
|
47
47
|
})
|
|
48
|
-
|
|
48
|
+
// Projection may omit the newest internal result. Preserve the full
|
|
49
|
+
// journal watermark without restoring its hidden conversation content.
|
|
50
|
+
const historyPosition = replay.messages.reduce((latest, message) => (
|
|
51
|
+
Number.isSafeInteger(message.historyPosition)
|
|
52
|
+
? Math.max(latest, message.historyPosition)
|
|
53
|
+
: latest
|
|
54
|
+
), 0)
|
|
55
|
+
this.conversationSync.restore?.({ ownerId, sessionId, messages, historyPosition })
|
|
49
56
|
restored += messages.length
|
|
50
57
|
} catch (error) {
|
|
51
58
|
this.logger?.warn('conversation_history.restore_failed', {
|
|
@@ -69,6 +76,7 @@ export class SessionConversationHistory {
|
|
|
69
76
|
source: message.source || 'conversation-sync',
|
|
70
77
|
payload: {
|
|
71
78
|
messageId: message.id,
|
|
79
|
+
historyPosition: message.historyPosition,
|
|
72
80
|
content: message.content,
|
|
73
81
|
inputs: message.inputs || [],
|
|
74
82
|
taskIds: message.taskIds || [],
|
|
@@ -54,6 +54,14 @@ function bounded(value, max = 4_000) {
|
|
|
54
54
|
return clean(value).slice(0, max)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
function inputResponseStatus(action) {
|
|
58
|
+
return {
|
|
59
|
+
accept: InputRequestStatus.ACCEPTED,
|
|
60
|
+
decline: InputRequestStatus.DECLINED,
|
|
61
|
+
cancel: InputRequestStatus.CANCELLED,
|
|
62
|
+
}[action] || InputRequestStatus.ANSWERED
|
|
63
|
+
}
|
|
64
|
+
|
|
57
65
|
function positiveNumber(value, fallback, minimum) {
|
|
58
66
|
const number = Number(value)
|
|
59
67
|
return Number.isFinite(number) && number >= minimum ? number : fallback
|
|
@@ -839,11 +847,7 @@ export class A2ABackendAdapter {
|
|
|
839
847
|
} finally {
|
|
840
848
|
clearTimeout(expiryTimer)
|
|
841
849
|
}
|
|
842
|
-
const resolved = resolveInputRequest(request, answer.action
|
|
843
|
-
? InputRequestStatus.ACCEPTED
|
|
844
|
-
: answer.action === 'decline'
|
|
845
|
-
? InputRequestStatus.DECLINED
|
|
846
|
-
: InputRequestStatus.CANCELLED)
|
|
850
|
+
const resolved = resolveInputRequest(request, inputResponseStatus(answer.action))
|
|
847
851
|
record.pendingInput = null
|
|
848
852
|
this.publish(backendEvent(BackendEventType.INPUT_RESOLVED, {
|
|
849
853
|
input: resolved,
|
|
@@ -852,14 +856,17 @@ export class A2ABackendAdapter {
|
|
|
852
856
|
await this.bestEffortCancel(record)
|
|
853
857
|
throw cancellationError(record.gatewayTaskId)
|
|
854
858
|
}
|
|
855
|
-
const text = answer.
|
|
856
|
-
?
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
? JSON.stringify(answer.values)
|
|
860
|
-
: '用户已确认,请继续处理。')
|
|
859
|
+
const text = clean(answer.text)
|
|
860
|
+
|| (answer.values && Object.keys(answer.values).length ? JSON.stringify(answer.values) : '')
|
|
861
|
+
|| (answer.action === 'decline' ? '用户拒绝提供所请求的信息。' : '')
|
|
862
|
+
|| (answer.action === 'accept' ? '用户已确认,请继续处理。' : '')
|
|
861
863
|
const result = await record.client.sendMessage({
|
|
862
|
-
message: continuationMessage(text, task, {
|
|
864
|
+
message: continuationMessage(text, task, {
|
|
865
|
+
kind,
|
|
866
|
+
// Only explicit client decisions carry an action. Natural-language
|
|
867
|
+
// replies are interpreted by the remote agent, never auto-approved.
|
|
868
|
+
...(answer.action ? { action: answer.action } : {}),
|
|
869
|
+
}),
|
|
863
870
|
configuration: {
|
|
864
871
|
acceptedOutputModes: this.acceptedOutputModes,
|
|
865
872
|
historyLength: 20,
|
|
@@ -1171,28 +1178,27 @@ export class A2ABackendAdapter {
|
|
|
1171
1178
|
code: 'INPUT_ALREADY_SUBMITTED',
|
|
1172
1179
|
})
|
|
1173
1180
|
}
|
|
1174
|
-
if (
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1181
|
+
if (response.action !== undefined && !['accept', 'decline', 'cancel'].includes(response.action)) {
|
|
1182
|
+
throw new A2ABackendError('Input action must be accept, decline, or cancel when provided', {
|
|
1183
|
+
code: 'INVALID_INPUT_ACTION',
|
|
1184
|
+
})
|
|
1185
|
+
}
|
|
1186
|
+
const { action, values } = response
|
|
1187
|
+
const text = clean(response.text)
|
|
1188
|
+
if (!action && !text && !(values && Object.keys(values).length)) {
|
|
1189
|
+
throw new A2ABackendError('Input response requires text or form values', {
|
|
1190
|
+
code: 'INPUT_RESPONSE_REQUIRED',
|
|
1178
1191
|
})
|
|
1179
1192
|
}
|
|
1180
|
-
const action = ['accept', 'decline', 'cancel'].includes(response.action)
|
|
1181
|
-
? response.action
|
|
1182
|
-
: 'accept'
|
|
1183
1193
|
record.pendingInput.settled = true
|
|
1184
1194
|
record.pendingInput.pending.resolve({
|
|
1185
1195
|
action,
|
|
1186
|
-
text
|
|
1187
|
-
values
|
|
1196
|
+
text,
|
|
1197
|
+
values,
|
|
1188
1198
|
})
|
|
1189
1199
|
return resolveInputRequest(
|
|
1190
1200
|
record.pendingInput.input,
|
|
1191
|
-
action
|
|
1192
|
-
? InputRequestStatus.ACCEPTED
|
|
1193
|
-
: action === 'decline'
|
|
1194
|
-
? InputRequestStatus.DECLINED
|
|
1195
|
-
: InputRequestStatus.CANCELLED,
|
|
1201
|
+
inputResponseStatus(action),
|
|
1196
1202
|
)
|
|
1197
1203
|
}
|
|
1198
1204
|
|