echoclaw-relay-agent 0.32.1 → 0.33.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.
@@ -2,7 +2,7 @@ import {
2
2
  fetchAvailableModels,
3
3
  verifyModel,
4
4
  waitForGateway
5
- } from "./chunk-NHM6IWCC.js";
5
+ } from "./chunk-FYTXP6H5.js";
6
6
  import {
7
7
  configureModel,
8
8
  detectProvider,
@@ -24,13 +24,20 @@ async function findOpenClaw() {
24
24
  return null;
25
25
  }
26
26
  }
27
- async function runOpenClaw(args, timeoutMs = 6e4) {
28
- const openclawBin = await findOpenClaw();
29
- if (!openclawBin) throw new Error("OpenClaw binary not found");
30
- return execFileAsync(openclawBin, args, {
31
- timeout: timeoutMs,
32
- env: { ...process.env }
33
- });
27
+ async function runOpenClaw(args, timeoutMs = 6e4, ctx = "local") {
28
+ if (ctx === "local") {
29
+ const openclawBin = await findOpenClaw();
30
+ if (!openclawBin) throw new Error("OpenClaw binary not found. Is OpenClaw installed?");
31
+ return execFileAsync(openclawBin, args, {
32
+ timeout: timeoutMs,
33
+ env: { ...process.env }
34
+ });
35
+ }
36
+ return execFileAsync(
37
+ "docker",
38
+ ["exec", ctx.container, "openclaw", ...args],
39
+ { timeout: timeoutMs }
40
+ );
34
41
  }
35
42
  async function checkOpenClawInstalled() {
36
43
  try {
@@ -45,7 +52,10 @@ async function checkOpenClawInstalled() {
45
52
  async function checkNeedsApiKey() {
46
53
  return !await hasApiKeyConfigured();
47
54
  }
48
- async function handleConfigure(request, sendStatus) {
55
+ async function handleConfigure(request, sendStatus, ctx = "local") {
56
+ if (ctx !== "local") {
57
+ console.log(` [configure] VM mode \u2014 openclaw commands run via docker exec (container=${ctx.container})`);
58
+ }
49
59
  try {
50
60
  sendStatus({
51
61
  type: "agent_setup_status",
@@ -76,7 +86,7 @@ async function handleConfigure(request, sendStatus) {
76
86
  }).catch(() => {
77
87
  });
78
88
  try {
79
- await runOpenClaw(["doctor", "--generate-gateway-token", "--non-interactive"], 3e4);
89
+ await runOpenClaw(["doctor", "--generate-gateway-token", "--non-interactive"], 3e4, ctx);
80
90
  } catch (err) {
81
91
  return {
82
92
  type: "agent_setup_status",
@@ -100,7 +110,7 @@ async function handleConfigure(request, sendStatus) {
100
110
  }).catch(() => {
101
111
  });
102
112
  try {
103
- await runOpenClaw(["gateway", "install"], 3e4);
113
+ await runOpenClaw(["gateway", "install"], 3e4, ctx);
104
114
  } catch (installErr) {
105
115
  sendStatus({
106
116
  type: "agent_setup_status",
@@ -110,7 +120,7 @@ async function handleConfigure(request, sendStatus) {
110
120
  });
111
121
  }
112
122
  try {
113
- await runOpenClaw(["gateway", "start"], 15e3);
123
+ await runOpenClaw(["gateway", "start"], 15e3, ctx);
114
124
  } catch (startErr) {
115
125
  sendStatus({
116
126
  type: "agent_setup_status",
@@ -129,7 +139,7 @@ async function handleConfigure(request, sendStatus) {
129
139
  const gatewayReady = await waitForGateway(configuredPort, gatewayToken, 3e4);
130
140
  if (!gatewayReady) {
131
141
  try {
132
- await runOpenClaw(["gateway", "status", "--require-rpc"], 1e4);
142
+ await runOpenClaw(["gateway", "status", "--require-rpc"], 1e4, ctx);
133
143
  } catch {
134
144
  return {
135
145
  type: "agent_setup_status",
@@ -182,7 +192,8 @@ async function handleQueryModels() {
182
192
  const port = await getGatewayPort() ?? DEFAULT_GATEWAY_PORT;
183
193
  const models = await fetchAvailableModels(port, gatewayToken);
184
194
  const config = await (await import("./OpenClawConfig-S7RF66V3.js")).readOpenClawConfig();
185
- const activeModel = config?.agents?.defaults?.model;
195
+ const rawModel = config?.agents?.defaults?.model;
196
+ const activeModel = typeof rawModel === "object" && rawModel !== null ? rawModel.primary ?? rawModel.id ?? String(rawModel) : rawModel;
186
197
  return { type: "query_models_result", models, activeModel };
187
198
  } catch (err) {
188
199
  console.log(` [configure] handleQueryModels error: ${err.message}`);
@@ -78,6 +78,8 @@ export declare class ChatHandler {
78
78
  private _toolUpdateTimestamps;
79
79
  /** Buffered messages when _sendBack is null (relay disconnected but OpenClaw still active). */
80
80
  private _messageBuffer;
81
+ /** Reusable shim that routes messages through _send() when _sendBack is null. */
82
+ private readonly _bufferingShim;
81
83
  /**
82
84
  * Queued outbound chat.send payloads when gateway is disconnected.
83
85
  * Drained automatically on reconnect. Max MAX_PENDING_CHAT_QUEUE entries.