@kirkchinese/dsh-citeciter 0.8.2 → 0.9.0-alpha.2
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 +80 -30
- package/README.zh.md +78 -30
- package/lib/client.js +7539 -6260
- package/lib/index.js +921 -386
- package/lib/{typert-common-BMA9IB7p.js → typert-common-BQpqe5Ph.js} +24 -17
- package/lib/typert.host.js +9 -30
- package/lib/typert.remote-client.js +1 -1
- package/lib/types/actions.d.ts +10 -0
- package/lib/types/atomic-replace.d.ts +9 -0
- package/lib/types/board-capture-protocol.d.ts +45 -0
- package/lib/types/board-capture.d.ts +6 -1
- package/lib/types/board.d.ts +4 -4
- package/lib/types/citer-agent-registry.d.ts +2 -2
- package/lib/types/citer-session-access.d.ts +1 -1
- package/lib/types/client/action-controller.d.ts +2 -5
- package/lib/types/client/action-executor.d.ts +1 -1
- package/lib/types/client/board-capture-controller.d.ts +17 -0
- package/lib/types/client/citer-session-face.d.ts +17 -1
- package/lib/types/client/companion-controller.d.ts +17 -9
- package/lib/types/client/components/ActionWheel.d.ts +2 -4
- package/lib/types/client/components/BoardCaptureWorker.d.ts +7 -0
- package/lib/types/client/components/CitePanel.d.ts +6 -3
- package/lib/types/client/components/LearningExample.d.ts +5 -0
- package/lib/types/client/components/MessageImage.d.ts +8 -0
- package/lib/types/client/components/ToolMessage.d.ts +10 -0
- package/lib/types/client/components/TopicComposer.d.ts +1 -4
- package/lib/types/client/dock-geometry.d.ts +4 -2
- package/lib/types/client/draft-controller.d.ts +45 -0
- package/lib/types/client/draft-references.d.ts +4 -7
- package/lib/types/client/host-dock.d.ts +4 -2
- package/lib/types/client/host-icons.d.ts +13 -0
- package/lib/types/client/host-image-preview.d.ts +8 -0
- package/lib/types/client/host-ui-adapter.d.ts +24 -0
- package/lib/types/client/native-composer.d.ts +7 -3
- package/lib/types/client/native-document.d.ts +2 -8
- package/lib/types/client/prompt.d.ts +2 -0
- package/lib/types/client/selection-references.d.ts +4 -0
- package/lib/types/client/transcript-position.d.ts +2 -1
- package/lib/types/client/types.d.ts +2 -0
- package/lib/types/client/update-controller.d.ts +2 -2
- package/lib/types/document-access.d.ts +3 -0
- package/lib/types/document-tools.d.ts +10 -0
- package/lib/types/draft-contract.d.ts +98 -0
- package/lib/types/draft-store.d.ts +23 -0
- package/lib/types/host-agent-modules.d.ts +4 -2
- package/lib/types/host-settings-adapter.d.ts +11 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/types/learning-example.d.ts +53 -0
- package/lib/types/learning.d.ts +24 -3
- package/lib/types/message-projection.d.ts +15 -0
- package/lib/types/model-admission.d.ts +7 -0
- package/lib/types/native-session-contract.d.ts +1 -0
- package/lib/types/package-version.d.ts +9 -0
- package/lib/types/session-format-guard.d.ts +6 -0
- package/lib/types/source-storage.d.ts +3 -0
- package/lib/types/tool-events.d.ts +18 -0
- package/lib/types/topic-archive.d.ts +5 -0
- package/lib/types/topic-prompts.d.ts +5 -3
- package/lib/types/topic-runtime.d.ts +4 -2
- package/lib/types/topic.d.ts +204 -17
- package/lib/types/typert-codec.d.ts +13 -0
- package/lib/types/typert-common.d.ts +1165 -100
- package/lib/types/typert.host.d.ts +3271 -825
- package/lib/{update-BtuUBRbP.js → update-CRD1jFLf.js} +220 -50
- package/package.json +81 -77
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Isolated, disposable layout adapter for DSH
|
|
1
|
+
/** Isolated, disposable layout adapter for DSH alpha and legacy three-column frames. */
|
|
2
2
|
import { type RefObject } from 'react';
|
|
3
3
|
import { type DockGeometry } from './dock-geometry.ts';
|
|
4
4
|
/**
|
|
@@ -13,6 +13,8 @@ export declare function findContainingFrame(panel: HTMLElement | null): HTMLElem
|
|
|
13
13
|
* @param panel - mounted panel reference.
|
|
14
14
|
* @param open - whether space should be reserved.
|
|
15
15
|
* @param percent - user's preferred fraction of the content viewport.
|
|
16
|
+
* @param floating - whether the user detached the panel.
|
|
17
|
+
* @param activation - increases only on explicit Citer navigation, permitting return from details.
|
|
16
18
|
* @returns measured panel placement; null when the host frame is unsupported.
|
|
17
19
|
*/
|
|
18
|
-
export declare function useHostDock(panel: RefObject<HTMLElement | null>, open: boolean, percent: number, floating?: boolean): DockGeometry | null;
|
|
20
|
+
export declare function useHostDock(panel: RefObject<HTMLElement | null>, open: boolean, percent: number, floating?: boolean, activation?: number): DockGeometry | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
type Icon = ComponentType<{
|
|
3
|
+
size?: number;
|
|
4
|
+
className?: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const IconSettingsOutlineMedium: Icon;
|
|
7
|
+
export declare const IconQuestionOutlineMedium: Icon;
|
|
8
|
+
export declare const IconSparkleMedium: Icon;
|
|
9
|
+
export declare const IconDownloadOutlineMedium: Icon;
|
|
10
|
+
export declare const IconThinkOutlineMedium: Icon;
|
|
11
|
+
export declare const IconStopFillMedium: Icon;
|
|
12
|
+
export declare const IconArchiveOutlineMedium: Icon;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface PreviewProps {
|
|
2
|
+
readonly src: string;
|
|
3
|
+
readonly alt: string;
|
|
4
|
+
readonly onClose: () => void;
|
|
5
|
+
}
|
|
6
|
+
/** Preview an existing authorized object URL in the host UI; the caller retains URL ownership. */
|
|
7
|
+
export declare function HostImagePreview({ src, alt, onClose }: PreviewProps): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store';
|
|
3
|
+
import type { SettingsDescribeFace } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
4
|
+
import type { SessionPendingInteraction } from '@deepseek-ai/dsh-client-ui-session/client';
|
|
5
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
6
|
+
/** Stable preference operations shared by SettingsScope (0.1.5) and ConfigForm (0.1.7). */
|
|
7
|
+
export interface SettingsForm<T> extends ObservableSnapshot<{
|
|
8
|
+
value: T | undefined;
|
|
9
|
+
status: 'loading' | 'ready' | 'unavailable';
|
|
10
|
+
mode: 'host' | 'memory';
|
|
11
|
+
}> {
|
|
12
|
+
set(field: string, value: unknown): Promise<void>;
|
|
13
|
+
unset(field: string): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
interface ModernForms {
|
|
16
|
+
get<T>(namespace: string): SettingsForm<T>;
|
|
17
|
+
describe(): SettingsDescribeFace;
|
|
18
|
+
}
|
|
19
|
+
/** Call only public preference services. The selected service owns binding teardown. */
|
|
20
|
+
export declare function hostSettings(ctx: Context): ModernForms;
|
|
21
|
+
export type InteractionSnapshot = ReadonlyMap<SessionId, SessionPendingInteraction>;
|
|
22
|
+
/** Normalize the renamed UI status source without creating another approval authority. */
|
|
23
|
+
export declare function hostInteractions(ctx: Context): ObservableSnapshot<InteractionSnapshot>;
|
|
24
|
+
export {};
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import type { ComposerAttachment, DraftAttachmentId, DraftFileUploads } from '@deepseek-ai/dsh-client-ui-conversation/client';
|
|
3
3
|
import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store';
|
|
4
|
-
import type { SessionFace
|
|
4
|
+
import type { SessionFace } from '@deepseek-ai/dsh-api-session-controller/client';
|
|
5
|
+
import { type CiterSessionSnapshot } from './citer-session-face.ts';
|
|
5
6
|
export type DeliveryMode = 'queue' | 'steer';
|
|
7
|
+
/** A lost transport response is not proof that the host rejected a submission. */
|
|
8
|
+
export declare class UncertainSubmissionError extends Error {
|
|
9
|
+
}
|
|
6
10
|
export interface NativeComposer {
|
|
7
11
|
readonly uploads: ObservableSnapshot<DraftFileUploads>;
|
|
8
12
|
retry(sessionId: string, id: DraftAttachmentId): void;
|
|
9
|
-
watch(sessionId: string, listener: (snapshot:
|
|
13
|
+
watch(sessionId: string, listener: (snapshot: CiterSessionSnapshot) => void): () => void;
|
|
10
14
|
queue(sessionId: string, id: Parameters<SessionFace['updateQueue']>[0], action: Parameters<SessionFace['updateQueue']>[1]): Promise<void>;
|
|
11
15
|
/** Read an image or file through its owning Session's attachment authorization. */
|
|
12
16
|
attachment(sessionId: string, id: string): Promise<Blob>;
|
|
13
17
|
add(sessionId: string, files: readonly File[]): Promise<readonly ComposerAttachment[]>;
|
|
14
18
|
remove(id: DraftAttachmentId): void;
|
|
15
|
-
send(sessionId: string, text: string, attachments: readonly DraftAttachmentId[], mode: DeliveryMode): Promise<void>;
|
|
19
|
+
send(sessionId: string, text: string, attachments: readonly DraftAttachmentId[], mode: DeliveryMode, requestId?: string): Promise<void>;
|
|
16
20
|
}
|
|
17
21
|
/** Adapt the installed conversation service's published composer methods; never reach its private input machine. */
|
|
18
22
|
export declare function createNativeComposer(ctx: Context): NativeComposer;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { ActionSource } from './action-controller.ts';
|
|
2
2
|
import type { ReaderSelection } from './reader-selection.ts';
|
|
3
|
+
import type { DocumentPreviewProps } from '@deepseek-ai/dsh-client-ui-sidebar-documentpreview/client';
|
|
3
4
|
/** Decode a complete Host-owned preview buffer. Reject binary, partial and oversized imports. */
|
|
4
|
-
export declare function decodeNativeText(content:
|
|
5
|
-
readonly kind: 'text';
|
|
6
|
-
readonly text: string;
|
|
7
|
-
readonly eof: boolean;
|
|
8
|
-
} | {
|
|
9
|
-
readonly kind: 'bytes';
|
|
10
|
-
readonly data: Uint8Array;
|
|
11
|
-
}): string;
|
|
5
|
+
export declare function decodeNativeText(content: DocumentPreviewProps['content']): string;
|
|
12
6
|
/** Capture the file address's own Session and immutable text, never the later active tab. */
|
|
13
7
|
export declare function nativeDocumentSource(address: string, content: string, selection: ReaderSelection): ActionSource;
|
|
@@ -10,6 +10,8 @@ export interface ParsedNextQuestions {
|
|
|
10
10
|
* prose. System Tutor and Citation Context travel through their own layers.
|
|
11
11
|
*/
|
|
12
12
|
export declare function normalizeQuestion(rawQuestion: string): string;
|
|
13
|
+
/** Creation may prepare an empty composer; length limits apply before any request. */
|
|
14
|
+
export declare function normalizeDraftQuestion(rawQuestion: string): string;
|
|
13
15
|
/**
|
|
14
16
|
* Parse optional follow-up control text without exposing complete or partial markers.
|
|
15
17
|
* @param text - accumulated assistant text.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ActionSource } from './action-controller.ts';
|
|
2
|
+
import type { DraftReference } from './draft-references.ts';
|
|
3
|
+
/** Capture an actual selected passage and its address; never reconstruct a citation from Topic metadata. */
|
|
4
|
+
export declare function selectionReferences(source: ActionSource, documentId?: string): readonly DraftReference[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type UIEvent } from 'react';
|
|
2
|
-
/** Keep each Topic's reading position across portal moves, view changes and close/reopen. Follow new output only while the reader is near the end. */
|
|
2
|
+
/** Keep each Topic's reading position across portal moves, image loading, view changes and close/reopen. Follow new output only while the reader is near the end. */
|
|
3
3
|
export declare function useTranscriptPosition(topicId: string, revision: unknown): {
|
|
4
4
|
ref: (node: HTMLDivElement | null) => void;
|
|
5
5
|
onScroll: (event: UIEvent<HTMLDivElement>) => void;
|
|
6
|
+
followLatest: () => void;
|
|
6
7
|
};
|
|
@@ -38,6 +38,8 @@ export interface BoardCitationRequest {
|
|
|
38
38
|
}
|
|
39
39
|
export interface CiteOverlaySnapshot {
|
|
40
40
|
readonly panelOpen: boolean;
|
|
41
|
+
/** Explicit navigation request, including reopening a temporarily covered panel. */
|
|
42
|
+
readonly activation: number;
|
|
41
43
|
readonly presentation: PanelPresentation;
|
|
42
44
|
readonly boardCitation: BoardCitationRequest | null;
|
|
43
45
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SettingsForm as ConfigForm } from './host-ui-adapter.ts';
|
|
2
2
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
3
3
|
import type { CiteCiterSettings } from '../topic.ts';
|
|
4
4
|
type UpdateStorage = Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
|
|
@@ -53,7 +53,7 @@ export declare function createUpdateBrowserEnvironment(): UpdateBrowserEnvironme
|
|
|
53
53
|
* @param reportCheckError - diagnostic sink for silent automatic-check failures.
|
|
54
54
|
* @returns the root-scoped update controller.
|
|
55
55
|
*/
|
|
56
|
-
export declare function createUpdateController(settings:
|
|
56
|
+
export declare function createUpdateController(settings: ConfigForm<CiteCiterSettings>, checkUpdate: CheckUpdate, store: SnapshotStore<UpdateNoticeSnapshot>, environment?: UpdateBrowserEnvironment, reportCheckError?: (error: unknown) => void): UpdateController;
|
|
57
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
58
|
export declare function citeCiterUpdateCommand(version: string, profile?: string): string;
|
|
59
59
|
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Session } from '@deepseek-ai/dsh-session';
|
|
2
|
+
/** Resolve one document from durable user submissions. Draft metadata grants no native Topic access. */
|
|
3
|
+
export declare function resolveReadableDocument(session: Session | undefined, hosted: boolean, initial: string | null, requested?: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Session } from '@deepseek-ai/dsh-session';
|
|
2
|
+
/** Read an immutable document only after checking the requesting Session's submitted attachments. The caller owns authorization and storage; tools own ranges, output budgets and model-visible guidance. */
|
|
3
|
+
export type AuthorizedDocumentReader = (requested: string | undefined, session: Session | undefined) => Promise<{
|
|
4
|
+
readonly documentId: string;
|
|
5
|
+
readonly content: string;
|
|
6
|
+
}>;
|
|
7
|
+
/** Build a bounded document reader. Offsets and documentLength count UTF-16 code units, while bytesUsed measures the UTF-8 response text. Invalid ranges remain errors; they are never silently clamped. */
|
|
8
|
+
export declare function createDocumentReadTool(read: AuthorizedDocumentReader): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
9
|
+
/** Build document search independently of Topic lifecycle. Returns the document horizon so the model can expand a match without inventing an out-of-range endpoint. */
|
|
10
|
+
export declare function createDocumentSearchTool(read: AuthorizedDocumentReader): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Persisted drafts are user work, never model input until explicitly submitted. */
|
|
3
|
+
export declare const draftReferenceSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
kind: z.ZodEnum<{
|
|
6
|
+
source: "source";
|
|
7
|
+
excerpt: "excerpt";
|
|
8
|
+
board: "board";
|
|
9
|
+
}>;
|
|
10
|
+
label: z.ZodString;
|
|
11
|
+
content: z.ZodString;
|
|
12
|
+
address: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export declare const draftFileSchema: z.ZodObject<{
|
|
15
|
+
id: z.ZodUUID;
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
type: z.ZodString;
|
|
18
|
+
size: z.ZodNumber;
|
|
19
|
+
lastModified: z.ZodNumber;
|
|
20
|
+
}, z.core.$strict>;
|
|
21
|
+
export declare const draftContentSchema: z.ZodObject<{
|
|
22
|
+
text: z.ZodString;
|
|
23
|
+
references: z.ZodArray<z.ZodObject<{
|
|
24
|
+
id: z.ZodString;
|
|
25
|
+
kind: z.ZodEnum<{
|
|
26
|
+
source: "source";
|
|
27
|
+
excerpt: "excerpt";
|
|
28
|
+
board: "board";
|
|
29
|
+
}>;
|
|
30
|
+
label: z.ZodString;
|
|
31
|
+
content: z.ZodString;
|
|
32
|
+
address: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}, z.core.$strict>>;
|
|
34
|
+
files: z.ZodArray<z.ZodObject<{
|
|
35
|
+
id: z.ZodUUID;
|
|
36
|
+
name: z.ZodString;
|
|
37
|
+
type: z.ZodString;
|
|
38
|
+
size: z.ZodNumber;
|
|
39
|
+
lastModified: z.ZodNumber;
|
|
40
|
+
}, z.core.$strict>>;
|
|
41
|
+
}, z.core.$strict>;
|
|
42
|
+
export declare const draftStateSchema: z.ZodObject<{
|
|
43
|
+
version: z.ZodLiteral<1>;
|
|
44
|
+
revision: z.ZodNumber;
|
|
45
|
+
content: z.ZodObject<{
|
|
46
|
+
text: z.ZodString;
|
|
47
|
+
references: z.ZodArray<z.ZodObject<{
|
|
48
|
+
id: z.ZodString;
|
|
49
|
+
kind: z.ZodEnum<{
|
|
50
|
+
source: "source";
|
|
51
|
+
excerpt: "excerpt";
|
|
52
|
+
board: "board";
|
|
53
|
+
}>;
|
|
54
|
+
label: z.ZodString;
|
|
55
|
+
content: z.ZodString;
|
|
56
|
+
address: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strict>>;
|
|
58
|
+
files: z.ZodArray<z.ZodObject<{
|
|
59
|
+
id: z.ZodUUID;
|
|
60
|
+
name: z.ZodString;
|
|
61
|
+
type: z.ZodString;
|
|
62
|
+
size: z.ZodNumber;
|
|
63
|
+
lastModified: z.ZodNumber;
|
|
64
|
+
}, z.core.$strict>>;
|
|
65
|
+
}, z.core.$strict>;
|
|
66
|
+
pending: z.ZodNullable<z.ZodObject<{
|
|
67
|
+
requestId: z.ZodUUID;
|
|
68
|
+
content: z.ZodObject<{
|
|
69
|
+
text: z.ZodString;
|
|
70
|
+
references: z.ZodArray<z.ZodObject<{
|
|
71
|
+
id: z.ZodString;
|
|
72
|
+
kind: z.ZodEnum<{
|
|
73
|
+
source: "source";
|
|
74
|
+
excerpt: "excerpt";
|
|
75
|
+
board: "board";
|
|
76
|
+
}>;
|
|
77
|
+
label: z.ZodString;
|
|
78
|
+
content: z.ZodString;
|
|
79
|
+
address: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}, z.core.$strict>>;
|
|
81
|
+
files: z.ZodArray<z.ZodObject<{
|
|
82
|
+
id: z.ZodUUID;
|
|
83
|
+
name: z.ZodString;
|
|
84
|
+
type: z.ZodString;
|
|
85
|
+
size: z.ZodNumber;
|
|
86
|
+
lastModified: z.ZodNumber;
|
|
87
|
+
}, z.core.$strict>>;
|
|
88
|
+
}, z.core.$strict>;
|
|
89
|
+
}, z.core.$strict>>;
|
|
90
|
+
}, z.core.$strict>;
|
|
91
|
+
export type DraftContent = z.infer<typeof draftContentSchema>;
|
|
92
|
+
export type DraftState = z.infer<typeof draftStateSchema>;
|
|
93
|
+
export type DraftFile = z.infer<typeof draftFileSchema>;
|
|
94
|
+
export declare const EMPTY_DRAFT: DraftContent;
|
|
95
|
+
export declare const EMPTY_DRAFT_STATE: DraftState;
|
|
96
|
+
export declare const DRAFT_CHUNK_BYTES: number;
|
|
97
|
+
/** Remove only the acknowledged submission, preserving edits made while it was pending. */
|
|
98
|
+
export declare function subtractSubmitted(current: DraftContent, submitted: DraftContent): DraftContent;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type DraftFile, type DraftState } from './draft-contract.ts';
|
|
2
|
+
/** Caller serializes with Topic deletion and supplies an ownership-verified Topic directory. No model log is touched. */
|
|
3
|
+
export declare class DraftStore {
|
|
4
|
+
private readonly topicDirectory;
|
|
5
|
+
constructor(topicDirectory: string);
|
|
6
|
+
private directory;
|
|
7
|
+
private file;
|
|
8
|
+
/** Read validated state. Missing drafts are empty; malformed drafts remain on disk and surface an error. */
|
|
9
|
+
read(): Promise<DraftState>;
|
|
10
|
+
/** Compare-and-swap state; conflict returns the authoritative draft without overwriting either client's input. */
|
|
11
|
+
save(expected: number, next: Omit<DraftState, 'revision'>): Promise<{
|
|
12
|
+
state: DraftState;
|
|
13
|
+
conflict: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
/** Reconcile an exact native admission receipt after a lost response or restart. */
|
|
16
|
+
acknowledge(state: DraftState): Promise<DraftState>;
|
|
17
|
+
/** Sequential bounded upload. Repeated identical chunks are safe after a lost response. */
|
|
18
|
+
put(meta: DraftFile, offset: number, data: string): Promise<void>;
|
|
19
|
+
/** Read only an attachment referenced by this exact saved draft, never an arbitrary path. */
|
|
20
|
+
chunk(id: string, offset: number): Promise<string>;
|
|
21
|
+
/** Delete only the verified draft subtree after the Topic is retired. */
|
|
22
|
+
remove(): Promise<void>;
|
|
23
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import type AgentLoop from '@deepseek-ai/dsh-agent-loop';
|
|
3
3
|
import type SessionStore from '@deepseek-ai/dsh-session';
|
|
4
|
+
import type SessionTitleService from '@deepseek-ai/dsh-session-title';
|
|
4
5
|
interface HostScope {
|
|
5
6
|
readonly ctx: Context;
|
|
6
7
|
dispose(): Promise<void>;
|
|
@@ -8,13 +9,14 @@ interface HostScope {
|
|
|
8
9
|
export interface HostAgentModules {
|
|
9
10
|
readonly AgentLoop: typeof AgentLoop;
|
|
10
11
|
readonly SessionStore: typeof SessionStore;
|
|
12
|
+
readonly SessionTitleService: typeof SessionTitleService;
|
|
11
13
|
readonly createScope: (ctx: Context, key: object) => HostScope;
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
16
|
* Resolve runtime modules from the host installation, not the plugin's dependencies.
|
|
15
17
|
* CLI argv can name an npm/pnpm symlink; canonicalize it before walking node_modules.
|
|
16
|
-
* Desktop
|
|
17
|
-
* @returns the host's AgentLoop, SessionStore and scope factory.
|
|
18
|
+
* Desktop accepts app.asar and unpacked app layouts without canonicalizing virtual paths.
|
|
19
|
+
* @returns the host's AgentLoop, SessionStore, title service and scope factory.
|
|
18
20
|
* @throws when the launcher cannot be located or its runtime exports are unavailable.
|
|
19
21
|
*/
|
|
20
22
|
export declare function loadHostAgentModules(): Promise<HostAgentModules>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type z from '@deepseek-ai/schemastery';
|
|
3
|
+
import { type CiteCiterSettings } from './topic.ts';
|
|
4
|
+
/** The 0.1.7 Cordis configuration reader. Old hosts pass no reader. */
|
|
5
|
+
export interface SettingsReader {
|
|
6
|
+
get(): unknown;
|
|
7
|
+
}
|
|
8
|
+
/** Choose the schema mode without importing a Cordis export absent in Desktop's SDK. */
|
|
9
|
+
export declare function settingsConfig(schema: z<object>): z<object>;
|
|
10
|
+
/** Bind settings through the public contract of the installed host; registrations belong to ctx. */
|
|
11
|
+
export declare function bindHostSettings(ctx: Context, schema: z<object>, config?: SettingsReader): () => CiteCiterSettings;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Host entry for native Topics, legacy compatibility and the browser Remote API. */
|
|
2
2
|
import { Service, type Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import { type SettingsReader } from './host-settings-adapter.ts';
|
|
3
4
|
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
4
5
|
import z from '@deepseek-ai/schemastery';
|
|
5
6
|
import { type UpdateCheckResponse } from './update.ts';
|
|
@@ -15,11 +16,12 @@ export declare const CITECITER_SETTINGS_SCHEMA: z<object>;
|
|
|
15
16
|
/** Root-scoped Remote service owning Topic metadata, native contributions and a legacy runtime. */
|
|
16
17
|
export declare class CiteCiterHost extends TypertRemoteService {
|
|
17
18
|
static inject: readonly ["llm", "sessionQuery", "subprocess", "agents", "agentPresets", "sessionController", "systemPrompt", "tools", "sandboxPolicy", "sessions", "sessionPersistence", "sessionTitle", "attachments"];
|
|
19
|
+
static Config: z<object>;
|
|
18
20
|
private readonly topics;
|
|
19
21
|
private readonly updates;
|
|
20
22
|
private readonly service;
|
|
21
23
|
private releaseService;
|
|
22
|
-
constructor(ctx: Context);
|
|
24
|
+
constructor(ctx: Context, config?: SettingsReader);
|
|
23
25
|
/** Do not publish the Remote service until its private runtime is ready. */
|
|
24
26
|
[Service.init](): Promise<void>;
|
|
25
27
|
/** Resolve one create/ask command into a committed Topic snapshot. */
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const learningExampleSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
|
+
kind: z.ZodLiteral<"text">;
|
|
4
|
+
content: z.ZodString;
|
|
5
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
6
|
+
kind: z.ZodLiteral<"code">;
|
|
7
|
+
content: z.ZodString;
|
|
8
|
+
language: z.ZodString;
|
|
9
|
+
}, z.core.$strict>], "kind">;
|
|
10
|
+
export type LearningExample = z.infer<typeof learningExampleSchema>;
|
|
11
|
+
/** Native DSH tool schema; kept beside the validator to expose the same tagged contract. */
|
|
12
|
+
export declare const LEARNING_EXAMPLE_PARAMETER: {
|
|
13
|
+
readonly required: true;
|
|
14
|
+
readonly description: "Choose text for prose or code for literal source code.";
|
|
15
|
+
readonly oneOf: readonly [{
|
|
16
|
+
readonly type: "object";
|
|
17
|
+
readonly additionalProperties: false;
|
|
18
|
+
readonly properties: {
|
|
19
|
+
readonly kind: {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
readonly enum: readonly ["text"];
|
|
22
|
+
readonly required: true;
|
|
23
|
+
};
|
|
24
|
+
readonly content: {
|
|
25
|
+
readonly type: "string";
|
|
26
|
+
readonly required: true;
|
|
27
|
+
readonly description: "A prose example in Markdown, at most 1500 characters. Use the code variant for source code.";
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}, {
|
|
31
|
+
readonly type: "object";
|
|
32
|
+
readonly additionalProperties: false;
|
|
33
|
+
readonly properties: {
|
|
34
|
+
readonly kind: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
readonly enum: readonly ["code"];
|
|
37
|
+
readonly required: true;
|
|
38
|
+
};
|
|
39
|
+
readonly content: {
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
readonly required: true;
|
|
42
|
+
readonly description: "Raw source code, at most 1500 characters. Preserve line breaks and indentation; do not add Markdown fences.";
|
|
43
|
+
};
|
|
44
|
+
readonly language: {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
readonly required: true;
|
|
47
|
+
readonly description: "Language identifier such as javascript, python, html or text; 1–40 letters, digits, underscores, plus signs, dots, hashes or hyphens.";
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}];
|
|
51
|
+
};
|
|
52
|
+
/** Export code literally, including embedded fences; the renderer never guesses its type. */
|
|
53
|
+
export declare function learningExampleMarkdown(example: LearningExample): string;
|
package/lib/types/learning.d.ts
CHANGED
|
@@ -37,10 +37,24 @@ export type LearningStageId = typeof LEARNING_STAGES[number]['id'];
|
|
|
37
37
|
export declare function learningQuestion(stageId: LearningStageId, question?: string): string;
|
|
38
38
|
/** Recover the most recently requested stage from this Topic's own visible history. */
|
|
39
39
|
export declare function latestLearningStage(messages: readonly TopicMessage[]): LearningStageId | null;
|
|
40
|
+
/** The validation schema and model-visible native tool must expose the same field contract. */
|
|
41
|
+
export declare const LEARNING_CARD_FIELD_DESCRIPTIONS: {
|
|
42
|
+
readonly title: "Non-empty title, at most 100 characters.";
|
|
43
|
+
readonly summary: "Markdown summary, at most 2000 characters. Separate independent points with lists or paragraphs; include conditions and corrections.";
|
|
44
|
+
readonly question: "Non-empty self-test question, at most 500 characters.";
|
|
45
|
+
readonly answer: "Markdown reference answer, at most 2000 characters, consistent with the summary and example. Fence multiline code.";
|
|
46
|
+
};
|
|
40
47
|
export declare const learningCardSchema: z.ZodObject<{
|
|
41
48
|
title: z.ZodString;
|
|
42
49
|
summary: z.ZodString;
|
|
43
|
-
example: z.
|
|
50
|
+
example: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
51
|
+
kind: z.ZodLiteral<"text">;
|
|
52
|
+
content: z.ZodString;
|
|
53
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
54
|
+
kind: z.ZodLiteral<"code">;
|
|
55
|
+
content: z.ZodString;
|
|
56
|
+
language: z.ZodString;
|
|
57
|
+
}, z.core.$strict>], "kind">;
|
|
44
58
|
question: z.ZodString;
|
|
45
59
|
answer: z.ZodString;
|
|
46
60
|
}, z.core.$strict>;
|
|
@@ -48,7 +62,14 @@ export declare const learningCardsInputSchema: z.ZodObject<{
|
|
|
48
62
|
cards: z.ZodArray<z.ZodObject<{
|
|
49
63
|
title: z.ZodString;
|
|
50
64
|
summary: z.ZodString;
|
|
51
|
-
example: z.
|
|
65
|
+
example: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
66
|
+
kind: z.ZodLiteral<"text">;
|
|
67
|
+
content: z.ZodString;
|
|
68
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
69
|
+
kind: z.ZodLiteral<"code">;
|
|
70
|
+
content: z.ZodString;
|
|
71
|
+
language: z.ZodString;
|
|
72
|
+
}, z.core.$strict>], "kind">;
|
|
52
73
|
question: z.ZodString;
|
|
53
74
|
answer: z.ZodString;
|
|
54
75
|
}, z.core.$strict>>;
|
|
@@ -69,4 +90,4 @@ export declare function projectLearningCards(messages: readonly TopicMessage[]):
|
|
|
69
90
|
/** Export the visible set with its Topic provenance; content is plain Markdown, never executed. */
|
|
70
91
|
export declare function learningCardsMarkdown(cards: readonly LearningCard[], topicTitle: string, topicId: string, source: string): string;
|
|
71
92
|
/** Shared teaching contract appended to every scenario's logged tutor section. */
|
|
72
|
-
export declare const LEARNING_PROMPT = "The optional learning route is \u5E95\u5C42\u903B\u8F91 \u2192 \u5B9A\u6027\u5206\u6790 \u2192 \u5B9A\u91CF\u5206\u6790\uFF08\u677F\u4E66\uFF09 \u2192 \u6982\u5FF5\u5173\u8054 \u2192 \u603B\u7ED3\u5B66\u4E60\u5361\u7247. A user may select or skip any stage. Respond to the current request only; never advance automatically or claim that a stage proves mastery. Never schedule spaced repetition or reminders. Do not require quizzes before continuing.\n\nUse learning_cards only when the user asks to summarize or revise learning cards. Before composing cards in this same turn, check the Topic's conclusions and existing board for incorrect definitions, missing conditions, faulty derivations or arithmetic, and contradictions. Earlier assistant output is not evidence. Read available sources when needed; distinguish source evidence from general knowledge. Correct errors before saving, and explicitly label unresolved claims as \u672A\u6838\u5B9E (unverified) or omit them. Check every card's summary, example, question and reference answer for consistency: a correction in the summary must also reach its example and answer. Briefly report corrections and unresolved points; do not present this self-check as independent verification.\n\nEach successful learning_cards call replaces the visible card set for this Topic; older sets remain in its log. Send the complete desired set in one call, not separate calls for individual cards. Write concise, source-grounded summaries and examples, plus a question and reference answer for optional self-testing. Preserve real available source locators inside summaries; do not invent offsets, sources or evidence. Cards and blackboard tools only record learning material inside this independent Topic; they never write to the workspace or source Session.";
|
|
93
|
+
export declare const LEARNING_PROMPT = "The optional learning route is \u5E95\u5C42\u903B\u8F91 \u2192 \u5B9A\u6027\u5206\u6790 \u2192 \u5B9A\u91CF\u5206\u6790\uFF08\u677F\u4E66\uFF09 \u2192 \u6982\u5FF5\u5173\u8054 \u2192 \u603B\u7ED3\u5B66\u4E60\u5361\u7247. A user may select or skip any stage. Respond to the current request only; never advance automatically or claim that a stage proves mastery. Never schedule spaced repetition or reminders. Do not require quizzes before continuing.\n\nUse learning_cards only when the user asks to summarize or revise learning cards. Before composing cards in this same turn, check the Topic's conclusions and existing board for incorrect definitions, missing conditions, faulty derivations or arithmetic, and contradictions. Earlier assistant output is not evidence. Read available sources when needed; distinguish source evidence from general knowledge. Correct errors before saving, and explicitly label unresolved claims as \u672A\u6838\u5B9E (unverified) or omit them. Check every card's summary, example, question and reference answer for consistency: a correction in the summary must also reach its example and answer. Briefly report corrections and unresolved points; do not present this self-check as independent verification.\n\nEach successful learning_cards call replaces the visible card set for this Topic; older sets remain in its log. Send the complete desired set in one call, not separate calls for individual cards. Respect the user's requested count: one card means one card, not one per stage. Write concise, source-grounded summaries and examples, plus a question and reference answer for optional self-testing. Choose example.kind=text for Markdown prose or example.kind=code for raw source code; code includes its language and preserves indentation without Markdown fences. Put explanations in the summary or answer, not around a code example. Preserve real available source locators inside summaries; do not invent offsets, sources or evidence. Cards and blackboard tools only record learning material inside this independent Topic; they never write to the workspace or source Session.";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ContentBlock } from '@deepseek-ai/dsh-llm';
|
|
2
|
+
import type { SessionEvent } from '@deepseek-ai/dsh-session';
|
|
3
|
+
interface ContextMessage {
|
|
4
|
+
id: string;
|
|
5
|
+
content: readonly ContentBlock[];
|
|
6
|
+
source: {
|
|
7
|
+
kind: string;
|
|
8
|
+
plugin?: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/** Project the installed SDK's validated log. 0.1.7 split plugin context into developer/message. */
|
|
12
|
+
export declare function contextMessage(event: SessionEvent): (ContextMessage & {
|
|
13
|
+
label: string;
|
|
14
|
+
}) | undefined;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TopicMetadata } from './topic.ts';
|
|
2
|
+
/** Keep an unavailable inherited route visible until the user explicitly replaces it. */
|
|
3
|
+
export declare const MODEL_SELECTION_REQUIRED = "\u6765\u6E90\u6A21\u578B\u5DF2\u4E0D\u53EF\u7528\u3002\u8349\u7A3F\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u9009\u62E9\u53EF\u7528\u6A21\u578B\u540E\u53D1\u9001\u3002";
|
|
4
|
+
/** A retired catalog entry must not discard a newly created, still empty Topic. Other failures propagate. */
|
|
5
|
+
export declare function selectInitialModel(metadata: TopicMetadata, select: () => Promise<unknown>): Promise<void>;
|
|
6
|
+
/** Check the durable flag before an explicit submission, without changing permissions or model defaults. */
|
|
7
|
+
export declare function requireSelectedModel(metadata: Pick<TopicMetadata, 'modelSelectionRequired'>): void;
|
|
@@ -101,6 +101,7 @@ export declare const nativeAttachmentSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
|
|
|
101
101
|
}, z.core.$strict>], "type">;
|
|
102
102
|
/** Read-only control projection. The Agent inbox remains the only authoritative queue. */
|
|
103
103
|
export declare const nativeStateSchema: z.ZodObject<{
|
|
104
|
+
modelSelectionRequired: z.ZodOptional<z.ZodBoolean>;
|
|
104
105
|
running: z.ZodBoolean;
|
|
105
106
|
blank: z.ZodBoolean;
|
|
106
107
|
error: z.ZodNullable<z.ZodString>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Validate an exact package version, not an npm tag, range or CLI argument. */
|
|
2
|
+
export declare function isPackageVersion(version: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Compare complete package versions using npm SemVer precedence; build metadata does not affect order.
|
|
5
|
+
* @param installed - installed package version.
|
|
6
|
+
* @param available - version selected by the registry tag; it may be a prerelease.
|
|
7
|
+
* @returns negative, zero or positive, or null when either input is not a canonical package version.
|
|
8
|
+
*/
|
|
9
|
+
export declare function comparePackageVersions(installed: string, available: string): -1 | 0 | 1 | null;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare class NewerSessionFormatError extends Error {
|
|
2
|
+
}
|
|
3
|
+
/** Refuse stale writable fallback when a newer host has already produced a successor log. Never migrate logs here. */
|
|
4
|
+
export declare function assertSessionFormat(directory: string): Promise<void>;
|
|
5
|
+
/** Inspect only the exact owned Topic identity beneath the persistence workspace level. */
|
|
6
|
+
export declare function assertOwnedSessionFormat(root: string, sessionId: string): Promise<void>;
|
|
@@ -3,10 +3,13 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
3
3
|
export declare class SourceStorage {
|
|
4
4
|
private readonly host;
|
|
5
5
|
private readonly pending;
|
|
6
|
+
private historicalDirectories;
|
|
6
7
|
constructor(host: Context);
|
|
7
8
|
/** @returns a canonical source/citeciter directory, optionally creating its ownership marker. */
|
|
8
9
|
root(sourceSessionId: string, create?: boolean): Promise<string | undefined>;
|
|
9
10
|
private resolveRoot;
|
|
11
|
+
/** Locate historical source containers only; DSH alone reads and migrates their logs. */
|
|
12
|
+
private findHistoricalDirectories;
|
|
10
13
|
/** Discover owned roots without creating directories or changing Host Session data. */
|
|
11
14
|
discover(): Promise<ReadonlyMap<string, string>>;
|
|
12
15
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ContentBlock } from '@deepseek-ai/dsh-llm';
|
|
2
|
+
import type { SessionEvent } from '@deepseek-ai/dsh-session';
|
|
3
|
+
/** One committed tool dispatch, independent of native or run_code transport. */
|
|
4
|
+
export interface ToolCallRecord {
|
|
5
|
+
readonly callId: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly arguments: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ToolResultRecord {
|
|
10
|
+
readonly callId: string;
|
|
11
|
+
readonly content: readonly ContentBlock[];
|
|
12
|
+
readonly isError: boolean;
|
|
13
|
+
readonly meta?: SessionEvent<'tool/result'>['data']['meta'];
|
|
14
|
+
}
|
|
15
|
+
/** Normalize native and PTC starts using the actual child call identity. No synthetic model messages. */
|
|
16
|
+
export declare function toolCallRecord(event: SessionEvent): ToolCallRecord | undefined;
|
|
17
|
+
/** Normalize settled results for transcript, board, source and attachment readers. */
|
|
18
|
+
export declare function toolResultRecord(event: SessionEvent): ToolResultRecord | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SessionEvent } from '@deepseek-ai/dsh-session';
|
|
2
|
+
/** Return the admission time of a user inbox insertion; claims and canceled items do not qualify. */
|
|
3
|
+
export declare function topicSubmissionTime(event: SessionEvent): number | null;
|
|
4
|
+
/** Ignore inherited source history when repairing archive state after a restart. */
|
|
5
|
+
export declare function latestTopicSubmission(events: readonly SessionEvent[], inheritedEventCount: number): number | null;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export declare const FIRST_ANSWER_FOLLOWUPS = "
|
|
1
|
+
/** Optional first-answer shortcuts. The current user's scope and output constraints take precedence over this default. */
|
|
2
|
+
export declare const FIRST_ANSWER_FOLLOWUPS = "Suggested follow-up questions are an optional default, not a requirement that overrides the current request. Omit the entire suggestions block when the user asks for no suggestions or follow-up questions, only an answer/result, an exact format, or a length limit that leaves no room for suggestions. Do not explain the omission. Length and format limits apply to the complete visible response, including introductions, tables, notes and suggestions.\n\nOtherwise, after completing the first user question in this Topic, append three concise, distinct questions the user may naturally ask next, in the user's language. Put them only at the end of that first final answer, not in intermediate tool steps or later replies. Each question must deepen understanding of the answer, be at most 160 characters, and avoid unsolicited source changes or workflow actions. The UI turns them into editable drafts; never answer or send them automatically. Emit a JSON array inside this exact block, without a code fence or prose after it:\n<citeciter-next-questions>\n[\"\u95EE\u9898\u4E00\uFF1F\",\"\u95EE\u9898\u4E8C\uFF1F\",\"\u95EE\u9898\u4E09\uFF1F\"]\n</citeciter-next-questions>";
|
|
3
|
+
/** Live preference overrides stale route instructions in Topic history without suppressing ordinary coding plans. */
|
|
4
|
+
export declare function learningRoutePrompt(enabled: boolean): string;
|
|
3
5
|
/** Compose native Topic instructions without importing legacy read-only policy or hidden citation content. */
|
|
4
|
-
export declare function composeHostedTopicPrompt(custom: string | undefined, followups: boolean): string;
|
|
6
|
+
export declare function composeHostedTopicPrompt(custom: string | undefined, followups: boolean, learningRoute?: boolean): string;
|
|
@@ -361,8 +361,8 @@ export declare class TopicRuntime {
|
|
|
361
361
|
private globTool;
|
|
362
362
|
private learningCardsTool;
|
|
363
363
|
private blackboardApplyTool;
|
|
364
|
-
|
|
365
|
-
private
|
|
364
|
+
/** Keep storage and submitted-reference authorization outside the shared document tool contract. */
|
|
365
|
+
private registerDocumentTools;
|
|
366
366
|
/** Share source-read instructions and contract across native and legacy Topic runtimes. */
|
|
367
367
|
private registerSourceTool;
|
|
368
368
|
private ensureHandle;
|
|
@@ -379,6 +379,8 @@ export declare class TopicRuntime {
|
|
|
379
379
|
private stop;
|
|
380
380
|
private rename;
|
|
381
381
|
private archive;
|
|
382
|
+
/** Restore only admissions newer than the latest explicit archive; serialize with rename/delete/archive. */
|
|
383
|
+
private restoreSubmittedTopic;
|
|
382
384
|
private delete;
|
|
383
385
|
private deleteAdmitted;
|
|
384
386
|
/** Observe the retired Session after its Agent has released write ownership. */
|