@ftshare-lab/dsh-kline 0.0.0-stage → 0.6.10

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 (203) hide show
  1. package/CHANGELOG.md +601 -0
  2. package/LICENSE +21 -0
  3. package/PROVENANCE.md +13 -0
  4. package/README.en.md +116 -0
  5. package/README.md +115 -2
  6. package/chart_service.py +687 -0
  7. package/config/basic-symbols.json +570 -0
  8. package/config/dsh-kline.patch.yml +4 -0
  9. package/config/dsh-tool-catalog.json +3875 -0
  10. package/cordis.patch.yml +33 -0
  11. package/core/__init__.py +0 -0
  12. package/core/adjustment.py +16 -0
  13. package/core/calc.py +691 -0
  14. package/core/rows.py +228 -0
  15. package/core/ta_engine.py +99 -0
  16. package/docs/anonymous-market-support.md +33 -0
  17. package/docs/automatic-drawing.md +24 -0
  18. package/docs/chart-functions.md +136 -0
  19. package/docs/drawing-examples.en.md +13 -0
  20. package/docs/drawing-examples.md +13 -0
  21. package/docs/embedding.md +43 -0
  22. package/docs/fixtures/price-pattern-real-v1.json +1 -0
  23. package/docs/free-foreign-daily.md +44 -0
  24. package/docs/guide.en.md +232 -0
  25. package/docs/guide.md +248 -0
  26. package/docs/images/abc-drawing-v0.5.0.jpg +0 -0
  27. package/docs/images/channel-drawing-v0.5.0.jpg +0 -0
  28. package/docs/images/drawing-workbench-v0.5.0.jpg +0 -0
  29. package/docs/images/dsh-kline-tab-workspace.png +0 -0
  30. package/docs/images/dsh-market.png +0 -0
  31. package/docs/images/kline-news.png +0 -0
  32. package/docs/images/kline-range-stats.png +0 -0
  33. package/docs/images/kline-support.png +0 -0
  34. package/docs/images/main-chart-comparison-v0.6.9.png +0 -0
  35. package/docs/images/market-overview-v0.6.9.png +0 -0
  36. package/docs/images/natural-language-abc-wolong-2026-10-27.png +0 -0
  37. package/docs/images/natural-language-descending-channel-wolong-2026-10-27.png +0 -0
  38. package/docs/images/platform-breakout-msft-v0.6.9.png +0 -0
  39. package/docs/npm-release.md +33 -0
  40. package/docs/price-pattern-rules-v1.md +40 -0
  41. package/docs/price-pattern-samples-v1.md +42 -0
  42. package/docs/provider-adaptation.md +73 -0
  43. package/docs/release-acceptance-v0.4.0.md +46 -0
  44. package/docs/release-acceptance-v0.4.1.md +43 -0
  45. package/docs/release-acceptance-v0.5.0.md +40 -0
  46. package/docs/release-acceptance-v0.6.0.md +33 -0
  47. package/docs/release-acceptance-v0.6.1.md +19 -0
  48. package/docs/release-acceptance-v0.6.10.md +21 -0
  49. package/docs/release-acceptance-v0.6.2.md +31 -0
  50. package/docs/release-acceptance-v0.6.3.md +25 -0
  51. package/docs/release-acceptance-v0.6.4.md +24 -0
  52. package/docs/release-acceptance-v0.6.5.md +21 -0
  53. package/docs/release-acceptance-v0.6.6.md +21 -0
  54. package/docs/release-acceptance-v0.6.7.md +18 -0
  55. package/docs/release-acceptance-v0.6.8.md +18 -0
  56. package/docs/release-acceptance-v0.6.9.md +98 -0
  57. package/docs/release-notes-v0.5.0.md +23 -0
  58. package/docs/release-notes-v0.6.0.md +11 -0
  59. package/docs/release-notes-v0.6.1.md +20 -0
  60. package/docs/release-notes-v0.6.10.md +11 -0
  61. package/docs/release-notes-v0.6.2.md +14 -0
  62. package/docs/release-notes-v0.6.3.md +26 -0
  63. package/docs/release-notes-v0.6.4.md +12 -0
  64. package/docs/release-notes-v0.6.5.md +13 -0
  65. package/docs/release-notes-v0.6.6.md +13 -0
  66. package/docs/release-notes-v0.6.7.md +17 -0
  67. package/docs/release-notes-v0.6.8.md +10 -0
  68. package/docs/release-notes-v0.6.9.md +16 -0
  69. package/lib/candle-sequence.js +15 -0
  70. package/lib/chart-adjustment.js +7 -0
  71. package/lib/chart-annotations.js +33 -0
  72. package/lib/chart-applications.js +171 -0
  73. package/lib/chart-context.js +164 -0
  74. package/lib/chart-observation.js +251 -0
  75. package/lib/chart-service-status.js +82 -0
  76. package/lib/chart-source-status.js +39 -0
  77. package/lib/chart-sources.js +354 -0
  78. package/lib/client/BetterSidebarTab.js +70 -0
  79. package/lib/client/ClassicShell.js +254 -0
  80. package/lib/client/KlineContent.js +155 -0
  81. package/lib/client/chart-apply.js +73 -0
  82. package/lib/client/chart-context.js +233 -0
  83. package/lib/client/chart-handoff.js +34 -0
  84. package/lib/client/chart-session-resolver.js +74 -0
  85. package/lib/client/client-context.js +1 -0
  86. package/lib/client/conversation.js +88 -0
  87. package/lib/client/default-tab.js +83 -0
  88. package/lib/client/embed.js +50 -0
  89. package/lib/client/generated-view.js +12983 -0
  90. package/lib/client/horizontal-lines.js +19 -0
  91. package/lib/client/index.js +62 -0
  92. package/lib/client/mode-preferences.js +28 -0
  93. package/lib/client/native-sidebar-contract.js +45 -0
  94. package/lib/client/native-sidebar-register.js +133 -0
  95. package/lib/client/native-sidebar-services.js +1 -0
  96. package/lib/client/native-sidebar.js +96 -0
  97. package/lib/client/sidebar-integration.js +93 -0
  98. package/lib/client/ui-onboarding.js +42 -0
  99. package/lib/client/version.js +14 -0
  100. package/lib/client.js +17382 -0
  101. package/lib/client.js.map +1 -0
  102. package/lib/drawing-feedback.js +284 -0
  103. package/lib/fibonacci.js +18 -0
  104. package/lib/ftshare-settings-bridge.js +159 -0
  105. package/lib/index.js +279 -0
  106. package/lib/labeled-polyline.js +17 -0
  107. package/lib/pattern-groups.js +91 -0
  108. package/lib/price-bands.js +55 -0
  109. package/lib/price-series.js +47 -0
  110. package/lib/price-sticks.js +32 -0
  111. package/lib/types/candle-sequence.d.ts +2 -0
  112. package/lib/types/chart-adjustment.d.ts +2 -0
  113. package/lib/types/chart-annotations.d.ts +4 -0
  114. package/lib/types/chart-applications.d.ts +26 -0
  115. package/lib/types/chart-context.d.ts +14 -0
  116. package/lib/types/chart-observation.d.ts +8 -0
  117. package/lib/types/chart-service-status.d.ts +22 -0
  118. package/lib/types/chart-source-status.d.ts +47 -0
  119. package/lib/types/chart-sources.d.ts +25 -0
  120. package/lib/types/client/BetterSidebarTab.d.ts +12 -0
  121. package/lib/types/client/ClassicShell.d.ts +4 -0
  122. package/lib/types/client/KlineContent.d.ts +37 -0
  123. package/lib/types/client/chart-apply.d.ts +13 -0
  124. package/lib/types/client/chart-context.d.ts +23 -0
  125. package/lib/types/client/chart-handoff.d.ts +5 -0
  126. package/lib/types/client/chart-session-resolver.d.ts +2 -0
  127. package/lib/types/client/client-context.d.ts +14 -0
  128. package/lib/types/client/conversation.d.ts +43 -0
  129. package/lib/types/client/default-tab.d.ts +3 -0
  130. package/lib/types/client/embed.d.ts +37 -0
  131. package/lib/types/client/generated-view.d.ts +2 -0
  132. package/lib/types/client/horizontal-lines.d.ts +1 -0
  133. package/lib/types/client/index.d.ts +4 -0
  134. package/lib/types/client/mode-preferences.d.ts +13 -0
  135. package/lib/types/client/native-sidebar-contract.d.ts +52 -0
  136. package/lib/types/client/native-sidebar-register.d.ts +46 -0
  137. package/lib/types/client/native-sidebar-services.d.ts +45 -0
  138. package/lib/types/client/native-sidebar.d.ts +47 -0
  139. package/lib/types/client/sidebar-integration.d.ts +12 -0
  140. package/lib/types/client/ui-onboarding.d.ts +6 -0
  141. package/lib/types/client/version.d.ts +1 -0
  142. package/lib/types/drawing-feedback.d.ts +5 -0
  143. package/lib/types/fibonacci.d.ts +5 -0
  144. package/lib/types/ftshare-settings-bridge.d.ts +50 -0
  145. package/lib/types/index.d.ts +26 -0
  146. package/lib/types/labeled-polyline.d.ts +11 -0
  147. package/lib/types/pattern-groups.d.ts +2 -0
  148. package/lib/types/price-bands.d.ts +3 -0
  149. package/lib/types/price-series.d.ts +5 -0
  150. package/lib/types/price-sticks.d.ts +3 -0
  151. package/package.json +153 -4
  152. package/requirements.txt +6 -0
  153. package/screenshots.json +11 -0
  154. package/scripts/bootstrap.sh +5 -0
  155. package/scripts/dsh-bootstrap.mjs +179 -0
  156. package/scripts/dsh-mcp-plugin.mjs +27 -0
  157. package/scripts/run-dsh-kline.mjs +658 -0
  158. package/scripts/run-dsh-kline.sh +5 -0
  159. package/server.py +1755 -0
  160. package/tools/__init__.py +0 -0
  161. package/tools/annotations.py +119 -0
  162. package/tools/automatic_analysis.py +158 -0
  163. package/tools/baostock_source.py +176 -0
  164. package/tools/calc.py +39 -0
  165. package/tools/channel_candidates.py +260 -0
  166. package/tools/channel_preview.py +82 -0
  167. package/tools/channels.py +104 -0
  168. package/tools/chart_applications.py +204 -0
  169. package/tools/chart_context.py +186 -0
  170. package/tools/chart_edits.py +363 -0
  171. package/tools/chart_functions.py +451 -0
  172. package/tools/chart_indicators.py +65 -0
  173. package/tools/chart_measurements.py +84 -0
  174. package/tools/chart_source_status.py +32 -0
  175. package/tools/chart_sources.py +31 -0
  176. package/tools/closed_daily.py +68 -0
  177. package/tools/draw.py +410 -0
  178. package/tools/drawing_feedback.py +45 -0
  179. package/tools/drawing_interaction.py +117 -0
  180. package/tools/drawing_verification.py +141 -0
  181. package/tools/fetch.py +4680 -0
  182. package/tools/fibonacci.py +83 -0
  183. package/tools/foreign_daily.py +185 -0
  184. package/tools/free_sources.py +483 -0
  185. package/tools/lines.py +91 -0
  186. package/tools/nine_count.py +66 -0
  187. package/tools/pattern_groups.py +103 -0
  188. package/tools/pivots.py +60 -0
  189. package/tools/polylines.py +131 -0
  190. package/tools/price_bands.py +165 -0
  191. package/tools/price_patterns.py +311 -0
  192. package/tools/price_series.py +162 -0
  193. package/tools/price_sticks.py +114 -0
  194. package/tools/range_candidates.py +170 -0
  195. package/tools/recent_drawing_candidates.py +123 -0
  196. package/tools/rectangles.py +76 -0
  197. package/tools/regression_channels.py +87 -0
  198. package/tools/ta_functions.py +228 -0
  199. package/tools/trend_lines.py +106 -0
  200. package/tools/watchlist.py +149 -0
  201. package/view/ft-logo.jpg +0 -0
  202. package/view/kline.html +12436 -0
  203. package/view/vendor/klinecharts.min.js +7 -0
