@kirkchinese/dsh-citeciter 0.4.3 → 0.6.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.
- package/README.md +65 -64
- package/README.zh.md +65 -64
- package/lib/client.js +32195 -2477
- package/lib/index.js +1300 -149
- package/lib/{typert-common-4_cbghYz.js → typert-common-C6yTitXx.js} +23 -3
- package/lib/typert.host.js +7 -3
- package/lib/typert.remote-client.js +2 -2
- package/lib/types/board.d.ts +237 -0
- package/lib/types/client/companion-controller.d.ts +15 -6
- package/lib/types/client/components/BlackboardWorkspace.d.ts +18 -0
- package/lib/types/client/components/BoardView.d.ts +12 -0
- package/lib/types/client/components/CiteCiterSettings.d.ts +12 -5
- package/lib/types/client/components/CitePanel.d.ts +14 -6
- package/lib/types/client/components/DocumentReader.d.ts +8 -0
- package/lib/types/client/components/QuestionCard.d.ts +2 -2
- package/lib/types/client/components/SelectionMenu.d.ts +14 -6
- package/lib/types/client/components/UpdateNotice.d.ts +14 -0
- package/lib/types/client/conversation-dom.d.ts +9 -1
- package/lib/types/client/copy.d.ts +6 -0
- package/lib/types/client/dock-geometry.d.ts +23 -0
- package/lib/types/client/entries.d.ts +61 -0
- package/lib/types/client/entry-ids.d.ts +3 -0
- package/lib/types/client/host-dock.d.ts +18 -0
- package/lib/types/client/hotkeys.d.ts +19 -0
- package/lib/types/client/reader-controller.d.ts +33 -0
- package/lib/types/client/reader-selection.d.ts +12 -0
- package/lib/types/client/request-guard.d.ts +24 -1
- package/lib/types/client/rich-content.d.ts +6 -0
- package/lib/types/client/selection.d.ts +5 -3
- package/lib/types/client/topic-presentation.d.ts +15 -0
- package/lib/types/client/types.d.ts +37 -2
- package/lib/types/client/update-controller.d.ts +59 -0
- package/lib/types/client/view-actions.d.ts +26 -0
- package/lib/types/documents.d.ts +45 -0
- package/lib/types/evidence-text.d.ts +29 -0
- package/lib/types/index.d.ts +14 -15
- package/lib/types/observer.d.ts +28 -2
- package/lib/types/service.d.ts +81 -0
- package/lib/types/topic-runtime.d.ts +305 -7
- package/lib/types/topic.d.ts +604 -43
- package/lib/types/typert-common.d.ts +279 -11
- package/lib/types/typert.host.d.ts +671 -34
- package/lib/types/typert.remote-client.d.ts +3 -0
- package/lib/types/update.d.ts +69 -0
- package/lib/update-C0K5ekMg.js +1073 -0
- package/package.json +87 -79
- package/lib/topic-BVNCaVbJ.js +0 -307
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** CiteCiter-owned accelerator parsing and listener installation. */
|
|
2
|
+
export interface Accelerator {
|
|
3
|
+
readonly modifiers: ReadonlySet<'Control' | 'Alt' | 'Shift' | 'Meta'>;
|
|
4
|
+
readonly key: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Parse a `Modifier+Modifier+Key` accelerator string.
|
|
8
|
+
* @param accelerator - user-configured accelerator, e.g. `Control+Shift+C`.
|
|
9
|
+
* @returns normalized modifiers and the final key, or null when malformed.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseAccelerator(accelerator: string): Accelerator | null;
|
|
12
|
+
/**
|
|
13
|
+
* Install a window-level keydown listener that reads the accelerator fresh on
|
|
14
|
+
* every keypress, so settings changes apply without re-registering.
|
|
15
|
+
* @param accelerator - current accelerator getter; an empty value disables the binding.
|
|
16
|
+
* @param handler - invoked once for each matching, non-editable, non-IME keypress.
|
|
17
|
+
* @returns disposer removing the listener.
|
|
18
|
+
*/
|
|
19
|
+
export declare function installDynamicAccelerator(accelerator: () => string | undefined, handler: () => void): () => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol';
|
|
2
|
+
import type { CiteCiterRequest, CiteCiterResponse, DocumentContent, DocumentSummary } from '../topic.ts';
|
|
3
|
+
import type { CompanionFace } from './companion-controller.ts';
|
|
4
|
+
import type { ReaderSelection } from './reader-selection.ts';
|
|
5
|
+
export type ReaderDocumentsStatus = 'idle' | 'loading' | 'ready' | 'error';
|
|
6
|
+
export interface ReaderSnapshot {
|
|
7
|
+
open: boolean;
|
|
8
|
+
documents: readonly DocumentSummary[];
|
|
9
|
+
documentsStatus: ReaderDocumentsStatus;
|
|
10
|
+
active: DocumentContent | null;
|
|
11
|
+
selection: ReaderSelection | null;
|
|
12
|
+
question: string;
|
|
13
|
+
creating: boolean;
|
|
14
|
+
error: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface ReaderFace {
|
|
17
|
+
getSnapshot(): ReaderSnapshot;
|
|
18
|
+
subscribe(listener: () => void): () => void;
|
|
19
|
+
setOpen(open: boolean): void;
|
|
20
|
+
refresh(): Promise<void>;
|
|
21
|
+
importFile(name: string, content: string): Promise<DocumentSummary | null>;
|
|
22
|
+
openDocument(documentId: string): Promise<void>;
|
|
23
|
+
setSelection(selection: ReaderSelection | null): void;
|
|
24
|
+
setQuestion(question: string): void;
|
|
25
|
+
createTopic(): Promise<void>;
|
|
26
|
+
dispose(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
type RemoteRequest = (request: CiteCiterRequest, signal: AbortSignal) => Promise<RemoteResult<CiteCiterResponse>>;
|
|
29
|
+
/** Initial Reader snapshot. */
|
|
30
|
+
export declare function createInitialReaderSnapshot(): ReaderSnapshot;
|
|
31
|
+
/** Bind the Reader store to the CiteCiter Remote and the companion Topic creator. */
|
|
32
|
+
export declare function createReaderController(request: RemoteRequest, companion: CompanionFace, store?: import("@deepseek-ai/dsh-client-store").SnapshotStore<ReaderSnapshot>): ReaderFace;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Reader textarea selection facts resolved from the user-owned textarea value. */
|
|
2
|
+
export interface ReaderSelection {
|
|
3
|
+
readonly displayText: string;
|
|
4
|
+
readonly prefixText: string;
|
|
5
|
+
readonly suffixText: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the current textarea selection into a verifiable document claim.
|
|
9
|
+
* @param textarea - read-only document textarea holding the complete loaded page.
|
|
10
|
+
* @returns trimmed quote with surrounding context, or null for a collapsed/empty selection.
|
|
11
|
+
*/
|
|
12
|
+
export declare function readTextareaSelection(textarea: HTMLTextAreaElement): ReaderSelection | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TopicScenario } from '../topic.ts';
|
|
1
2
|
import type { CiteSelection } from './types.ts';
|
|
2
3
|
export type CreateMode = 'observer' | 'exact-fork' | 'exact-when-available';
|
|
3
4
|
export interface RequestIntent {
|
|
@@ -11,7 +12,29 @@ export interface RequestIntent {
|
|
|
11
12
|
* @param mode - resolved Topic creation mode.
|
|
12
13
|
* @returns the pending intent key and request ID.
|
|
13
14
|
*/
|
|
14
|
-
export declare function claimCreateTopicIntent(selection: CiteSelection, question: string, mode: CreateMode): Promise<RequestIntent>;
|
|
15
|
+
export declare function claimCreateTopicIntent(selection: CiteSelection, question: string, mode: CreateMode, scenario?: TopicScenario): Promise<RequestIntent>;
|
|
16
|
+
/**
|
|
17
|
+
* Claim the retry-stable request ID for one uncited Topic creation.
|
|
18
|
+
* @param sourceSessionId - owning DSH Session.
|
|
19
|
+
* @param question - normalized first question.
|
|
20
|
+
* @param scenario - requested Topic presentation.
|
|
21
|
+
* @returns the pending intent key and request ID.
|
|
22
|
+
*/
|
|
23
|
+
export declare function claimCreateFreeTopicIntent(sourceSessionId: string, question: string, scenario: Extract<TopicScenario, 'qa' | 'present'>): Promise<RequestIntent>;
|
|
24
|
+
/** Document-range claim identity shared by the Reader entry point. */
|
|
25
|
+
export interface DocumentClaimIntent {
|
|
26
|
+
readonly documentId: string;
|
|
27
|
+
readonly displayText: string;
|
|
28
|
+
readonly prefixText: string;
|
|
29
|
+
readonly suffixText: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Claim the retry-stable request ID for one pending document Topic creation.
|
|
33
|
+
* @param claim - document identity and verified-looking quote context.
|
|
34
|
+
* @param question - normalized first question.
|
|
35
|
+
* @returns the pending intent key and request ID.
|
|
36
|
+
*/
|
|
37
|
+
export declare function claimCreateDocumentIntent(claim: DocumentClaimIntent, question: string): Promise<RequestIntent>;
|
|
15
38
|
/**
|
|
16
39
|
* Claim the retry-stable request ID for one pending Topic follow-up.
|
|
17
40
|
* @param topicSessionId - target private Topic Session.
|
|
@@ -18,6 +18,12 @@ export type RichSegment = {
|
|
|
18
18
|
readonly kind: 'html';
|
|
19
19
|
readonly document: string;
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Break CommonMark image openers without changing visible text or ordinary links.
|
|
23
|
+
* @param text - untrusted board Markdown or table source.
|
|
24
|
+
* @returns Markdown that cannot produce image nodes.
|
|
25
|
+
*/
|
|
26
|
+
export declare function neutralizeMarkdownImages(text: string): string;
|
|
21
27
|
/**
|
|
22
28
|
* Split complete safe rich fences from Markdown while preserving all prose.
|
|
23
29
|
* @param text - current assistant response text.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SessionId } from '@deepseek-ai/dsh-
|
|
1
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
2
2
|
import type { CiteSelection } from './types.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Resolve the current DOM selection into a CiteSelection.
|
|
@@ -9,14 +9,16 @@ import type { CiteSelection } from './types.ts';
|
|
|
9
9
|
*
|
|
10
10
|
* @param event - context-menu event whose pointer position anchors the menu.
|
|
11
11
|
* @param sourceSessionId - current session identity captured with the DOM range.
|
|
12
|
+
* @param committedAssistantText - DSH Session projection used when a collapsed reasoning row anchors the range.
|
|
12
13
|
* @returns validated selection metadata, or null when CiteCiter should ignore it.
|
|
13
14
|
*/
|
|
14
|
-
export declare function readSelection(event: MouseEvent, sourceSessionId: SessionId): CiteSelection | null;
|
|
15
|
+
export declare function readSelection(event: MouseEvent, sourceSessionId: SessionId, committedAssistantText?: string): CiteSelection | null;
|
|
15
16
|
/**
|
|
16
17
|
* Claim a context menu only after resolving a valid DSH assistant selection.
|
|
17
18
|
*
|
|
18
19
|
* @param event - context-menu event to validate and optionally cancel.
|
|
19
20
|
* @param sourceSessionId - current source session captured with the selection.
|
|
21
|
+
* @param committedAssistantText - DSH Session projection used when a collapsed reasoning row anchors the range.
|
|
20
22
|
* @returns validated selection metadata, or null while leaving the native menu untouched.
|
|
21
23
|
*/
|
|
22
|
-
export declare function claimSelectionContextMenu(event: MouseEvent, sourceSessionId: SessionId): CiteSelection | null;
|
|
24
|
+
export declare function claimSelectionContextMenu(event: MouseEvent, sourceSessionId: SessionId, committedAssistantText?: string): CiteSelection | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TopicMessage } from '../topic.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Append a requested board reference without replacing text the user already wrote.
|
|
4
|
+
* @param draft - current Topic composer draft.
|
|
5
|
+
* @param prompt - explicit board reference requested by the user.
|
|
6
|
+
* @returns the combined composer value.
|
|
7
|
+
*/
|
|
8
|
+
export declare function appendBoardCitation(draft: string, prompt: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Decide whether one Topic event belongs in the user-facing transcript.
|
|
11
|
+
* @param message - candidate projected Topic event.
|
|
12
|
+
* @param messages - complete ordered Topic transcript used to detect recovery.
|
|
13
|
+
* @returns whether the event should remain visible.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isTopicMessageVisible(message: TopicMessage, messages: readonly TopicMessage[]): boolean;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { SessionId } from '@deepseek-ai/dsh-
|
|
1
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
2
|
+
import type { ToolEvidenceProjection } from '../evidence-text.ts';
|
|
2
3
|
/** One right-click selection inside a rendered assistant model call. */
|
|
3
|
-
export interface
|
|
4
|
+
export interface AssistantCiteSelection {
|
|
5
|
+
readonly entryId: 'citeciter.entry.assistant';
|
|
4
6
|
readonly sourceSessionId: SessionId;
|
|
5
7
|
readonly displayText: string;
|
|
6
8
|
readonly sourceHintText?: string;
|
|
@@ -13,15 +15,37 @@ export interface CiteSelection {
|
|
|
13
15
|
readonly x: number;
|
|
14
16
|
readonly y: number;
|
|
15
17
|
}
|
|
18
|
+
/** One right-click whole-card selection on a committed tool result. */
|
|
19
|
+
export interface ToolCiteSelection {
|
|
20
|
+
readonly entryId: 'citeciter.entry.tool';
|
|
21
|
+
readonly sourceSessionId: SessionId;
|
|
22
|
+
readonly displayText: string;
|
|
23
|
+
readonly kind: 'tool-result';
|
|
24
|
+
readonly callId: string;
|
|
25
|
+
readonly projection: ToolEvidenceProjection;
|
|
26
|
+
readonly anchorKey: string;
|
|
27
|
+
readonly x: number;
|
|
28
|
+
readonly y: number;
|
|
29
|
+
}
|
|
30
|
+
/** One validated selection claimed by a CiteCiter client entry point. */
|
|
31
|
+
export type CiteSelection = AssistantCiteSelection | ToolCiteSelection;
|
|
32
|
+
/** One explicit request to append a blackboard reference to the Topic composer. */
|
|
33
|
+
export interface BoardCitationRequest {
|
|
34
|
+
readonly id: number;
|
|
35
|
+
readonly topicSessionId: string;
|
|
36
|
+
readonly prompt: string;
|
|
37
|
+
}
|
|
16
38
|
export interface CiteOverlaySnapshot {
|
|
17
39
|
readonly menuSelection: CiteSelection | null;
|
|
18
40
|
readonly panelOpen: boolean;
|
|
41
|
+
readonly boardCitation: BoardCitationRequest | null;
|
|
19
42
|
}
|
|
20
43
|
/** Tiny observable state shared by the selection popover and independent dock. */
|
|
21
44
|
export declare class CiteBus {
|
|
22
45
|
private readonly reportListenerError;
|
|
23
46
|
private snapshot;
|
|
24
47
|
private readonly listeners;
|
|
48
|
+
private nextCitationId;
|
|
25
49
|
/** @param reportListenerError - contains one failed browser subscriber. */
|
|
26
50
|
constructor(reportListenerError: (error: unknown) => void);
|
|
27
51
|
/** @returns stable overlay snapshot. */
|
|
@@ -32,5 +56,16 @@ export declare class CiteBus {
|
|
|
32
56
|
setMenuSelection(selection: CiteSelection | null): void;
|
|
33
57
|
/** Open or close the independent companion dock. */
|
|
34
58
|
setPanelOpen(panelOpen: boolean): void;
|
|
59
|
+
/**
|
|
60
|
+
* Queue one user-requested board reference for the matching Topic composer.
|
|
61
|
+
* @param topicSessionId - Topic that owns the referenced board.
|
|
62
|
+
* @param prompt - composer text derived from the selected board element.
|
|
63
|
+
*/
|
|
64
|
+
requestBoardCitation(topicSessionId: string, prompt: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Clear the citation only when the matching consumer handled it.
|
|
67
|
+
* @param id - monotonically assigned citation request identity.
|
|
68
|
+
*/
|
|
69
|
+
clearBoardCitation(id: number): void;
|
|
35
70
|
private notify;
|
|
36
71
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { SettingsScope } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
2
|
+
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
3
|
+
import type { CiteCiterSettings } from '../topic.ts';
|
|
4
|
+
type UpdateStorage = Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
|
|
5
|
+
/** One newer package version returned by the validated Host check. */
|
|
6
|
+
export interface AvailableUpdate {
|
|
7
|
+
readonly currentVersion: string;
|
|
8
|
+
readonly latestVersion: string;
|
|
9
|
+
readonly profile?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Observable state shared by the update card and settings page. */
|
|
12
|
+
export interface UpdateNoticeSnapshot {
|
|
13
|
+
available: AvailableUpdate | null;
|
|
14
|
+
checking: boolean;
|
|
15
|
+
copyStatus: 'idle' | 'copying' | 'copied' | 'error';
|
|
16
|
+
copyMessage: string | null;
|
|
17
|
+
notificationsEnabled: boolean;
|
|
18
|
+
preferenceReady: boolean;
|
|
19
|
+
preferencePersistence: 'host' | 'browser';
|
|
20
|
+
preferenceStatus: 'idle' | 'saving' | 'saved' | 'error';
|
|
21
|
+
preferenceMessage: string | null;
|
|
22
|
+
}
|
|
23
|
+
/** Initial root-scoped update-notice state. */
|
|
24
|
+
export declare const INITIAL_UPDATE_SNAPSHOT: UpdateNoticeSnapshot;
|
|
25
|
+
/** Browser APIs used by the update controller. */
|
|
26
|
+
export interface UpdateBrowserEnvironment {
|
|
27
|
+
readonly document: Pick<Document, 'visibilityState' | 'addEventListener' | 'removeEventListener'>;
|
|
28
|
+
readonly sessionStorage: UpdateStorage;
|
|
29
|
+
readonly localStorage: UpdateStorage;
|
|
30
|
+
readonly clipboard: Pick<Clipboard, 'writeText'> | undefined;
|
|
31
|
+
readonly now: () => number;
|
|
32
|
+
}
|
|
33
|
+
/** Operations exposed to the update notice and settings page. */
|
|
34
|
+
export interface UpdateController {
|
|
35
|
+
getSnapshot(): UpdateNoticeSnapshot;
|
|
36
|
+
subscribe(listener: () => void): () => void;
|
|
37
|
+
start(): Promise<void>;
|
|
38
|
+
copyUpdateCommand(): Promise<void>;
|
|
39
|
+
defer(): void;
|
|
40
|
+
setNotificationsEnabled(enabled: boolean): Promise<boolean>;
|
|
41
|
+
dispose(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
/** Read a newer validated version, or null when the installed version is current. */
|
|
44
|
+
export type CheckUpdate = (signal: AbortSignal) => Promise<AvailableUpdate | null>;
|
|
45
|
+
/** @returns browser services without letting denied storage or clipboard getters break plugin mount. */
|
|
46
|
+
export declare function createUpdateBrowserEnvironment(): UpdateBrowserEnvironment;
|
|
47
|
+
/**
|
|
48
|
+
* Own update discovery, deferral, copy feedback, and preference persistence.
|
|
49
|
+
* @param settings - existing CiteCiter settings namespace scope.
|
|
50
|
+
* @param checkUpdate - validated Host version check; it never installs software.
|
|
51
|
+
* @param store - root-scoped observable state owned by the client runtime.
|
|
52
|
+
* @param environment - browser APIs, injectable for deterministic tests.
|
|
53
|
+
* @param reportCheckError - diagnostic sink for silent automatic-check failures.
|
|
54
|
+
* @returns the root-scoped update controller.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createUpdateController(settings: SettingsScope<CiteCiterSettings>, checkUpdate: CheckUpdate, store: SnapshotStore<UpdateNoticeSnapshot>, environment?: UpdateBrowserEnvironment, reportCheckError?: (error: unknown) => void): UpdateController;
|
|
57
|
+
/** @param version - validated latest package version. @param profile - active Desktop profile, or Web default. @returns the command shown and copied by the notice. */
|
|
58
|
+
export declare function citeCiterUpdateCommand(version: string, profile?: string): string;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Plain UI callbacks; subscriptions and disposal remain with the Client plugin. */
|
|
2
|
+
import type { CompanionFace } from './companion-controller.ts';
|
|
3
|
+
import type { ReaderFace } from './reader-controller.ts';
|
|
4
|
+
import type { SettingsDocumentController } from './settings-document.ts';
|
|
5
|
+
import type { CiteBus } from './types.ts';
|
|
6
|
+
import type { UpdateController } from './update-controller.ts';
|
|
7
|
+
/** Callbacks the Topic view may invoke. */
|
|
8
|
+
export type CompanionActions = Omit<CompanionFace, 'getSnapshot' | 'subscribe' | 'dispose'>;
|
|
9
|
+
/** Callbacks the document view may invoke. */
|
|
10
|
+
export type ReaderActions = Omit<ReaderFace, 'getSnapshot' | 'subscribe' | 'dispose'>;
|
|
11
|
+
/** Callbacks the settings view may invoke. */
|
|
12
|
+
export type SettingsDocumentActions = Omit<SettingsDocumentController, 'getSnapshot' | 'subscribe' | 'dispose'>;
|
|
13
|
+
/** Callbacks the update view may invoke. */
|
|
14
|
+
export type UpdateActions = Omit<UpdateController, 'getSnapshot' | 'subscribe' | 'dispose'>;
|
|
15
|
+
/** Overlay events used by rendered components. */
|
|
16
|
+
export type OverlayActions = Pick<CiteBus, 'setMenuSelection' | 'setPanelOpen' | 'requestBoardCitation' | 'clearBoardCitation'>;
|
|
17
|
+
/**
|
|
18
|
+
* Remove lifecycle and subscription methods from a plain controller's view props.
|
|
19
|
+
* @param controller - Client-owned controller with arrow-function callbacks.
|
|
20
|
+
* @returns callbacks separate from the observable supplied to inject.hooks.
|
|
21
|
+
*/
|
|
22
|
+
export declare function viewActions<T extends {
|
|
23
|
+
getSnapshot(): unknown;
|
|
24
|
+
subscribe(listener: () => void): () => void;
|
|
25
|
+
dispose(): Promise<void>;
|
|
26
|
+
}>(controller: T): Omit<T, 'getSnapshot' | 'subscribe' | 'dispose'>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type DocumentContent, type DocumentFormat, type DocumentSummary } from './topic.ts';
|
|
2
|
+
/** Reader page budget keeps one document-get response comfortably bounded. */
|
|
3
|
+
export declare const DOCUMENT_CONTENT_MAX_BYTES: number;
|
|
4
|
+
interface DocumentRecordFile {
|
|
5
|
+
readonly schemaVersion: 1;
|
|
6
|
+
readonly documentId: string;
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly format: DocumentFormat;
|
|
9
|
+
readonly size: number;
|
|
10
|
+
readonly importedAt: number;
|
|
11
|
+
}
|
|
12
|
+
/** Validate and persist one imported text document under the private library. */
|
|
13
|
+
export declare class DocumentStore {
|
|
14
|
+
private readonly root;
|
|
15
|
+
/** @param root - private document library root. */
|
|
16
|
+
constructor(root?: string);
|
|
17
|
+
/**
|
|
18
|
+
* Persist one imported document and its normalized UTF-8 text.
|
|
19
|
+
* @param input - validated title, format, and content from the import boundary.
|
|
20
|
+
* @returns the durable document summary.
|
|
21
|
+
*/
|
|
22
|
+
import(input: {
|
|
23
|
+
readonly title: string;
|
|
24
|
+
readonly format: DocumentFormat;
|
|
25
|
+
readonly content: string;
|
|
26
|
+
}): Promise<DocumentSummary>;
|
|
27
|
+
/**
|
|
28
|
+
* Read one stored document record and its complete normalized text.
|
|
29
|
+
* @param documentId - private document identity.
|
|
30
|
+
* @returns the record and content pair.
|
|
31
|
+
*/
|
|
32
|
+
read(documentId: string): Promise<{
|
|
33
|
+
readonly record: DocumentRecordFile;
|
|
34
|
+
readonly content: string;
|
|
35
|
+
}>;
|
|
36
|
+
/** @returns all documents sorted by import time descending. */
|
|
37
|
+
list(): Promise<DocumentSummary[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Return one bounded Reader page.
|
|
40
|
+
* @param documentId - private document identity.
|
|
41
|
+
* @returns the first content window, truncated when the text exceeds the page budget.
|
|
42
|
+
*/
|
|
43
|
+
get(documentId: string): Promise<DocumentContent>;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Shared tool-evidence text projections used by Host validation and Client claims. */
|
|
2
|
+
/** Tool-result projection kinds carried by a tool EvidenceRef. */
|
|
3
|
+
export type ToolEvidenceProjection = 'result-text' | 'terminal' | 'diff';
|
|
4
|
+
/** One diff entry inside the opaque `tool/result.meta` written by dsh-tool-fs. */
|
|
5
|
+
export interface FileDiffMetaEntry {
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly oldText: string | null;
|
|
8
|
+
readonly newText: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Join the text blocks of one tool result into its citable projection.
|
|
12
|
+
* @param blocks - model-facing tool-result content blocks.
|
|
13
|
+
* @returns concatenated text blocks.
|
|
14
|
+
*/
|
|
15
|
+
export declare function projectToolResultText(blocks: readonly unknown[]): string;
|
|
16
|
+
/**
|
|
17
|
+
* Project one diff payload from a tool-result presentation meta.
|
|
18
|
+
* @param meta - opaque tool-result meta carrying an optional `diffs` array.
|
|
19
|
+
* @returns deterministic whole-card diff text, or null when no valid diff exists.
|
|
20
|
+
*/
|
|
21
|
+
export declare function projectDiffMeta(meta: unknown): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Resolve the citable whole-card projection for one tool result.
|
|
24
|
+
* @param projection - declared evidence projection kind.
|
|
25
|
+
* @param content - model-facing tool-result content blocks.
|
|
26
|
+
* @param meta - opaque presentation meta (diff payload for the diff projection).
|
|
27
|
+
* @returns projection text, or null when the payload cannot satisfy the kind.
|
|
28
|
+
*/
|
|
29
|
+
export declare function projectToolEvidence(projection: ToolEvidenceProjection, content: readonly unknown[], meta: unknown): string | null;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2,38 +2,37 @@
|
|
|
2
2
|
import { Service, type Context } from '@deepseek-ai/cordis';
|
|
3
3
|
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
4
4
|
import z from '@deepseek-ai/schemastery';
|
|
5
|
+
import { type UpdateCheckResponse } from './update.ts';
|
|
5
6
|
import { type CiteCiterRequest, type CiteCiterResponse } from './topic.ts';
|
|
6
7
|
/** Cordis/Typert package identity. */
|
|
7
8
|
export declare const name = "@kirkchinese/dsh-citeciter";
|
|
8
9
|
/** Services required by the private Topic runtime. */
|
|
9
10
|
export declare const inject: readonly ["llm", "sessionQuery", "subprocess"];
|
|
10
11
|
/** Host settings identity shared with the browser settings scope. */
|
|
11
|
-
export declare const CITECITER_SETTINGS_NS:
|
|
12
|
+
export declare const CITECITER_SETTINGS_NS: "citeciter";
|
|
12
13
|
/** Native settings schema for new Topics and the companion panel. */
|
|
13
|
-
export declare const CITECITER_SETTINGS_SCHEMA: z<
|
|
14
|
-
defaultMode: z<"observer" | "exact-when-available", "observer" | "exact-when-available">;
|
|
15
|
-
includeSourceReasoning: z<boolean, boolean>;
|
|
16
|
-
allowSourceFiles: z<boolean, boolean>;
|
|
17
|
-
panelWidthPercent: z<number, number>;
|
|
18
|
-
reopenLastTopic: z<boolean, boolean>;
|
|
19
|
-
}>, Schemastery.ObjectT<{
|
|
20
|
-
defaultMode: z<"observer" | "exact-when-available", "observer" | "exact-when-available">;
|
|
21
|
-
includeSourceReasoning: z<boolean, boolean>;
|
|
22
|
-
allowSourceFiles: z<boolean, boolean>;
|
|
23
|
-
panelWidthPercent: z<number, number>;
|
|
24
|
-
reopenLastTopic: z<boolean, boolean>;
|
|
25
|
-
}>>;
|
|
14
|
+
export declare const CITECITER_SETTINGS_SCHEMA: z<object>;
|
|
26
15
|
/** Root-scoped Remote service owning one isolated DSH runtime. */
|
|
27
16
|
export declare class CiteCiterHost extends TypertRemoteService {
|
|
28
17
|
static inject: readonly ["llm", "sessionQuery", "subprocess"];
|
|
29
18
|
private readonly topics;
|
|
19
|
+
private readonly updates;
|
|
20
|
+
private readonly service;
|
|
21
|
+
private releaseService;
|
|
30
22
|
constructor(ctx: Context);
|
|
31
23
|
/** Do not publish the Remote service until its private runtime is ready. */
|
|
32
24
|
[Service.init](): Promise<void>;
|
|
25
|
+
/** Resolve one create/ask command into a committed Topic snapshot. */
|
|
26
|
+
private topicSnapshot;
|
|
33
27
|
/** Validate and execute one strict Topic command. */
|
|
34
28
|
request(rawRequest: CiteCiterRequest, signal: AbortSignal): Promise<CiteCiterResponse>;
|
|
29
|
+
/** Check npm for an installable stable version without changing this installation. */
|
|
30
|
+
checkUpdate(signal: AbortSignal): Promise<UpdateCheckResponse>;
|
|
35
31
|
}
|
|
36
32
|
/** Register optional settings and mount the Host Remote service. */
|
|
37
33
|
export declare function apply(ctx: Context): Promise<void>;
|
|
38
|
-
export type {
|
|
34
|
+
export type { CiteCiterService } from './service.ts';
|
|
35
|
+
export { updateCheckErrorCodeSchema, updateCheckResponseSchema } from './update.ts';
|
|
36
|
+
export type { UpdateCheckErrorCode, UpdateCheckResponse } from './update.ts';
|
|
37
|
+
export type { CiteCiterRequest, CiteCiterResponse, CiteCiterSettings, CitationSelectionClaim, CitationDraft, CitationEntry, CitationEvidence, CitationRecord, DocumentContent, DocumentEvidenceClaim, DocumentFormat, DocumentSummary, ToolEvidenceClaim, TopicMode, TopicScenario, TopicSnapshot, TopicSummary, } from './topic.ts';
|
|
39
38
|
export default CiteCiterHost;
|
package/lib/types/observer.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
export { projectDiffMeta, projectToolEvidence, projectToolResultText, type ToolEvidenceProjection, } from './evidence-text.ts';
|
|
2
|
+
import type { SessionEvent, SessionHeader } from '@deepseek-ai/dsh-session';
|
|
3
|
+
import { type JsonValue } from '@deepseek-ai/dsh-util-values';
|
|
4
|
+
import { type CitationEvidence, type CitationSelectionClaim, type CitationDraft, type DocumentEvidenceClaim, type ToolEvidenceClaim } from './topic.ts';
|
|
3
5
|
/** One atomic live-preferred SessionQuery observation. */
|
|
4
6
|
export interface ObserverSourceSnapshot {
|
|
5
7
|
readonly session: Pick<SessionHeader, 'id' | 'cwd'>;
|
|
@@ -12,6 +14,14 @@ export interface ValidatedObserverCitation {
|
|
|
12
14
|
readonly assistantVisibleText: string;
|
|
13
15
|
readonly contentFingerprint: string;
|
|
14
16
|
}
|
|
17
|
+
/** One Host-verified tool-result evidence resolved from a browser claim. */
|
|
18
|
+
export interface ValidatedToolEvidence {
|
|
19
|
+
readonly evidence: CitationEvidence;
|
|
20
|
+
}
|
|
21
|
+
/** One Host-verified document-range evidence resolved against the stored text. */
|
|
22
|
+
export interface ValidatedDocumentEvidence {
|
|
23
|
+
readonly evidence: CitationEvidence;
|
|
24
|
+
}
|
|
15
25
|
/** Options for one bounded `read_source_session` result. */
|
|
16
26
|
export interface SourceReadOptions {
|
|
17
27
|
readonly fromSeq?: number;
|
|
@@ -35,6 +45,8 @@ export interface SourceReadResult {
|
|
|
35
45
|
}
|
|
36
46
|
/** Compute the SHA-256 identity carried by the current CitationDraft schema. */
|
|
37
47
|
export declare function fingerprintCitationDraft(draft: Omit<CitationDraft, 'selectionFingerprint'>): string;
|
|
48
|
+
/** Compute the SHA-256 identity of a canonical v4 Citation evidence record. */
|
|
49
|
+
export declare function fingerprintCitationRecord(record: CitationEvidence): string;
|
|
38
50
|
/** Resolve a browser selection claim against the authoritative committed assistant message. */
|
|
39
51
|
export declare function resolveObserverCitation(source: ObserverSourceSnapshot, rawClaim: CitationSelectionClaim): ValidatedObserverCitation;
|
|
40
52
|
/**
|
|
@@ -42,5 +54,19 @@ export declare function resolveObserverCitation(source: ObserverSourceSnapshot,
|
|
|
42
54
|
* A matching `assistant/message` is sufficient; its step and turn may remain open.
|
|
43
55
|
*/
|
|
44
56
|
export declare function validateObserverCitation(source: ObserverSourceSnapshot, rawDraft: CitationDraft): ValidatedObserverCitation;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve a whole-card tool-result claim against the committed `tool/result`.
|
|
59
|
+
* @param source - one atomic live-preferred SessionQuery observation.
|
|
60
|
+
* @param rawClaim - browser-submitted tool result identity, projection, and visible quote.
|
|
61
|
+
* @returns verified evidence with the full committed projection text.
|
|
62
|
+
*/
|
|
63
|
+
export declare function resolveToolEvidence(source: ObserverSourceSnapshot, rawClaim: ToolEvidenceClaim): ValidatedToolEvidence;
|
|
64
|
+
/**
|
|
65
|
+
* Re-resolve a Reader selection against the authoritative stored document text.
|
|
66
|
+
* @param content - complete normalized document text.
|
|
67
|
+
* @param rawClaim - browser-submitted document identity and visible quote context.
|
|
68
|
+
* @returns verified evidence with document offsets in its entry.
|
|
69
|
+
*/
|
|
70
|
+
export declare function resolveDocumentEvidence(content: string, rawClaim: DocumentEvidenceClaim): ValidatedDocumentEvidence;
|
|
45
71
|
/** Format one seq range without exposing chunks or exceeding the event-array byte budget. */
|
|
46
72
|
export declare function formatSourceSessionRead(source: ObserverSourceSnapshot, options: SourceReadOptions): SourceReadResult;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** Public CiteCiter host service face (`ctx.citeciterRuntime`; `ctx.citeciter` stays the Typert Remote service) for other DSH plugins. */
|
|
2
|
+
import type { CiteCiterRequest, CiteCiterResponse, TopicSnapshot, TopicSummary } from './topic.ts';
|
|
3
|
+
declare module '@deepseek-ai/cordis' {
|
|
4
|
+
interface Context {
|
|
5
|
+
citeciterRuntime?: CiteCiterService;
|
|
6
|
+
}
|
|
7
|
+
interface Events {
|
|
8
|
+
/**
|
|
9
|
+
* A new Topic committed its metadata and answered its first question.
|
|
10
|
+
* @param payload.topic - the durable Topic summary.
|
|
11
|
+
* @mode emit
|
|
12
|
+
*/
|
|
13
|
+
'citeciter/topic-created'(payload: {
|
|
14
|
+
topic: TopicSummary;
|
|
15
|
+
}): void;
|
|
16
|
+
/**
|
|
17
|
+
* An existing Topic committed a state change (follow-up, stop, rename,
|
|
18
|
+
* archive, or model route change).
|
|
19
|
+
* @param payload.topic - the durable Topic summary.
|
|
20
|
+
* @mode emit
|
|
21
|
+
*/
|
|
22
|
+
'citeciter/topic-updated'(payload: {
|
|
23
|
+
topic: TopicSummary;
|
|
24
|
+
}): void;
|
|
25
|
+
/**
|
|
26
|
+
* A Topic was logically deleted; physical owner cleanup may still be pending.
|
|
27
|
+
* @param payload - deleted Topic identity and independent cleanup outcome.
|
|
28
|
+
* @mode emit
|
|
29
|
+
*/
|
|
30
|
+
'citeciter/topic-deleted'(payload: Omit<Extract<CiteCiterResponse, {
|
|
31
|
+
kind: 'deleted';
|
|
32
|
+
}>, 'kind'>): void;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Command-style v1 host API: the same validated surface the browser Remote exposes. */
|
|
36
|
+
export interface CiteCiterService {
|
|
37
|
+
/**
|
|
38
|
+
* Create one source-bound Topic, with or without a validated evidence claim.
|
|
39
|
+
* @param request - strict source or evidence create command.
|
|
40
|
+
* @param signal - caller cancellation.
|
|
41
|
+
* @returns the committed Topic snapshot.
|
|
42
|
+
*/
|
|
43
|
+
create(request: Extract<CiteCiterRequest, {
|
|
44
|
+
action: 'create';
|
|
45
|
+
}>, signal?: AbortSignal): Promise<TopicSnapshot>;
|
|
46
|
+
/**
|
|
47
|
+
* Submit one follow-up question to a Topic.
|
|
48
|
+
* @param request - strict ask command.
|
|
49
|
+
* @param signal - caller cancellation.
|
|
50
|
+
* @returns the committed Topic snapshot.
|
|
51
|
+
*/
|
|
52
|
+
ask(request: Extract<CiteCiterRequest, {
|
|
53
|
+
action: 'ask';
|
|
54
|
+
}>, signal?: AbortSignal): Promise<TopicSnapshot>;
|
|
55
|
+
/**
|
|
56
|
+
* Read one Topic snapshot.
|
|
57
|
+
* @param topicSessionId - private Topic Session identity.
|
|
58
|
+
* @param signal - caller cancellation.
|
|
59
|
+
* @returns the current Topic snapshot.
|
|
60
|
+
*/
|
|
61
|
+
get(topicSessionId: string, signal?: AbortSignal): Promise<TopicSnapshot>;
|
|
62
|
+
/**
|
|
63
|
+
* List Topics grouped by their source session.
|
|
64
|
+
* @param sourceSessionId - source DSH Session identity.
|
|
65
|
+
* @param includeArchived - include archived Topics when true.
|
|
66
|
+
* @param signal - caller cancellation.
|
|
67
|
+
* @returns summaries sorted by update time descending.
|
|
68
|
+
*/
|
|
69
|
+
list(sourceSessionId: string, includeArchived?: boolean, signal?: AbortSignal): Promise<TopicSummary[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Permanently delete one Topic from CiteCiter's private JSONL store.
|
|
72
|
+
* @param request - strict delete command carrying the repeated target identity.
|
|
73
|
+
* @param signal - caller cancellation before logical deletion commits.
|
|
74
|
+
* @returns logical deletion identity and physical cleanup outcome.
|
|
75
|
+
*/
|
|
76
|
+
delete(request: Extract<CiteCiterRequest, {
|
|
77
|
+
action: 'delete';
|
|
78
|
+
}>, signal?: AbortSignal): Promise<Extract<CiteCiterResponse, {
|
|
79
|
+
kind: 'deleted';
|
|
80
|
+
}>>;
|
|
81
|
+
}
|