nemo-relay-openclaw 0.0.0 → 0.3.0-beta.2
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/README.md +262 -4
- package/dist/index.d.ts +8 -0
- package/dist/index.js +20 -0
- package/dist/openclaw.plugin.json +154 -0
- package/dist/src/config.d.ts +329 -0
- package/dist/src/config.js +185 -0
- package/dist/src/health.d.ts +48 -0
- package/dist/src/health.js +63 -0
- package/dist/src/hook-replay/correlation.d.ts +34 -0
- package/dist/src/hook-replay/correlation.js +40 -0
- package/dist/src/hook-replay/llm.d.ts +52 -0
- package/dist/src/hook-replay/llm.js +1060 -0
- package/dist/src/hook-replay/marks.d.ts +30 -0
- package/dist/src/hook-replay/marks.js +109 -0
- package/dist/src/hook-replay/session.d.ts +157 -0
- package/dist/src/hook-replay/session.js +204 -0
- package/dist/src/hook-replay/tool.d.ts +12 -0
- package/dist/src/hook-replay/tool.js +101 -0
- package/dist/src/hooks-backend.d.ts +94 -0
- package/dist/src/hooks-backend.js +321 -0
- package/dist/src/modules.d.ts +42 -0
- package/dist/src/modules.js +15 -0
- package/dist/src/openclaw-hook-types.d.ts +186 -0
- package/dist/src/openclaw-hook-types.js +3 -0
- package/dist/src/runtime-state.d.ts +66 -0
- package/dist/src/runtime-state.js +420 -0
- package/dist/src/types.d.ts +27 -0
- package/dist/src/types.js +3 -0
- package/index.ts +23 -0
- package/openclaw.plugin.json +154 -0
- package/package.json +62 -24
- package/src/config.ts +251 -0
- package/src/health.ts +116 -0
- package/src/hook-replay/correlation.ts +75 -0
- package/src/hook-replay/llm.ts +1302 -0
- package/src/hook-replay/marks.ts +141 -0
- package/src/hook-replay/session.ts +396 -0
- package/src/hook-replay/tool.ts +142 -0
- package/src/hooks-backend.ts +457 -0
- package/src/modules.ts +79 -0
- package/src/openclaw-hook-types.ts +211 -0
- package/src/runtime-state.ts +553 -0
- package/src/types.ts +34 -0
- package/index.d.ts +0 -2
- package/index.js +0 -15
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM span reconstruction for OpenClaw hook replay.
|
|
3
|
+
*
|
|
4
|
+
* OpenClaw currently exposes public hooks for request snapshots, assistant
|
|
5
|
+
* outputs, message writes, and model-call timing as separate event streams. This
|
|
6
|
+
* module correlates those signals into NeMo Relay LLM spans while staying on the
|
|
7
|
+
* public plugin API. The reconstruction is intentionally best-effort until
|
|
8
|
+
* OpenClaw exposes a first-class provider-call lifecycle hook with a stable
|
|
9
|
+
* call id, request, response, usage, and timing in one contract.
|
|
10
|
+
*/
|
|
11
|
+
import type { NemoRelayHookBackendConfig } from '../config.js';
|
|
12
|
+
import type { PluginHookAgentContext, PluginHookAgentEndEvent, PluginHookBeforeMessageWriteContext, PluginHookBeforeMessageWriteEvent, PluginHookLlmInputEvent, PluginHookLlmOutputEvent, PluginHookModelCallEndedEvent, PluginHookModelCallStartedEvent } from '../openclaw-hook-types.js';
|
|
13
|
+
import type { JsonObject as JsonRecord, JsonValue } from 'nemo-relay-node/typed';
|
|
14
|
+
import { type LlmInputRecord, type ModelCallRecord, type SessionManager, type SessionState } from './session.js';
|
|
15
|
+
/**
|
|
16
|
+
* Store one OpenClaw llm_input snapshot and replay it immediately if the matching
|
|
17
|
+
* llm_output arrived first.
|
|
18
|
+
*/
|
|
19
|
+
export declare function recordLlmInput(manager: SessionManager, event: PluginHookLlmInputEvent, ctx: PluginHookAgentContext): void;
|
|
20
|
+
/**
|
|
21
|
+
* Replay one llm_output event or hold it briefly for a late llm_input snapshot.
|
|
22
|
+
*
|
|
23
|
+
* The grace window keeps traces accurate for out-of-order hooks without blocking
|
|
24
|
+
* the OpenClaw process or keeping Node alive.
|
|
25
|
+
*/
|
|
26
|
+
export declare function recordLlmOutput(manager: SessionManager, event: PluginHookLlmOutputEvent, ctx: PluginHookAgentContext): void;
|
|
27
|
+
/**
|
|
28
|
+
* Capture assistant message writes as a higher-fidelity fallback for LLM outputs.
|
|
29
|
+
*
|
|
30
|
+
* Some OpenClaw paths expose the clearest assistant text, tool calls, and usage
|
|
31
|
+
* during message persistence rather than through llm_output.
|
|
32
|
+
*/
|
|
33
|
+
export declare function recordBeforeMessageWrite(manager: SessionManager, event: PluginHookBeforeMessageWriteEvent, ctx: PluginHookBeforeMessageWriteContext): void;
|
|
34
|
+
/** Record the start of a provider call when OpenClaw supplies a model call id. */
|
|
35
|
+
export declare function recordModelCallStarted(manager: SessionManager, event: PluginHookModelCallStartedEvent, ctx: PluginHookAgentContext): void;
|
|
36
|
+
/** Record provider-call timing and byte counters for later LLM span correlation. */
|
|
37
|
+
export declare function recordModelCallEnded(manager: SessionManager, event: PluginHookModelCallEndedEvent, ctx: PluginHookAgentContext): void;
|
|
38
|
+
/** Flush pending llm_output records for a session before the root span closes. */
|
|
39
|
+
export declare function replayPendingLlmOutputsForSession(manager: SessionManager, session: SessionState, options: {
|
|
40
|
+
allowPlaceholderRequest: boolean;
|
|
41
|
+
}): void;
|
|
42
|
+
/**
|
|
43
|
+
* Reconstruct final-run LLM spans from agent_end/message-write data when direct
|
|
44
|
+
* llm_output replay did not already produce the trajectory.
|
|
45
|
+
*/
|
|
46
|
+
export declare function replayAgentEndMessages(manager: SessionManager, event: PluginHookAgentEndEvent, ctx: PluginHookAgentContext, session: SessionState): JsonRecord | undefined;
|
|
47
|
+
/** Emit diagnostic marks for provider-call timing records that could not pair to an LLM span. */
|
|
48
|
+
export declare function emitUnpairedModelCallTimingMarks(manager: SessionManager, session: SessionState): void;
|
|
49
|
+
/** Build the request payload passed to NeMo Relay for a replayed LLM span. */
|
|
50
|
+
export declare function buildReplayLlmRequest(input: LlmInputRecord, output: PluginHookLlmOutputEvent, config: NemoRelayHookBackendConfig, source?: string): JsonValue;
|
|
51
|
+
/** Build the response payload passed to NeMo Relay for a replayed LLM span. */
|
|
52
|
+
export declare function buildReplayLlmResponse(event: PluginHookLlmOutputEvent, timing: ModelCallRecord | undefined, config: NemoRelayHookBackendConfig): JsonValue;
|