dsh-reference-anything 0.3.1 → 0.3.3

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.
Files changed (107) hide show
  1. package/LICENSE +22 -22
  2. package/NOTICE.md +52 -25
  3. package/README.md +342 -284
  4. package/cordis.patch.yml +89 -18
  5. package/lib/client.js +13534 -521
  6. package/lib/contract.d.ts +155 -3
  7. package/lib/contract.js +68 -4
  8. package/lib/download-directory.d.ts +18 -0
  9. package/lib/download-directory.js +55 -0
  10. package/lib/errors.d.ts +4 -0
  11. package/lib/host.d.ts +96 -3
  12. package/lib/host.js +88 -5
  13. package/lib/index.d.ts +22 -2
  14. package/lib/index.js +57 -7
  15. package/lib/opencli.d.ts +5 -3
  16. package/lib/opencli.js +13 -6
  17. package/lib/openlist/host.d.ts +157 -0
  18. package/lib/openlist/host.js +873 -0
  19. package/lib/openlist/index.d.ts +84 -0
  20. package/lib/openlist/index.js +507 -0
  21. package/lib/render.d.ts +12 -7
  22. package/lib/render.js +27 -21
  23. package/lib/sources/cloud-drive/cache.d.ts +60 -0
  24. package/lib/sources/cloud-drive/cache.js +107 -0
  25. package/lib/sources/cloud-drive/index.d.ts +190 -0
  26. package/lib/sources/cloud-drive/index.js +526 -0
  27. package/lib/sources/cloud-drive/providers/http.d.ts +27 -0
  28. package/lib/sources/cloud-drive/providers/http.js +73 -0
  29. package/lib/sources/cloud-drive/providers/openlist.d.ts +59 -0
  30. package/lib/sources/cloud-drive/providers/openlist.js +535 -0
  31. package/lib/sources/cloud-drive/registry.d.ts +53 -0
  32. package/lib/sources/cloud-drive/registry.js +101 -0
  33. package/lib/sources/cloud-drive/types.d.ts +169 -0
  34. package/lib/sources/cloud-drive/types.js +17 -0
  35. package/lib/sources/file.d.ts +2 -0
  36. package/lib/sources/file.js +2 -0
  37. package/lib/sources/local-agent/adapters/claude-code.d.ts +16 -0
  38. package/lib/sources/local-agent/adapters/claude-code.js +171 -0
  39. package/lib/sources/local-agent/adapters/codex.d.ts +20 -0
  40. package/lib/sources/local-agent/adapters/codex.js +204 -0
  41. package/lib/sources/local-agent/adapters/cursor.d.ts +23 -0
  42. package/lib/sources/local-agent/adapters/cursor.js +121 -0
  43. package/lib/sources/local-agent/adapters/gemini-cli.d.ts +20 -0
  44. package/lib/sources/local-agent/adapters/gemini-cli.js +141 -0
  45. package/lib/sources/local-agent/adapters/grokbuild.d.ts +22 -0
  46. package/lib/sources/local-agent/adapters/grokbuild.js +76 -0
  47. package/lib/sources/local-agent/adapters/hermes.d.ts +19 -0
  48. package/lib/sources/local-agent/adapters/hermes.js +85 -0
  49. package/lib/sources/local-agent/adapters/kimi.d.ts +28 -0
  50. package/lib/sources/local-agent/adapters/kimi.js +261 -0
  51. package/lib/sources/local-agent/adapters/openclaw.d.ts +21 -0
  52. package/lib/sources/local-agent/adapters/openclaw.js +120 -0
  53. package/lib/sources/local-agent/adapters/opencode.d.ts +44 -0
  54. package/lib/sources/local-agent/adapters/opencode.js +236 -0
  55. package/lib/sources/local-agent/adapters/pi.d.ts +26 -0
  56. package/lib/sources/local-agent/adapters/pi.js +242 -0
  57. package/lib/sources/local-agent/adapters/qoder.d.ts +19 -0
  58. package/lib/sources/local-agent/adapters/qoder.js +93 -0
  59. package/lib/sources/local-agent/adapters/reasonix.d.ts +23 -0
  60. package/lib/sources/local-agent/adapters/reasonix.js +90 -0
  61. package/lib/sources/local-agent/adapters/shared.d.ts +163 -0
  62. package/lib/sources/local-agent/adapters/shared.js +415 -0
  63. package/lib/sources/local-agent/adapters/sqlite-shared.d.ts +92 -0
  64. package/lib/sources/local-agent/adapters/sqlite-shared.js +215 -0
  65. package/lib/sources/local-agent/adapters/zcode.d.ts +41 -0
  66. package/lib/sources/local-agent/adapters/zcode.js +159 -0
  67. package/lib/sources/local-agent/index.d.ts +222 -0
  68. package/lib/sources/local-agent/index.js +656 -0
  69. package/lib/sources/local-agent/page.d.ts +55 -0
  70. package/lib/sources/local-agent/page.js +83 -0
  71. package/lib/sources/local-agent/path.d.ts +8 -0
  72. package/lib/sources/local-agent/path.js +43 -0
  73. package/lib/sources/local-agent/registry.d.ts +68 -0
  74. package/lib/sources/local-agent/registry.js +116 -0
  75. package/lib/sources/local-agent/scan.d.ts +175 -0
  76. package/lib/sources/local-agent/scan.js +472 -0
  77. package/lib/sources/local-agent/sqlite.d.ts +45 -0
  78. package/lib/sources/local-agent/sqlite.js +113 -0
  79. package/lib/sources/local-agent/store.d.ts +93 -0
  80. package/lib/sources/local-agent/store.js +113 -0
  81. package/lib/sources/local-agent/types.d.ts +338 -0
  82. package/lib/sources/local-agent/types.js +20 -0
  83. package/lib/sources/web-chat/index.d.ts +5 -1
  84. package/lib/sources/web-chat/index.js +47 -8
  85. package/lib/store/spec.d.ts +50 -0
  86. package/lib/store/spec.js +2 -2
  87. package/lib/sync/index.d.ts +1 -0
  88. package/lib/sync/index.js +28 -8
  89. package/lib/tool.d.ts +5 -0
  90. package/lib/tool.js +418 -45
  91. package/lib/typert.js +13 -1
  92. package/lib/types.d.ts +28 -2
  93. package/lib/update.d.ts +6 -0
  94. package/lib/update.js +29 -1
  95. package/lib/web.js +5 -1
  96. package/lib/wire.d.ts +80 -0
  97. package/lib/wire.js +30 -1
  98. package/opencli-plugin/chatgpt.js +30 -27
  99. package/opencli-plugin/claude.js +12 -8
  100. package/opencli-plugin/common.js +266 -187
  101. package/opencli-plugin/deepseek.js +8 -5
  102. package/opencli-plugin/gemini.js +42 -38
  103. package/opencli-plugin/grok.js +22 -21
  104. package/opencli-plugin/kimi.js +34 -31
  105. package/opencli-plugin/opencli-plugin.json +6 -6
  106. package/opencli-plugin/package.json +8 -8
  107. package/package.json +200 -185
