@dsh-ft/dsh-fft-paper-trading 0.6.3 → 0.7.1

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 (48) hide show
  1. package/lib/client.js +9 -1
  2. package/node_modules/@ftshare-lab/dsh-kline/CHANGELOG.md +47 -0
  3. package/node_modules/@ftshare-lab/dsh-kline/README.en.md +107 -201
  4. package/node_modules/@ftshare-lab/dsh-kline/README.md +106 -216
  5. package/node_modules/@ftshare-lab/dsh-kline/chart_service.py +3 -2
  6. package/node_modules/@ftshare-lab/dsh-kline/config/dsh-tool-catalog.json +103 -11
  7. package/node_modules/@ftshare-lab/dsh-kline/core/calc.py +8 -0
  8. package/node_modules/@ftshare-lab/dsh-kline/lib/chart-applications.js +1 -1
  9. package/node_modules/@ftshare-lab/dsh-kline/lib/chart-context.js +1 -1
  10. package/node_modules/@ftshare-lab/dsh-kline/lib/chart-observation.js +11 -1
  11. package/node_modules/@ftshare-lab/dsh-kline/lib/chart-sources.js +6 -1
  12. package/node_modules/@ftshare-lab/dsh-kline/lib/client.js +2971 -835
  13. package/node_modules/@ftshare-lab/dsh-kline/lib/drawing-feedback.js +35 -3
  14. package/node_modules/@ftshare-lab/dsh-kline/lib/pattern-groups.js +91 -0
  15. package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/PanelHost.d.ts +25 -0
  16. package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/chart-handoff.d.ts +5 -0
  17. package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/client-context.d.ts +2 -0
  18. package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/conversation.d.ts +4 -0
  19. package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/generated-view.d.ts +1 -1
  20. package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/host-options.d.ts +38 -0
  21. package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/host-panels.d.ts +55 -0
  22. package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/mode-preferences.d.ts +13 -1
  23. package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/ui-onboarding.d.ts +3 -9
  24. package/node_modules/@ftshare-lab/dsh-kline/lib/types/pattern-groups.d.ts +2 -0
  25. package/node_modules/@ftshare-lab/dsh-kline/package.json +27 -6
  26. package/node_modules/@ftshare-lab/dsh-kline/scripts/run-dsh-kline.mjs +4 -1
  27. package/node_modules/@ftshare-lab/dsh-kline/server.py +46 -25
  28. package/node_modules/@ftshare-lab/dsh-kline/tools/automatic_analysis.py +158 -0
  29. package/node_modules/@ftshare-lab/dsh-kline/tools/channel_candidates.py +1 -1
  30. package/node_modules/@ftshare-lab/dsh-kline/tools/chart_context.py +1 -1
  31. package/node_modules/@ftshare-lab/dsh-kline/tools/chart_edits.py +30 -12
  32. package/node_modules/@ftshare-lab/dsh-kline/tools/chart_functions.py +53 -68
  33. package/node_modules/@ftshare-lab/dsh-kline/tools/chart_indicators.py +3 -1
  34. package/node_modules/@ftshare-lab/dsh-kline/tools/closed_daily.py +68 -0
  35. package/node_modules/@ftshare-lab/dsh-kline/tools/draw.py +18 -2
  36. package/node_modules/@ftshare-lab/dsh-kline/tools/drawing_feedback.py +2 -2
  37. package/node_modules/@ftshare-lab/dsh-kline/tools/fetch.py +2 -3
  38. package/node_modules/@ftshare-lab/dsh-kline/tools/nine_count.py +66 -0
  39. package/node_modules/@ftshare-lab/dsh-kline/tools/pattern_groups.py +103 -0
  40. package/node_modules/@ftshare-lab/dsh-kline/tools/polylines.py +12 -6
  41. package/node_modules/@ftshare-lab/dsh-kline/tools/price_patterns.py +311 -0
  42. package/node_modules/@ftshare-lab/dsh-kline/tools/range_candidates.py +1 -1
  43. package/node_modules/@ftshare-lab/dsh-kline/tools/recent_drawing_candidates.py +123 -0
  44. package/package.json +4 -4
  45. package/src/client/index.js +8 -0
  46. package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/PaperKlinePanel.d.ts +0 -15
  47. package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/canvas-panel.d.ts +0 -33
  48. package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/host-services.d.ts +0 -55
