dsh-fulltext 0.0.0-stage → 0.1.0

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,354 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>全文搜索报告 - {{QUERY}}</title>
7
+ <style>
8
+ {{STYLES}}
9
+ </style>
10
+ </head>
11
+ <body>
12
+
13
+ <script>
14
+ const SEARCH_QUERY = {{QUERY_JSON}};
15
+ const SEARCH_TERMS = SEARCH_QUERY.toLowerCase().split(/\s+/).filter(t => t.length > 2);
16
+ </script>
17
+
18
+ <!-- 主题切换器 -->
19
+ <div class="theme-switcher">
20
+ <button class="theme-toggle" title="切换主题">
21
+ <svg id="themeIcon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
22
+ <circle cx="12" cy="12" r="4"/>
23
+ <path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"/>
24
+ </svg>
25
+ </button>
26
+ <div class="theme-panel">
27
+ <button class="theme-btn active" data-theme="light" title="明亮"></button>
28
+ <button class="theme-btn" data-theme="sepia" title="护眼"></button>
29
+ <button class="theme-btn" data-theme="dark" title="深色"></button>
30
+ <button class="theme-btn" data-theme="green" title="自然"></button>
31
+ <button class="theme-btn" data-theme="pink" title="浪漫"></button>
32
+ <button class="theme-btn" data-theme="perplexity" title="Perplexity"></button>
33
+ </div>
34
+ </div>
35
+
36
+ <div class="container">
37
+
38
+ <!-- 报告头部 -->
39
+ <header class="report-header">
40
+ <div class="header-top">
41
+ <div class="header-brand">
42
+ <span class="brand-logo" aria-hidden="true"><svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 5v16m0-16C9 3 5 3 2 4v15c3-1 7-1 10 2 3-3 7-3 10-2V4c-3-1-7-1-10 1"/></svg></span>
43
+ <a href="https://ai4scholar.net/?src=dsh_fulltext" target="_blank" rel="noopener noreferrer" class="brand-name">Ai4Scholar</a>
44
+ </div>
45
+ <div class="header-links"><span class="header-text">Fulltext · DeepSeek Harness</span></div>
46
+ </div>
47
+ <h1 class="report-title">全文搜索报告</h1>
48
+ <p class="report-subtitle">在已索引论文的标题、摘要和正文中查找证据 · 原文片段检索</p>
49
+ </header>
50
+
51
+ <!-- 搜索参数卡片 -->
52
+ {{SEARCH_PARAMS_CARD}}
53
+
54
+ <!-- 搜索概况 -->
55
+ <div class="section-header">
56
+ <div class="section-icon">
57
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
58
+ <path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/>
59
+ <polyline points="14 2 14 8 20 8"/>
60
+ </svg>
61
+ </div>
62
+ <div>
63
+ <h2 class="section-title">搜索概况</h2>
64
+ </div>
65
+ </div>
66
+
67
+ <div class="summary-card">
68
+ <div class="summary-content">{{SUMMARY}}</div>
69
+ </div>
70
+
71
+ <!-- 匹配片段列表 -->
72
+ <div class="section-header">
73
+ <div class="section-icon">
74
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
75
+ <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/>
76
+ <path d="M14 2v4a2 2 0 0 0 2 2h4"/>
77
+ </svg>
78
+ </div>
79
+ <div>
80
+ <h2 class="section-title">匹配片段</h2>
81
+ <p class="section-subtitle">按相关度排序</p>
82
+ </div>
83
+ </div>
84
+
85
+ <!-- 筛选栏 -->
86
+ <div class="filter-bar">
87
+ <div class="filter-group">
88
+ <label>排序</label>
89
+ <select id="sortFilter" aria-label="排序">
90
+ <option value="relevance">默认(相关度)</option>
91
+ <option value="date-desc">日期(新→旧)</option>
92
+ <option value="date-asc">日期(旧→新)</option>
93
+ </select>
94
+ </div>
95
+ <div class="filter-group">
96
+ <label>来源类型</label>
97
+ <div class="filter-buttons" id="kindFilter">
98
+ <button class="filter-btn active" data-value="">全部</button>
99
+ <button class="filter-btn" data-value="title">标题</button>
100
+ <button class="filter-btn" data-value="abstract">摘要</button>
101
+ <button class="filter-btn" data-value="body">正文</button>
102
+ </div>
103
+ </div>
104
+ <div class="filter-group">
105
+ <label>年份</label>
106
+ <select id="yearFilter" aria-label="年份">
107
+ {{FILTER_YEARS}}
108
+ </select>
109
+ </div>
110
+ <div class="filter-group">
111
+ <label>期刊</label>
112
+ <select id="venueFilter" aria-label="期刊">
113
+ {{FILTER_VENUES}}
114
+ </select>
115
+ </div>
116
+ <div class="filter-group search-group">
117
+ <input type="text" id="textSearch" aria-label="在报告内搜索" placeholder="搜索...">
118
+ </div>
119
+ <div class="filter-stats">
120
+ <span id="visibleCount">0</span>/<span id="totalCount">0</span>
121
+ </div>
122
+ </div>
123
+ <p id="noMatches" hidden>没有匹配的片段,请放宽报告内筛选条件。</p>
124
+
125
+ <div class="snippets-grid" id="snippetsGrid">
126
+ {{SNIPPET_CARDS}}
127
+ </div>
128
+
129
+ <!-- 片段详情弹窗 -->
130
+ {{MODALS}}
131
+
132
+ <footer id="footer"><p class="footer-main">由 <a href="https://ai4scholar.net/?src=dsh_fulltext" target="_blank" rel="noopener noreferrer">Ai4Scholar</a> · dsh-fulltext 生成 · {{DATETIME}}</p><p class="footer-desc">数据来源:Semantic Scholar。片段不等同于可下载全文;覆盖范围以索引为准。</p></footer>
133
+
134
+ </div>
135
+
136
+ <!-- 主题切换脚本 -->
137
+ <script>
138
+ const themeIcons = {
139
+ light: '<circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"/>',
140
+ sepia: '<path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/>',
141
+ dark: '<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>',
142
+ green: '<path d="M7 20h10"/><path d="M10 20c5.5-2.5.8-6.4 3-10"/><path d="M9.5 9.4c1.1.8 1.8 2.2 2.3 3.7-2 .4-3.5.4-4.8-.3-1.2-.6-2.3-1.9-3-4.2 2.8-.5 4.4 0 5.5.8Z"/><path d="M14.1 6a7 7 0 0 0-1.1 4c1.9-.1 3.3-.6 4.3-1.4 1-1 1.6-2.3 1.7-4.6-2.7.1-4 1-4.9 2Z"/>',
143
+ pink: '<path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"/>',
144
+ perplexity: '<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/>'
145
+ };
146
+
147
+ let manualTheme = false;
148
+ function setTheme(theme, persist = false) {
149
+ document.documentElement.setAttribute('data-theme', theme === 'light' ? '' : theme);
150
+ if (persist) { manualTheme = true; try { localStorage.setItem('ai4s-fulltext-theme', theme); } catch {} }
151
+ document.getElementById('themeIcon').innerHTML = themeIcons[theme];
152
+ document.querySelectorAll('.theme-btn').forEach(btn => {
153
+ btn.classList.toggle('active', btn.dataset.theme === theme);
154
+ });
155
+ }
156
+
157
+ document.querySelectorAll('.theme-btn').forEach(btn => {
158
+ btn.addEventListener('click', () => setTheme(btn.dataset.theme, true));
159
+ });
160
+
161
+ (function() {
162
+ const media = matchMedia('(prefers-color-scheme: dark)');
163
+ let saved;
164
+ try { saved = localStorage.getItem('ai4s-fulltext-theme'); } catch {}
165
+ manualTheme = !!themeIcons[saved];
166
+ setTheme(manualTheme ? saved : media.matches ? 'dark' : 'light');
167
+ media.addEventListener?.('change', event => { if (!manualTheme) setTheme(event.matches ? 'dark' : 'light'); });
168
+ })();
169
+ </script>
170
+
171
+ <!-- 高亮脚本 -->
172
+ <script>
173
+ function highlightText(el) {
174
+ if (!SEARCH_TERMS.length) return;
175
+ const escaped = SEARCH_TERMS.slice(0, 20).map(t => t.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
176
+ const pattern = new RegExp('(' + escaped.join('|') + ')', 'gi');
177
+ const original = el.textContent;
178
+ const pieces = original.split(pattern);
179
+ el.replaceChildren(...pieces.map((piece, i) => {
180
+ if (!(i % 2)) return document.createTextNode(piece);
181
+ const mark = document.createElement('mark'); mark.textContent = piece; return mark;
182
+ }));
183
+ }
184
+ document.addEventListener('DOMContentLoaded', () => {
185
+ document.querySelectorAll('[data-highlight]').forEach(highlightText);
186
+ });
187
+ </script>
188
+
189
+ <!-- 弹窗脚本 -->
190
+ <script>
191
+ let returnFocus;
192
+ function openModal(id) { returnFocus = document.activeElement; const m = document.getElementById(id); m.classList.add('show'); m.querySelector('.close')?.focus(); }
193
+ function closeModal(id) { document.getElementById(id).classList.remove('show'); returnFocus?.focus(); }
194
+ window.onclick = e => { if (e.target.classList.contains('modal')) closeModal(e.target.id); };
195
+ document.addEventListener('keydown', e => {
196
+ if (e.key === 'Escape') document.querySelectorAll('.modal.show').forEach(m => closeModal(m.id));
197
+ });
198
+
199
+ function copyText(id, btn) {
200
+ const text = document.getElementById(id).innerText;
201
+
202
+ function showSuccess() {
203
+ btn.style.background = '#dcfce7';
204
+ btn.style.color = '#22c55e';
205
+ btn.innerHTML = '✓ 已复制';
206
+ setTimeout(() => {
207
+ btn.style.background = '';
208
+ btn.style.color = '';
209
+ btn.innerHTML = '复制';
210
+ }, 1500);
211
+ }
212
+
213
+ function fallbackCopy(text) {
214
+ const textArea = document.createElement('textarea');
215
+ textArea.value = text;
216
+ textArea.style.position = 'fixed';
217
+ textArea.style.left = '-9999px';
218
+ textArea.style.top = '-9999px';
219
+ document.body.appendChild(textArea);
220
+ textArea.focus();
221
+ textArea.select();
222
+ try {
223
+ const success = document.execCommand('copy');
224
+ if (success) {
225
+ showSuccess();
226
+ } else {
227
+ alert('复制失败,请手动复制');
228
+ }
229
+ } catch (err) {
230
+ console.error('复制失败:', err);
231
+ alert('复制失败,请手动复制');
232
+ } finally {
233
+ document.body.removeChild(textArea);
234
+ }
235
+ }
236
+
237
+ if (navigator.clipboard && window.isSecureContext) {
238
+ navigator.clipboard.writeText(text).then(showSuccess).catch(() => fallbackCopy(text));
239
+ } else {
240
+ fallbackCopy(text);
241
+ }
242
+ }
243
+ </script>
244
+
245
+ <script>
246
+ document.querySelectorAll('.snippet-card').forEach(card => card.addEventListener('keydown', e => {
247
+ if (e.target !== card || !['Enter', ' '].includes(e.key)) return; e.preventDefault(); card.click();
248
+ }));
249
+ document.addEventListener('keydown', e => {
250
+ if (e.key !== 'Tab') return; const modal = document.querySelector('.modal.show'); if (!modal) return;
251
+ const nodes = [...modal.querySelectorAll('a[href],button,[tabindex="0"]')];
252
+ const first = nodes[0], last = nodes[nodes.length - 1];
253
+ if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last?.focus(); }
254
+ else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first?.focus(); }
255
+ });
256
+ </script>
257
+ <!-- 筛选脚本 -->
258
+ <script>
259
+ (function() {
260
+ const grid = document.getElementById('snippetsGrid');
261
+ const cards = grid ? Array.from(grid.querySelectorAll('.snippet-card')) : [];
262
+ const visibleEl = document.getElementById('visibleCount');
263
+ const totalEl = document.getElementById('totalCount');
264
+
265
+ // 保存原始顺序
266
+ const originalOrder = cards.map((card, index) => ({ card, index }));
267
+
268
+ if (totalEl) totalEl.textContent = cards.length;
269
+ if (visibleEl) visibleEl.textContent = cards.length;
270
+
271
+ let filters = { kind: '', year: '', venue: '', text: '', sort: 'relevance' };
272
+
273
+ function sortCards() {
274
+ let sorted = [...originalOrder];
275
+
276
+ if (filters.sort === 'date-desc') {
277
+ sorted.sort((a, b) => {
278
+ const yearA = parseInt(a.card.dataset.year) || 0;
279
+ const yearB = parseInt(b.card.dataset.year) || 0;
280
+ return yearB - yearA;
281
+ });
282
+ } else if (filters.sort === 'date-asc') {
283
+ sorted.sort((a, b) => {
284
+ const yearA = parseInt(a.card.dataset.year) || 0;
285
+ const yearB = parseInt(b.card.dataset.year) || 0;
286
+ return yearA - yearB;
287
+ });
288
+ }
289
+ // relevance 保持原始顺序
290
+
291
+ // 重新排列 DOM 并更新编号
292
+ sorted.forEach((item, idx) => {
293
+ grid.appendChild(item.card);
294
+ // 更新卡片编号
295
+ const numEl = item.card.querySelector('.snippet-num');
296
+ if (numEl) numEl.textContent = `[${idx + 1}]`;
297
+ });
298
+ }
299
+
300
+ function apply() {
301
+ let count = 0;
302
+ cards.forEach(c => {
303
+ const match =
304
+ (!filters.kind || c.dataset.kind === filters.kind) &&
305
+ (!filters.year || c.dataset.year === filters.year) &&
306
+ (!filters.venue || c.dataset.venue === filters.venue) &&
307
+ (!filters.text || (c.dataset.title + c.dataset.text).toLowerCase().includes(filters.text.toLowerCase()));
308
+ c.style.display = match ? '' : 'none';
309
+ if (match) count++;
310
+ });
311
+ if (visibleEl) visibleEl.textContent = count;
312
+ document.getElementById('noMatches').hidden = count > 0;
313
+ }
314
+
315
+ // 排序选择
316
+ document.getElementById('sortFilter')?.addEventListener('change', function() {
317
+ filters.sort = this.value;
318
+ sortCards();
319
+ apply();
320
+ });
321
+
322
+ // 按钮筛选
323
+ document.querySelectorAll('#kindFilter .filter-btn').forEach(btn => {
324
+ btn.addEventListener('click', function() {
325
+ document.querySelectorAll('#kindFilter .filter-btn').forEach(b => b.classList.remove('active'));
326
+ this.classList.add('active');
327
+ filters.kind = this.dataset.value;
328
+ apply();
329
+ });
330
+ });
331
+
332
+ document.getElementById('yearFilter')?.addEventListener('change', function() {
333
+ filters.year = this.value;
334
+ apply();
335
+ });
336
+
337
+ document.getElementById('venueFilter')?.addEventListener('change', function() {
338
+ filters.venue = this.value;
339
+ apply();
340
+ });
341
+
342
+ let timer;
343
+ document.getElementById('textSearch')?.addEventListener('input', function() {
344
+ clearTimeout(timer);
345
+ timer = setTimeout(() => {
346
+ filters.text = this.value;
347
+ apply();
348
+ }, 200);
349
+ });
350
+ })();
351
+ </script>
352
+
353
+ </body>
354
+ </html>
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: fulltext
3
+ name: dsh-fulltext
@@ -0,0 +1,14 @@
1
+ import type { ReportEntry } from '../shared/types.js';
2
+ import type { Controller, State } from './controller.js';
3
+ export declare function Icon({ size }: {
4
+ size?: number;
5
+ }): import("react").JSX.Element;
6
+ export declare function reportUrl(report: ReportEntry, format: 'html' | 'csv', download?: boolean): string;
7
+ export declare function keyStatus(state: State): string;
8
+ export declare function Settings({ controller }: {
9
+ controller: Controller;
10
+ }): import("react").JSX.Element;
11
+ export declare function Workspace({ controller, handoff }: {
12
+ controller: Controller;
13
+ handoff(report: ReportEntry): Promise<'filled' | 'busy' | 'unavailable'>;
14
+ }): import("react").JSX.Element;
@@ -0,0 +1,57 @@
1
+ import type { ReportEntry, SearchInput } from '../shared/types.js';
2
+ import type { CredentialsPort } from './credentials-port.js';
3
+ export interface Catalog {
4
+ version: string;
5
+ configured: boolean;
6
+ keySource: 'own' | 'shared' | 'none';
7
+ keyRef: string;
8
+ defaultLimit: number;
9
+ reports: ReportEntry[];
10
+ }
11
+ export interface State {
12
+ catalog?: Catalog | undefined;
13
+ reports: ReportEntry[];
14
+ selected?: ReportEntry | undefined;
15
+ draft: SearchInput;
16
+ loading: boolean;
17
+ busy: boolean;
18
+ keyBusy: boolean;
19
+ error?: string | undefined;
20
+ message?: string | undefined;
21
+ }
22
+ type Reply<T> = {
23
+ ok: true;
24
+ value: T;
25
+ } | {
26
+ ok: false;
27
+ error: string;
28
+ };
29
+ export type Fetcher = <T>(path: string, signal: AbortSignal, body?: unknown) => Promise<Reply<T>>;
30
+ export declare const request: Fetcher;
31
+ /** Persistent in-memory UI state; saved reports themselves live on the host. */
32
+ export declare class Controller {
33
+ private readonly credentials;
34
+ private readonly fetcher;
35
+ private state;
36
+ private listeners;
37
+ private active;
38
+ private refreshRequest;
39
+ private first;
40
+ private disposed;
41
+ private revision;
42
+ constructor(credentials: () => CredentialsPort, fetcher?: Fetcher);
43
+ getSnapshot: () => State;
44
+ subscribe: (listener: () => void) => (() => void);
45
+ private set;
46
+ edit(patch: Partial<SearchInput>): void;
47
+ select(id: string): void;
48
+ newSearch(): void;
49
+ attach(): Promise<void>;
50
+ search(): Promise<void>;
51
+ cancel(): void;
52
+ notify(message: string): void;
53
+ saveKey(text: string): Promise<boolean>;
54
+ removeKey(): Promise<void>;
55
+ dispose(): void;
56
+ }
57
+ export {};
@@ -0,0 +1,94 @@
1
+ /**
2
+ * One credentials face over two incompatible dsh contracts.
3
+ *
4
+ * Why this exists: dsh moved the credentials domain in 0.1.2-alpha, and the two
5
+ * shapes overlap in nothing but the data they carry.
6
+ *
7
+ * ≤0.1.1-rc.2 (npm `latest`, and the hosted web app)
8
+ * ctx.get('connection').api.credentials
9
+ * describe({ refs: [ref] }) -> { result: { ok, value: { credentials: {…} } } }
10
+ * set({ ref, value }) unset({ ref }) event: credentials/updated
11
+ *
12
+ * ≥0.1.2-alpha (what DSH Desktop 2.0.4 bundles — alpha.1)
13
+ * ctx.get('remote.credentials')
14
+ * describe([ref]) -> { ok, value: { [ref]: view } }
15
+ * set(ref, value) unset(ref) event: credentials/reference-updated
16
+ *
17
+ * `ConnectionHandle.api` is simply gone in alpha, so the card built against rc.6
18
+ * read `undefined.credentials` on the desktop app and reported
19
+ * "保存失败: Cannot read properties of undefined (reading 'credentials')".
20
+ * The view payload is identical on both (configured / source? / writable), so
21
+ * only the call shape and the envelope need bridging.
22
+ *
23
+ * The alpha face is passed in already resolved, and this module never dots into
24
+ * `ctx.remote` to find it. `remote` is a cordis Service registering its
25
+ * sub-domains as flat store entries under dotted names, and reading `.credentials`
26
+ * off it goes through the traceable proxy, which rewrites the access into
27
+ * `Reflect.get(ctx, 'remote.credentials')` — a *guarded* context read. Without
28
+ * that exact name in `inject` the guard throws
29
+ * "cannot get property "remote.credentials" without inject", which is what the
30
+ * desktop app reported after the first fix. `ctx.get(name)` reads the same flat
31
+ * store with no inject requirement, returning undefined instead of throwing when
32
+ * the name is absent, so the caller resolves it that way.
33
+ *
34
+ * Resolved per call, never captured at apply() time, for two reasons:
35
+ * - which face exists is a property of the host, not of our plugin, and on the
36
+ * desktop app the answer is not the one the types promise;
37
+ * - the alternative — declaring `remote.credentials` in `inject` — would make
38
+ * cordis withhold apply() entirely on stable dsh, where that service does
39
+ * not exist (cordis 4.0.x has no optional inject: every declared name is
40
+ * required and checked). The card would vanish with no message at all, which
41
+ * is a worse failure than the one being fixed.
42
+ * @module dsh-ai4scholar/client/credentials-port
43
+ */
44
+ /** What both contracts report about a reference; identical payload on each. */
45
+ export interface CredentialView {
46
+ /** Whether the Host currently resolves a value. */
47
+ configured: boolean;
48
+ /** Winning source layer when configured; absent while unconfigured. */
49
+ source?: string;
50
+ /** Whether a write from here can affect the reference. */
51
+ writable: boolean;
52
+ }
53
+ /** The three calls the card makes, with the version differences already absorbed. */
54
+ export interface CredentialsPort {
55
+ /**
56
+ * @param ref - the reference to describe.
57
+ * @returns its view, or undefined when the Host knows nothing about it.
58
+ */
59
+ describe(ref: string): Promise<CredentialView | undefined>;
60
+ /**
61
+ * @param ref - the reference to write.
62
+ * @param value - the secret literal.
63
+ */
64
+ set(ref: string, value: string): Promise<void>;
65
+ /** @param ref - the reference to clear. */
66
+ unset(ref: string): Promise<void>;
67
+ }
68
+ /**
69
+ * Where a port comes from. The controller holds this, not a port, so a host that
70
+ * finishes wiring after apply() still works and a missing face is reported at
71
+ * the moment of the click rather than at boot.
72
+ */
73
+ export type CredentialsPortSource = () => CredentialsPort;
74
+ /** The two places a credentials face has lived, both optional at runtime. */
75
+ export interface CredentialsFaces {
76
+ /** `ctx.get('connection')` — carries `.api.credentials` up to 0.1.1-rc.2. */
77
+ connection?: unknown;
78
+ /**
79
+ * `ctx.get('remote.credentials')` from 0.1.2-alpha — the service itself, already
80
+ * resolved. Deliberately not `ctx.remote`: see the module note on why dotting
81
+ * into that proxy throws on the very host this face exists to support.
82
+ */
83
+ remoteCredentials?: unknown;
84
+ }
85
+ /**
86
+ * Pick the face this host actually has.
87
+ *
88
+ * The alpha face is preferred: a host carrying both is mid-migration, and the
89
+ * newer face is the one it will keep.
90
+ * @param faces - the two candidate faces, as resolved from the client context.
91
+ * @returns a port for whichever contract is present.
92
+ * @throws NoCredentialsFace when neither is.
93
+ */
94
+ export declare function resolveCredentialsPort(faces: CredentialsFaces): CredentialsPort;
@@ -0,0 +1,7 @@
1
+ import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client';
2
+ import type { ReportEntry } from '../shared/types.js';
3
+ type Outcome = 'filled' | 'busy' | 'unavailable';
4
+ export declare const reportPrompt: (report: ReportEntry) => string;
5
+ /** Use the native draft initializer when no Session has been selected yet. */
6
+ export declare function handoffReport(ctx: Pick<ClientContext, 'get'>, report: ReportEntry): Promise<Outcome>;
7
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client';
2
+ export declare const inject: string[];
3
+ export declare function apply(ctx: ClientContext): void;
@@ -0,0 +1 @@
1
+ export declare function installStyles(): () => void;
@@ -0,0 +1,59 @@
1
+ export declare const ROUTE = "/api/fulltext";
2
+ export declare const PANEL = "fulltext";
3
+ export declare const OWN_KEY = "FULLTEXT_API_KEY";
4
+ export declare const SHARED_KEY = "AI4SCHOLAR_API_KEY";
5
+ export interface SearchInput {
6
+ query: string;
7
+ limit: number;
8
+ year?: string;
9
+ fieldsOfStudy?: string;
10
+ venue?: string;
11
+ minCitationCount?: number | undefined;
12
+ enrich: boolean;
13
+ }
14
+ export interface Snippet {
15
+ id: string;
16
+ corpusId?: string;
17
+ paperId?: string;
18
+ title: string;
19
+ titleZh?: string;
20
+ authors: string[];
21
+ year?: number;
22
+ venue?: string;
23
+ url?: string;
24
+ pdfUrl?: string;
25
+ text: string;
26
+ kind: 'title' | 'abstract' | 'body' | 'unknown';
27
+ section?: string;
28
+ score?: number;
29
+ }
30
+ export interface Charge {
31
+ operation: 'search' | 'metadata';
32
+ charged?: number;
33
+ remaining?: number;
34
+ }
35
+ export interface Report {
36
+ id: string;
37
+ createdAt: string;
38
+ updatedAt: string;
39
+ input: SearchInput;
40
+ snippets: Snippet[];
41
+ summary?: string;
42
+ warnings: string[];
43
+ charges: Charge[];
44
+ }
45
+ export interface ReportEntry {
46
+ id: string;
47
+ query: string;
48
+ createdAt: string;
49
+ updatedAt: string;
50
+ count: number;
51
+ papers: number;
52
+ charged?: number;
53
+ }
54
+ export declare const isRecord: (v: unknown) => v is Record<string, unknown>;
55
+ export declare const safeUrl: (v: unknown) => string | undefined;
56
+ export declare const paperKey: (s: Snippet) => string;
57
+ export declare const paperCount: (r: Report) => number;
58
+ export declare const totalCharge: (r: Report) => number | undefined;
59
+ export declare const entryOf: (r: Report) => ReportEntry;