@dsh-ft/dsh-fft-paper-trading 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/README.zh.md +4 -4
- package/lib/agent/format.d.ts.map +1 -1
- package/lib/agent/format.js +4 -0
- package/lib/agent/format.js.map +1 -1
- package/lib/agent/tools.d.ts.map +1 -1
- package/lib/agent/tools.js +5 -3
- package/lib/agent/tools.js.map +1 -1
- package/lib/client.js +76 -13
- package/lib/contract.d.ts.map +1 -1
- package/lib/contract.js +3 -1
- package/lib/contract.js.map +1 -1
- package/lib/core/risk.d.ts.map +1 -1
- package/lib/core/risk.js +10 -2
- package/lib/core/risk.js.map +1 -1
- package/lib/core/views.js +2 -2
- package/lib/core/views.js.map +1 -1
- package/lib/service/paper-service.d.ts +1 -1
- package/lib/service/paper-service.d.ts.map +1 -1
- package/lib/service/paper-service.js +24 -12
- package/lib/service/paper-service.js.map +1 -1
- package/lib/service/rpc.d.ts.map +1 -1
- package/lib/service/rpc.js +12 -1
- package/lib/service/rpc.js.map +1 -1
- package/node_modules/@ftshare-lab/dsh-kline/CHANGELOG.md +98 -0
- package/node_modules/@ftshare-lab/dsh-kline/README.en.md +116 -26
- package/node_modules/@ftshare-lab/dsh-kline/README.md +125 -25
- package/node_modules/@ftshare-lab/dsh-kline/chart_service.py +38 -0
- package/node_modules/@ftshare-lab/dsh-kline/cordis.patch.yml +3 -9
- package/node_modules/@ftshare-lab/dsh-kline/core/calc.py +63 -269
- package/node_modules/@ftshare-lab/dsh-kline/core/rows.py +15 -3
- package/node_modules/@ftshare-lab/dsh-kline/core/ta_engine.py +99 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/candle-sequence.js +15 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-annotations.js +33 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-applications.js +1 -1
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-context.js +12 -3
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-observation.js +91 -2
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-sources.js +64 -13
- package/node_modules/@ftshare-lab/dsh-kline/lib/client.js +3356 -787
- package/node_modules/@ftshare-lab/dsh-kline/lib/drawing-feedback.js +96 -19
- package/node_modules/@ftshare-lab/dsh-kline/lib/fibonacci.js +18 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/index.js +19 -2
- package/node_modules/@ftshare-lab/dsh-kline/lib/labeled-polyline.js +17 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/price-bands.js +55 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/price-series.js +47 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/price-sticks.js +32 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/candle-sequence.d.ts +2 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/chart-annotations.d.ts +4 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/chart-context.d.ts +1 -1
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/chart-observation.d.ts +2 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/BetterSidebarTab.d.ts +3 -2
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/ClassicShell.d.ts +1 -1
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/chart-context.d.ts +1 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/client-context.d.ts +14 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/conversation.d.ts +11 -3
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/embed.d.ts +2 -2
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/generated-view.d.ts +1 -1
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/host-services.d.ts +0 -36
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/index.d.ts +2 -1
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/native-sidebar-contract.d.ts +35 -4
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/native-sidebar-register.d.ts +46 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/native-sidebar-services.d.ts +45 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/native-sidebar.d.ts +21 -36
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/fibonacci.d.ts +5 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/labeled-polyline.d.ts +11 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/price-bands.d.ts +3 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/price-series.d.ts +5 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/price-sticks.d.ts +3 -0
- package/node_modules/@ftshare-lab/dsh-kline/package.json +27 -5
- package/node_modules/@ftshare-lab/dsh-kline/requirements.txt +2 -0
- package/node_modules/@ftshare-lab/dsh-kline/scripts/dsh-mcp-plugin.mjs +27 -0
- package/node_modules/@ftshare-lab/dsh-kline/scripts/run-dsh-kline.mjs +180 -49
- package/node_modules/@ftshare-lab/dsh-kline/server.py +300 -34
- package/node_modules/@ftshare-lab/dsh-kline/tools/annotations.py +119 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/baostock_source.py +176 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/channel_candidates.py +260 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_applications.py +1 -1
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_context.py +22 -3
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_edits.py +141 -16
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_functions.py +466 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_indicators.py +63 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/draw.py +3 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/drawing_feedback.py +13 -7
- package/node_modules/@ftshare-lab/dsh-kline/tools/drawing_interaction.py +117 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/drawing_verification.py +58 -3
- package/node_modules/@ftshare-lab/dsh-kline/tools/fetch.py +164 -40
- package/node_modules/@ftshare-lab/dsh-kline/tools/fibonacci.py +83 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/free_sources.py +78 -21
- package/node_modules/@ftshare-lab/dsh-kline/tools/pivots.py +60 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/polylines.py +125 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/price_bands.py +165 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/price_series.py +162 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/price_sticks.py +114 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/range_candidates.py +170 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/regression_channels.py +87 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/ta_functions.py +228 -0
- package/package.json +2 -2
- package/src/agent/format.ts +3 -0
- package/src/agent/tools.ts +5 -3
- package/src/client/index.js +75 -12
- package/src/contract.ts +3 -1
- package/src/core/risk.ts +10 -2
- package/src/core/views.ts +2 -2
- package/src/service/paper-service.ts +22 -19
- package/src/service/rpc.ts +12 -1
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
/** Object-API observations, not pixel verification or a trading conclusion. */
|
|
2
2
|
import { drawingInventory } from "./chart-observation.js";
|
|
3
|
-
|
|
3
|
+
import { fibonacciOverlayPoints } from "./fibonacci.js";
|
|
4
|
+
import { polylineOverlayPoints } from "./labeled-polyline.js";
|
|
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'];
|
|
4
7
|
export const FEEDBACK_STATUSES = ['created', 'hidden', 'removed', 'failed', 'unknown'];
|
|
5
8
|
export const FEEDBACK_REASONS = ['overlay_registered', 'period_mismatch', 'anchors_not_loaded', 'outside_time_viewport',
|
|
6
9
|
'invalid_geometry', 'overlay_missing', 'overlay_mismatch', 'overlay_api_unavailable', 'overlay_lookup_failed',
|
|
7
|
-
'overlay_removed', 'overlay_still_present', 'context_not_ready', 'application_rolled_back', 'rollback_unknown', 'creation_failed'
|
|
10
|
+
'overlay_removed', 'overlay_still_present', 'context_not_ready', 'application_rolled_back', 'rollback_unknown', 'creation_failed',
|
|
11
|
+
'indicator_registered', 'indicator_removed', 'indicator_missing', 'indicator_still_present', 'indicator_api_unavailable'];
|
|
8
12
|
const PHASES = ['current', 'applied', 'rolled_back', 'rollback_unknown'];
|
|
9
|
-
const STATUS_REASONS = { created: ['overlay_registered', 'outside_time_viewport'], hidden: ['period_mismatch', 'anchors_not_loaded'],
|
|
10
|
-
removed: ['overlay_removed'], failed: ['invalid_geometry', 'overlay_missing', 'overlay_mismatch', 'overlay_still_present', 'creation_failed'],
|
|
11
|
-
unknown: ['overlay_api_unavailable', 'overlay_lookup_failed', 'overlay_mismatch', 'context_not_ready', 'application_rolled_back', 'rollback_unknown'] };
|
|
13
|
+
const STATUS_REASONS = { created: ['overlay_registered', 'outside_time_viewport', 'indicator_registered'], hidden: ['period_mismatch', 'anchors_not_loaded'],
|
|
14
|
+
removed: ['overlay_removed', 'indicator_removed'], failed: ['invalid_geometry', 'overlay_missing', 'overlay_mismatch', 'overlay_still_present', 'creation_failed', 'indicator_missing', 'indicator_still_present'],
|
|
15
|
+
unknown: ['overlay_api_unavailable', 'overlay_lookup_failed', 'overlay_mismatch', 'context_not_ready', 'application_rolled_back', 'rollback_unknown', 'indicator_api_unavailable'] };
|
|
12
16
|
function empty(status) { return { schema_version: 1, report_status: status, evidence_scope: 'chart_object_api', render_verified: false, pixel_verified: false, items: [] }; }
|
|
17
|
+
function timeRangeOverlap(points, first, last) {
|
|
18
|
+
if (!first || !last || !points.length)
|
|
19
|
+
return null;
|
|
20
|
+
const times = points.map(point => point.timestamp / 1000);
|
|
21
|
+
return Math.max(...times) >= first && Math.min(...times) <= last;
|
|
22
|
+
}
|
|
13
23
|
export function sanitizeDrawingFeedback(raw, allowed) {
|
|
14
24
|
if (raw == null)
|
|
15
25
|
return empty('not_reported');
|
|
@@ -23,17 +33,21 @@ export function sanitizeDrawingFeedback(raw, allowed) {
|
|
|
23
33
|
if (typeof item.id !== 'string' || !item.id || item.id.length > 256 || objects.get(item.id) !== item.kind || seen.has(item.id)
|
|
24
34
|
|| !FEEDBACK_KINDS.includes(item.kind) || !FEEDBACK_STATUSES.includes(item.status) || !FEEDBACK_REASONS.includes(item.reason)
|
|
25
35
|
|| !STATUS_REASONS[item.status].includes(item.reason)
|
|
26
|
-
|| !['unknown', 'outside_time_viewport', 'not_applicable'].includes(item.visibility)
|
|
36
|
+
|| !['unknown', 'outside_time_viewport', 'not_applicable'].includes(item.visibility)
|
|
37
|
+
|| (item.time_range_overlap != null && typeof item.time_range_overlap !== 'boolean'))
|
|
27
38
|
throw Error('invalid_item');
|
|
28
39
|
if ((item.reason === 'outside_time_viewport') !== (item.visibility === 'outside_time_viewport'))
|
|
29
40
|
throw Error('invalid_visibility');
|
|
30
41
|
seen.add(item.id);
|
|
31
42
|
return { id: item.id, kind: item.kind, status: item.status, reason: item.reason, visibility: item.visibility,
|
|
32
|
-
outside_loaded_price_envelope: item.outside_loaded_price_envelope === true
|
|
43
|
+
outside_loaded_price_envelope: item.outside_loaded_price_envelope === true,
|
|
44
|
+
time_range_overlap: typeof item.time_range_overlap === 'boolean' ? item.time_range_overlap : null };
|
|
33
45
|
});
|
|
34
46
|
if (seen.size !== objects.size)
|
|
35
47
|
throw Error('incomplete_report');
|
|
36
|
-
|
|
48
|
+
const evidence_scope = ['chart_object_api', 'indicator_registry', 'mixed_chart_api_and_indicator_registry'].includes(raw.evidence_scope)
|
|
49
|
+
? raw.evidence_scope : 'chart_object_api';
|
|
50
|
+
return { ...empty('reported'), phase: raw.phase, evidence_scope, items };
|
|
37
51
|
}
|
|
38
52
|
catch {
|
|
39
53
|
return empty('invalid');
|
|
@@ -41,14 +55,45 @@ export function sanitizeDrawingFeedback(raw, allowed) {
|
|
|
41
55
|
}
|
|
42
56
|
function expectedOverlay(command, rows, interval, times) {
|
|
43
57
|
const types = { DRAW_HORIZONTAL_LINE: ['ftvHorizontalLine', 'agentHorizontalLines'], DRAW_AGENT_TREND_LINE: ['ftvTrendLine', 'agentTrendLines'],
|
|
44
|
-
DRAW_AGENT_CHANNEL: ['ftvAgentChannel', 'agentChannels'], DRAW_AGENT_RECTANGLE: ['ftvAgentRectangle', 'agentRectangles']
|
|
58
|
+
DRAW_AGENT_CHANNEL: ['ftvAgentChannel', 'agentChannels'], DRAW_AGENT_RECTANGLE: ['ftvAgentRectangle', 'agentRectangles'],
|
|
59
|
+
DRAW_AGENT_FIBONACCI: ['ftvAgentFibonacci', 'agentFibonacci'], DRAW_AGENT_POLYLINE: ['ftvAgentPolyline', 'agentPolylines'],
|
|
60
|
+
DRAW_AGENT_ANNOTATION: ['ftvAgentAnnotation', 'agentAnnotations'] };
|
|
45
61
|
const point = (p) => ({ timestamp: Number(p?.time) * 1000, value: Number(p?.price) });
|
|
46
62
|
const type = command.type;
|
|
47
|
-
if (['DRAW_AGENT_CHANNEL', 'DRAW_AGENT_RECTANGLE'].includes(type) && command.interval !== interval)
|
|
63
|
+
if (['DRAW_AGENT_CHANNEL', 'DRAW_AGENT_RECTANGLE', 'DRAW_AGENT_FIBONACCI', 'DRAW_AGENT_POLYLINE', 'DRAW_AGENT_ANNOTATION'].includes(type) && command.interval !== interval)
|
|
48
64
|
return { skip: 'period_mismatch' };
|
|
49
65
|
let points, sourceTimes = [];
|
|
50
66
|
if (type === 'DRAW_HORIZONTAL_LINE')
|
|
51
67
|
points = [{ timestamp: rows.at(-1)?.time * 1000, value: Number(command.price) }];
|
|
68
|
+
else if (type === 'DRAW_AGENT_ANNOTATION') {
|
|
69
|
+
try {
|
|
70
|
+
const clean = { ...command };
|
|
71
|
+
points = [{ timestamp: clean.time * 1000, value: clean.price }];
|
|
72
|
+
sourceTimes = [clean.time];
|
|
73
|
+
chartAnnotationText(clean);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return { failure: 'invalid_geometry' };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (type === 'DRAW_AGENT_POLYLINE') {
|
|
80
|
+
try {
|
|
81
|
+
points = polylineOverlayPoints(command);
|
|
82
|
+
sourceTimes = command.points.map((p) => p.time);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return { failure: 'invalid_geometry' };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if (type === 'DRAW_AGENT_FIBONACCI') {
|
|
89
|
+
sourceTimes = [command.from?.time, command.to?.time];
|
|
90
|
+
try {
|
|
91
|
+
points = fibonacciOverlayPoints(command);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return { failure: 'invalid_geometry' };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
52
97
|
else if (type === 'DRAW_AGENT_RECTANGLE') {
|
|
53
98
|
sourceTimes = [command.start_time, command.end_time];
|
|
54
99
|
points = [{ timestamp: command.start_time * 1000, value: command.upper_price }, { timestamp: command.end_time * 1000, value: command.lower_price }];
|
|
@@ -94,13 +139,31 @@ export function collectDrawingFeedback(payload, context, chart, previous = [], p
|
|
|
94
139
|
const low = rows.length ? Math.min(...rows.map((r) => r.low)) : NaN, high = rows.length ? Math.max(...rows.map((r) => r.high)) : NaN;
|
|
95
140
|
const items = inventory.map((drawing) => {
|
|
96
141
|
const cmd = commands.find((c) => c.id === drawing.id), item = { id: drawing.id, kind: drawing.kind, status: 'unknown',
|
|
97
|
-
reason: 'context_not_ready', visibility: 'unknown', outside_loaded_price_envelope: false };
|
|
142
|
+
reason: 'context_not_ready', visibility: 'unknown', outside_loaded_price_envelope: false, time_range_overlap: null };
|
|
98
143
|
if (!ready)
|
|
99
144
|
return item;
|
|
100
145
|
if (phase === 'rolled_back' || phase === 'rollback_unknown') {
|
|
101
146
|
item.reason = phase === 'rolled_back' ? 'application_rolled_back' : 'rollback_unknown';
|
|
102
147
|
return item;
|
|
103
148
|
}
|
|
149
|
+
if (['series_line', 'price_band', 'price_sticks'].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 registry = drawing.kind === 'series_line' ? chart?.__dshSeriesLineRegistry
|
|
157
|
+
: drawing.kind === 'price_band' ? chart?.__dshPriceBandRegistry : chart?.__dshPriceSticksRegistry;
|
|
158
|
+
if (!(registry instanceof Map)) {
|
|
159
|
+
item.reason = 'indicator_api_unavailable';
|
|
160
|
+
return item;
|
|
161
|
+
}
|
|
162
|
+
item.status = registry.get(drawing.id) === (drawing.kind === 'series_line' ? cmd.series_hash
|
|
163
|
+
: drawing.kind === 'price_band' ? cmd.band_hash : cmd.sticks_hash) ? 'created' : 'failed';
|
|
164
|
+
item.reason = item.status === 'created' ? 'indicator_registered' : 'indicator_missing';
|
|
165
|
+
return item;
|
|
166
|
+
}
|
|
104
167
|
const expected = expectedOverlay(cmd, rows, context.ui_interval || context.interval, times);
|
|
105
168
|
const prices = expected.points?.map((p) => p.value) ?? [];
|
|
106
169
|
item.outside_loaded_price_envelope = prices.some((p) => p < low || p > high);
|
|
@@ -124,6 +187,8 @@ export function collectDrawingFeedback(payload, context, chart, previous = [], p
|
|
|
124
187
|
item.reason = expected.failure;
|
|
125
188
|
return item;
|
|
126
189
|
}
|
|
190
|
+
item.time_range_overlap = drawing.kind === 'horizontal_line' ? (first && last ? true : null)
|
|
191
|
+
: timeRangeOverlap(expected.points, first, last);
|
|
127
192
|
if (!observed.value) {
|
|
128
193
|
item.status = 'failed';
|
|
129
194
|
item.reason = 'overlay_missing';
|
|
@@ -138,7 +203,12 @@ export function collectDrawingFeedback(payload, context, chart, previous = [], p
|
|
|
138
203
|
&& Number.isFinite(p.value) && Math.abs(p.value - expected.points[i].value) <= Math.max(1, Math.abs(p.value)) * 1e-10)
|
|
139
204
|
&& overlay.extendData?.label === (cmd.label || '') && overlay.extendData?.colorName === (cmd.color || 'info')
|
|
140
205
|
&& (drawing.kind !== 'channel' || overlay.extendData?.showMidline === (cmd.show_midline !== false))
|
|
141
|
-
&& (drawing.kind !== 'rectangle' || overlay.extendData?.showFill === (cmd.show_fill !== false))
|
|
206
|
+
&& (drawing.kind !== 'rectangle' || overlay.extendData?.showFill === (cmd.show_fill !== false))
|
|
207
|
+
&& (drawing.kind !== 'fibonacci_retracement' || JSON.stringify(overlay.extendData?.levels) === JSON.stringify(cmd.levels))
|
|
208
|
+
&& (drawing.kind !== 'labeled_polyline' || JSON.stringify(overlay.extendData?.pointLabels) === JSON.stringify(cmd.points.map((p) => p.label)))
|
|
209
|
+
&& (!['text_annotation', 'number_annotation', 'icon_annotation'].includes(drawing.kind)
|
|
210
|
+
|| overlay.extendData?.annotationKind === cmd.kind && (cmd.kind === 'icon_annotation'
|
|
211
|
+
? overlay.extendData?.annotationIcon === cmd.icon : overlay.extendData?.text === chartAnnotationText(cmd)));
|
|
142
212
|
}
|
|
143
213
|
catch {
|
|
144
214
|
item.reason = 'overlay_lookup_failed';
|
|
@@ -146,12 +216,9 @@ export function collectDrawingFeedback(payload, context, chart, previous = [], p
|
|
|
146
216
|
}
|
|
147
217
|
item.status = same ? 'created' : 'failed';
|
|
148
218
|
item.reason = same ? 'overlay_registered' : 'overlay_mismatch';
|
|
149
|
-
if (same &&
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
item.visibility = 'outside_time_viewport';
|
|
153
|
-
item.reason = 'outside_time_viewport';
|
|
154
|
-
}
|
|
219
|
+
if (same && item.time_range_overlap === false) {
|
|
220
|
+
item.visibility = 'outside_time_viewport';
|
|
221
|
+
item.reason = 'outside_time_viewport';
|
|
155
222
|
}
|
|
156
223
|
return item;
|
|
157
224
|
});
|
|
@@ -166,10 +233,20 @@ export function collectDrawingFeedback(payload, context, chart, previous = [], p
|
|
|
166
233
|
visibility: 'not_applicable', outside_loaded_price_envelope: false });
|
|
167
234
|
continue;
|
|
168
235
|
}
|
|
236
|
+
if (['series_line', 'price_band', 'price_sticks'].includes(drawing.kind)) {
|
|
237
|
+
const registry = drawing.kind === 'series_line' ? chart?.__dshSeriesLineRegistry
|
|
238
|
+
: drawing.kind === 'price_band' ? chart?.__dshPriceBandRegistry : chart?.__dshPriceSticksRegistry;
|
|
239
|
+
items.push({ id: drawing.id, kind: drawing.kind, status: !(registry instanceof Map) ? 'unknown' : registry.has(drawing.id) ? 'failed' : 'removed',
|
|
240
|
+
reason: !(registry instanceof Map) ? 'indicator_api_unavailable' : registry.has(drawing.id) ? 'indicator_still_present' : 'indicator_removed',
|
|
241
|
+
visibility: 'not_applicable', outside_loaded_price_envelope: false });
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
169
244
|
const observed = canRead ? lookup(drawing.id) : { error: true };
|
|
170
245
|
items.push({ id: drawing.id, kind: drawing.kind, status: observed.error ? 'unknown' : observed.value ? 'failed' : 'removed',
|
|
171
246
|
reason: observed.error ? (canRead ? 'overlay_lookup_failed' : 'overlay_api_unavailable') : observed.value ? 'overlay_still_present' : 'overlay_removed', visibility: 'not_applicable',
|
|
172
247
|
outside_loaded_price_envelope: false });
|
|
173
248
|
}
|
|
174
|
-
|
|
249
|
+
const hasSeries = items.some((item) => ['series_line', 'price_band', 'price_sticks'].includes(item.kind)), hasOverlay = items.some((item) => !['series_line', 'price_band', 'price_sticks'].includes(item.kind));
|
|
250
|
+
return { schema_version: 1, phase, evidence_scope: hasSeries ? hasOverlay ? 'mixed_chart_api_and_indicator_registry' : 'indicator_registry' : 'chart_object_api',
|
|
251
|
+
render_verified: false, pixel_verified: false, items };
|
|
175
252
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Validate price-domain geometry and produce exact overlay points, never pixels. */
|
|
2
|
+
export function fibonacciOverlayPoints(c) {
|
|
3
|
+
const validPoint = (p) => Number.isSafeInteger(p?.time) && p.time > 0 && typeof p.price === 'number' && Number.isFinite(p.price) && p.price > 0;
|
|
4
|
+
if (c?.geometry_basis !== 'linear_price_retracement' || !validPoint(c.from) || !validPoint(c.to)
|
|
5
|
+
|| c.from.time >= c.to.time || c.from.price === c.to.price || !Array.isArray(c.ratios) || !c.ratios.length || c.ratios.length > 16
|
|
6
|
+
|| !Array.isArray(c.levels) || c.levels.length !== c.ratios.length)
|
|
7
|
+
throw Error('invalid_fibonacci_geometry');
|
|
8
|
+
const points = [c.from, c.to].map(p => ({ timestamp: p.time * 1000, value: p.price }));
|
|
9
|
+
c.ratios.forEach((r, i) => {
|
|
10
|
+
const level = c.levels[i], expected = c.to.price - r * (c.to.price - c.from.price);
|
|
11
|
+
if (typeof r !== 'number' || !Number.isFinite(r) || r < 0 || r > 1 || i > 0 && r <= c.ratios[i - 1]
|
|
12
|
+
|| level?.ratio !== r || typeof level.price !== 'number' || !Number.isFinite(level.price) || level.price <= 0
|
|
13
|
+
|| Math.abs(level.price - expected) > Math.max(1, Math.abs(expected)) * 1e-12)
|
|
14
|
+
throw Error('invalid_fibonacci_geometry');
|
|
15
|
+
points.push({ timestamp: c.from.time * 1000, value: level.price }, { timestamp: c.to.time * 1000, value: level.price });
|
|
16
|
+
});
|
|
17
|
+
return points;
|
|
18
|
+
}
|
|
@@ -17,6 +17,7 @@ const CHART_ACTIONS = new Set([
|
|
|
17
17
|
'analyze_kline',
|
|
18
18
|
'analyze_key_levels',
|
|
19
19
|
'calc_range',
|
|
20
|
+
'calculate_chart_indicators',
|
|
20
21
|
'fetch_candles',
|
|
21
22
|
'fetch_comparison_candles',
|
|
22
23
|
'fetch_security_workspace',
|
|
@@ -31,6 +32,11 @@ const CHART_ACTIONS = new Set([
|
|
|
31
32
|
'data_source_status',
|
|
32
33
|
'configure_ftshare',
|
|
33
34
|
'test_ftshare_connection',
|
|
35
|
+
'workbench_run_ta',
|
|
36
|
+
'workbench_run_chart_function',
|
|
37
|
+
'workbench_prepare_edit',
|
|
38
|
+
'workbench_apply_edit',
|
|
39
|
+
'workbench_edit_status',
|
|
34
40
|
]);
|
|
35
41
|
export function apply(ctx) {
|
|
36
42
|
const contexts = new ChartContextBroker(join(RUNTIME_DIR, 'views', String(process.pid)), () => Date.now(), RUNTIME_DIR);
|
|
@@ -80,8 +86,13 @@ async function serveRuntimeSession(request, response, contexts) {
|
|
|
80
86
|
const result = await contexts.publish(JSON.parse((await readRequestBody(request)).toString('utf8')));
|
|
81
87
|
sendJson(response, 200, result);
|
|
82
88
|
}
|
|
83
|
-
catch {
|
|
84
|
-
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error instanceof Error && error.message === 'context_state_required') {
|
|
91
|
+
sendJson(response, 409, { ok: false, error: 'context_state_required' });
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
sendJson(response, 400, { ok: false, error: 'context_publication_rejected' });
|
|
95
|
+
}
|
|
85
96
|
}
|
|
86
97
|
return;
|
|
87
98
|
}
|
|
@@ -130,6 +141,12 @@ async function serveRuntimeSession(request, response, contexts) {
|
|
|
130
141
|
sendJson(response, 404, { ok: false, error: 'unsupported_chart_action' });
|
|
131
142
|
return;
|
|
132
143
|
}
|
|
144
|
+
if (action.startsWith('workbench_') && (request.headers['content-type']?.split(';')[0] !== 'application/json'
|
|
145
|
+
|| request.headers.origin && new URL(request.headers.origin).host !== request.headers.host
|
|
146
|
+
|| request.headers['sec-fetch-site'] && !['same-origin', 'none'].includes(String(request.headers['sec-fetch-site'])))) {
|
|
147
|
+
sendJson(response, 403, { ok: false, error: 'invalid_workbench_origin' });
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
133
150
|
const body = await readRequestBody(request);
|
|
134
151
|
await proxyJson(response, `${serviceOrigin(session)}/api/tools/${encodeURIComponent(action)}`, {
|
|
135
152
|
method: 'POST',
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function sanitizePolylinePoints(raw) {
|
|
2
|
+
if (!Array.isArray(raw) || raw.length < 2 || raw.length > 8)
|
|
3
|
+
throw Error('invalid_polyline_points');
|
|
4
|
+
const seen = new Set();
|
|
5
|
+
return raw.map((p, i) => {
|
|
6
|
+
if (typeof p?.label !== 'string' || !p.label.length || [...p.label].length > 16 || p.label !== p.label.trim()
|
|
7
|
+
|| /[\x00-\x1f]/.test(p.label) || seen.has(p.label) || !Number.isSafeInteger(p.time) || p.time <= 0
|
|
8
|
+
|| typeof p.price !== 'number' || !Number.isFinite(p.price) || p.price <= 0
|
|
9
|
+
|| i > 0 && p.time <= raw[i - 1].time)
|
|
10
|
+
throw Error('invalid_polyline_points');
|
|
11
|
+
seen.add(p.label);
|
|
12
|
+
return { label: p.label, time: p.time, price: p.price };
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export function polylineOverlayPoints(command) {
|
|
16
|
+
return sanitizePolylinePoints(command.points).map(p => ({ timestamp: p.time * 1000, value: p.price }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { sanitizePriceSource, sanitizePriceCondition } from "./price-series.js";
|
|
2
|
+
const COLORS = new Set(['info', 'warning', 'success', 'danger']);
|
|
3
|
+
const INTERVALS = new Set(['minute', 'day', 'week', 'month', 'quarter', 'year']);
|
|
4
|
+
function bandSource(raw, output) {
|
|
5
|
+
if (raw?.kind !== 'bbands')
|
|
6
|
+
return sanitizePriceSource(raw);
|
|
7
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw) || Object.keys(raw).length !== 6
|
|
8
|
+
|| raw.output !== output || !Number.isSafeInteger(raw.period) || raw.period < 2 || raw.period > 200
|
|
9
|
+
|| typeof raw.deviation_up !== 'number' || !Number.isFinite(raw.deviation_up)
|
|
10
|
+
|| raw.deviation_up <= 0 || raw.deviation_up > 5
|
|
11
|
+
|| typeof raw.deviation_down !== 'number' || !Number.isFinite(raw.deviation_down)
|
|
12
|
+
|| raw.deviation_down <= 0 || raw.deviation_down > 5 || raw.matype !== 0)
|
|
13
|
+
throw Error('invalid_source_band');
|
|
14
|
+
return { kind: 'bbands', output, period: raw.period, deviation_up: raw.deviation_up,
|
|
15
|
+
deviation_down: raw.deviation_down, matype: 0 };
|
|
16
|
+
}
|
|
17
|
+
/** One bounded object; null pairs are explicit gaps and crossed bounds are refused. */
|
|
18
|
+
export function sanitizePriceBandCommand(raw, expectedBars, interval) {
|
|
19
|
+
if (raw?.type !== 'DRAW_AGENT_PRICE_BAND' || typeof raw.id !== 'string' || !/^band_[a-f0-9]{24}$/.test(raw.id)
|
|
20
|
+
|| !INTERVALS.has(raw.interval) || !COLORS.has(raw.color) || typeof raw.label !== 'string' || raw.label.length > 48
|
|
21
|
+
|| !/^[a-f0-9]{64}$/.test(raw.band_hash) || raw.row_hash != null && !/^[a-f0-9]{16}$/.test(raw.row_hash)
|
|
22
|
+
|| !Number.isSafeInteger(raw.bar_count)
|
|
23
|
+
|| raw.bar_count < 1 || raw.bar_count > 4000 || raw.interval === interval && raw.bar_count !== expectedBars
|
|
24
|
+
|| !Array.isArray(raw.upper_values) || !Array.isArray(raw.lower_values)
|
|
25
|
+
|| raw.upper_values.length !== raw.bar_count || raw.lower_values.length !== raw.bar_count)
|
|
26
|
+
throw Error('invalid_source_band');
|
|
27
|
+
const upperSource = bandSource(raw.upper_source, 'upperband');
|
|
28
|
+
const lowerSource = bandSource(raw.lower_source, 'lowerband');
|
|
29
|
+
const boll = upperSource.kind === 'bbands';
|
|
30
|
+
if (boll !== (lowerSource.kind === 'bbands') || boll && (raw.condition != null || JSON.stringify({ ...upperSource, output: null }) !== JSON.stringify({ ...lowerSource, output: null })
|
|
31
|
+
|| !Array.isArray(raw.middle_values) || raw.middle_values.length !== raw.bar_count)
|
|
32
|
+
|| !boll && raw.middle_values !== undefined)
|
|
33
|
+
throw Error('invalid_source_band');
|
|
34
|
+
let present = 0;
|
|
35
|
+
for (let i = 0; i < raw.bar_count; i++) {
|
|
36
|
+
const upper = raw.upper_values[i], lower = raw.lower_values[i];
|
|
37
|
+
const middle = boll ? raw.middle_values[i] : null;
|
|
38
|
+
if (upper === null && lower === null && middle === null)
|
|
39
|
+
continue;
|
|
40
|
+
if (typeof upper !== 'number' || typeof lower !== 'number' || !Number.isFinite(upper) || !Number.isFinite(lower)
|
|
41
|
+
|| lower <= 0 || upper <= lower || boll && (typeof middle !== 'number' || !Number.isFinite(middle)
|
|
42
|
+
|| !(lower < middle && middle < upper)))
|
|
43
|
+
throw Error('invalid_source_band');
|
|
44
|
+
present++;
|
|
45
|
+
}
|
|
46
|
+
if (!present)
|
|
47
|
+
throw Error('invalid_source_band');
|
|
48
|
+
return { type: 'DRAW_AGENT_PRICE_BAND', id: raw.id, interval: raw.interval, label: raw.label, color: raw.color,
|
|
49
|
+
bar_count: raw.bar_count, upper_source: upperSource,
|
|
50
|
+
lower_source: lowerSource, condition: sanitizePriceCondition(raw.condition),
|
|
51
|
+
upper_values: [...raw.upper_values], lower_values: [...raw.lower_values], band_hash: raw.band_hash,
|
|
52
|
+
...(boll ? { middle_values: [...raw.middle_values] } : {}),
|
|
53
|
+
...(raw.row_hash ? { row_hash: raw.row_hash } : {}) };
|
|
54
|
+
}
|
|
55
|
+
export function bandObservation(raw) { return { band_hash: raw.band_hash, bar_count: raw.bar_count }; }
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Bounded, candle-index-aligned AI price line. No formula source or arbitrary arrays from the host. */
|
|
2
|
+
const COLORS = new Set(['info', 'warning', 'success', 'danger']);
|
|
3
|
+
const FIELDS = new Set(['open', 'high', 'low', 'close']);
|
|
4
|
+
const OPS = new Set(['gt', 'gte', 'lt', 'lte']);
|
|
5
|
+
function source(raw) {
|
|
6
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw))
|
|
7
|
+
throw Error('invalid_series_source');
|
|
8
|
+
const keys = Object.keys(raw);
|
|
9
|
+
if (FIELDS.has(raw.kind) && keys.length === 1)
|
|
10
|
+
return { kind: raw.kind };
|
|
11
|
+
if ((raw.kind === 'sma' || raw.kind === 'ema') && keys.length === 2 && Number.isSafeInteger(raw.period) && raw.period >= 2 && raw.period <= 200)
|
|
12
|
+
return { kind: raw.kind, period: raw.period };
|
|
13
|
+
throw Error('invalid_series_source');
|
|
14
|
+
}
|
|
15
|
+
function condition(raw) {
|
|
16
|
+
if (raw == null)
|
|
17
|
+
return null;
|
|
18
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw) || Object.keys(raw).length !== 3 || !OPS.has(raw.op))
|
|
19
|
+
throw Error('invalid_series_condition');
|
|
20
|
+
const left = source(raw.left), right = raw.right;
|
|
21
|
+
if (!right || typeof right !== 'object' || Array.isArray(right) || Object.keys(right).length !== 1)
|
|
22
|
+
throw Error('invalid_series_condition');
|
|
23
|
+
if (right.source !== undefined)
|
|
24
|
+
return { left, op: raw.op, right: { source: source(right.source) } };
|
|
25
|
+
if (typeof right.constant === 'number' && Number.isFinite(right.constant) && right.constant > 0)
|
|
26
|
+
return { left, op: raw.op, right: { constant: right.constant } };
|
|
27
|
+
throw Error('invalid_series_condition');
|
|
28
|
+
}
|
|
29
|
+
export { source as sanitizePriceSource, condition as sanitizePriceCondition };
|
|
30
|
+
export function sanitizePriceSeriesCommand(raw, expectedBars, interval) {
|
|
31
|
+
if (raw?.type !== 'DRAW_AGENT_SERIES_LINE' || typeof raw.id !== 'string' || !/^series_[a-f0-9]{24}$/.test(raw.id)
|
|
32
|
+
|| !['minute', 'day', 'week', 'month', 'quarter', 'year'].includes(raw.interval)
|
|
33
|
+
|| !COLORS.has(raw.color) || typeof raw.label !== 'string' || raw.label.length > 48
|
|
34
|
+
|| !/^[a-f0-9]{64}$/.test(raw.series_hash) || raw.row_hash != null && !/^[a-f0-9]{16}$/.test(raw.row_hash)
|
|
35
|
+
|| !Number.isSafeInteger(raw.bar_count)
|
|
36
|
+
|| raw.bar_count < 1 || raw.bar_count > 4000 || raw.interval === interval && raw.bar_count !== expectedBars
|
|
37
|
+
|| !Array.isArray(raw.values) || raw.values.length !== raw.bar_count
|
|
38
|
+
|| raw.values.some((value) => value !== null && (typeof value !== 'number' || !Number.isFinite(value) || value <= 0))
|
|
39
|
+
|| !raw.values.some((value) => value !== null))
|
|
40
|
+
throw Error('invalid_source_series');
|
|
41
|
+
return { type: 'DRAW_AGENT_SERIES_LINE', id: raw.id, interval: raw.interval, label: raw.label, color: raw.color,
|
|
42
|
+
bar_count: raw.bar_count, source: source(raw.source), condition: condition(raw.condition),
|
|
43
|
+
values: [...raw.values], series_hash: raw.series_hash, ...(raw.row_hash ? { row_hash: raw.row_hash } : {}) };
|
|
44
|
+
}
|
|
45
|
+
export function seriesObservation(raw) {
|
|
46
|
+
return { series_hash: raw.series_hash, bar_count: raw.bar_count };
|
|
47
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { sanitizePriceSource, sanitizePriceCondition } from "./price-series.js";
|
|
2
|
+
const COLORS = new Set(['info', 'warning', 'success', 'danger']);
|
|
3
|
+
const INTERVALS = new Set(['minute', 'day', 'week', 'month', 'quarter', 'year']);
|
|
4
|
+
/** A bounded sequence of independent vertical price sticks. */
|
|
5
|
+
export function sanitizePriceSticksCommand(raw, expectedBars, interval) {
|
|
6
|
+
if (raw?.type !== 'DRAW_AGENT_PRICE_STICKS' || typeof raw.id !== 'string' || !/^sticks_[a-f0-9]{24}$/.test(raw.id)
|
|
7
|
+
|| !INTERVALS.has(raw.interval) || !COLORS.has(raw.color) || typeof raw.label !== 'string' || raw.label.length > 48
|
|
8
|
+
|| !/^[a-f0-9]{64}$/.test(raw.sticks_hash) || raw.row_hash != null && !/^[a-f0-9]{16}$/.test(raw.row_hash)
|
|
9
|
+
|| !Number.isSafeInteger(raw.bar_count) || raw.bar_count < 1 || raw.bar_count > 4000
|
|
10
|
+
|| raw.interval === interval && raw.bar_count !== expectedBars
|
|
11
|
+
|| !Array.isArray(raw.start_values) || !Array.isArray(raw.end_values)
|
|
12
|
+
|| raw.start_values.length !== raw.bar_count || raw.end_values.length !== raw.bar_count)
|
|
13
|
+
throw Error('invalid_source_sticks');
|
|
14
|
+
let present = 0;
|
|
15
|
+
for (let i = 0; i < raw.bar_count; i++) {
|
|
16
|
+
const start = raw.start_values[i], end = raw.end_values[i];
|
|
17
|
+
if (start === null && end === null)
|
|
18
|
+
continue;
|
|
19
|
+
if (typeof start !== 'number' || typeof end !== 'number' || !Number.isFinite(start) || !Number.isFinite(end)
|
|
20
|
+
|| start <= 0 || end <= 0 || start === end)
|
|
21
|
+
throw Error('invalid_source_sticks');
|
|
22
|
+
present++;
|
|
23
|
+
}
|
|
24
|
+
if (!present)
|
|
25
|
+
throw Error('invalid_source_sticks');
|
|
26
|
+
return { type: 'DRAW_AGENT_PRICE_STICKS', id: raw.id, interval: raw.interval, label: raw.label, color: raw.color,
|
|
27
|
+
bar_count: raw.bar_count, start_source: sanitizePriceSource(raw.start_source),
|
|
28
|
+
end_source: sanitizePriceSource(raw.end_source), condition: sanitizePriceCondition(raw.condition),
|
|
29
|
+
start_values: [...raw.start_values], end_values: [...raw.end_values], sticks_hash: raw.sticks_hash,
|
|
30
|
+
...(raw.row_hash ? { row_hash: raw.row_hash } : {}) };
|
|
31
|
+
}
|
|
32
|
+
export function sticksObservation(raw) { return { sticks_hash: raw.sticks_hash, bar_count: raw.bar_count }; }
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Canonical AI-owned text, numeric and icon annotations anchored to exact chart bars. */
|
|
2
|
+
export declare const CHART_ANNOTATION_ICONS: readonly ["arrow_up", "arrow_down", "diamond"];
|
|
3
|
+
export declare function sanitizeChartAnnotation(raw: any): any;
|
|
4
|
+
export declare function chartAnnotationText(command: any): string;
|
|
@@ -3,4 +3,6 @@ export declare function text(value: unknown, max?: number): string;
|
|
|
3
3
|
export declare function sanitizeDataProvenance(raw: any): any;
|
|
4
4
|
export declare function sanitizeChartContext(raw: any): any;
|
|
5
5
|
export declare function observationKey(raw: any): string;
|
|
6
|
+
/** Identity required for editing the current source, excluding transient UI state. */
|
|
7
|
+
export declare function drawingSourceKey(raw: any): string;
|
|
6
8
|
export declare function drawingInventory(payload: any): any[];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { BetterSidebarService } from 'dsh-better-sidebar';
|
|
2
|
-
import type
|
|
2
|
+
import { type Sessions } from './conversation';
|
|
3
3
|
/** The chart itself, shared by every host tab: Better Sidebar and the native one. */
|
|
4
|
-
export declare function KlineTabContent({ sessions, conversationId }: {
|
|
4
|
+
export declare function KlineTabContent({ sessions, conversationId, visible }: {
|
|
5
5
|
sessions: Sessions;
|
|
6
6
|
conversationId?: string;
|
|
7
|
+
visible?: boolean;
|
|
7
8
|
}): import("react").JSX.Element;
|
|
8
9
|
export declare function BetterSidebarBridge({ service, sessions }: {
|
|
9
10
|
service: BetterSidebarService;
|
|
@@ -13,6 +13,7 @@ interface Options {
|
|
|
13
13
|
bindSource?: (token: string, previous: string | null) => void;
|
|
14
14
|
confirmSource?: (token: string, confirmed: boolean) => void;
|
|
15
15
|
onSourceStatus?: (status: any) => void;
|
|
16
|
+
onPublished?: (publication: any) => void;
|
|
16
17
|
}
|
|
17
18
|
export declare function createChartContextPublisher(options: Options): {
|
|
18
19
|
notify(): void;
|
|
@@ -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
|
+
}
|
|
@@ -17,15 +17,23 @@ export interface SessionEventWindow {
|
|
|
17
17
|
event: any;
|
|
18
18
|
}[];
|
|
19
19
|
}
|
|
20
|
-
export interface
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
export interface SessionListSnapshot {
|
|
21
|
+
current?: string;
|
|
22
|
+
byId?: Record<string, {
|
|
23
|
+
retainedBy?: {
|
|
24
|
+
mainView?: number;
|
|
25
|
+
};
|
|
23
26
|
}>;
|
|
27
|
+
}
|
|
28
|
+
export interface Sessions {
|
|
29
|
+
list: Observable<SessionListSnapshot>;
|
|
24
30
|
binding(id: string): {
|
|
25
31
|
session: Observable<ConversationSnapshot>;
|
|
26
32
|
eventSource?: Observable<SessionEventWindow>;
|
|
27
33
|
} | undefined;
|
|
28
34
|
}
|
|
35
|
+
/** Resolve one active conversation across the two public DSH session shapes. */
|
|
36
|
+
export declare function currentConversationId(snapshot: SessionListSnapshot): string | undefined;
|
|
29
37
|
export declare function latestChartFromEvents(entries: SessionEventWindow['entries']): ChartReference | undefined;
|
|
30
38
|
export declare function latestChart(nodes: readonly any[]): ChartReference | undefined;
|
|
31
39
|
export declare function chartStorageKey(conversationId: string): string;
|
|
@@ -31,7 +31,7 @@ export interface KlineEmbedApi {
|
|
|
31
31
|
* gets `{}` — no attribute, so none of the embedding CSS can ever match it.
|
|
32
32
|
*/
|
|
33
33
|
export declare function klineHostDataset({ embedded, chrome }?: Pick<KlineHostProps, 'embedded' | 'chrome'>): Record<string, string>;
|
|
34
|
-
/**
|
|
34
|
+
/** Normalize host identities using the chart's input conventions, retaining the market. */
|
|
35
35
|
export declare function symbolKey(value: string | undefined): string;
|
|
36
|
-
/**
|
|
36
|
+
/** Only an exact normalized identity is the same instrument; empty never matches. */
|
|
37
37
|
export declare function sameSymbol(left: string | undefined, right: string | undefined): boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "0.4
|
|
1
|
+
export declare const PACKAGE_VERSION = "0.6.4";
|
|
2
2
|
export declare function mountKlineView(root: any, payload: any, dependencies?: {}): () => void;
|
|
@@ -18,10 +18,6 @@ export interface HostServices {
|
|
|
18
18
|
slots?: SlotsService;
|
|
19
19
|
/** The free-canvas service, present only when the canvas plugin is loaded. */
|
|
20
20
|
canvas?: CanvasService;
|
|
21
|
-
/** DSH's own right-Sidebar tab registry, present on hosts that own that column. */
|
|
22
|
-
sidebarRightTabs?: SidebarRightTabsService;
|
|
23
|
-
/** DSH's own right-Sidebar navigation face, the way a page type is opened. */
|
|
24
|
-
sidebarRight?: SidebarRightService;
|
|
25
21
|
}
|
|
26
22
|
/** The slice of the host `slots` service this plugin registers into. */
|
|
27
23
|
export interface SlotsService {
|
|
@@ -32,40 +28,8 @@ export interface SlotsService {
|
|
|
32
28
|
id?: string;
|
|
33
29
|
order?: number;
|
|
34
30
|
label?: string;
|
|
35
|
-
/** Business props for the body; the framework adds its own standard share. */
|
|
36
|
-
inject?: (...args: any[]) => Record<string, unknown>;
|
|
37
31
|
}, component: unknown): () => void;
|
|
38
32
|
}
|
|
39
|
-
/** One tab type as DSH's native right Sidebar registry takes it (the members this plugin sets). */
|
|
40
|
-
export interface NativeSidebarTabDefinition {
|
|
41
|
-
/** Implementation identity, unique across registrations; the body seat dispatches by it. */
|
|
42
|
-
id: string;
|
|
43
|
-
/** Type discriminator — what `openTab` names and what every tab of this type is. */
|
|
44
|
-
kind: string;
|
|
45
|
-
/** `extension` is the band for a type shipped outside the product, which is this one. */
|
|
46
|
-
priority?: 'extension' | 'builtin' | 'fallback';
|
|
47
|
-
/** The chip text captured when a tab of this type opens. */
|
|
48
|
-
title: (address: string) => string;
|
|
49
|
-
/** Entry boxes the host's guide page offers for opening this type. */
|
|
50
|
-
guide?: readonly NativeSidebarGuideEntry[];
|
|
51
|
-
}
|
|
52
|
-
/** One guide entry: a capsule that opens this tab type when picked. */
|
|
53
|
-
export interface NativeSidebarGuideEntry {
|
|
54
|
-
id: string;
|
|
55
|
-
order: number;
|
|
56
|
-
title: () => string;
|
|
57
|
-
description?: () => string;
|
|
58
|
-
}
|
|
59
|
-
/** The slice of the host right-Sidebar tab registry this plugin registers into. */
|
|
60
|
-
export interface SidebarRightTabsService {
|
|
61
|
-
register(definition: NativeSidebarTabDefinition): () => void;
|
|
62
|
-
}
|
|
63
|
-
/** The slice of the host right-Sidebar navigation face this plugin uses. */
|
|
64
|
-
export interface SidebarRightService {
|
|
65
|
-
openTab(kind: string, options?: {
|
|
66
|
-
params?: unknown;
|
|
67
|
-
}): void;
|
|
68
|
-
}
|
|
69
33
|
/** The slice of the host free-canvas service this plugin registers into. */
|
|
70
34
|
export interface CanvasService {
|
|
71
35
|
registerType(descriptor: CanvasPanelType): () => void;
|