@kirkchinese/dsh-citeciter 0.5.0 → 0.8.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.
Files changed (101) hide show
  1. package/README.md +89 -70
  2. package/README.zh.md +91 -70
  3. package/lib/client.js +7028 -1167
  4. package/lib/index.js +1786 -587
  5. package/lib/{typert-common-DKqYKnRO.js → typert-common-DxE1_Bn_.js} +1 -1
  6. package/lib/typert.host.js +2 -2
  7. package/lib/typert.remote-client.js +1 -1
  8. package/lib/types/actions.d.ts +47 -0
  9. package/lib/types/board-capture.d.ts +11 -0
  10. package/lib/types/board.d.ts +4 -4
  11. package/lib/types/citation-mapping.d.ts +8 -0
  12. package/lib/types/citer-agent-registry.d.ts +21 -0
  13. package/lib/types/citer-session-access.d.ts +11 -0
  14. package/lib/types/citer-session-store.d.ts +7 -0
  15. package/lib/types/citer-session-world.d.ts +21 -0
  16. package/lib/types/client/action-controller.d.ts +61 -0
  17. package/lib/types/client/action-executor.d.ts +6 -0
  18. package/lib/types/client/board-capture-target.d.ts +8 -0
  19. package/lib/types/client/citer-session-face.d.ts +59 -0
  20. package/lib/types/client/compact-navigation.d.ts +3 -0
  21. package/lib/types/client/companion-controller.d.ts +19 -5
  22. package/lib/types/client/components/ActionWheel.d.ts +12 -0
  23. package/lib/types/client/components/BlackboardWorkspace.d.ts +7 -5
  24. package/lib/types/client/components/BoardCaptureSurface.d.ts +8 -0
  25. package/lib/types/client/components/BoardView.d.ts +5 -3
  26. package/lib/types/client/components/ChoicePopover.d.ts +8 -0
  27. package/lib/types/client/components/CiteCiterSettings.d.ts +12 -7
  28. package/lib/types/client/components/CiteLauncher.d.ts +9 -0
  29. package/lib/types/client/components/CitePanel.d.ts +15 -5
  30. package/lib/types/client/components/CompactBackButton.d.ts +4 -0
  31. package/lib/types/client/components/DocumentReader.d.ts +12 -3
  32. package/lib/types/client/components/FileAttachments.d.ts +9 -0
  33. package/lib/types/client/components/FileDropHint.d.ts +5 -0
  34. package/lib/types/client/components/LearningCards.d.ts +12 -0
  35. package/lib/types/client/components/LearningRoute.d.ts +7 -0
  36. package/lib/types/client/components/MessageAttachments.d.ts +12 -0
  37. package/lib/types/client/components/MessageFile.d.ts +8 -0
  38. package/lib/types/client/components/ModelChoice.d.ts +10 -0
  39. package/lib/types/client/components/NativeInteraction.d.ts +7 -0
  40. package/lib/types/client/components/NativeLearningDocument.d.ts +9 -0
  41. package/lib/types/client/components/NativeQueue.d.ts +6 -0
  42. package/lib/types/client/components/OverlayPortal.d.ts +10 -0
  43. package/lib/types/client/components/PermissionControl.d.ts +7 -0
  44. package/lib/types/client/components/QuestionCard.d.ts +10 -4
  45. package/lib/types/client/components/ReasoningDisclosure.d.ts +5 -0
  46. package/lib/types/client/components/ReferenceAttachments.d.ts +6 -0
  47. package/lib/types/client/components/TopicActions.d.ts +6 -0
  48. package/lib/types/client/components/TopicComposer.d.ts +36 -0
  49. package/lib/types/client/components/TopicHeader.d.ts +10 -0
  50. package/lib/types/client/components/TopicModelControls.d.ts +9 -0
  51. package/lib/types/client/components/TopicNavigation.d.ts +12 -0
  52. package/lib/types/client/components/TopicSettingsDialog.d.ts +21 -0
  53. package/lib/types/client/components/TopicTitle.d.ts +6 -0
  54. package/lib/types/client/components/UpdateNotice.d.ts +6 -3
  55. package/lib/types/client/components/UserMessageBody.d.ts +4 -0
  56. package/lib/types/client/components/WheelSettings.d.ts +7 -0
  57. package/lib/types/client/copy.d.ts +6 -0
  58. package/lib/types/client/dock-geometry.d.ts +23 -0
  59. package/lib/types/client/draft-references.d.ts +20 -0
  60. package/lib/types/client/entries.d.ts +3 -2
  61. package/lib/types/client/file-download.d.ts +16 -0
  62. package/lib/types/client/file-drop.d.ts +18 -0
  63. package/lib/types/client/host-dock.d.ts +18 -0
  64. package/lib/types/client/learning-route.d.ts +10 -0
  65. package/lib/types/client/native-composer.d.ts +18 -0
  66. package/lib/types/client/native-document.d.ts +13 -0
  67. package/lib/types/client/panel-drag.d.ts +10 -0
  68. package/lib/types/client/reader-controller.d.ts +7 -1
  69. package/lib/types/client/request-guard.d.ts +3 -2
  70. package/lib/types/client/selection.d.ts +1 -1
  71. package/lib/types/client/submission-preference.d.ts +5 -0
  72. package/lib/types/client/transcript-position.d.ts +6 -0
  73. package/lib/types/client/types.d.ts +6 -5
  74. package/lib/types/client/update-controller.d.ts +5 -3
  75. package/lib/types/client/view-actions.d.ts +26 -0
  76. package/lib/types/client/wheel-gesture.d.ts +13 -0
  77. package/lib/types/document-pages.d.ts +4 -0
  78. package/lib/types/documents.d.ts +7 -5
  79. package/lib/types/host-agent-modules.d.ts +15 -0
  80. package/lib/types/host-session-adapter.d.ts +31 -0
  81. package/lib/types/index.d.ts +6 -6
  82. package/lib/types/learning.d.ts +72 -0
  83. package/lib/types/native-attachment-read.d.ts +19 -0
  84. package/lib/types/native-session-contract.d.ts +198 -0
  85. package/lib/types/native-session-read.d.ts +4 -0
  86. package/lib/types/observer.d.ts +2 -1
  87. package/lib/types/owned-session-cleanup.d.ts +2 -0
  88. package/lib/types/service.d.ts +1 -1
  89. package/lib/types/session-migration.d.ts +3 -0
  90. package/lib/types/source-session.d.ts +7 -0
  91. package/lib/types/source-storage.d.ts +12 -0
  92. package/lib/types/topic-index.d.ts +75 -0
  93. package/lib/types/topic-runtime.d.ts +21 -57
  94. package/lib/types/topic-stream.d.ts +14 -0
  95. package/lib/types/topic.d.ts +301 -2
  96. package/lib/types/typert-common.d.ts +211 -1
  97. package/lib/types/typert.host.d.ts +456 -3
  98. package/lib/types/update.d.ts +1 -0
  99. package/lib/{update-u9-6c_qp.js → update-0LcFDvI5.js} +281 -14
  100. package/package.json +83 -70
  101. package/lib/types/client/components/SelectionMenu.d.ts +0 -13
