@myassis/gateway 1.0.32 → 1.0.34

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.
@@ -47,8 +47,8 @@ const getEnvPath = () => {
47
47
  }
48
48
  // 2. pkg 环境:从 snapshot 虚拟路径读取打包的 .env
49
49
  if (process.pkg) {
50
- // __dirname 在 pkg 中指向 /snapshot/pocketclaw/gateway/dist/config
51
- // 打包的 .env 在 /snapshot/pocketclaw/gateway/dist/.env
50
+ // __dirname 在 pkg 中指向 /snapshot/myassis/gateway/dist/config
51
+ // 打包的 .env 在 /snapshot/myassis/gateway/dist/.env
52
52
  const snapshotEnvPath = path.resolve(__dirname, '..', '.env');
53
53
  if (fs.existsSync(snapshotEnvPath)) {
54
54
  return snapshotEnvPath;
@@ -26,11 +26,14 @@ class LLMClient {
26
26
  preferredModelId;
27
27
  signal;
28
28
  timeoutMs = 120000;
29
- constructor(models, messages, signal, tools) {
29
+ constructor(models, messages, signal, tools, timeoutMs) {
30
30
  this.models = models;
31
31
  this.messages = messages;
32
32
  this.tools = tools;
33
33
  this.signal = signal;
34
+ if (timeoutMs) {
35
+ this.timeoutMs = timeoutMs;
36
+ }
34
37
  }
35
38
  getActionName(params) {
36
39
  const args = parseAruments(params);
@@ -151,12 +154,18 @@ class LLMClient {
151
154
  return [{
152
155
  role: 'tool',
153
156
  tool_call_id: m.tool_call_id,
154
- content: JSON.stringify({
155
- success: contentObj.success,
156
- result_type: 'image',
157
- image_url: contentObj.output,
158
- text_for_llm: '工具生成了一张图片,图片地址已返回。'
159
- }),
157
+ content: '内容在user里面返回',
158
+ }, {
159
+ role: 'user',
160
+ content: [{
161
+ type: 'text',
162
+ text: '请识别这张屏幕截图,然后继续当前任务'
163
+ }, {
164
+ type: 'image_url',
165
+ image_url: {
166
+ url: `data:image/png;base64,${contentObj.output}`
167
+ }
168
+ }]
160
169
  }];
161
170
  }
162
171
  else {
@@ -209,7 +209,7 @@ ${conversation}
209
209
  }
210
210
  const summaryPrompt = this.buildSummaryPrompt(messages, lastSummary);
211
211
  const token = index_js_1.authStore.get(this.session.userId).accessToken;
212
- const llmClient = new LLMClient_js_1.LLMClient((await dataService_js_1.modelsService.list(token)).data.map((x) => (0, models_js_1.toModel)(x)), [{ role: 'user', content: summaryPrompt }], this.signal, []);
212
+ const llmClient = new LLMClient_js_1.LLMClient((await dataService_js_1.modelsService.list(token)).data.map((x) => (0, models_js_1.toModel)(x)), [{ role: 'user', content: summaryPrompt }], this.signal, [], 600000);
213
213
  const response = await llmClient.Chat();
214
214
  const content = (response.content || '').trim();
215
215
  if (!content) {
@@ -233,7 +233,7 @@ ${conversation}
233
233
  const batch = formattedMessages.slice(i, i + BATCH_SIZE);
234
234
  const batchPrompt = `请简洁总结以下对话片段的关键信息,特别关注:项目结构、关键决策、错误及修复。\n\n${batch.join('\n\n')}`;
235
235
  const token = index_js_1.authStore.get(this.session.userId).accessToken;
236
- const llmClient = new LLMClient_js_1.LLMClient((await dataService_js_1.modelsService.list(token)).data.map((x) => (0, models_js_1.toModel)(x)), [{ role: 'user', content: batchPrompt }], this.signal, []);
236
+ const llmClient = new LLMClient_js_1.LLMClient((await dataService_js_1.modelsService.list(token)).data.map((x) => (0, models_js_1.toModel)(x)), [{ role: 'user', content: batchPrompt }], this.signal, [], 600000);
237
237
  const response = await llmClient.Chat();
238
238
  const subContent = (response.content || '').trim();
239
239
  if (subContent) {
@@ -250,7 +250,7 @@ ${conversation}
250
250
  // 合并子摘要为最终摘要
251
251
  const mergePrompt = this.buildMergePrompt(subSummaries, lastSummary);
252
252
  const token = index_js_1.authStore.get(this.session.userId).accessToken;
253
- const mergeLlmClient = new LLMClient_js_1.LLMClient((await dataService_js_1.modelsService.list(token)).data.map((x) => (0, models_js_1.toModel)(x)), [{ role: 'user', content: mergePrompt }], this.signal, []);
253
+ const mergeLlmClient = new LLMClient_js_1.LLMClient((await dataService_js_1.modelsService.list(token)).data.map((x) => (0, models_js_1.toModel)(x)), [{ role: 'user', content: mergePrompt }], this.signal, [], 600000);
254
254
  const mergeResponse = await mergeLlmClient.Chat();
255
255
  const mergedContent = (mergeResponse.content || '').trim();
256
256
  return mergedContent || subSummaries.join('\n\n');
@@ -15,7 +15,7 @@ exports.screenshotTool = {
15
15
  const base64 = imgBuffer.toString('base64');
16
16
  return {
17
17
  success: true,
18
- output: `data:image/jpeg;base64,${base64}`,
18
+ output: `${base64}`,
19
19
  };
20
20
  }
21
21
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myassis/gateway",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "我的助手 Gateway Service - 本地 AI 网关服务,支持认证、WebSocket 实时通信和任务调度",
5
5
  "main": "dist/index.js",
6
6
  "bin": {