@kirkchinese/dsh-citeciter 0.6.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 (92) hide show
  1. package/README.md +83 -56
  2. package/README.zh.md +85 -56
  3. package/lib/client.js +6677 -953
  4. package/lib/index.js +1730 -538
  5. package/lib/{typert-common-C6yTitXx.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 +15 -4
  22. package/lib/types/client/components/ActionWheel.d.ts +12 -0
  23. package/lib/types/client/components/BoardCaptureSurface.d.ts +8 -0
  24. package/lib/types/client/components/BoardView.d.ts +5 -3
  25. package/lib/types/client/components/ChoicePopover.d.ts +8 -0
  26. package/lib/types/client/components/CiteLauncher.d.ts +9 -0
  27. package/lib/types/client/components/CitePanel.d.ts +7 -1
  28. package/lib/types/client/components/CompactBackButton.d.ts +4 -0
  29. package/lib/types/client/components/DocumentReader.d.ts +7 -1
  30. package/lib/types/client/components/FileAttachments.d.ts +9 -0
  31. package/lib/types/client/components/FileDropHint.d.ts +5 -0
  32. package/lib/types/client/components/LearningCards.d.ts +12 -0
  33. package/lib/types/client/components/LearningRoute.d.ts +7 -0
  34. package/lib/types/client/components/MessageAttachments.d.ts +12 -0
  35. package/lib/types/client/components/MessageFile.d.ts +8 -0
  36. package/lib/types/client/components/ModelChoice.d.ts +10 -0
  37. package/lib/types/client/components/NativeInteraction.d.ts +7 -0
  38. package/lib/types/client/components/NativeLearningDocument.d.ts +9 -0
  39. package/lib/types/client/components/NativeQueue.d.ts +6 -0
  40. package/lib/types/client/components/OverlayPortal.d.ts +10 -0
  41. package/lib/types/client/components/PermissionControl.d.ts +7 -0
  42. package/lib/types/client/components/QuestionCard.d.ts +10 -4
  43. package/lib/types/client/components/ReasoningDisclosure.d.ts +5 -0
  44. package/lib/types/client/components/ReferenceAttachments.d.ts +6 -0
  45. package/lib/types/client/components/TopicActions.d.ts +6 -0
  46. package/lib/types/client/components/TopicComposer.d.ts +36 -0
  47. package/lib/types/client/components/TopicHeader.d.ts +10 -0
  48. package/lib/types/client/components/TopicModelControls.d.ts +9 -0
  49. package/lib/types/client/components/TopicNavigation.d.ts +12 -0
  50. package/lib/types/client/components/TopicSettingsDialog.d.ts +21 -0
  51. package/lib/types/client/components/TopicTitle.d.ts +6 -0
  52. package/lib/types/client/components/UserMessageBody.d.ts +4 -0
  53. package/lib/types/client/components/WheelSettings.d.ts +7 -0
  54. package/lib/types/client/dock-geometry.d.ts +3 -3
  55. package/lib/types/client/draft-references.d.ts +20 -0
  56. package/lib/types/client/file-download.d.ts +16 -0
  57. package/lib/types/client/file-drop.d.ts +18 -0
  58. package/lib/types/client/host-dock.d.ts +2 -2
  59. package/lib/types/client/learning-route.d.ts +10 -0
  60. package/lib/types/client/native-composer.d.ts +18 -0
  61. package/lib/types/client/native-document.d.ts +13 -0
  62. package/lib/types/client/panel-drag.d.ts +10 -0
  63. package/lib/types/client/reader-controller.d.ts +6 -0
  64. package/lib/types/client/request-guard.d.ts +3 -2
  65. package/lib/types/client/submission-preference.d.ts +5 -0
  66. package/lib/types/client/transcript-position.d.ts +6 -0
  67. package/lib/types/client/types.d.ts +5 -4
  68. package/lib/types/client/view-actions.d.ts +1 -1
  69. package/lib/types/client/wheel-gesture.d.ts +13 -0
  70. package/lib/types/document-pages.d.ts +4 -0
  71. package/lib/types/documents.d.ts +7 -5
  72. package/lib/types/host-agent-modules.d.ts +15 -0
  73. package/lib/types/host-session-adapter.d.ts +31 -0
  74. package/lib/types/index.d.ts +5 -5
  75. package/lib/types/learning.d.ts +72 -0
  76. package/lib/types/native-attachment-read.d.ts +19 -0
  77. package/lib/types/native-session-contract.d.ts +198 -0
  78. package/lib/types/native-session-read.d.ts +4 -0
  79. package/lib/types/owned-session-cleanup.d.ts +2 -0
  80. package/lib/types/service.d.ts +1 -1
  81. package/lib/types/session-migration.d.ts +3 -0
  82. package/lib/types/source-session.d.ts +7 -0
  83. package/lib/types/source-storage.d.ts +12 -0
  84. package/lib/types/topic-index.d.ts +75 -0
  85. package/lib/types/topic-runtime.d.ts +19 -55
  86. package/lib/types/topic-stream.d.ts +14 -0
  87. package/lib/types/topic.d.ts +301 -2
  88. package/lib/types/typert-common.d.ts +210 -1
  89. package/lib/types/typert.host.d.ts +454 -3
  90. package/lib/{update-C0K5ekMg.js → update-0LcFDvI5.js} +279 -13
  91. package/package.json +86 -78
  92. package/lib/types/client/components/SelectionMenu.d.ts +0 -17
@@ -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;
@@ -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 {};
@@ -1,10 +1,9 @@
1
1
  import { Context } from '@deepseek-ai/cordis';
2
2
  import { SessionLogOffset, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session';
3
3
  import { type SessionTitleProviderRequest } from '@deepseek-ai/dsh-session-title';
4
- import { z } from 'zod';
5
4
  import { type BoardSnapshot } from './board.ts';
6
5
  import { type ObserverSourceSnapshot } from './observer.ts';
7
- import { type CiteCiterRequest, type CiteCiterResponse, type CiteCiterSettings, type CitationRecord, type TopicMessage, type TopicMetadata, type TopicMode, type TopicScenario, type TopicSummary } from './topic.ts';
6
+ import { type CiteCiterRequest, type CiteCiterResponse, type CiteCiterSettings, type CitationRecord, type TopicMessage, type TopicMode, type TopicScenario, type TopicSummary } from './topic.ts';
8
7
  type CreateRequest = Extract<CiteCiterRequest, {
9
8
  action: 'create';
10
9
  }>;
@@ -247,55 +246,8 @@ export interface RuntimeTopicLog {
247
246
  readonly header: SessionHeader;
248
247
  readonly events: readonly SessionEvent[];
249
248
  readonly inheritedEventCount: SessionLogOffset;
250
- }
251
- /**
252
- * Remove one artifact from a caller-owned JSONL root without following links.
253
- * @param root - fixed private JSONL root owned by the caller.
254
- * @param artifact - location returned by that exact JSONL backend.
255
- * @returns when the file/link and its empty per-session directory are absent.
256
- */
257
- export declare function removeOwnedJsonlArtifact(root: string, artifact: {
258
- readonly kind: string;
259
- readonly path: string;
260
- } | undefined): Promise<void>;
261
- declare const topicDeletionMarkerSchema: z.ZodObject<{
262
- schemaVersion: z.ZodLiteral<1>;
263
- sessionId: z.ZodString;
264
- sourceSessionId: z.ZodString;
265
- topicId: z.ZodNumber;
266
- sessionHeader: z.ZodObject<{
267
- version: z.ZodNumber;
268
- id: z.ZodString;
269
- createdAt: z.ZodNumber;
270
- isSeeded: z.ZodDefault<z.ZodBoolean>;
271
- cwd: z.ZodOptional<z.ZodString>;
272
- }, z.core.$strict>;
273
- }, z.core.$strict>;
274
- type TopicDeletionMarker = Omit<z.infer<typeof topicDeletionMarkerSchema>, 'sessionHeader'> & {
275
- readonly sessionHeader: SessionHeader;
276
- };
277
- /** Minimal on-disk navigation index; Session history stays in standard DSH JSONL. */
278
- export declare class TopicIndex {
279
- private readonly root;
280
- /** @param root - private Topic index root. */
281
- constructor(root?: string);
282
- reserve(sourceSessionId: string): Promise<{
283
- topicId: number;
284
- directory: string;
285
- }>;
286
- save(metadata: TopicMetadata): Promise<void>;
287
- loadBySessionId(sessionId: string): Promise<TopicMetadata>;
288
- list(sourceSessionId: string): Promise<TopicMetadata[]>;
289
- /** Commit a minimal deletion marker before making Topic metadata unreachable. */
290
- markDeleting(metadata: TopicMetadata, sessionHeader: SessionHeader): Promise<TopicDeletionMarker>;
291
- /** Discover committed deletion markers without following linked directories. */
292
- listDeleting(): Promise<TopicDeletionMarker[]>;
293
- /** Remove the marker and its now-empty Topic directory after artifact cleanup. */
294
- finishDeleting(marker: TopicDeletionMarker): Promise<void>;
295
- private directory;
296
- private read;
297
- private readIfPresent;
298
- private deletionMarkerIfPresent;
249
+ readonly liveMessage?: TopicMessage | undefined;
250
+ readonly renderKeys?: ReadonlyMap<number, string> | undefined;
299
251
  }
300
252
  /**
301
253
  * Project transcript rows and the latest turn's active failure banner.
@@ -325,8 +277,12 @@ export declare function firstPostSeedUserQuestion(log: RuntimeTopicLog): string
325
277
  * @returns the matching question, or `null` when the request is not committed.
326
278
  */
327
279
  export declare function postSeedUserQuestionById(log: RuntimeTopicLog, messageId: string): string | null;
328
- /** Fold only titles created inside the private Topic, excluding inherited fork titles. */
329
- export declare function foldTopicTitle(metadata: TopicMetadata, events: readonly SessionEvent[]): import("@deepseek-ai/dsh-session-title").SessionTitleSnapshot | undefined;
280
+ /**
281
+ * Fold child-owned titles using the restored logical prefix, including after migration.
282
+ * @param log - restored Topic events and the host-owned inherited event count.
283
+ * @returns the latest Topic title projection, or undefined before any title is recorded.
284
+ */
285
+ export declare function foldTopicTitle(log: RuntimeTopicLog): import("@deepseek-ai/dsh-session-title").SessionTitleSnapshot | undefined;
330
286
  /** Resolve the actual Topic mode without forking through an open DSH turn. */
331
287
  export declare function resolveTopicModeAndSeed(requested: CreateRequest, source: ObserverSourceSnapshot, anchorSeq: number): {
332
288
  mode: TopicMode;
@@ -338,7 +294,9 @@ export declare class TopicRuntime {
338
294
  private readonly host;
339
295
  private readonly settings;
340
296
  private readonly runtime;
297
+ private readonly native;
341
298
  private readonly index;
299
+ private readonly sourceStorage;
342
300
  private readonly documents;
343
301
  private readonly lifecycleAbort;
344
302
  private readonly fibers;
@@ -359,6 +317,7 @@ export declare class TopicRuntime {
359
317
  private readonly sourceAvailabilityChecks;
360
318
  private readonly ready;
361
319
  private readonly topicListeners;
320
+ private readonly streams;
362
321
  private disposal;
363
322
  private releasing;
364
323
  private releaseLlm;
@@ -378,6 +337,7 @@ export declare class TopicRuntime {
378
337
  * @returns disposer removing the exact listener.
379
338
  */
380
339
  onTopicChange(listener: TopicChangeListener): () => void;
340
+ private readonly boardCapture;
381
341
  private executeRequest;
382
342
  /** Stop every owned Agent and plugin fiber before releasing bridged services. */
383
343
  dispose(): Promise<void>;
@@ -385,6 +345,8 @@ export declare class TopicRuntime {
385
345
  private beginClosing;
386
346
  private assertOpen;
387
347
  private start;
348
+ /** Adopt existing Citer histories into each source directory without deleting or rewriting their original logs. */
349
+ private migrateStorage;
388
350
  private releaseRuntime;
389
351
  private releaseOwnedRuntime;
390
352
  private settleOwnedOperations;
@@ -394,8 +356,10 @@ export declare class TopicRuntime {
394
356
  private createIdempotent;
395
357
  private resumeOrCreate;
396
358
  private createHandle;
359
+ private setupHostedAgent;
397
360
  private setupAgent;
398
361
  private globTool;
362
+ private learningCardsTool;
399
363
  private blackboardApplyTool;
400
364
  private readDocumentTool;
401
365
  private searchDocumentTool;
@@ -416,9 +380,9 @@ export declare class TopicRuntime {
416
380
  private archive;
417
381
  private delete;
418
382
  private deleteAdmitted;
419
- /** Await JSONL retirement without populating its prepared-session cache. */
383
+ /** Observe the retired Session after its Agent has released write ownership. */
420
384
  private readRetiredSessionHeader;
421
- /** Remove one artifact only from CiteCiter's fixed private JSONL backend. */
385
+ /** Remove every retired generation only from CiteCiter's fixed private JSONL backend. */
422
386
  private removeSessionArtifact;
423
387
  private finishDeletion;
424
388
  private recoverDeletions;
@@ -0,0 +1,14 @@
1
+ /** Process-local Topic output; durable settlements remain owned by DSH Session. */
2
+ import type { AssistantStreamFrame } from '@deepseek-ai/dsh-agent';
3
+ import type { TopicMessage } from './topic.ts';
4
+ /** One Agent's ordered live stream. Dispose the instance with that Agent. */
5
+ export declare class TopicStreamProjection {
6
+ private active;
7
+ private readonly settled;
8
+ /** Exact end-frame receipts keep an existing UI row mounted after durable settlement; aliases expire with this Agent. */
9
+ get renderKeys(): ReadonlyMap<number, string>;
10
+ /** @param frame - scoped Agent publication. @param nextSeq - current Session event count. */
11
+ accept(frame: AssistantStreamFrame, nextSeq: number): void;
12
+ /** @returns a detached display row, absent before visible output or after settlement. */
13
+ snapshot(): TopicMessage | undefined;
14
+ }