@@ -0,0 +1,13 @@
1
+ import { type CiteAction, type WheelTrigger } from '../actions.ts';
2
+ import type { ActionController, ActionSource } from './action-controller.ts';
3
+ /** Owned reading surfaces provide captures without probing other plugins' private DOM. */
4
+ export declare function createSelectionSurfaces(): {
5
+ register(element: HTMLElement, read: () => ActionSource | null): () => void;
6
+ read(target: EventTarget | null): ActionSource | null;
7
+ };
8
+ export type SelectionSurfaces = ReturnType<typeof createSelectionSurfaces>;
9
+ /** Install hold/move/release gestures; returns a disposer removing every global listener. */
10
+ export declare function installWheelGesture(controller: ActionController, read: (event: MouseEvent) => ActionSource | null, preferences: () => {
11
+ wheelTrigger?: WheelTrigger | undefined;
12
+ wheelSlots?: (CiteAction | null)[] | undefined;
13
+ }): () => void;
@@ -0,0 +1,4 @@
1
+ /** Shared Host/Client page budget; full text stays in the document owner. */
2
+ export declare const DOCUMENT_CONTENT_MAX_BYTES: number;
3
+ /** Split UTF-8 text without breaking code points; concatenation exactly reproduces the input. */
4
+ export declare function documentPages(content: string): string[];
@@ -1,6 +1,5 @@
1
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;
2
+ export { DOCUMENT_CONTENT_MAX_BYTES } from './document-pages.ts';
4
3
  interface DocumentRecordFile {
5
4
  readonly schemaVersion: 1;
6
5
  readonly documentId: string;
@@ -12,8 +11,11 @@ interface DocumentRecordFile {
12
11
  /** Validate and persist one imported text document under the private library. */
13
12
  export declare class DocumentStore {
14
13
  private readonly root;
14
+ private readonly summaries;
15
15
  /** @param root - private document library root. */
16
16
  constructor(root?: string);
17
+ /** Read validated, immutable metadata without loading the document body. Missing documents return null; successful reads are cached for this store's lifetime. */
18
+ summary(documentId: string): Promise<DocumentSummary | null>;
17
19
  /**
18
20
  * Persist one imported document and its normalized UTF-8 text.
19
21
  * @param input - validated title, format, and content from the import boundary.
@@ -38,8 +40,8 @@ export declare class DocumentStore {
38
40
  /**
39
41
  * Return one bounded Reader page.
40
42
  * @param documentId - private document identity.
41
- * @returns the first content window, truncated when the text exceeds the page budget.
43
+ * @param pageIndex - zero-based page; omitted requests the first page. Out-of-range pages are rejected.
44
+ * @returns a UTF-8-budgeted page and the total page count; Unicode code points are never split.
42
45
  */
43
- get(documentId: string): Promise<DocumentContent>;
46
+ get(documentId: string, pageIndex?: number): Promise<DocumentContent>;
44
47
  }
45
- export {};
@@ -0,0 +1,15 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type AgentLoop from '@deepseek-ai/dsh-agent-loop';
3
+ import type SessionStore from '@deepseek-ai/dsh-session';
4
+ interface HostScope {
5
+ readonly ctx: Context;
6
+ dispose(): Promise<void>;
7
+ }
8
+ export interface HostAgentModules {
9
+ readonly AgentLoop: typeof AgentLoop;
10
+ readonly SessionStore: typeof SessionStore;
11
+ readonly createScope: (ctx: Context, key: object) => HostScope;
12
+ }
13
+ /** Resolve published runtime modules from the actual launcher, preserving Desktop's module identities across external-plugin fallback paths. */
14
+ export declare function loadHostAgentModules(): Promise<HostAgentModules>;
15
+ export {};
@@ -0,0 +1,31 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { Agent, AgentHandle } from '@deepseek-ai/dsh-agent';
3
+ import { type SessionEvent } from '@deepseek-ai/dsh-session';
4
+ import type { CiteCiterSettings, TopicMetadata } from './topic.ts';
5
+ /** Host-owned session services; Citer owns only its scoped contributions and factory handles. */
6
+ export declare class HostSessionAdapter {
7
+ private readonly ctx;
8
+ private readonly settings;
9
+ private readonly assemble;
10
+ private readonly storageRoot;
11
+ private readonly metadata;
12
+ private readonly scopes;
13
+ private readonly worlds;
14
+ private readonly access;
15
+ private disposal;
16
+ constructor(ctx: Context, settings: () => CiteCiterSettings, assemble: (scope: Context, agent: Agent, metadata: TopicMetadata) => Promise<void>, storageRoot: (metadata: TopicMetadata) => string);
17
+ /** Drain owned factories before removing their native checkpoint routes. */
18
+ private dispose;
19
+ /** Retain navigation metadata before the Host can resume this identity. */
20
+ remember(metadata: TopicMetadata): void;
21
+ /** Resolve the Topic's factory/persistence realm, retaining old candidate records without deleting Host files. */
22
+ context(metadata: TopicMetadata): Promise<Context>;
23
+ /** Release a complete owned Topic realm before deleting its files. */
24
+ retire(metadata: TopicMetadata): Promise<void>;
25
+ /** Compose a Topic on a native Agent without replacing its loop, tools or permission service. */
26
+ private attach;
27
+ /** Create a native Session with an explicit initial permission. Citer supplies an empty seed so removed references cannot leak through inherited history. No prompt is sent here. */
28
+ create(metadata: TopicMetadata, seed: readonly SessionEvent[], signal?: AbortSignal): Promise<AgentHandle>;
29
+ /** Resume with the Host's preset and preserve the user's logged permission. */
30
+ resume(metadata: TopicMetadata, signal?: AbortSignal): Promise<AgentHandle>;
31
+ }
@@ -1,4 +1,4 @@
1
- /** Host entry for private Observer Topics and their browser Remote API. */
1
+ /** Host entry for native Topics, legacy compatibility and the browser Remote API. */
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';
@@ -6,15 +6,15 @@ import { type UpdateCheckResponse } from './update.ts';
6
6
  import { type CiteCiterRequest, type CiteCiterResponse } from './topic.ts';
7
7
  /** Cordis/Typert package identity. */
8
8
  export declare const name = "@kirkchinese/dsh-citeciter";
9
- /** Services required by the private Topic runtime. */
10
- export declare const inject: readonly ["llm", "sessionQuery", "subprocess"];
9
+ /** Explicit dependencies for native session composition and legacy compatibility. */
10
+ export declare const inject: readonly ["llm", "sessionQuery", "subprocess", "agents", "agentPresets", "sessionController", "systemPrompt", "tools", "sandboxPolicy", "sessions", "sessionPersistence", "sessionTitle", "attachments"];
11
11
  /** Host settings identity shared with the browser settings scope. */
12
- export declare const CITECITER_SETTINGS_NS: import("@deepseek-ai/dsh-settings").SettingsNamespace;
12
+ export declare const CITECITER_SETTINGS_NS: "citeciter";
13
13
  /** Native settings schema for new Topics and the companion panel. */
14
14
  export declare const CITECITER_SETTINGS_SCHEMA: z<object>;
15
- /** Root-scoped Remote service owning one isolated DSH runtime. */
15
+ /** Root-scoped Remote service owning Topic metadata, native contributions and a legacy runtime. */
16
16
  export declare class CiteCiterHost extends TypertRemoteService {
17
- static inject: readonly ["llm", "sessionQuery", "subprocess"];
17
+ static inject: readonly ["llm", "sessionQuery", "subprocess", "agents", "agentPresets", "sessionController", "systemPrompt", "tools", "sandboxPolicy", "sessions", "sessionPersistence", "sessionTitle", "attachments"];
18
18
  private readonly topics;
19
19
  private readonly updates;
20
20
  private readonly service;
@@ -0,0 +1,72 @@
1
+ import { z } from 'zod';
2
+ import type { TopicMessage } from './topic.ts';
3
+ /** User-selected teaching stages; these indicate intent, never measured mastery. */
4
+ export declare const LEARNING_STAGES: readonly [{
5
+ readonly id: "logic";
6
+ readonly label: "底层逻辑";
7
+ readonly shortLabel: "逻辑";
8
+ readonly hint: "从定义、成立条件和因果机制讲起。";
9
+ readonly instruction: "请讲清当前主题的底层逻辑:先给出定义和成立条件,再解释因果机制与为什么成立。区分来源证据、一般知识和假设。只讲这一阶段,不自动推进。";
10
+ }, {
11
+ readonly id: "qualitative";
12
+ readonly label: "定性分析";
13
+ readonly shortLabel: "定性";
14
+ readonly hint: "看方向、边界,以及改变条件会发生什么。";
15
+ readonly instruction: "请对当前主题做定性分析:解释变量或因素之间的关系、变化方向、边界与反例,用一个具体情境说明。只讲这一阶段,不自动推进。";
16
+ }, {
17
+ readonly id: "quantitative";
18
+ readonly label: "定量分析(板书)";
19
+ readonly shortLabel: "定量";
20
+ readonly hint: "把变量、推导和算例写到板书上。";
21
+ readonly instruction: "请对当前主题做定量分析,并调用 blackboard_apply 整理板书:注明变量、单位、假设、推导步骤与一个可核查算例。示例数值必须标明是假设,不得伪造来源数据。如果此主题不适合定量或信息不足,请明确说明原因。只讲这一阶段,不自动推进。";
22
+ }, {
23
+ readonly id: "connections";
24
+ readonly label: "概念关联";
25
+ readonly shortLabel: "关联";
26
+ readonly hint: "说明它与哪些概念相连,以及为什么。";
27
+ readonly instruction: "请围绕当前主题给出 2–4 个最有帮助的概念关联,逐一解释是前提、推论、类比还是对比,说明关联理由与类比的边界。需要时用板书画关系。只讲这一阶段,不自动推进。";
28
+ }, {
29
+ readonly id: "summary";
30
+ readonly label: "总结学习卡片";
31
+ readonly shortLabel: "总结";
32
+ readonly hint: "先核对与纠错,再整理成学习卡片。";
33
+ readonly instruction: "请先核对本 Topic 的结论与已有板书:检查定义、成立条件、推导、数值和前后矛盾,不要把此前的模型回答当作证据;必要时读取可用来源。纠正发现的错误,将无法核实的内容明确标为“未核实”或省略,不要补造来源与定位。然后调用 learning_cards 生成 1–6 张学习卡片,每张包含核心结论、一个具体例子、可选自测问题和参考答案;逐项检查这些字段的一致性,纠错必须同步到例子和参考答案。涉及来源事实时保留真实可用的定位,区分来源证据与一般知识。完成后简短说明纠正了什么、还有哪些内容未核实;不安排复习计划。";
34
+ }];
35
+ export type LearningStageId = typeof LEARNING_STAGES[number]['id'];
36
+ /** Make the entire stage instruction visible and durable as an ordinary Topic user message. */
37
+ export declare function learningQuestion(stageId: LearningStageId, question?: string): string;
38
+ /** Recover the most recently requested stage from this Topic's own visible history. */
39
+ export declare function latestLearningStage(messages: readonly TopicMessage[]): LearningStageId | null;
40
+ export declare const learningCardSchema: z.ZodObject<{
41
+ title: z.ZodString;
42
+ summary: z.ZodString;
43
+ example: z.ZodString;
44
+ question: z.ZodString;
45
+ answer: z.ZodString;
46
+ }, z.core.$strict>;
47
+ export declare const learningCardsInputSchema: z.ZodObject<{
48
+ cards: z.ZodArray<z.ZodObject<{
49
+ title: z.ZodString;
50
+ summary: z.ZodString;
51
+ example: z.ZodString;
52
+ question: z.ZodString;
53
+ answer: z.ZodString;
54
+ }, z.core.$strict>>;
55
+ }, z.core.$strict>;
56
+ export type LearningCard = z.infer<typeof learningCardSchema>;
57
+ export interface LearningCardsProjection {
58
+ readonly cards: readonly LearningCard[];
59
+ /** Successful tool message owning this set, or null before any valid set exists. */
60
+ readonly messageId: string | null;
61
+ readonly invalid: number;
62
+ }
63
+ /**
64
+ * Recover the latest complete card set from successful Topic tool records.
65
+ * Pending, failed and malformed records cannot replace the previous valid set.
66
+ * No separate storage or migration is needed; older sets remain in the Topic log.
67
+ */
68
+ export declare function projectLearningCards(messages: readonly TopicMessage[]): LearningCardsProjection;
69
+ /** Export the visible set with its Topic provenance; content is plain Markdown, never executed. */
70
+ export declare function learningCardsMarkdown(cards: readonly LearningCard[], topicTitle: string, topicId: string, source: string): string;
71
+ /** 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.";
@@ -0,0 +1,19 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { Session } from '@deepseek-ai/dsh-session';
3
+ /**
4
+ * Read an image or verbatim file only after finding its reference in this Topic.
5
+ * @param ctx - the owned Agent context supplying the native attachment store.
6
+ * @param session - the exact Citer log authorizing the requested identity.
7
+ * @param id - opaque attachment identity; never interpreted as a filesystem path.
8
+ * @param signal - cancellation propagated to the host reader.
9
+ * @returns the durable image/file reference and base64 bytes for the remote client.
10
+ * Native readers retain byte-integrity checks. The browser materializes the complete
11
+ * attachment for preview/download; this operation never reads the source Session.
12
+ */
13
+ export declare function readNativeAttachment(ctx: Context, session: Session, id: string, signal: AbortSignal): Promise<{
14
+ attachment: import("@deepseek-ai/dsh-attachment").ImageAttachmentRef;
15
+ data: string;
16
+ } | {
17
+ attachment: import("@deepseek-ai/dsh-attachment").FileAttachmentRef;
18
+ data: string;
19
+ }>;
@@ -0,0 +1,198 @@
1
+ import { z } from 'zod';
2
+ import type { AttachmentIdType, ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
3
+ export declare const nativeImageSchema: z.ZodPipe<z.ZodObject<{
4
+ attachmentId: z.ZodPipe<z.ZodString, z.ZodTransform<AttachmentIdType, string>>;
5
+ mediaType: z.ZodEnum<{
6
+ "image/png": "image/png";
7
+ "image/jpeg": "image/jpeg";
8
+ "image/webp": "image/webp";
9
+ "image/gif": "image/gif";
10
+ }>;
11
+ bytes: z.ZodNumber;
12
+ width: z.ZodNumber;
13
+ height: z.ZodNumber;
14
+ name: z.ZodOptional<z.ZodString>;
15
+ originalDimensions: z.ZodOptional<z.ZodObject<{
16
+ width: z.ZodNumber;
17
+ height: z.ZodNumber;
18
+ }, z.core.$strict>>;
19
+ }, z.core.$strict>, z.ZodTransform<ImageAttachmentRef, {
20
+ attachmentId: AttachmentIdType;
21
+ mediaType: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
22
+ bytes: number;
23
+ width: number;
24
+ height: number;
25
+ name?: string | undefined;
26
+ originalDimensions?: {
27
+ width: number;
28
+ height: number;
29
+ } | undefined;
30
+ }>>;
31
+ /** Wire reference for an authorized attachment; generic files have no image metadata. */
32
+ export declare const nativeAttachmentRefSchema: z.ZodUnion<readonly [z.ZodPipe<z.ZodObject<{
33
+ attachmentId: z.ZodPipe<z.ZodString, z.ZodTransform<AttachmentIdType, string>>;
34
+ mediaType: z.ZodEnum<{
35
+ "image/png": "image/png";
36
+ "image/jpeg": "image/jpeg";
37
+ "image/webp": "image/webp";
38
+ "image/gif": "image/gif";
39
+ }>;
40
+ bytes: z.ZodNumber;
41
+ width: z.ZodNumber;
42
+ height: z.ZodNumber;
43
+ name: z.ZodOptional<z.ZodString>;
44
+ originalDimensions: z.ZodOptional<z.ZodObject<{
45
+ width: z.ZodNumber;
46
+ height: z.ZodNumber;
47
+ }, z.core.$strict>>;
48
+ }, z.core.$strict>, z.ZodTransform<ImageAttachmentRef, {
49
+ attachmentId: AttachmentIdType;
50
+ mediaType: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
51
+ bytes: number;
52
+ width: number;
53
+ height: number;
54
+ name?: string | undefined;
55
+ originalDimensions?: {
56
+ width: number;
57
+ height: number;
58
+ } | undefined;
59
+ }>>, z.ZodObject<{
60
+ attachmentId: z.ZodPipe<z.ZodString, z.ZodTransform<AttachmentIdType, string>>;
61
+ name: z.ZodString;
62
+ bytes: z.ZodNumber;
63
+ }, z.core.$strict>]>;
64
+ export declare const nativeAttachmentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
65
+ type: z.ZodLiteral<"image">;
66
+ attachment: z.ZodPipe<z.ZodObject<{
67
+ attachmentId: z.ZodPipe<z.ZodString, z.ZodTransform<AttachmentIdType, string>>;
68
+ mediaType: z.ZodEnum<{
69
+ "image/png": "image/png";
70
+ "image/jpeg": "image/jpeg";
71
+ "image/webp": "image/webp";
72
+ "image/gif": "image/gif";
73
+ }>;
74
+ bytes: z.ZodNumber;
75
+ width: z.ZodNumber;
76
+ height: z.ZodNumber;
77
+ name: z.ZodOptional<z.ZodString>;
78
+ originalDimensions: z.ZodOptional<z.ZodObject<{
79
+ width: z.ZodNumber;
80
+ height: z.ZodNumber;
81
+ }, z.core.$strict>>;
82
+ }, z.core.$strict>, z.ZodTransform<ImageAttachmentRef, {
83
+ attachmentId: AttachmentIdType;
84
+ mediaType: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
85
+ bytes: number;
86
+ width: number;
87
+ height: number;
88
+ name?: string | undefined;
89
+ originalDimensions?: {
90
+ width: number;
91
+ height: number;
92
+ } | undefined;
93
+ }>>;
94
+ }, z.core.$strict>, z.ZodObject<{
95
+ type: z.ZodLiteral<"file">;
96
+ attachment: z.ZodObject<{
97
+ attachmentId: z.ZodPipe<z.ZodString, z.ZodTransform<AttachmentIdType, string>>;
98
+ name: z.ZodString;
99
+ bytes: z.ZodNumber;
100
+ }, z.core.$strict>;
101
+ }, z.core.$strict>], "type">;
102
+ /** Read-only control projection. The Agent inbox remains the only authoritative queue. */
103
+ export declare const nativeStateSchema: z.ZodObject<{
104
+ running: z.ZodBoolean;
105
+ blank: z.ZodBoolean;
106
+ error: z.ZodNullable<z.ZodString>;
107
+ queue: z.ZodArray<z.ZodObject<{
108
+ id: z.ZodString;
109
+ placement: z.ZodEnum<{
110
+ queued: "queued";
111
+ steering: "steering";
112
+ context: "context";
113
+ }>;
114
+ rpcId: z.ZodOptional<z.ZodString>;
115
+ text: z.ZodString;
116
+ attachments: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
117
+ type: z.ZodLiteral<"image">;
118
+ attachment: z.ZodPipe<z.ZodObject<{
119
+ attachmentId: z.ZodPipe<z.ZodString, z.ZodTransform<AttachmentIdType, string>>;
120
+ mediaType: z.ZodEnum<{
121
+ "image/png": "image/png";
122
+ "image/jpeg": "image/jpeg";
123
+ "image/webp": "image/webp";
124
+ "image/gif": "image/gif";
125
+ }>;
126
+ bytes: z.ZodNumber;
127
+ width: z.ZodNumber;
128
+ height: z.ZodNumber;
129
+ name: z.ZodOptional<z.ZodString>;
130
+ originalDimensions: z.ZodOptional<z.ZodObject<{
131
+ width: z.ZodNumber;
132
+ height: z.ZodNumber;
133
+ }, z.core.$strict>>;
134
+ }, z.core.$strict>, z.ZodTransform<ImageAttachmentRef, {
135
+ attachmentId: AttachmentIdType;
136
+ mediaType: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
137
+ bytes: number;
138
+ width: number;
139
+ height: number;
140
+ name?: string | undefined;
141
+ originalDimensions?: {
142
+ width: number;
143
+ height: number;
144
+ } | undefined;
145
+ }>>;
146
+ }, z.core.$strict>, z.ZodObject<{
147
+ type: z.ZodLiteral<"file">;
148
+ attachment: z.ZodObject<{
149
+ attachmentId: z.ZodPipe<z.ZodString, z.ZodTransform<AttachmentIdType, string>>;
150
+ name: z.ZodString;
151
+ bytes: z.ZodNumber;
152
+ }, z.core.$strict>;
153
+ }, z.core.$strict>], "type">>;
154
+ }, z.core.$strict>>;
155
+ receipts: z.ZodArray<z.ZodObject<{
156
+ requestId: z.ZodString;
157
+ attachments: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
158
+ type: z.ZodLiteral<"image">;
159
+ attachment: z.ZodPipe<z.ZodObject<{
160
+ attachmentId: z.ZodPipe<z.ZodString, z.ZodTransform<AttachmentIdType, string>>;
161
+ mediaType: z.ZodEnum<{
162
+ "image/png": "image/png";
163
+ "image/jpeg": "image/jpeg";
164
+ "image/webp": "image/webp";
165
+ "image/gif": "image/gif";
166
+ }>;
167
+ bytes: z.ZodNumber;
168
+ width: z.ZodNumber;
169
+ height: z.ZodNumber;
170
+ name: z.ZodOptional<z.ZodString>;
171
+ originalDimensions: z.ZodOptional<z.ZodObject<{
172
+ width: z.ZodNumber;
173
+ height: z.ZodNumber;
174
+ }, z.core.$strict>>;
175
+ }, z.core.$strict>, z.ZodTransform<ImageAttachmentRef, {
176
+ attachmentId: AttachmentIdType;
177
+ mediaType: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
178
+ bytes: number;
179
+ width: number;
180
+ height: number;
181
+ name?: string | undefined;
182
+ originalDimensions?: {
183
+ width: number;
184
+ height: number;
185
+ } | undefined;
186
+ }>>;
187
+ }, z.core.$strict>, z.ZodObject<{
188
+ type: z.ZodLiteral<"file">;
189
+ attachment: z.ZodObject<{
190
+ attachmentId: z.ZodPipe<z.ZodString, z.ZodTransform<AttachmentIdType, string>>;
191
+ name: z.ZodString;
192
+ bytes: z.ZodNumber;
193
+ }, z.core.$strict>;
194
+ }, z.core.$strict>], "type">>;
195
+ }, z.core.$strict>>;
196
+ }, z.core.$strict>;
197
+ export type NativeState = z.infer<typeof nativeStateSchema>;
198
+ export type NativeAttachment = z.infer<typeof nativeAttachmentSchema>;
@@ -0,0 +1,4 @@
1
+ import type { Agent } from '@deepseek-ai/dsh-agent';
2
+ import type { NativeState } from './native-session-contract.ts';
3
+ /** Read native inbox occurrences and requested admission receipts without registering a Host list row. */
4
+ export declare function readNativeState(agent: Agent, requestIds: readonly string[]): NativeState;
@@ -1,5 +1,6 @@
1
1
  export { projectDiffMeta, projectToolEvidence, projectToolResultText, type ToolEvidenceProjection, } from './evidence-text.ts';
