@myassis/gateway 1.0.60 → 1.0.62

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.
@@ -525,6 +525,12 @@ class LLMClient {
525
525
  // 系统模式 /api/v1/llm/invoke 返回格式
526
526
  if (data.success === true && data.data) {
527
527
  const d = data.data;
528
+ if (d.finish_reason === 'length' && !d.content) {
529
+ throw Error('exceed max message tokens');
530
+ }
531
+ if (d.finish_reason === 'stop' && !d.content) {
532
+ throw Error('model return empty content');
533
+ }
528
534
  const toolCalls = d.toolCalls?.map((tc) => ({
529
535
  id: tc.id || '',
530
536
  toolName: tc.function?.name || '',
@@ -537,18 +543,15 @@ class LLMClient {
537
543
  modelName: data.quota?.modelName || modelName,
538
544
  };
539
545
  }
540
- // Coze 格式
541
- if (data.type === 'conversation_message.completed' || data.message) {
542
- const messageData = data.message || {};
543
- return {
544
- content: messageData.content?.[0]?.text || '',
545
- reasoningContent: messageData.thinking || undefined,
546
- modelName
547
- };
548
- }
549
546
  // OpenAI/DeepSeek 格式
550
547
  if (data.choices?.[0]?.message) {
551
548
  const messageData = data.choices[0].message;
549
+ if (messageData.finish_reason === 'length' && !messageData.content) {
550
+ throw Error('exceed max message tokens');
551
+ }
552
+ if (messageData.finish_reason === 'stop' && !messageData.content) {
553
+ throw Error('model return empty content');
554
+ }
552
555
  return {
553
556
  content: messageData.content || '',
554
557
  reasoningContent: messageData.reasoning_content || undefined,
@@ -561,34 +564,6 @@ class LLMClient {
561
564
  modelName
562
565
  };
563
566
  }
564
- // Claude 格式
565
- if (data.content) {
566
- const toolCalls = [];
567
- let content = '';
568
- let reasoningContent = '';
569
- for (const block of data.content) {
570
- if (block.type === 'text') {
571
- content += block.text;
572
- }
573
- else if (block.type === 'thinking') {
574
- reasoningContent += block.thinking;
575
- }
576
- else if (block.type === 'tool_use') {
577
- toolCalls.push({
578
- id: block.id,
579
- toolName: block.name,
580
- input: typeof block.input === 'string' ? block.input : JSON.stringify(block.input),
581
- actionName: this.getActionName(typeof block.input === 'string' ? block.input : JSON.stringify(block.input))
582
- });
583
- }
584
- }
585
- return {
586
- content,
587
- reasoningContent: reasoningContent || undefined,
588
- toolCalls: toolCalls.length > 0 ? toolCalls : undefined,
589
- modelName
590
- };
591
- }
592
567
  return { content: '', modelName };
593
568
  }
594
569
  /**
@@ -82,17 +82,17 @@ class SessionStore {
82
82
  // ========== Session Operations ==========
83
83
  insertSession(session) {
84
84
  this.db.prepare(`
85
- INSERT INTO sessions (id, user_id, agent_id, title, select_model_id, voice_state, created_at, updated_at,last_message_summary,last_message_summary_at,unread_count,is_current,message_queue,message_queue_auto_execute)
86
- VALUES (?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?)
87
- `).run(session.id, session.userId, session.agentId || null, session.title, session.selectModelId || '', JSON.stringify(session.voiceState), session.createdAt, session.updatedAt, session.lastMessageSummary, session.lastMessageSummaryAt, session.unreadCount || 0, session.isCurrent ? 1 : 0, JSON.stringify(session.messageQueue || []), session.messageQueueAutoExecute === false ? 0 : 1);
85
+ INSERT INTO sessions (id, user_id, agent_id, title, select_model_id, voice_state, created_at, updated_at,last_message_summary,last_message_summary_at,unread_count,is_current,message_queue,message_queue_auto_execute, use_system_mode)
86
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?)
87
+ `).run(session.id, session.userId, session.agentId || null, session.title, session.selectModelId || '', JSON.stringify(session.voiceState), session.createdAt, session.updatedAt, session.lastMessageSummary, session.lastMessageSummaryAt, session.unreadCount || 0, session.isCurrent ? 1 : 0, JSON.stringify(session.messageQueue || []), session.messageQueueAutoExecute === false ? 0 : 1, session.useSystemMode ? 1 : 0);
88
88
  }
89
89
  updateSession(session) {
90
90
  this.db.prepare(`
91
91
  UPDATE sessions
92
92
  SET user_id = ?, agent_id = ?, title = ?, select_model_id = ?,
93
- voice_state = ?, updated_at = ?,last_message_summary=?,last_message_summary_at=?,unread_count=?,is_current=?,message_queue=?,message_queue_auto_execute=?
93
+ voice_state = ?, updated_at = ?,last_message_summary=?,last_message_summary_at=?,unread_count=?,is_current=?,message_queue=?,message_queue_auto_execute=?, use_system_mode=?
94
94
  WHERE id = ?
95
- `).run(session.userId, session.agentId || null, session.title, session.selectModelId || '', JSON.stringify(session.voiceState), session.updatedAt, session.lastMessageSummary, session.lastMessageSummaryAt, session.unreadCount || 0, session.isCurrent ? 1 : 0, JSON.stringify(session.messageQueue || []), session.messageQueueAutoExecute === false ? 0 : 1, session.id);
95
+ `).run(session.userId, session.agentId || null, session.title, session.selectModelId || '', JSON.stringify(session.voiceState), session.updatedAt, session.lastMessageSummary, session.lastMessageSummaryAt, session.unreadCount || 0, session.isCurrent ? 1 : 0, JSON.stringify(session.messageQueue || []), session.messageQueueAutoExecute === false ? 0 : 1, session.useSystemMode ? 1 : 0, session.id);
96
96
  }
97
97
  // 支持部分更新的 updateSession
98
98
  updateSessionPartial(id, data) {
@@ -187,6 +187,7 @@ class SessionStore {
187
187
  agentId: row.agent_id || undefined,
188
188
  title: row.title,
189
189
  selectModelId: row.select_model_id || undefined,
190
+ useSystemMode: row.use_system_mode !== 0,
190
191
  voiceState: JSON.parse(row.voice_state),
191
192
  createdAt: row.created_at,
192
193
  updatedAt: row.updated_at,
@@ -0,0 +1 @@
1
+ ALTER TABLE sessions ADD COLUMN use_system_mode INTEGER DEFAULT 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myassis/gateway",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "description": "我的助手 Gateway Service - 本地 AI 网关服务,支持认证、WebSocket 实时通信和任务调度",
5
5
  "main": "dist/index.js",
6
6
  "bin": {