@@ -0,0 +1,47 @@
1
+ /** Diagnostic only: never an edit capability, alignment bypass or rendering receipt. */
2
+ export declare const SOURCE_STATUS_REASONS: {
3
+ readonly not_checked: readonly ["not_checked", "retry_observation"];
4
+ readonly chart_not_ready: readonly ["not_checked", "wait_for_chart"];
5
+ readonly client_unsupported: readonly ["blocked", "reload_client"];
6
+ readonly view_inactive: readonly ["blocked", "activate_view"];
7
+ readonly ambiguous_views: readonly ["blocked", "keep_one_active_view"];
8
+ readonly source_missing: readonly ["blocked", "reopen_chart"];
9
+ readonly source_unavailable: readonly ["blocked", "reopen_chart"];
10
+ readonly source_owner_mismatch: readonly ["blocked", "reopen_chart"];
11
+ readonly source_unconfirmed: readonly ["blocked", "check_drawing_status"];
12
+ readonly source_metadata_unknown: readonly ["blocked", "check_chart_settings"];
13
+ readonly source_limit_exceeded: readonly ["blocked", "reduce_range"];
14
+ readonly drawing_pending: readonly ["checking", "check_drawing_status"];
15
+ readonly drawing_outcome_unknown: readonly ["blocked", "check_drawing_status"];
16
+ readonly source_snapshot_mismatch: readonly ["blocked", "retry_observation"];
17
+ readonly source_payload_invalid: readonly ["blocked", "retry_observation"];
18
+ readonly source_handoff_pending: readonly ["checking", "wait_for_report"];
19
+ readonly source_handoff_rejected: readonly ["blocked", "retry_observation"];
20
+ readonly source_matches_view: readonly ["aligned", "continue_guarded_workflow"];
21
+ readonly context_transport_unavailable: readonly ["blocked", "retry_observation"];
22
+ readonly source_handoff_unavailable: readonly ["blocked", "retry_observation"];
23
+ };
24
+ export declare function sourceStatus(reason?: keyof typeof SOURCE_STATUS_REASONS): {
25
+ schema_version: number;
26
+ scope: string;
27
+ phase: "not_checked" | "blocked" | "checking" | "aligned";
28
+ reason: "not_checked" | "chart_not_ready" | "client_unsupported" | "view_inactive" | "ambiguous_views" | "source_missing" | "source_unavailable" | "source_owner_mismatch" | "source_unconfirmed" | "source_metadata_unknown" | "source_limit_exceeded" | "drawing_pending" | "drawing_outcome_unknown" | "source_snapshot_mismatch" | "source_payload_invalid" | "source_handoff_pending" | "source_handoff_rejected" | "source_matches_view" | "context_transport_unavailable" | "source_handoff_unavailable";
29
+ next_action: "retry_observation" | "wait_for_chart" | "reload_client" | "activate_view" | "keep_one_active_view" | "reopen_chart" | "check_drawing_status" | "check_chart_settings" | "reduce_range" | "wait_for_report" | "continue_guarded_workflow";
30
+ edit_authorized: boolean;
31
+ };
32
+ export declare function sanitizeSourceStatus(raw: any): {
33
+ schema_version: number;
34
+ scope: string;
35
+ phase: "not_checked" | "blocked" | "checking" | "aligned";
36
+ reason: "not_checked" | "chart_not_ready" | "client_unsupported" | "view_inactive" | "ambiguous_views" | "source_missing" | "source_unavailable" | "source_owner_mismatch" | "source_unconfirmed" | "source_metadata_unknown" | "source_limit_exceeded" | "drawing_pending" | "drawing_outcome_unknown" | "source_snapshot_mismatch" | "source_payload_invalid" | "source_handoff_pending" | "source_handoff_rejected" | "source_matches_view" | "context_transport_unavailable" | "source_handoff_unavailable";
37
+ next_action: "retry_observation" | "wait_for_chart" | "reload_client" | "activate_view" | "keep_one_active_view" | "reopen_chart" | "check_drawing_status" | "check_chart_settings" | "reduce_range" | "wait_for_report" | "continue_guarded_workflow";
38
+ edit_authorized: boolean;
39
+ };
40
+ export declare function sourceFailure(error: any): {
41
+ schema_version: number;
42
+ scope: string;
43
+ phase: "not_checked" | "blocked" | "checking" | "aligned";
44
+ reason: "not_checked" | "chart_not_ready" | "client_unsupported" | "view_inactive" | "ambiguous_views" | "source_missing" | "source_unavailable" | "source_owner_mismatch" | "source_unconfirmed" | "source_metadata_unknown" | "source_limit_exceeded" | "drawing_pending" | "drawing_outcome_unknown" | "source_snapshot_mismatch" | "source_payload_invalid" | "source_handoff_pending" | "source_handoff_rejected" | "source_matches_view" | "context_transport_unavailable" | "source_handoff_unavailable";
45
+ next_action: "retry_observation" | "wait_for_chart" | "reload_client" | "activate_view" | "keep_one_active_view" | "reopen_chart" | "check_drawing_status" | "check_chart_settings" | "reduce_range" | "wait_for_report" | "continue_guarded_workflow";
46
+ edit_authorized: boolean;
47
+ };
@@ -0,0 +1,25 @@
1
+ /** Keep only renderer fields; never copy arbitrary metadata, URLs or provider secrets. */
2
+ export declare function sanitizeSourcePayload(raw: any, state: any): any;
3
+ interface SourceView {
4
+ ref: string;
5
+ conversation: string;
6
+ view: string;
7
+ revision: number;
8
+ active: boolean;
9
+ ambiguous: boolean;
10
+ applyCapable: boolean;
11
+ state: any;
12
+ }
13
+ export declare class ChartSources {
14
+ private offers;
15
+ private runtime;
16
+ private now;
17
+ constructor(runtime: string, now?: () => number);
18
+ private proofPath;
19
+ private read;
20
+ private write;
21
+ acknowledge(view: SourceView, receipt: any): Promise<any>;
22
+ offer(view: SourceView, raw: any): Promise<any>;
23
+ assess(view: SourceView, raw?: any): Promise<any>;
24
+ }
25
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { BetterSidebarService } from 'dsh-better-sidebar';
2
+ import { type Sessions } from './conversation';
3
+ /** The chart itself, shared by every host tab: Better Sidebar and the native one. */
4
+ export declare function KlineTabContent({ sessions, conversationId, visible }: {
5
+ sessions: Sessions;
6
+ conversationId?: string;
7
+ visible?: boolean;
8
+ }): import("react").JSX.Element;
9
+ export declare function BetterSidebarBridge({ service, sessions }: {
10
+ service: BetterSidebarService;
11
+ sessions: Sessions;
12
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ import { type Sessions } from './conversation';
2
+ export declare function ClassicShell({ sessions }: {
3
+ sessions: Sessions;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { type KlineHostProps } from './embed';
2
+ export interface ChartSession {
3
+ ok: true;
4
+ session: string;
5
+ symbol?: string;
6
+ name?: string;
7
+ published_at: number;
8
+ recovery?: boolean;
9
+ }
10
+ export interface ChartIdentity {
11
+ symbol?: string;
12
+ name?: string;
13
+ }
14
+ export declare function standaloneChartSession(conversationId?: string): string;
15
+ export declare function standaloneWorkspaceScope(conversationId?: string): string;
16
+ export declare function isSymbolLikeName(value: string | undefined, symbol: string | undefined): boolean;
17
+ declare global {
18
+ interface Window {
19
+ klinecharts?: any;
20
+ __dshKlineVendorPromise?: Promise<any>;
21
+ __dshKlineVwapRegistered?: boolean;
22
+ }
23
+ }
24
+ export declare function NativeKlineApp({ session, conversationId, ownerConversationId, visible, onIdentity }: {
25
+ session: ChartSession;
26
+ conversationId: string;
27
+ ownerConversationId?: string;
28
+ visible?: boolean;
29
+ onIdentity: (symbol?: string, name?: string) => void;
30
+ }): import("react").JSX.Element;
31
+ export type { KlineChrome, KlineHostProps, KlineEmbedApi } from './embed';
32
+ export declare function StandaloneKlineApp({ conversationId, ownerConversationId, visible, onIdentity, embedded, chrome, theme, symbol, name }: {
33
+ conversationId: string;
34
+ ownerConversationId?: string;
35
+ visible?: boolean;
36
+ onIdentity: (symbol?: string, name?: string) => void;
37
+ } & KlineHostProps): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ interface Options {
2
+ conversationId?: string;
3
+ viewId: string;
4
+ capture: () => any;
5
+ isActive: () => boolean;
6
+ apply: (payload: any, token: string) => any;
7
+ confirm?: (token: string) => void;
8
+ }
9
+ export declare function createChartApplyController(options: Options): {
10
+ consume(command: any, publication: any): any;
11
+ confirm(ack: any): void;
12
+ };
13
+ export {};
@@ -0,0 +1,23 @@
1
+ export declare const CONTEXT_PUBLICATION_TIMEOUT_MS = 8000;
2
+ interface Options {
3
+ conversationId?: string;
4
+ capture: () => any;
5
+ isActive: () => boolean;
6
+ transport?: (body: any, signal?: AbortSignal) => Promise<any>;
7
+ viewId?: string;
8
+ publicationTimeoutMs?: number;
9
+ apply?: (payload: any, token: string) => any;
10
+ confirm?: (token: string) => void;
11
+ feedback?: () => any;
12
+ captureSource?: () => any;
13
+ bindSource?: (token: string, previous: string | null) => void;
14
+ confirmSource?: (token: string, confirmed: boolean) => void;
15
+ onSourceStatus?: (status: any) => void;
16
+ onPublished?: (publication: any) => void;
17
+ }
18
+ export declare function createChartContextPublisher(options: Options): {
19
+ notify(): void;
20
+ retrySource(): void;
21
+ dispose(): void;
22
+ };
23
+ export {};
@@ -0,0 +1,5 @@
1
+ import { type ChartReference, type Sessions, type SessionEventWindow } from './conversation.ts';
2
+ /** Distinguish live appends from history hydration using the host's delta. */
3
+ export declare function observeLiveCharts(initial: SessionEventWindow): (window: SessionEventWindow) => ChartReference | undefined;
4
+ export declare function handoffLiveChart(sessions: Sessions, conversationId: string, reference: ChartReference): void;
5
+ export declare function liveChartFor(sessions: Sessions, conversationId?: string): ChartReference | undefined;
@@ -0,0 +1,2 @@
1
+ import { type ChartReference, type Sessions } from './conversation';
2
+ export declare function useChartReference(sessions: Sessions, conversationId?: string, onNewChart?: (reference: ChartReference) => void): ChartReference | undefined;
@@ -0,0 +1,14 @@
1
+ import type { Sessions } from './conversation';
2
+ /**
3
+ * The client context `apply` receives (only the members this plugin uses).
4
+ *
5
+ * Kept in its own module so host adapters can name the context without
6
+ * importing the plugin entry: this file has no runtime code, so it cannot
7
+ * create an import cycle.
8
+ */
9
+ export interface ClientContext {
10
+ effect(callback: () => () => void, label?: string): void;
11
+ inject(deps: string[], callback: (ctx: ClientContext) => void): unknown;
12
+ get(name: string): unknown;
13
+ sessions: Sessions;
14
+ }
@@ -0,0 +1,43 @@
1
+ export interface ChartReference {
2
+ session: string;
3
+ order: number;
4
+ recovery?: boolean;
5
+ recoverySourceSessions?: string[];
6
+ }
7
+ export interface Observable<T> {
8
+ getSnapshot(): T;
9
+ subscribe(listener: () => void): () => void;
10
+ }
11
+ export interface ConversationSnapshot {
12
+ nodes?: readonly any[];
13
+ }
14
+ export interface SessionEventWindow {
15
+ entries: readonly {
16
+ type: string;
17
+ event: any;
18
+ }[];
19
+ revision?: number;
20
+ change?: {
21
+ kind: string;
22
+ };
23
+ }
24
+ export interface SessionListSnapshot {
25
+ current?: string;
26
+ byId?: Record<string, {
27
+ retainedBy?: {
28
+ mainView?: number;
29
+ };
30
+ }>;
31
+ }
32
+ export interface Sessions {
33
+ list: Observable<SessionListSnapshot>;
34
+ binding(id: string): {
35
+ session: Observable<ConversationSnapshot>;
36
+ eventSource?: Observable<SessionEventWindow>;
37
+ } | undefined;
38
+ }
39
+ /** Resolve one active conversation across the two public DSH session shapes. */
40
+ export declare function currentConversationId(snapshot: SessionListSnapshot): string | undefined;
41
+ export declare function latestChartFromEvents(entries: SessionEventWindow['entries']): ChartReference | undefined;
42
+ export declare function latestChart(nodes: readonly any[]): ChartReference | undefined;
43
+ export declare function chartStorageKey(conversationId: string): string;
@@ -0,0 +1,3 @@
1
+ import type { BetterSidebarService } from 'dsh-better-sidebar';
2
+ export declare const defaultTabKey: (sessionId: string) => string;
3
+ export declare function installDefaultKlineTabs(service: BetterSidebarService, storage?: Pick<Storage, 'getItem' | 'setItem'>): () => void;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The host-facing contract of the embeddable chart.
3
+ *
4
+ * Kept free of React and of the generated view so both the component and the
5
+ * tests can rely on it: the sidebar mount passes nothing, and every helper here
6
+ * is a no-op for the defaults.
7
+ */
8
+ /** Chrome an embedded host keeps: the full workspace, the chart page only, or the chart page plus symbol search. */
9
+ export type KlineChrome = 'full' | 'chart' | 'chart-search';
10
+ /** Host options for a chart that lives inside a bounded panel (a canvas panel, a rail, a card). */
11
+ export interface KlineHostProps {
12
+ /** Bounded panel: anchor dialogs to the panel and lay the chart out for the panel height. */
13
+ embedded?: boolean;
14
+ /** Which workspace chrome to keep. Defaults to the full sidebar workspace. */
15
+ chrome?: KlineChrome;
16
+ /** Pin the palette instead of following the host document. */
17
+ theme?: 'dark' | 'light';
18
+ /** Follow an external instrument selection (the canvas `instrument` channel). */
19
+ symbol?: string;
20
+ name?: string;
21
+ }
22
+ /** The window-level bridge the view installs for an embedded mount. */
23
+ export interface KlineEmbedApi {
24
+ ready: Promise<unknown>;
25
+ openSymbol(symbol: string, name?: string): Promise<unknown>;
26
+ currentSymbol(): string;
27
+ setTheme(theme: 'dark' | 'light' | 'host'): void;
28
+ }
29
+ /**
30
+ * The attributes an embedded host turns on. The sidebar passes the defaults and
31
+ * gets `{}` — no attribute, so none of the embedding CSS can ever match it.
32
+ */
33
+ export declare function klineHostDataset({ embedded, chrome }?: Pick<KlineHostProps, 'embedded' | 'chrome'>): Record<string, string>;
34
+ /** Normalize host identities using the chart's input conventions, retaining the market. */
35
+ export declare function symbolKey(value: string | undefined): string;
36
+ /** Only an exact normalized identity is the same instrument; empty never matches. */
37
+ export declare function sameSymbol(left: string | undefined, right: string | undefined): boolean;
@@ -0,0 +1,2 @@
1
+ export declare const PACKAGE_VERSION = "0.6.10";
2
+ export declare function mountKlineView(root: any, payload: any, dependencies?: {}): () => void;
@@ -0,0 +1 @@
1
+ export declare function mergeHorizontalLineSnapshot(payload: any, saved: any): any;
@@ -0,0 +1,4 @@
1
+ import type { ClientContext } from './client-context';
2
+ export declare const inject: string[];
3
+ export type { ClientContext } from './client-context';
4
+ export declare function apply(ctx: ClientContext): void;
@@ -0,0 +1,13 @@
1
+ export type DisplayMode = 'auto' | 'classic' | 'better-sidebar';
2
+ export declare const DISPLAY_MODE_KEY = "dsh-kline:display-mode:v1";
3
+ export declare const AUTO_OPEN_KEY = "dsh-kline:auto-open-after-analysis:v1";
4
+ export declare const UI_SEEN_KEY = "dsh-kline:ui-change-seen:v0.2.0";
5
+ export interface InterfaceState {
6
+ preference: DisplayMode;
7
+ mode: Exclude<DisplayMode, 'auto'>;
8
+ available: boolean;
9
+ }
10
+ export declare const InterfaceContext: import("react").Context<InterfaceState>;
11
+ export declare function readDisplayMode(storage?: Storage): DisplayMode;
12
+ export declare function resolveDisplayMode(preference: DisplayMode, available: boolean): InterfaceState['mode'];
13
+ export declare function readAutoOpen(storage?: Storage): boolean;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The static half of the native right-Sidebar integration.
3
+ *
4
+ * Kept free of JSX so the tests can import it directly: the registration itself
5
+ * needs a host context, but what this plugin contributes — the tab kind, the
6
+ * band it registers in, the chip title and the guide entry — is plain data.
7
+ */
8
+ /**
9
+ * Implementation identity of the tab type; also the key its body registers
10
+ * under. The host only requires it to be unique across every registration, and
11
+ * a package name is the natural value for a type shipped from another package.
12
+ */
13
+ export declare const NATIVE_TAB_ID = "@ftshare-lab/dsh-kline";
14
+ /** One tab type as DSH's own right-Sidebar registry takes it (the members this plugin sets). */
15
+ export interface NativeSidebarTabDefinition {
16
+ /** Implementation identity, unique across registrations; the body seat dispatches by it. */
17
+ id: string;
18
+ /** Type discriminator — what `openTab` names and what every tab of this type is. */
19
+ kind: string;
20
+ /** Every opening of this type is one page per pane: the chart is a singleton. */
21
+ multiple?: boolean;
22
+ /** Keep a visited body mounted through hiding, Session changes and docking. */
23
+ keepMounted?: boolean;
24
+ /** `extension` is the band for a type shipped outside the product, which is this one. */
25
+ priority?: 'extension' | 'builtin' | 'fallback';
26
+ /** The chip text captured when a tab of this type opens. */
27
+ title: (address: string) => string;
28
+ /** Entry boxes the host's guide page offers for opening this type. */
29
+ guide?: readonly NativeSidebarGuideEntry[];
30
+ }
31
+ /** One guide entry: a capsule that opens this tab type when picked. */
32
+ export interface NativeSidebarGuideEntry {
33
+ id: string;
34
+ order: number;
35
+ title: () => string;
36
+ description?: () => string;
37
+ }
38
+ /**
39
+ * The type definition this plugin contributes.
40
+ *
41
+ * A page type (no address `patterns`) is opened by kind, which is what the
42
+ * auto-open path does; the guide entry is how a person reaches the chart from
43
+ * the host's own add-tab page. Both keep the product label separate from the
44
+ * internal kind, exactly like the Better Sidebar title does.
45
+ *
46
+ * `keepMounted` matters for the chart: collapsing the right column or
47
+ * switching tabs must not tear the chart down, because the view keeps its
48
+ * own state (last instrument reference, zoom, drawings) that a remount loses.
49
+ */
50
+ export declare function nativeTabDefinition(): NativeSidebarTabDefinition;
51
+ /** One line under the guide capsule: what picking it opens, in the host language. */
52
+ export declare function nativeTabDescription(locale?: string): string;
@@ -0,0 +1,46 @@
1
+ import type { SidebarRightService, SidebarRightTabsService, SlotsService } from './native-sidebar-services';
2
+ /**
3
+ * The native right-Sidebar registration, without React and without a host
4
+ * context: a pure function over the three host services, so the bootstrap
5
+ * policy (both stages, their teardown order, the deferred body seat) is
6
+ * testable with fakes.
7
+ *
8
+ * A DSH host that owns its right column publishes `sidebarRightTabs` (stage
9
+ * one — what the tab type is) and a keyed `sidebar.right.pane.tab` seat
10
+ * (stage two — the body), navigated by `sidebarRight`. A type without a body
11
+ * makes the host draw "nothing can view this", so the two stages are one unit
12
+ * and any failure backs the type out again.
13
+ */
14
+ /** The seat a tab type's body registers under. */
15
+ export declare const BODY_SEAT = "sidebar.right.pane.tab";
16
+ /** The host services registration needs, all of them already resolved. */
17
+ export interface NativeTabHost {
18
+ readonly tabs: SidebarRightTabsService;
19
+ readonly navigation: SidebarRightService;
20
+ readonly slots: SlotsService;
21
+ }
22
+ /** What to register, and how the caller wants to hear about it. */
23
+ export interface NativeTabOptions {
24
+ /** The body component registered into the keyed seat. */
25
+ readonly body: unknown;
26
+ /** Business props the body receives; the framework adds its own standard share. */
27
+ readonly bodyProps?: (sessionId: string) => Record<string, unknown>;
28
+ /** Called whenever `available()` changes. */
29
+ readonly onChange?: () => void;
30
+ }
31
+ /** A live native tab: what the router asks, and how the auto-open path opens it. */
32
+ export interface NativeTabRegistration {
33
+ /** Both stages are in place: the tab can actually draw. */
34
+ available(): boolean;
35
+ /** Open (or reveal) the chart tab of the session on screen. */
36
+ open(): void;
37
+ /** Back both stages out. Idempotent, and every teardown is failure-isolated. */
38
+ dispose(): void;
39
+ }
40
+ /**
41
+ * Register the chart as a tab type of the host's right column.
42
+ * @param host - the resolved host services.
43
+ * @param options - the body, its props, and the availability callback.
44
+ * @returns the registration, live until `dispose()`.
45
+ */
46
+ export declare function registerNativeTab(host: NativeTabHost, options: NativeTabOptions): NativeTabRegistration;
@@ -0,0 +1,45 @@
1
+ import type { Sessions } from './conversation';
2
+ import type { NativeSidebarTabDefinition } from './native-sidebar-contract';
3
+ /**
4
+ * The slices of the host services this plugin reaches for.
5
+ *
6
+ * Each slice names only the members used here, so a host that ships a
7
+ * compatible implementation works without this package depending on the
8
+ * host's client packages. The shapes follow DSH 0.2.1's public faces:
9
+ * `@deepseek-ai/dsh-client-ui-sidebar-right/client` (tab registry and
10
+ * navigation), and `@deepseek-ai/dsh-client-ui-slots` (the keyed seat).
11
+ */
12
+ /** The right-Sidebar tab registry: stage one of a tab type's registration. */
13
+ export interface SidebarRightTabsService {
14
+ register(definition: NativeSidebarTabDefinition): () => void;
15
+ }
16
+ /** The right-Sidebar navigation face: how a page type is opened. */
17
+ export interface SidebarRightService {
18
+ openTab(kind: string, options?: {
19
+ params?: unknown;
20
+ }): void;
21
+ }
22
+ /** The host `slots` service, limited to the keyed body seat. */
23
+ export interface SlotsService {
24
+ inject(name: string, factory: () => unknown): unknown;
25
+ register(options: SlotsRegistration, component: unknown): () => void;
26
+ }
27
+ /** One keyed seat registration: the body that draws the tabs of `key`'s type. */
28
+ export interface SlotsRegistration {
29
+ name: string;
30
+ key?: string;
31
+ /** Business props for the body; the framework adds the standard share. */
32
+ inject?: (sessionId: string) => Record<string, unknown>;
33
+ }
34
+ /** The metadata hook the host seat binds into every tab body. */
35
+ export interface NativeTabInfo {
36
+ tab: {
37
+ readonly visible: boolean;
38
+ };
39
+ }
40
+ /** What the body seat hands a registered body: its session and the props it needs. */
41
+ export interface NativeTabBodyProps {
42
+ readonly sessionId: string;
43
+ readonly sessions: Sessions;
44
+ readonly useTabInfo: () => NativeTabInfo;
45
+ }
@@ -0,0 +1,47 @@
1
+ import type { ClientContext } from './client-context';
2
+ import { type Sessions } from './conversation';
3
+ import type { NativeTabBodyProps } from './native-sidebar-services';
4
+ /**
5
+ * The chart as a tab of the host's own right column.
6
+ *
7
+ * The registration policy lives in `native-sidebar-register.ts`; this module
8
+ * owns the two things that need React or the client context: the tab body and
9
+ * the auto-open trigger. The body is the same chart the Better Sidebar tab
10
+ * draws, mounted against the tab's own conversation.
11
+ */
12
+ /**
13
+ * One tab body: the chart of the tab's session.
14
+ *
15
+ * A registered tab can still be opened while the user chose Classic mode, or
16
+ * remain mounted while the host changes Sessions. Only the active conversation
17
+ * in Tab mode may publish a chart; otherwise show a harmless explanation.
18
+ * When that conversation owns the tab, visibility is passed through so a
19
+ * collapsed column does not discard the chart's viewport.
20
+ */
21
+ export declare function NativeKlineTabBody({ sessionId, sessions, useTabInfo }: NativeTabBodyProps): import("react").JSX.Element;
22
+ /**
23
+ * Auto-open lives in the tab's own session, exactly like the Better Sidebar
24
+ * path; the router decides whether this path is the active interface.
25
+ */
26
+ export declare function NativeSidebarBridgeView({ bridge, sessions }: {
27
+ bridge: NativeSidebarBridge;
28
+ sessions: Sessions;
29
+ }): import("react").JSX.Element | null;
30
+ /** The host-facing handle the router polls to decide which interface to draw. */
31
+ export interface NativeSidebarBridge {
32
+ /** Both stages registered: the host can draw the chart tab. */
33
+ available(): boolean;
34
+ /** Open (or reveal) the chart tab of the session on screen. */
35
+ open(): void;
36
+ }
37
+ /**
38
+ * Register the chart tab into the host's native right Sidebar.
39
+ *
40
+ * Every host service is optional: a host without `sidebarRightTabs`,
41
+ * `sidebarRight` or `slots` keeps `available() === false` and the plugin's
42
+ * existing interfaces untouched.
43
+ * @param ctx - the client context to register on.
44
+ * @param onChange - called whenever availability changes, so the router repaints.
45
+ * @returns the handle the router and the auto-open path share.
46
+ */
47
+ export declare function registerNativeSidebar(ctx: ClientContext, onChange: () => void): NativeSidebarBridge;
@@ -0,0 +1,12 @@
1
+ import type { BetterSidebarService } from 'dsh-better-sidebar';
2
+ export declare const KLINE_TAB_ID = "ftshare-kline:chart";
3
+ export declare const KLINE_TAB_TITLE_ZH = "\u975E\u51F8 K \u7EBF\u52A9\u624B";
4
+ export declare const KLINE_TAB_TITLE_EN = "FtAI K-Line";
5
+ export declare function klineTabTitle(locale?: string): string;
6
+ export declare function migrateKlineTabTitle(service: BetterSidebarService, tab: {
7
+ id: string;
8
+ type: string;
9
+ title?: string;
10
+ }, sessionId?: string): void;
11
+ export declare function isSidebarUsable(service?: BetterSidebarService): boolean;
12
+ export declare function cleanClassicTabs(service: BetterSidebarService): () => void;
@@ -0,0 +1,6 @@
1
+ export declare const ONBOARDING_KEY = "dsh-kline:onboarding-version:v2";
2
+ export declare function hasPreviousUsage(storage: Storage): boolean;
3
+ export declare function captureOnboarding(storage?: Storage): void;
4
+ export declare function onboardingKind(storage?: Storage): 'upgrade' | 'first' | 'none';
5
+ export declare function classifyOnboarding(storage: Storage, previousUsage: boolean): 'upgrade' | 'first' | 'none';
6
+ export declare function acknowledgeOnboarding(storage?: Storage): void;
@@ -0,0 +1 @@
1
+ export declare function isNewerStableVersion(candidate: string, current: string): boolean;
@@ -0,0 +1,5 @@
1
+ export declare const FEEDBACK_KINDS: string[];
2
+ export declare const FEEDBACK_STATUSES: string[];
3
+ export declare const FEEDBACK_REASONS: string[];
4
+ export declare function sanitizeDrawingFeedback(raw: any, allowed: any[]): any;
5
+ export declare function collectDrawingFeedback(payload: any, context: any, chart: any, previous?: any[], phase?: string): any;
@@ -0,0 +1,5 @@
1
+ /** Validate price-domain geometry and produce exact overlay points, never pixels. */
2
+ export declare function fibonacciOverlayPoints(c: any): {
3
+ timestamp: number;
4
+ value: number;
5
+ }[];
@@ -0,0 +1,50 @@
1
+ /** Environment variable naming the bridge file for the Python MCP server. */
2
+ export declare const SETTINGS_CREDENTIAL_ENV = "DSH_KLINE_SETTINGS_KEY_FILE";
3
+ /** Directory, relative to the runtime directory, owned by the host bridge. */
4
+ export declare const CREDENTIAL_DIRECTORY = "credentials";
5
+ /**
6
+ * Structural view of the settings service this bridge depends on.
7
+ *
8
+ * Declared here instead of imported from the settings plugin so that a host
9
+ * without that plugin needs no dependency, type, or build edge on it.
10
+ */
11
+ export interface FtshareApiKeySettings {
12
+ /** Current Key, `undefined` when nothing is configured. */
13
+ resolve(): Promise<string | undefined>;
14
+ /** Credential invalidation notification; returns an unsubscribe function. */
15
+ subscribe(listener: () => void): () => void;
16
+ }
17
+ /** Host service name published by the DSH FTShare settings plugin. */
18
+ export interface FtshareSettingsService {
19
+ readonly apiKey: FtshareApiKeySettings;
20
+ }
21
+ export interface FtshareSettingsBridgeOptions {
22
+ settings: FtshareSettingsService;
23
+ /** Runtime directory shared with the launcher and the MCP server. */
24
+ runtimeDirectory: string;
25
+ /** Owning DSH host process, matching the accompanying service locator. */
26
+ hostPid?: number;
27
+ /** Optional diagnostic sink; the bridge stays silent without one. */
28
+ warn?: (message: string) => void;
29
+ }
30
+ export interface FtshareSettingsBridge {
31
+ /** Stop following the credential and remove the published file. */
32
+ dispose(): Promise<void>;
33
+ }
34
+ /**
35
+ * Path of the credential file published by the DSH host.
36
+ *
37
+ * The launcher mirrors this rule in `scripts/run-dsh-kline.mjs`; keeping the
38
+ * owner pid in the name means a file left behind by an earlier host can never
39
+ * be read by a later one.
40
+ */
41
+ export declare function settingsCredentialFile(runtimeDirectory: string, hostPid: number): string;
42
+ /**
43
+ * Follow the settings credential until the returned bridge is disposed.
44
+ *
45
+ * The current Key is published immediately and re-published on every
46
+ * invalidation; clearing the Key removes the file. Failures are reported to
47
+ * `warn` and otherwise ignored: a credential convenience must never take the
48
+ * chart down.
49
+ */
50
+ export declare function startFtshareSettingsBridge(options: FtshareSettingsBridgeOptions): FtshareSettingsBridge;
@@ -0,0 +1,26 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ import { type FtshareSettingsService } from './ftshare-settings-bridge.ts';
3
+ export declare const name = "dsh-kline-sidebar";
4
+ export declare const inject: string[];
5
+ interface WebServerContext {
6
+ effect(callback: () => () => void, label: string): void;
7
+ inject?(deps: string[], callback: (ctx: WebServerContext) => void): unknown;
8
+ systemPrompt?: {
9
+ context(input: {
10
+ name: string;
11
+ order: number;
12
+ text: (context: any) => string;
13
+ }): () => void;
14
+ };
15
+ ftshareSettings?: FtshareSettingsService;
16
+ webServer: {
17
+ register(route: {
18
+ kind: 'prefix';
19
+ path: string;
20
+ handler: (request: IncomingMessage, response: ServerResponse) => void | Promise<void>;
21
+ }): () => void;
22
+ };
23
+ }
24
+ export declare function apply(ctx: WebServerContext): void;
25
+ export declare function runtimeDirectory(env?: NodeJS.ProcessEnv): string;
26
+ export {};
@@ -0,0 +1,11 @@
1
+ /** Canonical explicit labeled paths: no sorting, snapping or automatic waves. */
2
+ export interface LabeledPolylinePoint {
3
+ label: string;
4
+ time: number;
5
+ price: number;
6
+ }
7
+ export declare function sanitizePolylinePoints(raw: any): LabeledPolylinePoint[];
8
+ export declare function polylineOverlayPoints(command: any): {
9
+ timestamp: number;
10
+ value: number;
11
+ }[];
@@ -0,0 +1,2 @@
1
+ export declare function patternGroupObservation(raw: any): any;
2
+ export declare function sanitizePatternGroupCommand(raw: any, interval: string): any;