@@ -3,14 +3,14 @@ import { drawingInventory } from "./chart-observation.js";
3
3
  import { fibonacciOverlayPoints } from "./fibonacci.js";
4
4
  import { polylineOverlayPoints } from "./labeled-polyline.js";
5
5
  import { chartAnnotationText } from "./chart-annotations.js";
6
- export const FEEDBACK_KINDS = ['horizontal_line', 'trend_line', 'channel', 'rectangle', 'fibonacci_retracement', 'labeled_polyline', 'text_annotation', 'number_annotation', 'icon_annotation', 'series_line', 'price_band', 'price_sticks'];
6
+ export const FEEDBACK_KINDS = ['horizontal_line', 'trend_line', 'channel', 'rectangle', 'fibonacci_retracement', 'labeled_polyline', 'text_annotation', 'number_annotation', 'icon_annotation', 'series_line', 'price_band', 'price_sticks', 'price_pattern', 'nine_count'];
7
7
  export const FEEDBACK_STATUSES = ['created', 'hidden', 'removed', 'failed', 'unknown'];
8
8
  export const FEEDBACK_REASONS = ['overlay_registered', 'period_mismatch', 'anchors_not_loaded', 'outside_time_viewport',
9
- 'invalid_geometry', 'overlay_missing', 'overlay_mismatch', 'overlay_api_unavailable', 'overlay_lookup_failed',
9
+ 'invalid_geometry', 'overlay_missing', 'overlay_mismatch', 'overlay_api_unavailable', 'overlay_lookup_failed', 'snapshot_outside_loaded_history',
10
10
  'overlay_removed', 'overlay_still_present', 'context_not_ready', 'application_rolled_back', 'rollback_unknown', 'creation_failed',
11
11
  'indicator_registered', 'indicator_removed', 'indicator_missing', 'indicator_still_present', 'indicator_api_unavailable'];
12
12
  const PHASES = ['current', 'applied', 'rolled_back', 'rollback_unknown'];
