@xmanrui/dsh-im 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmanrui/dsh-im",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "通过扫码或机器人凭据把IM机器人接入DeepSeek Harness(支持飞书、微信、钉钉、企业微信、QQ、Telegram和Discord)。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  "access": "public"
15
15
  },
16
16
  "bin": {
17
- "dsh-im": "./bin/dsh-im.mjs"
17
+ "dsh-im": "bin/dsh-im.mjs"
18
18
  },
19
19
  "main": "./lib/index.js",
20
20
  "exports": {
@@ -57,7 +57,6 @@
57
57
  "node": ">=22.19"
58
58
  },
59
59
  "dependencies": {
60
- "@larksuiteoapi/node-sdk": "1.73.0",
61
60
  "@tencent-connect/qqbot-connector": "1.2.0",
62
61
  "@tencent-connect/qqbot-nodejs": "1.0.4",
63
62
  "@wecom/aibot-node-sdk": "1.0.7",
@@ -65,6 +64,7 @@
65
64
  "qrcode": "1.5.4"
66
65
  },
67
66
  "devDependencies": {
67
+ "@larksuiteoapi/node-sdk": "1.73.0",
68
68
  "esbuild": "0.25.9",
69
69
  "react": "18.3.1",
70
70
  "react-dom": "18.3.1",
@@ -7,6 +7,14 @@ import { build } from 'esbuild';
7
7
  const sourceDirectory = dirname(fileURLToPath(import.meta.url));
8
8
  const packageRoot = resolve(sourceDirectory, '../..');
9
9
  const outputPath = resolve(packageRoot, 'lib/index.js');
10
+ const externalRuntimePackages = [
11
+ '@tencent-connect/qqbot-connector',
12
+ '@tencent-connect/qqbot-nodejs',
13
+ '@wecom/aibot-node-sdk',
14
+ 'dingtalk-stream',
15
+ 'qrcode',
16
+ ];
17
+ const external = externalRuntimePackages.flatMap((name) => [name, `${name}/*`]);
10
18
 
11
19
  await mkdir(dirname(outputPath), { recursive: true });
12
20
  await build({
@@ -15,10 +23,22 @@ await build({
15
23
  format: 'esm',
16
24
  platform: 'node',
17
25
  target: ['node22'],
18
- packages: 'external',
26
+ mainFields: ['module', 'main'],
27
+ external,
19
28
  outfile: outputPath,
29
+ banner: {
30
+ js: [
31
+ "import { createRequire as __dshCreateRequire } from 'node:module';",
32
+ "import { dirname as __dshDirname } from 'node:path';",
33
+ "import { fileURLToPath as __dshFileURLToPath } from 'node:url';",
34
+ 'const require = __dshCreateRequire(import.meta.url);',
35
+ 'const __filename = __dshFileURLToPath(import.meta.url);',
36
+ 'const __dirname = __dshDirname(__filename);',
37
+ ].join('\n'),
38
+ },
20
39
  sourcemap: false,
21
- legalComments: 'none',
40
+ minify: true,
41
+ legalComments: 'eof',
22
42
  });
23
43
 
24
44
  console.log(`Wrote ${outputPath}`);
@@ -1,5 +1,6 @@
1
1
  import { access, readFile, stat } from 'node:fs/promises';
2
2
  import { resolve } from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
3
4
 
4
5
  const root = resolve(import.meta.dirname, '..');
5
6
  const required = [
@@ -38,6 +39,7 @@ const [client, host, patch, manifestText, lockText, hostSource, clientSource, ex
38
39
  stat(resolve(root, 'bin/dsh-im.mjs')),
39
40
  ]);
40
41
  const manifest = JSON.parse(manifestText);
42
+ const lock = JSON.parse(lockText);
41
43
 
42
44
  if (!client.includes('id: "@xmanrui/dsh-im"')) {
43
45
  throw new Error('client bundle does not register the dsh-im loader id');
@@ -77,7 +79,6 @@ for (const name of ['@xmanrui/dsh-feishu', '@xmanrui/dsh-weixin', '@xmanrui/dsh-
77
79
  }
78
80
  }
79
81
  const directDependencies = {
80
- '@larksuiteoapi/node-sdk': '1.73.0',
81
82
  'dingtalk-stream': '2.1.4',
82
83
  '@tencent-connect/qqbot-connector': '1.2.0',
83
84
  '@tencent-connect/qqbot-nodejs': '1.0.4',
@@ -89,9 +90,30 @@ for (const [name, version] of Object.entries(directDependencies)) {
89
90
  throw new Error(`${name} must be a pinned direct dependency at ${version}`);
90
91
  }
91
92
  }
93
+ const bundledBuildDependencies = {
94
+ '@larksuiteoapi/node-sdk': '1.73.0',
95
+ };
96
+ for (const [name, version] of Object.entries(bundledBuildDependencies)) {
97
+ if (manifest.dependencies?.[name] !== undefined) {
98
+ throw new Error(`${name} must not remain a runtime dependency`);
99
+ }
100
+ if (manifest.devDependencies?.[name] !== version) {
101
+ throw new Error(`${name} must be a pinned build dependency at ${version}`);
102
+ }
103
+ }
104
+ if (lock.packages?.['node_modules/protobufjs']?.dev !== true) {
105
+ throw new Error('protobufjs must remain build-only in the package lock');
106
+ }
107
+ if (manifest.bin?.['dsh-im'] !== 'bin/dsh-im.mjs') {
108
+ throw new Error('package manifest must publish the dsh-im executable');
109
+ }
110
+ if (/(?:from\s*|import\s*\(|require\s*\()\s*["'](?:@larksuiteoapi\/node-sdk|protobufjs)(?:\/[^"']*)?["']/.test(host)) {
111
+ throw new Error('host bundle must not import the Feishu SDK or protobufjs at runtime');
112
+ }
92
113
  if ((executable.mode & 0o111) === 0) throw new Error('dsh-im CLI is not executable');
93
114
  if (/private-bot-token|must-be-rolled-back|DEEPSEEK_API_KEY=/.test(client + host)) {
94
115
  throw new Error('built artifacts contain a test or environment secret marker');
95
116
  }
117
+ await import(pathToFileURL(resolve(root, 'lib/index.js')).href);
96
118
 
97
119
  console.log('Verified dsh-im package artifacts.');
@@ -108,7 +108,7 @@ export class DiscordApi {
108
108
  headers: {
109
109
  authorization: `Bot ${this.#token}`,
110
110
  'content-type': 'application/json',
111
- 'user-agent': 'DeepSeek-Harness-dsh-im (https://github.com/xmanrui/dsh-im, 0.1.0)',
111
+ 'user-agent': 'DeepSeek-Harness-dsh-im (https://github.com/xmanrui/dsh-im, 0.1.1)',
112
112
  },
113
113
  ...(body === undefined ? {} : { body: JSON.stringify(body) }),
114
114
  signal: requestSignal(signal, timeoutMs),
@@ -92,7 +92,7 @@ function authenticatedHeaders(token) {
92
92
  function baseInfo() {
93
93
  return {
94
94
  channel_version: WEIXIN_PROTOCOL_VERSION,
95
- bot_agent: 'DeepSeekHarness/0.1.0',
95
+ bot_agent: 'DeepSeekHarness/0.1.1',
96
96
  };
97
97
  }
98
98