dsh-monkeyai-sessions 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.
@@ -620,7 +620,7 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
620
620
  }
621
621
  return {
622
622
  switched: false,
623
- message: 'This MonkeyAI runtime does not support switching models on an active session. Create a new session to use a different model.',
623
+ message: '该 MonkeyAI runtime 不支持在活跃会话上切换模型,请新建会话使用其他模型。',
624
624
  }
625
625
  } finally {
626
626
  acp.close()
@@ -665,7 +665,7 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
665
665
  // oversized single frame; both end the stream.
666
666
  const pushed = events.push(frame)
667
667
  if (pushed === false) {
668
- const reason = new Error('Remote session event queue exceeded its limit')
668
+ const reason = new Error('远程会话事件队列超出上限')
669
669
  controller.abort(reason)
670
670
  currentAcp?.close(reason)
671
671
  return false
@@ -793,7 +793,7 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
793
793
  return
794
794
  }
795
795
  reconnectsUsed += 1
796
- emit({ type: 'reconnecting', sessionId: selectedSession, message: `History replay interrupted - reconnecting to continue loading (${reconnectsUsed}/${MAX_REPLAY_RECONNECTS})` })
796
+ emit({ type: 'reconnecting', sessionId: selectedSession, message: `历史回放中断,正在重连以继续加载(${reconnectsUsed}/${MAX_REPLAY_RECONNECTS})` })
797
797
  void (async () => {
798
798
  try {
799
799
  await establishAcp(true)
@@ -802,7 +802,7 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
802
802
  type: 'error',
803
803
  sessionId: selectedSession,
804
804
  code: 'acp_connection_closed',
805
- message: reconnectError instanceof Error ? reconnectError.message : 'Remote session connection closed',
805
+ message: reconnectError instanceof Error ? reconnectError.message : '远程会话连接已关闭',
806
806
  })
807
807
  controller.abort(reason)
808
808
  events.close()
@@ -814,7 +814,7 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
814
814
  // keep working (the runtime binds sessions per connection).
815
815
  if (loadCompleted && reconnectsUsed < MAX_REPLAY_RECONNECTS) {
816
816
  reconnectsUsed += 1
817
- emit({ type: 'reconnecting', sessionId: selectedSession, message: 'Remote connection dropped - reconnecting' })
817
+ emit({ type: 'reconnecting', sessionId: selectedSession, message: '远程连接中断,正在重连' })
818
818
  void (async () => {
819
819
  try {
820
820
  await establishAcp(true)
@@ -824,7 +824,7 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
824
824
  type: 'error',
825
825
  sessionId: selectedSession,
826
826
  code: 'acp_connection_closed',
827
- message: reconnectError instanceof Error ? reconnectError.message : 'Remote session connection closed',
827
+ message: reconnectError instanceof Error ? reconnectError.message : '远程会话连接已关闭',
828
828
  })
829
829
  controller.abort(reason)
830
830
  events.close()
@@ -836,14 +836,14 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
836
836
  type: 'error',
837
837
  sessionId: selectedSession,
838
838
  code: 'acp_connection_closed',
839
- message: 'Remote session connection closed',
839
+ message: '远程会话连接已关闭',
840
840
  })
841
841
  controller.abort(reason)
842
842
  events.close()
843
843
  })
844
844
  unsubscribe = () => { unsubscribeThis(); unsubscribe = () => {} }
845
845
  unsubscribeClose = () => { unsubscribeCloseThis(); unsubscribeClose = () => {} }
846
- if (signal.aborted) throw signal.reason ?? new Error('Remote session cancelled')
846
+ if (signal.aborted) throw signal.reason ?? new Error('远程会话已取消')
847
847
 
848
848
  const initialized = await acp.request('initialize', {
849
849
  protocolVersion: 1,
@@ -883,7 +883,7 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
883
883
  type: 'session_missing',
884
884
  sessionId: selectedSession,
885
885
  code: 'session_not_found',
886
- message: 'This session no longer exists on the selected device (the runtime may have been reset). Create a new session instead.',
886
+ message: '该会话在所选设备上已不存在(runtime 可能已重置),请新建会话。',
887
887
  })
888
888
  connection.sessionMissing = true
889
889
  return
@@ -902,7 +902,7 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
902
902
  type: 'history_incomplete',
903
903
  sessionId: selectedSession,
904
904
  code: 'history_load_failed',
905
- message: 'History replay was repeatedly cut off by the remote runtime; showing only the messages received so far.',
905
+ message: '历史回放被远程 runtime 反复中断,仅显示已收到的消息。',
906
906
  })