13
- const STATUS_REASONS = { created: ['overlay_registered', 'outside_time_viewport', 'indicator_registered'], hidden: ['period_mismatch', 'anchors_not_loaded'],
13
+ const STATUS_REASONS = { created: ['overlay_registered', 'outside_time_viewport', 'indicator_registered'], hidden: ['period_mismatch', 'anchors_not_loaded', 'snapshot_outside_loaded_history'],
14
14
  removed: ['overlay_removed', 'indicator_removed'], failed: ['invalid_geometry', 'overlay_missing', 'overlay_mismatch', 'overlay_still_present', 'creation_failed', 'indicator_missing', 'indicator_still_present'],
15
15
  unknown: ['overlay_api_unavailable', 'overlay_lookup_failed', 'overlay_mismatch', 'context_not_ready', 'application_rolled_back', 'rollback_unknown', 'indicator_api_unavailable'] };
16
16
  function empty(status) { return { schema_version: 1, report_status: status, evidence_scope: 'chart_object_api', render_verified: false, pixel_verified: false, items: [] }; }
@@ -146,6 +146,31 @@ export function collectDrawingFeedback(payload, context, chart, previous = [], p
146
146
  item.reason = phase === 'rolled_back' ? 'application_rolled_back' : 'rollback_unknown';
147
147
  return item;
148
148
  }
149
+ if (['price_pattern', 'nine_count'].includes(drawing.kind)) {
150
+ if (cmd.interval !== (context.ui_interval || context.interval)) {
151
+ item.status = 'hidden';
152
+ item.reason = 'period_mismatch';
153
+ item.visibility = 'not_applicable';
154
+ return item;
155
+ }
156
+ const loaded = drawing.kind === 'nine_count' ? (cmd.marks ?? []).every((m) => times.has(m.time))
157
+ : (cmd.pattern?.anchors ?? []).every((a) => times.has(a.time))
158
+ && (cmd.pattern?.type !== 'platform' || (times.has(cmd.pattern?.box?.start_time) && times.has(cmd.pattern?.box?.end_time)));
159
+ if (!loaded) {
160
+ item.status = 'hidden';
161
+ item.reason = 'snapshot_outside_loaded_history';
162
+ item.visibility = 'not_applicable';
163
+ return item;
164
+ }
165
+ const registry = chart?.__dshPatternGroupRegistry;
166
+ if (!(registry instanceof Map)) {
167
+ item.reason = 'overlay_api_unavailable';
168
+ return item;
169
+ }
170
+ item.status = registry.get(drawing.id) === cmd.geometry_hash ? 'created' : 'failed';
171
+ item.reason = item.status === 'created' ? 'overlay_registered' : 'overlay_missing';
172
+ return item;
173
+ }
149
174
  if (['series_line', 'price_band', 'price_sticks'].includes(drawing.kind)) {
150
175
  if (cmd.interval !== (context.ui_interval || context.interval)) {
151
176
  item.status = 'hidden';
@@ -233,6 +258,13 @@ export function collectDrawingFeedback(payload, context, chart, previous = [], p
233
258
  visibility: 'not_applicable', outside_loaded_price_envelope: false });
234
259
  continue;
235
260
  }
261
+ if (['price_pattern', 'nine_count'].includes(drawing.kind)) {
262
+ const registry = chart?.__dshPatternGroupRegistry;
263
+ items.push({ id: drawing.id, kind: drawing.kind, status: !(registry instanceof Map) ? 'unknown' : registry.has(drawing.id) ? 'failed' : 'removed',
264
+ reason: !(registry instanceof Map) ? 'overlay_api_unavailable' : registry.has(drawing.id) ? 'overlay_still_present' : 'overlay_removed',
265
+ visibility: 'not_applicable', outside_loaded_price_envelope: false });
266
+ continue;
267
+ }
236
268
  if (['series_line', 'price_band', 'price_sticks'].includes(drawing.kind)) {
237
269
  const registry = drawing.kind === 'series_line' ? chart?.__dshSeriesLineRegistry
238
270
  : drawing.kind === 'price_band' ? chart?.__dshPriceBandRegistry : chart?.__dshPriceSticksRegistry;
@@ -0,0 +1,91 @@
1
+ /** Bounded, atomic snapshots produced by the shared Python analyses. */
2
+ const HEX = /^[a-f0-9]{64}$/;
3
+ const COLORS = new Set(['info', 'warning', 'success', 'danger']);
4
+ const TYPES = new Set(['double_top', 'double_bottom', 'head_shoulders_top', 'head_shoulders_bottom', 'platform']);
5
+ const STATUSES = new Set(['candidate', 'pending_confirmation', 'price_confirmed', 'structurally_invalid', 'breakout_failed', 'expired']);
6
+ function time(value) {
7
+ if (!Number.isSafeInteger(value) || value <= 0)
8
+ throw Error('invalid_pattern_time');
9
+ return value;
10
+ }
11
+ function price(value) {
12
+ if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0)
13
+ throw Error('invalid_pattern_price');
14
+ return value;
15
+ }
16
+ function nonnegative(value) {
17
+ if (typeof value !== 'number' || !Number.isFinite(value) || value < 0)
18
+ throw Error('invalid_pattern_ratio');
19
+ return value;
20
+ }
21
+ function label(value, limit) {
22
+ if (typeof value !== 'string' || value.length > limit || /[\x00-\x1f]/.test(value))
23
+ throw Error('invalid_pattern_label');
24
+ return value;
25
+ }
26
+ export function patternGroupObservation(raw) {
27
+ return { geometry_hash: raw.geometry_hash, bar_count: raw.bar_count, rule_version: raw.rule_version, as_of: raw.as_of };
28
+ }
29
+ export function sanitizePatternGroupCommand(raw, interval) {
30
+ const pattern = raw?.type === 'DRAW_AGENT_PRICE_PATTERN';
31
+ const nine = raw?.type === 'DRAW_AGENT_NINE_COUNT';
32
+ if (!pattern && !nine || raw.interval !== interval || !COLORS.has(raw.color)
33
+ || typeof raw.id !== 'string' || !new RegExp(`^${pattern ? 'pattern' : 'nine'}_[a-f0-9]{24}$`).test(raw.id)
34
+ || !HEX.test(raw.geometry_hash) || raw.rule_version !== (pattern ? 'price_patterns_v1' : 'nine_count_v1')
35
+ || !Number.isSafeInteger(raw.bar_count) || raw.bar_count < 0 || raw.bar_count > (pattern ? 5 : 240))
36
+ throw Error('invalid_pattern_group');
37
+ const result = { type: raw.type, id: raw.id, interval, label: label(raw.label ?? '', 48), color: raw.color,
38
+ geometry_hash: raw.geometry_hash, bar_count: raw.bar_count, rule_version: raw.rule_version, as_of: time(raw.as_of) };
39
+ if (raw.create_request_id !== undefined)
40
+ result.create_request_id = label(raw.create_request_id, 160);
41
+ if (pattern) {
42
+ const p = raw.pattern;
43
+ if (!p || !TYPES.has(p.type) || !STATUSES.has(p.status)
44
+ || !Array.isArray(p.anchors) || p.anchors.length !== (p.type === 'platform' ? 0 : p.type.startsWith('double') ? 3 : 5)
45
+ || raw.bar_count !== p.anchors.length || !Array.isArray(p.events) || p.events.length > 128
46
+ || !['up', 'down', null].includes(p.direction) || !['up', 'down', null].includes(p.break_direction))
47
+ throw Error('invalid_pattern_geometry');
48
+ const anchors = p.anchors.map((a) => ({ index: a.index, side: a.side, time: time(a.time), price: price(a.price) }));
49
+ if (anchors.some((a, i) => !Number.isSafeInteger(a.index) || a.index < 0 || !['high', 'low'].includes(a.side)
50
+ || i > 0 && (a.index <= anchors[i - 1].index || a.time <= anchors[i - 1].time)))
51
+ throw Error('invalid_pattern_anchors');
52
+ const events = p.events.map((e) => ({ type: label(e.type, 40), time: time(e.time), index: e.index }));
53
+ if (events.some((e) => !Number.isSafeInteger(e.index) || e.index < 0))
54
+ throw Error('invalid_pattern_events');
55
+ const geometry = { type: p.type, anchors, status: p.status, direction: p.direction, break_direction: p.break_direction,
56
+ atr: price(p.atr), buffer: price(p.buffer), available_at: time(p.available_at), as_of: time(p.as_of),
57
+ confirmed_at: p.confirmed_at == null ? null : time(p.confirmed_at), invalidated_at: p.invalidated_at == null ? null : time(p.invalidated_at),
58
+ outer: p.outer == null ? undefined : price(p.outer), events,
59
+ volume_evidence: p.volume_evidence?.status === 'known' ? { status: 'known', relative_to_preceding_20: nonnegative(p.volume_evidence.relative_to_preceding_20), unit: label(p.volume_evidence.unit, 16) } :
60
+ { status: 'unknown', reason: label(p.volume_evidence?.reason ?? 'unavailable', 80) } };
61
+ if (p.type === 'platform') {
62
+ geometry.box = { start_time: time(p.box?.start_time), end_time: time(p.box?.end_time),
63
+ lower_price: price(p.box?.lower_price), upper_price: price(p.box?.upper_price) };
64
+ if (geometry.box.start_time >= geometry.box.end_time || geometry.box.lower_price >= geometry.box.upper_price)
65
+ throw Error('invalid_pattern_box');
66
+ }
67
+ else if (p.neckline?.type === 'horizontal')
68
+ geometry.neckline = { type: 'horizontal', price: price(p.neckline.price) };
69
+ else if (p.neckline?.type === 'sloped')
70
+ geometry.neckline = { type: 'sloped', from: { index: p.neckline.from?.index, time: time(p.neckline.from?.time), price: price(p.neckline.from?.price) },
71
+ to: { index: p.neckline.to?.index, time: time(p.neckline.to?.time), price: price(p.neckline.to?.price) } };
72
+ else
73
+ throw Error('invalid_pattern_neckline');
74
+ result.pattern = geometry;
75
+ }
76
+ else {
77
+ if (!Array.isArray(raw.marks) || raw.marks.length > 240 || raw.bar_count !== raw.marks.length
78
+ || !Array.isArray(raw.events) || raw.events.length > 30)
79
+ throw Error('invalid_nine_group');
80
+ result.marks = raw.marks.map((m) => ({ time: time(m.time), index: m.index, direction: m.direction, count: m.count,
81
+ label: label(m.label, 2), price: price(m.price) }));
82
+ if (result.marks.some((m, i) => !Number.isSafeInteger(m.index) || m.index < 0 || !['up', 'down'].includes(m.direction)
83
+ || !Number.isSafeInteger(m.count) || m.count < 1 || m.count > 9 || m.label !== String(m.count)
84
+ || i > 0 && m.time <= result.marks[i - 1].time))
85
+ throw Error('invalid_nine_marks');
86
+ result.events = raw.events.map((e) => ({ time: time(e.time), direction: e.direction, label: label(e.label, 20) }));
87
+ if (result.events.some((e) => !['up', 'down'].includes(e.direction)))
88
+ throw Error('invalid_nine_events');
89
+ }
90
+ return result;
91
+ }
@@ -0,0 +1,25 @@
1
+ import type { ClientContext } from './client-context';
2
+ import type { KlineChrome } from './embed';
3
+ import { type KlinePanelProps } from './host-panels.ts';
4
+ /**
5
+ * The chart as a host panel body.
6
+ *
7
+ * The host declares a slot, renders it with `{ symbol, name, onIdentity }` and
8
+ * asks the chart to fill it through `klinePanels.mount(seat)`. The body is the
9
+ * same chart the sidebar and the tab draw, only bounded and without the
10
+ * workspace chrome that belongs to the sidebar.
11
+ */
12
+ export declare function KlinePanelHost({ seat, chrome, symbol, name, onIdentity }: KlinePanelProps & {
13
+ seat: string;
14
+ chrome?: KlineChrome;
15
+ }): import("react").JSX.Element;
16
+ /**
17
+ * Register the optional host panel contract.
18
+ *
19
+ * The `klinePanels` service exists for every host, but it registers nothing
20
+ * until a host mounts a seat: without a caller no slot is injected, so a host
21
+ * that does not know this contract sees the plugin exactly as before. Mounts
22
+ * requested before the `slots` service settles are applied once it does.
23
+ * @param ctx - the client context to register on.
24
+ */
25
+ export declare function registerPanelHosts(ctx: ClientContext): void;
@@ -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;
@@ -10,5 +10,7 @@ export interface ClientContext {
10
10
  effect(callback: () => () => void, label?: string): void;
11
11
  inject(deps: string[], callback: (ctx: ClientContext) => void): unknown;
12
12
  get(name: string): unknown;
13
+ /** Publish an optional service another plugin may inject, such as a host contract. */
14
+ provide(name: string, value: unknown): void;
13
15
  sessions: Sessions;
14
16
  }
@@ -16,6 +16,10 @@ export interface SessionEventWindow {
16
16
  type: string;
17
17
  event: any;
18
18
  }[];
19
+ revision?: number;
20
+ change?: {
21
+ kind: string;
22
+ };
19
23
  }