2
- import { type JsonValue, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session';
2
+ import type { SessionEvent, SessionHeader } from '@deepseek-ai/dsh-session';
3
+ import { type JsonValue } from '@deepseek-ai/dsh-util-values';
3
4
  import { type CitationEvidence, type CitationSelectionClaim, type CitationDraft, type DocumentEvidenceClaim, type ToolEvidenceClaim } from './topic.ts';
4
5
  /** One atomic live-preferred SessionQuery observation. */
5
6
  export interface ObserverSourceSnapshot {
@@ -0,0 +1,2 @@
1
+ /** Delete a retired Topic's private backend, including its child Agents. The caller must drain the factory and verify its source ownership marker first. Never accepts the Host backend root. */
2
+ export declare function removeOwnedSessionTree(topicDirectory: string): Promise<void>;
@@ -62,7 +62,7 @@ export interface CiteCiterService {
62
62
  /**
63
63
  * List Topics grouped by their source session.
64
64
  * @param sourceSessionId - source DSH Session identity.
65
- * @param includeArchived - include archived Topics when true.
65
+ * @param includeArchived - select archived Topics when true; otherwise select active Topics.
66
66
  * @param signal - caller cancellation.
67
67
  * @returns summaries sorted by update time descending.
68
68
  */
@@ -0,0 +1,3 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ /** Copy a validated Session through public persistence handles. Resume an interrupted identical prefix; never overwrite divergent data or remove the original. Close both handles before returning. */
3
+ export declare function copySessionHistory(source: Context['sessionPersistence'], target: Context['sessionPersistence'], sessionId: string): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import { type Session } from '@deepseek-ai/dsh-session';
3
+ import type { ObserverSourceSnapshot } from './observer.ts';
4
+ /** Read one consistent source cut. Release the observation even when copying fails. */
5
+ export declare function readSourceSession(ctx: Context, id: string): Promise<ObserverSourceSnapshot>;
6
+ /** Only an explicitly sent attachment enables later tool reads; unsent metadata grants nothing. */
7
+ export declare function hasSentSource(session: Session | undefined, address: string): boolean;
@@ -0,0 +1,12 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ /** Locate only source-owned Citer directories through the installed JSONL backend; persisted paths are never trusted. */
3
+ export declare class SourceStorage {
4
+ private readonly host;
5
+ private readonly pending;
6
+ constructor(host: Context);
7
+ /** @returns a canonical source/citeciter directory, optionally creating its ownership marker. */
8
+ root(sourceSessionId: string, create?: boolean): Promise<string | undefined>;
9
+ private resolveRoot;
10
+ /** Discover owned roots without creating directories or changing Host Session data. */
11
+ discover(): Promise<ReadonlyMap<string, string>>;
12
+ }
@@ -0,0 +1,75 @@
1
+ import { type SessionHeader } from '@deepseek-ai/dsh-session';
2
+ import { z } from 'zod';
3
+ import { type TopicMetadata } from './topic.ts';
4
+ export declare function errorCode(error: unknown): string | undefined;
5
+ export declare function unlinkIfPresent(path: string): Promise<void>;
6
+ export declare function rmdirIfEmpty(path: string): Promise<void>;
7
+ /**
8
+ * Remove one artifact from a caller-owned JSONL root without following links.
9
+ * @param root - fixed private JSONL root owned by the caller.
10
+ * @param artifact - location returned by that exact JSONL backend.
11
+ * @returns when the file/link and its empty per-session directory are absent.
12
+ */
13
+ export declare function removeOwnedJsonlArtifact(root: string, artifact: {
14
+ readonly kind: string;
15
+ readonly path: string;
16
+ } | undefined): Promise<void>;
17
+ /**
18
+ * Delete all JSONL generations of an already retired private Topic.
19
+ * DSH 0.1.5 has no public delete/location API. This bounded disk adapter follows
20
+ * its project/Session directory layout and canonical generation filenames.
21
+ * @param root - exclusively owned CiteCiter Session root, never a host Session root.
22
+ * @param sessionId - generated CiteCiter identity; arbitrary path segments are refused.
23
+ * @returns after every canonical generation and the retired lock file are absent.
24
+ */
25
+ export declare function removeOwnedTopicGenerations(root: string, sessionId: string): Promise<void>;
26
+ declare const topicDeletionMarkerSchema: z.ZodObject<{
27
+ schemaVersion: z.ZodLiteral<1>;
28
+ storage: z.ZodOptional<z.ZodLiteral<"source">>;
29
+ sessionId: z.ZodString;
30
+ sourceSessionId: z.ZodString;
31
+ topicId: z.ZodNumber;
32
+ sessionHeader: z.ZodObject<{
33
+ version: z.ZodNumber;
34
+ id: z.ZodString;
35
+ createdAt: z.ZodNumber;
36
+ isSeeded: z.ZodDefault<z.ZodBoolean>;
37
+ cwd: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strict>;
39
+ }, z.core.$strict>;
40
+ export type TopicDeletionMarker = Omit<z.infer<typeof topicDeletionMarkerSchema>, 'sessionHeader'> & {
41
+ readonly sessionHeader: SessionHeader;
42
+ };
43
+ /** Minimal on-disk navigation index; Session history stays in standard DSH JSONL. */
44
+ export declare class TopicIndex {
45
+ private readonly root;
46
+ private readonly sourceRoots;
47
+ /** Bind a canonical source-owned root resolved by SourceStorage. */
48
+ bindSource(sourceSessionId: string, root: string): void;
49
+ /** Return the owned metadata directory for one source-backed Topic. */
50
+ ownedDirectory(sourceSessionId: string, topicId: number): string;
51
+ /** @param root - private Topic index root. */
52
+ constructor(root?: string);
53
+ /** Read navigation records across sources; never opens or mutates a Session log. */
54
+ all(includeSuperseded?: boolean): Promise<TopicMetadata[]>;
55
+ reserve(sourceSessionId: string): Promise<{
56
+ topicId: number;
57
+ directory: string;
58
+ }>;
59
+ save(metadata: TopicMetadata): Promise<void>;
60
+ loadBySessionId(sessionId: string): Promise<TopicMetadata>;
61
+ list(sourceSessionId: string): Promise<TopicMetadata[]>;
62
+ /** Commit a minimal deletion marker before making Topic metadata unreachable. */
63
+ markDeleting(metadata: TopicMetadata, sessionHeader: SessionHeader): Promise<TopicDeletionMarker>;
64
+ /** Discover committed deletion markers without following linked directories. */
65
+ listDeleting(): Promise<TopicDeletionMarker[]>;
66
+ /** Remove the marker and its now-empty Topic directory after artifact cleanup. */
67
+ finishDeleting(marker: TopicDeletionMarker): Promise<void>;
68
+ /** Forget only a superseded plugin index after an owned copy was committed; original logs remain intact. */
69
+ forgetLegacy(metadata: Pick<TopicMetadata, 'sessionId' | 'sourceSessionId' | 'topicId'>): Promise<void>;
70
+ private directory;
71
+ private read;
72
+ private readIfPresent;
73
+ private deletionMarkerIfPresent;
74
+ }
75
+ export {};