Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

Merge remote-tracking branch 'origin/main' into thinhlpg/393-otel-export

thinhlpg4088c8b4971a
diff --cc src-tauri/src/core/agent/global_config.rs
index d5d3731cc,15f97cb14..f5ab526d2
--- a/src-tauri/src/core/agent/global_config.rs
+++ b/src-tauri/src/core/agent/global_config.rs
@@@ -56,13 -56,13 +56,20 @@@ const GLOBAL_CONFIG_TEMPLATE: &str = r#
# # Defaults to 👋; set "" for the plain
# # throbber if your terminal draws tofu
#
+# [telemetry] # opt-in OpenTelemetry (OTLP) export of
+# enabled = true # usage metrics and events to YOUR
+# # collector (OTEL_EXPORTER_OTLP_* env);
+# # off by default. A project's agent.toml
+# # [telemetry] and JAN_AGENT_ENABLE_TELEMETRY
+# # win over this
+#
+ # [context]
+ # fallback_files = ["AGENTS.md"] # instructions files read where a folder
+ # # has no JAN.md (JAN.md always wins).
+ # # Default ["AGENTS.md"]; add "CLAUDE.md"
+ # # to opt in; [] reads JAN.md only. A
+ # # project's agent.toml [context] wins
+ #
# [providers.my-provider]
# api_key = "sk-..."
# base_url = "https://api.example.com/v1"
@@@ -160,29 -160,21 +167,40 @@@ struct GlobalConfigToml
/// but a human appending to the file would not.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
hooks: Vec<tauri_plugin_agent_tools::tools::hooks::HookEntry>,
+ /// `[telemetry]` -- opt-in OTLP export (`core::agent::otel`). A table, so
+ /// declared after the plain values and before `providers`.
+ #[serde(default, skip_serializing_if = "TelemetrySection::is_empty")]
+ telemetry: TelemetrySection,
+ /// `[context]` -- the user-wide default for which instructions files are
+ /// read where a directory has no `JAN.md`. A project's own `[context]`
+ /// wins. See `project::context_fallback_files`.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ context: Option<GlobalContextSection>,
#[serde(default)]
providers: HashMap<String, GlobalProviderEntry>,
}
+/// `[telemetry]` in `~/.jan/config.toml` or a project's `agent.toml`. Only the
+/// switch lives here: where the data goes is the standard `OTEL_*` env, so one
+/// collector setup serves every OpenTelemetry-speaking tool unchanged.
+#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq)]
+pub(crate) struct TelemetrySection {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub enabled: Option<bool>,
+}
+
+impl TelemetrySection {
+ fn is_empty(&self) -> bool {
+ self.enabled.is_none()
+ }
+}
+
+ #[derive(Debug, Clone, Default, Deserialize, Serialize)]
+ struct GlobalContextSection {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ fallback_files: Option<Vec<String>>,
+ }
+
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
struct GlobalProviderEntry {
#[serde(default, skip_serializing_if = "Option::is_none")]
diff --cc src-tauri/src/core/agent/project.rs
index 6d237bfda,80942c5d2..156decbb1
--- a/src-tauri/src/core/agent/project.rs
+++ b/src-tauri/src/core/agent/project.rs
@@@ -30,11 -30,8 +30,13 @@@ pub(crate) struct AgentToml
pub skills: SkillsSection,
#[serde(default)]
pub plugins: PluginsSection,
+ /// `[telemetry]`: opt-in OTLP export. Wins over the global setting.
+ /// CLI-only: the desktop doesn't export telemetry yet.
+ #[cfg(feature = "cli")]
+ #[serde(default)]
+ pub telemetry: crate::core::agent::global_config::TelemetrySection,
+ #[serde(default)]
+ pub context: ContextSection,
/// `[[hooks]]` -- lifecycle commands this project runs around tool calls,
/// prompts, sessions and compactions. An array of tables rather than a
/// `[hooks]` map because several hooks may share one event.