@forgecharts/sdk 1.1.32 → 1.1.34
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/dist/api/IndicatorDAG.d.ts +2 -0
- package/dist/api/IndicatorDAG.d.ts.map +1 -1
- package/dist/api/TChart.d.ts +13 -0
- package/dist/api/TChart.d.ts.map +1 -1
- package/dist/api/drawingUtils.d.ts +6 -0
- package/dist/api/drawingUtils.d.ts.map +1 -1
- package/dist/core/Chart.d.ts +30 -1
- package/dist/core/Chart.d.ts.map +1 -1
- package/dist/core/Crosshair.d.ts.map +1 -1
- package/dist/core/InteractionManager.d.ts +16 -1
- package/dist/core/InteractionManager.d.ts.map +1 -1
- package/dist/core/TimeScale.d.ts.map +1 -1
- package/dist/datafeed/DatafeedConnector.d.ts.map +1 -1
- package/dist/{tscript/TScriptIndicator.d.ts → forgescript/ForgeScriptIndicator.d.ts} +19 -5
- package/dist/forgescript/ForgeScriptIndicator.d.ts.map +1 -0
- package/dist/forgescript/ForgeScriptTypes.d.ts +89 -0
- package/dist/forgescript/ForgeScriptTypes.d.ts.map +1 -0
- package/dist/forgescript/__tests__/ai-response-parser.test.d.ts +2 -0
- package/dist/forgescript/__tests__/ai-response-parser.test.d.ts.map +1 -0
- package/dist/forgescript/__tests__/language-detector.test.d.ts +2 -0
- package/dist/forgescript/__tests__/language-detector.test.d.ts.map +1 -0
- package/dist/forgescript/__tests__/lexer.test.d.ts +2 -0
- package/dist/forgescript/__tests__/lexer.test.d.ts.map +1 -0
- package/dist/forgescript/__tests__/orchestrator.test.d.ts +2 -0
- package/dist/forgescript/__tests__/orchestrator.test.d.ts.map +1 -0
- package/dist/forgescript/__tests__/parser.test.d.ts +2 -0
- package/dist/forgescript/__tests__/parser.test.d.ts.map +1 -0
- package/dist/forgescript/__tests__/pine-transpiler.test.d.ts +2 -0
- package/dist/forgescript/__tests__/pine-transpiler.test.d.ts.map +1 -0
- package/dist/forgescript/__tests__/runtime.test.d.ts +2 -0
- package/dist/forgescript/__tests__/runtime.test.d.ts.map +1 -0
- package/dist/forgescript/__tests__/sandbox.test.d.ts +2 -0
- package/dist/forgescript/__tests__/sandbox.test.d.ts.map +1 -0
- package/dist/forgescript/__tests__/save-gate.test.d.ts +2 -0
- package/dist/forgescript/__tests__/save-gate.test.d.ts.map +1 -0
- package/dist/forgescript/__tests__/series.test.d.ts +2 -0
- package/dist/forgescript/__tests__/series.test.d.ts.map +1 -0
- package/dist/forgescript/__tests__/telemetry.test.d.ts +2 -0
- package/dist/forgescript/__tests__/telemetry.test.d.ts.map +1 -0
- package/dist/forgescript/__tests__/validation.test.d.ts +2 -0
- package/dist/forgescript/__tests__/validation.test.d.ts.map +1 -0
- package/dist/forgescript/ast.d.ts +153 -0
- package/dist/forgescript/ast.d.ts.map +1 -0
- package/dist/forgescript/builtins/color.d.ts +29 -0
- package/dist/forgescript/builtins/color.d.ts.map +1 -0
- package/dist/forgescript/builtins/math.d.ts +22 -0
- package/dist/forgescript/builtins/math.d.ts.map +1 -0
- package/dist/forgescript/builtins/request.d.ts +22 -0
- package/dist/forgescript/builtins/request.d.ts.map +1 -0
- package/dist/forgescript/builtins/syminfo.d.ts +27 -0
- package/dist/forgescript/builtins/syminfo.d.ts.map +1 -0
- package/dist/forgescript/builtins/ta.d.ts +39 -0
- package/dist/forgescript/builtins/ta.d.ts.map +1 -0
- package/dist/forgescript/conversion/ai-conversion-agent.d.ts +41 -0
- package/dist/forgescript/conversion/ai-conversion-agent.d.ts.map +1 -0
- package/dist/forgescript/conversion/conversion-orchestrator.d.ts +44 -0
- package/dist/forgescript/conversion/conversion-orchestrator.d.ts.map +1 -0
- package/dist/forgescript/conversion/index.d.ts +19 -0
- package/dist/forgescript/conversion/index.d.ts.map +1 -0
- package/dist/forgescript/conversion/language-detector.d.ts +27 -0
- package/dist/forgescript/conversion/language-detector.d.ts.map +1 -0
- package/dist/forgescript/conversion/prompts/index.d.ts +17 -0
- package/dist/forgescript/conversion/prompts/index.d.ts.map +1 -0
- package/dist/forgescript/conversion/sandbox.d.ts +23 -0
- package/dist/forgescript/conversion/sandbox.d.ts.map +1 -0
- package/dist/forgescript/conversion/save-gate.d.ts +29 -0
- package/dist/forgescript/conversion/save-gate.d.ts.map +1 -0
- package/dist/forgescript/conversion/telemetry.d.ts +22 -0
- package/dist/forgescript/conversion/telemetry.d.ts.map +1 -0
- package/dist/forgescript/conversion/types.d.ts +120 -0
- package/dist/forgescript/conversion/types.d.ts.map +1 -0
- package/dist/forgescript/conversion/validation.d.ts +18 -0
- package/dist/forgescript/conversion/validation.d.ts.map +1 -0
- package/dist/{tscript → forgescript}/lexer.d.ts +7 -1
- package/dist/forgescript/lexer.d.ts.map +1 -0
- package/dist/{tscript → forgescript}/parser.d.ts +14 -0
- package/dist/forgescript/parser.d.ts.map +1 -0
- package/dist/{pine → forgescript/pine}/PineCompiler.d.ts +7 -4
- package/dist/forgescript/pine/PineCompiler.d.ts.map +1 -0
- package/dist/forgescript/pine/diagnostics.d.ts.map +1 -0
- package/dist/forgescript/pine/index.d.ts.map +1 -0
- package/dist/{pine → forgescript/pine}/pine-ast.d.ts +50 -2
- package/dist/forgescript/pine/pine-ast.d.ts.map +1 -0
- package/dist/forgescript/pine/pine-lexer.d.ts.map +1 -0
- package/dist/forgescript/pine/pine-parser.d.ts +108 -0
- package/dist/forgescript/pine/pine-parser.d.ts.map +1 -0
- package/dist/{pine → forgescript/pine}/pine-transpiler.d.ts +10 -3
- package/dist/forgescript/pine/pine-transpiler.d.ts.map +1 -0
- package/dist/forgescript/runtime.d.ts +307 -0
- package/dist/forgescript/runtime.d.ts.map +1 -0
- package/dist/forgescript/series.d.ts.map +1 -0
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3365 -265
- package/dist/index.js.map +1 -1
- package/dist/internal.js +3409 -309
- package/dist/internal.js.map +1 -1
- package/dist/licensing/ChartRuntimeResolver.d.ts +4 -0
- package/dist/licensing/ChartRuntimeResolver.d.ts.map +1 -1
- package/dist/licensing/licenseTypes.d.ts +18 -0
- package/dist/licensing/licenseTypes.d.ts.map +1 -1
- package/dist/logo_dark-B2KCSRPJ.png +0 -0
- package/dist/logo_light-NAWNBY4G.png +0 -0
- package/dist/react/canvas/ChartCanvas.d.ts +18 -2
- package/dist/react/canvas/ChartCanvas.d.ts.map +1 -1
- package/dist/react/canvas/PointerOverlay.d.ts +3 -1
- package/dist/react/canvas/PointerOverlay.d.ts.map +1 -1
- package/dist/react/canvas/TableOverlay.d.ts +12 -0
- package/dist/react/canvas/TableOverlay.d.ts.map +1 -0
- package/dist/react/canvas/toolbars/LeftToolbar.d.ts +7 -1
- package/dist/react/canvas/toolbars/LeftToolbar.d.ts.map +1 -1
- package/dist/react/hooks/useBrokerEvents.d.ts +32 -0
- package/dist/react/hooks/useBrokerEvents.d.ts.map +1 -0
- package/dist/react/index.js +2506 -387
- package/dist/react/index.js.map +1 -1
- package/dist/react/internal.d.ts +1 -1
- package/dist/react/internal.d.ts.map +1 -1
- package/dist/react/internal.js +5103 -988
- package/dist/react/internal.js.map +1 -1
- package/dist/react/shell/ManagedAppShell.d.ts +20 -0
- package/dist/react/shell/ManagedAppShell.d.ts.map +1 -1
- package/dist/react/shell/OrderEntryPanel.d.ts +73 -1
- package/dist/react/shell/OrderEntryPanel.d.ts.map +1 -1
- package/dist/react/shell/ScriptDrawer.d.ts +5 -1
- package/dist/react/shell/ScriptDrawer.d.ts.map +1 -1
- package/dist/react/shell/TradeDrawer.d.ts +8 -1
- package/dist/react/shell/TradeDrawer.d.ts.map +1 -1
- package/dist/react/shell/WatchlistDrawer.d.ts.map +1 -1
- package/dist/react/shell/useWatchlistQuotes.d.ts +1 -0
- package/dist/react/shell/useWatchlistQuotes.d.ts.map +1 -1
- package/dist/react/workspace/ChartWorkspace.d.ts +5 -1
- package/dist/react/workspace/ChartWorkspace.d.ts.map +1 -1
- package/dist/react/workspace/SymbolSearchDialog.d.ts.map +1 -1
- package/dist/react/workspace/TabBar.d.ts.map +1 -1
- package/dist/react/workspace/toolbars/BottomToolbar.d.ts.map +1 -1
- package/dist/react/workspace/toolbars/TopToolbar.d.ts +2 -1
- package/dist/react/workspace/toolbars/TopToolbar.d.ts.map +1 -1
- package/dist/renderers/CandlestickRenderer.d.ts.map +1 -1
- package/dist/services/serverClock.d.ts +61 -0
- package/dist/services/serverClock.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/pine/PineCompiler.d.ts.map +0 -1
- package/dist/pine/diagnostics.d.ts.map +0 -1
- package/dist/pine/index.d.ts.map +0 -1
- package/dist/pine/pine-ast.d.ts.map +0 -1
- package/dist/pine/pine-lexer.d.ts.map +0 -1
- package/dist/pine/pine-parser.d.ts +0 -51
- package/dist/pine/pine-parser.d.ts.map +0 -1
- package/dist/pine/pine-transpiler.d.ts.map +0 -1
- package/dist/tscript/TScriptIndicator.d.ts.map +0 -1
- package/dist/tscript/ast.d.ts +0 -89
- package/dist/tscript/ast.d.ts.map +0 -1
- package/dist/tscript/lexer.d.ts.map +0 -1
- package/dist/tscript/parser.d.ts.map +0 -1
- package/dist/tscript/runtime.d.ts +0 -123
- package/dist/tscript/runtime.d.ts.map +0 -1
- package/dist/tscript/series.d.ts.map +0 -1
- /package/dist/{pine → forgescript/pine}/diagnostics.d.ts +0 -0
- /package/dist/{pine → forgescript/pine}/index.d.ts +0 -0
- /package/dist/{pine → forgescript/pine}/pine-lexer.d.ts +0 -0
- /package/dist/{tscript → forgescript}/series.d.ts +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TScript Abstract Syntax Tree node types.
|
|
3
|
+
*
|
|
4
|
+
* Grammar (simplified):
|
|
5
|
+
* program → stmt*
|
|
6
|
+
* stmt → indicator_decl | var_decl | assign | reassign | for | while | if | expr_stmt
|
|
7
|
+
* var_decl → ('var' | 'varip') IDENT '=' expr
|
|
8
|
+
* assign → IDENT '=' expr
|
|
9
|
+
* reassign → IDENT ':=' expr
|
|
10
|
+
* for → 'for' IDENT '=' expr 'to' expr ('by' expr)? NEWLINE block
|
|
11
|
+
* indicator → 'indicator' '(' STRING (',' namedArgs)* ')'
|
|
12
|
+
* expr → ternary
|
|
13
|
+
* ternary → or ('?' expr ':' expr)?
|
|
14
|
+
* or → and ('or' and)*
|
|
15
|
+
* and → not ('and' not)*
|
|
16
|
+
* not → 'not' comparison | comparison
|
|
17
|
+
* comparison → addition (('<'|'>'|'<='|'>='|'=='|'!=') addition)*
|
|
18
|
+
* addition → multiplication (('+' | '-') multiplication)*
|
|
19
|
+
* multiplication→ unary (('*' | '/' | '%') unary)*
|
|
20
|
+
* unary → '-' unary | primary
|
|
21
|
+
* primary → NUMBER | STRING | BOOL | COLOR | IDENT ('[' expr ']')? | ns_call | call | '(' expr ')'
|
|
22
|
+
* ns_call → IDENT '.' IDENT '(' args ')'
|
|
23
|
+
* call → IDENT '(' args (',' IDENT '=' expr)* ')'
|
|
24
|
+
*/
|
|
25
|
+
export type NumberLit = {
|
|
26
|
+
kind: 'NumberLit';
|
|
27
|
+
value: number;
|
|
28
|
+
};
|
|
29
|
+
export type StringLit = {
|
|
30
|
+
kind: 'StringLit';
|
|
31
|
+
value: string;
|
|
32
|
+
};
|
|
33
|
+
export type BoolLit = {
|
|
34
|
+
kind: 'BoolLit';
|
|
35
|
+
value: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type ColorLit = {
|
|
38
|
+
kind: 'ColorLit';
|
|
39
|
+
value: string;
|
|
40
|
+
};
|
|
41
|
+
export type Identifier = {
|
|
42
|
+
kind: 'Identifier';
|
|
43
|
+
name: string;
|
|
44
|
+
};
|
|
45
|
+
export type IndexExpr = {
|
|
46
|
+
kind: 'IndexExpr';
|
|
47
|
+
series: Expr;
|
|
48
|
+
index: Expr;
|
|
49
|
+
};
|
|
50
|
+
export type CallExpr = {
|
|
51
|
+
kind: 'CallExpr';
|
|
52
|
+
callee: string;
|
|
53
|
+
args: Expr[];
|
|
54
|
+
namedArgs: Map<string, Expr>;
|
|
55
|
+
};
|
|
56
|
+
/** Namespace-qualified call: ta.sma(close, 14), math.abs(x), color.new(...) */
|
|
57
|
+
export type NsCallExpr = {
|
|
58
|
+
kind: 'NsCallExpr';
|
|
59
|
+
namespace: string;
|
|
60
|
+
fn: string;
|
|
61
|
+
args: Expr[];
|
|
62
|
+
namedArgs: Map<string, Expr>;
|
|
63
|
+
};
|
|
64
|
+
/** Namespace member access: color.red, syminfo.tickerid */
|
|
65
|
+
export type MemberExpr = {
|
|
66
|
+
kind: 'MemberExpr';
|
|
67
|
+
object: string;
|
|
68
|
+
prop: string;
|
|
69
|
+
};
|
|
70
|
+
export type BinaryExpr = {
|
|
71
|
+
kind: 'BinaryExpr';
|
|
72
|
+
op: '+' | '-' | '*' | '/' | '%' | '<' | '>' | '<=' | '>=' | '==' | '!=';
|
|
73
|
+
left: Expr;
|
|
74
|
+
right: Expr;
|
|
75
|
+
};
|
|
76
|
+
export type UnaryExpr = {
|
|
77
|
+
kind: 'UnaryExpr';
|
|
78
|
+
op: '-' | 'not';
|
|
79
|
+
operand: Expr;
|
|
80
|
+
};
|
|
81
|
+
export type TernaryExpr = {
|
|
82
|
+
kind: 'TernaryExpr';
|
|
83
|
+
condition: Expr;
|
|
84
|
+
consequent: Expr;
|
|
85
|
+
alternate: Expr;
|
|
86
|
+
};
|
|
87
|
+
export type LogicalExpr = {
|
|
88
|
+
kind: 'LogicalExpr';
|
|
89
|
+
op: 'and' | 'or';
|
|
90
|
+
left: Expr;
|
|
91
|
+
right: Expr;
|
|
92
|
+
};
|
|
93
|
+
export type Expr = NumberLit | StringLit | BoolLit | ColorLit | Identifier | IndexExpr | CallExpr | NsCallExpr | MemberExpr | BinaryExpr | UnaryExpr | TernaryExpr | LogicalExpr;
|
|
94
|
+
export type IndicatorDecl = {
|
|
95
|
+
kind: 'IndicatorDecl';
|
|
96
|
+
title: string;
|
|
97
|
+
namedArgs: Map<string, Expr>;
|
|
98
|
+
};
|
|
99
|
+
/** var x = expr (init once on bar 0) or varip x = expr (init once, update intra-bar) */
|
|
100
|
+
export type VarDeclStmt = {
|
|
101
|
+
kind: 'VarDeclStmt';
|
|
102
|
+
modifier: 'var' | 'varip';
|
|
103
|
+
name: string;
|
|
104
|
+
value: Expr;
|
|
105
|
+
};
|
|
106
|
+
export type AssignStmt = {
|
|
107
|
+
kind: 'AssignStmt';
|
|
108
|
+
name: string;
|
|
109
|
+
value: Expr;
|
|
110
|
+
};
|
|
111
|
+
/** x := expr (reassignment — variable must already exist) */
|
|
112
|
+
export type ReassignStmt = {
|
|
113
|
+
kind: 'ReassignStmt';
|
|
114
|
+
name: string;
|
|
115
|
+
value: Expr;
|
|
116
|
+
};
|
|
117
|
+
export type ExprStmt = {
|
|
118
|
+
kind: 'ExprStmt';
|
|
119
|
+
expr: Expr;
|
|
120
|
+
};
|
|
121
|
+
export type IfStmt = {
|
|
122
|
+
kind: 'IfStmt';
|
|
123
|
+
condition: Expr;
|
|
124
|
+
then: Stmt[];
|
|
125
|
+
else_: Stmt[];
|
|
126
|
+
};
|
|
127
|
+
export type WhileStmt = {
|
|
128
|
+
kind: 'WhileStmt';
|
|
129
|
+
condition: Expr;
|
|
130
|
+
body: Stmt[];
|
|
131
|
+
};
|
|
132
|
+
/** for i = start to end [by step] */
|
|
133
|
+
export type ForStmt = {
|
|
134
|
+
kind: 'ForStmt';
|
|
135
|
+
name: string;
|
|
136
|
+
start: Expr;
|
|
137
|
+
end: Expr;
|
|
138
|
+
step: Expr | null;
|
|
139
|
+
body: Stmt[];
|
|
140
|
+
};
|
|
141
|
+
/** User-defined function: name(params) => body_expr OR name(params) => INDENT block DEDENT */
|
|
142
|
+
export type FnDeclStmt = {
|
|
143
|
+
kind: 'FnDeclStmt';
|
|
144
|
+
name: string;
|
|
145
|
+
params: string[];
|
|
146
|
+
body: Stmt[];
|
|
147
|
+
};
|
|
148
|
+
export type Stmt = IndicatorDecl | VarDeclStmt | AssignStmt | ReassignStmt | ExprStmt | IfStmt | WhileStmt | ForStmt | FnDeclStmt;
|
|
149
|
+
export type Program = {
|
|
150
|
+
kind: 'Program';
|
|
151
|
+
stmts: Stmt[];
|
|
152
|
+
};
|
|
153
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/forgescript/ast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,MAAM,MAAM,SAAS,GAAI;IAAE,IAAI,EAAE,WAAW,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/D,MAAM,MAAM,SAAS,GAAI;IAAE,IAAI,EAAE,WAAW,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/D,MAAM,MAAM,OAAO,GAAM;IAAE,IAAI,EAAE,SAAS,CAAC;IAAI,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAChE,MAAM,MAAM,QAAQ,GAAK;IAAE,IAAI,EAAE,UAAU,CAAC;IAAG,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/D,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAI9D,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAI,WAAW,CAAC;IACpB,MAAM,EAAE,IAAI,CAAC;IACb,KAAK,EAAG,IAAI,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAO,UAAU,CAAC;IACtB,MAAM,EAAK,MAAM,CAAC;IAClB,IAAI,EAAO,IAAI,EAAE,CAAC;IAClB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAO,YAAY,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IA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AAG,IAAI,CAAC;IACnB,IAAI,EAAG,IAAI,EAAE,CAAC;CACf,CAAC;AAEF,gGAAgG;AAChG,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAI,YAAY,CAAC;IACrB,IAAI,EAAI,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAI,IAAI,EAAE,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;AAElI,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAG,SAAS,CAAC;IACjB,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ForgeScript color.* namespace — color constants and constructor.
|
|
3
|
+
*
|
|
4
|
+
* Color values are CSS hex strings (#rrggbb or #rrggbbaa).
|
|
5
|
+
*/
|
|
6
|
+
export type ColorNamespace = {
|
|
7
|
+
red: string;
|
|
8
|
+
green: string;
|
|
9
|
+
blue: string;
|
|
10
|
+
white: string;
|
|
11
|
+
black: string;
|
|
12
|
+
yellow: string;
|
|
13
|
+
orange: string;
|
|
14
|
+
purple: string;
|
|
15
|
+
aqua: string;
|
|
16
|
+
gray: string;
|
|
17
|
+
silver: string;
|
|
18
|
+
lime: string;
|
|
19
|
+
maroon: string;
|
|
20
|
+
navy: string;
|
|
21
|
+
olive: string;
|
|
22
|
+
teal: string;
|
|
23
|
+
fuchsia: string;
|
|
24
|
+
/** Create a CSS hex color string from RGBA components (0–255). */
|
|
25
|
+
new: (r: number, g: number, b: number, a?: number) => string;
|
|
26
|
+
};
|
|
27
|
+
/** Built-in color constants matching Pine Script v5. */
|
|
28
|
+
export declare const COLORS: Readonly<Record<string, string>>;
|
|
29
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../src/forgescript/builtins/color.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAM,MAAM,CAAC;IAChB,KAAK,EAAI,MAAM,CAAC;IAChB,IAAI,EAAK,MAAM,CAAC;IAChB,KAAK,EAAI,MAAM,CAAC;IAChB,KAAK,EAAI,MAAM,CAAC;IAChB,MAAM,EAAG,MAAM,CAAC;IAChB,MAAM,EAAG,MAAM,CAAC;IAChB,MAAM,EAAG,MAAM,CAAC;IAChB,IAAI,EAAK,MAAM,CAAC;IAChB,IAAI,EAAK,MAAM,CAAC;IAChB,MAAM,EAAG,MAAM,CAAC;IAChB,IAAI,EAAK,MAAM,CAAC;IAChB,MAAM,EAAG,MAAM,CAAC;IAChB,IAAI,EAAK,MAAM,CAAC;IAChB,KAAK,EAAI,MAAM,CAAC;IAChB,IAAI,EAAK,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,GAAG,EAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAClE,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB1C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ForgeScript math.* namespace — mathematical function type contracts.
|
|
3
|
+
*/
|
|
4
|
+
export type MathNamespace = {
|
|
5
|
+
abs: (x: number) => number;
|
|
6
|
+
max: (...args: number[]) => number;
|
|
7
|
+
min: (...args: number[]) => number;
|
|
8
|
+
round: (x: number) => number;
|
|
9
|
+
floor: (x: number) => number;
|
|
10
|
+
ceil: (x: number) => number;
|
|
11
|
+
sqrt: (x: number) => number;
|
|
12
|
+
log: (x: number) => number;
|
|
13
|
+
/** Natural exponent: e^x */
|
|
14
|
+
exp: (x: number) => number;
|
|
15
|
+
pow: (base: number, exp: number) => number;
|
|
16
|
+
sign: (x: number) => number;
|
|
17
|
+
/** Mathematical constant π ≈ 3.14159 */
|
|
18
|
+
pi: number;
|
|
19
|
+
/** Mathematical constant e ≈ 2.71828 */
|
|
20
|
+
e: number;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=math.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../src/forgescript/builtins/math.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAI,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7B,GAAG,EAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;IACrC,GAAG,EAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;IACrC,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7B,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7B,IAAI,EAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7B,IAAI,EAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7B,GAAG,EAAI,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7B,4BAA4B;IAC5B,GAAG,EAAI,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7B,GAAG,EAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7C,IAAI,EAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7B,wCAAwC;IACxC,EAAE,EAAK,MAAM,CAAC;IACd,wCAAwC;IACxC,CAAC,EAAM,MAAM,CAAC;CACf,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ForgeScript request.* namespace — external data request functions.
|
|
3
|
+
*
|
|
4
|
+
* PERMISSION-GATED: Only available to scripts that have been granted
|
|
5
|
+
* `request` capability by the platform. Untrusted / user scripts that
|
|
6
|
+
* call `request.security()` will have the call replaced with `0` by the
|
|
7
|
+
* Pine transpiler's UNSUPPORTED_FN guard, and the native parser will throw
|
|
8
|
+
* at runtime if invoked directly.
|
|
9
|
+
*/
|
|
10
|
+
export type RequestNamespace = {
|
|
11
|
+
/**
|
|
12
|
+
* Fetch a value from a different symbol or timeframe context.
|
|
13
|
+
*
|
|
14
|
+
* @param symbol Ticker id, e.g. `"CME:NQ1!"`
|
|
15
|
+
* @param timeframe Timeframe string, e.g. `"D"`, `"60"`, `"1"`
|
|
16
|
+
* @param expression The series value to retrieve from that context
|
|
17
|
+
* @returns The value of `expression` in the requested context,
|
|
18
|
+
* or `NaN` if unavailable.
|
|
19
|
+
*/
|
|
20
|
+
security: (symbol: string, timeframe: string, expression: number) => number;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/forgescript/builtins/request.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;CAC7E,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ForgeScript syminfo.* namespace — symbol metadata constants.
|
|
3
|
+
*
|
|
4
|
+
* Values are injected by the host before script execution via
|
|
5
|
+
* `ForgeScriptRuntime.setSyminfo()` (not yet implemented — returns defaults).
|
|
6
|
+
*/
|
|
7
|
+
export type SyminfoNamespace = {
|
|
8
|
+
/** Full ticker id, e.g. "CME:ES1!" */
|
|
9
|
+
tickerid: string;
|
|
10
|
+
/** Human-readable description, e.g. "E-mini S&P 500 Futures" */
|
|
11
|
+
description: string;
|
|
12
|
+
/** Exchange prefix, e.g. "CME" */
|
|
13
|
+
prefix: string;
|
|
14
|
+
/** Ticker without exchange, e.g. "ES1!" */
|
|
15
|
+
ticker: string;
|
|
16
|
+
/** Minimum tick size (price increment) */
|
|
17
|
+
mintick: number;
|
|
18
|
+
/** Dollar value of one point movement */
|
|
19
|
+
pointvalue: number;
|
|
20
|
+
/** Asset class: "futures" | "forex" | "crypto" | "stock" */
|
|
21
|
+
type: string;
|
|
22
|
+
/** Active session string, e.g. "0830-1515:23456" */
|
|
23
|
+
session: string;
|
|
24
|
+
/** IANA timezone, e.g. "America/Chicago" */
|
|
25
|
+
timezone: string;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=syminfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syminfo.d.ts","sourceRoot":"","sources":["../../../src/forgescript/builtins/syminfo.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,sCAAsC;IACtC,QAAQ,EAAK,MAAM,CAAC;IACpB,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,MAAM,EAAO,MAAM,CAAC;IACpB,2CAA2C;IAC3C,MAAM,EAAO,MAAM,CAAC;IACpB,0CAA0C;IAC1C,OAAO,EAAM,MAAM,CAAC;IACpB,yCAAyC;IACzC,UAAU,EAAG,MAAM,CAAC;IACpB,4DAA4D;IAC5D,IAAI,EAAS,MAAM,CAAC;IACpB,oDAAoD;IACpD,OAAO,EAAM,MAAM,CAAC;IACpB,4CAA4C;IAC5C,QAAQ,EAAK,MAAM,CAAC;CACrB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ForgeScript ta.* namespace — technical analysis function type contracts.
|
|
3
|
+
*
|
|
4
|
+
* These describe the public surface for the `ta.` namespace. In ForgeScript
|
|
5
|
+
* native syntax the dot-notation will eventually be parsed and dispatched here.
|
|
6
|
+
* The actual computation is handled by ForgeScriptRuntime's built-in flat
|
|
7
|
+
* function dispatch (sma, ema, rsi, ...) which these map 1-to-1 with.
|
|
8
|
+
*/
|
|
9
|
+
export type TANamespace = {
|
|
10
|
+
/** Simple Moving Average */
|
|
11
|
+
sma: (src: number, length: number) => number;
|
|
12
|
+
/** Exponential Moving Average */
|
|
13
|
+
ema: (src: number, length: number) => number;
|
|
14
|
+
/** Weighted Moving Average */
|
|
15
|
+
wma: (src: number, length: number) => number;
|
|
16
|
+
/** Wilder's Moving Average (RMA) */
|
|
17
|
+
rma: (src: number, length: number) => number;
|
|
18
|
+
/** Relative Strength Index */
|
|
19
|
+
rsi: (src: number, length: number) => number;
|
|
20
|
+
/** Rolling Standard Deviation */
|
|
21
|
+
stdev: (src: number, length: number) => number;
|
|
22
|
+
/** Rolling maximum over `length` bars */
|
|
23
|
+
highest: (src: number, length: number) => number;
|
|
24
|
+
/** Rolling minimum over `length` bars */
|
|
25
|
+
lowest: (src: number, length: number) => number;
|
|
26
|
+
/** `src - src[n]`, default n=1 */
|
|
27
|
+
change: (src: number, length?: number) => number;
|
|
28
|
+
/** Momentum = change(src, length) */
|
|
29
|
+
mom: (src: number, length: number) => number;
|
|
30
|
+
/** Average True Range */
|
|
31
|
+
atr: (length: number) => number;
|
|
32
|
+
/** True when `a` crosses above `b` */
|
|
33
|
+
crossover: (a: number, b: number) => boolean;
|
|
34
|
+
/** True when `a` crosses below `b` */
|
|
35
|
+
crossunder: (a: number, b: number) => boolean;
|
|
36
|
+
/** Bars since `condition` was last true */
|
|
37
|
+
barssince: (condition: boolean) => number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AAG,EAAS,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC,sCAAsC;IACtC,SAAS,EAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IAC9C,sCAAsC;IACtC,UAAU,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IAC9C,2CAA2C;IAC3C,SAAS,EAAG,CAAC,SAAS,EAAE,OAAO,KAAK,MAAM,CAAC;CAC5C,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Conversion Agent — interface between the conversion pipeline and an LLM.
|
|
3
|
+
*
|
|
4
|
+
* This module:
|
|
5
|
+
* 1. Accepts source code + detected language
|
|
6
|
+
* 2. Builds a prompt using the language-specific template
|
|
7
|
+
* 3. Calls the injected LLM provider
|
|
8
|
+
* 4. Parses the response — tries JSON first (structured output from
|
|
9
|
+
* the Responses API), then falls back to markdown section parsing
|
|
10
|
+
*
|
|
11
|
+
* The AI is an ASSISTIVE layer — its output ALWAYS passes through validation
|
|
12
|
+
* before the user can save. No AI output bypasses the validation layer.
|
|
13
|
+
*/
|
|
14
|
+
import type { SourceLanguage, AIConversionResponse } from './types';
|
|
15
|
+
/** Message format for the LLM chat completion. */
|
|
16
|
+
export interface ChatMessage {
|
|
17
|
+
role: 'system' | 'user' | 'assistant';
|
|
18
|
+
content: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Pluggable LLM provider. Implementations call an external AI service.
|
|
22
|
+
*
|
|
23
|
+
* Returning `null` indicates the provider is unavailable / rate-limited.
|
|
24
|
+
* The orchestrator will handle graceful fallback.
|
|
25
|
+
*/
|
|
26
|
+
export type LLMProvider = (messages: ChatMessage[]) => Promise<string | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Parse the structured 6-section response from the AI.
|
|
29
|
+
* Returns a typed AIConversionResponse or throws if the format is unrecognisable.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseAIResponse(raw: string): AIConversionResponse;
|
|
32
|
+
/**
|
|
33
|
+
* Run the AI conversion agent.
|
|
34
|
+
*
|
|
35
|
+
* @param source - The original source code to convert.
|
|
36
|
+
* @param language - The detected or user-selected source language.
|
|
37
|
+
* @param llm - The LLM provider to call.
|
|
38
|
+
* @returns A parsed AIConversionResponse, or null if the LLM is unavailable.
|
|
39
|
+
*/
|
|
40
|
+
export declare function runAIConversion(source: string, language: SourceLanguage, llm: LLMProvider): Promise<AIConversionResponse | null>;
|
|
41
|
+
//# sourceMappingURL=ai-conversion-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-conversion-agent.d.ts","sourceRoot":"","sources":["../../../src/forgescript/conversion/ai-conversion-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAiC,MAAM,SAAS,CAAC;AAKnG,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAM9E;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAmCjE;AAID;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,cAAc,EACxB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAsBtC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversion Orchestrator — central pipeline for AI-assisted script conversion.
|
|
3
|
+
*
|
|
4
|
+
* Pipeline flow:
|
|
5
|
+
* 1. Language Detection / User Override
|
|
6
|
+
* 2. Route: deterministic (Pine) or AI (Python, JS, unknown)
|
|
7
|
+
* 3. For Pine: deterministic first, optionally AI-refine
|
|
8
|
+
* 4. Validation Layer (syntax + runtime + hallucination)
|
|
9
|
+
* 5. Sandbox Execution
|
|
10
|
+
* 6. Build Save Gate check
|
|
11
|
+
* 7. Emit telemetry
|
|
12
|
+
*
|
|
13
|
+
* ForgeScript passthrough: if source is already ForgeScript, skip conversion.
|
|
14
|
+
*
|
|
15
|
+
* Core principle: NO AI output bypasses validation. NO silent approximations.
|
|
16
|
+
*/
|
|
17
|
+
import type { SourceLanguage, ConversionResult } from './types';
|
|
18
|
+
import type { AILanguageClassifier } from './language-detector';
|
|
19
|
+
import type { LLMProvider } from './ai-conversion-agent';
|
|
20
|
+
export interface ConversionOptions {
|
|
21
|
+
/** Force a specific source language (skip detection). */
|
|
22
|
+
sourceLanguage?: SourceLanguage;
|
|
23
|
+
/** LLM provider for AI conversion. If omitted, AI path is unavailable. */
|
|
24
|
+
llmProvider?: LLMProvider;
|
|
25
|
+
/** AI language classifier fallback. */
|
|
26
|
+
aiClassifier?: AILanguageClassifier;
|
|
27
|
+
/** Skip sandbox execution. Default: false. */
|
|
28
|
+
skipSandbox?: boolean;
|
|
29
|
+
/** Pre-acknowledge all warnings (testing only — never in production). */
|
|
30
|
+
acknowledgeWarnings?: boolean;
|
|
31
|
+
/** Pre-confirm save (testing only — never in production). */
|
|
32
|
+
confirmSave?: boolean;
|
|
33
|
+
/** Force AI conversion even when deterministic is available. */
|
|
34
|
+
forceAI?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Run the full conversion pipeline.
|
|
38
|
+
*
|
|
39
|
+
* @param source - Raw source code pasted by the user.
|
|
40
|
+
* @param options - Pipeline configuration.
|
|
41
|
+
* @returns Complete ConversionResult with code, validation, sandbox, and gate.
|
|
42
|
+
*/
|
|
43
|
+
export declare function convertScript(source: string, options?: ConversionOptions): Promise<ConversionResult>;
|
|
44
|
+
//# sourceMappingURL=conversion-orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversion-orchestrator.d.ts","sourceRoot":"","sources":["../../../src/forgescript/conversion/conversion-orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAMjB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAKhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMzD,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,0EAA0E;IAC1E,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,uCAAuC;IACvC,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,8CAA8C;IAC9C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,yEAAyE;IACzE,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,6DAA6D;IAC7D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gEAAgE;IAChE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAID;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,CAAC,CA8K3B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI-Assisted Script Conversion System — public API.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the conversion pipeline, language detection, validation,
|
|
5
|
+
* sandbox, save gate, AI agent, prompt templates, and telemetry.
|
|
6
|
+
*/
|
|
7
|
+
export type { SourceLanguage, Confidence, LanguageDetectionResult, ConversionPath, ConversionWarning, ConversionAssumption, ReviewItem, AIConversionResponse, ValidationIssue, ValidationResult, SandboxResult, SaveGateCheck, ConversionResult, ConversionTelemetryEvent, } from './types';
|
|
8
|
+
export { detectLanguage, detectLanguageWithFallback } from './language-detector';
|
|
9
|
+
export type { AILanguageClassifier } from './language-detector';
|
|
10
|
+
export { convertScript } from './conversion-orchestrator';
|
|
11
|
+
export type { ConversionOptions } from './conversion-orchestrator';
|
|
12
|
+
export { validateForgeScript } from './validation';
|
|
13
|
+
export { runSandbox } from './sandbox';
|
|
14
|
+
export { evaluateSaveGate } from './save-gate';
|
|
15
|
+
export { runAIConversion, parseAIResponse } from './ai-conversion-agent';
|
|
16
|
+
export type { LLMProvider, ChatMessage } from './ai-conversion-agent';
|
|
17
|
+
export { getSystemPrompt, buildConversionPrompt, FORGESCRIPT_REFERENCE } from './prompts';
|
|
18
|
+
export { onConversionEvent, emitConversionEvent, buildTelemetryEvent, clearTelemetryListeners, } from './telemetry';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forgescript/conversion/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EACV,cAAc,EACd,UAAU,EACV,uBAAuB,EACvB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjF,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGhE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACzE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGtE,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAG1F,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language Detection — heuristic-based source language identification.
|
|
3
|
+
*
|
|
4
|
+
* Uses keyword/pattern scoring to determine the most likely scripting
|
|
5
|
+
* language of a pasted code snippet. Designed to be fast, deterministic,
|
|
6
|
+
* and to run client-side without network calls.
|
|
7
|
+
*
|
|
8
|
+
* An optional AI-based classification callback can refine "unknown" results.
|
|
9
|
+
*/
|
|
10
|
+
import type { LanguageDetectionResult } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Detect the source language of a script using pattern-based heuristics.
|
|
13
|
+
*
|
|
14
|
+
* Returns the best-matching language and a confidence level.
|
|
15
|
+
* If no patterns match above a threshold the result is `unknown / LOW`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function detectLanguage(source: string): LanguageDetectionResult;
|
|
18
|
+
/**
|
|
19
|
+
* Optional AI-based classification callback type.
|
|
20
|
+
* Implementations should call an LLM to classify the language.
|
|
21
|
+
*/
|
|
22
|
+
export type AILanguageClassifier = (source: string) => Promise<LanguageDetectionResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Enhanced detection: heuristics first, falls back to AI if result is `unknown`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function detectLanguageWithFallback(source: string, aiClassifier?: AILanguageClassifier): Promise<LanguageDetectionResult>;
|
|
27
|
+
//# sourceMappingURL=language-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-detector.d.ts","sourceRoot":"","sources":["../../../src/forgescript/conversion/language-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAA8B,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAuEnF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,uBAAuB,CA0CtE;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAExF;;GAEG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,oBAAoB,GAClC,OAAO,CAAC,uBAAuB,CAAC,CAIlC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Prompt Templates — language-specific prompt contracts for conversion.
|
|
3
|
+
*
|
|
4
|
+
* Each template produces a structured prompt that instructs an LLM to convert
|
|
5
|
+
* source code from a specific language into valid ForgeScript.
|
|
6
|
+
* The response format is enforced by JSON schema in openai-provider.ts,
|
|
7
|
+
* NOT by prompt instructions — do not add markdown format rules here.
|
|
8
|
+
*
|
|
9
|
+
* These prompts are deterministic text; they have no runtime side effects.
|
|
10
|
+
*/
|
|
11
|
+
import type { SourceLanguage } from '../types';
|
|
12
|
+
export declare const FORGESCRIPT_REFERENCE: string;
|
|
13
|
+
/** Get the system prompt for a specific source language. */
|
|
14
|
+
export declare function getSystemPrompt(language: SourceLanguage): string;
|
|
15
|
+
/** Build the full user message for the AI conversion request. */
|
|
16
|
+
export declare function buildConversionPrompt(sourceLanguage: SourceLanguage, sourceCode: string): string;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/forgescript/conversion/prompts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C,eAAO,MAAM,qBAAqB,QAsG1B,CAAC;AA0GT,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAQhE;AAED,iEAAiE;AACjE,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,MAAM,GACjB,MAAM,CAUR"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox Execution — compile and safely run ForgeScript in isolation.
|
|
3
|
+
*
|
|
4
|
+
* The sandbox:
|
|
5
|
+
* 1. Compiles the ForgeScript source (syntax check)
|
|
6
|
+
* 2. Runs it against synthetic bar data (runtime check)
|
|
7
|
+
* 3. Reports any compile/runtime errors
|
|
8
|
+
* 4. Surfaces a preview of the output
|
|
9
|
+
*
|
|
10
|
+
* No external I/O, no eval, no dynamic code — the tree-walking interpreter
|
|
11
|
+
* is inherently sandboxed. This module adds execution-time safety.
|
|
12
|
+
*/
|
|
13
|
+
import type { SandboxResult } from './types';
|
|
14
|
+
import type { OHLCV } from '@forgecharts/types';
|
|
15
|
+
/**
|
|
16
|
+
* Run a ForgeScript source in a sandboxed environment.
|
|
17
|
+
*
|
|
18
|
+
* @param source - ForgeScript source code.
|
|
19
|
+
* @param bars - Optional bar data; defaults to 200 synthetic 1-min bars.
|
|
20
|
+
* @returns SandboxResult with success/failure, preview, and any errors.
|
|
21
|
+
*/
|
|
22
|
+
export declare function runSandbox(source: string, bars?: readonly OHLCV[]): SandboxResult;
|
|
23
|
+
//# sourceMappingURL=sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/forgescript/conversion/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAmChD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,SAAS,KAAK,EAAE,GACtB,aAAa,CAyDf"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Save Gate — pre-save checklist enforcement.
|
|
3
|
+
*
|
|
4
|
+
* A script CANNOT be saved unless ALL of:
|
|
5
|
+
* 1. The ForgeScript compiles successfully
|
|
6
|
+
* 2. Validation passes (no error-severity issues)
|
|
7
|
+
* 3. All warnings have been acknowledged by the user
|
|
8
|
+
* 4. The user explicitly confirms
|
|
9
|
+
*
|
|
10
|
+
* No auto-save. No bypassing.
|
|
11
|
+
*/
|
|
12
|
+
import type { SaveGateCheck, ValidationResult, SandboxResult, ConversionWarning } from './types';
|
|
13
|
+
/**
|
|
14
|
+
* Evaluate whether a converted script is eligible to be saved.
|
|
15
|
+
*
|
|
16
|
+
* @param validation - Result from the validation layer.
|
|
17
|
+
* @param sandbox - Result from sandbox execution (null = skipped).
|
|
18
|
+
* @param warnings - Conversion warnings to present.
|
|
19
|
+
* @param warningsAcknowledged - Whether the user has acknowledged all warnings.
|
|
20
|
+
* @param userConfirmed - Whether the user has explicitly pressed "Save".
|
|
21
|
+
*/
|
|
22
|
+
export declare function evaluateSaveGate(params: {
|
|
23
|
+
validation: ValidationResult;
|
|
24
|
+
sandbox: SandboxResult | null;
|
|
25
|
+
warnings: ConversionWarning[];
|
|
26
|
+
warningsAcknowledged: boolean;
|
|
27
|
+
userConfirmed: boolean;
|
|
28
|
+
}): SaveGateCheck;
|
|
29
|
+
//# sourceMappingURL=save-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-gate.d.ts","sourceRoot":"","sources":["../../../src/forgescript/conversion/save-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,aAAa,EAAE,OAAO,CAAC;CACxB,GAAG,aAAa,CAuChB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversion Telemetry — event tracking for observability.
|
|
3
|
+
*
|
|
4
|
+
* Tracks conversion pipeline usage, success rates, and failure patterns
|
|
5
|
+
* to drive improvements in prompts, converter coverage, and the
|
|
6
|
+
* ForgeScript runtime itself.
|
|
7
|
+
*
|
|
8
|
+
* Events are emitted to registered listeners. The consumer (app layer)
|
|
9
|
+
* is responsible for persisting events to a backend or analytics system.
|
|
10
|
+
*/
|
|
11
|
+
import type { ConversionTelemetryEvent } from './types';
|
|
12
|
+
/** Telemetry event listener callback. */
|
|
13
|
+
export type TelemetryListener = (event: ConversionTelemetryEvent) => void;
|
|
14
|
+
/** Register a listener that receives all conversion telemetry events. */
|
|
15
|
+
export declare function onConversionEvent(listener: TelemetryListener): () => void;
|
|
16
|
+
/** Emit a telemetry event to all registered listeners. */
|
|
17
|
+
export declare function emitConversionEvent(event: ConversionTelemetryEvent): void;
|
|
18
|
+
/** Build a telemetry event from pipeline parameters. */
|
|
19
|
+
export declare function buildTelemetryEvent(params: Omit<ConversionTelemetryEvent, 'timestamp'>): ConversionTelemetryEvent;
|
|
20
|
+
/** Remove all registered listeners (useful for tests). */
|
|
21
|
+
export declare function clearTelemetryListeners(): void;
|
|
22
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../src/forgescript/conversion/telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,yCAAyC;AACzC,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,CAAC;AAM1E,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,IAAI,CAOzE;AAED,0DAA0D;AAC1D,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,IAAI,CAQzE;AAED,wDAAwD;AACxD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,wBAAwB,EAAE,WAAW,CAAC,GAAG,wBAAwB,CAEjH;AAED,0DAA0D;AAC1D,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C"}
|