# Changelog

## 0.2.0

- Ported the **entire memory-service API surface** of `@tablestore/agent-storage` (`AgentStorageClient`) into the plugin. All 22 memory methods are now reachable, up from the 10 previously wired.
- Introduced a single source of truth (`MEMORY_METHODS`) for the memory API surface, shared by the internal path-based dispatch and the new generic `call` command. This also **removed a dead `/DescribeMemoryStore -> describeMemoryStore` mapping** — the SDK has no such method, so any call would have thrown "method not found".
- New generic passthrough CLI command: `openclaw tablestore-mem call <method> [--json | --file] [--uid]` dispatches to any of the 22 memory methods by name (camelCase) or `/PascalCase` path, with an allowlist guard, default `memoryStoreName` injection, and optional `--uid` scope injection (only when the body omits `scope`). CLI-only, since it can reach destructive methods.
- New first-class CLI subcommands for the high-value methods, each with `--uid` scope handling and pagination (`--limit` / `--next-token`):
  - `memory get|update|delete` (getMemory / updateMemory / deleteMemory)
  - `stores list|delete` (listMemoryStores / deleteMemoryStore)
  - `messages` / `requests` (listMemoryStoreMessages / listMemoryStoreRequests)
  - `tasks list|get` (listMemoryTasks / getMemoryTask)
  - `dream-tasks list|cancel` (listMemoryDreamTasks / cancelMemoryDreamTask)
  - `dream-actions list|apply` (listMemoryDreamActions / applyMemoryDreamActions)
- Destructive commands (`memory delete`, `stores delete`, `dream-tasks cancel`) require `--yes`; without it they abort and make no API call.
- New read-only slash commands: `/tablestore-mem-get <memoryId>` and `/tablestore-mem-dream-status`. Destructive operations remain CLI-only.
- The new commands are faithful API wrappers and do not auto-create the memory store (no `ensureMemoryStore` side effect on reads), so a call against a missing store returns the service error rather than silently provisioning one.
- No new authentication requirements: all 22 methods are data-plane calls, so both API Key and AK/SK work; only managed-instance auto-create still needs AK/SK (unchanged).

## 0.1.8

- Persist the per-session writeback cursor to disk (`$OPENCLAW_HOME/plugins/tablestore-mem/writeback-state.json`) so a gateway restart no longer re-ingests the in-progress session's history. New `writebackCursorPersist` config (default `true`); set `false` to keep the previous memory-only behavior. The file is capped to the most recent sessions. Long-term memory was already deduplicated server-side; this removes the redundant re-upload/re-extraction after a restart.

## 0.1.7

- Added retrieval similarity-threshold filtering: new `minSimilarity` config (default `0` = no filter, range `0..1`) is passed to `SearchMemories` to drop results below the normalized cosine similarity threshold. CLI `tablestore-mem search` gains `--min-similarity <n>` to override per call.
- Added user-customizable memory extraction prompt: new `extractInstructions` config (≤4096 chars) is applied at `CreateMemoryStore` time and reconciled onto an existing store via `UpdateMemoryStore` (PATCH), attempted at most once per process (a persistent failure no longer re-issues the call on every turn). Guides which long-term memories the service extracts.
- Added per-action Dream auto-apply thresholds: new `dreamConfidenceThresholds` config (`{add,update,merge}`, each `0..1`) overrides the single `dreamConfidenceThreshold` per action and falls back to it for unset actions. CLI `tablestore-mem dream --threshold <n>` overrides all actions for one run.
- Added custom Dream consolidation instructions: new `dreamInstructions` config (≤4000 chars) passed as `instructions` to every Dream task (background, `session_end`, and CLI). CLI `tablestore-mem dream` gains `--instructions <text>` to override per run.

## 0.1.6

