@remnic/plugin-openclaw 9.45.4 → 9.46.0

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 CHANGED
@@ -116,7 +116,7 @@ runs from real runtime and OpenClaw chain runs.
116
116
  This plugin hooks into the OpenClaw gateway lifecycle:
117
117
 
118
118
  - **`gateway_start`** -- initializes the Remnic memory engine
119
- - **`before_agent_start`** / **`before_prompt_build`** -- adds relevant memories to the agent context through OpenClaw's memory context builders
119
+ - **`before_prompt_build`** -- adds relevant memories to the agent context through OpenClaw's memory context builders
120
120
  - **`agent_end`** -- buffers the conversation turn for extraction
121
121
  - **`before_compaction`** / **`after_compaction`** -- saves checkpoints and triggers session reset on context compaction
122
122
  - **`before_reset`** -- bounded flush of the in-flight buffer before OpenClaw discards a session
@@ -348,8 +348,7 @@ Remnic supports the following OpenClaw memory integration points:
348
348
 
349
349
  | Feature | Status | Since |
350
350
  |---------|--------|-------|
351
- | `before_agent_start` hook (legacy) | Supported | 2025.x |
352
- | `before_prompt_build` hook (new SDK) | Supported | 2026.3.22 |
351
+ | `before_prompt_build` hook | Supported | 2026.3.22 |
353
352
  | `registerMemoryPromptSection()` (structured builder) | Supported | 2026.3.22 |
354
353
  | `registerMemoryCapability()` (unified capability) | Supported | 2026.4.5 |
355
354
  | `registerMemoryRuntime()` (split runtime surface) | Supported | 2026.4.x |
package/dist/index.js CHANGED
@@ -40,7 +40,11 @@ import * as logger_star from "@remnic/core/logger";
40
40
  import { detectSdkCapabilities } from "@remnic/core/sdk-compat";
41
41
 
42
42
  // ../../src/index.ts
43
- import { Orchestrator, sanitizeSessionKeyForFilename, defaultWorkspaceDir } from "@remnic/core/orchestrator";
43
+ import {
44
+ Orchestrator,
45
+ sanitizeSessionKeyForFilename,
46
+ defaultWorkspaceDir
47
+ } from "@remnic/core/orchestrator";
44
48
 
45
49
  // ../../src/tools.ts
46
50
  import { createHash as createHash2 } from "crypto";
@@ -68,11 +72,39 @@ __export(temporal_index_exports, {
68
72
  resolvePromptTagPrefilterAsync: () => resolvePromptTagPrefilterAsync
69
73
  });
70
74
  __reExport(temporal_index_exports, temporal_index_star);
71
- import { clearIndexes, clearIndexesAsync, deindexMemory, deindexMemoryAsync, extractTagsFromPrompt, indexMemoriesBatch, indexMemoriesBatchAsync, indexMemory, indexMemoryAsync, indexesExist, indexesExistAsync, isTemporalQuery, queryByDateRangeAsync, queryByTagsAsync, recencyWindowBoundsFromPrompt, recencyWindowFromPrompt, resolvePromptTagPrefilterAsync } from "@remnic/core/temporal-index";
75
+ import {
76
+ clearIndexes,
77
+ clearIndexesAsync,
78
+ deindexMemory,
79
+ deindexMemoryAsync,
80
+ extractTagsFromPrompt,
81
+ indexMemoriesBatch,
82
+ indexMemoriesBatchAsync,
83
+ indexMemory,
84
+ indexMemoryAsync,
85
+ indexesExist,
86
+ indexesExistAsync,
87
+ isTemporalQuery,
88
+ queryByDateRangeAsync,
89
+ queryByTagsAsync,
90
+ recencyWindowBoundsFromPrompt,
91
+ recencyWindowFromPrompt,
92
+ resolvePromptTagPrefilterAsync
93
+ } from "@remnic/core/temporal-index";
72
94
  import * as temporal_index_star from "@remnic/core/temporal-index";
73
95
 
74
96
  // ../../src/explicit-capture.ts
