# @lacneu/hindsight-openclaw

Fork of [`@vectorize-io/hindsight-openclaw`](https://github.com/vectorize-io/hindsight/tree/main/hindsight-integrations/openclaw) with a single behavioral change: **`deriveBankId` resolves the canonical user identity from `sessionKey` when OpenClaw's `session.identityLinks` is configured**.

## Why this fork

OpenClaw supports [`session.identityLinks`](https://docs.openclaw.ai/concepts/session) to unify sessions across channels for the same human user:

```json
{
  "session": {
    "dmScope": "per-channel-peer",
    "identityLinks": {
      "alice": ["telegram:123", "discord:987"]
    }
  }
}
```

Upstream `@vectorize-io/hindsight-openclaw` **does not honor this mapping when computing bank IDs** — it reads `senderId` (the raw channel peer) instead of the canonical identity resolved into `sessionKey`. Result: Alice writing from Telegram and Discord ends up with two separate Hindsight banks, breaking cross-channel memory consolidation.

This fork extracts the canonical identity from the sessionKey's `direct:<canonical>` segment and uses it as the `user` field in `dynamicBankGranularity`. One human = one bank, regardless of channel.

See upstream issues that motivated this fork:

- [openclaw/openclaw#67735](https://github.com/openclaw/openclaw/issues/67735) — WebChat does not honor identityLinks
- [openclaw/openclaw#46652](https://github.com/openclaw/openclaw/issues/46652) — Matrix identityLinks broken
- [openclaw/openclaw#52504](https://github.com/openclaw/openclaw/issues/52504) — Cross-Platform Session Continuity feature request

## Installation

```bash
openclaw plugins install @lacneu/hindsight-openclaw
```

The plugin is a drop-in replacement — it keeps the same `id: "hindsight-openclaw"` so existing configs and slot assignments (`plugins.slots.memory: "hindsight-openclaw"`) continue to work.

## Configuration (typical)

```json
{
  "session": {
    "dmScope": "per-channel-peer",
    "identityLinks": {
      "alice": ["telegram:12345", "openwebui:alice@example.com"]
    }
  },
  "plugins": {
    "entries": {
      "hindsight-openclaw": {
        "enabled": true,
        "config": {
          "bankIdPrefix": "alice",
          "dynamicBankGranularity": ["agent", "user"],
          "hindsightApiUrl": "http://hindsight:8888"
        }
      }
    }
  }
}
```

With `dynamicBankGranularity: ["agent", "user"]` and `identityLinks` configured, all channels linked to `alice` feed the same Hindsight bank.

## Backwards compatibility

The patch is purely additive. When `session.identityLinks` is not configured or the sessionKey doesn't contain a `direct:<canonical>` segment, the plugin falls back to the raw `senderId` — behavior is identical to upstream.

## Relation to upstream

Based on `@vectorize-io/hindsight-openclaw` 0.6.5. Starting with 0.7.0 this fork follows an independent semver track (0.7.x, 0.8.x, …); earlier releases used the now-retired `<upstream>-identity.<n>` scheme, which npm/OpenClaw treated as prereleases and required explicit version pinning at install time.

## License

MIT — inherited from upstream Hindsight.