- Switched the data plane from the generic `tablestore` SDK to `@tablestore/agent-storage` (`AgentStorageClient`).
- Added **API Key** authentication (`apiKey` config) as an alternative to AccessKey. When `apiKey` is set it is used instead of AK/SK; it requires an explicit `https` endpoint and `otsInstanceName` because the control plane (managed-instance auto-create) is AccessKey-only.
- Added automatic offline **Dream** memory consolidation:
  - A background scheduler (`dreamIntervalHours`, default 24h) consolidates the concrete scopes written this process, `safe_auto` with a conservative confidence threshold (`dreamConfidenceThreshold`, default 0.9). High-confidence add/update/merge actions are auto-applied; DELETE is never auto-applied.
  - Consolidation runs per concrete `appId/tenantId/agentId/runId` scope (not a wildcard), which is the configuration that actually auto-applies; results stay in place (`preserve_scope`). A per-scope watermark is persisted to `dream-state.json` and a min-interval (`dreamMinIntervalHours`) prevents re-consolidating the same scope too often.
  - **`session_end`-triggered consolidation** (`dreamOnSessionEnd`, default `true`): when a session ends (rotation/reset/idle/compaction), the plugin consolidates that session's concrete scope immediately, in addition to the periodic cycle. The session's exact write scope is remembered per session id at writeback time so the same scope is consolidated (no re-derivation drift); falls back to deriving from the `session_end` event otherwise. `session_end` is not a conversation hook, so it does not require `allowConversationAccess`, and it shares the watermark/min-interval/single-run guard with the periodic cycle.
  - New CLI command `openclaw tablestore-mem dream --uid <uid> [--wait] [--apply-mode safe_auto|proposal] [--threshold 0..1] [--no-incremental]` enumerates a tenant's concrete scopes and consolidates them on demand.
  - Dream runs fully off the hot path; any failure is logged and never affects retrieval or writeback.
- Fixed `agent_end` writeback to persist only the new turn increment per session (cursor) and to chunk into `<=20` messages / `<=32000` chars per `AddMemories` call, instead of re-sending the full cumulative snapshot.

## 0.1.5

- Documented the OpenClaw `2026.4.26+` hook trust requirement for non-bundled plugins: `plugins.entries.tablestore-mem.hooks.allowConversationAccess=true` is required for the `agent_end` writeback hook.
- Clarified in the README that this is an OpenClaw security trust flag rather than a TableStore plugin business configuration field.
- Verified on a freshly reinstalled OpenClaw `2026.4.26` environment that AK/SK-only setup, managed-instance auto-create, CLI commands, retrieval, and `agent_end` writeback all work end-to-end when the trust flag is enabled.

## 0.1.4

- Fixed the AK/SK-only auto-create flow so control-plane SDK loading works correctly under OpenClaw's ESM runtime.
- Kept managed instance creation on `CreateVCUInstance` and fixed the full first-run lifecycle: `CreateVCUInstance` -> `GetInstance` polling -> `UpdateInstance` -> DNS readiness.
- Added readiness waiting for new managed instances, including control-plane status polling, post-create `UpdateInstance`, and data-endpoint DNS availability checks.
- Persisted auto-created instance metadata before first use and reused the same `instance.json` across CLI and conversation hooks.
- Fixed `doctor`/CLI first-run behavior in a clean OpenClaw home so one successful auto-create instance can be reused on later runs.
- Updated README to match the verified auto-create, reuse, and first-run diagnostic behavior.
- Added a packaged-artifact cold-start smoke test and wired it into `prepublishOnly` so `npm publish` now fails if a fresh OpenClaw install cannot load the packed plugin and register its hooks/CLI.
- Added an optional live OpenClaw smoke script for real TableStore verification, including the AK/SK-only managed-instance creation and `instance.json` reuse path.

## 0.1.3

- Changed `tenantId` resolution so configured `tenantId` now overrides runtime session user identity for both read and write scopes.
- Fixed endpoint-only configuration so a configured endpoint can be used without `otsInstanceName` when the instance name can be parsed from the endpoint.
- Updated README to match the current configuration priority rules.

## 0.1.2

- Added `openclaw tablestore-mem doctor` for CLI diagnosis of plugin connectivity and memory-store state.
- Doctor now checks resolved connection info, ensures the memory store exists, fetches memory-store metadata, and lists a sample of memories for the selected scope.
- Updated README for the new CLI diagnostic workflow.

## 0.1.1

- Switched automatic memory retrieval from visible prompt injection to hidden system-context injection.
- Removed `message:preprocessed` compatibility baggage and cleaned up plugin behavior.
- Search now relies directly on `SearchMemories` results and no longer performs `ListMemories` fallback or client-side tenant re-filtering.
- Defaulted `SearchMemories.enableRerank` to `true`.
- Defaulted `AddMemories.sync` to `false`.
- Simplified required configuration to access key pair only when auto-managed instance flow is used.
- Added automatic TableStore instance provisioning when `otsInstanceName` is omitted.
- Persisted auto-created instance metadata to local OpenClaw state and reused it across hooks and CLI.
- Updated README and packaging metadata for publish-ready `@tablestore/openclaw-tablestore-memory`.
