@virtue-ai/gateway-connect 0.3.2 → 0.3.4

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.
@@ -26,7 +26,7 @@ const DEFAULT_GUARD_UUID = '3a2389709528a539a12ba6239e402ef159ecffa88f99af6e1323
26
26
  // ---------------------------------------------------------------------------
27
27
  function buildPluginSource() {
28
28
  return `\
29
- import { readFileSync } from "fs";
29
+ import { readFileSync, appendFileSync, mkdirSync } from "fs";
30
30
  import { join } from "path";
31
31
  import { homedir } from "os";
32
32
 
@@ -40,6 +40,7 @@ import { homedir } from "os";
40
40
  */
41
41
 
42
42
  const MCP_CONFIG_PATH = join(homedir(), ".openclaw", "mcp-gateway.json");
43
+ const TRAJECTORY_LOG_DIR = join(homedir(), ".openclaw", "logs", "trajectory");
43
44
  const DEFAULT_GUARD_UUID =
44
45
  "${DEFAULT_GUARD_UUID}";
45
46
 
@@ -100,8 +101,19 @@ const plugin = {
100
101
  let gatewaySessionId = null;
101
102
  let endpointDisabled = false;
102
103
  const endpoint = config.apiUrl + "/api/prompt-guard/topic_guard";
104
+ const localSessionId = "local_" + Date.now().toString(36);
103
105
 
104
- api.logger.info("[virtueai-trajectory] Plugin registered, sending to " + config.gatewayUrl);
106
+ try { mkdirSync(TRAJECTORY_LOG_DIR, { recursive: true }); } catch {}
107
+
108
+ function writeLocal(role, content) {
109
+ try {
110
+ const entry = { timestamp: new Date().toISOString(), session_id: gatewaySessionId || localSessionId, role, content };
111
+ const logFile = join(TRAJECTORY_LOG_DIR, localSessionId + ".jsonl");
112
+ appendFileSync(logFile, JSON.stringify(entry) + "\\n");
113
+ } catch {}
114
+ }
115
+
116
+ api.logger.info("[virtueai-trajectory] Plugin registered, sending to " + config.apiUrl);
105
117
 
106
118
  async function sendStep(role, content) {
107
119
  if (endpointDisabled) return;
@@ -147,9 +159,13 @@ const plugin = {
147
159
  }
148
160
 
149
161
  api.on("llm_input", (event) => {
162
+ if (event.systemPrompt) {
163
+ writeLocal("system", event.systemPrompt);
164
+ }
150
165
  const cleaned = stripSenderMetadata(event.prompt);
151
166
  api.logger.info("[virtueai-trajectory] llm_input fired, prompt=" + (cleaned ?? "").slice(0, 80));
152
167
  if (cleaned) {
168
+ writeLocal("user", cleaned);
153
169
  sendStep("user", cleaned);
154
170
  }
155
171
  });
@@ -159,6 +175,7 @@ const plugin = {
159
175
  const text = (event.assistantTexts ?? []).join("\\n").trim();
160
176
  if (text) {
161
177
  api.logger.info("[virtueai-trajectory] llm_output sending agent text, len=" + text.length);
178
+ writeLocal("agent", text);
162
179
  sendStep("agent", text);
163
180
  } else {
164
181
  api.logger.warn("[virtueai-trajectory] llm_output fired but assistantTexts empty");
@@ -174,6 +191,7 @@ const plugin = {
174
191
  : "";
175
192
  const callStr = event.toolName + "(" + toolParams + ")";
176
193
  const resultStr = event.result != null ? truncate(event.result, 500) : (event.error ?? "no result");
194
+ writeLocal("tool", callStr + " → " + resultStr);
177
195
  sendStep("agent", callStr + " → " + resultStr);
178
196
  });
179
197
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virtue-ai/gateway-connect",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "One-command setup to connect OpenClaw to VirtueAI MCP gateway",
5
5
  "type": "module",
6
6
  "files": [