@twsxtd/hapi-openclaw 0.1.1 → 0.1.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.
Files changed (2) hide show
  1. package/dist/index.js +7 -23
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -106,17 +106,6 @@ function resolvePluginConfig(value) {
106
106
  prototypeCaptureFileName: readOptionalNonEmptyString(value.prototypeCaptureFileName) ?? "transcript-capture.jsonl"
107
107
  };
108
108
  }
109
- function resolvePluginConfigFromOpenClawConfig(config) {
110
- const pluginConfig = config.plugins?.entries?.[OPENCLAW_PLUGIN_ID]?.config;
111
- if (!pluginConfig) {
112
- return null;
113
- }
114
- try {
115
- return resolvePluginConfig(pluginConfig);
116
- } catch {
117
- return null;
118
- }
119
- }
120
109
 
121
110
  // src/nativeRoute.ts
122
111
  import { Readable } from "node:stream";
@@ -537,16 +526,11 @@ async function handleTranscriptUpdate(ctx, callbackClient, update) {
537
526
  });
538
527
  }
539
528
  }
540
- function createTranscriptBridgeService() {
529
+ function createTranscriptBridgeService(config) {
541
530
  let stopListening = null;
542
531
  return {
543
532
  id: `${OPENCLAW_PLUGIN_ID}:transcript-bridge`,
544
533
  async start(ctx) {
545
- const config = resolvePluginConfigFromOpenClawConfig(ctx.config);
546
- if (!config) {
547
- ctx.logger.warn(`Skipping ${OPENCLAW_PLUGIN_ID} transcript bridge because plugin config is unavailable`);
548
- return;
549
- }
550
534
  const callbackClient = new HapiCallbackClient(config.hapiBaseUrl, config.sharedSecret);
551
535
  const runtime = runtimeStore.getRuntime();
552
536
  stopListening = runtime.events.onSessionTranscriptUpdate((update) => {
@@ -569,7 +553,7 @@ import { appendFile, mkdir } from "node:fs/promises";
569
553
  import { join } from "node:path";
570
554
  var CAPTURE_DIRECTORY = "hapi-openclaw";
571
555
  function resolveCaptureFilePath(ctx, config) {
572
- const fileName = config?.prototypeCaptureFileName ?? "transcript-capture.jsonl";
556
+ const fileName = config.prototypeCaptureFileName;
573
557
  return join(ctx.stateDir, CAPTURE_DIRECTORY, fileName);
574
558
  }
575
559
  async function writeCaptureRecord(ctx, config, record) {
@@ -579,18 +563,17 @@ async function writeCaptureRecord(ctx, config, record) {
579
563
  `, "utf8");
580
564
  }
581
565
  function shouldCapture(config, sessionKey) {
582
- if (!config?.prototypeCaptureSessionKey) {
566
+ if (!config.prototypeCaptureSessionKey) {
583
567
  return false;
584
568
  }
585
569
  return sessionKey === config.prototypeCaptureSessionKey;
586
570
  }
587
- function createTranscriptCaptureService() {
571
+ function createTranscriptCaptureService(config) {
588
572
  let stopListening = null;
589
573
  return {
590
574
  id: `${OPENCLAW_PLUGIN_ID}:transcript-capture`,
591
575
  async start(ctx) {
592
576
  const runtime = runtimeStore.getRuntime();
593
- const config = resolvePluginConfigFromOpenClawConfig(ctx.config);
594
577
  stopListening = runtime.events.onSessionTranscriptUpdate((update) => {
595
578
  if (!shouldCapture(config, update.sessionKey)) {
596
579
  return;
@@ -2344,8 +2327,9 @@ var src_default = definePluginEntry({
2344
2327
  }
2345
2328
  runtimeStore.setRuntime(api.runtime);
2346
2329
  registerPluginRoutes(api);
2347
- api.registerService(createTranscriptBridgeService());
2348
- api.registerService(createTranscriptCaptureService());
2330
+ const config = resolvePluginConfig(api.pluginConfig ?? {});
2331
+ api.registerService(createTranscriptBridgeService(config));
2332
+ api.registerService(createTranscriptCaptureService(config));
2349
2333
  }
2350
2334
  });
2351
2335
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twsxtd/hapi-openclaw",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
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",