dsh-remote-plugin 0.7.3 → 0.7.5

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.
@@ -0,0 +1,17 @@
1
+ /* Explicit user downloads only; attachment IDs never become filesystem paths. */
2
+ (function(root,factory){const api=factory(root);if(typeof module==='object')module.exports=api;root.DshChatFiles=api})(typeof window!=='undefined'?window:globalThis,(root)=>{
3
+ const esc=v=>String(v??'').replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]))
4
+ function pathOf(value,cwd='') {
5
+ if(typeof value!=='string'||value.length>4096||/[\x00-\x1f]/.test(value))return ''
6
+ let path=value.trim()
7
+ if(/^file:/i.test(path)){try{const u=new URL(path);if(u.hostname&&u.hostname!=='localhost')return '';path=decodeURIComponent(u.pathname);if(/^\/[a-z]:\//i.test(path))path=path.slice(1)}catch{return ''}}
8
+ if(/[\x00-\x1f]/.test(path))return ''
9
+ if(/^(?:[a-z]:[\\/]|\/(?!\/))/i.test(path))return path
10
+ if(/^\.{1,2}[\\/]/.test(path)){const base=pathOf(cwd);if(base)return base.replace(/[\\/]+$/,'')+'/'+path}
11
+ return ''
12
+ }
13
+
14
+ function render(block){const a=block.attachment||block,path=pathOf(a.path||block.path)||(/^\.{1,2}[\\/]/.test(a.path||block.path||'')?(a.path||block.path):''),id=/^[a-f0-9]{64}$/.test(a.attachmentId||'')?a.attachmentId:'';const name=a.name||block.name||'file';return `<div class="chat-file"><span class="chat-file-name">📎 ${esc(name)} <small>${esc(a.bytes??block.bytes??'')} bytes</small></span>${id||path?`<button type="button" ${id?'data-dsh-attachment="'+esc(id)+'"':'data-dsh-file-path="'+esc(path)+'"'} data-dsh-file-name="${esc(name)}">下载文件</button>`:''}</div>`}
15
+ function bind(target,config){target.addEventListener('click',async event=>{const control=event.target.closest?.('[data-dsh-file-path],[data-dsh-attachment]');if(!control||!target.contains(control)||control.getAttribute('aria-busy')==='true')return;event.preventDefault();const c=config(),id=control.dataset.dshAttachment,path=pathOf(control.dataset.dshFilePath,c.cwd);if(!c.valid())return;if(!id&&!path){c.notice('无法定位文件,请核对当前会话的工作目录','err');return;}const name=(control.dataset.dshFileName||path.split(/[\\/]/).pop()||'download').replace(/[\\/\x00-\x1f]/g,'_');const url=new URL(c.server+(id?'/remote/api/session-file':'/fs/file'),root.location?.href);if(id){url.searchParams.set('sessionId',c.sessionId);url.searchParams.set('attachmentId',id)}else url.searchParams.set('path',path);control.setAttribute('aria-busy','true');try{const response=await fetch(url,{method:'HEAD',redirect:'error',headers:c.headers,signal:AbortSignal.timeout(15000)});if(!c.valid())return;if(!response.ok)throw Error(response.status===403?'主机不允许下载这个文件':response.status===404?'文件不存在或不属于当前会话':response.status===503?'主机版本暂不支持附件下载':'文件下载失败(HTTP '+response.status+')');if(c.native){if(!root.NativeFile?.downloadToDownloads)throw Error('当前 App 不支持系统下载');root.NativeFile.downloadToDownloads(url.href,name,c.token)}else{if(c.token)url.searchParams.set('token',c.token);const link=document.createElement('a');link.href=url.href;link.download=name;link.referrerPolicy='no-referrer';document.body.append(link);link.click();link.remove()}c.notice('已交给系统下载,请在下载目录查看','ok')}catch(error){if(c.valid())c.notice(error.message,'err')}finally{control.removeAttribute('aria-busy')}})}
16
+ return {pathOf,render,bind}
17
+ })
@@ -746,3 +746,8 @@ input:focus-visible, select:focus-visible, textarea:focus-visible {
746
746
  }
747
747
 
748
748
  @media(max-width:600px) { .ds-system-pulse-ring { width:108px; height:108px; } .ds-overview-status { font-size:20px; } html[lang="en"] .ds-overview-status { min-block-size:2.5em; } }
749
+ #view-plugins{overflow-y:auto}
750
+
751
+ .chat-file { display:flex; flex-wrap:wrap; align-items:center; gap:8px 12px; padding:12px; border:1px solid var(--dsr-line); border-radius:12px; margin:8px 0; }
752
+ .chat-file-name { min-width:0; flex:1; overflow-wrap:break-word; }.chat-file small { color:var(--dsr-muted); }
753
+ .chat-file button { flex-shrink:0; min-height:44px; padding:8px 12px; border:1px solid var(--dsr-accent-line); border-radius:10px; color:var(--dsr-accent-strong); background:var(--dsr-accent-soft); font:inherit; cursor:pointer; }
@@ -8,6 +8,8 @@
8
8
  <link rel="stylesheet" href="../theme-vars.css">
9
9
  <link rel="stylesheet" href="desktop.css">
10
10
  <link rel="stylesheet" href="../plugin-center.css">
11
+ <link rel="stylesheet" href="../skills.css">
12
+ <link rel="stylesheet" href="../extensions.css">
11
13
  <link rel="stylesheet" href="../insights.css">
12
14
  </head>
13
15
  <body>
@@ -244,6 +246,11 @@
244
246
  <div><div class="ds-setting-name" data-i18n="ds.tokenTitle">访问令牌</div><div class="ds-setting-desc" id="token-desc"></div></div>
245
247
  <button id="btn-copy-token" class="ds-btn" data-i18n="ds.copyToken">复制</button>
246
248
  </div>
249
+ <div class="ds-setting-row">
250
+ <label for="desktop-token-input" data-i18n="ds.tokenTitle">访问令牌</label>
251
+ <input id="desktop-token-input" type="password" autocomplete="off" style="min-width:0;flex:1" />
252
+ <button id="desktop-token-save" class="ds-btn" data-i18n="ds.saveToken">保存并连接</button>
253
+ </div>
247
254
  <div class="ds-setting-row">
248
255
  <div><div class="ds-setting-name" data-i18n="ds.langTitle">语言 / Language</div></div>
249
256
  <button id="btn-lang" class="ds-btn">EN</button>
@@ -534,6 +541,8 @@
534
541
  'ds.attention': '需要你处理', 'ds.runtime': '运行指标', 'ds.recentActivity': '近期活动', 'ds.dshVersion': 'DSH 版本', 'ds.gatewayStatus': '网关状态', 'ds.activeSessions': '活跃会话', 'ds.connectionMode': '连接模式', 'ds.liveWs': '实时 WS', 'ds.poll': '降级轮询', 'ds.running': '运行中', 'ds.noReason': '无说明', 'ds.noActivity': '暂无后台活动', 'ds.noSessions': '暂无会话', 'ds.refreshOverview': '刷新总览', 'ds.pendingCount': '{n} 项待处理', 'ds.activeCount': '{n} 个活跃会话', 'ds.nothingPending': '暂无事项', 'ds.action.openSession': '打开最近会话', 'ds.action.newSession': '新建会话', 'ds.action.attention': '处理待办', 'ds.action.connect': '去设置连接', 'ds.action.refresh': '重新检查连接',
535
542
  'ds.sortLabel': '会话排序', 'ds.sortTime': '按时间', 'ds.sortWorkspace': '按工作区', 'ds.workspace': '工作区', 'ds.workspaceUnknown': '未指定工作区', 'ds.wbOrderSaved': '顺序已保存到当前设备',
536
543
  'ds.insights': '上下文与费用',
544
+ 'ds.insightsContext': '上下文分析',
545
+ 'ds.insightsCost': '费用与额度',
537
546
  'ds.files': '文件传输', 'ds.plugins': '插件', 'ds.settings': '设置', 'ds.stats': '统计', 'ds.menu': '导航',
538
547
  'ds.send': '发送', 'ds.composerPlaceholder': '输入消息,Enter 发送…', 'ds.composerRunning': '运行中…', 'ds.presets': '预设', 'ds.sessionRename': '重命名会话', 'ds.sessionRenameTitle': '重命名会话', 'ds.sessionRenamePlaceholder': '输入新的会话名称', 'ds.sessionRenameConfirm': '保存', 'ds.sessionRenameFailed': '重命名失败', 'ds.sessionRenameEmpty': '会话名称不能为空', 'ds.sessionRenamed': '会话名称已更新', 'ds.sessionArchive': '归档', 'ds.sessionArchiveConfirm': '归档这个会话?归档后可在“显示已归档”中打开。', 'ds.sessionArchived': '会话已归档', 'ds.sessionStop': '停止本轮', 'ds.sessionStopConfirm': '停止当前回合?排队中的消息不会被删除。', 'ds.sessionStopFailed': '停止失败', 'ds.sessionStopRequested': '已请求停止本轮', 'ds.sessionRecovering': '恢复会话中…', 'ds.sessionReady': '会话已恢复', 'ds.sessionRecoveryFailed': '会话恢复失败',
539
548
  'ds.commands': '指令',
@@ -552,7 +561,7 @@
552
561
  'ds.notesTitle': '更新内容', 'ds.notesClose': '关闭', 'ds.notesPage': '版本号 {current}/{total}',
553
562
  'ds.back': '‹ 返回', 'ds.emptyGroup': '暂无设置项',
554
563
  'ds.serversTitle': '服务器(分组)', 'ds.speedTest': '测速', 'ds.currentGroup': '当前组',
555
- 'ds.addGroup': '+ 组', 'ds.addServer': '添加', 'ds.tokenTitle': '访问令牌', 'ds.copyToken': '复制',
564
+ 'ds.addGroup': '+ 组', 'ds.addServer': '添加', 'ds.saveToken': '保存并连接', 'ds.tokenTitle': '访问令牌', 'ds.copyToken': '复制',
556
565
  'ds.themeTitle': '皮肤', 'ds.themeDesc': '默认深空 / 落日 / 易北爱乐厅 / 草原孤塔 / 黑曜白', 'ds.langTitle': '语言 / Language',
557
566
  'ds.feedbackTitle': '反馈渠道', 'ds.feedbackDesc': 'GitHub / Gitee / B站:反馈 bug、提建议、唠嗑',
558
567
  'ds.feedback': '反馈', 'ds.feedbackGithubDesc': '反馈 bug / 提建议', 'ds.feedbackGiteeDesc': '国内镜像,无需代理',
@@ -641,6 +650,8 @@
641
650
  'ds.attention': 'Needs attention', 'ds.runtime': 'Runtime metrics', 'ds.recentActivity': 'Recent activity', 'ds.dshVersion': 'DSH version', 'ds.gatewayStatus': 'Gateway status', 'ds.activeSessions': 'Active sessions', 'ds.connectionMode': 'Connection mode', 'ds.liveWs': 'Live WS', 'ds.poll': 'Degraded polling', 'ds.running': 'Running', 'ds.noReason': 'No reason given', 'ds.noActivity': 'No background activity', 'ds.noSessions': 'No sessions yet', 'ds.refreshOverview': 'Refresh overview', 'ds.pendingCount': '{n} pending', 'ds.activeCount': '{n} active sessions', 'ds.nothingPending': 'Nothing pending', 'ds.action.openSession': 'Open recent session', 'ds.action.newSession': 'New session', 'ds.action.attention': 'Review pending', 'ds.action.connect': 'Set up connection', 'ds.action.refresh': 'Check connection',
642
651
  'ds.sortLabel': 'Session sort', 'ds.sortTime': 'By time', 'ds.sortWorkspace': 'By workspace', 'ds.workspace': 'Workspace', 'ds.workspaceUnknown': 'No workspace', 'ds.wbOrderSaved': 'Order saved on this device',
643
652
  'ds.insights': 'Context & costs',
653
+ 'ds.insightsContext': 'Context analysis',
654
+ 'ds.insightsCost': 'Cost & quotas',
644
655
  'ds.files': 'Files', 'ds.plugins': 'Plugins', 'ds.settings': 'Settings', 'ds.stats': 'Stats', 'ds.menu': 'Menu',
645
656
  'ds.send': 'Send', 'ds.composerPlaceholder': 'Type a message, Enter to send…', 'ds.composerRunning': 'Running…', 'ds.presets': 'Presets', 'ds.sessionRename': 'Rename session', 'ds.sessionRenameTitle': 'Rename session', 'ds.sessionRenamePlaceholder': 'Enter a new session name', 'ds.sessionRenameConfirm': 'Save', 'ds.sessionRenameFailed': 'Rename failed', 'ds.sessionRenameEmpty': 'Session name cannot be empty', 'ds.sessionRenamed': 'Session name updated', 'ds.sessionArchive': 'Archive', 'ds.sessionArchiveConfirm': 'Archive this session? You can open it from “Show archived”.', 'ds.sessionArchived': 'Session archived', 'ds.sessionStop': 'Stop turn', 'ds.sessionStopConfirm': 'Stop the current turn? Queued messages will be kept.', 'ds.sessionStopFailed': 'Stop failed', 'ds.sessionStopRequested': 'Stop requested', 'ds.sessionRecovering': 'Restoring session…', 'ds.sessionReady': 'Session ready', 'ds.sessionRecoveryFailed': 'Session restore failed',
646
657
  'ds.commands': 'Commands',
@@ -658,7 +669,7 @@
658
669
  'ds.notesTitle': 'What\'s New', 'ds.notesClose': 'Close', 'ds.notesPage': 'Version {current}/{total}',
659
670
  'ds.back': '‹ Back', 'ds.emptyGroup': 'No settings here',
660
671
  'ds.serversTitle': 'Servers (groups)', 'ds.speedTest': 'Test', 'ds.currentGroup': 'Current group',
661
- 'ds.addGroup': '+ Group', 'ds.addServer': 'Add', 'ds.tokenTitle': 'Access token', 'ds.copyToken': 'Copy',
672
+ 'ds.addGroup': '+ Group', 'ds.addServer': 'Add', 'ds.saveToken': 'Save and connect', 'ds.tokenTitle': 'Access token', 'ds.copyToken': 'Copy',
662
673
  'ds.themeTitle': 'Theme', 'ds.themeDesc': 'Deep Space / Sunset / Elbphilharmonie / Prairie Tower / Monochrome', 'ds.langTitle': 'Language',
663
674
  'ds.feedbackTitle': 'Feedback', 'ds.feedbackDesc': 'GitHub / Gitee / Bilibili: report bugs, suggest features, or just chat',
664
675
  'ds.feedback': 'Feedback', 'ds.feedbackGithubDesc': 'Report bugs · suggest features', 'ds.feedbackGiteeDesc': 'Mirror in China, no proxy needed',
@@ -746,15 +757,19 @@
746
757
  <script src="i18n.js"></script>
747
758
  <link rel="stylesheet" href="../genui.css">
748
759
  <script src="../genui.js"></script>
760
+ <script src="../chat-files.js"></script>
749
761
  <script src="../md.js"></script>
750
762
  <script src="../vendor/gsap/gsap.min.js"></script>
751
763
  <script src="../motion.js"></script>
752
764
  <script type="module" src="../morphicons-init.js"></script>
753
765
  <script src="../plugin-center.js"></script>
766
+ <script src="../skills.js"></script>
754
767
  <script src="../insights.js"></script>
768
+ <script src="../extensions.js"></script>
755
769
  <script src="../sha256.js"></script>
756
770
  <script src="../history.js"></script>
757
771
  <script src="../link-check.js"></script>
772
+ <script src="../network.js"></script>
758
773
  <script src="desktop.js"></script>
759
774
  </body>
760
775
  </html>