@dsh-ft/dsh-fft-paper-trading 0.7.0 → 0.7.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/lib/client.js +9 -1
- package/package.json +2 -5
- package/src/client/index.js +8 -0
- package/node_modules/@ftshare-lab/dsh-kline/CHANGELOG.md +0 -564
- package/node_modules/@ftshare-lab/dsh-kline/LICENSE +0 -21
- package/node_modules/@ftshare-lab/dsh-kline/PROVENANCE.md +0 -13
- package/node_modules/@ftshare-lab/dsh-kline/README.en.md +0 -265
- package/node_modules/@ftshare-lab/dsh-kline/README.md +0 -281
- package/node_modules/@ftshare-lab/dsh-kline/chart_service.py +0 -686
- package/node_modules/@ftshare-lab/dsh-kline/config/basic-symbols.json +0 -570
- package/node_modules/@ftshare-lab/dsh-kline/config/dsh-kline.patch.yml +0 -4
- package/node_modules/@ftshare-lab/dsh-kline/config/dsh-tool-catalog.json +0 -3783
- package/node_modules/@ftshare-lab/dsh-kline/cordis.patch.yml +0 -33
- package/node_modules/@ftshare-lab/dsh-kline/core/__init__.py +0 -0
- package/node_modules/@ftshare-lab/dsh-kline/core/adjustment.py +0 -16
- package/node_modules/@ftshare-lab/dsh-kline/core/calc.py +0 -683
- package/node_modules/@ftshare-lab/dsh-kline/core/rows.py +0 -228
- package/node_modules/@ftshare-lab/dsh-kline/core/ta_engine.py +0 -99
- package/node_modules/@ftshare-lab/dsh-kline/lib/candle-sequence.js +0 -15
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-adjustment.js +0 -7
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-annotations.js +0 -33
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-applications.js +0 -171
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-context.js +0 -164
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-observation.js +0 -241
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-service-status.js +0 -82
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-source-status.js +0 -39
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-sources.js +0 -349
- package/node_modules/@ftshare-lab/dsh-kline/lib/client.js +0 -15445
- package/node_modules/@ftshare-lab/dsh-kline/lib/drawing-feedback.js +0 -252
- package/node_modules/@ftshare-lab/dsh-kline/lib/fibonacci.js +0 -18
- package/node_modules/@ftshare-lab/dsh-kline/lib/ftshare-settings-bridge.js +0 -159
- package/node_modules/@ftshare-lab/dsh-kline/lib/index.js +0 -279
- package/node_modules/@ftshare-lab/dsh-kline/lib/labeled-polyline.js +0 -17
- package/node_modules/@ftshare-lab/dsh-kline/lib/price-bands.js +0 -55
- package/node_modules/@ftshare-lab/dsh-kline/lib/price-series.js +0 -47
- package/node_modules/@ftshare-lab/dsh-kline/lib/price-sticks.js +0 -32
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/candle-sequence.d.ts +0 -2
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/chart-adjustment.d.ts +0 -2
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/chart-annotations.d.ts +0 -4
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/chart-applications.d.ts +0 -26
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/chart-context.d.ts +0 -14
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/chart-observation.d.ts +0 -8
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/chart-service-status.d.ts +0 -22
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/chart-source-status.d.ts +0 -47
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/chart-sources.d.ts +0 -25
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/BetterSidebarTab.d.ts +0 -12
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/ClassicShell.d.ts +0 -4
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/KlineContent.d.ts +0 -37
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/PaperKlinePanel.d.ts +0 -15
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/canvas-panel.d.ts +0 -33
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/chart-apply.d.ts +0 -13
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/chart-context.d.ts +0 -23
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/chart-session-resolver.d.ts +0 -2
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/client-context.d.ts +0 -14
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/conversation.d.ts +0 -39
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/default-tab.d.ts +0 -3
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/embed.d.ts +0 -37
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/generated-view.d.ts +0 -2
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/horizontal-lines.d.ts +0 -1
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/host-services.d.ts +0 -55
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/index.d.ts +0 -4
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/mode-preferences.d.ts +0 -13
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/native-sidebar-contract.d.ts +0 -52
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/native-sidebar-register.d.ts +0 -46
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/native-sidebar-services.d.ts +0 -45
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/native-sidebar.d.ts +0 -47
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/sidebar-integration.d.ts +0 -12
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/ui-onboarding.d.ts +0 -13
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/version.d.ts +0 -1
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/drawing-feedback.d.ts +0 -5
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/fibonacci.d.ts +0 -5
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/ftshare-settings-bridge.d.ts +0 -50
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/index.d.ts +0 -26
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/labeled-polyline.d.ts +0 -11
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/price-bands.d.ts +0 -3
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/price-series.d.ts +0 -5
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/price-sticks.d.ts +0 -3
- package/node_modules/@ftshare-lab/dsh-kline/package.json +0 -136
- package/node_modules/@ftshare-lab/dsh-kline/requirements.txt +0 -6
- package/node_modules/@ftshare-lab/dsh-kline/scripts/bootstrap.sh +0 -5
- package/node_modules/@ftshare-lab/dsh-kline/scripts/dsh-bootstrap.mjs +0 -179
- package/node_modules/@ftshare-lab/dsh-kline/scripts/dsh-mcp-plugin.mjs +0 -27
- package/node_modules/@ftshare-lab/dsh-kline/scripts/run-dsh-kline.mjs +0 -655
- package/node_modules/@ftshare-lab/dsh-kline/scripts/run-dsh-kline.sh +0 -5
- package/node_modules/@ftshare-lab/dsh-kline/server.py +0 -1734
- package/node_modules/@ftshare-lab/dsh-kline/tools/__init__.py +0 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/annotations.py +0 -119
- package/node_modules/@ftshare-lab/dsh-kline/tools/baostock_source.py +0 -176
- package/node_modules/@ftshare-lab/dsh-kline/tools/calc.py +0 -39
- package/node_modules/@ftshare-lab/dsh-kline/tools/channel_candidates.py +0 -260
- package/node_modules/@ftshare-lab/dsh-kline/tools/channel_preview.py +0 -82
- package/node_modules/@ftshare-lab/dsh-kline/tools/channels.py +0 -104
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_applications.py +0 -204
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_context.py +0 -186
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_edits.py +0 -345
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_functions.py +0 -466
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_indicators.py +0 -63
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_measurements.py +0 -84
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_source_status.py +0 -32
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_sources.py +0 -31
- package/node_modules/@ftshare-lab/dsh-kline/tools/draw.py +0 -394
- package/node_modules/@ftshare-lab/dsh-kline/tools/drawing_feedback.py +0 -45
- package/node_modules/@ftshare-lab/dsh-kline/tools/drawing_interaction.py +0 -117
- package/node_modules/@ftshare-lab/dsh-kline/tools/drawing_verification.py +0 -141
- package/node_modules/@ftshare-lab/dsh-kline/tools/fetch.py +0 -4681
- package/node_modules/@ftshare-lab/dsh-kline/tools/fibonacci.py +0 -83
- package/node_modules/@ftshare-lab/dsh-kline/tools/foreign_daily.py +0 -185
- package/node_modules/@ftshare-lab/dsh-kline/tools/free_sources.py +0 -483
- package/node_modules/@ftshare-lab/dsh-kline/tools/lines.py +0 -91
- package/node_modules/@ftshare-lab/dsh-kline/tools/pivots.py +0 -60
- package/node_modules/@ftshare-lab/dsh-kline/tools/polylines.py +0 -125
- package/node_modules/@ftshare-lab/dsh-kline/tools/price_bands.py +0 -165
- package/node_modules/@ftshare-lab/dsh-kline/tools/price_series.py +0 -162
- package/node_modules/@ftshare-lab/dsh-kline/tools/price_sticks.py +0 -114
- package/node_modules/@ftshare-lab/dsh-kline/tools/range_candidates.py +0 -170
- package/node_modules/@ftshare-lab/dsh-kline/tools/rectangles.py +0 -76
- package/node_modules/@ftshare-lab/dsh-kline/tools/regression_channels.py +0 -87
- package/node_modules/@ftshare-lab/dsh-kline/tools/ta_functions.py +0 -228
- package/node_modules/@ftshare-lab/dsh-kline/tools/trend_lines.py +0 -106
- package/node_modules/@ftshare-lab/dsh-kline/tools/watchlist.py +0 -149
- package/node_modules/@ftshare-lab/dsh-kline/view/ft-logo.jpg +0 -0
- package/node_modules/@ftshare-lab/dsh-kline/view/vendor/klinecharts.min.js +0 -7
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { homedir } from 'node:os';
|
|
3
|
-
import { join, resolve } from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { ChartServiceUnavailable, readServiceLocator, probeChartService, unavailableService } from "./chart-service-status.js";
|
|
6
|
-
import { ChartContextBroker } from "./chart-context.js";
|
|
7
|
-
import { ChartApplications } from "./chart-applications.js";
|
|
8
|
-
import { startFtshareSettingsBridge } from "./ftshare-settings-bridge.js";
|
|
9
|
-
export const name = 'dsh-kline-sidebar';
|
|
10
|
-
export const inject = ['webServer'];
|
|
11
|
-
const RUNTIME_DIR = runtimeDirectory();
|
|
12
|
-
const RUNTIME_FILE = join(RUNTIME_DIR, 'services', `${process.pid}.json`);
|
|
13
|
-
const STATE_DIR = stateDirectory();
|
|
14
|
-
const SESSION_DIR = join(RUNTIME_DIR, 'sessions');
|
|
15
|
-
const VENDOR_FILE = fileURLToPath(new URL('../view/vendor/klinecharts.min.js', import.meta.url));
|
|
16
|
-
const LOGO_FILE = fileURLToPath(new URL('../view/ft-logo.jpg', import.meta.url));
|
|
17
|
-
const MAX_PROXY_BYTES = 8 * 1024 * 1024;
|
|
18
|
-
const CHART_ACTIONS = new Set([
|
|
19
|
-
'analyze_kline',
|
|
20
|
-
'analyze_key_levels',
|
|
21
|
-
'calc_range',
|
|
22
|
-
'calculate_chart_indicators',
|
|
23
|
-
'fetch_candles',
|
|
24
|
-
'fetch_comparison_candles',
|
|
25
|
-
'fetch_security_workspace',
|
|
26
|
-
'fetch_market_pulse',
|
|
27
|
-
'fetch_market_board_detail',
|
|
28
|
-
'fetch_security_intelligence',
|
|
29
|
-
'watchlist_get',
|
|
30
|
-
'watchlist_save',
|
|
31
|
-
'market_ticker',
|
|
32
|
-
'search_symbols',
|
|
33
|
-
'symbol_directory',
|
|
34
|
-
'data_source_status',
|
|
35
|
-
'configure_ftshare',
|
|
36
|
-
'test_ftshare_connection',
|
|
37
|
-
'workbench_run_ta',
|
|
38
|
-
'workbench_run_chart_function',
|
|
39
|
-
'workbench_prepare_edit',
|
|
40
|
-
'workbench_apply_edit',
|
|
41
|
-
'workbench_edit_status',
|
|
42
|
-
]);
|
|
43
|
-
export function apply(ctx) {
|
|
44
|
-
const contexts = new ChartContextBroker(join(RUNTIME_DIR, 'views', String(process.pid)), () => Date.now(), RUNTIME_DIR);
|
|
45
|
-
ctx.effect(() => ctx.webServer.register({
|
|
46
|
-
kind: 'prefix',
|
|
47
|
-
path: '/dsh-kline',
|
|
48
|
-
handler: (request, response) => serveRuntimeSession(request, response, contexts),
|
|
49
|
-
}), 'dsh-kline: chart session route');
|
|
50
|
-
ctx.inject?.(['systemPrompt'], scoped => {
|
|
51
|
-
if (typeof scoped.systemPrompt?.context !== 'function')
|
|
52
|
-
return;
|
|
53
|
-
scoped.effect(() => scoped.systemPrompt.context({ name: 'dsh-kline:current-view', order: 350,
|
|
54
|
-
text: context => contexts.prompt(context) }), 'dsh-kline: current chart context');
|
|
55
|
-
});
|
|
56
|
-
ctx.inject?.(['ftshareSettings'], scoped => {
|
|
57
|
-
if (!scoped.ftshareSettings?.apiKey)
|
|
58
|
-
return;
|
|
59
|
-
const bridge = startFtshareSettingsBridge({ settings: scoped.ftshareSettings, runtimeDirectory: RUNTIME_DIR });
|
|
60
|
-
scoped.effect(() => () => { void bridge.dispose(); }, 'dsh-kline: FTShare settings credential bridge');
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
async function serveRuntimeSession(request, response, contexts) {
|
|
64
|
-
const url = new URL(request.url ?? '/', 'http://localhost');
|
|
65
|
-
const pathname = url.pathname;
|
|
66
|
-
try {
|
|
67
|
-
if (pathname === '/dsh-kline/healthz') {
|
|
68
|
-
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
69
|
-
sendJson(response, 405, { ok: false, error: 'method_not_allowed' });
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const version = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
73
|
-
const diagnostics = { version, host_process_id: process.pid, locator_path: RUNTIME_FILE,
|
|
74
|
-
log_path: join(STATE_DIR, 'logs', `backend-${process.pid}.log`) };
|
|
75
|
-
try {
|
|
76
|
-
const locator = await readServiceLocator(RUNTIME_FILE, process.pid);
|
|
77
|
-
await probeChartService(locator);
|
|
78
|
-
sendJson(response, 200, { ok: true, ...diagnostics, process_id: locator.process_id,
|
|
79
|
-
service_url: locator.service_url }, request.method === 'HEAD');
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
let reason = error instanceof ChartServiceUnavailable ? error.reason : 'service_locator_invalid';
|
|
83
|
-
if (reason === 'service_locator_missing') {
|
|
84
|
-
try {
|
|
85
|
-
const status = JSON.parse(await readFile(join(STATE_DIR, 'logs', `backend-${process.pid}.json`), 'utf8'));
|
|
86
|
-
if (status.host_process_id === process.pid && Number.isSafeInteger(status.launcher_process_id)) {
|
|
87
|
-
process.kill(status.launcher_process_id, 0);
|
|
88
|
-
if (status.phase === 'preparing')
|
|
89
|
-
reason = 'runtime_preparing';
|
|
90
|
-
else if (status.phase === 'recovering')
|
|
91
|
-
reason = 'runtime_recovering';
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
catch { /* A missing or stale diagnostic cannot prove readiness. */ }
|
|
95
|
-
}
|
|
96
|
-
sendJson(response, 503, { ...unavailableService(reason), ...diagnostics }, request.method === 'HEAD');
|
|
97
|
-
}
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (pathname === '/dsh-kline/recovery' && request.method === 'GET') {
|
|
101
|
-
try {
|
|
102
|
-
const recovery = await new ChartApplications(RUNTIME_DIR).recover(url.searchParams.get('conversation') ?? '');
|
|
103
|
-
sendJson(response, 200, recovery);
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
sendJson(response, 200, { ok: false, error: 'confirmed_chart_recovery_unavailable' });
|
|
107
|
-
}
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (pathname === '/dsh-kline/context') {
|
|
111
|
-
if (request.method !== 'POST') {
|
|
112
|
-
sendJson(response, 405, { ok: false, error: 'method_not_allowed' });
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
if (request.headers['content-type']?.split(';')[0] !== 'application/json'
|
|
116
|
-
|| request.headers.origin && new URL(request.headers.origin).host !== request.headers.host) {
|
|
117
|
-
sendJson(response, 403, { ok: false, error: 'invalid_context_origin' });
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
const result = await contexts.publish(JSON.parse((await readRequestBody(request)).toString('utf8')));
|
|
122
|
-
sendJson(response, 200, result);
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
if (error instanceof Error && error.message === 'context_state_required') {
|
|
126
|
-
sendJson(response, 409, { ok: false, error: 'context_state_required' });
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
sendJson(response, 400, { ok: false, error: 'context_publication_rejected' });
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
// Static browser assets must remain available before the first chart session exists.
|
|
135
|
-
if (pathname === '/dsh-kline/vendor/klinecharts.min.js' && (request.method === 'GET' || request.method === 'HEAD')) {
|
|
136
|
-
const body = await readFile(VENDOR_FILE);
|
|
137
|
-
sendBytes(response, 200, body, 'text/javascript; charset=utf-8', request.method === 'HEAD');
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (pathname === '/dsh-kline/logo.jpg' && (request.method === 'GET' || request.method === 'HEAD')) {
|
|
141
|
-
const body = await readFile(LOGO_FILE);
|
|
142
|
-
sendBytes(response, 200, body, 'image/jpeg', request.method === 'HEAD');
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
// Never infer a chart from the global latest publication. The browser
|
|
146
|
-
// obtains this opaque reference from the owning conversation's result.
|
|
147
|
-
if (pathname === '/dsh-kline/session' || pathname === '/dsh-kline/data') {
|
|
148
|
-
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
149
|
-
sendJson(response, 405, { ok: false, error: 'method_not_allowed' });
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
const token = url.searchParams.get('session') ?? '';
|
|
153
|
-
if (!/^[A-Za-z0-9_-]{32}$/.test(token)) {
|
|
154
|
-
sendJson(response, 200, { ok: false, error: 'chart_session_required' });
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const saved = JSON.parse(await readFile(join(SESSION_DIR, `${token}.json`), 'utf8'));
|
|
158
|
-
if (saved.session !== token || saved.ok !== true)
|
|
159
|
-
throw new Error('invalid_chart_snapshot');
|
|
160
|
-
if (pathname === '/dsh-kline/data') {
|
|
161
|
-
sendJson(response, 200, { ok: true, session: token, payload: saved.payload }, request.method === 'HEAD');
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
sendJson(response, 200, { ok: true, session: token, symbol: saved.symbol, name: saved.name, published_at: saved.published_at }, request.method === 'HEAD');
|
|
165
|
-
}
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
// Unknown paths have a stable routing result, independent of backend state.
|
|
169
|
-
if (!pathname.startsWith('/dsh-kline/api/tools/')) {
|
|
170
|
-
sendJson(response, 404, { ok: false, error: 'not_found' }, request.method === 'HEAD');
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
const session = await readLiveSession();
|
|
174
|
-
if (pathname.startsWith('/dsh-kline/api/tools/') && request.method === 'POST') {
|
|
175
|
-
const action = pathname.slice('/dsh-kline/api/tools/'.length).replaceAll('/', '');
|
|
176
|
-
if (!CHART_ACTIONS.has(action)) {
|
|
177
|
-
sendJson(response, 404, { ok: false, error: 'unsupported_chart_action' });
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
if (action.startsWith('workbench_') && (request.headers['content-type']?.split(';')[0] !== 'application/json'
|
|
181
|
-
|| request.headers.origin && new URL(request.headers.origin).host !== request.headers.host
|
|
182
|
-
|| request.headers['sec-fetch-site'] && !['same-origin', 'none'].includes(String(request.headers['sec-fetch-site'])))) {
|
|
183
|
-
sendJson(response, 403, { ok: false, error: 'invalid_workbench_origin' });
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
const body = await readRequestBody(request);
|
|
187
|
-
await proxyJson(response, `${serviceOrigin(session)}/api/tools/${encodeURIComponent(action)}`, {
|
|
188
|
-
method: 'POST',
|
|
189
|
-
headers: { ...chartServiceHeaders(session), 'Content-Type': 'application/json' },
|
|
190
|
-
body: body.toString('utf8'),
|
|
191
|
-
});
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
if (pathname.startsWith('/dsh-kline/api/tools/')) {
|
|
195
|
-
response.writeHead(405, { Allow: 'POST' });
|
|
196
|
-
response.end();
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
sendJson(response, 404, { ok: false, error: 'not_found' });
|
|
200
|
-
}
|
|
201
|
-
catch (error) {
|
|
202
|
-
if (error instanceof ChartServiceUnavailable) {
|
|
203
|
-
sendJson(response, 200, unavailableService(error.reason), request.method === 'HEAD');
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
const code = error instanceof Error && 'code' in error ? String(error.code) : '';
|
|
207
|
-
sendJson(response, code === 'ENOENT' ? 200 : 500, code === 'ENOENT'
|
|
208
|
-
? (pathname === '/dsh-kline/data' || pathname === '/dsh-kline/session'
|
|
209
|
-
? { ok: false, error: 'chart_session_unavailable', message: '这张图表的快照已不可用,请在当前对话重新分析该标的。' }
|
|
210
|
-
: unavailableService())
|
|
211
|
-
: { ok: false, error: 'chart_session_manifest_failed' }, request.method === 'HEAD');
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
export function runtimeDirectory(env = process.env) {
|
|
215
|
-
const explicit = String(env.DSH_KLINE_RUNTIME_DIR || '').trim();
|
|
216
|
-
if (explicit)
|
|
217
|
-
return resolve(explicit);
|
|
218
|
-
return join(stateDirectory(env), 'runtime');
|
|
219
|
-
}
|
|
220
|
-
function stateDirectory(env = process.env) {
|
|
221
|
-
const explicit = String(env.DSH_KLINE_CACHE_DIR || '').trim();
|
|
222
|
-
if (explicit)
|
|
223
|
-
return resolve(explicit);
|
|
224
|
-
if (process.platform === 'win32') {
|
|
225
|
-
const local = String(env.LOCALAPPDATA || env.APPDATA || '').trim();
|
|
226
|
-
return join(local || join(homedir(), 'AppData', 'Local'), 'dsh_kline');
|
|
227
|
-
}
|
|
228
|
-
const cache = String(env.XDG_CACHE_HOME || '').trim();
|
|
229
|
-
return join(cache || join(homedir(), '.cache'), 'dsh_kline');
|
|
230
|
-
}
|
|
231
|
-
function chartServiceHeaders(session) {
|
|
232
|
-
return { 'X-DSH-Kline-Token': session.service_token };
|
|
233
|
-
}
|
|
234
|
-
async function readLiveSession() {
|
|
235
|
-
return readServiceLocator(RUNTIME_FILE, process.pid);
|
|
236
|
-
}
|
|
237
|
-
function serviceOrigin(session) {
|
|
238
|
-
return new URL(session.service_url).origin;
|
|
239
|
-
}
|
|
240
|
-
async function proxyJson(response, url, init) {
|
|
241
|
-
let upstream;
|
|
242
|
-
try {
|
|
243
|
-
upstream = await fetch(url, { ...init, signal: AbortSignal.timeout(120000) });
|
|
244
|
-
}
|
|
245
|
-
catch (error) {
|
|
246
|
-
throw new ChartServiceUnavailable(error instanceof Error && error.name === 'TimeoutError' ? 'backend_timeout' : 'backend_unreachable');
|
|
247
|
-
}
|
|
248
|
-
const body = Buffer.from(await upstream.arrayBuffer());
|
|
249
|
-
if (body.length > MAX_PROXY_BYTES) {
|
|
250
|
-
sendJson(response, 502, { ok: false, error: 'chart_response_too_large' });
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
sendBytes(response, upstream.status, body, 'application/json; charset=utf-8');
|
|
254
|
-
}
|
|
255
|
-
async function readRequestBody(request) {
|
|
256
|
-
const chunks = [];
|
|
257
|
-
let size = 0;
|
|
258
|
-
for await (const chunk of request) {
|
|
259
|
-
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
260
|
-
size += buffer.length;
|
|
261
|
-
if (size > MAX_PROXY_BYTES)
|
|
262
|
-
throw new Error('request_too_large');
|
|
263
|
-
chunks.push(buffer);
|
|
264
|
-
}
|
|
265
|
-
return Buffer.concat(chunks);
|
|
266
|
-
}
|
|
267
|
-
function sendJson(response, status, value, head = false) {
|
|
268
|
-
const body = Buffer.from(JSON.stringify(value));
|
|
269
|
-
sendBytes(response, status, body, 'application/json; charset=utf-8', head);
|
|
270
|
-
}
|
|
271
|
-
function sendBytes(response, status, body, contentType, head = false) {
|
|
272
|
-
response.writeHead(status, {
|
|
273
|
-
'Content-Type': contentType,
|
|
274
|
-
'Content-Length': String(body.length),
|
|
275
|
-
'Cache-Control': 'no-store',
|
|
276
|
-
'X-Content-Type-Options': 'nosniff',
|
|
277
|
-
});
|
|
278
|
-
response.end(head ? undefined : body);
|
|
279
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
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 }; }
|
|
@@ -1,47 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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 }; }
|
|
@@ -1,4 +0,0 @@
|
|
|
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;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export interface ApplicationView {
|
|
2
|
-
ref: string;
|
|
3
|
-
conversation: string;
|
|
4
|
-
view: string;
|
|
5
|
-
revision: number;
|
|
6
|
-
active: boolean;
|
|
7
|
-
ambiguous: boolean;
|
|
8
|
-
applyCapable?: boolean;
|
|
9
|
-
state: any;
|
|
10
|
-
}
|
|
11
|
-
export declare class ChartApplications {
|
|
12
|
-
private runtime;
|
|
13
|
-
private now;
|
|
14
|
-
constructor(runtime: string, now?: () => number);
|
|
15
|
-
private directory;
|
|
16
|
-
private path;
|
|
17
|
-
private read;
|
|
18
|
-
private write;
|
|
19
|
-
private recoveryPath;
|
|
20
|
-
recover(conversation: string): Promise<any>;
|
|
21
|
-
private validate;
|
|
22
|
-
private candidate;
|
|
23
|
-
private publicReceipt;
|
|
24
|
-
acknowledge(view: ApplicationView, receipt: any): Promise<any>;
|
|
25
|
-
dispatch(view: ApplicationView): Promise<any>;
|
|
26
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export { sanitizeChartContext } from './chart-observation.ts';
|
|
2
|
-
export declare const CONTEXT_TTL_MS = 90000;
|
|
3
|
-
export declare class ChartContextBroker {
|
|
4
|
-
private records;
|
|
5
|
-
private queue;
|
|
6
|
-
private directory;
|
|
7
|
-
private now;
|
|
8
|
-
private applications?;
|
|
9
|
-
private sources?;
|
|
10
|
-
constructor(directory: string, now?: () => number, runtime?: string);
|
|
11
|
-
publish(raw: any): Promise<any>;
|
|
12
|
-
private accept;
|
|
13
|
-
prompt(context: any): string;
|
|
14
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function text(value: unknown, max?: number): string;
|
|
2
|
-
/** Describes browser input -> display only, never vendor-native history or edit authority. */
|
|
3
|
-
export declare function sanitizeDataProvenance(raw: any): any;
|
|
4
|
-
export declare function sanitizeChartContext(raw: any): any;
|
|
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;
|
|
8
|
-
export declare function drawingInventory(payload: any): any[];
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare class ChartServiceUnavailable extends Error {
|
|
2
|
-
readonly reason: string;
|
|
3
|
-
constructor(reason: string);
|
|
4
|
-
}
|
|
5
|
-
export interface ServiceLocator extends Record<string, unknown> {
|
|
6
|
-
ok: true;
|
|
7
|
-
process_id: number;
|
|
8
|
-
host_process_id: number;
|
|
9
|
-
session: string;
|
|
10
|
-
service_url: string;
|
|
11
|
-
service_token: string;
|
|
12
|
-
published_at: number;
|
|
13
|
-
instance_id?: string;
|
|
14
|
-
}
|
|
15
|
-
export declare function readServiceLocator(path: string, hostPid: number): Promise<ServiceLocator>;
|
|
16
|
-
export declare function probeChartService(locator: ServiceLocator, timeoutMs?: number): Promise<void>;
|
|
17
|
-
export declare function unavailableService(reason?: string): {
|
|
18
|
-
ok: boolean;
|
|
19
|
-
error: string;
|
|
20
|
-
reason: string;
|
|
21
|
-
message: string;
|
|
22
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,12 +0,0 @@
|
|
|
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;
|