75
- import { InlineExplicitCaptureProcessor, hasInlineExplicitCaptureMarkup, parseInlineExplicitCaptureNotes, persistExplicitCapture, queueExplicitCaptureForReview, shouldProcessInlineExplicitCapture, shouldSkipImplicitExtraction, stripInlineExplicitCaptureNotes, validateExplicitCaptureInput } from "@remnic/core/explicit-capture";
97
+ import {
98
+ InlineExplicitCaptureProcessor,
99
+ hasInlineExplicitCaptureMarkup,
100
+ parseInlineExplicitCaptureNotes,
101
+ persistExplicitCapture,
102
+ queueExplicitCaptureForReview,
103
+ shouldProcessInlineExplicitCapture,
104
+ shouldSkipImplicitExtraction,
105
+ stripInlineExplicitCaptureNotes,
106
+ validateExplicitCaptureInput
107
+ } from "@remnic/core/explicit-capture";
76
108
  function mergeInlineCaptureDedupeKeys(messageKeys, fallbackDedupeKeys = []) {
77
109
  const dedupeKeys = new Set(messageKeys ?? []);
78
110
  if (dedupeKeys.size === 0) {
@@ -89,7 +121,10 @@ import { composeSalvagedEnvelope as composeSalvagedEnvelope2 } from "@remnic/cor
89
121
  // ../../src/memory-promote.ts
90
122
  import { createHash } from "crypto";
91
123
  import { composeSalvagedEnvelope } from "@remnic/core/salvage-envelope";
92
- import { STRUCTURED_ATTRIBUTE_LIMITS, TAG_LIMITS } from "@remnic/core/write-envelope";
124
+ import {
125
+ STRUCTURED_ATTRIBUTE_LIMITS,
126
+ TAG_LIMITS
127
+ } from "@remnic/core/write-envelope";
93
128
  import { stripAttributesSuffix } from "@remnic/core/storage";
94
129
  import { displayErrorDetail } from "@remnic/core/runtime/better-sqlite";
95
130
  import { isSafeRouteNamespace } from "@remnic/core/routing/engine";
@@ -185,7 +220,10 @@ import { exportWorkBoardMarkdown, exportWorkBoardSnapshot, importWorkBoardSnapsh
185
220
  import { wrapWorkLayerContext } from "@remnic/core/work/boundary";
186
221
 
187
222
  // ../../src/profiling.ts
188
- import { formatProfileTraceAscii, ProfilingCollector } from "@remnic/core/profiling";
223
+ import {
224
+ formatProfileTraceAscii,
225
+ ProfilingCollector
226
+ } from "@remnic/core/profiling";
189
227
 
190
228
  // ../../src/tools.ts
191
229
  import { runMemoryGovernance } from "@remnic/core/maintenance/memory-governance";
@@ -3036,7 +3074,10 @@ Returns: Performance trace data with timing breakdown`,
3036
3074
  import { registerLcmTools } from "@remnic/core/lcm/index";
3037
3075
  import { estimateTokens as estimateLcmTokens } from "@remnic/core/lcm/archive";
3038
3076
  import { registerCli } from "@remnic/core/cli";
3039
- import { FallbackLlmClient, fallbackLlmRuntimeContextFromConfig } from "@remnic/core/fallback-llm";
3077
+ import {
3078
+ FallbackLlmClient,
3079
+ fallbackLlmRuntimeContextFromConfig
3080
+ } from "@remnic/core/fallback-llm";
3040
3081
 
3041
3082
  // ../../src/objective-state.ts
3042
3083
  var objective_state_exports = {};
@@ -3084,7 +3125,10 @@ import { readEnvVar, resolveHomeDir as resolveHomeDir2 } from "@remnic/core/runt
3084
3125
  import { displayErrorDetail as displayErrorDetail2 } from "@remnic/core/runtime/better-sqlite";
3085
3126
 
3086
3127
  // ../../src/migrate/from-engram.ts
3087
- import { migrateFromEngram, rollbackFromEngramMigration } from "@remnic/core/migrate/from-engram";
3128
+ import {
3129
+ migrateFromEngram,
3130
+ rollbackFromEngramMigration
3131
+ } from "@remnic/core/migrate/from-engram";
3088
3132
 
3089
3133
  // ../../src/user-message-cleaning.ts
3090
3134
  var DEFAULT_CHANNEL_ENVELOPE_PREFIXES = ["OpenClaw"];
@@ -3285,7 +3329,9 @@ async function listRemnicPublicArtifacts(params) {
3285
3329
  }
3286
3330
 
3287
3331
  // src/openclaw-tools/memory-get-tool.ts
3288
- import { getMemoryForActiveMemory } from "@remnic/core";
3332
+ import {
3333
+ getMemoryForActiveMemory
3334
+ } from "@remnic/core";
3289
3335
 
3290
3336
  // src/openclaw-tools/shapes.ts
3291
3337
  import { Type as Type2 } from "@sinclair/typebox";
@@ -3338,7 +3384,9 @@ function buildMemoryGetTool(orchestrator, options = {}) {
3338
3384
  }
3339
3385
 
3340
3386
  // src/openclaw-tools/memory-search-tool.ts
3341
- import { recallForActiveMemory } from "@remnic/core";
3387
+ import {
3388
+ recallForActiveMemory
3389
+ } from "@remnic/core";
3342
3390
  function buildMemorySearchTool(orchestrator, options = {}) {
3343
3391
  const recall = options.recallForActiveMemory ?? recallForActiveMemory;
3344
3392
  return {
@@ -3368,7 +3416,9 @@ function buildMemorySearchTool(orchestrator, options = {}) {
3368
3416
 
3369
3417
  // src/runtime-surfaces.ts
3370
3418
  import { composeSalvagedEnvelope as composeSalvagedEnvelope3 } from "@remnic/core/salvage-envelope";
3371
- import { gatewayTaskChainOptions } from "@remnic/core/fallback-llm";
3419
+ import {
3420
+ gatewayTaskChainOptions
3421
+ } from "@remnic/core/fallback-llm";
3372
3422
  function resolveDreamNarrativeRoute(config, directClientAvailable) {
3373
3423
  if (config.modelSource === "gateway") {
3374
3424
  const narrativeModel = typeof config.dreaming.narrativeModel === "string" ? config.dreaming.narrativeModel.trim() : "";
@@ -4147,15 +4197,16 @@ function validateSlotSelection(ctx) {
4147
4197
  // ../../src/openclaw-flush-plan-lifecycle.ts
4148
4198
  import path2 from "path";
4149
4199
  import { createHash as createHash3, randomUUID } from "crypto";
4150
- import * as fsReadModule0 from "fs/promises";
4151
- const lstat2 = fsReadModule0.lstat;
4152
- const mkdir = fsReadModule0.mkdir;
4153
- const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
4154
- const readdir2 = fsReadModule0.readdir;
4155
- const realpath2 = fsReadModule0.realpath;
4156
- const rename = fsReadModule0.rename;
4157
- const unlink = fsReadModule0.unlink;
4158
- const writeFile = fsReadModule0.writeFile;
4200
+ import {
4201
+ lstat as lstat2,
4202
+ mkdir,
4203
+ readFile,
4204
+ readdir as readdir2,
4205
+ realpath as realpath2,
4206
+ rename,
4207
+ unlink,
4208
+ writeFile
4209
+ } from "fs/promises";
4159
4210
  var DEFAULT_MAX_IMPORT_TURN_CHARS = 4e3;
4160
4211
  var MARKER_WRITE_TEMP_ATTEMPTS = 8;
4161
4212
  var CLEANUP_SNAPSHOT_PREFIX = "flush-plan.cleanup-";
@@ -4277,7 +4328,7 @@ async function readProcessedMarker(markerPath) {
4277
4328
  try {
4278
4329
  const stat2 = await lstat2(markerPath);
4279
4330
  if (stat2.isSymbolicLink() || !stat2.isFile()) return void 0;
4280
- return parseProcessedMarker(await fileReader(markerPath, "utf8"));
4331
+ return parseProcessedMarker(await readFile(markerPath, "utf8"));
4281
4332
  } catch (error) {
4282
4333
  if (error?.code === "ENOENT") return void 0;
4283
4334
  throw error;
@@ -4348,7 +4399,7 @@ function reconcileOpenClawFlushPlanReplacementContent(params) {
4348
4399
  async function readSafeFlushPlanReplacementContent(flushPlanPath) {
4349
4400
  if (!await isSafeFlushPlanAppendTarget(flushPlanPath)) return { ok: false };
4350
4401
  try {
4351
- return { ok: true, content: await fileReader(flushPlanPath, "utf8") };
4402
+ return { ok: true, content: await readFile(flushPlanPath, "utf8") };
4352
4403
  } catch (error) {
4353
4404
  if (error?.code === "ENOENT") {
4354
4405
  return { ok: true, content: "" };
@@ -4490,7 +4541,7 @@ async function recoverInterruptedCleanupSnapshots(params) {
4490
4541
  }
4491
4542
  let currentContent;
4492
4543
  try {
4493
- currentContent = await fileReader(params.flushPlanPath, "utf8");
4544
+ currentContent = await readFile(params.flushPlanPath, "utf8");
4494
4545
  } catch (error) {
4495
4546
  if (error?.code !== "ENOENT") throw error;
4496
4547
  }
@@ -4508,7 +4559,7 @@ async function recoverInterruptedCleanupSnapshots(params) {
4508
4559
  );
4509
4560
  continue;
4510
4561
  }
4511
- const cleanupContent = await fileReader(cleanupPath, "utf8");
4562
+ const cleanupContent = await readFile(cleanupPath, "utf8");
4512
4563
  if (marker?.processedContent && cleanupContent.startsWith(marker.processedContent)) {
4513
4564
  const restoredTail = cleanupContent.slice(marker.processedContent.length);
4514
4565
  if (restoredTail.length > 0) {
@@ -4883,7 +4934,7 @@ async function readFlushPlanSnapshot(flushPlanPath) {
4883
4934
  reason: "flush plan path is not a regular file"
4884
4935
  };
4885
4936
  }
4886
- const content = await fileReader(flushPlanPath, "utf8");
4937
+ const content = await readFile(flushPlanPath, "utf8");
4887
4938
  if (!isMeaningfulFlushPlanContent(content)) {
4888
4939
  return { status: "empty", path: flushPlanPath };
4889
4940
  }
@@ -4982,7 +5033,7 @@ async function removeProcessedFlushPlanContent(params) {
4982
5033
  throw error;
4983
5034
  }
4984
5035
  }
4985
- const current = await fileReader(cleanupPath, "utf8");
5036
+ const current = await readFile(cleanupPath, "utf8");
4986
5037
  const processedStatus = params.recoveredFromMarker ? "processed_marker_recovered" : "processed";
4987
5038
  const preservedTailStatus = params.recoveredFromMarker ? "processed_marker_recovered_tail" : "processed_preserved_tail";
4988
5039
  const matchIndex = current === params.processedContent || current.startsWith(params.processedContent) ? 0 : params.allowNonPrefixMatch ? current.indexOf(params.processedContent) : -1;
@@ -5282,9 +5333,16 @@ function resolveRemnicOpenClawPluginEntry(raw, preferredId) {
5282
5333
 
5283
5334
  // src/delegate-runtime.ts
5284
5335
  import path4 from "path";
5285
- import { renderMemoryContextPrompt } from "@remnic/core";
5336
+ import {
5337
+ renderMemoryContextPrompt
5338
+ } from "@remnic/core";
5286
5339
  import { log as log2 } from "@remnic/core/logger";
5287
- import { SESSION_NAMESPACE_BINDING_MAX_ENTRIES, SESSION_NAMESPACE_BINDING_MAX_NAMESPACES, SESSION_NAMESPACE_BINDING_MAX_NAMESPACE_LENGTH, createFileSessionNamespaceBindingStore } from "@remnic/core/session-namespace-bindings";
5340
+ import {
5341
+ SESSION_NAMESPACE_BINDING_MAX_ENTRIES,
5342
+ SESSION_NAMESPACE_BINDING_MAX_NAMESPACES,
5343
+ SESSION_NAMESPACE_BINDING_MAX_NAMESPACE_LENGTH,
5344
+ createFileSessionNamespaceBindingStore
5345
+ } from "@remnic/core/session-namespace-bindings";
5288
5346
  import { createFileToggleStore } from "@remnic/core/session-toggles";
5289
5347
 
5290
5348
  // src/bridge.ts
@@ -5415,7 +5473,7 @@ function isDaemonRunning() {
5415
5473
  path3.join(resolveHomeDir(), ".engram", "server.pid")
5416
5474
  ]) {
5417
5475
  try {
5418
- const pid = parseInt(fs["re"+"ad"+"Fi"+"le"+"Sync"](pidFile, "utf8").trim(), 10);
5476
+ const pid = parseInt(fs.readFileSync(pidFile, "utf8").trim(), 10);
5419
5477
  process.kill(pid, 0);
5420
5478
  return true;
5421
5479
  } catch {
@@ -5478,7 +5536,7 @@ function readDaemonHost() {
5478
5536
  for (const p of configPathCandidates()) {
5479
5537
  if (!fs.existsSync(p)) continue;
5480
5538
  try {
5481
- const raw = JSON.parse(fs["re"+"ad"+"Fi"+"le"+"Sync"](p, "utf8"));
5539
+ const raw = JSON.parse(fs.readFileSync(p, "utf8"));
5482
5540
  const configHost = raw.server?.host;
5483
5541
  if (typeof configHost === "string" && configHost.trim() !== "") {
5484
5542
  return normalizeDaemonHost(configHost);
@@ -5494,7 +5552,7 @@ function readDaemonPort() {
5494
5552
  for (const p of configPathCandidates()) {
5495
5553
  if (!fs.existsSync(p)) continue;
5496
5554
  try {
5497
- const raw = JSON.parse(fs["re"+"ad"+"Fi"+"le"+"Sync"](p, "utf8"));
5555
+ const raw = JSON.parse(fs.readFileSync(p, "utf8"));
5498
5556
  const configPort = coerceDaemonPort(raw.server?.port);
5499
5557
  if (configPort !== void 0) return configPort;
5500
5558
  } catch {
@@ -5564,8 +5622,8 @@ function isOpenClawTokenEntry(value) {
5564
5622
  function loadDaemonAuth() {
5565
5623
  const environmentTokens = [
5566
5624
  ["OPENCLAW_REMNIC_ACCESS_TOKEN", readEnv("OPENCLAW_REMNIC_ACCESS_TOKEN")],
5567
- ["OPENCLAW_ENGRAM_ACCESS_TOKEN", readEnv("OPENCLAW_ENGRAM_ACCESS_TOKEN")],
5568
5625
  ["REMNIC_AUTH_TOKEN", readEnv("REMNIC_AUTH_TOKEN")],
5626
+ ["OPENCLAW_ENGRAM_ACCESS_TOKEN", readEnv("OPENCLAW_ENGRAM_ACCESS_TOKEN")],
5569
5627
  ["ENGRAM_AUTH_TOKEN", readEnv("ENGRAM_AUTH_TOKEN")]
5570
5628
  ];
5571
5629
  for (const [source, token] of environmentTokens) {
@@ -5578,7 +5636,7 @@ function loadDaemonAuth() {
5578
5636
  for (const tokenStore of tokenStores) {
5579
5637
  if (!fs.existsSync(tokenStore.path)) continue;
5580
5638
  try {
5581
- const store = JSON.parse(fs["re"+"ad"+"Fi"+"le"+"Sync"](tokenStore.path, "utf8"));
5639
+ const store = JSON.parse(fs.readFileSync(tokenStore.path, "utf8"));
5582
5640
  const tokens = Array.isArray(store.tokens) ? store.tokens : [];
5583
5641
  const openClawToken = tokens.find(isOpenClawTokenEntry)?.token;
5584
5642
  if (typeof openClawToken === "string" && openClawToken.length > 0) {
@@ -5594,8 +5652,8 @@ function loadDaemonAuth() {
5594
5652
  try {
5595
5653
  for (const configPath of configPathCandidates()) {
5596
5654
  if (!fs.existsSync(configPath)) continue;
5597
- const raw = JSON.parse(fs["re"+"ad"+"Fi"+"le"+"Sync"](configPath, "utf8"));
5598
- const token = raw.server?.["auth"+"Token"];
5655
+ const raw = JSON.parse(fs.readFileSync(configPath, "utf8"));
5656
+ const token = raw.server?.authToken;
5599
5657
  if (typeof token === "string" && token.length > 0) {
5600
5658
  return { token, source: "daemon configuration" };
5601
5659
  }
@@ -5880,7 +5938,7 @@ function registerDelegateRuntime(api, options) {
5880
5938
  if (options.allowPromptInjection && options.recallBudgetChars !== 0) {
5881
5939
  const promptLinesBySession = /* @__PURE__ */ new Map();
5882
5940
  const useSectionBuilder = typeof api.registerMemoryPromptSection === "function";
5883
- const recallHandler = async (hook, event, ctx) => {
5941
+ const recallHandler = async (event, ctx) => {
5884
5942
  const query = recallQueryFrom(event);
5885
5943
  if (query.trim().length < 5) return void 0;
5886
5944
  const sessionKey = sessionKeyFrom(event, ctx);
@@ -5931,7 +5989,7 @@ function registerDelegateRuntime(api, options) {
5931
5989
  promptLinesBySession.set(sessionKey, rendered.lines);
5932
5990
  return void 0;
5933
5991
  }
5934
- return hook === "before_prompt_build" ? { prependSystemContext: prompt } : { prependSystemContext: prompt, prependContext: prompt };
5992
+ return { prependSystemContext: prompt };
5935
5993
  } catch (err) {
5936
5994
  log2.warn(`delegate recall failed: ${String(err)}`);
5937
5995
  return void 0;
@@ -5939,12 +5997,7 @@ function registerDelegateRuntime(api, options) {
5939
5997
  };
5940
5998
  api.on(
5941
5999
  "before_prompt_build",
5942
- (event, ctx) => recallHandler("before_prompt_build", event, ctx),
5943
- { timeoutMs: options.hookTimeoutMs }
5944
- );
5945
- api.on(
5946
- "before_agent_start",
5947
- (event, ctx) => recallHandler("before_agent_start", event, ctx),
6000
+ (event, ctx) => recallHandler(event, ctx),
5948
6001
  { timeoutMs: options.hookTimeoutMs }
5949
6002
  );
5950
6003
  if (useSectionBuilder && api.registerMemoryPromptSection) {
@@ -6472,8 +6525,16 @@ function buildTurnFingerprint(input) {
6472
6525
 
6473
6526
  // ../../src/index.ts
6474
6527
  import { planRecallMode } from "@remnic/core/intent";
6475
- import { expandTildePath as expandTildePath2, renderMemoryContextPrompt as renderSharedMemoryContextPrompt, resolveAgentAccessAuthToken as resolveAgentAccessAuthCredential, resolvePrincipal } from "@remnic/core";
6476
- import { normalizeHostEmbeddingVector, registerHostEmbeddingProvider } from "@remnic/core/host-embedding-provider";
6528
+ import {
6529
+ expandTildePath as expandTildePath2,
6530
+ renderMemoryContextPrompt as renderSharedMemoryContextPrompt,
6531
+ resolveAgentAccessAuthToken,
6532
+ resolvePrincipal
6533
+ } from "@remnic/core";
6534
+ import {
6535
+ normalizeHostEmbeddingVector,
6536
+ registerHostEmbeddingProvider
6537
+ } from "@remnic/core/host-embedding-provider";
6477
6538
 
6478
6539
  // ../../src/resolve-provider-secret.ts
6479
6540
  var resolve_provider_secret_exports = {};
@@ -6484,7 +6545,7 @@ __reExport(resolve_provider_secret_exports, resolve_provider_secret_star);
6484
6545
  import path5 from "path";
6485
6546
  import * as resolve_provider_secret_star from "@remnic/core/resolve-provider-secret";
6486
6547
  async function findGatewayRuntimeModules(filePrefix) {
6487
- const { existsSync, ["re"+"ad"+"Fi"+"le"+"Sync"]: fileReaderSync, readdirSync, realpathSync } = await import("fs");
6548
+ const { existsSync, readFileSync, readdirSync, realpathSync } = await import("fs");
6488
6549
  const { createRequire: createRequire2 } = await import("module");
6489
6550
  const candidates = [];
6490
6551
  const isWithinRoot = (root, candidate) => {
@@ -6499,7 +6560,7 @@ async function findGatewayRuntimeModules(filePrefix) {
6499
6560
  while (true) {
6500
6561
  const packageJsonPath = path5.join(currentDir, "package.json");
6501
6562
  if (existsSync(packageJsonPath)) {
6502
- const packageJson = JSON.parse(fileReaderSync(packageJsonPath, "utf8"));
6563
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
6503
6564
  if (packageJson.name !== "openclaw") {
6504
6565
  return [];
6505
6566
  }
@@ -6622,7 +6683,7 @@ function fileExistsNow(filePath) {
6622
6683
  }
6623
6684
  async function readTextFileLater(filePath) {
6624
6685
  const fs2 = await import(NODE_FS_PROMISES_MODULE_ID);
6625
- return fs2["re"+"ad"+"Fi"+"le"](filePath, "utf-8");
6686
+ return fs2.readFile(filePath, "utf-8");
6626
6687
  }
6627
6688
  async function writeTextFileLater(filePath, data) {
6628
6689
  const fs2 = await import(NODE_FS_PROMISES_MODULE_ID);
@@ -6796,7 +6857,7 @@ async function loadOpenClawProviderAuthRuntimeModule() {
6796
6857
  );
6797
6858
  return null;
6798
6859
  }
6799
- async function resolveOpenClawProviderCredential(params) {
6860
+ async function resolveOpenClawProviderApiKey(params) {
6800
6861
  const mod = await loadOpenClawProviderAuthRuntimeModule();
6801
6862
  const resolver = mod?.resolveApiKeyForProvider;
6802
6863
  if (typeof resolver !== "function") return null;
@@ -7329,7 +7390,7 @@ var pluginDefinition = {
7329
7390
  fileConfig ?? {},
7330
7391
  runtimeSet
7331
7392
  );
7332
- cfg.providerApiKeyResolver = resolveOpenClawProviderCredential;
7393
+ cfg.providerApiKeyResolver = resolveOpenClawProviderApiKey;
7333
7394
  cfg.runtimeAuthForModelResolver = getOpenClawRuntimeAuthForModel;
7334
7395
  (0, logger_exports.initLogger)(api.logger, cfg.debug);
7335
7396
  logger_exports.log.info(
@@ -7438,19 +7499,19 @@ var pluginDefinition = {
7438
7499
  resolveSecretRef: (ref, context) => loadOpenClawSecretRefResolver().then((resolver) => resolver ? resolver(ref, context) : void 0)
7439
7500
  });
7440
7501
  globalThis[keys.ACCESS_SERVICE] = accessService;
7441
- const rawAuthCredential = cfg.agentAccessHttp["auth"+"Token"];
7442
- const authCredentialIsSecretRef = rawAuthCredential !== void 0 && typeof rawAuthCredential !== "string";
7502
+ const rawAuthToken = cfg.agentAccessHttp.authToken;
7503
+ const authTokenIsSecretRef = rawAuthToken !== void 0 && typeof rawAuthToken !== "string";
7443
7504
  const accessHttpAuthState = globalThis[keys.ACCESS_HTTP_AUTH_STATE] ??= {
7444
7505
  resolvedSecretRefAuthToken: void 0
7445
7506
  };
7446
- const authCredentialsFromSecretRef = () => accessHttpAuthState.resolvedSecretRefAuthToken ? [accessHttpAuthState.resolvedSecretRefAuthToken] : [];
7507
+ const authTokensFromSecretRef = () => accessHttpAuthState.resolvedSecretRefAuthToken ? [accessHttpAuthState.resolvedSecretRefAuthToken] : [];
7447
7508
  const existingAccessHttpServer = globalThis[keys.ACCESS_HTTP_SERVER];
7448
7509
  const accessHttpServer = existingAccessHttpServer && existingAccessHttpServer ? existingAccessHttpServer : new access_http_exports.EngramAccessHttpServer({
7449
7510
  service: accessService,
7450
7511
  host: cfg.agentAccessHttp.host,
7451
7512
  port: cfg.agentAccessHttp.port,
7452
- ["auth"+"Token"]: authCredentialIsSecretRef ? void 0 : rawAuthCredential,
7453
- authTokensGetter: authCredentialIsSecretRef ? authCredentialsFromSecretRef : void 0,
7513
+ authToken: authTokenIsSecretRef ? void 0 : rawAuthToken,
7514
+ authTokensGetter: authTokenIsSecretRef ? authTokensFromSecretRef : void 0,
7454
7515
  principal: cfg.agentAccessHttp.principal,
7455
7516
  maxBodyBytes: cfg.agentAccessHttp.maxBodyBytes,
7456
7517
  writeRateLimitMaxRequests: cfg.agentAccessHttp.writeRateLimitMaxRequests,
@@ -7469,7 +7530,7 @@ var pluginDefinition = {
7469
7530
  const dreamsSurface = createDreamsSurface();
7470
7531
  const heartbeatSurface = createHeartbeatSurface();
7471
7532
  const dreamNarrativeClient = cfg.openaiApiKey ? new OpenAI({
7472
- ["api"+"Key"]: cfg.openaiApiKey,
7533
+ apiKey: cfg.openaiApiKey,
7473
7534
  ...cfg.openaiBaseUrl ? { baseURL: cfg.openaiBaseUrl } : {}
7474
7535
  }) : null;
7475
7536
  let stopDreamWatcher = null;
@@ -8321,7 +8382,8 @@ Keep the reflection grounded in the evidence below.
8321
8382
  }
8322
8383
  return lines;
8323
8384
  }
8324
- async function recallHookHandler(hookLabel, event, ctx) {
8385
+ async function recallHookHandler(event, ctx) {
8386
+ const hookLabel = "before_prompt_build";
8325
8387
  let prompt = event.prompt;
8326
8388
  if ((!prompt || prompt.length < 5) && Array.isArray(event.messages)) {
8327
8389
  const msgs = event.messages;
@@ -8346,7 +8408,7 @@ Keep the reflection grounded in the evidence below.
8346
8408
  );
8347
8409
  codexCompactionModeLogged = true;
8348
8410
  }
8349
- if (hookLabel === "before_prompt_build" && cfg.codexCompat.enabled !== false && sessionIdentity.codexThreadBound && sessionIdentity.providerThreadId && (cfg.codexCompat.compactionFlushMode === "heuristic" || cfg.codexCompat.compactionFlushMode === "auto")) {
8411
+ if (cfg.codexCompat.enabled !== false && sessionIdentity.codexThreadBound && sessionIdentity.providerThreadId && (cfg.codexCompat.compactionFlushMode === "heuristic" || cfg.codexCompat.compactionFlushMode === "auto")) {
8350
8412
  const currentCount = sessionIdentity.messageCount;
8351
8413
  const codexBaselineKey = resolveCodexCompactionBaselineKey2(
8352
8414
  sessionKey,
@@ -8434,14 +8496,7 @@ Keep the reflection grounded in the evidence below.
8434
8496
  summary: null
8435
8497
  });
8436
8498
  const verbosePrompt = verboseLines.join("\n").replace(/\n$/, "");
8437
- if (hookLabel === "before_prompt_build") {
8438
- return useMemoryPromptSection ? { memoryLines: verboseLines } : { prependSystemContext: verbosePrompt, memoryLines: verboseLines };
8439
- }
8440
- return {
8441
- prependSystemContext: verbosePrompt,
8442
- prependContext: verbosePrompt,
8443
- memoryLines: verboseLines
8444
- };
8499
+ return useMemoryPromptSection ? { memoryLines: verboseLines } : { prependSystemContext: verbosePrompt, memoryLines: verboseLines };
8445
8500
  }
8446
8501
  try {
8447
8502
  await orchestrator.maybeRunFileHygiene().catch(() => void 0);
@@ -8465,14 +8520,7 @@ Keep the reflection grounded in the evidence below.
8465
8520
  }) : [];
8466
8521
  const mergedLines = [...verboseLines2, ...heartbeatLines];
8467
8522
  const heartbeatPrompt = mergedLines.join("\n").replace(/\n$/, "");
8468
- if (hookLabel === "before_prompt_build") {
8469
- return useMemoryPromptSection ? { memoryLines: mergedLines } : { prependSystemContext: heartbeatPrompt, memoryLines: mergedLines };
8470
- }
8471
- return {
8472
- prependSystemContext: heartbeatPrompt,
8473
- prependContext: heartbeatPrompt,
8474
- memoryLines: mergedLines
8475
- };
8523
+ return useMemoryPromptSection ? { memoryLines: mergedLines } : { prependSystemContext: heartbeatPrompt, memoryLines: mergedLines };
8476
8524
  }
8477
8525
  if (orchestrator.config.compactionResetEnabled) {
8478
8526
  const agentWorkspace = ctx?.workspaceDir;
@@ -8569,14 +8617,7 @@ Keep the reflection grounded in the evidence below.
8569
8617
  });
8570
8618
  }
8571
8619
  if (mergedLines.length === 0) return;
8572
- if (hookLabel === "before_prompt_build") {
8573
- return useMemoryPromptSection ? { memoryLines: mergedLines } : { prependSystemContext: auxiliaryPrompt, memoryLines: mergedLines };
8574
- }
8575
- return {
8576
- prependSystemContext: auxiliaryPrompt,
8577
- prependContext: auxiliaryPrompt,
8578
- memoryLines: mergedLines
8579
- };
8620
+ return useMemoryPromptSection ? { memoryLines: mergedLines } : { prependSystemContext: auxiliaryPrompt, memoryLines: mergedLines };
8580
8621
  }
8581
8622
  const memoryContext = renderMemoryContext2(recallComposition);
8582
8623
  if (!memoryContext) return;
@@ -8622,14 +8663,7 @@ Keep the reflection grounded in the evidence below.
8622
8663
  logger_exports.log.debug(
8623
8664
  `${hookLabel}: returning memory context with ${trimmed.length} chars`
8624
8665
  );
8625
- if (hookLabel === "before_prompt_build") {
8626
- return promptWithVerbose ? { prependSystemContext: promptWithVerbose, memoryLines } : { memoryLines };
8627
- }
8628
- return promptWithVerbose ? {
8629
- prependSystemContext: promptWithVerbose,
8630
- prependContext: promptWithVerbose,
8631
- memoryLines
8632
- } : { memoryLines };
8666
+ return promptWithVerbose ? { prependSystemContext: promptWithVerbose, memoryLines } : { memoryLines };
8633
8667
  } catch (err) {
8634
8668
  logger_exports.log.error("recall failed", err);
8635
8669
  lastRecallSummaryBySession.set(sessionKey, null);
@@ -8659,7 +8693,7 @@ Keep the reflection grounded in the evidence below.
8659
8693
  null
8660
8694
  );
8661
8695
  }
8662
- const result = await recallHookHandler("before_prompt_build", event, ctx);
8696
+ const result = await recallHookHandler(event, ctx);
8663
8697
  if (needsCacheFallback && result?.memoryLines) {
8664
8698
  cachePromptMemoryLines2(
8665
8699
  sessionKey,
@@ -8676,18 +8710,6 @@ Keep the reflection grounded in the evidence below.
8676
8710
  { timeoutMs: cfg.initGateTimeoutMs }
8677
8711
  );
8678
8712
  })(api);
8679
- } else {
8680
- api.on(
8681
- "before_agent_start",
8682
- async (event, ctx) => {
8683
- const result = await recallHookHandler("before_agent_start", event, ctx);
8684
- if (result && "memoryLines" in result) {
8685
- const { memoryLines: _ml, ...gatewayResult } = result;
8686
- return Object.keys(gatewayResult).length > 0 ? gatewayResult : void 0;
8687
- }
8688
- return result;
8689
- }
8690
- );
8691
8713
  }
8692
8714
  }
8693
8715
  let memoryPromptBuilder;
@@ -8704,7 +8726,7 @@ Keep the reflection grounded in the evidence below.
8704
8726
  const sessionKey = ctx?.sessionKey ?? "default";
8705
8727
  const sessionIdentity = resolveSessionIdentity2(sessionKey, event, ctx);
8706
8728
  cachePromptMemoryLines2(sessionKey, sessionIdentity.providerThreadId, null);
8707
- const result = await recallHookHandler("before_prompt_build", event, ctx);
8729
+ const result = await recallHookHandler(event, ctx);
8708
8730
  if (result?.memoryLines) {
8709
8731
  cachePromptMemoryLines2(
8710
8732
  sessionKey,
@@ -8871,7 +8893,7 @@ Keep the reflection grounded in the evidence below.
8871
8893
  (result) => typeof opts?.minScore === "number" && Number.isFinite(opts.minScore) ? result.score >= opts.minScore : true
8872
8894
  );
8873
8895
  },
8874
- async ["re"+"ad"+"Fi"+"le"](params) {
8896
+ async readFile(params) {
8875
8897
  const requestedPath = normalizeWorkspacePath(params.relPath);
8876
8898
  const absolutePath = await resolveReadablePath(params.relPath);
8877
8899
  const text = await readTextFileLater(absolutePath);
@@ -9647,51 +9669,6 @@ Keep the reflection grounded in the evidence below.
9647
9669
  );
9648
9670
  }
9649
9671
  );
9650
- } else if (!passiveMode) {
9651
- const runtimeApi = api;
9652
- runtimeApi.registerHook?.(
9653
- ["agent_heartbeat", "agent:heartbeat"],
9654
- (event) => {
9655
- if (orchestrator.config.sessionObserverEnabled !== true) return;
9656
- const sessionKey = event?.context?.sessionKey ?? "default";
9657
- const rememberedThreadId = resolveStoredCodexThreadId2(sessionKey);
9658
- const bufferKey = resolveExtractionBufferKey2(
9659
- sessionKey,
9660
- rememberedThreadId && cfg.codexCompat.threadIdBufferKeying !== false ? codexLogicalSessionKey(rememberedThreadId) : sessionKey
9661
- );
9662
- void orchestrator.observeSessionHeartbeat(sessionKey, { bufferKey }).catch((err) => {
9663
- logger_exports.log.debug(`agent_heartbeat observer failed: ${err}`);
9664
- });
9665
- },
9666
- {
9667
- name: "engram_agent_heartbeat_legacy",
9668
- description: "Observe legacy heartbeat events for session observation."
9669
- }
9670
- );
9671
- const runtimeVersion = runtimeApi.runtime?.version || readEnvVar("OPENCLAW_SERVICE_VERSION") || "unknown";
9672
- void import("./legacy-hook-compat-QHHKF4GK.js").then(({ shouldRegisterTypedAgentHeartbeat }) => {
9673
- if (shouldRegisterTypedAgentHeartbeat(runtimeVersion)) {
9674
- api.on(
9675
- "agent_heartbeat",
9676
- (_event, ctx) => {
9677
- if (orchestrator.config.sessionObserverEnabled !== true) return;
9678
- const sessionKey = ctx?.sessionKey ?? "default";
9679
- const rememberedThreadId = resolveStoredCodexThreadId2(sessionKey);
9680
- const bufferKey = resolveExtractionBufferKey2(
9681
- sessionKey,
9682
- rememberedThreadId && cfg.codexCompat.threadIdBufferKeying !== false ? codexLogicalSessionKey(rememberedThreadId) : sessionKey
9683
- );
9684
- void orchestrator.observeSessionHeartbeat(sessionKey, { bufferKey }).catch((err) => {
9685
- logger_exports.log.debug(`agent_heartbeat typed observer failed: ${err}`);
9686
- });
9687
- }
9688
- );
9689
- logger_exports.log.info(
9690
- `registered typed agent_heartbeat hook for OpenClaw ${runtimeVersion}`
9691
- );
9692
- }
9693
- }).catch(() => {
9694
- });
9695
9672
  }
9696
9673
  }
9697
9674
  async function ensureHourlySummaryCron(api2) {
@@ -10017,8 +9994,8 @@ Keep the reflection grounded in the evidence below.
10017
9994
  }
10018
9995
  if (cfg.agentAccessHttp.enabled) {
10019
9996
  if (!didCountStart) return;
10020
- if (authCredentialIsSecretRef) {
10021
- const resolved = await resolveAgentAccessAuthCredential(rawAuthCredential, {
9997
+ if (authTokenIsSecretRef) {
9998
+ const resolved = await resolveAgentAccessAuthToken(rawAuthToken, {
10022
9999
  resolveSecretRef: await loadOpenClawSecretRefResolver()
10023
10000
  });
10024
10001
  if (!resolved) {
@@ -10298,4 +10275,17 @@ async function resolveFlushPlanProcessingChainKey(workspaceRoot) {
10298
10275
  }
10299
10276
  }
10300
10277
  var export_loadDaySummaryPrompt = day_summary_exports.loadDaySummaryPrompt;
10301
- export { buildHourlySummaryCronJob, checkDaemonHealth, src_default as default, detectBridgeMode, embedWithOpenClawProvider, listRemnicPublicArtifacts, export_loadDaySummaryPrompt as loadDaySummaryPrompt, loadHourlySummaryCronJobsData, loadOpenClawMemoryEmbeddingSdk, parseHourlySummaryCronJobsData, reconcileHourlySummaryCronRouting, selectOpenClawMemoryEmbeddingSdk };
10278
+ export {
10279
+ buildHourlySummaryCronJob,
10280
+ checkDaemonHealth,
10281
+ src_default as default,
10282
+ detectBridgeMode,
10283
+ embedWithOpenClawProvider,
10284
+ listRemnicPublicArtifacts,
10285
+ export_loadDaySummaryPrompt as loadDaySummaryPrompt,
10286
+ loadHourlySummaryCronJobsData,
10287
+ loadOpenClawMemoryEmbeddingSdk,
10288
+ parseHourlySummaryCronJobsData,
10289
+ reconcileHourlySummaryCronRouting,
10290
+ selectOpenClawMemoryEmbeddingSdk
10291
+ };