907
907
  loadCompleted = true
908
908
  }
@@ -914,12 +914,12 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
914
914
  grantRef = await this.getGrant(accountId)
915
915
  this.requireScope(grantRef, 'device:connect')
916
916
  this.requireScope(grantRef, 'session:read')
917
- if (signal.aborted) throw signal.reason ?? new Error('Remote session cancelled')
917
+ if (signal.aborted) throw signal.reason ?? new Error('远程会话已取消')
918
918
 
919
919
  const token = await this.refreshAccessToken(accountId, signal)
920
920
  const ticket = await this.requestConnectionTicket(accountId, grantRef, token, target, { signal })
921
921
  ticketValue = ticket.ticket
922
- if (signal.aborted) throw signal.reason ?? new Error('Remote session cancelled')
922
+ if (signal.aborted) throw signal.reason ?? new Error('远程会话已取消')
923
923
 
924
924
  // Load the full history over the runtime's HTTP read channel before the
925
925
  // ACP connection starts. The ACP session/load replay only streams a
@@ -959,7 +959,7 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
959
959
  try {
960
960
  const currentGrant = await this.getGrant(accountId)
961
961
  if (!currentGrant.token.scopes.includes('session:read')) {
962
- emit({ type: 'error', sessionId: selectedSession, code: 'read_permission_revoked', message: 'Session read permission is no longer available' })
962
+ emit({ type: 'error', sessionId: selectedSession, code: 'read_permission_revoked', message: '会话读取权限已失效' })
963
963
  controller.abort(new Error('Session read permission was revoked'))
964
964
  currentAcp?.close(new Error('Session read permission was revoked'))
965
965
  events.close()
@@ -973,7 +973,7 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
973
973
  continue
974
974
  }
975
975
 
976
- if (!currentAcp) throw new Error('ACP connection is re-establishing')
976
+ if (!currentAcp) throw new Error('ACP 连接正在重建')
977
977
 
978
978
  if (command.type === 'switch_model') {
979
979
  try {
@@ -1017,7 +1017,7 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
1017
1017
  type: 'delivery',
1018
1018
  sessionId: selectedSession,
1019
1019
  data: { accepted: false, code: 'remote_rejected' },
1020
- message: promptError instanceof Error ? promptError.message : 'Remote runtime rejected the instruction',
1020
+ message: promptError instanceof Error ? promptError.message : '远程 runtime 拒绝了该指令',
1021
1021
  })
1022
1022
  }
1023
1023
  continue
@@ -1043,7 +1043,7 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
1043
1043
  continue
1044
1044
  }
1045
1045
 
1046
- emit({ type: 'error', sessionId: selectedSession, code: 'invalid_command', message: 'Remote command is unsupported' })
1046
+ emit({ type: 'error', sessionId: selectedSession, code: 'invalid_command', message: '不支持该远程命令' })
1047
1047
  } catch (error) {
1048
1048
  if (signal.aborted) return
1049
1049
  const requestId = command.type === 'respond' ? command.requestId : undefined
@@ -1061,9 +1061,9 @@ export class MonkeyAIRemoteService extends TypertRemoteService {
1061
1061
  })()
1062
1062
  commandPump.catch(() => {
1063
1063
  if (signal.aborted) return
1064
- emit({ type: 'error', sessionId: selectedSession, code: 'command_channel_closed', message: 'Remote command channel closed' })
1065
- controller.abort(new Error('Remote command channel closed'))
1066
- currentAcp?.close(new Error('Remote command channel closed'))
1064
+ emit({ type: 'error', sessionId: selectedSession, code: 'command_channel_closed', message: '远程命令通道已关闭' })
1065
+ controller.abort(new Error('远程命令通道已关闭'))
1066
+ currentAcp?.close(new Error('远程命令通道已关闭'))
1067
1067
  events.close()
1068
1068
  })
1069
1069
 
@@ -1,7 +1,7 @@
1
1
  const MESSAGE_UPDATES = Object.freeze({
2
- user_message_chunk: { role: 'user', label: 'You', mode: 'append' },
2
+ user_message_chunk: { role: 'user', label: '我', mode: 'append' },
3
3
  agent_message_chunk: { role: 'assistant', label: 'MonkeyAI', mode: 'append' },
4
- user_message: { role: 'user', label: 'You', mode: 'replace' },
4
+ user_message: { role: 'user', label: '我', mode: 'replace' },
5
5
  agent_message: { role: 'assistant', label: 'MonkeyAI', mode: 'replace' },
6
6
  })