20
24
  export interface SessionListSnapshot {
21
25
  current?: string;
@@ -1,2 +1,2 @@
1
- export declare const PACKAGE_VERSION = "0.6.7";
1
+ export declare const PACKAGE_VERSION = "0.6.11";
2
2
  export declare function mountKlineView(root: any, payload: any, dependencies?: {}): () => void;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The optional host contract for the chrome the chart draws itself.
3
+ *
4
+ * A host client plugin provides the `klineHost` service; nothing else changes
5
+ * when it is absent, which is what keeps every upstream default intact. Only
6
+ * the members a host may switch are modelled here, and unknown values collapse
7
+ * to the default, so a newer host can never put the chart in a half-configured
8
+ * state.
9
+ *
10
+ * The store is deliberately framework-free: the router subscribes with
11
+ * `useSyncExternalStore`, and the onboarding classifier reads it once per open.
12
+ */
13
+ /** What a host may change; every field omitted means the upstream behavior. */
14
+ export interface KlineHostOptions {
15
+ /**
16
+ * `'tab'` — the host owns the chart entry (its own right column), so the
17
+ * chart must not draw the floating classic launcher. Omitted: the user's
18
+ * stored interface preference decides, with the launcher as the fallback.
19
+ */
20
+ entry?: 'tab';
21
+ /**
22
+ * `'off'` — the host suppresses the first-run welcome and the one-time
23
+ * interface notice. Omitted: upstream onboarding.
24
+ */
25
+ onboarding?: 'off';
26
+ }
27
+ /** The options the active host provided, if it provided any. */
28
+ export declare function readHostOptions(): KlineHostOptions | undefined;
29
+ /** Subscribe to host option changes; the router repaints when they arrive. */
30
+ export declare function subscribeHostOptions(listener: () => void): () => void;
31
+ /**
32
+ * Take the options a host provided.
33
+ *
34
+ * Unknown or malformed values are dropped rather than trusted, so this stays a
35
+ * closed contract: only the switches this build understands ever take effect.
36
+ * @param value - the service value, or undefined when the host withdrew it.
37
+ */
38
+ export declare function setHostOptions(value: unknown): void;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The optional host contract for panel mounts.
3
+ *
4
+ * A host that already owns a bounded panel declares a slot of its own and asks
5
+ * the chart to fill it through the `klinePanels` service. The chart therefore
6
+ * never learns a host's slot names, and a host that does not ask sees the
7
+ * plugin exactly as it was before this contract existed.
8
+ *
9
+ * Kept free of React, like `native-sidebar-register.ts`, so the registration
10
+ * policy is testable with fake slot services.
11
+ */
12
+ import type { KlineChrome } from './embed.ts';
13
+ import type { SlotsService } from './native-sidebar-services.ts';
14
+ /** Props a host slot passes to the chart panel it mounts. */
15
+ export interface KlinePanelProps {
16
+ /** The instrument the host currently has selected. */
17
+ symbol?: string;
18
+ /** Display name of that instrument, when the host has one. */
19
+ name?: string;
20
+ /** The chart's own selection, published back so the host can update its ticket. */
21
+ onIdentity?: (symbol?: string, name?: string) => void;
22
+ }
23
+ /** The optional service a host calls to fill its own panel seat with the chart. */
24
+ export interface KlinePanelsService {
25
+ /**
26
+ * Fill `seat` with the chart panel.
27
+ * @param seat - a slot name the host itself declares and renders.
28
+ * @param options.chrome - chrome the panel keeps (default `chart-search`).
29
+ * Repeated mounts with the same chrome share one panel until all callers
30
+ * release it. Conflicting chrome is rejected while the seat is in use.
31
+ * @returns an idempotent disposer for this caller's mount.
32
+ */
33
+ mount(seat: string, options?: {
34
+ chrome?: KlineChrome;
35
+ }): () => void;
36
+ }
37
+ /** The host slice a mount needs: only the slot registry. */
38
+ export interface PanelMountHost {
39
+ readonly slots: SlotsService;
40
+ }
41
+ /** Build the body for one seat; the component side supplies the React element. */
42
+ export type PanelBodyFactory = (seat: string, chrome: KlineChrome | undefined) => unknown;
43
+ /** Pending requests survive slot-service replacement; callers own separate leases. */
44
+ export interface PanelMountRegistry extends KlinePanelsService {
45
+ connect(service: KlinePanelsService): () => void;
46
+ }
47
+ /** Coordinate caller lifetimes independently of the current slot-service lifetime. */
48
+ export declare function createPanelMountRegistry(): PanelMountRegistry;
49
+ /**
50
+ * Turn slot services plus a body factory into the `klinePanels` service.
51
+ * @param host - the host services a mount registers into.
52
+ * @param body - the component body for one seat (one per mounted seat).
53
+ * @returns the service a host calls; nothing is registered until it calls.
54
+ */
55
+ export declare function createPanelMounts(host: PanelMountHost, body: PanelBodyFactory): KlinePanelsService;
@@ -1,3 +1,4 @@
1
+ import type { KlineHostOptions } from './host-options.ts';
1
2
  export type DisplayMode = 'auto' | 'classic' | 'better-sidebar';
2
3
  export declare const DISPLAY_MODE_KEY = "dsh-kline:display-mode:v1";
3
4
  export declare const AUTO_OPEN_KEY = "dsh-kline:auto-open-after-analysis:v1";
@@ -9,5 +10,16 @@ export interface InterfaceState {
9
10
  }
10
11
  export declare const InterfaceContext: import("react").Context<InterfaceState>;
11
12
  export declare function readDisplayMode(storage?: Storage): DisplayMode;
12
- export declare function resolveDisplayMode(_preference: DisplayMode, available: boolean): InterfaceState['mode'];
13
+ export declare function resolveDisplayMode(preference: DisplayMode, available: boolean, host?: KlineHostOptions): InterfaceState['mode'];
14
+ /**
15
+ * Whether the floating classic launcher is drawn for this frame.
16
+ *
17
+ * Upstream keeps it for classic mode and for screens without a Session, where
18
+ * the tab body cannot live yet. A host that declared `entry: 'tab'` owns the
19
+ * chart entry instead, so it never draws the launcher.
20
+ * @param host - the host options, if the host provided any.
21
+ * @param mode - the interface mode this frame resolved to.
22
+ * @param hasConversation - whether a Session exists to host a tab body.
23
+ */
24
+ export declare function shouldDrawClassicLauncher(host: KlineHostOptions | undefined, mode: InterfaceState['mode'], hasConversation: boolean): boolean;
13
25
  export declare function readAutoOpen(storage?: Storage): boolean;
@@ -1,13 +1,7 @@
1
+ import { type KlineHostOptions } from './host-options.ts';
1
2
  export declare const ONBOARDING_KEY = "dsh-kline:onboarding-version:v2";
2
3
  export declare function hasPreviousUsage(storage: Storage): boolean;
3
4
  export declare function captureOnboarding(storage?: Storage): void;
4
- export declare function onboardingKind(storage?: Storage): 'upgrade' | 'none';
5
- /**
6
- * Only a returning user gets a one-time notice.
7
- *
8
- * A fresh install gets no dialog at all: the chart opens straight into its
9
- * workspace, because the first-run welcome that used to pitch the FTShare key
10
- * is gone.
11
- */
12
- export declare function classifyOnboarding(storage: Storage, previousUsage: boolean): 'upgrade' | 'none';
5
+ export declare function onboardingKind(storage?: Storage, host?: KlineHostOptions | undefined): 'upgrade' | 'first' | 'none';
6
+ export declare function classifyOnboarding(storage: Storage, previousUsage: boolean): 'upgrade' | 'first' | 'none';
13
7
  export declare function acknowledgeOnboarding(storage?: Storage): void;
@@ -0,0 +1,2 @@
1
+ export declare function patternGroupObservation(raw: any): any;
2
+ export declare function sanitizePatternGroupCommand(raw: any, interval: string): any;
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@ftshare-lab/dsh-kline",
3
- "version": "0.6.7",
4
- "private": true,
3
+ "version": "0.6.11",
5
4
  "description": "DeepSeek Harness K-line plugin for conversational and manual chart drawing, TA-Lib indicators, and FTShare market data.",
6
5
  "license": "MIT",
7
6
  "type": "module",
@@ -23,6 +22,10 @@
23
22
  "docs/release-acceptance-v0.6.0.md",
24
23
  "docs/release-notes-v0.6.0.md",
25
24
  "docs/chart-functions.md",
25
+ "docs/price-pattern-rules-v1.md",
26
+ "docs/price-pattern-samples-v1.md",
27
+ "docs/automatic-drawing.md",
28
+ "docs/fixtures/price-pattern-real-v1.json",
26
29
  "!core/**/__pycache__/**",
27
30
  "!core/**/*.py[cod]",
28
31
  "lib",
@@ -54,7 +57,21 @@
54
57
  "docs/free-foreign-daily.md",
55
58
  "docs/release-notes-v0.6.7.md",
56
59
  "docs/release-acceptance-v0.6.7.md",
57
- "scripts/dsh-bootstrap.mjs"
60
+ "docs/release-notes-v0.6.8.md",
61
+ "docs/release-acceptance-v0.6.8.md",
62
+ "scripts/dsh-bootstrap.mjs",
63
+ "docs/release-notes-v0.6.9.md",
64
+ "docs/release-acceptance-v0.6.9.md",
65
+ "docs/npm-release.md",
66
+ "docs/guide.md",
67
+ "docs/guide.en.md",
68
+ "docs/drawing-examples.md",
69
+ "docs/drawing-examples.en.md",
70
+ "docs/provider-adaptation.md",
71
+ "docs/release-notes-v0.6.10.md",
72
+ "docs/release-acceptance-v0.6.10.md",
73
+ "docs/release-notes-v0.6.11.md",
74
+ "docs/release-acceptance-v0.6.11.md"
58
75
  ],
