@latitude-data/openclaw-telemetry 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,157 @@
1
+ # GNU LESSER GENERAL PUBLIC LICENSE
2
+
3
+ Version 3, 29 June 2007
4
+
5
+ Copyright (C) 2007 Free Software Foundation, Inc.
6
+ <https://fsf.org/>
7
+
8
+ Everyone is permitted to copy and distribute verbatim copies of this
9
+ license document, but changing it is not allowed.
10
+
11
+ This version of the GNU Lesser General Public License incorporates the
12
+ terms and conditions of version 3 of the GNU General Public License,
13
+ supplemented by the additional permissions listed below.
14
+
15
+ ## 0. Additional Definitions.
16
+
17
+ As used herein, "this License" refers to version 3 of the GNU Lesser
18
+ General Public License, and the "GNU GPL" refers to version 3 of the
19
+ GNU General Public License.
20
+
21
+ "The Library" refers to a covered work governed by this License, other
22
+ than an Application or a Combined Work as defined below.
23
+
24
+ An "Application" is any work that makes use of an interface provided
25
+ by the Library, but which is not otherwise based on the Library.
26
+ Defining a subclass of a class defined by the Library is deemed a mode
27
+ of using an interface provided by the Library.
28
+
29
+ A "Combined Work" is a work produced by combining or linking an
30
+ Application with the Library. The particular version of the Library
31
+ with which the Combined Work was made is also called the "Linked
32
+ Version".
33
+
34
+ The "Minimal Corresponding Source" for a Combined Work means the
35
+ Corresponding Source for the Combined Work, excluding any source code
36
+ for portions of the Combined Work that, considered in isolation, are
37
+ based on the Application, and not on the Linked Version.
38
+
39
+ The "Corresponding Application Code" for a Combined Work means the
40
+ object code and/or source code for the Application, including any data
41
+ and utility programs needed for reproducing the Combined Work from the
42
+ Application, but excluding the System Libraries of the Combined Work.
43
+
44
+ ## 1. Exception to Section 3 of the GNU GPL.
45
+
46
+ You may convey a covered work under sections 3 and 4 of this License
47
+ without being bound by section 3 of the GNU GPL.
48
+
49
+ ## 2. Conveying Modified Versions.
50
+
51
+ If you modify a copy of the Library, and, in your modifications, a
52
+ facility refers to a function or data to be supplied by an Application
53
+ that uses the facility (other than as an argument passed when the
54
+ facility is invoked), then you may convey a copy of the modified
55
+ version:
56
+
57
+ - a) under this License, provided that you make a good faith effort
58
+ to ensure that, in the event an Application does not supply the
59
+ function or data, the facility still operates, and performs
60
+ whatever part of its purpose remains meaningful, or
61
+ - b) under the GNU GPL, with none of the additional permissions of
62
+ this License applicable to that copy.
63
+
64
+ ## 3. Object Code Incorporating Material from Library Header Files.
65
+
66
+ The object code form of an Application may incorporate material from a
67
+ header file that is part of the Library. You may convey such object
68
+ code under terms of your choice, provided that, if the incorporated
69
+ material is not limited to numerical parameters, data structure
70
+ layouts and accessors, or small macros, inline functions and templates
71
+ (ten or fewer lines in length), you do both of the following:
72
+
73
+ - a) Give prominent notice with each copy of the object code that
74
+ the Library is used in it and that the Library and its use are
75
+ covered by this License.
76
+ - b) Accompany the object code with a copy of the GNU GPL and this
77
+ license document.
78
+
79
+ ## 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that, taken
82
+ together, effectively do not restrict modification of the portions of
83
+ the Library contained in the Combined Work and reverse engineering for
84
+ debugging such modifications, if you also do each of the following:
85
+
86
+ - a) Give prominent notice with each copy of the Combined Work that
87
+ the Library is used in it and that the Library and its use are
88
+ covered by this License.
89
+ - b) Accompany the Combined Work with a copy of the GNU GPL and this
90
+ license document.
91
+ - c) For a Combined Work that displays copyright notices during
92
+ execution, include the copyright notice for the Library among
93
+ these notices, as well as a reference directing the user to the
94
+ copies of the GNU GPL and this license document.
95
+ - d) Do one of the following:
96
+ - 0) Convey the Minimal Corresponding Source under the terms of
97
+ this License, and the Corresponding Application Code in a form
98
+ suitable for, and under terms that permit, the user to
99
+ recombine or relink the Application with a modified version of
100
+ the Linked Version to produce a modified Combined Work, in the
101
+ manner specified by section 6 of the GNU GPL for conveying
102
+ Corresponding Source.
103
+ - 1) Use a suitable shared library mechanism for linking with
104
+ the Library. A suitable mechanism is one that (a) uses at run
105
+ time a copy of the Library already present on the user's
106
+ computer system, and (b) will operate properly with a modified
107
+ version of the Library that is interface-compatible with the
108
+ Linked Version.
109
+ - e) Provide Installation Information, but only if you would
110
+ otherwise be required to provide such information under section 6
111
+ of the GNU GPL, and only to the extent that such information is
112
+ necessary to install and execute a modified version of the
113
+ Combined Work produced by recombining or relinking the Application
114
+ with a modified version of the Linked Version. (If you use option
115
+ 4d0, the Installation Information must accompany the Minimal
116
+ Corresponding Source and Corresponding Application Code. If you
117
+ use option 4d1, you must provide the Installation Information in
118
+ the manner specified by section 6 of the GNU GPL for conveying
119
+ Corresponding Source.)
120
+
121
+ ## 5. Combined Libraries.
122
+
123
+ You may place library facilities that are a work based on the Library
124
+ side by side in a single library together with other library
125
+ facilities that are not Applications and are not covered by this
126
+ License, and convey such a combined library under terms of your
127
+ choice, if you do both of the following:
128
+
129
+ - a) Accompany the combined library with a copy of the same work
130
+ based on the Library, uncombined with any other library
131
+ facilities, conveyed under the terms of this License.
132
+ - b) Give prominent notice with the combined library that part of it
133
+ is a work based on the Library, and explaining where to find the
134
+ accompanying uncombined form of the same work.
135
+
136
+ ## 6. Revised Versions of the GNU Lesser General Public License.
137
+
138
+ The Free Software Foundation may publish revised and/or new versions
139
+ of the GNU Lesser General Public License from time to time. Such new
140
+ versions will be similar in spirit to the present version, but may
141
+ differ in detail to address new problems or concerns.
142
+
143
+ Each version is given a distinguishing version number. If the Library
144
+ as you received it specifies that a certain numbered version of the
145
+ GNU Lesser General Public License "or any later version" applies to
146
+ it, you have the option of following the terms and conditions either
147
+ of that published version or of any later version published by the
148
+ Free Software Foundation. If the Library as you received it does not
149
+ specify a version number of the GNU Lesser General Public License, you
150
+ may choose any version of the GNU Lesser General Public License ever
151
+ published by the Free Software Foundation.
152
+
153
+ If the Library as you received it specifies that a proxy can decide
154
+ whether future versions of the GNU Lesser General Public License shall
155
+ apply, that proxy's public statement of acceptance of any version is
156
+ permanent authorization for you to choose that version for the
157
+ Library.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # @latitude-data/openclaw-telemetry
2
+
3
+ OpenClaw plugin that streams every agent run to [Latitude](https://latitude.so) as OTLP traces. Full fidelity — exact system prompt, message history, assistant output, token usage, tool I/O, and the running agent's name on every span.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npx -y @latitude-data/openclaw-telemetry install
9
+ ```
10
+
11
+ The installer prompts for your Latitude API key and project slug, then writes a plugin entry to `~/.openclaw/openclaw.json` with `hooks.allowConversationAccess: true` so OpenClaw forwards raw conversation content to our handlers.
12
+
13
+ Restart the OpenClaw gateway after install:
14
+
15
+ ```bash
16
+ openclaw gateway restart
17
+ ```
18
+
19
+ That's it. Traces show up at `https://console.latitude.so/projects/<your-slug>`.
20
+
21
+ ### Install flags
22
+
23
+ | Flag | What it does |
24
+ | --- | --- |
25
+ | `--api-key=<key>` | Pass the API key instead of being prompted. |
26
+ | `--project=<slug>` | Pass the project slug instead of being prompted. |
27
+ | `--staging` | Target `https://staging.latitude.so` / `https://staging-ingest.latitude.so`. |
28
+ | `--dev` | Target `http://localhost:3000` / `http://localhost:3002`. |
29
+ | `--yes` / `--no-prompt` | Skip all prompts. Required for non-TTY / CI invocations. |
30
+
31
+ Re-running `install` is idempotent — existing values are preserved.
32
+
33
+ ## Uninstall
34
+
35
+ ```bash
36
+ npx -y @latitude-data/openclaw-telemetry uninstall
37
+ ```
38
+
39
+ Shows a plan, asks for confirmation, then removes the plugin entry and the `LATITUDE_*` env vars from `~/.openclaw/openclaw.json`. A backup is saved at `openclaw.json.latitude-bak`.
40
+
41
+ ## What gets sent
42
+
43
+ For each agent run, the plugin emits one trace with three span kinds:
44
+
45
+ - **`interaction`** — the agent run. Carries `openclaw.session.key`, `openclaw.agent.id`, `openclaw.agent.name`, aggregated token usage across all LLM calls, run duration, success/error status, and the first user prompt.
46
+ - **`llm_request`** — one per LLM call. Carries provider, request/response model, `gen_ai.system_instructions`, `gen_ai.input.messages` (full history + current prompt), `gen_ai.output.messages` (assistant text + tool_call parts), and full token usage (input/output/cache_read/cache_creation/total) — under both canonical `gen_ai.*` keys and legacy aliases.
47
+ - **`tool_execution`** — one per tool call. Canonical `gen_ai.tool.*` attributes: `name`, `call.id`, `call.arguments`, `call.result`. Failures set `error.type`, `error.message`, and OTel status code 2.
48
+
49
+ Every span carries `openclaw.agent.id` and `openclaw.agent.name`. Multi-agent OpenClaw setups (sub-agents) naturally produce spans tagged with the invoking agent's id, letting you filter and group by agent in the Latitude UI.
50
+
51
+ All spans share the run id and trace id so they group together.
52
+
53
+ ## How it works
54
+
55
+ OpenClaw ships typed plugin hooks that fire per-LLM-call with the complete payload (`src/plugins/hook-types.ts` in the OpenClaw source). We subscribe to:
56
+
57
+ - `llm_input` — full system prompt, prompt text, history messages, provider, model.
58
+ - `llm_output` — assistant text, last assistant message, full token usage (input/output/cacheRead/cacheWrite/total), resolved provider/model ref.
59
+ - `before_tool_call` / `after_tool_call` — tool name, arguments, result, error, duration.
60
+ - `agent_end` — run completion signal. This is when we build the OTLP trace and POST it.
61
+ - `session_start` — currently a no-op; reserved for future session-level metadata.
62
+
63
+ OpenClaw runs LLM hooks **fire-and-forget** (see [`src/plugins/hooks.ts`](https://github.com/openclaw/openclaw/blob/main/src/plugins/hooks.ts) — `runLlmInput`/`runLlmOutput` are documented as parallel, and the call site in [`src/agents/pi-embedded-runner/run/attempt.ts`](https://github.com/openclaw/openclaw/blob/main/src/agents/pi-embedded-runner/run/attempt.ts) wraps them with `void hookRunner.run*(...).catch(...)`). Our handlers can never slow down the agent loop.
64
+
65
+ **No runtime wrapping.** Unlike existing third-party OpenClaw observability plugins that try to monkey-patch `@mariozechner/pi-ai` (and run into jiti's CJS/ESM module isolation), we stay inside the supported plugin API. The hooks give us everything, at lower risk of breaking on OpenClaw updates.
66
+
67
+ ## Configuration reference
68
+
69
+ Everything the installer writes. You can edit `~/.openclaw/openclaw.json` directly if you want to tweak:
70
+
71
+ ### `env`
72
+
73
+ | Variable | Required | Default | Description |
74
+ | --- | --- | --- | --- |
75
+ | `LATITUDE_API_KEY` | yes | — | Bearer token for Latitude ingestion. |
76
+ | `LATITUDE_PROJECT` | yes | — | Slug of the project to route traces into. |
77
+ | `LATITUDE_BASE_URL` | no | `https://ingest.latitude.so` | Override ingest origin. Installer sets this only when you pass `--staging` or `--dev`. |
78
+ | `LATITUDE_OPENCLAW_ENABLED` | no | `1` | Set to `0` to pause the plugin without uninstalling. |
79
+ | `LATITUDE_DEBUG` | no | — | Set to `1` to log diagnostics to stderr. |
80
+
81
+ ### `plugins.entries`
82
+
83
+ ```json
84
+ {
85
+ "@latitude-data/openclaw-telemetry": {
86
+ "enabled": true,
87
+ "hooks": {
88
+ "allowConversationAccess": true
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ `allowConversationAccess` is load-bearing — OpenClaw scrubs payloads from `llm_input` / `llm_output` / `agent_end` for third-party plugins unless they opt in explicitly.
95
+
96
+ ### Manual installation
97
+
98
+ If the installer doesn't fit your setup, the equivalent `openclaw.json` is:
99
+
100
+ ```jsonc
101
+ {
102
+ "env": {
103
+ "LATITUDE_API_KEY": "lat_xxx",
104
+ "LATITUDE_PROJECT": "my-openclaw-project"
105
+ },
106
+ "plugins": {
107
+ "entries": {
108
+ "@latitude-data/openclaw-telemetry": {
109
+ "enabled": true,
110
+ "hooks": {
111
+ "allowConversationAccess": true
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ Then ensure the package is installed where OpenClaw can load it (either in your OpenClaw workspace, or globally via `npm i -g @latitude-data/openclaw-telemetry`).
120
+
121
+ ## Privacy
122
+
123
+ This plugin reads every LLM input and output and sends the **full content** to Latitude — system prompts, user prompts, assistant responses, tool I/O. There is no per-flag opt-in once `allowConversationAccess` is set: everything gets shipped.
124
+
125
+ If that's not what you want:
126
+
127
+ - Don't install the plugin.
128
+ - Set `LATITUDE_OPENCLAW_ENABLED=0` in your shell before starting a sensitive session.
129
+ - Run `uninstall`.
130
+
131
+ ## Supported OpenClaw versions
132
+
133
+ Requires OpenClaw **2026.3.0+** for the `llm_input` / `llm_output` hooks. Older versions lack these hooks and would only surface metadata via `model.usage` diagnostics — not enough for full trace fidelity.
134
+
135
+ ## How it fails
136
+
137
+ Fail-open by design. If the API is unreachable, your key is wrong, or a hook payload is malformed, the plugin logs to stderr (when `LATITUDE_DEBUG=1`) and the agent run continues unaffected.
138
+
139
+ ## License
140
+
141
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { };
package/dist/cli.js ADDED
@@ -0,0 +1,272 @@
1
+ #!/usr/bin/env node
2
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import { cancel, confirm, intro, isCancel, log, note, outro, password, spinner, text } from "@clack/prompts";
5
+ import pc from "picocolors";
6
+ import { homedir } from "node:os";
7
+ //#region src/settings-file.ts
8
+ const SETTINGS_PATH = join(homedir(), ".openclaw", "openclaw.json");
9
+ const SETTINGS_BACKUP_PATH = join(homedir(), ".openclaw", "openclaw.json.latitude-bak");
10
+ const PLUGIN_ID = "@latitude-data/openclaw-telemetry";
11
+ function readSettings() {
12
+ if (!existsSync(SETTINGS_PATH)) return {};
13
+ try {
14
+ const raw = readFileSync(SETTINGS_PATH, "utf-8");
15
+ const parsed = JSON.parse(raw);
16
+ return parsed && typeof parsed === "object" ? parsed : {};
17
+ } catch {
18
+ return {};
19
+ }
20
+ }
21
+ function writeSettings(settings) {
22
+ writeFileSync(SETTINGS_PATH, `${JSON.stringify(settings, null, 2)}\n`, "utf-8");
23
+ }
24
+ function backupSettings() {
25
+ if (existsSync(SETTINGS_PATH)) copyFileSync(SETTINGS_PATH, SETTINGS_BACKUP_PATH);
26
+ }
27
+ function ensurePluginEntry(settings) {
28
+ const plugins = settings.plugins ?? {};
29
+ const entries = plugins.entries ?? {};
30
+ const existing = entries["@latitude-data/openclaw-telemetry"] ?? {};
31
+ const entry = {
32
+ ...existing,
33
+ enabled: true,
34
+ hooks: {
35
+ ...existing.hooks ?? {},
36
+ allowConversationAccess: true
37
+ }
38
+ };
39
+ entries[PLUGIN_ID] = entry;
40
+ plugins.entries = entries;
41
+ settings.plugins = plugins;
42
+ return entry;
43
+ }
44
+ function removePluginEntry(settings) {
45
+ const plugins = settings.plugins;
46
+ if (!plugins?.entries) return false;
47
+ if (!("@latitude-data/openclaw-telemetry" in plugins.entries)) return false;
48
+ delete plugins.entries[PLUGIN_ID];
49
+ return true;
50
+ }
51
+ function setEnv(settings, key, value) {
52
+ const env = settings.env ?? {};
53
+ env[key] = value;
54
+ settings.env = env;
55
+ }
56
+ function removeEnv(settings, keys) {
57
+ const env = settings.env;
58
+ if (!env) return false;
59
+ let removed = false;
60
+ for (const k of keys) if (k in env) {
61
+ delete env[k];
62
+ removed = true;
63
+ }
64
+ return removed;
65
+ }
66
+ function hasLatitudePlugin(settings) {
67
+ return Boolean(settings.plugins?.entries && "@latitude-data/openclaw-telemetry" in settings.plugins.entries);
68
+ }
69
+ //#endregion
70
+ //#region src/setup.ts
71
+ const DOCS_URL = "https://docs.latitude.so/openclaw-telemetry";
72
+ const PRODUCTION_ENV = {
73
+ name: "production",
74
+ label: "production",
75
+ app: "https://console.latitude.so",
76
+ ingest: "https://ingest.latitude.so"
77
+ };
78
+ const STAGING_ENV = {
79
+ name: "staging",
80
+ label: "staging",
81
+ app: "https://staging.latitude.so",
82
+ ingest: "https://staging-ingest.latitude.so"
83
+ };
84
+ const DEV_ENV = {
85
+ name: "dev",
86
+ label: "local dev",
87
+ app: "http://localhost:3000",
88
+ ingest: "http://localhost:3002"
89
+ };
90
+ function urlsFor(env) {
91
+ return {
92
+ apiKeys: `${env.app}/settings/api-keys`,
93
+ projects: env.app,
94
+ projectView: (slug) => `${env.app}/projects/${slug}`
95
+ };
96
+ }
97
+ function parseFlags(argv) {
98
+ const [subcommand, ...rest] = argv;
99
+ const flags = {};
100
+ for (const arg of rest) {
101
+ if (!arg.startsWith("--")) continue;
102
+ const eq = arg.indexOf("=");
103
+ if (eq >= 0) flags[arg.slice(2, eq)] = arg.slice(eq + 1);
104
+ else flags[arg.slice(2)] = true;
105
+ }
106
+ return {
107
+ subcommand,
108
+ flags
109
+ };
110
+ }
111
+ function normalizeInstallFlags(flags) {
112
+ let environment;
113
+ if (flags.staging === true) environment = STAGING_ENV;
114
+ if (flags.dev === true) {
115
+ if (environment) throw new Error("--staging and --dev are mutually exclusive");
116
+ environment = DEV_ENV;
117
+ }
118
+ return {
119
+ apiKey: typeof flags["api-key"] === "string" ? flags["api-key"] : void 0,
120
+ project: typeof flags.project === "string" ? flags.project : void 0,
121
+ environment,
122
+ noPrompt: flags["no-prompt"] === true || flags.yes === true,
123
+ yes: flags.yes === true
124
+ };
125
+ }
126
+ async function runInstall(flags = {}) {
127
+ if (!(!flags.noPrompt && process.stdin.isTTY === true)) return runFlagDrivenInstall(flags);
128
+ await runInteractiveInstall(flags);
129
+ }
130
+ async function runInteractiveInstall(flags) {
131
+ intro(pc.bgCyan(pc.black(" Latitude · OpenClaw telemetry ")));
132
+ const existingEnv = readSettings().env ?? {};
133
+ const envConfig = flags.environment ?? PRODUCTION_ENV;
134
+ const urls = urlsFor(envConfig);
135
+ const aboutLines = [
136
+ "Captures every OpenClaw agent run and ships it to Latitude as",
137
+ "OpenTelemetry traces — full system prompt, tool I/O, messages,",
138
+ "token usage, and agent name on every span.",
139
+ "",
140
+ `${pc.dim("Docs")} ${pc.cyan(DOCS_URL)}`
141
+ ];
142
+ if (envConfig.name !== "production") aboutLines.push("", pc.yellow(`Using ${envConfig.label} environment (${envConfig.ingest})`));
143
+ note(aboutLines.join("\n"), "About");
144
+ log.info(`Get an API key at ${pc.cyan(urls.apiKeys)}`);
145
+ log.info(`Create a project at ${pc.cyan(urls.projects)}`);
146
+ const apiKey = await promptApiKey(existingEnv.LATITUDE_API_KEY, flags.apiKey);
147
+ const project = await promptProject(existingEnv.LATITUDE_PROJECT, flags.project);
148
+ await applyChanges({
149
+ apiKey,
150
+ project,
151
+ envConfig
152
+ });
153
+ note([
154
+ "Restart the OpenClaw gateway for the plugin to load:",
155
+ pc.dim(" openclaw gateway restart"),
156
+ "",
157
+ `View your traces at ${pc.cyan(urls.projectView(project))}`
158
+ ].join("\n"), "Next step");
159
+ outro(pc.green("✓ Installed"));
160
+ }
161
+ async function runFlagDrivenInstall(flags) {
162
+ const apiKey = flags.apiKey;
163
+ const project = flags.project;
164
+ if (!apiKey || !project) throw new Error("Non-interactive install requires --api-key=... and --project=... (or run in a TTY).");
165
+ await applyChanges({
166
+ apiKey,
167
+ project,
168
+ envConfig: flags.environment ?? PRODUCTION_ENV
169
+ });
170
+ process.stdout.write(`Installed Latitude plugin in ${SETTINGS_PATH}\n`);
171
+ }
172
+ async function promptApiKey(_existing, flag) {
173
+ if (flag) return flag;
174
+ const result = await password({
175
+ message: "Latitude API key",
176
+ mask: "•",
177
+ validate: (v) => v && v.length > 0 ? void 0 : "Required"
178
+ });
179
+ if (isCancel(result)) return onCancel();
180
+ return result;
181
+ }
182
+ async function promptProject(existing, flag) {
183
+ if (flag) return flag;
184
+ const result = await text({
185
+ message: "Latitude project slug",
186
+ placeholder: existing ?? "my-openclaw-project",
187
+ ...existing ? { initialValue: existing } : {},
188
+ validate: (v) => v && v.length > 0 ? void 0 : "Required"
189
+ });
190
+ if (isCancel(result)) return onCancel();
191
+ return result;
192
+ }
193
+ function onCancel() {
194
+ cancel("Cancelled — nothing was changed");
195
+ process.exit(1);
196
+ }
197
+ async function applyChanges({ apiKey, project, envConfig }) {
198
+ const s = spinner();
199
+ s.start("Updating openclaw.json");
200
+ ensureSettingsDir();
201
+ backupSettings();
202
+ const settings = readSettings();
203
+ ensurePluginEntry(settings);
204
+ setEnv(settings, "LATITUDE_API_KEY", apiKey);
205
+ setEnv(settings, "LATITUDE_PROJECT", project);
206
+ if (envConfig.name !== "production") setEnv(settings, "LATITUDE_BASE_URL", envConfig.ingest);
207
+ else removeEnv(settings, ["LATITUDE_BASE_URL"]);
208
+ writeSettings(settings);
209
+ s.stop(`Updated ${SETTINGS_PATH}`);
210
+ if (existsSync(SETTINGS_BACKUP_PATH)) log.info(`Backup saved at ${pc.dim(SETTINGS_BACKUP_PATH)}`);
211
+ }
212
+ function ensureSettingsDir() {
213
+ const dir = dirname(SETTINGS_PATH);
214
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
215
+ }
216
+ async function runUninstall(flags = {}) {
217
+ intro(pc.bgYellow(pc.black(" Latitude · OpenClaw telemetry — uninstall ")));
218
+ const settings = readSettings();
219
+ if (!hasLatitudePlugin(settings)) {
220
+ note("No Latitude plugin entry found — nothing to remove.", "Status");
221
+ outro(pc.dim("Nothing changed"));
222
+ return;
223
+ }
224
+ note([
225
+ `Remove "${PLUGIN_ID}" plugin entry from ${SETTINGS_PATH}`,
226
+ "Remove LATITUDE_API_KEY / LATITUDE_PROJECT / LATITUDE_BASE_URL from env",
227
+ `Backup saved at ${SETTINGS_BACKUP_PATH}`
228
+ ].join("\n"), "Plan");
229
+ if (!flags.noPrompt && process.stdin.isTTY === true) {
230
+ const ok = await confirm({
231
+ message: "Proceed?",
232
+ initialValue: true
233
+ });
234
+ if (isCancel(ok) || ok !== true) return onCancel();
235
+ }
236
+ const s = spinner();
237
+ s.start("Reverting settings");
238
+ backupSettings();
239
+ removePluginEntry(settings);
240
+ removeEnv(settings, [
241
+ "LATITUDE_API_KEY",
242
+ "LATITUDE_PROJECT",
243
+ "LATITUDE_BASE_URL"
244
+ ]);
245
+ writeSettings(settings);
246
+ s.stop("Done");
247
+ outro(pc.green("✓ Uninstalled"));
248
+ }
249
+ //#endregion
250
+ //#region src/cli.ts
251
+ async function main() {
252
+ const { subcommand, flags } = parseFlags(process.argv.slice(2));
253
+ if (subcommand === "install" || subcommand === void 0) {
254
+ await runInstall(normalizeInstallFlags(flags));
255
+ return;
256
+ }
257
+ if (subcommand === "uninstall") {
258
+ await runUninstall({ noPrompt: flags["no-prompt"] === true || flags.yes === true });
259
+ return;
260
+ }
261
+ process.stderr.write(`unknown subcommand: ${subcommand}\n`);
262
+ process.stderr.write("usage: latitude-openclaw [install|uninstall] [--api-key=...] [--project=...] [--staging|--dev] [--yes]\n");
263
+ process.exit(1);
264
+ }
265
+ main().catch((err) => {
266
+ process.stderr.write(`${String(err)}\n`);
267
+ process.exit(1);
268
+ });
269
+ //#endregion
270
+ export {};
271
+
272
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/settings-file.ts","../src/setup.ts","../src/cli.ts"],"sourcesContent":["import { copyFileSync, existsSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { homedir } from \"node:os\"\nimport { join } from \"node:path\"\n\nexport const SETTINGS_PATH = join(homedir(), \".openclaw\", \"openclaw.json\")\nexport const SETTINGS_BACKUP_PATH = join(homedir(), \".openclaw\", \"openclaw.json.latitude-bak\")\n\nexport const PLUGIN_ID = \"@latitude-data/openclaw-telemetry\"\n\ninterface OpenClawPluginEntry {\n enabled?: boolean\n hooks?: {\n allowPromptInjection?: boolean\n allowConversationAccess?: boolean\n }\n config?: Record<string, unknown>\n}\n\ninterface OpenClawSettings {\n plugins?: {\n enabled?: boolean\n entries?: Record<string, OpenClawPluginEntry>\n [key: string]: unknown\n }\n env?: Record<string, string>\n [key: string]: unknown\n}\n\nexport function readSettings(): OpenClawSettings {\n if (!existsSync(SETTINGS_PATH)) return {}\n try {\n const raw = readFileSync(SETTINGS_PATH, \"utf-8\")\n const parsed = JSON.parse(raw) as OpenClawSettings\n return parsed && typeof parsed === \"object\" ? parsed : {}\n } catch {\n return {}\n }\n}\n\nexport function writeSettings(settings: OpenClawSettings): void {\n writeFileSync(SETTINGS_PATH, `${JSON.stringify(settings, null, 2)}\\n`, \"utf-8\")\n}\n\nexport function backupSettings(): void {\n if (existsSync(SETTINGS_PATH)) copyFileSync(SETTINGS_PATH, SETTINGS_BACKUP_PATH)\n}\n\nexport function ensurePluginEntry(settings: OpenClawSettings): OpenClawPluginEntry {\n const plugins = settings.plugins ?? {}\n const entries = plugins.entries ?? {}\n const existing = entries[PLUGIN_ID] ?? {}\n const entry: OpenClawPluginEntry = {\n ...existing,\n enabled: true,\n hooks: {\n ...(existing.hooks ?? {}),\n // Required for third-party plugins to read raw conversation content\n // from llm_input/llm_output/agent_end. Without this the hooks fire but\n // payloads are scrubbed — which is exactly the silent failure mode that\n // the existing third-party OpenClaw observability plugin runs into.\n allowConversationAccess: true,\n },\n }\n entries[PLUGIN_ID] = entry\n plugins.entries = entries\n settings.plugins = plugins\n return entry\n}\n\nexport function removePluginEntry(settings: OpenClawSettings): boolean {\n const plugins = settings.plugins\n if (!plugins?.entries) return false\n if (!(PLUGIN_ID in plugins.entries)) return false\n delete plugins.entries[PLUGIN_ID]\n return true\n}\n\nexport function setEnv(settings: OpenClawSettings, key: string, value: string): void {\n const env = settings.env ?? {}\n env[key] = value\n settings.env = env\n}\n\nexport function removeEnv(settings: OpenClawSettings, keys: string[]): boolean {\n const env = settings.env\n if (!env) return false\n let removed = false\n for (const k of keys) {\n if (k in env) {\n delete env[k]\n removed = true\n }\n }\n return removed\n}\n\nexport function hasLatitudePlugin(settings: OpenClawSettings): boolean {\n return Boolean(settings.plugins?.entries && PLUGIN_ID in settings.plugins.entries)\n}\n","import { existsSync, mkdirSync } from \"node:fs\"\nimport { dirname } from \"node:path\"\nimport { cancel, confirm, intro, isCancel, log, note, outro, password, spinner, text } from \"@clack/prompts\"\nimport pc from \"picocolors\"\nimport {\n backupSettings,\n ensurePluginEntry,\n hasLatitudePlugin,\n PLUGIN_ID,\n readSettings,\n removeEnv,\n removePluginEntry,\n SETTINGS_BACKUP_PATH,\n SETTINGS_PATH,\n setEnv,\n writeSettings,\n} from \"./settings-file.ts\"\n\nconst DOCS_URL = \"https://docs.latitude.so/openclaw-telemetry\"\n\ninterface EnvironmentConfig {\n name: \"production\" | \"staging\" | \"dev\"\n label: string\n app: string\n ingest: string\n}\n\nconst PRODUCTION_ENV: EnvironmentConfig = {\n name: \"production\",\n label: \"production\",\n app: \"https://console.latitude.so\",\n ingest: \"https://ingest.latitude.so\",\n}\nconst STAGING_ENV: EnvironmentConfig = {\n name: \"staging\",\n label: \"staging\",\n app: \"https://staging.latitude.so\",\n ingest: \"https://staging-ingest.latitude.so\",\n}\nconst DEV_ENV: EnvironmentConfig = {\n name: \"dev\",\n label: \"local dev\",\n app: \"http://localhost:3000\",\n ingest: \"http://localhost:3002\",\n}\n\nfunction urlsFor(env: EnvironmentConfig): {\n apiKeys: string\n projects: string\n projectView: (slug: string) => string\n} {\n return {\n apiKeys: `${env.app}/settings/api-keys`,\n projects: env.app,\n projectView: (slug: string) => `${env.app}/projects/${slug}`,\n }\n}\n\ninterface InstallFlags {\n apiKey?: string | undefined\n project?: string | undefined\n environment?: EnvironmentConfig | undefined\n noPrompt?: boolean\n yes?: boolean\n}\n\nexport function parseFlags(argv: string[]): {\n subcommand: string | undefined\n flags: Record<string, string | boolean>\n} {\n const [subcommand, ...rest] = argv\n const flags: Record<string, string | boolean> = {}\n for (const arg of rest) {\n if (!arg.startsWith(\"--\")) continue\n const eq = arg.indexOf(\"=\")\n if (eq >= 0) {\n flags[arg.slice(2, eq)] = arg.slice(eq + 1)\n } else {\n flags[arg.slice(2)] = true\n }\n }\n return { subcommand, flags }\n}\n\nexport function normalizeInstallFlags(flags: Record<string, string | boolean>): InstallFlags {\n let environment: EnvironmentConfig | undefined\n if (flags.staging === true) environment = STAGING_ENV\n if (flags.dev === true) {\n if (environment) throw new Error(\"--staging and --dev are mutually exclusive\")\n environment = DEV_ENV\n }\n return {\n apiKey: typeof flags[\"api-key\"] === \"string\" ? flags[\"api-key\"] : undefined,\n project: typeof flags.project === \"string\" ? flags.project : undefined,\n environment,\n noPrompt: flags[\"no-prompt\"] === true || flags.yes === true,\n yes: flags.yes === true,\n }\n}\n\n// ─── Install ────────────────────────────────────────────────────────────────\n\nexport async function runInstall(flags: InstallFlags = {}): Promise<void> {\n const canPrompt = !flags.noPrompt && process.stdin.isTTY === true\n if (!canPrompt) return runFlagDrivenInstall(flags)\n await runInteractiveInstall(flags)\n}\n\nasync function runInteractiveInstall(flags: InstallFlags): Promise<void> {\n intro(pc.bgCyan(pc.black(\" Latitude · OpenClaw telemetry \")))\n\n const existing = readSettings()\n const existingEnv = existing.env ?? {}\n const envConfig = flags.environment ?? PRODUCTION_ENV\n const urls = urlsFor(envConfig)\n\n const aboutLines = [\n \"Captures every OpenClaw agent run and ships it to Latitude as\",\n \"OpenTelemetry traces — full system prompt, tool I/O, messages,\",\n \"token usage, and agent name on every span.\",\n \"\",\n `${pc.dim(\"Docs\")} ${pc.cyan(DOCS_URL)}`,\n ]\n if (envConfig.name !== \"production\") {\n aboutLines.push(\"\", pc.yellow(`Using ${envConfig.label} environment (${envConfig.ingest})`))\n }\n note(aboutLines.join(\"\\n\"), \"About\")\n\n log.info(`Get an API key at ${pc.cyan(urls.apiKeys)}`)\n log.info(`Create a project at ${pc.cyan(urls.projects)}`)\n\n const apiKey = await promptApiKey(existingEnv.LATITUDE_API_KEY, flags.apiKey)\n const project = await promptProject(existingEnv.LATITUDE_PROJECT, flags.project)\n\n await applyChanges({ apiKey, project, envConfig })\n\n note(\n [\n \"Restart the OpenClaw gateway for the plugin to load:\",\n pc.dim(\" openclaw gateway restart\"),\n \"\",\n `View your traces at ${pc.cyan(urls.projectView(project))}`,\n ].join(\"\\n\"),\n \"Next step\",\n )\n outro(pc.green(\"✓ Installed\"))\n}\n\nasync function runFlagDrivenInstall(flags: InstallFlags): Promise<void> {\n const apiKey = flags.apiKey\n const project = flags.project\n if (!apiKey || !project) {\n throw new Error(\"Non-interactive install requires --api-key=... and --project=... (or run in a TTY).\")\n }\n const envConfig = flags.environment ?? PRODUCTION_ENV\n await applyChanges({ apiKey, project, envConfig })\n process.stdout.write(`Installed Latitude plugin in ${SETTINGS_PATH}\\n`)\n}\n\nasync function promptApiKey(_existing: string | undefined, flag: string | undefined): Promise<string> {\n if (flag) return flag\n const result = await password({\n message: \"Latitude API key\",\n mask: \"•\",\n validate: (v) => (v && v.length > 0 ? undefined : \"Required\"),\n })\n if (isCancel(result)) return onCancel()\n return result\n}\n\nasync function promptProject(existing: string | undefined, flag: string | undefined): Promise<string> {\n if (flag) return flag\n const result = await text({\n message: \"Latitude project slug\",\n placeholder: existing ?? \"my-openclaw-project\",\n ...(existing ? { initialValue: existing } : {}),\n validate: (v) => (v && v.length > 0 ? undefined : \"Required\"),\n })\n if (isCancel(result)) return onCancel()\n return result\n}\n\nfunction onCancel(): never {\n cancel(\"Cancelled — nothing was changed\")\n process.exit(1)\n}\n\ninterface ApplyParams {\n apiKey: string\n project: string\n envConfig: EnvironmentConfig\n}\n\nasync function applyChanges({ apiKey, project, envConfig }: ApplyParams): Promise<void> {\n const s = spinner()\n s.start(\"Updating openclaw.json\")\n ensureSettingsDir()\n backupSettings()\n const settings = readSettings()\n ensurePluginEntry(settings)\n setEnv(settings, \"LATITUDE_API_KEY\", apiKey)\n setEnv(settings, \"LATITUDE_PROJECT\", project)\n if (envConfig.name !== \"production\") {\n setEnv(settings, \"LATITUDE_BASE_URL\", envConfig.ingest)\n } else {\n // Clear any stale BASE_URL left over from a prior --staging/--dev install so\n // re-running `install` without flags is idempotent back to production.\n removeEnv(settings, [\"LATITUDE_BASE_URL\"])\n }\n writeSettings(settings)\n s.stop(`Updated ${SETTINGS_PATH}`)\n if (existsSync(SETTINGS_BACKUP_PATH)) log.info(`Backup saved at ${pc.dim(SETTINGS_BACKUP_PATH)}`)\n}\n\nfunction ensureSettingsDir(): void {\n const dir = dirname(SETTINGS_PATH)\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n}\n\n// ─── Uninstall ──────────────────────────────────────────────────────────────\n\ninterface UninstallFlags {\n noPrompt?: boolean\n}\n\nexport async function runUninstall(flags: UninstallFlags = {}): Promise<void> {\n intro(pc.bgYellow(pc.black(\" Latitude · OpenClaw telemetry — uninstall \")))\n const settings = readSettings()\n\n if (!hasLatitudePlugin(settings)) {\n note(\"No Latitude plugin entry found — nothing to remove.\", \"Status\")\n outro(pc.dim(\"Nothing changed\"))\n return\n }\n\n const plan = [\n `Remove \"${PLUGIN_ID}\" plugin entry from ${SETTINGS_PATH}`,\n \"Remove LATITUDE_API_KEY / LATITUDE_PROJECT / LATITUDE_BASE_URL from env\",\n `Backup saved at ${SETTINGS_BACKUP_PATH}`,\n ]\n note(plan.join(\"\\n\"), \"Plan\")\n\n if (!flags.noPrompt && process.stdin.isTTY === true) {\n const ok = await confirm({ message: \"Proceed?\", initialValue: true })\n if (isCancel(ok) || ok !== true) return onCancel()\n }\n\n const s = spinner()\n s.start(\"Reverting settings\")\n backupSettings()\n removePluginEntry(settings)\n removeEnv(settings, [\"LATITUDE_API_KEY\", \"LATITUDE_PROJECT\", \"LATITUDE_BASE_URL\"])\n writeSettings(settings)\n s.stop(\"Done\")\n outro(pc.green(\"✓ Uninstalled\"))\n}\n","import { normalizeInstallFlags, parseFlags, runInstall, runUninstall } from \"./setup.ts\"\n\nasync function main(): Promise<void> {\n const { subcommand, flags } = parseFlags(process.argv.slice(2))\n if (subcommand === \"install\" || subcommand === undefined) {\n await runInstall(normalizeInstallFlags(flags))\n return\n }\n if (subcommand === \"uninstall\") {\n await runUninstall({ noPrompt: flags[\"no-prompt\"] === true || flags.yes === true })\n return\n }\n process.stderr.write(`unknown subcommand: ${subcommand}\\n`)\n process.stderr.write(\n \"usage: latitude-openclaw [install|uninstall] [--api-key=...] [--project=...] [--staging|--dev] [--yes]\\n\",\n )\n process.exit(1)\n}\n\nmain().catch((err) => {\n process.stderr.write(`${String(err)}\\n`)\n process.exit(1)\n})\n"],"mappings":";;;;;;;AAIA,MAAa,gBAAgB,KAAK,SAAS,EAAE,aAAa,gBAAgB;AAC1E,MAAa,uBAAuB,KAAK,SAAS,EAAE,aAAa,6BAA6B;AAE9F,MAAa,YAAY;AAqBzB,SAAgB,eAAiC;AAC/C,KAAI,CAAC,WAAW,cAAc,CAAE,QAAO,EAAE;AACzC,KAAI;EACF,MAAM,MAAM,aAAa,eAAe,QAAQ;E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