@@ -1,33 +1,33 @@
1
- import { domFallbackScript, registerProvider, sinceGuardSource } from './common.js'
2
- // OpenCLI discovery marker: registerProvider below performs the cli() calls.
3
-
4
- export const timestampSource = String.raw`value => {
5
- if (Array.isArray(value)) {
6
- if (value.length === 0) return ''
7
- const seconds = Number(value[0])
8
- const nanos = Number(value[1] || 0)
9
- if (Number.isFinite(seconds) && seconds > 0 && seconds < 1e11) {
10
- const date = new Date(seconds * 1000 + (Number.isFinite(nanos) ? nanos / 1e6 : 0))
11
- return Number.isNaN(date.getTime()) ? '' : date.toISOString()
12
- }
13
- value = value[0]
14
- }
15
- if (value === undefined || value === null || value === '') return ''
16
- if (typeof value === 'string' && Number.isNaN(Number(value))) {
17
- const parsed = Date.parse(value)
18
- return Number.isNaN(parsed) ? '' : new Date(parsed).toISOString()
19
- }
20
- const numeric = Number(value)
21
- if (!Number.isFinite(numeric) || numeric <= 0) return ''
22
- const milliseconds = numeric < 1e11 ? numeric * 1000
23
- : numeric < 1e14 ? numeric : numeric < 1e17 ? numeric / 1000 : numeric / 1e6
24
- const date = new Date(milliseconds)
25
- return Number.isNaN(date.getTime()) ? '' : date.toISOString()
26
- }`
27
-
28
- const helpers = String.raw`
29
- const toIso = (${timestampSource})
30
- const auth = () => {
1
+ import { domFallbackScript, registerProvider, sinceGuardSource } from './common.js'
2
+ // OpenCLI discovery marker: registerProvider below performs the cli() calls.
3
+
4
+ export const timestampSource = String.raw`value => {
5
+ if (Array.isArray(value)) {
6
+ if (value.length === 0) return ''
7
+ const seconds = Number(value[0])
8
+ const nanos = Number(value[1] || 0)
9
+ if (Number.isFinite(seconds) && seconds > 0 && seconds < 1e11) {
10
+ const date = new Date(seconds * 1000 + (Number.isFinite(nanos) ? nanos / 1e6 : 0))
11
+ return Number.isNaN(date.getTime()) ? '' : date.toISOString()
12
+ }
13
+ value = value[0]
14
+ }
15
+ if (value === undefined || value === null || value === '') return ''
16
+ if (typeof value === 'string' && Number.isNaN(Number(value))) {
17
+ const parsed = Date.parse(value)
18
+ return Number.isNaN(parsed) ? '' : new Date(parsed).toISOString()
19
+ }
20
+ const numeric = Number(value)
21
+ if (!Number.isFinite(numeric) || numeric <= 0) return ''
22
+ const milliseconds = numeric < 1e11 ? numeric * 1000
23
+ : numeric < 1e14 ? numeric : numeric < 1e17 ? numeric / 1000 : numeric / 1e6
24
+ const date = new Date(milliseconds)
25
+ return Number.isNaN(date.getTime()) ? '' : date.toISOString()
26
+ }`
27
+
28
+ const helpers = String.raw`
29
+ const toIso = (${timestampSource})
30
+ const auth = () => {
31
31
  const wiz = window.__WIZ_global_data || window.WIZ_global_data || {}
32
32
  if (wiz.SNlM0e) return String(wiz.SNlM0e)
33
33
  for (const script of document.scripts) {
@@ -93,7 +93,7 @@ const historyScript = String.raw`async function (args) {
93
93
  if (!byId.has(id)) {
94
94
  const row = { provider: 'gemini', accountScope: '', id,
95
95
  title: String(value[1] || value[2]), url: location.origin + '/app/' + encodeURIComponent(id),
96
- createdAt: '', updatedAt: toIso(value[5]), messageCount: 0, cursor: '', partial: false }
96
+ createdAt: '', updatedAt: toIso(value[5]), messageCount: 0, cursor: '', partial: false }
97
97
  byId.set(id, row)
98
98
  pageRows.push(row)
99
99
  }
@@ -135,8 +135,8 @@ const detailScript = String.raw`async function (args) {
135
135
  const rows = []
136
136
  for (const turn of turns.slice().reverse()) {
137
137
  if (!Array.isArray(turn)) continue
138
- const stamp = turn && turn[4]
139
- const createdAt = toIso(stamp)
138
+ const stamp = turn && turn[4]
139
+ const createdAt = toIso(stamp)
140
140
  const responseId = turn && turn[0] && typeof turn[0][1] === 'string' ? turn[0][1] : String(rows.length)
141
141
  const user = turn && turn[2] && turn[2][0] && turn[2][0][0]
142
142
  const assistant = turn && turn[3] && turn[3][0] && turn[3][0][0] && turn[3][0][0][1] && turn[3][0][0][1][0]
@@ -153,13 +153,17 @@ const detailScript = String.raw`async function (args) {
153
153
  }
154
154
  }`
155
155
 
156
+ export const whoamiScript = String.raw`async function () {
157
+ const wiz = window.__WIZ_global_data || window.WIZ_global_data || {}
158
+ const candidate = wiz.oPEP7c || wiz.CfO9Re
159
+ const identity = typeof candidate === 'string' ? candidate.trim() : ''
160
+ if (!identity) return JSON.stringify({ ok: false, message: 'Gemini stable account identity unavailable' })
161
+ return JSON.stringify({ ok: true, identity })
162
+ }`
163
+
156
164
  registerProvider({
157
165
  site: 'dsh-gemini', provider: 'Gemini', domain: 'gemini.google.com', home: 'https://gemini.google.com/app',
158
166
  conversationUrl: id => `https://gemini.google.com/app/${encodeURIComponent(id)}`,
159
- whoamiScript: String.raw`async function () {
160
- const match = location.pathname.match(/\/u\/(\d+)(?:\/|$)/); const slot = match ? match[1] : 'default'
161
- const wiz = window.__WIZ_global_data || window.WIZ_global_data || {}; const identity = String(wiz.oPEP7c || wiz.CfO9Re || slot)
162
- return JSON.stringify({ ok: Boolean(identity), identity })
163
- }`,
167
+ whoamiScript,
164
168
  historyScript, detailScript, fallbackScript: domFallbackScript,
165
169
  })
@@ -50,7 +50,7 @@ const historyScript = String.raw`async function (args) {
50
50
  }
51
51
  }`
52
52
 
53
- const detailScript = String.raw`async function (args) {
53
+ const detailScript = String.raw`async function (args) {
54
54
  try {
55
55
  const init = { credentials: 'include', headers: { Accept: 'application/json' } }
56
56
  const detailResponse = await fetch('/rest/app-chat/conversations_v2/' + encodeURIComponent(args.id), init)
@@ -101,23 +101,24 @@ const detailScript = String.raw`async function (args) {
101
101
  } catch (error) {
102
102
  return JSON.stringify({ ok: false, message: String(error && error.message || error) })
103
103
  }
104
- }`
105
-
106
- export const whoamiScript = String.raw`async function () {
107
- for (const url of ['/api/auth/session', '/rest/app-chat/users/me', '/rest/auth/me']) {
108
- const response = await fetch(url, { credentials: 'include', headers: { Accept: 'application/json' } })
109
- if (!response.ok) continue
110
- const payload = await response.json()
111
- const user = payload.session || payload.user || payload
112
- const identity = String(user.userId || user.id || user.xUserId || user.email || '')
113
- if (identity) return JSON.stringify({ ok: true, identity })
114
- }
115
- return JSON.stringify({ ok: false, code: 'AUTH' })
116
- }`
117
-
118
- registerProvider({
119
- site: 'dsh-grok', provider: 'Grok', domain: 'grok.com', home: 'https://grok.com/',
120
- conversationUrl: id => `https://grok.com/c/${encodeURIComponent(id)}`,
121
- whoamiScript,
122
- historyScript, detailScript, fallbackScript: domFallbackScript,
123
- })
104
+ }`
105
+
106
+ export const whoamiScript = String.raw`async function () {
107
+ for (const url of ['/api/auth/session', '/rest/app-chat/users/me', '/rest/auth/me']) {
108
+ const response = await fetch(url, { credentials: 'include', headers: { Accept: 'application/json' } })
109
+ if (response.status === 429) return JSON.stringify({ ok: false, code: 'RATE_LIMIT' })
110
+ if (!response.ok) continue
111
+ const payload = await response.json()
112
+ const user = payload.session || payload.user || payload
113
+ const identity = String(user.userId || user.id || user.xUserId || user.email || '')
114
+ if (identity) return JSON.stringify({ ok: true, identity })
115
+ }
116
+ return JSON.stringify({ ok: false, code: 'AUTH' })
117
+ }`
118
+
119
+ registerProvider({
120
+ site: 'dsh-grok', provider: 'Grok', domain: 'grok.com', home: 'https://grok.com/',
121
+ conversationUrl: id => `https://grok.com/c/${encodeURIComponent(id)}`,
122
+ whoamiScript,
123
+ historyScript, detailScript, fallbackScript: domFallbackScript,
124
+ })
@@ -51,7 +51,7 @@ const historyScript = String.raw`async function (args) {
51
51
  }
52
52
  }`
53
53
 
54
- export const detailScript = String.raw`async function (args) {
54
+ export const detailScript = String.raw`async function (args) {
55
55
  const headers = (${authHeaders})()
56
56
  const textOf = value => typeof value === 'string' ? value
57
57
  : Array.isArray(value) ? value.map(textOf).filter(Boolean).join('\n')
@@ -67,30 +67,30 @@ export const detailScript = String.raw`async function (args) {
67
67
  kind: mimeType.startsWith('image/') || /\.(?:gif|jpe?g|png|webp)$/i.test(name) ? 'image' : 'file',
68
68
  name, mimeType, size: Number(file.size || file.file_size || 0), locator,
69
69
  status: locator ? 'available' : 'unavailable' }
70
- }
71
- try {
72
- const messages = []
73
- let pageToken = ''
74
- for (let page = 0; page < 500; page++) {
75
- let response = await fetch('/apiv2/kimi.chat.v1.ChatService/ListMessages', { method: 'POST', credentials: 'include', headers,
76
- body: JSON.stringify({ chat_id: args.id, ...(pageToken ? { pageToken } : {}) }) })
77
- if ((response.status === 404 || response.status === 405) && page === 0) {
78
- response = await fetch('/api/chat/' + encodeURIComponent(args.id) + '/messages', { credentials: 'include', headers })
79
- }
80
- if (response.status === 401 || response.status === 403) return JSON.stringify({ ok: false, code: 'AUTH' })
81
- if (response.status === 429) return JSON.stringify({ ok: false, code: 'RATE_LIMIT' })
82
- if (!response.ok) throw new Error('detail HTTP ' + response.status)
83
- const payload = await response.json()
84
- const items = payload.messages || payload.items || payload.data && (payload.data.messages || payload.data.items) || []
85
- messages.push(...items)
86
- const next = String(payload.nextPageToken || payload.next_page_token || payload.data && (payload.data.nextPageToken || payload.data.next_page_token) || '')
87
- if (!next || next === pageToken || items.length === 0) break
88
- pageToken = next
89
- }
90
- // Kimi lists newest messages first. The local mirror and every other
91
- // adapter use chronological ordinals, so reverse only after all pages land.
92
- messages.reverse()
93
- const rows = messages.map((message, ordinal) => {
70
+ }
71
+ try {
72
+ const messages = []
73
+ let pageToken = ''
74
+ for (let page = 0; page < 500; page++) {
75
+ let response = await fetch('/apiv2/kimi.chat.v1.ChatService/ListMessages', { method: 'POST', credentials: 'include', headers,
76
+ body: JSON.stringify({ chat_id: args.id, ...(pageToken ? { pageToken } : {}) }) })
77
+ if ((response.status === 404 || response.status === 405) && page === 0) {
78
+ response = await fetch('/api/chat/' + encodeURIComponent(args.id) + '/messages', { credentials: 'include', headers })
79
+ }
80
+ if (response.status === 401 || response.status === 403) return JSON.stringify({ ok: false, code: 'AUTH' })
81
+ if (response.status === 429) return JSON.stringify({ ok: false, code: 'RATE_LIMIT' })
82
+ if (!response.ok) throw new Error('detail HTTP ' + response.status)
83
+ const payload = await response.json()
84
+ const items = payload.messages || payload.items || payload.data && (payload.data.messages || payload.data.items) || []
85
+ messages.push(...items)
86
+ const next = String(payload.nextPageToken || payload.next_page_token || payload.data && (payload.data.nextPageToken || payload.data.next_page_token) || '')
87
+ if (!next || next === pageToken || items.length === 0) break
88
+ pageToken = next
89
+ }
90
+ // Kimi lists newest messages first. The local mirror and every other
91
+ // adapter use chronological ordinals, so reverse only after all pages land.
92
+ messages.reverse()
93
+ const rows = messages.map((message, ordinal) => {
94
94
  const roleRaw = String(message.role || message.sender || message.message_role || message.type || '').toLowerCase()
95
95
  const role = /assistant|bot|model|kimi/.test(roleRaw) ? 'assistant' : 'user'
96
96
  const files = message.attachments || message.files || message.file_infos || []
@@ -98,7 +98,7 @@ export const detailScript = String.raw`async function (args) {
98
98
  return { conversationId: args.id, ordinal,
99
99
  messageId: String(message.id || message.message_id || ordinal),
100
100
  parentId: String(message.parent_id || message.parentId || ''), branchId: '', activeBranch: true,
101
- role, text: textOf(message.blocks || message.contents || message.content || message.text || message.fragments || ''),
101
+ role, text: textOf(message.blocks || message.contents || message.content || message.text || message.fragments || ''),
102
102
  createdAt: String(message.created_at || message.createdAt || message.timestamp || ''),
103
103
  attachmentsJson: JSON.stringify(attachments), partial: false }
104
104
  }).filter(row => row.text || row.attachmentsJson !== '[]')
@@ -108,16 +108,19 @@ export const detailScript = String.raw`async function (args) {
108
108
  }
109
109
  }`
110
110
 
111
- registerProvider({
112
- site: 'dsh-kimi', provider: 'Kimi', domain: 'kimi.com', home: 'https://www.kimi.com/',
113
- conversationUrl: id => `https://www.kimi.com/chat/${encodeURIComponent(id)}`,
114
- whoamiScript: String.raw`async function () {
111
+ export const whoamiScript = String.raw`async function () {
115
112
  const headers = (${authHeaders})()
116
113
  const response = await fetch('/api/user', { credentials: 'include', headers })
117
114
  if (response.status === 401 || response.status === 403) return JSON.stringify({ ok: false, code: 'AUTH' })
115
+ if (response.status === 429) return JSON.stringify({ ok: false, code: 'RATE_LIMIT' })
118
116
  if (!response.ok) return JSON.stringify({ ok: false, message: 'user HTTP ' + response.status })
119
117
  const user = await response.json(); const identity = String(user.id || user.user_id || user.email || '')
120
118
  return JSON.stringify({ ok: Boolean(identity), identity, code: identity ? undefined : 'AUTH' })
121
- }`,
119
+ }`
120
+
121
+ registerProvider({
122
+ site: 'dsh-kimi', provider: 'Kimi', domain: 'kimi.com', home: 'https://www.kimi.com/',
123
+ conversationUrl: id => `https://www.kimi.com/chat/${encodeURIComponent(id)}`,
124
+ whoamiScript,
122
125
  historyScript, detailScript, fallbackScript: domFallbackScript,
123
126
  })
@@ -1,6 +1,6 @@
1
- {
2
- "name": "dsh-chat-history",
3
- "version": "0.2.2",
4
- "opencli": ">=1.8.6",
5
- "description": "Full-history read adapters used by dsh-reference-anything"
6
- }
1
+ {
2
+ "name": "dsh-chat-history",
3
+ "version": "0.2.3",
4
+ "opencli": ">=1.8.6",
5
+ "description": "Full-history read adapters used by dsh-reference-anything"
6
+ }
@@ -1,8 +1,8 @@
1
- {
2
- "name": "opencli-plugin-dsh-chat-history",
3
- "version": "0.2.2",
4
- "type": "module",
5
- "peerDependencies": {
6
- "@jackwener/opencli": ">=1.8.6"
7
- }
8
- }
1
+ {
2
+ "name": "opencli-plugin-dsh-chat-history",
3
+ "version": "0.2.3",
4
+ "type": "module",
5
+ "peerDependencies": {
6
+ "@jackwener/opencli": ">=1.8.6"
7
+ }
8
+ }