Skip to content

FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.

chore: update project files and ignore Windows nul file

tilakpatel229186bbb7baae
diff --git a/.gitignore b/.gitignore
index b0ff4680a..1762efb54 100644
--- a/.gitignore
+++ b/.gitignore
@@ -78,3 +78,4 @@ settings.json
watchlist_settings.json
.DS_Storenul
**/.claude/"fincept-terminal-desktop/src-tauri/resources/bun/"
+nul
diff --git a/fincept-terminal-desktop/src-tauri/Cargo.lock b/fincept-terminal-desktop/src-tauri/Cargo.lock
index bab3df755..190fbe568 100644
--- a/fincept-terminal-desktop/src-tauri/Cargo.lock
+++ b/fincept-terminal-desktop/src-tauri/Cargo.lock
@@ -62,6 +62,15 @@ version = "1.0.99"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100"
+[[package]]
+name = "arbitrary"
+version = "1.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1"
+dependencies = [
+ "derive_arbitrary",
+]
+
[[package]]
name = "ashpd"
version = "0.11.0"
@@ -619,7 +628,7 @@ dependencies = [
"bitflags 2.9.4",
"core-foundation 0.10.1",
"core-graphics-types",
- "foreign-types",
+ "foreign-types 0.5.0",
"libc",
]
@@ -794,6 +803,17 @@ dependencies = [
"serde",
]
+[[package]]
+name = "derive_arbitrary"
+version = "1.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.106",
+]
+
[[package]]
name = "derive_more"
version = "0.99.20"
@@ -978,7 +998,7 @@ dependencies = [
"rustc_version",
"toml 0.9.7",
"vswhom",
- "winreg",
+ "winreg 0.55.0",
]
[[package]]
@@ -1107,12 +1127,25 @@ dependencies = [
"rustc_version",
]
+[[package]]
+name = "filetime"
+version = "0.2.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc0505cd1b6fa6580283f6bdf70a73fcf4aba1184038c90902b92b3dd0df63ed"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "libredox",
+ "windows-sys 0.60.2",
+]
+
[[package]]
name = "fincept-terminal-desktop"
-version = "3.0.0"
+version = "3.0.11"
dependencies = [
"anyhow",
"chrono",
+ "reqwest 0.11.27",
"serde",
"serde_json",
"sha2",
@@ -1121,7 +1154,9 @@ dependencies = [
"tauri-plugin-cors-fetch",
"tauri-plugin-dialog",
"tauri-plugin-opener",
+ "tauri-plugin-process",
"tauri-plugin-sql",
+ "tauri-plugin-updater",
"tokio",
"uuid",
]
@@ -1165,6 +1200,15 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
+[[package]]
+name = "foreign-types"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
+dependencies = [
+ "foreign-types-shared 0.1.1",
+]
+
[[package]]
name = "foreign-types"
version = "0.5.0"
@@ -1172,7 +1216,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
dependencies = [
"foreign-types-macros",
- "foreign-types-shared",
+ "foreign-types-shared 0.3.1",
]
[[package]]
@@ -1186,6 +1230,12 @@ dependencies = [
"syn 2.0.106",
]
+[[package]]
+name = "foreign-types-shared"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
+
[[package]]
name = "foreign-types-shared"
version = "0.3.1"
@@ -1618,6 +1668,25 @@ dependencies = [
"syn 2.0.106",
]
+[[package]]
+name = "h2"
+version = "0.3.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d"
+dependencies = [
+ "bytes",
+ "fnv",
+ "futures-core",
+ "futures-sink",
+ "futures-util",
+ "http 0.2.12",
+ "indexmap 2.11.4",
+ "slab",
+ "tokio",
+ "tokio-util",
+ "tracing",
+]
+
[[package]]
name = "h2"
version = "0.4.12"
@@ -1629,7 +1698,7 @@ dependencies = [
"fnv",
"futures-core",
"futures-sink",
- "http",
+ "http 1.3.1",
"indexmap 2.11.4",
"slab",
"tokio",
@@ -1732,6 +1801,17 @@ dependencies = [
"match_token",
]
+[[package]]
+name = "http"
+version = "0.2.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1"
+dependencies = [
+ "bytes",
+ "fnv",
+ "itoa",
+]
+
[[package]]
name = "http"
version = "1.3.1"
@@ -1743,6 +1823,17 @@ dependencies = [
"itoa",
]
+[[package]]
+name = "http-body"
+version = "0.4.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
+dependencies = [
+ "bytes",
+ "http 0.2.12",
+ "pin-project-lite",
+]
+
[[package]]
name = "http-body"
version = "1.0.1"
@@ -1750,7 +1841,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
dependencies = [
"bytes",
- "http",
+ "http 1.3.1",
]
[[package]]
@@ -1761,8 +1852,8 @@ checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a"
dependencies = [
"bytes",
"futures-core",
- "http",
- "http-body",
+ "http 1.3.1",
+ "http-body 1.0.1",
"pin-project-lite",
]
@@ -1772,6 +1863,36 @@ version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
+[[package]]
+name = "httpdate"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
+
+[[package]]
+name = "hyper"
+version = "0.14.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7"
+dependencies = [
+ "bytes",
+ "futures-channel",
+ "futures-core",
+ "futures-util",
+ "h2 0.3.27",
+ "http 0.2.12",
+ "http-body 0.4.6",
+ "httparse",
+ "httpdate",
+ "itoa",
+ "pin-project-lite",
+ "socket2 0.5.10",
+ "tokio",
+ "tower-service",
+ "tracing",
+ "want",
+]
+
[[package]]
name = "hyper"
version = "1.7.0"
@@ -1782,9 +1903,9 @@ dependencies = [
"bytes",
"futures-channel",
"futures-core",
- "h2",
- "http",
- "http-body",
+ "h2 0.4.12",
+ "http 1.3.1",
+ "http-body 1.0.1",
"httparse",
"itoa",
"pin-project-lite",
@@ -1800,8 +1921,8 @@ version = "0.27.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58"
dependencies = [
- "http",
- "hyper",
+ "http 1.3.1",
+ "hyper 1.7.0",
"hyper-util",
"rustls",
"rustls-pki-types",
@@ -1811,6 +1932,19 @@ dependencies = [
"webpki-roots",
]
+[[package]]
+name = "hyper-tls"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
+dependencies = [
+ "bytes",
+ "hyper 0.14.32",
+ "native-tls",
+ "tokio",
+ "tokio-native-tls",
+]
+
[[package]]
name = "hyper-util"
version = "0.1.17"
@@ -1822,15 +1956,15 @@ dependencies = [
"futures-channel",
"futures-core",
"futures-util",
- "http",
- "http-body",
- "hyper",
+ "http 1.3.1",
+ "http-body 1.0.1",
+ "hyper 1.7.0",
"ipnet",
"libc",
"percent-encoding",
"pin-project-lite",
- "socket2",
- "system-configuration",
+ "socket2 0.6.0",
+ "system-configuration 0.6.1",
"tokio",
"tower-service",
"tracing",
@@ -2353,6 +2487,12 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
+[[package]]
+name = "minisign-verify"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e856fdd13623a2f5f2f54676a4ee49502a96a80ef4a62bcedd23d52427c44d43"
+
[[package]]
name = "miniz_oxide"
version = "0.8.9"
@@ -2395,6 +2535,23 @@ dependencies = [
"windows-sys 0.60.2",
]
+[[package]]
+name = "native-tls"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e"
+dependencies = [
+ "libc",
+ "log",
+ "openssl",
+ "openssl-probe",
+ "openssl-sys",
+ "schannel",
+ "security-framework",
+ "security-framework-sys",
+ "tempfile",
+]
+
[[package]]
name = "ndk"
version = "0.9.0"
@@ -2699,6 +2856,18 @@ dependencies = [
"objc2-foundation 0.2.2",
]
+[[package]]
+name = "objc2-osa-kit"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26bb88504b5a050dbba515d2414607bf5e57dd56b107bc5f0351197a3e7bdc5d"
+dependencies = [
+ "bitflags 2.9.4",
+ "objc2 0.6.2",
+ "objc2-app-kit",
+ "objc2-foundation 0.3.1",
+]
+
[[package]]
name = "objc2-quartz-core"
version = "0.2.2"
@@ -2789,6 +2958,50 @@ dependencies = [
"pathdiff",
]
+[[package]]
+name = "openssl"
+version = "0.10.74"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24ad14dd45412269e1a30f52ad8f0664f0f4f4a89ee8fe28c3b3527021ebb654"
+dependencies = [
+ "bitflags 2.9.4",
+ "cfg-if",
+ "foreign-types 0.3.2",
+ "libc",
+ "once_cell",
+ "openssl-macros",
+ "openssl-sys",
+]
+
+[[package]]
+name = "openssl-macros"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.106",
+]
+
+[[package]]
+name = "openssl-probe"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
+
+[[package]]
+name = "openssl-sys"
+version = "0.9.110"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0a9f0075ba3c21b09f8e8b2026584b1d18d49388648f2fbbf3c97ea8deced8e2"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+ "vcpkg",
+]
+
[[package]]
name = "option-ext"
version = "0.2.0"
@@ -2805,6 +3018,20 @@ dependencies = [
"pin-project-lite",
]
+[[package]]
+name = "osakit"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "732c71caeaa72c065bb69d7ea08717bd3f4863a4f451402fc9513e29dbd5261b"
+dependencies = [
+ "objc2 0.6.2",
+ "objc2-foundation 0.3.1",
+ "objc2-osa-kit",
+ "serde",
+ "serde_json",
+ "thiserror 2.0.16",
+]
+
[[package]]
name = "pango"
version = "0.18.3"
@@ -3249,7 +3476,7 @@ dependencies = [
"quinn-udp",
"rustc-hash",
"rustls",
- "socket2",
+ "socket2 0.6.0",
"thiserror 2.0.16",
"tokio",
"tracing",
@@ -3286,7 +3513,7 @@ dependencies = [
"cfg_aliases",
"libc",
"once_cell",
- "socket2",
+ "socket2 0.6.0",
"tracing",
"windows-sys 0.60.2",
]
@@ -3491,6 +3718,46 @@ version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001"
+[[package]]
+name = "reqwest"
+version = "0.11.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62"
+dependencies = [
+ "base64 0.21.7",
+ "bytes",
+ "encoding_rs",
+ "futures-core",
+ "futures-util",
+ "h2 0.3.27",
+ "http 0.2.12",
+ "http-body 0.4.6",
+ "hyper 0.14.32",
+ "hyper-tls",
+ "ipnet",
+ "js-sys",
+ "log",
+ "mime",
+ "native-tls",
+ "once_cell",
+ "percent-encoding",
+ "pin-project-lite",
+ "rustls-pemfile",
+ "serde",
+ "serde_json",
+ "serde_urlencoded",
+ "sync_wrapper 0.1.2",
+ "system-configuration 0.5.1",
+ "tokio",
+ "tokio-native-tls",
+ "tower-service",
+ "url",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "web-sys",
+ "winreg 0.50.0",
+]
+
[[package]]
name = "reqwest"
version = "0.12.23"
@@ -3504,11 +3771,11 @@ dependencies = [
"encoding_rs",
"futures-core",
"futures-util",
- "h2",
- "http",
- "http-body",
+ "h2 0.4.12",
+ "http 1.3.1",
+ "http-body 1.0.1",
"http-body-util",
- "hyper",
+ "hyper 1.7.0",
"hyper-rustls",
"hyper-util",
"js-sys",
@@ -3522,7 +3789,7 @@ dependencies = [
"serde",
"serde_json",
"serde_urlencoded",
- "sync_wrapper",
+ "sync_wrapper 1.0.2",
"tokio",
"tokio-rustls",
"tokio-util",
@@ -3644,6 +3911,15 @@ dependencies = [
"zeroize",
]
+[[package]]
+name = "rustls-pemfile"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
+dependencies = [
+ "base64 0.21.7",
+]
+
[[package]]
name = "rustls-pki-types"
version = "1.12.0"
@@ -3686,6 +3962,15 @@ dependencies = [
"winapi-util",
]
+[[package]]
+name = "schannel"
+version = "0.1.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1"
+dependencies = [
+ "windows-sys 0.61.0",
+]
+
[[package]]
name = "schemars"
version = "0.8.22"
@@ -3749,6 +4034,29 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+[[package]]
+name = "security-framework"
+version = "2.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
+dependencies = [
+ "bitflags 2.9.4",
+ "core-foundation 0.9.4",
+ "core-foundation-sys",
+ "libc",
+ "security-framework-sys",
+]
+
+[[package]]
+name = "security-framework-sys"
+version = "2.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
[[package]]
name = "selectors"
version = "0.24.0"
@@ -4028,6 +4336,16 @@ dependencies = [
"serde",
]
+[[package]]
+name = "socket2"
+version = "0.5.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678"
+dependencies = [
+ "libc",
+ "windows-sys 0.52.0",
+]
+
[[package]]
name = "socket2"
version = "0.6.0"
@@ -4047,7 +4365,7 @@ dependencies = [
"bytemuck",
"cfg_aliases",
"core-graphics",
- "foreign-types",
+ "foreign-types 0.5.0",
"js-sys",
"log",
"objc2 0.5.2",
@@ -4390,6 +4708,12 @@ dependencies = [
"unicode-ident",
]
+[[package]]
+name = "sync_wrapper"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
+
[[package]]
name = "sync_wrapper"
version = "1.0.2"
@@ -4410,6 +4734,17 @@ dependencies = [
"syn 2.0.106",
]
+[[package]]
+name = "system-configuration"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
+dependencies = [
+ "bitflags 1.3.2",
+ "core-foundation 0.9.4",
+ "system-configuration-sys 0.5.0",
+]
+
[[package]]
name = "system-configuration"
version = "0.6.1"
@@ -4418,7 +4753,17 @@ checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
dependencies = [
"bitflags 2.9.4",
"core-foundation 0.9.4",
- "system-configuration-sys",
+ "system-configuration-sys 0.6.0",
+]
+
+[[package]]
+name = "system-configuration-sys"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
]
[[package]]
@@ -4495,6 +4840,17 @@ dependencies = [
"syn 2.0.106",
]
+[[package]]
+name = "tar"
+version = "0.4.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d863878d212c87a19c1a610eb53bb01fe12951c0501cf5a0d65f724914a667a"
+dependencies = [
+ "filetime",
+ "libc",
+ "xattr",
+]
+
[[package]]
name = "target-lexicon"
version = "0.12.16"
@@ -4517,7 +4873,7 @@ dependencies = [
"glob",
"gtk",
"heck 0.5.0",
- "http",
+ "http 1.3.1",
"jni",
"libc",
"log",
@@ -4531,7 +4887,7 @@ dependencies = [
"percent-encoding",
"plist",
"raw-window-handle",
- "reqwest",
+ "reqwest 0.12.23",
"serde",
"serde_json",
"serde_repr",
@@ -4639,9 +4995,9 @@ version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bbb818e0e97f72dc9d353d38fa5799ed1dd4cf7371ff3195bd1231072d6fc2d"
dependencies = [
- "http",
+ "http 1.3.1",
"once_cell",
- "reqwest",
+ "reqwest 0.12.23",
"serde",
"serde_json",
"tauri",
@@ -4713,6 +5069,16 @@ dependencies = [
"zbus",
]
+[[package]]
+name = "tauri-plugin-process"
+version = "2.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d55511a7bf6cd70c8767b02c97bf8134fa434daf3926cfc1be0a0f94132d165a"
+dependencies = [
+ "tauri",
+ "tauri-plugin",
+]
+
[[package]]
name = "tauri-plugin-sql"
version = "2.3.0"
@@ -4732,6 +5098,38 @@ dependencies = [
"tokio",
]
+[[package]]
+name = "tauri-plugin-updater"
+version = "2.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "27cbc31740f4d507712550694749572ec0e43bdd66992db7599b89fbfd6b167b"
+dependencies = [
+ "base64 0.22.1",
+ "dirs",
+ "flate2",
+ "futures-util",
+ "http 1.3.1",
+ "infer",
+ "log",
+ "minisign-verify",
+ "osakit",
+ "percent-encoding",
+ "reqwest 0.12.23",
+ "semver",
+ "serde",
+ "serde_json",
+ "tar",
+ "tauri",
+ "tauri-plugin",
+ "tempfile",
+ "thiserror 2.0.16",
+ "time",
+ "tokio",
+ "url",
+ "windows-sys 0.60.2",
+ "zip",
+]
+
[[package]]
name = "tauri-runtime"
version = "2.8.0"
@@ -4741,7 +5139,7 @@ dependencies = [
"cookie",
"dpi",
"gtk",
- "http",
+ "http 1.3.1",
"jni",
"objc2 0.6.2",
"objc2-ui-kit",
@@ -4764,7 +5162,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1fe9d48bd122ff002064e88cfcd7027090d789c4302714e68fcccba0f4b7807"
dependencies = [
"gtk",
- "http",
+ "http 1.3.1",
"jni",
"log",
"objc2 0.6.2",
@@ -4797,7 +5195,7 @@ dependencies = [
"dunce",
"glob",
"html5ever",
- "http",
+ "http 1.3.1",
"infer",
"json-patch",
"kuchikiki",
@@ -4967,7 +5365,7 @@ dependencies = [
"pin-project-lite",
"signal-hook-registry",
"slab",
- "socket2",
+ "socket2 0.6.0",
"tokio-macros",
"tracing",
"windows-sys 0.59.0",
@@ -4984,6 +5382,16 @@ dependencies = [
"syn 2.0.106",
]
+[[package]]
+name = "tokio-native-tls"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
+dependencies = [
+ "native-tls",
+ "tokio",
+]
+
[[package]]
name = "tokio-rustls"
version = "0.26.4"
@@ -5123,7 +5531,7 @@ dependencies = [
"futures-core",
"futures-util",
"pin-project-lite",
- "sync_wrapper",
+ "sync_wrapper 1.0.2",
"tokio",
"tower-layer",
"tower-service",
@@ -5138,8 +5546,8 @@ dependencies = [
"bitflags 2.9.4",
"bytes",
"futures-util",
- "http",
- "http-body",
+ "http 1.3.1",
+ "http-body 1.0.1",
"iri-string",
"pin-project-lite",
"tower",
@@ -6225,6 +6633,16 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "winreg"
+version = "0.50.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
+dependencies = [
+ "cfg-if",
+ "windows-sys 0.48.0",
+]
+
[[package]]
name = "winreg"
version = "0.55.0"
@@ -6263,7 +6681,7 @@ dependencies = [
"gdkx11",
"gtk",
"html5ever",
- "http",
+ "http 1.3.1",
"javascriptcore-rs",
"jni",
"kuchikiki",
@@ -6313,6 +6731,16 @@ dependencies = [
"pkg-config",
]
+[[package]]
+name = "xattr"
+version = "1.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32e45ad4206f6d2479085147f02bc2ef834ac85886624a23575ae137c8aa8156"
+dependencies = [
+ "libc",
+ "rustix",
+]
+
[[package]]
name = "yoke"
version = "0.8.0"
@@ -6478,6 +6906,18 @@ dependencies = [
"syn 2.0.106",
]
+[[package]]
+name = "zip"
+version = "4.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "caa8cd6af31c3b31c6631b8f483848b91589021b28fffe50adada48d4f4d2ed1"
+dependencies = [
+ "arbitrary",
+ "crc32fast",
+ "indexmap 2.11.4",
+ "memchr",
+]
+
[[package]]
name = "zvariant"
version = "5.7.0"
diff --git a/fincept-terminal-desktop/src-tauri/Cargo.toml b/fincept-terminal-desktop/src-tauri/Cargo.toml
index 0f65f874f..4fe63a081 100644
--- a/fincept-terminal-desktop/src-tauri/Cargo.toml
+++ b/fincept-terminal-desktop/src-tauri/Cargo.toml
@@ -35,3 +35,4 @@ tokio = { version = "1", features = ["full"] }
anyhow = "1.0"
chrono = "0.4"
uuid = { version = "1.11", features = ["v4", "serde"] }
+reqwest = { version = "0.11", features = ["json"] }
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/mod.rs b/fincept-terminal-desktop/src-tauri/src/commands/mod.rs
index c85003d05..b2b43530a 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/mod.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/mod.rs
@@ -53,6 +53,7 @@ pub mod sentinelhub;
// Code editor and Jupyter notebook
pub mod jupyter;
+pub mod finscript_cmd;
// Python Agents
pub mod agents;
diff --git a/fincept-terminal-desktop/src-tauri/src/lib.rs b/fincept-terminal-desktop/src-tauri/src/lib.rs
index 5d6dd450f..da478bcde 100644
--- a/fincept-terminal-desktop/src-tauri/src/lib.rs
+++ b/fincept-terminal-desktop/src-tauri/src/lib.rs
@@ -14,6 +14,7 @@ use sha2::{Sha256, Digest};
mod data_sources;
mod commands;
mod utils;
+mod finscript;
// MCP Server Process with communication channels
struct MCPProcess {
@@ -39,6 +40,15 @@ fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
+// Cleanup workflow on app close (called from frontend)
+#[tauri::command]
+async fn cleanup_running_workflows() -> Result<(), String> {
+ println!("[Tauri] Cleaning up running workflows...");
+ // This is just a marker command - the actual cleanup happens in the frontend
+ // via workflowService.cleanupRunningWorkflows()
+ Ok(())
+}
+
// Spawn an MCP server process with background stdout reader
#[tauri::command]
fn spawn_mcp_server(
@@ -379,6 +389,7 @@ pub fn run() {
})
.invoke_handler(tauri::generate_handler![
greet,
+ cleanup_running_workflows,
spawn_mcp_server,
send_mcp_request,
send_mcp_notification,
@@ -917,6 +928,7 @@ pub fn run() {
commands::jupyter::get_python_version,
commands::jupyter::install_python_package,
commands::jupyter::list_python_packages,
+ commands::finscript_cmd::execute_finscript,
// Python Agent Commands
commands::agents::list_available_agents,
commands::agents::execute_python_agent,
diff --git a/fincept-terminal-desktop/src/App.tsx b/fincept-terminal-desktop/src/App.tsx
index 27727ce16..07a84134c 100644
--- a/fincept-terminal-desktop/src/App.tsx
+++ b/fincept-terminal-desktop/src/App.tsx
@@ -5,7 +5,9 @@ import React, { useState, useEffect } from 'react';
import { useAuth } from './contexts/AuthContext';
import { NavigationProvider } from './contexts/NavigationContext';
import { ThemeProvider } from './contexts/ThemeContext';
+import { DataSourceProvider } from './contexts/DataSourceContext';
import { setPaymentWindowManager } from './services/paymentApi';
+import { workflowService } from './services/workflowService';
// Import screens
import LoginScreen from './components/auth/LoginScreen';
@@ -105,6 +107,16 @@ const App: React.FC = () => {
console.log('PaymentManager: Initialized in-app payment window manager');
}, []);
+ // Cleanup running workflows on app unmount
+ useEffect(() => {
+ return () => {
+ console.log('[App] App unmounting, cleaning up running workflows...');
+ workflowService.cleanupRunningWorkflows().catch((error) => {
+ console.error('[App] Failed to cleanup running workflows:', error);
+ });
+ };
+ }, []);
+
// Handle payment success URL parameters
useEffect(() => {
const urlParams = new URLSearchParams(window.location.search);
@@ -201,11 +213,13 @@ const App: React.FC = () => {
if (session?.authenticated && currentScreen === 'dashboard') {
return (
<>
- <ThemeProvider>
- <NavigationProvider onNavigate={setCurrentScreen} onSetActiveTab={setActiveTab}>
- <DashboardScreen />
- </NavigationProvider>
- </ThemeProvider>
+ <DataSourceProvider>
+ <ThemeProvider>
+ <NavigationProvider onNavigate={setCurrentScreen} onSetActiveTab={setActiveTab}>
+ <DashboardScreen />
+ </NavigationProvider>
+ </ThemeProvider>
+ </DataSourceProvider>
{/* In-App Payment Window Overlay */}
<PaymentOverlay paymentWindow={paymentWindow} />
</>
diff --git a/fincept-terminal-desktop/src/components/dashboard/DashboardScreen.tsx b/fincept-terminal-desktop/src/components/dashboard/DashboardScreen.tsx
index 320ae970b..505d1e354 100644
--- a/fincept-terminal-desktop/src/components/dashboard/DashboardScreen.tsx
+++ b/fincept-terminal-desktop/src/components/dashboard/DashboardScreen.tsx
@@ -137,17 +137,28 @@ export default function FinxeptTerminal() {
document.documentElement.style.overflow = 'hidden';
document.documentElement.style.overscrollBehavior = 'none';
- // Initialize database on app start
+ // Initialize database and MCP servers on app start
(async () => {
try {
+ // Initialize database first
const { sqliteService } = await import('@/services/sqliteService');
if (!sqliteService.isReady()) {
- console.log('Initializing database on app start...');
+ console.log('[App] Initializing database on app start...');
await sqliteService.initialize();
- console.log('Database initialized successfully');
+ console.log('[App] Database initialized successfully');
+ }
+
+ // Auto-start MCP servers that have auto_start enabled
+ try {
+ const { mcpManager } = await import('@/services/mcpManager');
+ console.log('[App] Starting MCP auto-start servers...');
+ await mcpManager.startAutoStartServers();
+ console.log('[App] MCP servers auto-started successfully');
+ } catch (mcpError) {
+ console.warn('[App] MCP auto-start failed (this is OK if no servers are configured):', mcpError);
}
} catch (error) {
- console.error('Failed to initialize database on app start:', error);
+ console.error('[App] Failed to initialize on app start:', error);
}
})();
diff --git a/fincept-terminal-desktop/src/components/tabs/ChatTab.tsx b/fincept-terminal-desktop/src/components/tabs/ChatTab.tsx
index d14c736d3..9814d8ee2 100644
--- a/fincept-terminal-desktop/src/components/tabs/ChatTab.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/ChatTab.tsx
@@ -26,6 +26,7 @@ const ChatTab: React.FC<ChatTabProps> = ({ onNavigateToSettings }) => {
const [currentProvider, setCurrentProvider] = useState('ollama');
const [streamingContent, setStreamingContent] = useState('');
const [statistics, setStatistics] = useState({ totalSessions: 0, totalMessages: 0, totalTokens: 0 });
+ const [mcpToolsCount, setMcpToolsCount] = useState(0);
// Rename and search functionality
const [renamingSessionId, setRenamingSessionId] = useState<string | null>(null);
@@ -58,6 +59,7 @@ const ChatTab: React.FC<ChatTabProps> = ({ onNavigateToSettings }) => {
await loadSessions();
await loadStatistics();
await loadLLMProvider();
+ await loadMCPToolsCount();
setSystemStatus('STATUS: READY');
} catch (error) {
@@ -81,6 +83,15 @@ const ChatTab: React.FC<ChatTabProps> = ({ onNavigateToSettings }) => {
return () => clearInterval(timer);
}, []);
+ // Periodically check for MCP tools updates
+ useEffect(() => {
+ const mcpCheckInterval = setInterval(() => {
+ loadMCPToolsCount();
+ }, 10000); // Check every 10 seconds
+
+ return () => clearInterval(mcpCheckInterval);
+ }, []);
+
// Auto-scroll to bottom
useEffect(() => {
scrollToBottom();
@@ -129,6 +140,25 @@ const ChatTab: React.FC<ChatTabProps> = ({ onNavigateToSettings }) => {
}
};
+ const loadMCPToolsCount = async (retryCount = 0, maxRetries = 5) => {
+ try {
+ const { mcpToolService } = await import('../../services/mcpToolService');
+ const tools = await mcpToolService.getAllTools();
+ setMcpToolsCount(tools.length);
+ console.log(`[Chat] MCP Tools available: ${tools.length}`);
+
+ // If we got 0 tools and haven't exceeded max retries, try again after a delay
+ if (tools.length === 0 && retryCount < maxRetries) {
+ const delay = Math.min(1000 * Math.pow(2, retryCount), 10000); // Exponential backoff, max 10s
+ console.log(`[Chat] No tools found, retrying in ${delay}ms (attempt ${retryCount + 1}/${maxRetries})...`);
+ setTimeout(() => loadMCPToolsCount(retryCount + 1, maxRetries), delay);
+ }
+ } catch (error) {
+ console.log('[Chat] MCP not available:', error);
+ setMcpToolsCount(0);
+ }
+ };
+
const loadSessionMessages = async (sessionUuid: string) => {
try {
setSystemStatus('STATUS: LOADING MESSAGES...');
@@ -340,11 +370,13 @@ const ChatTab: React.FC<ChatTabProps> = ({ onNavigateToSettings }) => {
}
},
(toolName: string, args: any, result?: any) => {
- // Tool call callback
+ // Tool call callback - don't show in UI, only in console
if (!result) {
- setSystemStatus(`STATUS: Calling tool ${toolName}...`);
+ console.log(`[Tool Call] ${toolName}`, args);
+ setSystemStatus(`STATUS: Fetching data...`);
} else {
- setSystemStatus(`STATUS: Tool ${toolName} completed`);
+ console.log(`[Tool Result] ${toolName}`, result);
+ setSystemStatus(`STATUS: Processing response...`);
}
}
)
@@ -1001,9 +1033,18 @@ const ChatTab: React.FC<ChatTabProps> = ({ onNavigateToSettings }) => {
<div style={{ color: colors.text, fontSize: '9px', marginBottom: '2px' }}>
Temp: {llmConfigService.getActiveConfig().temperature}
</div>
- <div style={{ color: colors.secondary, fontSize: '9px' }}>
+ <div style={{ color: colors.secondary, fontSize: '9px', marginBottom: '2px' }}>
Streaming: Enabled
</div>
+ <div style={{
+ color: mcpToolsCount > 0 ? colors.secondary : colors.textMuted,
+ fontSize: '9px',
+ marginTop: '6px',
+ paddingTop: '6px',
+ borderTop: `1px solid ${colors.textMuted}`
+ }}>
+ MCP Tools: {mcpToolsCount > 0 ? `${mcpToolsCount} Available ✓` : 'None'}
+ </div>
</div>
</div>
diff --git a/fincept-terminal-desktop/src/components/tabs/CodeEditorTab.tsx b/fincept-terminal-desktop/src/components/tabs/CodeEditorTab.tsx
index 97b054ca7..4c9ed029a 100644
--- a/fincept-terminal-desktop/src/components/tabs/CodeEditorTab.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/CodeEditorTab.tsx
@@ -78,16 +78,39 @@ export default function CodeEditorTab() {
content: `// FinScript - Financial Analysis Language
// Example: EMA/WMA Crossover Strategy
-if ema(AAPL, 21) > wma(AAPL, 50) {
- buy "EMA 21 crosses WMA 50 - Buy Signal"
+// Calculate technical indicators
+ema_fast = ema(AAPL, 21)
+wma_slow = wma(AAPL, 50)
+rsi_value = rsi(AAPL, 14)
+
+// Get last values for comparison
+ema_current = last(ema_fast)
+wma_current = last(wma_slow)
+rsi_current = last(rsi_value)
+
+// EMA/WMA Crossover Strategy
+if ema_current > wma_current {
+ buy "EMA 21 crosses above WMA 50 - Bullish Signal"
}
-if ema(AAPL, 21) < wma(AAPL, 50) {
- sell "EMA 21 crosses below WMA 50 - Sell Signal"
+if ema_current < wma_current {
+ sell "EMA 21 crosses below WMA 50 - Bearish Signal"
}
+// RSI Overbought/Oversold Strategy
+if rsi_current > 70 {
+ sell "RSI Overbought - Consider Selling"
+}
+
+if rsi_current < 30 {
+ buy "RSI Oversold - Consider Buying"
+}
+
+// Plot indicators
plot ema(AAPL, 7), "EMA (7)"
-plot wma(AAPL, 21), "WMA (21)"
+plot ema_fast, "EMA (21)"
+plot wma_slow, "WMA (50)"
+plot rsi_value, "RSI (14)"
plot_candlestick AAPL, "Apple Stock Chart"`,
language: 'finscript',
unsaved: false
@@ -351,33 +374,74 @@ plot_candlestick AAPL, "Apple Stock Chart"`,
timestamp: new Date()
}]);
- // Simulate execution (in production, this would call the Rust backend)
- setTimeout(() => {
- const mockOutput = `
+ try {
+ const result = await invoke<{
+ success: boolean;
+ output: string;
+ signals: Array<{
+ signal_type: string;
+ message: string;
+ timestamp: string;
+ price?: number;
+ }>;
+ plots: Array<{
+ plot_type: string;
+ label: string;
+ data: Array<any>;
+ }>;
+ errors: string[];
+ execution_time_ms: number;
+ }>('execute_finscript', {
+ code: activeFile.content
+ });
+
+ let outputText = `
=== FinScript Execution Results ===
File: ${activeFile.name}
-Status: Completed Successfully
+Status: ${result.success ? 'Completed Successfully' : 'Failed'}
+Execution Time: ${result.execution_time_ms}ms
+
+${result.output}
-Fetching data for AAPL...
-Calculating EMA(7), EMA(21), WMA(21), WMA(50)...
+`;
-Signal Generated:
- ✓ BUY: EMA 21 crosses WMA 50 - Buy Signal
+ if (result.signals.length > 0) {
+ outputText += `\nSignals Generated:\n`;
+ result.signals.forEach(signal => {
+ const icon = signal.signal_type === 'Buy' ? '✓ BUY' : '✗ SELL';
+ outputText += ` ${icon}: ${signal.message}\n`;
+ });
+ }
+
+ if (result.plots.length > 0) {
+ outputText += `\nPlots Generated:\n`;
+ result.plots.forEach(plot => {
+ outputText += ` ✓ ${plot.plot_type}: ${plot.label} (${plot.data.length} data points)\n`;
+ });
+ }
-Chart Generated:
- ✓ Candlestick Chart: Apple Stock Chart
- ✓ Plot: EMA (7) - Current: 184.52
- ✓ Plot: WMA (21) - Current: 182.34
+ if (result.errors.length > 0) {
+ outputText += `\nErrors:\n`;
+ result.errors.forEach(error => {
+ outputText += ` ✗ ${error}\n`;
+ });
+ }
-Execution Time: 1.24s
-Memory Used: 2.4 MB
-`;
setOutput([...output, {
- output: mockOutput,
+ output: outputText,
+ error: result.errors.length > 0 ? result.errors.join('\n') : undefined,
timestamp: new Date()
}]);
+
setIsRunning(false);
- }, 1500);
+ } catch (error) {
+ setOutput([...output, {
+ output: `Execution failed: ${error}`,
+ error: String(error),
+ timestamp: new Date()
+ }]);
+ setIsRunning(false);
+ }
};
const runCode = () => {
@@ -442,6 +506,37 @@ Memory Used: 2.4 MB
}
};
+ const highlightFinScript = (code: string) => {
+ const keywords = ['if', 'else', 'buy', 'sell', 'plot', 'plot_candlestick', 'plot_bar', 'plot_area'];
+ const functions = ['ema', 'sma', 'wma', 'rsi', 'macd', 'last', 'high', 'low', 'open', 'close', 'volume'];
+ const operators = ['>', '<', '>=', '<=', '==', '!=', '&&', '||', '+', '-', '*', '/'];
+
+ let highlighted = code;
+
+ // Highlight comments
+ highlighted = highlighted.replace(/(\/\/.*$)/gm, '<span style="color: #787878; font-style: italic;">$1</span>');
+
+ // Highlight strings
+ highlighted = highlighted.replace(/"([^"]*)"/g, '<span style="color: #98c379;">\"$1\"</span>');
+
+ // Highlight numbers
+ highlighted = highlighted.replace(/\b(\d+\.?\d*)\b/g, '<span style="color: #d19a66;">$1</span>');
+
+ // Highlight keywords
+ keywords.forEach(keyword => {
+ const regex = new RegExp(`\\b(${keyword})\\b`, 'g');
+ highlighted = highlighted.replace(regex, `<span style="color: ${C.ORANGE}; font-weight: bold;">$1</span>`);
+ });
+
+ // Highlight functions
+ functions.forEach(func => {
+ const regex = new RegExp(`\\b(${func})(?=\\()`, 'g');
+ highlighted = highlighted.replace(regex, `<span style="color: ${C.CYAN};">$1</span>`);
+ });
+
+ return highlighted;
+ };
+
// Jupyter Notebook Functions
const createNewNotebook = async () => {
try {
diff --git a/fincept-terminal-desktop/src/components/tabs/DashboardTab.tsx b/fincept-terminal-desktop/src/components/tabs/DashboardTab.tsx
index 0ee03d859..cc50b6bcb 100644
--- a/fincept-terminal-desktop/src/components/tabs/DashboardTab.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/DashboardTab.tsx
@@ -536,14 +536,14 @@ const DashboardTab: React.FC<DashboardTabProps> = ({ onNavigateToTab }) => {
rowHeight={60}
width={containerWidth - 16}
onLayoutChange={handleLayoutChange}
- draggableHandle=".drag-handle"
+ draggableHandle=".widget-drag-handle"
isDraggable={true}
isResizable={true}
compactType="vertical"
preventCollision={false}
>
{widgets.map(widget => (
- <div key={widget.id} className="drag-handle">
+ <div key={widget.id}>
{renderWidget(widget)}
</div>
))}
diff --git a/fincept-terminal-desktop/src/components/tabs/ForumTab.tsx b/fincept-terminal-desktop/src/components/tabs/ForumTab.tsx
index da960701f..9a3d37eeb 100644
--- a/fincept-terminal-desktop/src/components/tabs/ForumTab.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/ForumTab.tsx
@@ -71,7 +71,7 @@ const ForumTab: React.FC = () => {
const [profileEdit, setProfileEdit] = useState({
display_name: '',
bio: '',
- avatar_color: 'colors.primary',
+ avatar_color: colors.primary,
signature: ''
});
@@ -82,18 +82,18 @@ const ForumTab: React.FC = () => {
const [trendingTopics, setTrendingTopics] = useState<Array<{ topic: string; mentions: number; sentiment: string; change: string }>>([]);
const [recentActivity, setRecentActivity] = useState<Array<{ user: string; action: string; target: string; time: string }>>([]);
- // Bloomberg color scheme
- const BLOOMBERG_ORANGE = 'colors.primary';
- const BLOOMBERG_WHITE = 'colors.text';
- const BLOOMBERG_RED = 'colors.alert';
- const BLOOMBERG_GREEN = 'colors.secondary';
- const BLOOMBERG_YELLOW = 'colors.warning';
- const BLOOMBERG_GRAY = 'colors.textMuted';
- const BLOOMBERG_BLUE = 'colors.info';
- const BLOOMBERG_PURPLE = '#C864FF';
- const BLOOMBERG_CYAN = 'colors.accent';
- const BLOOMBERG_DARK_BG = 'colors.background';
- const BLOOMBERG_PANEL_BG = 'colors.panel';
+ // Bloomberg color scheme - use actual theme colors
+ const BLOOMBERG_ORANGE = colors.primary;
+ const BLOOMBERG_WHITE = colors.text;
+ const BLOOMBERG_RED = colors.alert;
+ const BLOOMBERG_GREEN = colors.secondary;
+ const BLOOMBERG_YELLOW = colors.warning;
+ const BLOOMBERG_GRAY = colors.textMuted;
+ const BLOOMBERG_BLUE = colors.info;
+ const BLOOMBERG_PURPLE = colors.purple;
+ const BLOOMBERG_CYAN = colors.accent;
+ const BLOOMBERG_DARK_BG = colors.background;
+ const BLOOMBERG_PANEL_BG = colors.panel;
// Top contributors - static for now
const topContributors: ForumUser[] = [
@@ -178,7 +178,8 @@ const ForumTab: React.FC = () => {
setCategories(formattedCategories);
}
} catch (error) {
- console.error('Error fetching categories:', error);
+ // Silently fail - backend may not be available
+ console.debug('Forum API not available (categories)');
}
};
@@ -209,7 +210,8 @@ const ForumTab: React.FC = () => {
setForumPosts(formattedPosts);
}
} catch (error) {
- console.error('Error fetching posts:', error);
+ // Silently fail - backend may not be available
+ console.debug('Forum API not available (posts)');
} finally {
setIsLoading(false);
}
@@ -228,7 +230,8 @@ const ForumTab: React.FC = () => {
}
}
} catch (error) {
- console.error('Error fetching forum stats:', error);
+ // Silently fail - backend may not be available
+ console.debug('Forum API not available (stats)');
}
};
@@ -302,7 +305,8 @@ const ForumTab: React.FC = () => {
setPostComments(formattedComments);
}
} catch (error) {
- console.error('Error fetching post details:', error);
+ // Silently fail - backend may not be available
+ console.debug('Forum API not available (post details)');
}
};
@@ -419,7 +423,7 @@ const ForumTab: React.FC = () => {
setProfileEdit({
display_name: profile.display_name || '',
bio: profile.bio || '',
- avatar_color: profile.avatar_color || 'colors.primary',
+ avatar_color: profile.avatar_color || colors.primary,
signature: profile.signature || ''
});
setShowProfile(true);
diff --git a/fincept-terminal-desktop/src/components/tabs/NodeEditorTab.tsx b/fincept-terminal-desktop/src/components/tabs/NodeEditorTab.tsx
index 306cc7bac..62120c3d1 100644
--- a/fincept-terminal-desktop/src/components/tabs/NodeEditorTab.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/NodeEditorTab.tsx
@@ -31,14 +31,20 @@ import {
FileText,
Edit3,
X,
- Monitor
+ Monitor,
+ Rocket
} from 'lucide-react';
import MCPToolNode from './node-editor/MCPToolNode';
import { generateMCPNodeConfigs, MCPNodeConfig } from './node-editor/mcpNodeConfigs';
import PythonAgentNode from './node-editor/PythonAgentNode';
import ResultsDisplayNode from './node-editor/ResultsDisplayNode';
import AgentMediatorNode from './node-editor/AgentMediatorNode';
+import DataSourceNode from './node-editor/DataSourceNode';
+import WorkflowManager from './node-editor/WorkflowManager';
+import ResultsModal from './node-editor/ResultsModal';
import { pythonAgentService, AgentMetadata } from '@/services/pythonAgentService';
+import { workflowExecutor } from './node-editor/WorkflowExecutor';
+import { Workflow, workflowService } from '@/services/workflowService';
import { nodeExecutionManager } from '@/services/nodeExecutionManager';
// Custom Node Component
@@ -207,6 +213,14 @@ const CustomNode = ({ data, id, selected }: any) => {
};
const NODE_CONFIGS = [
+ {
+ type: 'data-source',
+ label: 'Data Source',
+ color: '#3b82f6',
+ category: 'Input',
+ hasInput: false,
+ hasOutput: true,
+ },
{
type: 'agent-mediator',
label: 'Agent Mediator',
@@ -293,13 +307,25 @@ export default function NodeEditorTab() {
const [selectedNodes, setSelectedNodes] = useState<string[]>([]);
const [showNodeMenu, setShowNodeMenu] = useState(false);
+ const [activeView, setActiveView] = useState<'editor' | 'workflows'>('editor');
+ const [showDeployDialog, setShowDeployDialog] = useState(false);
+ const [workflowName, setWorkflowName] = useState('');
+ const [workflowDescription, setWorkflowDescription] = useState('');
+ const [editingDraftId, setEditingDraftId] = useState<string | null>(null);
+ const [isExecuting, setIsExecuting] = useState(false);
+ const [workflowMode, setWorkflowMode] = useState<'new' | 'draft' | 'deployed'>('new');
+ const [currentWorkflowId, setCurrentWorkflowId] = useState<string | null>(null);
+ const [showResultsModal, setShowResultsModal] = useState(false);
+ const [resultsData, setResultsData] = useState<any>(null);
+ const [resultsWorkflowName, setResultsWorkflowName] = useState<string>('');
const nodeTypes: NodeTypes = useMemo(() => ({
custom: CustomNode,
'mcp-tool': MCPToolNode,
'python-agent': PythonAgentNode,
'results-display': ResultsDisplayNode,
- 'agent-mediator': AgentMediatorNode
+ 'agent-mediator': AgentMediatorNode,
+ 'data-source': DataSourceNode
}), []);
// Handle label change
@@ -334,16 +360,17 @@ export default function NodeEditorTab() {
[setEdges]
);
- // Add new node (handles regular nodes, MCP tool nodes, Python agent nodes, and agent mediator)
+ // Add new node (handles regular nodes, MCP tool nodes, Python agent nodes, data source, and agent mediator)
const addNode = (config: any) => {
const isMCPNode = config.type === 'mcp-tool';
const isPythonAgent = config.type === 'python-agent';
const isResultsDisplay = config.type === 'results-display';
const isAgentMediator = config.type === 'agent-mediator';
+ const isDataSource = config.type === 'data-source';
const newNode: Node = {
id: `node_${Date.now()}`,
- type: isPythonAgent ? 'python-agent' : (isMCPNode ? 'mcp-tool' : (isResultsDisplay ? 'results-display' : (isAgentMediator ? 'agent-mediator' : 'custom'))),
+ type: isPythonAgent ? 'python-agent' : (isMCPNode ? 'mcp-tool' : (isResultsDisplay ? 'results-display' : (isAgentMediator ? 'agent-mediator' : (isDataSource ? 'data-source' : 'custom')))),
position: { x: Math.random() * 400 + 100, y: Math.random() * 300 + 100 },
data: isPythonAgent ? {
agentType: config.id, // Use 'id' field which contains agent_type like 'warren_buffett'
@@ -462,6 +489,47 @@ export default function NodeEditorTab() {
)
);
},
+ } : (isDataSource ? {
+ label: config.label,
+ selectedConnectionId: undefined,
+ query: '',
+ status: 'idle',
+ result: undefined,
+ error: undefined,
+ onConnectionChange: (connectionId: string) => {
+ setNodes((nds) =>
+ nds.map((n) =>
+ n.id === newNode.id
+ ? {
+ ...n,
+ data: {
+ ...n.data,
+ selectedConnectionId: connectionId,
+ },
+ }
+ : n
+ )
+ );
+ },
+ onQueryChange: (query: string) => {
+ setNodes((nds) =>
+ nds.map((n) =>
+ n.id === newNode.id
+ ? {
+ ...n,
+ data: {
+ ...n.data,
+ query: query,
+ },
+ }
+ : n
+ )
+ );
+ },
+ onExecute: async () => {
+ console.log('[NodeEditor] Data source node execute clicked');
+ // Will be handled by workflow execution
+ },
} : {
label: config.label,
nodeType: config.type,
@@ -469,7 +537,7 @@ export default function NodeEditorTab() {
hasInput: config.hasInput,
hasOutput: config.hasOutput,
onLabelChange: handleLabelChange,
- }))),
+ })))),
};
setNodes((nds) => [...nds, newNode]);
setShowNodeMenu(false);
@@ -576,7 +644,201 @@ export default function NodeEditorTab() {
setNodes([]);
setEdges([]);
localStorage.removeItem('nodeEditorWorkflow');
- console.log('[NodeEditor] Cleared workflow');
+ setWorkflowMode('new');
+ setCurrentWorkflowId(null);
+ setEditingDraftId(null);
+ setWorkflowName('');
+ setWorkflowDescription('');
+ console.log('[NodeEditor] Cleared workflow and reset to new mode');
+ }, [setNodes, setEdges]);
+
+ // Deploy workflow
+ const deployWorkflow = useCallback(async () => {
+ if (!workflowName.trim()) {
+ alert('Please enter a workflow name');
+ return;
+ }
+
+ if (isExecuting) {
+ alert('A workflow is already executing. Please wait for it to complete.');
+ return;
+ }
+
+ // Store values before closing dialog
+ const name = workflowName;
+ const description = workflowDescription;
+ const currentNodes = nodes;
+ const currentEdges = edges;
+
+ // Close dialog IMMEDIATELY - don't wait for execution
+ setShowDeployDialog(false);
+ setWorkflowName('');
+ setWorkflowDescription('');
+ setEditingDraftId(null);
+ setActiveView('editor'); // Stay in editor to see execution progress
+
+ // Execute in background
+ setIsExecuting(true);
+
+ // Use setTimeout to ensure dialog closes before heavy execution starts
+ setTimeout(async () => {
+ try {
+ const result = await workflowExecutor.executeAndSave(
+ currentNodes,
+ currentEdges,
+ {
+ name: name,
+ description: description,
+ saveAsDraft: false
+ },
+ (nodeId, status, result) => {
+ setNodes((nds) =>
+ nds.map((node) => {
+ if (node.id === nodeId) {
+ if (node.type === 'results-display') {
+ return {
+ ...node,
+ data: {
+ ...node.data,
+ inputData: status === 'completed' ? result : undefined,
+ status,
+ },
+ };
+ }
+ return {
+ ...node,
+ data: {
+ ...node.data,
+ status,
+ result: status === 'completed' ? result : undefined,
+ error: status === 'error' ? result : undefined,
+ },
+ };
+ }
+ return node;
+ })
+ );
+ }
+ );
+
+ if (result.success) {
+ console.log('[NodeEditor] Workflow deployed successfully:', result.workflowId);
+
+ // Clear the canvas after successful deployment
+ setNodes([]);
+ setEdges([]);
+ localStorage.removeItem('nodeEditorWorkflow');
+
+ // Reset to new workflow mode
+ setCurrentWorkflowId(null);
+ setWorkflowMode('new');
+ setEditingDraftId(null);
+
+ console.log('[NodeEditor] Canvas cleared, ready for new workflow');
+ } else {
+ console.error('[NodeEditor] Deployment failed:', result.error);
+ alert(`Deployment failed: ${result.error}`);
+ }
+ } catch (error: any) {
+ console.error('[NodeEditor] Deploy failed:', error);
+ alert(`Deployment failed: ${error.message}`);
+ } finally {
+ setIsExecuting(false);
+ }
+ }, 0);
+ }, [nodes, edges, workflowName, workflowDescription, isExecuting, setNodes]);
+
+ // Save as draft
+ const saveDraft = useCallback(async () => {
+ if (!workflowName.trim()) {
+ alert('Please enter a workflow name');
+ return;
+ }
+
+ try {
+ let workflowId: string;
+ if (editingDraftId) {
+ // Update existing draft
+ await workflowService.updateDraft(
+ editingDraftId,
+ workflowName,
+ workflowDescription,
+ nodes,
+ edges
+ );
+ console.log('[NodeEditor] Draft updated:', editingDraftId);
+ workflowId = editingDraftId;
+ setEditingDraftId(null);
+ } else {
+ // Create new draft
+ workflowId = await workflowExecutor.saveDraft(
+ workflowName,
+ workflowDescription,
+ nodes,
+ edges
+ );
+ console.log('[NodeEditor] Draft saved:', workflowId);
+ }
+ setCurrentWorkflowId(workflowId);
+ setWorkflowMode('draft');
+ setShowDeployDialog(false);
+ setWorkflowName('');
+ setWorkflowDescription('');
+ setActiveView('workflows');
+ } catch (error: any) {
+ console.error('[NodeEditor] Save draft failed:', error);
+ alert(`Save failed: ${error.message}`);
+ }
+ }, [nodes, edges, workflowName, workflowDescription, editingDraftId]);
+
+ // Load workflow from manager (for play button on draft/completed workflows)
+ const handleLoadWorkflow = useCallback((loadedNodes: Node[], loadedEdges: Edge[], workflowId: string, workflow: Workflow) => {
+ setNodes(loadedNodes);
+ setEdges(loadedEdges);
+ setCurrentWorkflowId(workflowId);
+ setWorkflowMode(workflow.status === 'draft' ? 'draft' : 'deployed');
+ setActiveView('editor');
+ console.log('[NodeEditor] Loaded workflow:', loadedNodes.length, 'nodes', 'Mode:', workflow.status);
+ }, [setNodes, setEdges]);
+
+ // View workflow results
+ const handleViewResults = useCallback((workflow: Workflow) => {
+ console.log('[NodeEditor] Viewing results for workflow:', workflow.id);
+
+ // Ask user if they want to see in modal or navigate to workflow
+ const choice = window.confirm(
+ `View results for: ${workflow.name}\n\n` +
+ `Click OK to view in modal window\n` +
+ `Click Cancel to navigate to workflow editor with results`
+ );
+
+ if (choice) {
+ // Show in modal
+ setResultsData(workflow.results);
+ setResultsWorkflowName(workflow.name);
+ setShowResultsModal(true);
+ } else {
+ // Navigate to editor with results
+ setNodes(workflow.nodes);
+ setEdges(workflow.edges);
+ setCurrentWorkflowId(workflow.id);
+ setWorkflowMode('deployed');
+ setActiveView('editor');
+ }
+ }, [setNodes, setEdges]);
+
+ // Edit draft workflow
+ const handleEditDraft = useCallback((workflow: Workflow) => {
+ console.log('[NodeEditor] Editing draft:', workflow.id);
+ setNodes(workflow.nodes);
+ setEdges(workflow.edges);
+ setWorkflowName(workflow.name);
+ setWorkflowDescription(workflow.description || '');
+ setEditingDraftId(workflow.id);
+ setCurrentWorkflowId(workflow.id);
+ setWorkflowMode('draft');
+ setShowDeployDialog(true);
+ setActiveView('editor');
}, [setNodes, setEdges]);
return (
@@ -614,10 +876,45 @@ export default function NodeEditorTab() {
NODE EDITOR
</span>
<div style={{ width: '1px', height: '20px', backgroundColor: '#404040' }}></div>
+
+ {/* Tab Switcher */}
+ <button
+ onClick={() => setActiveView('editor')}
+ style={{
+ backgroundColor: activeView === 'editor' ? '#ea580c' : 'transparent',
+ color: activeView === 'editor' ? 'white' : '#a3a3a3',
+ border: activeView === 'editor' ? 'none' : '1px solid #404040',
+ padding: '4px 10px',
+ fontSize: '10px',
+ cursor: 'pointer',
+ borderRadius: '3px',
+ fontWeight: 'bold',
+ }}
+ >
+ EDITOR
+ </button>
+ <button
+ onClick={() => setActiveView('workflows')}
+ style={{
+ backgroundColor: activeView === 'workflows' ? '#ea580c' : 'transparent',
+ color: activeView === 'workflows' ? 'white' : '#a3a3a3',
+ border: activeView === 'workflows' ? 'none' : '1px solid #404040',
+ padding: '4px 10px',
+ fontSize: '10px',
+ cursor: 'pointer',
+ borderRadius: '3px',
+ fontWeight: 'bold',
+ }}
+ >
+ WORKFLOWS
+ </button>
</div>
- <button
- onClick={() => setShowNodeMenu(!showNodeMenu)}
+ {/* Editor-specific buttons */}
+ {activeView === 'editor' && (
+ <>
+ <button
+ onClick={() => setShowNodeMenu(!showNodeMenu)}
style={{
backgroundColor: '#ea580c',
color: 'white',
@@ -640,7 +937,13 @@ export default function NodeEditorTab() {
<button
onClick={async () => {
+ if (isExecuting) {
+ alert('A workflow is already executing. Please wait for it to complete.');
+ return;
+ }
+
try {
+ setIsExecuting(true);
console.log('[NodeEditor] Starting workflow execution...');
await nodeExecutionManager.executeWorkflow(
nodes,
@@ -686,12 +989,54 @@ export default function NodeEditorTab() {
} catch (error: any) {
console.error('[NodeEditor] Workflow execution failed:', error);
// Don't use alert - just log the error
+ } finally {
+ setIsExecuting(false);
}
}}
+ disabled={isExecuting}
style={{
backgroundColor: 'transparent',
- color: '#10b981',
- border: '1px solid #10b981',
+ color: isExecuting ? '#737373' : '#10b981',
+ border: `1px solid ${isExecuting ? '#737373' : '#10b981'}`,
+ padding: '6px 12px',
+ fontSize: '11px',
+ cursor: isExecuting ? 'not-allowed' : 'pointer',
+ borderRadius: '3px',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '6px',
+ opacity: isExecuting ? 0.5 : 1,
+ }}
+ onMouseEnter={(e) => {
+ if (!isExecuting) {
+ e.currentTarget.style.backgroundColor = '#10b981';
+ e.currentTarget.style.color = 'white';
+ }
+ }}
+ onMouseLeave={(e) => {
+ if (!isExecuting) {
+ e.currentTarget.style.backgroundColor = 'transparent';
+ e.currentTarget.style.color = '#10b981';
+ }
+ }}
+ >
+ <Play size={14} />
+ {isExecuting ? 'EXECUTING...' : 'EXECUTE'}
+ </button>
+
+ <div style={{ width: '1px', height: '20px', backgroundColor: '#404040' }}></div>
+
+ {/* New Workflow Button */}
+ <button
+ onClick={() => {
+ if (window.confirm('Start a new workflow? Current work will be cleared unless saved.')) {
+ clearWorkflow();
+ }
+ }}
+ style={{
+ backgroundColor: 'transparent',
+ color: '#3b82f6',
+ border: '1px solid #3b82f6',
padding: '6px 12px',
fontSize: '11px',
cursor: 'pointer',
@@ -699,20 +1044,59 @@ export default function NodeEditorTab() {
display: 'flex',
alignItems: 'center',
gap: '6px',
+ fontWeight: 'bold',
}}
onMouseEnter={(e) => {
- e.currentTarget.style.backgroundColor = '#10b981';
+ e.currentTarget.style.backgroundColor = '#3b82f6';
e.currentTarget.style.color = 'white';
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = 'transparent';
- e.currentTarget.style.color = '#10b981';
+ e.currentTarget.style.color = '#3b82f6';
}}
+ title="Start a new workflow"
>
- <Play size={14} />
- EXECUTE
+ <Plus size={14} />
+ NEW
</button>
+ {/* Quick Save for Drafts */}
+ {workflowMode === 'draft' && editingDraftId && (
+ <button
+ onClick={async () => {
+ try {
+ await workflowService.updateDraft(
+ editingDraftId,
+ workflowName || 'Untitled Draft',
+ workflowDescription,
+ nodes,
+ edges
+ );
+ alert('Draft saved successfully!');
+ } catch (error: any) {
+ alert(`Save failed: ${error.message}`);
+ }
+ }}
+ style={{
+ backgroundColor: '#f59e0b',
+ color: 'white',
+ border: 'none',
+ padding: '6px 12px',
+ fontSize: '11px',
+ cursor: 'pointer',
+ borderRadius: '3px',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '6px',
+ fontWeight: 'bold',
+ }}
+ title="Quick save current draft"
+ >
+ <Save size={14} />
+ SAVE DRAFT
+ </button>
+ )}
+
<div style={{ width: '1px', height: '20px', backgroundColor: '#404040' }}></div>
<button
@@ -864,21 +1248,55 @@ export default function NodeEditorTab() {
</>
)}
- <div
- style={{
- marginLeft: 'auto',
- display: 'flex',
- alignItems: 'center',
- gap: '12px',
- }}
- >
- <span style={{ color: '#737373', fontSize: '10px' }}>
- NODES: {nodes.length}
- </span>
- <span style={{ color: '#737373', fontSize: '10px' }}>
- CONNECTIONS: {edges.length}
- </span>
- </div>
+ <div style={{ width: '1px', height: '20px', backgroundColor: '#404040' }}></div>
+
+ {/* DEPLOY Button */}
+ <button
+ onClick={() => setShowDeployDialog(true)}
+ style={{
+ backgroundColor: 'transparent',
+ color: '#3b82f6',
+ border: '1px solid #3b82f6',
+ padding: '6px 12px',
+ fontSize: '11px',
+ cursor: 'pointer',
+ borderRadius: '3px',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '6px',
+ fontWeight: 'bold',
+ }}
+ onMouseEnter={(e) => {
+ e.currentTarget.style.backgroundColor = '#3b82f6';
+ e.currentTarget.style.color = 'white';
+ }}
+ onMouseLeave={(e) => {
+ e.currentTarget.style.backgroundColor = 'transparent';
+ e.currentTarget.style.color = '#3b82f6';
+ }}
+ title="Deploy workflow to database"
+ >
+ <Rocket size={14} />
+ DEPLOY
+ </button>
+
+ <div
+ style={{
+ marginLeft: 'auto',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '12px',
+ }}
+ >
+ <span style={{ color: '#737373', fontSize: '10px' }}>
+ NODES: {nodes.length}
+ </span>
+ <span style={{ color: '#737373', fontSize: '10px' }}>
+ CONNECTIONS: {edges.length}
+ </span>
+ </div>
+ </>
+ )}
</div>
{/* Node Menu */}
@@ -1106,82 +1524,274 @@ export default function NodeEditorTab() {
</div>
)}
- {/* React Flow Canvas */}
- <div style={{ flex: 1, position: 'relative' }}>
- <ReactFlow
- nodes={nodes}
- edges={edges}
- onNodesChange={onNodesChange}
- onEdgesChange={onEdgesChange}
- onConnect={onConnect}
- onSelectionChange={onSelectionChange}
- nodeTypes={nodeTypes}
- fitView
- style={{ background: 'colors.panel' }}
- defaultEdgeOptions={{
- animated: true,
- style: { stroke: '#ea580c', strokeWidth: 2 },
+ {/* Main Content - Conditional Rendering */}
+ {activeView === 'editor' ? (
+ <>
+ {/* React Flow Canvas */}
+ <div style={{ flex: 1, position: 'relative' }}>
+ <ReactFlow
+ nodes={nodes}
+ edges={edges}
+ onNodesChange={onNodesChange}
+ onEdgesChange={onEdgesChange}
+ onConnect={onConnect}
+ onSelectionChange={onSelectionChange}
+ nodeTypes={nodeTypes}
+ fitView
+ style={{ background: 'colors.panel' }}
+ defaultEdgeOptions={{
+ animated: true,
+ style: { stroke: '#ea580c', strokeWidth: 2 },
+ }}
+ >
+ <Background
+ color="#2d2d2d"
+ gap={20}
+ size={1}
+ style={{ backgroundColor: 'colors.panel' }}
+ />
+ <Controls
+ style={{
+ backgroundColor: '#1a1a1a',
+ border: '1px solid #2d2d2d',
+ borderRadius: '4px',
+ }}
+ />
+ <MiniMap
+ style={{
+ backgroundColor: '#1a1a1a',
+ border: '1px solid #2d2d2d',
+ }}
+ nodeColor={(node) => {
+ return node.data.color || '#3b82f6';
+ }}
+ />
+ </ReactFlow>
+ </div>
+ </>
+ ) : (
+ /* Workflow Manager View */
+ <div style={{ flex: 1, overflow: 'hidden' }}>
+ <WorkflowManager
+ onLoadWorkflow={handleLoadWorkflow}
+ onViewResults={handleViewResults}
+ onEditDraft={handleEditDraft}
+ />
+ </div>
+ )}
+
+ {/* Bottom Info Bar */}
+ {activeView === 'editor' && (
+ <div
+ style={{
+ backgroundColor: '#1a1a1a',
+ borderTop: '1px solid #2d2d2d',
+ padding: '6px 12px',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '16px',
+ fontSize: '10px',
+ color: '#737373',
+ flexShrink: 0,
}}
>
- <Background
- color="#2d2d2d"
- gap={20}
- size={1}
- style={{ backgroundColor: 'colors.panel' }}
- />
- <Controls
- style={{
- backgroundColor: '#1a1a1a',
- border: '1px solid #2d2d2d',
- borderRadius: '4px',
- }}
- />
- <MiniMap
+ <span>💡 Drag nodes to move | Drag from handles to connect | Select & Delete to remove</span>
+ {selectedNodes.length > 0 && (
+ <>
+ <div style={{ width: '1px', height: '14px', backgroundColor: '#404040' }}></div>
+ <span style={{ color: '#ea580c' }}>
+ Selected: {selectedNodes.length} node(s)
+ </span>
+ </>
+ )}
+ <div
style={{
- backgroundColor: '#1a1a1a',
- border: '1px solid #2d2d2d',
- }}
- nodeColor={(node) => {
- return node.data.color || '#3b82f6';
+ marginLeft: 'auto',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '12px',
}}
- />
- </ReactFlow>
- </div>
+ >
+ <span>Scroll to zoom | Right-click drag to pan</span>
+ </div>
+ </div>
+ )}
- {/* Bottom Info Bar */}
- <div
- style={{
- backgroundColor: '#1a1a1a',
- borderTop: '1px solid #2d2d2d',
- padding: '6px 12px',
- display: 'flex',
- alignItems: 'center',
- gap: '16px',
- fontSize: '10px',
- color: '#737373',
- flexShrink: 0,
- }}
- >
- <span>💡 Drag nodes to move | Drag from handles to connect | Select & Delete to remove</span>
- {selectedNodes.length > 0 && (
- <>
- <div style={{ width: '1px', height: '14px', backgroundColor: '#404040' }}></div>
- <span style={{ color: '#ea580c' }}>
- Selected: {selectedNodes.length} node(s)
- </span>
- </>
- )}
+ {/* Deploy Dialog */}
+ {showDeployDialog && (
<div
style={{
- marginLeft: 'auto',
+ position: 'fixed',
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ backgroundColor: 'rgba(0, 0, 0, 0.7)',
display: 'flex',
alignItems: 'center',
- gap: '12px',
+ justifyContent: 'center',
+ zIndex: 2000,
}}
+ onClick={() => setShowDeployDialog(false)}
>
- <span>Scroll to zoom | Right-click drag to pan</span>
+ <div
+ style={{
+ backgroundColor: '#1a1a1a',
+ border: '1px solid #2d2d2d',
+ borderRadius: '6px',
+ padding: '24px',
+ minWidth: '400px',
+ maxWidth: '500px',
+ }}
+ onClick={(e) => e.stopPropagation()}
+ >
+ <div
+ style={{
+ color: '#ea580c',
+ fontSize: '14px',
+ fontWeight: 'bold',
+ marginBottom: '20px',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '8px',
+ }}
+ >
+ <Rocket size={16} />
+ DEPLOY WORKFLOW
+ </div>
+
+ <div style={{ marginBottom: '16px' }}>
+ <label
+ style={{
+ display: 'block',
+ color: '#a3a3a3',
+ fontSize: '11px',
+ marginBottom: '6px',
+ fontWeight: 'bold',
+ }}
+ >
+ WORKFLOW NAME *
+ </label>
+ <input
+ type="text"
+ value={workflowName}
+ onChange={(e) => setWorkflowName(e.target.value)}
+ placeholder="Enter workflow name..."
+ autoFocus
+ style={{
+ width: '100%',
+ backgroundColor: '#0a0a0a',
+ border: '1px solid #2d2d2d',
+ color: 'white',
+ padding: '8px 12px',
+ fontSize: '12px',
+ borderRadius: '4px',
+ outline: 'none',
+ boxSizing: 'border-box',
+ }}
+ />
+ </div>
+
+ <div style={{ marginBottom: '20px' }}>
+ <label
+ style={{
+ display: 'block',
+ color: '#a3a3a3',
+ fontSize: '11px',
+ marginBottom: '6px',
+ fontWeight: 'bold',
+ }}
+ >
+ DESCRIPTION (OPTIONAL)
+ </label>
+ <textarea
+ value={workflowDescription}
+ onChange={(e) => setWorkflowDescription(e.target.value)}
+ placeholder="Enter workflow description..."
+ rows={3}
+ style={{
+ width: '100%',
+ backgroundColor: '#0a0a0a',
+ border: '1px solid #2d2d2d',
+ color: 'white',
+ padding: '8px 12px',
+ fontSize: '12px',
+ borderRadius: '4px',
+ outline: 'none',
+ resize: 'vertical',
+ fontFamily: 'Consolas, monospace',
+ boxSizing: 'border-box',
+ }}
+ />
+ </div>
+
+ <div style={{ display: 'flex', gap: '12px', justifyContent: 'flex-end' }}>
+ <button
+ onClick={() => {
+ setShowDeployDialog(false);
+ setWorkflowName('');
+ setWorkflowDescription('');
+ }}
+ style={{
+ backgroundColor: 'transparent',
+ color: '#a3a3a3',
+ border: '1px solid #404040',
+ padding: '8px 16px',
+ fontSize: '11px',
+ cursor: 'pointer',
+ borderRadius: '4px',
+ fontWeight: 'bold',
+ }}
+ >
+ CANCEL
+ </button>
+ <button
+ onClick={saveDraft}
+ style={{
+ backgroundColor: 'transparent',
+ color: '#f59e0b',
+ border: '1px solid #f59e0b',
+ padding: '8px 16px',
+ fontSize: '11px',
+ cursor: 'pointer',
+ borderRadius: '4px',
+ fontWeight: 'bold',
+ }}
+ >
+ SAVE AS DRAFT
+ </button>
+ <button
+ onClick={deployWorkflow}
+ style={{
+ backgroundColor: '#3b82f6',
+ color: 'white',
+ border: 'none',
+ padding: '8px 16px',
+ fontSize: '11px',
+ cursor: 'pointer',
+ borderRadius: '4px',
+ fontWeight: 'bold',
+ }}
+ >
+ DEPLOY & EXECUTE
+ </button>
+ </div>
+ </div>
</div>
- </div>
+ )}
+
+ {/* Results Modal */}
+ {showResultsModal && (
+ <ResultsModal
+ data={resultsData}
+ workflowName={resultsWorkflowName}
+ onClose={() => {
+ setShowResultsModal(false);
+ setResultsData(null);
+ setResultsWorkflowName('');
+ }}
+ />
+ )}
</div>
);
}
diff --git a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/BaseWidget.tsx b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/BaseWidget.tsx
index c65cbd2a3..2abc1147c 100644
--- a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/BaseWidget.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/BaseWidget.tsx
@@ -50,14 +50,20 @@ export const BaseWidget: React.FC<BaseWidgetProps> = ({
minHeight: '28px',
flexShrink: 0
}}>
- <div style={{
- color: headerColor,
- fontSize: '11px',
- fontWeight: 'bold',
- overflow: 'hidden',
- textOverflow: 'ellipsis',
- whiteSpace: 'nowrap'
- }}>
+ <div
+ className="widget-drag-handle"
+ style={{
+ color: headerColor,
+ fontSize: '11px',
+ fontWeight: 'bold',
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ cursor: 'move',
+ flex: 1,
+ userSelect: 'none'
+ }}
+ >
{title}
</div>
<div style={{ display: 'flex', gap: '4px', flexShrink: 0 }}>
diff --git a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/CommoditiesWidget.tsx b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/CommoditiesWidget.tsx
index 63e3c5f2f..1f7117cee 100644
--- a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/CommoditiesWidget.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/CommoditiesWidget.tsx
@@ -46,7 +46,7 @@ export const CommoditiesWidget: React.FC<CommoditiesWidgetProps> = ({ id, onRemo
useEffect(() => {
loadQuotes();
- const interval = setInterval(loadQuotes, 60000); // Refresh every minute
+ const interval = setInterval(loadQuotes, 10 * 60 * 1000); // Refresh every 10 minutes
return () => clearInterval(interval);
}, []);
diff --git a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/CryptoWidget.tsx b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/CryptoWidget.tsx
index e7d37b96a..c983a4038 100644
--- a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/CryptoWidget.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/CryptoWidget.tsx
@@ -35,7 +35,7 @@ export const CryptoWidget: React.FC<CryptoWidgetProps> = ({ id, onRemove }) => {
useEffect(() => {
loadQuotes();
- const interval = setInterval(loadQuotes, 30000); // Refresh every 30 seconds
+ const interval = setInterval(loadQuotes, 10 * 60 * 1000); // Refresh every 10 minutes
return () => clearInterval(interval);
}, []);
diff --git a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/ForexWidget.tsx b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/ForexWidget.tsx
index 560f9d98b..690c17327 100644
--- a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/ForexWidget.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/ForexWidget.tsx
@@ -46,7 +46,7 @@ export const ForexWidget: React.FC<ForexWidgetProps> = ({ id, onRemove }) => {
useEffect(() => {
loadQuotes();
- const interval = setInterval(loadQuotes, 30000); // Refresh every 30 seconds
+ const interval = setInterval(loadQuotes, 10 * 60 * 1000); // Refresh every 10 minutes
return () => clearInterval(interval);
}, []);
diff --git a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/ForumWidget.tsx b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/ForumWidget.tsx
index ba13ec625..9b3fcfa4a 100644
--- a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/ForumWidget.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/ForumWidget.tsx
@@ -41,13 +41,25 @@ export const ForumWidget: React.FC<ForumWidgetProps> = ({
setLoading(true);
setError(null);
try {
- const response = categoryId
- ? await ForumApiService.getPostsByCategory(categoryId, 'latest', limit)
- : await ForumApiService.getTrendingPosts(limit, 'week');
+ // Get API credentials from session/localStorage
+ const apiKey = localStorage.getItem('fincept_api_key') || undefined;
+ const deviceId = localStorage.getItem('fincept_device_id') || undefined;
+
+ console.log('[ForumWidget] Loading posts with:', { categoryId, limit, apiKey: !!apiKey, deviceId: !!deviceId });
+
+ // If no categoryId is provided, default to category 1 (like ForumTab does)
+ // The backend requires a category ID, there is no "get all posts" endpoint
+ const targetCategoryId = categoryId || 1;
+
+ const response = await ForumApiService.getPostsByCategory(targetCategoryId, 'latest', limit, apiKey, deviceId);
+
+ console.log('[ForumWidget] Response:', response);
if (response.success) {
// Handle both response formats
const postsData = (response.data as any)?.data?.posts || (response.data as any)?.posts || [];
+ console.log('[ForumWidget] Posts data:', postsData);
+
const formattedPosts = postsData.map((post: any) => ({
id: post.post_uuid,
title: post.title,
@@ -57,11 +69,15 @@ export const ForumWidget: React.FC<ForumWidgetProps> = ({
replies: post.reply_count || 0,
time: new Date(post.created_at).toLocaleTimeString('en-US', { hour12: false, hour: '2-digit', minute: '2-digit' })
}));
+
+ console.log('[ForumWidget] Formatted posts:', formattedPosts);
setPosts(formattedPosts);
} else {
- setError(response.error || 'Failed to load forum posts');
+ console.error('[ForumWidget] Error response:', response);
+ setError(response.error || `HTTP ${response.status_code || 'error'}`);
}
} catch (err) {
+ console.error('[ForumWidget] Exception:', err);
setError(err instanceof Error ? err.message : 'Failed to load forum posts');
} finally {
setLoading(false);
@@ -70,7 +86,7 @@ export const ForumWidget: React.FC<ForumWidgetProps> = ({
useEffect(() => {
loadPosts();
- const interval = setInterval(loadPosts, 2 * 60 * 1000); // Refresh every 2 minutes
+ const interval = setInterval(loadPosts, 10 * 60 * 1000); // Refresh every 10 minutes
return () => clearInterval(interval);
}, [categoryId, limit]);
diff --git a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/GlobalIndicesWidget.tsx b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/GlobalIndicesWidget.tsx
index 496a3def3..675ac1fb8 100644
--- a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/GlobalIndicesWidget.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/GlobalIndicesWidget.tsx
@@ -64,7 +64,7 @@ export const GlobalIndicesWidget: React.FC<GlobalIndicesWidgetProps> = ({ id, on
useEffect(() => {
loadQuotes();
- const interval = setInterval(loadQuotes, 60000); // Refresh every minute
+ const interval = setInterval(loadQuotes, 10 * 60 * 1000); // Refresh every 10 minutes
return () => clearInterval(interval);
}, []);
diff --git a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/MaritimeWidget.tsx b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/MaritimeWidget.tsx
index 4dd747169..46c1358c9 100644
--- a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/MaritimeWidget.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/MaritimeWidget.tsx
@@ -43,7 +43,7 @@ export const MaritimeWidget: React.FC<MaritimeWidgetProps> = ({ id, onRemove, on
...prev,
active_vessels: prev.active_vessels + Math.floor(Math.random() * 10 - 5)
}));
- }, 5000);
+ }, 10 * 60 * 1000); // Refresh every 10 minutes
return () => clearInterval(interval);
}, []);
diff --git a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/MarketDataWidget.tsx b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/MarketDataWidget.tsx
index 1ad5b7181..6c2c4a88e 100644
--- a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/MarketDataWidget.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/MarketDataWidget.tsx
@@ -39,7 +39,7 @@ export const MarketDataWidget: React.FC<MarketDataWidgetProps> = ({
useEffect(() => {
loadQuotes();
- const interval = setInterval(loadQuotes, 60000); // Refresh every minute
+ const interval = setInterval(loadQuotes, 10 * 60 * 1000); // Refresh every 10 minutes
return () => clearInterval(interval);
}, [tickers.join(',')]);
diff --git a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/NewsWidget.tsx b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/NewsWidget.tsx
index ae70f72c3..416f7653b 100644
--- a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/NewsWidget.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/NewsWidget.tsx
@@ -44,7 +44,7 @@ export const NewsWidget: React.FC<NewsWidgetProps> = ({
useEffect(() => {
loadNews();
- const interval = setInterval(loadNews, 5 * 60 * 1000); // Refresh every 5 minutes
+ const interval = setInterval(loadNews, 10 * 60 * 1000); // Refresh every 10 minutes
return () => clearInterval(interval);
}, [category, limit]);
diff --git a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/WatchlistWidget.tsx b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/WatchlistWidget.tsx
index cf3a5fc29..b8a6054f8 100644
--- a/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/WatchlistWidget.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/dashboard/widgets/WatchlistWidget.tsx
@@ -47,7 +47,7 @@ export const WatchlistWidget: React.FC<WatchlistWidgetProps> = ({
useEffect(() => {
loadStocks();
- const interval = setInterval(loadStocks, 60000); // Refresh every minute
+ const interval = setInterval(loadStocks, 10 * 60 * 1000); // Refresh every 10 minutes
return () => clearInterval(interval);
}, [watchlistId]);
diff --git a/fincept-terminal-desktop/src/components/tabs/data-sources/DataSourcesTab.tsx b/fincept-terminal-desktop/src/components/tabs/data-sources/DataSourcesTab.tsx
index 47bd78856..b57db3a9d 100644
--- a/fincept-terminal-desktop/src/components/tabs/data-sources/DataSourcesTab.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/data-sources/DataSourcesTab.tsx
@@ -18,13 +18,21 @@ import {
} from 'lucide-react';
import { DATA_SOURCE_CONFIGS } from './dataSourceConfigs';
import { DataSourceConfig, DataSourceConnection, DataSourceCategory } from './types';
-import { testConnection, hasAdapter } from './adapters';
+import { hasAdapter } from './adapters';
+import { useDataSources } from '../../../contexts/DataSourceContext';
export default function DataSourcesTab() {
+ const {
+ connections,
+ addConnection,
+ updateConnection,
+ deleteConnection,
+ testConnection,
+ } = useDataSources();
+
const [view, setView] = useState<'gallery' | 'connections'>('gallery');
const [searchTerm, setSearchTerm] = useState('');
const [selectedCategory, setSelectedCategory] = useState<DataSourceCategory | 'all'>('all');
- const [connections, setConnections] = useState<DataSourceConnection[]>([]);
const [showConfigModal, setShowConfigModal] = useState(false);
const [selectedDataSource, setSelectedDataSource] = useState<DataSourceConfig | null>(null);
const [configFormData, setConfigFormData] = useState<Record<string, any>>({});
@@ -92,18 +100,12 @@ export default function DataSourcesTab() {
if (editingConnection) {
// Update existing connection
- const updatedConnection: DataSourceConnection = {
- ...editingConnection,
+ updateConnection(editingConnection.id, {
name: configFormData.name || editingConnection.name,
config: { ...configFormData },
- updatedAt: new Date().toISOString(),
- };
+ });
- setConnections(
- connections.map((c) => (c.id === editingConnection.id ? updatedConnection : c))
- );
-
- console.log('Updated connection:', updatedConnection);
+ console.log('Updated connection:', editingConnection.id);
} else {
// Create new connection
const newConnection: DataSourceConnection = {
@@ -117,7 +119,7 @@ export default function DataSourcesTab() {
updatedAt: new Date().toISOString(),
};
- setConnections([...connections, newConnection]);
+ addConnection(newConnection);
console.log('Saved connection:', newConnection);
}
@@ -126,14 +128,11 @@ export default function DataSourcesTab() {
setConfigFormData({});
setEditingConnection(null);
setView('connections');
-
- // TODO: Save to DuckDB
};
// Handle delete connection
- const handleDeleteConnection = (id: string) => {
- setConnections(connections.filter((c) => c.id !== id));
- // TODO: Delete from DuckDB
+ const handleDeleteConnectionClick = (id: string) => {
+ deleteConnection(id);
};
// Handle test connection
@@ -141,48 +140,13 @@ export default function DataSourcesTab() {
console.log('Testing connection:', connection);
// Update status to testing
- setConnections(connections.map((c) =>
- c.id === connection.id
- ? { ...c, status: 'testing' as const, lastTested: new Date().toISOString() }
- : c
- ));
-
- try {
- // Use the real adapter to test the connection
- const result = await testConnection(connection);
-
- // Update connection with test result
- setConnections(connections.map((c) =>
- c.id === connection.id
- ? {
- ...c,
- status: result.success ? ('connected' as const) : ('error' as const),
- errorMessage: result.success ? undefined : result.message,
- lastTested: new Date().toISOString(),
- }
- : c
- ));
+ updateConnection(connection.id, {
+ status: 'testing',
+ lastTested: new Date().toISOString(),
+ });
- // Log the result
- if (result.success) {
- console.log('Connection test successful:', result);
- } else {
- console.error('Connection test failed:', result.message);
- }
- } catch (error) {
- // Handle unexpected errors
- console.error('Connection test error:', error);
- setConnections(connections.map((c) =>
- c.id === connection.id
- ? {
- ...c,
- status: 'error' as const,
- errorMessage: error instanceof Error ? error.message : 'Unknown error occurred',
- lastTested: new Date().toISOString(),
- }
- : c
- ));
- }
+ // Test connection (context will handle status updates)
+ await testConnection(connection);
};
return (
@@ -583,7 +547,7 @@ export default function DataSourcesTab() {
EDIT
</button>
<button
- onClick={() => handleDeleteConnection(connection.id)}
+ onClick={() => handleDeleteConnectionClick(connection.id)}
style={{
backgroundColor: 'transparent',
color: '#ef4444',
diff --git a/fincept-terminal-desktop/src/components/tabs/mcp/index.tsx b/fincept-terminal-desktop/src/components/tabs/mcp/index.tsx
index fffa16b45..afc093319 100644
--- a/fincept-terminal-desktop/src/components/tabs/mcp/index.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/mcp/index.tsx
@@ -31,11 +31,16 @@ const MCPTab: React.FC = () => {
useEffect(() => {
const initializeServers = async () => {
try {
- await mcpManager.startAutoStartServers();
+ // Ensure database is initialized first
+ await sqliteService.initialize();
+
+ // Don't auto-start here - DashboardScreen already handles it
+ // Just load the data
+ await loadData();
} catch (error) {
- console.error('Failed to auto-start servers:', error);
+ console.error('Failed to initialize MCP tab:', error);
+ setStatusMessage('Initialization failed');
}
- loadData();
};
initializeServers();
diff --git a/fincept-terminal-desktop/src/services/llmApi.ts b/fincept-terminal-desktop/src/services/llmApi.ts
index 4f8637db5..8409cf980 100644
--- a/fincept-terminal-desktop/src/services/llmApi.ts
+++ b/fincept-terminal-desktop/src/services/llmApi.ts
@@ -223,6 +223,212 @@ class LLMApiService {
}
}
+ // Gemini with function calling
+ private async callGeminiWithTools(
+ userMessage: string,
+ conversationHistory: ChatMessage[],
+ tools: Array<any>,
+ config: LLMConfig,
+ onStream?: StreamCallback,
+ onToolCall?: (toolName: string, args: any, result?: any) => void
+ ): Promise<LLMResponse> {
+ const url = `https://generativelanguage.googleapis.com/v1beta/models/${config.model}:generateContent?key=${config.apiKey}`;
+
+ // Convert MCP tools to Gemini function format
+ const functionDeclarations = tools.map(tool => {
+ // Clean schema for Gemini - remove $schema and additionalProperties
+ const cleanSchema = tool.inputSchema ? { ...tool.inputSchema } : { type: 'object', properties: {} };
+ delete cleanSchema.$schema;
+ delete cleanSchema.additionalProperties;
+
+ return {
+ name: `${tool.serverId}__${tool.name}`,
+ description: tool.description || '',
+ parameters: cleanSchema
+ };
+ });
+
+ console.log('[MCP] Sending tools to Gemini:', functionDeclarations.length, 'tools');
+
+ // Convert messages to Gemini format
+ const systemPrompt = conversationHistory.find(m => m.role === 'system')?.content || config.systemPrompt || '';
+ const conversationMessages = conversationHistory.filter(m => m.role !== 'system');
+
+ const contents = [
+ ...conversationMessages.map(msg => ({
+ role: msg.role === 'assistant' ? 'model' : 'user',
+ parts: [{ text: msg.content }]
+ })),
+ {
+ role: 'user',
+ parts: [{ text: userMessage }]
+ }
+ ];
+
+ try {
+ // First call - with tools
+ let response = await fetch(url, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ contents,
+ systemInstruction: systemPrompt ? { parts: [{ text: systemPrompt }] } : undefined,
+ tools: [{ functionDeclarations }],
+ generationConfig: {
+ temperature: config.temperature,
+ maxOutputTokens: config.maxTokens
+ }
+ })
+ });
+
+ if (!response.ok) {
+ const error = await response.json();
+ throw new Error(error.error?.message || `Gemini API error: ${response.status}`);
+ }
+
+ let data = await response.json();
+ const candidate = data.candidates?.[0];
+
+ // Track tool result content for fallback
+ let resultContent = '';
+
+ // Check if Gemini wants to call functions
+ const functionCall = candidate?.content?.parts?.find((part: any) => part.functionCall);
+
+ if (functionCall) {
+ console.log('[MCP] Gemini requested function call:', functionCall.functionCall.name);
+
+ const toolName = functionCall.functionCall.name;
+ const toolArgs = functionCall.functionCall.args || {};
+
+ // Notify UI
+ if (onToolCall) {
+ onToolCall(toolName, toolArgs);
+ }
+
+ // Execute tool
+ const { mcpManager } = await import('./mcpManager');
+ const [serverId, actualToolName] = toolName.includes('__')
+ ? toolName.split('__')
+ : [toolName, toolName];
+
+ let toolResult: any;
+ try {
+ toolResult = await mcpManager.callTool(serverId, actualToolName, toolArgs);
+
+ // Format result
+ if (toolResult.content && Array.isArray(toolResult.content)) {
+ resultContent = toolResult.content
+ .map((c: any) => {
+ if (c.text) return c.text;
+ if (c.data) return typeof c.data === 'string' ? c.data : JSON.stringify(c.data, null, 2);
+ return JSON.stringify(c, null, 2);
+ })
+ .join('\n\n');
+ } else if (toolResult.content) {
+ resultContent = typeof toolResult.content === 'string'
+ ? toolResult.content
+ : JSON.stringify(toolResult.content, null, 2);
+ } else {
+ resultContent = JSON.stringify(toolResult, null, 2);
+ }
+
+ // Notify UI of result
+ if (onToolCall) {
+ onToolCall(toolName, toolArgs, toolResult);
+ }
+
+ console.log('[MCP] Tool result:', resultContent);
+
+ // Second call with function response
+ contents.push({
+ role: 'model',
+ parts: [{ functionCall: functionCall.functionCall } as any]
+ });
+
+ contents.push({
+ role: 'user',
+ parts: [{
+ functionResponse: {
+ name: toolName,
+ response: { result: resultContent }
+ }
+ } as any]
+ });
+
+ } catch (error) {
+ console.error('[MCP] Tool execution error:', error);
+ contents.push({
+ role: 'user',
+ parts: [{
+ functionResponse: {
+ name: toolName,
+ response: { error: error instanceof Error ? error.message : 'Unknown error' }
+ }
+ } as any]
+ });
+ }
+
+ // Get final response
+ response = await fetch(url, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ contents,
+ systemInstruction: systemPrompt ? { parts: [{ text: systemPrompt }] } : undefined,
+ generationConfig: {
+ temperature: config.temperature,
+ maxOutputTokens: config.maxTokens
+ }
+ })
+ });
+
+ if (!response.ok) {
+ const error = await response.json();
+ throw new Error(error.error?.message || `Gemini API error: ${response.status}`);
+ }
+
+ data = await response.json();
+ }
+
+ // Extract final content
+ let finalContent = data.candidates?.[0]?.content?.parts?.[0]?.text || '';
+
+ // If Gemini didn't generate text after tool call, return the tool result
+ if (!finalContent && resultContent) {
+ finalContent = resultContent;
+ }
+
+ console.log('[MCP] Gemini final response length:', finalContent.length);
+
+ // Signal completion to UI
+ if (onStream && finalContent) {
+ onStream(finalContent, false);
+ onStream('', true);
+ }
+
+ return {
+ content: finalContent,
+ usage: {
+ promptTokens: data.usageMetadata?.promptTokenCount || 0,
+ completionTokens: data.usageMetadata?.candidatesTokenCount || 0,
+ totalTokens: data.usageMetadata?.totalTokenCount || 0
+ }
+ };
+
+ } catch (error) {
+ console.error('Gemini function calling error:', error);
+ return {
+ content: '',
+ error: error instanceof Error ? error.message : 'Unknown error'
+ };
+ }
+ }
+
// DeepSeek API (OpenAI-compatible)
private async callDeepSeek(
messages: ChatMessage[],
@@ -473,9 +679,11 @@ class LLMApiService {
};
}
- // Only OpenAI and OpenRouter support function calling well
- if (activeConfig.provider !== 'openai' && activeConfig.provider !== 'openrouter') {
- // Fall back to regular chat for other providers
+ // OpenAI, OpenRouter, Gemini, and DeepSeek support function calling
+ const supportsTools = ['openai', 'openrouter', 'gemini', 'deepseek'].includes(activeConfig.provider);
+
+ if (!supportsTools) {
+ // Fall back to regular chat for other providers (Ollama, etc.)
return this.chat(userMessage, conversationHistory, onStream);
}
@@ -496,7 +704,12 @@ class LLMApiService {
systemPrompt: globalSettings.system_prompt
};
- // Build messages
+ // Handle Gemini separately since it has different API format
+ if (activeConfig.provider === 'gemini') {
+ return this.callGeminiWithTools(userMessage, conversationHistory, tools, config, onStream, onToolCall);
+ }
+
+ // Build messages for OpenAI/OpenRouter/DeepSeek (all use OpenAI format)
let messages: any[] = [
{ role: 'system', content: config.systemPrompt || 'You are a helpful assistant with access to tools. Use them when needed.' },
...conversationHistory.map(msg => ({ role: msg.role, content: msg.content })),
@@ -514,7 +727,22 @@ class LLMApiService {
}
}));
- const url = `${config.baseUrl || 'https://api.openai.com/v1'}/chat/completions`;
+ console.log('[MCP] Sending tools to API:', functions.length, 'tools');
+ console.log('[MCP] Tool names:', functions.map(f => f.function.name));
+
+ // Determine base URL based on provider
+ let baseUrl = config.baseUrl;
+ if (!baseUrl) {
+ if (activeConfig.provider === 'deepseek') {
+ baseUrl = 'https://api.deepseek.com';
+ } else if (activeConfig.provider === 'openrouter') {
+ baseUrl = 'https://openrouter.ai/api/v1';
+ } else {
+ baseUrl = 'https://api.openai.com/v1';
+ }
+ }
+
+ const url = `${baseUrl}/chat/completions`;
// First call - with tools
let response = await fetch(url, {
@@ -547,6 +775,8 @@ class LLMApiService {
// Check if AI wants to call tools
if (assistantMessage.tool_calls && assistantMessage.tool_calls.length > 0) {
+ console.log('[MCP] AI requested tool calls:', assistantMessage.tool_calls.length);
+
// Add assistant's tool call message to conversation
messages.push(assistantMessage);
@@ -574,10 +804,23 @@ class LLMApiService {
const toolResult = await mcpManager.callTool(serverId, actualToolName, toolArgs);
- // Format result for OpenAI
- const resultContent = toolResult.content
- .map((c: any) => c.text || JSON.stringify(c.data || c))
- .join('\n');
+ // Format result for OpenAI - Better formatting
+ let resultContent = '';
+ if (toolResult.content && Array.isArray(toolResult.content)) {
+ resultContent = toolResult.content
+ .map((c: any) => {
+ if (c.text) return c.text;
+ if (c.data) return typeof c.data === 'string' ? c.data : JSON.stringify(c.data, null, 2);
+ return JSON.stringify(c, null, 2);
+ })
+ .join('\n\n');
+ } else if (toolResult.content) {
+ resultContent = typeof toolResult.content === 'string'
+ ? toolResult.content
+ : JSON.stringify(toolResult.content, null, 2);
+ } else {
+ resultContent = JSON.stringify(toolResult, null, 2);
+ }
// Add tool result to conversation
messages.push({
@@ -630,8 +873,12 @@ class LLMApiService {
assistantMessage = data.choices[0].message;
}
+ // Ensure content exists
+ const finalContent = assistantMessage.content || '';
+ console.log('[MCP] Final response length:', finalContent.length);
+
return {
- content: assistantMessage.content || '',
+ content: finalContent,
usage: {
promptTokens: data.usage?.prompt_tokens || 0,
completionTokens: data.usage?.completion_tokens || 0,
diff --git a/fincept-terminal-desktop/src/services/mcpManager.ts b/fincept-terminal-desktop/src/services/mcpManager.ts
index 4601fa687..7bc7b48b8 100644
--- a/fincept-terminal-desktop/src/services/mcpManager.ts
+++ b/fincept-terminal-desktop/src/services/mcpManager.ts
@@ -214,11 +214,15 @@ class MCPManager {
const serversWithStats = await Promise.all(
servers.map(async (server) => {
const stats = await sqliteService.getMCPServerStats(server.id);
+ // Check actual status by verifying client exists and is connected
+ const client = this.clients.get(server.id);
+ const actualStatus = client && client.isConnected() ? 'running' : 'stopped';
+
return {
...server,
args: JSON.parse(server.args),
env: server.env ? JSON.parse(server.env) : undefined,
- status: (server.status as 'running' | 'stopped' | 'error'),
+ status: actualStatus as 'running' | 'stopped' | 'error',
toolCount: stats.toolCount,
callsToday: stats.callsToday,
lastUsed: stats.lastUsed || undefined
diff --git a/fincept-terminal-desktop/src/services/sqliteService.ts b/fincept-terminal-desktop/src/services/sqliteService.ts
index f4ff69084..5251ea660 100644
--- a/fincept-terminal-desktop/src/services/sqliteService.ts
+++ b/fincept-terminal-desktop/src/services/sqliteService.ts
@@ -393,6 +393,22 @@ class SQLiteService {
)
`);
+ // Workflows table
+ await this.db.execute(`
+ CREATE TABLE IF NOT EXISTS workflows (
+ id TEXT PRIMARY KEY,
+ name TEXT NOT NULL,
+ description TEXT,
+ status TEXT CHECK(status IN ('draft', 'running', 'completed', 'failed')),
+ nodes TEXT NOT NULL,
+ edges TEXT NOT NULL,
+ results TEXT,
+ created_at INTEGER,
+ updated_at INTEGER,
+ executed_at INTEGER
+ )
+ `);
+
// Create indexes
await this.db.execute(`CREATE INDEX IF NOT EXISTS idx_credentials_service ON credentials(service_name)`);
await this.db.execute(`CREATE INDEX IF NOT EXISTS idx_settings_category ON settings(category)`);
@@ -415,6 +431,8 @@ class SQLiteService {
await this.db.execute(`CREATE INDEX IF NOT EXISTS idx_data_sources_type ON data_sources(type)`);
await this.db.execute(`CREATE INDEX IF NOT EXISTS idx_data_sources_provider ON data_sources(provider)`);
await this.db.execute(`CREATE INDEX IF NOT EXISTS idx_data_sources_enabled ON data_sources(enabled)`);
+ await this.db.execute(`CREATE INDEX IF NOT EXISTS idx_workflows_status ON workflows(status)`);
+ await this.db.execute(`CREATE INDEX IF NOT EXISTS idx_workflows_updated ON workflows(updated_at DESC)`);
}
private async seedDefaultSettings(): Promise<void> {
@@ -1038,11 +1056,11 @@ class SQLiteService {
// Delete existing tools for this server
await this.db.execute('DELETE FROM mcp_tools WHERE server_id = $1', [serverId]);
- // Insert new tools
+ // Insert new tools (use INSERT OR REPLACE to handle React Strict Mode double mounting)
for (const tool of tools) {
const toolId = `${serverId}__${tool.name}`;
await this.db.execute(
- `INSERT INTO mcp_tools (id, server_id, name, description, input_schema)
+ `INSERT OR REPLACE INTO mcp_tools (id, server_id, name, description, input_schema)
VALUES ($1, $2, $3, $4, $5)`,
[toolId, serverId, tool.name, tool.description || '', JSON.stringify(tool.inputSchema)]
);
@@ -1645,6 +1663,129 @@ class SQLiteService {
enabled: s.enabled === 1
}));
}
+
+ // ==================== WORKFLOW MANAGEMENT ====================
+
+ /**
+ * Save workflow
+ */
+ async saveWorkflow(workflow: {
+ id: string;
+ name: string;
+ description?: string;
+ status: string;
+ nodes: any[];
+ edges: any[];
+ results?: any;
+ created_at: number;
+ updated_at: number;
+ executed_at?: number;
+ }): Promise<void> {
+ if (!this.db) throw new Error('Database not initialized');
+
+ await this.db.execute(
+ `INSERT OR REPLACE INTO workflows (id, name, description, status, nodes, edges, results, created_at, updated_at, executed_at)
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`,
+ [
+ workflow.id,
+ workflow.name,
+ workflow.description || null,
+ workflow.status,
+ JSON.stringify(workflow.nodes),
+ JSON.stringify(workflow.edges),
+ workflow.results ? JSON.stringify(workflow.results) : null,
+ workflow.created_at,
+ workflow.updated_at,
+ workflow.executed_at || null
+ ]
+ );
+ }
+
+ /**
+ * Get workflows with optional status filter
+ */
+ async getWorkflows(status?: string): Promise<Array<{
+ id: string;
+ name: string;
+ description: string | null;
+ status: string;
+ nodes: any[];
+ edges: any[];
+ results: any;
+ created_at: number;
+ updated_at: number;
+ executed_at: number | null;
+ }>> {
+ if (!this.db) throw new Error('Database not initialized');
+
+ const sql = status
+ ? 'SELECT * FROM workflows WHERE status = $1 ORDER BY updated_at DESC'
+ : 'SELECT * FROM workflows ORDER BY updated_at DESC';
+
+ const params = status ? [status] : [];
+
+ const workflows = await this.db.select<Array<any>>(sql, params);
+
+ return workflows.map(w => ({
+ ...w,
+ nodes: JSON.parse(w.nodes),
+ edges: JSON.parse(w.edges),
+ results: w.results ? JSON.parse(w.results) : null
+ }));
+ }
+
+ /**
+ * Get single workflow by ID
+ */
+ async getWorkflow(id: string): Promise<{
+ id: string;
+ name: string;
+ description: string | null;
+ status: string;
+ nodes: any[];
+ edges: any[];
+ results: any;
+ created_at: number;
+ updated_at: number;
+ executed_at: number | null;
+ } | null> {
+ if (!this.db) throw new Error('Database not initialized');
+
+ const workflows = await this.db.select<Array<any>>(
+ 'SELECT * FROM workflows WHERE id = $1',
+ [id]
+ );
+
+ if (workflows.length === 0) return null;
+
+ return {
+ ...workflows[0],
+ nodes: JSON.parse(workflows[0].nodes),
+ edges: JSON.parse(workflows[0].edges),
+ results: workflows[0].results ? JSON.parse(workflows[0].results) : null
+ };
+ }
+
+ /**
+ * Update workflow status and results
+ */
+ async updateWorkflowStatus(id: string, status: string, results?: any): Promise<void> {
+ if (!this.db) throw new Error('Database not initialized');
+
+ await this.db.execute(
+ `UPDATE workflows SET status = $1, results = $2, updated_at = $3 WHERE id = $4`,
+ [status, results ? JSON.stringify(results) : null, Date.now(), id]
+ );
+ }
+
+ /**
+ * Delete workflow
+ */
+ async deleteWorkflow(id: string): Promise<void> {
+ if (!this.db) throw new Error('Database not initialized');
+
+ await this.db.execute('DELETE FROM workflows WHERE id = $1', [id]);
+ }
}
// Singleton instance