agent-bridge-qwenwork 1.0.2 → 1.0.3

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.
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveRuntimePort = resolveRuntimePort;
4
+ function resolveRuntimePort(config, runtime, pluginId, envName, fallback) {
5
+ const injected = runtime?.ports?.[pluginId];
6
+ if (typeof injected === "number" && Number.isInteger(injected) && injected > 0)
7
+ return injected;
8
+ const configured = config.cdpPort;
9
+ if (typeof configured === "number" && Number.isInteger(configured) && configured > 0)
10
+ return configured;
11
+ const environment = Number(process.env[envName] ?? "");
12
+ return Number.isInteger(environment) && environment > 0 ? environment : fallback;
13
+ }
@@ -27,7 +27,7 @@ class QwenCdpClient {
27
27
  options;
28
28
  constructor(options = {}) {
29
29
  this.options = {
30
- port: options.port ?? Number(process.env.QWEN_CDP_PORT ?? "9226"),
30
+ port: options.port ?? Number(process.env.QWEN_CDP_PORT ?? "9228"),
31
31
  subChatId: options.subChatId ?? process.env.QWEN_SUBCHAT ?? "muj55ep9426gudjw",
32
32
  chatId: options.chatId ?? process.env.QWEN_CHAT ?? "muj55ep9u6wbv0eo",
33
33
  workspace: options.workspace ?? `${process.env.APPDATA ?? ""}\\QwenWorkCN\\workspace`,
@@ -40,7 +40,14 @@ class QwenCdpClient {
40
40
  if (this.socket)
41
41
  return;
42
42
  const fetchImpl = this.options.fetchImpl ?? fetch;
43
- const response = await fetchImpl(`http://127.0.0.1:${this.options.port}/json`);
43
+ let response;
44
+ try {
45
+ response = await fetchImpl(`http://127.0.0.1:${this.options.port}/json`);
46
+ }
47
+ catch (error) {
48
+ const code = error?.cause?.code ?? String(error);
49
+ throw new Error(`无法连接千问办公 CDP 端口 ${this.options.port}(请先以 --remote-debugging-port=${this.options.port} 启动千问办公客户端): ${code}`);
50
+ }
44
51
  if (!response.ok)
45
52
  throw new Error(`CDP /json HTTP ${response.status}`);
46
53
  const targets = await response.json();
@@ -4,16 +4,17 @@ exports.QwenworkPlugin = exports.qwenworkManifest = void 0;
4
4
  exports.createQwenworkPlugin = createQwenworkPlugin;
5
5
  const openai_adapter_1 = require("./openai-adapter");
6
6
  const cdp_client_1 = require("./cdp-client");
7
+ const plugin_1 = require("../../plugin");
7
8
  exports.qwenworkManifest = {
8
9
  id: "qwenwork",
9
- version: "1.0.2",
10
+ version: "1.0.3",
10
11
  displayName: "千问办公",
11
12
  entry: "dist/index.js",
12
13
  apiVersion: "1",
13
14
  process: "in-process",
14
15
  capabilities: ["chat", "openai-compatible", "health"],
15
16
  configSchema: "config.schema.json",
16
- defaults: { cdpPort: 9226, httpPort: 17893 },
17
+ defaults: { cdpPort: 9228, httpPort: 17893 },
17
18
  };
18
19
  function asNumber(value, fallback) {
19
20
  return typeof value === "number" && Number.isFinite(value) ? value : fallback;
@@ -53,7 +54,7 @@ class QwenworkPlugin {
53
54
  this.relayTarget = relayTarget === "dsh" ? relayTarget : undefined;
54
55
  this.callPlugin = context.callPlugin;
55
56
  this.pluginStatus = context.pluginStatus;
56
- this.activeCdpPort = asNumber(config.cdpPort, this.configuredCdpPort ?? exports.qwenworkManifest.defaults.cdpPort);
57
+ this.activeCdpPort = (0, plugin_1.resolveRuntimePort)(config, context.runtime, "qwenwork", "QWEN_CDP_PORT", this.configuredCdpPort ?? exports.qwenworkManifest.defaults.cdpPort);
57
58
  if (!this.relayTarget) {
58
59
  const client = this.injectedClient ?? new cdp_client_1.QwenCdpClient({
59
60
  port: this.activeCdpPort,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-bridge-qwenwork",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "agent-bridge 的千问办公插件。",
5
5
  "keywords": [
6
6
  "mu-agent-bridge-plugin",
package/plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "qwenwork",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "type": "agent",
5
5
  "displayName": "千问办公",
6
6
  "entry": "dist/src-ts/plugins/qwenwork/index.js",
@@ -11,5 +11,6 @@
11
11
  "openai-compatible",
12
12
  "health"
13
13
  ],
14
- "configSchema": "config.schema.json"
14
+ "configSchema": "config.schema.json",
15
+ "clientDownloadUrl": "https://tongyi.aliyun.com/"
15
16
  }