@baishuyun/chat-backend 0.0.20 → 0.0.22

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @baishuyun/chat-backend
2
2
 
3
+ ## 0.0.22
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @baishuyun/coze-provider@1.0.2
9
+ - @baishuyun/agents@1.0.2
10
+ - @baishuyun/types@2.0.2
11
+
12
+ ## 0.0.21
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+ - @baishuyun/coze-provider@1.0.1
18
+ - @baishuyun/agents@1.0.1
19
+ - @baishuyun/types@2.0.1
20
+
3
21
  ## 0.0.20
4
22
 
5
23
  ### Patch Changes
package/config/default.ts CHANGED
@@ -40,6 +40,13 @@ export default {
40
40
  apiKey: process.env.BOT_API_KEY, // load from env
41
41
  ocrApiKey: process.env.OCR_API_KEY || '', // load from env
42
42
  },
43
+
44
+ batchFill: {
45
+ botId: process.env.BATCH_FILL_BOT_ID || '7638918862875918336',
46
+ baseUrl: `https://${process.env.AGENT_HOST}/v3/`,
47
+ apiKey: process.env.BOT_API_KEY, // load from env
48
+ ocrApiKey: process.env.OCR_API_KEY || '', // load from env
49
+ },
43
50
  },
44
51
 
45
52
  report: {
@@ -87,7 +87,7 @@ export const createBatchFillingResultTransformer = (enableJsonParser) => {
87
87
  }
88
88
  // logger.debug(`onValue: ${JSON.stringify(value, null, 2)}`);
89
89
  enqueueTextDelta(`${JSON.stringify(value)},`, {
90
- type: 'mcp-fields-json',
90
+ type: 'batch-filling-fields-json',
91
91
  field: value,
92
92
  }, id, true);
93
93
  };
@@ -87,7 +87,7 @@ export const createFieldsFillingResultTransformer = (enableJsonParser) => {
87
87
  const subFormField = getLastSubFormField(parsedInfo);
88
88
  if (subFormField) {
89
89
  enqueueTextDelta(JSON.stringify(value), {
90
- type: 'mcp-fields-json',
90
+ type: 'filling-fields-json',
91
91
  field: subFormField.value,
92
92
  });
93
93
  return;
@@ -96,7 +96,7 @@ export const createFieldsFillingResultTransformer = (enableJsonParser) => {
96
96
  return;
97
97
  }
98
98
  enqueueTextDelta(JSON.stringify(value), {
99
- type: 'mcp-fields-json',
99
+ type: 'filling-fields-json',
100
100
  field: value,
101
101
  }, id);
102
102
  };
@@ -14,6 +14,8 @@ export const botRouter = () => {
14
14
  [FORM_BUILDER_BOT_ID, buildForm],
15
15
  [FORM_FILLER_BOT_ID, fillForm],
16
16
  [REPORT_QUERY_BOT_ID, queryReport],
17
+ // TODO: 替换成配置的 BOT ID,暂时使用旧的填报 BOT ID 以免影响线上
18
+ ['7598079547136802816', fillForm],
17
19
  ]);
