@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.
@@ -0,0 +1,117 @@
1
+ //#region src/config.d.ts
2
+ interface Config {
3
+ apiKey: string;
4
+ baseUrl: string;
5
+ project: string;
6
+ enabled: boolean;
7
+ debug: boolean;
8
+ }
9
+ //#endregion
10
+ //#region src/logger.d.ts
11
+ interface Logger {
12
+ debug: (msg: string) => void;
13
+ warn: (msg: string) => void;
14
+ }
15
+ //#endregion
16
+ //#region src/types.d.ts
17
+ interface OpenClawLlmUsage {
18
+ input?: number;
19
+ output?: number;
20
+ cacheRead?: number;
21
+ cacheWrite?: number;
22
+ total?: number;
23
+ }
24
+ interface LlmCallRecord {
25
+ runId: string;
26
+ sessionId: string;
27
+ sessionKey: string | undefined;
28
+ agentId: string | undefined;
29
+ provider: string;
30
+ requestModel: string;
31
+ responseModel: string | undefined;
32
+ resolvedRef: string | undefined;
33
+ systemPrompt: string | undefined;
34
+ prompt: string;
35
+ historyMessages: unknown[];
36
+ imagesCount: number;
37
+ assistantTexts: string[];
38
+ lastAssistant: unknown;
39
+ usage: OpenClawLlmUsage | undefined;
40
+ startMs: number;
41
+ endMs: number | undefined;
42
+ error: string | undefined;
43
+ toolCalls: ToolCallRecord[];
44
+ }
45
+ interface ToolCallRecord {
46
+ toolCallId: string;
47
+ toolName: string;
48
+ params: Record<string, unknown>;
49
+ result: unknown;
50
+ error: string | undefined;
51
+ startMs: number;
52
+ endMs: number | undefined;
53
+ durationMs: number | undefined;
54
+ agentId: string | undefined;
55
+ }
56
+ interface RunRecord {
57
+ runId: string;
58
+ sessionId: string | undefined;
59
+ sessionKey: string | undefined;
60
+ agentId: string | undefined;
61
+ workspaceDir: string | undefined;
62
+ messageProvider: string | undefined;
63
+ trigger: string | undefined;
64
+ channelId: string | undefined;
65
+ modelProviderId: string | undefined;
66
+ modelId: string | undefined;
67
+ startMs: number;
68
+ endMs: number | undefined;
69
+ success: boolean | undefined;
70
+ error: string | undefined;
71
+ llmCalls: LlmCallRecord[];
72
+ /**
73
+ * Tool calls queued by `before_tool_call` but not yet matched to an `llm_call`
74
+ * because the most recent `llm_output` has already closed the call for this
75
+ * runId. Retained so `after_tool_call` can still complete the record.
76
+ */
77
+ orphanTools: ToolCallRecord[];
78
+ }
79
+ //#endregion
80
+ //#region src/plugin.d.ts
81
+ /**
82
+ * Minimal structural type for OpenClaw's plugin API — only the fields we
83
+ * touch. We avoid importing from `openclaw/plugin-sdk` so the package stays
84
+ * usable when OpenClaw isn't installed (the CLI and tests don't need it),
85
+ * and so we're robust to small signature changes across OpenClaw versions.
86
+ */
87
+ interface OpenClawPluginApiLike {
88
+ logger?: Logger;
89
+ on: <K extends string>(hookName: K, handler: (event: unknown, ctx: unknown) => unknown, opts?: {
90
+ priority?: number;
91
+ }) => void;
92
+ }
93
+ interface RegisterOptions {
94
+ /** Override the config, mostly for tests. */
95
+ config?: Config;
96
+ /** Override the logger. */
97
+ logger?: Logger;
98
+ /**
99
+ * Hook to observe the emitted run right before it's posted. Used by tests;
100
+ * not a stable public API.
101
+ */
102
+ onEmit?: (run: RunRecord) => void;
103
+ }
104
+ /**
105
+ * Register the Latitude plugin against an OpenClaw plugin API. OpenClaw calls
106
+ * this once at plugin activation; we wire up `llm_input`, `llm_output`, tool
107
+ * and lifecycle hooks to stream traces to Latitude.
108
+ *
109
+ * Every handler is fire-and-forget on OpenClaw's side (see
110
+ * `src/plugins/hooks.ts` — runLlmInput/runLlmOutput are documented as
111
+ * parallel and wrapped with `.catch()` at the call site in attempt.ts), so
112
+ * nothing we do here can slow the agent loop.
113
+ */
114
+ declare function registerLatitudePlugin(api: OpenClawPluginApiLike, opts?: RegisterOptions): void;
115
+ //#endregion
116
+ export { OpenClawPluginApiLike, RegisterOptions, registerLatitudePlugin as default };
117
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","names":[],"sources":["../src/config.ts","../src/logger.ts","../src/types.ts","../src/plugin.ts"],"mappings":";UAAiB,MAAA;EACf,MAAA;EACA,OAAA;EACA,OAAA;EACA,OAAA;EACA,KAAA;AAAA;;;UCHe,MAAA;EACf,KAAA,GAAQ,GAAA;EACR,IAAA,GAAO,GAAA;AAAA;;;UCwDQ,gBAAA;EACf,KAAA;EACA,MAAA;EACA,SAAA;EACA,UAAA;EACA,KAAA;AAAA;AAAA,UA4De,aAAA;EACf,KAAA;EACA,SAAA;EACA,UAAA;EACA,OAAA;EACA,QAAA;EACA,YAAA;EACA,aAAA;EACA,WAAA;EACA,YAAA;EACA,MAAA;EACA,eAAA;EACA,WAAA;EACA,cAAA;EACA,aAAA;EACA,KAAA,EAAO,gBAAA;EACP,OAAA;EACA,KAAA;EACA,KAAA;EACA,SAAA,EAAW,cAAA;AAAA;AAAA,UAGI,cAAA;EACf,UAAA;EACA,QAAA;EACA,MAAA,EAAQ,MAAA;EACR,MAAA;EACA,KAAA;EACA,OAAA;EACA,KAAA;EACA,UAAA;EACA,OAAA;AAAA;AAAA,UAGe,SAAA;EACf,KAAA;EACA,SAAA;EACA,UAAA;EACA,OAAA;EACA,YAAA;EACA,eAAA;EACA,OAAA;EACA,SAAA;EACA,eAAA;EACA,OAAA;EACA,OAAA;EACA,KAAA;EACA,OAAA;EACA,KAAA;EACA,QAAA,EAAU,aAAA;;;;;;EAMV,WAAA,EAAa,cAAA;AAAA;;;;;;;;;UC9JE,qBAAA;EACf,MAAA,GAAS,MAAA;EACT,EAAA,qBACE,QAAA,EAAU,CAAA,EACV,OAAA,GAAU,KAAA,WAAgB,GAAA,uBAC1B,IAAA;IAAS,QAAA;EAAA;AAAA;AAAA,UAII,eAAA;EF7BM;EE+BrB,MAAA,GAAS,MAAA;EF/BY;EEiCrB,MAAA,GAAS,MAAA;EFhCD;;;;EEqCR,MAAA,IAAU,GAAA,EAAK,SAAA;AAAA;;;ADoBjB;;;;;;;;iBCPwB,sBAAA,CAAuB,GAAA,EAAK,qBAAA,EAAuB,IAAA,GAAM,eAAA"}