59
76
  "main": "lib/index.js",
60
77
  "types": "lib/types/index.d.ts",
@@ -102,9 +119,9 @@
102
119
  },
103
120
  "scripts": {
104
121
  "bootstrap": "node ./scripts/run-dsh-kline.mjs --prepare-project",
105
- "pack:release": "node ./scripts/build-release-package.mjs ./release/dsh-kline-v0.6.7.tgz",
106
- "pack:codex": "node ./scripts/build-codex-package.mjs ./release/ft-kline-v0.6.7.zip && node ./scripts/verify-codex-package.mjs ./release/ft-kline-v0.6.7.zip",
107
- "smoke:codex-package": "python ./scripts/smoke-codex-package.py ./release/ft-kline-v0.6.7.zip",
122
+ "pack:release": "node ./scripts/build-release-package.mjs ./release/dsh-kline-v0.6.11.tgz",
123
+ "pack:codex": "node ./scripts/build-codex-package.mjs ./release/ft-kline-v0.6.11.zip && node ./scripts/verify-codex-package.mjs ./release/ft-kline-v0.6.11.zip",
124
+ "smoke:codex-package": "python ./scripts/smoke-codex-package.py ./release/ft-kline-v0.6.11.zip",
108
125
  "generate:client-view": "node ./scripts/generate-client-view.mjs",
109
126
  "build:sidebar": "pnpm generate:client-view && tsc -p tsconfig.json && tsdown --config tsdown.config.ts && pnpm verify:package",
110
127
  "verify:package": "node ./scripts/verify-package.mjs",
@@ -132,5 +149,9 @@
132
149
  "tsdown": "0.22.2",
133
150
  "typescript": "6.0.3",
134
151
  "unrun": "^0.3.1"
152
+ },
153
+ "publishConfig": {
154
+ "access": "public",
155
+ "registry": "https://registry.npmjs.org/"
135
156
  }
136
157
  }
@@ -396,7 +396,10 @@ async function prepareRuntime(venvDirectory, fingerprint, logPath, preferredPyth
396
396
  } else {
397
397
  const base = await findBootstrapPython(venvDirectory, logPath, preferredPython)
398
398
  process.stderr.write('[dsh_kline] Creating or repairing the Python environment…\n')
399
- const venvArgs = [...base.args, '-m', 'venv', ...(clearExisting ? ['--clear'] : []), venvDirectory]
399
+ // Python -m venv does not replace an existing interpreter when upgrading
400
+ // across Python versions. Clear any unusable venv before creating it again.
401
+ const replaceExisting = clearExisting || await pathExists(runtimePython)
402
+ const venvArgs = [...base.args, '-m', 'venv', ...(replaceExisting ? ['--clear'] : []), venvDirectory]
400
403
  const venvMs = await bootstrapStep('PYTHON_VENV_UNAVAILABLE', 'Cannot create or repair the virtual environment', base.command, venvArgs, logPath)
401
404
  process.stderr.write(`[dsh_kline] Python environment ready in ${Math.ceil(venvMs / 1000)}s.\n`)
402
405
  }