18
20
  return createMiddleware(async (c, next) => {
19
21
  const botId = c.req.header('X-Bot-Id') || '';
@@ -2,7 +2,12 @@ import { createMiddleware } from 'hono/factory';
2
2
  import { tokenCache } from '../config/cache.config.js';
3
3
  import { fetchCozeInfo } from '../services/fetchCozeInfo.js';
4
4
  import { logger } from '../logger/index.js';
5
+ const isProd = process.env.NODE_ENV === 'production';
5
6
  export const tokenExchange = () => createMiddleware(async (c, next) => {
7
+ if (!isProd) {
8
+ await next();
9
+ return;
10
+ }
6
11
  const userAuth = c.req.header('X-Bs-Team-Id') || c.req.query('x-bs-team-id') || '';
7
12
  if (!userAuth) {
8
13
  return c.json({ error: 'Unauthorized' }, 401);
@@ -4,6 +4,6 @@ import { tokenExchange } from '../../middleware/tokenExchange.js';
4
4
  import { botRouter } from '../../middleware/botRouter.js';
5
5
  export const createCommonRouter = () => {
6
6
  const commonRouter = new Hono();
7
- commonRouter.post('/connect', /*tokenExchange(),*/ botRouter(), connectToAgent);
7
+ commonRouter.post('/connect', tokenExchange(), botRouter(), connectToAgent);
8
8
  return commonRouter;
9
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baishuyun/chat-backend",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,9 +24,9 @@
24
24
  "pino": "^10.1.0",
25
25
  "ws": "^8.18.0",
26
26
  "zod": "^4.1.13",
27
- "@baishuyun/agents": "1.0.0",
28
- "@baishuyun/types": "2.0.0",
29
- "@baishuyun/coze-provider": "1.0.0"
27
+ "@baishuyun/coze-provider": "1.0.2",
28
+ "@baishuyun/types": "2.0.2",
29
+ "@baishuyun/agents": "1.0.2"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/config": "^3.3.5",
@@ -38,7 +38,7 @@
38
38
  "pm2": "^6.0.14",
39
39
  "tsx": "^4.7.1",
40
40
  "typescript": "^5.8.3",
41
- "@baishuyun/typescript-config": "1.0.0"
41
+ "@baishuyun/typescript-config": "1.0.2"
42
42
  },
43
43
  "scripts": {
44
44
  "dev": "cross-env NODE_ENV=development tsx watch src/index.ts",
@@ -41,7 +41,7 @@ const getModelMessagesFromUserMessages = ({
41
41
  mode2part(mode),
42
42
  {
43
43
  type: 'text',
44
- text: currentMsg,
44
+ text: `\n\n${currentMsg}\n\n`,
45
45
  },
46
46
  ],
47
47
  },
@@ -105,7 +105,8 @@ export const createBatchFillingResultTransformer = (enableJsonParser: boolean) =
105
105
  enqueueTextDelta(
106
106
  `${JSON.stringify(value)},`,
107
107
  {
108
- type: 'mcp-fields-json',
108
+ type: 'batch-filling-fields-json',
109
+ deprecatedType: 'mcp-fields-json',
109
110
  field: value,
110
111
  },
111
112
  id,
@@ -4,6 +4,7 @@ import { createTextInfoEnqueuer } from '@baishuyun/coze-provider';
4
4
  import { getLastSubFormField } from './utils.js';
5
5
  import { fillingChunkGuard as chunkGuard } from './utils.js';
6
6
  import { logger } from '../../../logger/index.js';
7
+ import type { deprecate } from 'node:util';
7
8
 
8
9
  export const createFieldsFillingResultTransformer = (enableJsonParser: boolean) => {
9
10
  let parser: JSONParser;
@@ -103,7 +104,8 @@ export const createFieldsFillingResultTransformer = (enableJsonParser: boolean)
103
104
  const subFormField = getLastSubFormField(parsedInfo);
104
105
  if (subFormField) {
105
106
  enqueueTextDelta(JSON.stringify(value), {
106
- type: 'mcp-fields-json',
107
+ type: 'filling-fields-json',
108
+ deprecatedType: 'mcp-fields-json',
107
109
  field: subFormField.value,
108
110
  });
109
111
 
@@ -117,7 +119,8 @@ export const createFieldsFillingResultTransformer = (enableJsonParser: boolean)
117
119
  enqueueTextDelta(
118
120
  JSON.stringify(value),
119
121
  {
120
- type: 'mcp-fields-json',
122
+ type: 'filling-fields-json',
123
+ deprecatedType: 'mcp-fields-json',
121
124
  field: value,
122
125
  },
123
126
  id
@@ -7,16 +7,19 @@ import { queryReport } from '../controllers/report/query/query.controller.js';
7
7
  import { createFakeUIMessageStreamResponse } from '../utils/createFakeUIMessageStreamResponse.js';
8
8
  import { ERROR_CODE } from '../const/error_code.js';
9
9
  import { logger } from '../logger/index.js';
10
+ import { batchFillForm } from '../controllers/form/fill/batch-fill.controller.js';
10
11
 
11
12
  export const botRouter = () => {
12
13
  const FORM_BUILDER_BOT_ID = config.get<string>('agent.form.build.botId');
13
14
  const FORM_FILLER_BOT_ID = config.get<string>('agent.form.fill.botId');
15
+ const BATCH_FILLER_BOT_ID = config.get<string>('agent.form.batchFill.botId');
14
16
  const REPORT_QUERY_BOT_ID = config.get<string>('agent.report.query.botId');
15
17
 
16
18
  const botIdControllerMap = new Map<string, (c: Context) => Promise<Response>>([
17
19
  [FORM_BUILDER_BOT_ID, buildForm],
18
20
  [FORM_FILLER_BOT_ID, fillForm],
19
21
  [REPORT_QUERY_BOT_ID, queryReport],
22
+ [BATCH_FILLER_BOT_ID, batchFillForm],
20
23
  ]);
21
24
 
22
25
  return createMiddleware(async (c, next) => {
@@ -3,8 +3,15 @@ import { tokenCache } from '../config/cache.config.js';
3
3
  import { fetchCozeInfo } from '../services/fetchCozeInfo.js';
4
4
  import { logger } from '../logger/index.js';
5
5
 
6
+ const isProd = process.env.NODE_ENV === 'production';
7
+
6
8
  export const tokenExchange = () =>
7
9
  createMiddleware(async (c, next) => {
10
+ if (!isProd) {
11
+ await next();
12
+ return;
13
+ }
14
+
8
15
  const userAuth = c.req.header('X-Bs-Team-Id') || c.req.query('x-bs-team-id') || '';
9
16
  if (!userAuth) {
10
17
  return c.json({ error: 'Unauthorized' }, 401);
@@ -6,7 +6,7 @@ import { botRouter } from '../../middleware/botRouter.js';
6
6
  export const createCommonRouter = () => {
7
7
  const commonRouter = new Hono();
8
8
 
9
- commonRouter.post('/connect', /*tokenExchange(),*/ botRouter(), connectToAgent);
9
+ commonRouter.post('/connect', tokenExchange(), botRouter(), connectToAgent);
10
10
 
11
11
  return commonRouter;
12
12
  };