@twsxtd/hapi-openclaw 0.1.6 → 0.1.7

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.
Files changed (2) hide show
  1. package/dist/index.js +14 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -302,11 +302,13 @@ class RealOpenClawAdapter {
302
302
  namespace;
303
303
  runtime;
304
304
  callbackClient;
305
+ logger;
305
306
  supportsApprovals = false;
306
- constructor(namespace, runtime, callbackClient) {
307
+ constructor(namespace, runtime, callbackClient, logger) {
307
308
  this.namespace = namespace;
308
309
  this.runtime = runtime;
309
310
  this.callbackClient = callbackClient;
311
+ this.logger = logger;
310
312
  }
311
313
  async ensureDefaultConversation(externalUserKey) {
312
314
  return {
@@ -322,6 +324,7 @@ class RealOpenClawAdapter {
322
324
  throw new ConversationBusyError;
323
325
  }
324
326
  const namespace = getStateNamespace(action.conversationId, this.namespace);
327
+ this.logger.info(`[${namespace}] hapi-openclaw send-message start conversation=${action.conversationId}`);
325
328
  await this.callbackClient.postEvent(createStateEvent({
326
329
  namespace,
327
330
  conversationId: action.conversationId,
@@ -336,6 +339,7 @@ class RealOpenClawAdapter {
336
339
  })).dir;
337
340
  const agentDir = this.runtime.agent.resolveAgentDir(config, agentId);
338
341
  const { sessionId, sessionFile } = await ensureSessionBinding(this.runtime, action.conversationId, agentId);
342
+ this.logger.info(`[${namespace}] hapi-openclaw runEmbeddedPiAgent sessionId=${sessionId} agentId=${agentId}`);
339
343
  const result = await this.runtime.agent.runEmbeddedPiAgent({
340
344
  sessionId,
341
345
  sessionKey: action.conversationId,
@@ -351,6 +355,7 @@ class RealOpenClawAdapter {
351
355
  });
352
356
  const runError = result.meta.error?.message?.trim() || null;
353
357
  if (runError) {
358
+ this.logger.warn(`[${namespace}] hapi-openclaw run failed conversation=${action.conversationId}: ${runError}`);
354
359
  if (adapterState.finishRun(action.conversationId)) {
355
360
  await this.callbackClient.postEvent(createStateEvent({
356
361
  namespace,
@@ -361,6 +366,7 @@ class RealOpenClawAdapter {
361
366
  }
362
367
  return;
363
368
  }
369
+ this.logger.info(`[${namespace}] hapi-openclaw run completed conversation=${action.conversationId}` + (result.meta.finalAssistantVisibleText ? ` finalText=${JSON.stringify(result.meta.finalAssistantVisibleText)}` : ""));
364
370
  if (result.meta.finalAssistantVisibleText) {
365
371
  await delay(RUN_COMPLETION_SETTLE_MS);
366
372
  }
@@ -374,6 +380,7 @@ class RealOpenClawAdapter {
374
380
  }
375
381
  } catch (error2) {
376
382
  const message = error2 instanceof Error ? error2.message : "OpenClaw embedded run failed";
383
+ this.logger.error(`[${namespace}] hapi-openclaw send-message error conversation=${action.conversationId}: ${message}`);
377
384
  if (adapterState.finishRun(action.conversationId)) {
378
385
  await this.callbackClient.postEvent(createStateEvent({
379
386
  namespace,
@@ -2205,6 +2212,7 @@ function createPluginApp(deps) {
2205
2212
  retryAfterMs: null
2206
2213
  };
2207
2214
  deps.idempotencyCache.set(idempotencyKey, ack);
2215
+ deps.logger.info(`[${deps.namespace}] hapi-openclaw accepted send-message conversation=${body.conversationId} localMessageId=${body.localMessageId}`);
2208
2216
  queueMicrotask(() => {
2209
2217
  deps.runtime.sendMessage({
2210
2218
  kind: "send-message",
@@ -2215,8 +2223,10 @@ function createPluginApp(deps) {
2215
2223
  await dispatchMaybeEvents(deps.callbackClient, events);
2216
2224
  }).catch((error2) => {
2217
2225
  if (error2 instanceof ConversationBusyError) {
2226
+ deps.logger.warn(`[${deps.namespace}] hapi-openclaw conversation busy conversation=${body.conversationId}`);
2218
2227
  return;
2219
2228
  }
2229
+ deps.logger.error(`[${deps.namespace}] hapi-openclaw send-message task failed conversation=${body.conversationId}: ` + (error2 instanceof Error ? error2.message : String(error2)));
2220
2230
  });
2221
2231
  });
2222
2232
  return c.json(ack);
@@ -2311,7 +2321,7 @@ function resolveRegisteredPluginConfig(api) {
2311
2321
  function registerPluginRoutes(api) {
2312
2322
  const config = resolveRegisteredPluginConfig(api);
2313
2323
  const callbackClient = new HapiCallbackClient(config.hapiBaseUrl, config.sharedSecret);
2314
- const runtime = new RealOpenClawAdapter(config.namespace, api.runtime, callbackClient);
2324
+ const runtime = new RealOpenClawAdapter(config.namespace, api.runtime, callbackClient, api.logger);
2315
2325
  const app = createPluginApp({
2316
2326
  sharedSecret: config.sharedSecret,
2317
2327
  namespace: config.namespace,
@@ -2319,7 +2329,8 @@ function registerPluginRoutes(api) {
2319
2329
  runtime,
2320
2330
  idempotencyCache: new Map,
2321
2331
  prototypeCaptureSessionKey: config.prototypeCaptureSessionKey,
2322
- prototypeCaptureFileName: config.prototypeCaptureFileName
2332
+ prototypeCaptureFileName: config.prototypeCaptureFileName,
2333
+ logger: api.logger
2323
2334
  });
2324
2335
  api.registerHttpRoute({
2325
2336
  path: "/hapi",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twsxtd/hapi-openclaw",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Native OpenClaw plugin that bridges HAPI to the OpenClaw Gateway route surface.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",