7
7
 
@@ -11,7 +11,7 @@ const THOUGHT_UPDATES = Object.freeze({
11
11
  })
12
12
 
13
13
  export const TOOL_STATUS_LABEL = Object.freeze({
14
- pending: 'queued', in_progress: 'running', completed: 'done', failed: 'failed', cancelled: 'cancelled',
14
+ pending: '排队中', in_progress: '执行中', completed: '完成', failed: '失败', cancelled: '已取消',
15
15
  })
16
16
 
17
17
  function contentText(content) {
@@ -124,20 +124,20 @@ function projectFrames(frames) {
124
124
  entries.push({ kind: 'raw', label: kind || 'session/update', data: update, key: `raw:${entries.length}` })
125
125
  continue
126
126
  }
127
- if (frame.type === 'ready') { if (!seenReady) { seenReady = true; entries.push({ kind: 'system', label: 'Connected to remote runtime', key: `sys-ready:${entries.length}` }) } continue }
128
- if (frame.type === 'history_loaded') { if (!seenHistoryLoaded) { seenHistoryLoaded = true; entries.push({ kind: 'system', label: 'History loaded', key: `sys-hist:${entries.length}` }) } continue }
129
- if (frame.type === 'history_incomplete') { entries.push({ kind: 'system', label: 'History incomplete - some earlier messages may be missing', key: `sys-inc:${entries.length}` }); continue }
130
- if (frame.type === 'reconnecting') { if (!seenReconnecting) { seenReconnecting = true; entries.push({ kind: 'system', label: frame.message || 'Reconnecting to remote runtime', key: `sys-reconn:${entries.length}` }) } continue }
127
+ if (frame.type === 'ready') { if (!seenReady) { seenReady = true; entries.push({ kind: 'system', label: '已连接到远程 runtime', key: `sys-ready:${entries.length}` }) } continue }
128
+ if (frame.type === 'history_loaded') { if (!seenHistoryLoaded) { seenHistoryLoaded = true; entries.push({ kind: 'system', label: '历史已加载', key: `sys-hist:${entries.length}` }) } continue }
129
+ if (frame.type === 'history_incomplete') { entries.push({ kind: 'system', label: '历史不完整,部分更早的消息可能缺失', key: `sys-inc:${entries.length}` }); continue }
130
+ if (frame.type === 'reconnecting') { if (!seenReconnecting) { seenReconnecting = true; entries.push({ kind: 'system', label: frame.message || '正在重连远程 runtime', key: `sys-reconn:${entries.length}` }) } continue }
131
131
  if (frame.type === 'reconnected') { continue }
132
132
  if (frame.type === 'delivery') {
133
133
  const accepted = Boolean(frame.data?.accepted)
134
134
  if (accepted) continue // turn completion is shown in the composer status line
135
- entries.push({ kind: 'system', label: 'MonkeyAI did not accept the instruction', key: `sys-del:${entries.length}` })
135
+ entries.push({ kind: 'system', label: 'MonkeyAI 未接受该指令', key: `sys-del:${entries.length}` })
136
136
  continue
137
137
  }
138
- if (frame.type === 'cancel_sent') { entries.push({ kind: 'system', label: 'Stop requested', key: `sys-cancel:${entries.length}` }); continue }
138
+ if (frame.type === 'cancel_sent') { entries.push({ kind: 'system', label: '已请求停止', key: `sys-cancel:${entries.length}` }); continue }
139
139
  if (frame.type === 'request') { continue } // rendered as an approval card from pendingRequests
140
- if (frame.type === 'model_switched') { entries.push({ kind: 'system', label: `Model switched to ${frame.data?.model ?? 'selected model'}`, key: `sys-model:${entries.length}` }); continue }
140
+ if (frame.type === 'model_switched') { entries.push({ kind: 'system', label: `已切换模型:${frame.data?.model ?? '所选模型'}`, key: `sys-model:${entries.length}` }); continue }
141
141
  if (frame.type === 'model_switch_failed') { continue } // surfaced via the error banner
142
142
  if (frame.type === 'notification' && typeof frame.method === 'string' && frame.method.startsWith('_monkeyai/')) { continue } // internal runtime state notifications
143
143
  if (frame.type === 'error') { entries.push({ kind: 'raw', label: frame.code || 'error', data: { message: frame.message || frame.code }, key: `sys-err:${entries.length}` }); continue }