Commit Graph

90 Commits

Author SHA1 Message Date
Ziyang Guo 823b478d46 fix(security): enable L1 prompt injection filtering (#175)
Signed-off-by: Ziyang Guo <121015044+RerankerGuo@users.noreply.github.com>
2026-06-15 01:06:26 +08:00
Willow Lopez f61c5fd5fd fix(pipeline): return cursor on zero-record L2 extraction for incremental processing (#130)
Fixes #98

Return { latestCursor: cursor } instead of void when VectorStore or
JSONL pipeline returns zero records. Add cold-start guard in pipeline
manager to initialize last_extraction_updated_time on first run.

Previously the L2 runner performed a full table scan on every invocation
because the cursor never advanced past the initial state.

Signed-off-by: Oxygen56 <1391083091@qq.com>
2026-06-15 01:04:52 +08:00
Yuntong8888 a21ef3f66a Update README_CN.md (#197) 2026-06-12 11:05:18 +08:00
jackyangjie 41c00b7d5a docs: fix config comments to match actual defaults (#171)
Three config fields had comments that disagreed with the code defaults:
- maxScenes: comment said 20, code uses 15
- l2DelayAfterL1Seconds: comment said 90, code uses 10
- report.enabled: comment said true, code uses false

Closes #161

Co-authored-by: jackyangjie <yangjie@qq.com>
2026-06-11 21:39:52 +08:00
fei121 b10a290ded [good first issue] fix: align config default comments (#174)
* fix: align config default comments

* Delete src/config.test.ts

---------

Co-authored-by: fei121 <fengyufei@fengyufeideMacBook-Pro.local>
Co-authored-by: 十五便士 <95488710+Maxwell-Code07@users.noreply.github.com>
2026-06-11 21:38:46 +08:00
杨俊杰 0d39dffd37 [good first issue] docs: recommend exact version install for OpenClaw (#144)
* docs(openclaw): recommend exact version install

Signed-off-by: yangjj-iso <3202137046@qq.com>

* Revise OpenClaw plugin installation instructions

Updated installation instructions for OpenClaw plugin to remove version specification and added upgrade command.

* Revise TencentDB memory plugin installation instructions

Updated installation instructions for the TencentDB memory plugin to remove the specific version and added a note on using the OpenClaw command for upgrades.

---------

Signed-off-by: yangjj-iso <3202137046@qq.com>
Co-authored-by: 十五便士 <95488710+Maxwell-Code07@users.noreply.github.com>
2026-06-11 20:28:23 +08:00
YOMXXX 46e9977ba8 [good first issue] docs(hermes): document plugging memory-tencentdb into an existing Hermes (#139)
* docs(hermes): document plugging memory-tencentdb into an existing Hermes

The Hermes section in README.md / README_CN.md only documented the
all-in-one Docker image, which is the wrong starting point when the
user already has hermes-agent installed. They don't want to throw
away their setup just to get memory; they want to drop the provider
in next to the other built-in providers.

The full reference already exists at
`hermes-plugin/memory/memory_tencentdb/README.md` (auto-discovery
paths, env vars, supervisor behaviour, troubleshooting). What's
missing is the discoverable entry point at the top-level README.

Restructure section 2 into two parallel paths:

- 2.A Docker — the existing one-command flow, unchanged.
- 2.B Plug into an existing Hermes (no Docker) — new. Covers:
  - installing the npm package so the Gateway source is on disk
  - symlink vs copy of the Python provider into
    `<hermes-agent-checkout>/plugins/memory/memory_tencentdb/`
    (with the "underscore not hyphen" trap called out)
  - the `memory.provider: memory_tencentdb` line in `~/.hermes/config.yaml`
  - the three `MEMORY_TENCENTDB_LLM_*` env vars
  - the three Gateway-start options (auto-discovery / explicit
    GATEWAY_CMD / run-yourself), with auto-discovery as default
  - a `curl /health` verification step
  - a link to the in-repo provider README for the full reference

Docs-only — no code change. Existing Docker users see no difference.

Fixes #69

Signed-off-by: 李冠辰 <liguanchen@xiaomi.com>

* docs(hermes): document tdai gateway config file

* update README_CN.md file

* Fix formatting in README_CN.md for clarity

* Clarify Hermes plugin installation instructions

Updated the README to clarify installation instructions for the Hermes plugin, including Docker usage and configuration steps.

---------

Signed-off-by: 李冠辰 <liguanchen@xiaomi.com>
Co-authored-by: 十五便士 <95488710+Maxwell-Code07@users.noreply.github.com>
2026-06-11 17:34:31 +08:00
YOMXXX f92b10259b feat(embedding): support ZeroEntropy native embed API (#137)
* feat(embedding): support ZeroEntropy native embed API

ZeroEntropy's embedding service is reachable but not OpenAI-shaped:
its endpoint is POST /v1/models/embed (not /v1/embeddings), the
request body requires an `input_type` ("query" or "document") and
rejects an explicit `dimensions` field, and the response is wrapped
as `{results: [{embedding}]}` instead of OpenAI's
`{data: [{index, embedding}]}`.

Branch on `provider === "zeroentropy"` inside OpenAIEmbeddingService
rather than introducing a new service class:

- `/models/embed` is used instead of `/embeddings` (also honoured
  by the qclaw proxy path so users can still front it).
- request body sets `input_type: "query"` and omits `dimensions`
  (zembed-1 is fixed-dimension and rejects explicit overrides).
- response parsing decodes the `results[]` envelope and preserves
  input order via array index rather than OpenAI's `index` field.

`openclaw.plugin.json` updates the `embedding.provider` description to
list `zeroentropy` as a recognized value.

Everything else (timeout, retries, batching, char-cap truncation,
sanitize+normalize) is shared with the OpenAI path — only the wire
format changes.

Fixes #68

Signed-off-by: 李冠辰 <liguanchen@xiaomi.com>

* refactor(embedding): split ZeroEntropy into its own EmbeddingService

Addresses @Xuruida's review feedback on PR #137: instead of branching
OpenAIEmbeddingService._callApi on `providerName === "zeroentropy"`,
extract the shared HTTP layer and give ZeroEntropy its own class.

This keeps OpenAIEmbeddingService focused on the OpenAI-compatible
wire format and stops provider-specific protocol differences from
accumulating inside a single class.

Changes:

- New module-level helpers (provider-agnostic):
  * `truncateEmbeddingInputs(texts, maxInputChars, logger)` — was
    previously a private method duplicated logic-side.
  * `postEmbeddingRequest({fetchUrl, headers, body, timeoutMs})` —
    owns fetch + AbortController timeout + exponential-backoff
    retries + the EmbeddingApiError non-retry rule for 4xx (except
    429). Returns the parsed JSON; callers own response parsing.

- `OpenAIEmbeddingService._callApi` is back to OpenAI-only: builds
  `{input, model, dimensions?}`, posts to `/embeddings`, parses
  `{data: [{index, embedding}]}` with index-sort. The qclaw proxy
  branch is unchanged. No more `isZeroEntropy` reads.

- New `ZeroEntropyEmbeddingService implements EmbeddingService`:
  - Same `OpenAIEmbeddingConfig` shape (baseUrl / apiKey / model /
    dimensions / maxInputChars / timeoutMs are identical on the
    wire), but encodes ZeroEntropy's wire format independently:
    posts to `${baseUrl}/models/embed`, sends `input_type: "query"`,
    omits `dimensions` (zembed-1 is fixed-dim), parses
    `{results: [{embedding}]}` preserving array order.
  - Doesn't carry the OpenAI-only knobs (`sendDimensions`,
    `proxyUrl`, qclaw) so the class surface stays small.

- `createEmbeddingService` factory: new `provider === "zeroentropy"`
  branch placed before the OpenAI-compatible catch-all so it wins
  the dispatch.

Behaviour preserved:
- All existing OpenAI / DeepSeek / Azure / qclaw deployments hit
  exactly the same wire calls as before this PR was opened.
- ZeroEntropy wire format (URL + body + response) matches the
  original PR's branched implementation byte for byte.
- Timeout, retry, error mapping, batch splitting, char-cap
  truncation, sanitize+normalize are shared via the module helpers
  so the two services can't diverge by accident.

Signed-off-by: 李冠辰 <liguanchen@xiaomi.com>

* fix(embedding): forward dimensions to ZeroEntropy when sendDimensions

Addresses @Xuruida's follow-up review on PR #137. The previous commit
silently dropped `dimensions` from every ZeroEntropy request based on
the wrong claim that zembed-1 is fixed-dim.

Verified against
https://docs.zeroentropy.dev/api-reference/models/embed: `dimensions`
is an optional integer; for zembed-1 the accepted set is
[2560, 1280, 640, 320, 160, 80, 40] (Matryoshka truncation). Not
forwarding it left users no way to pick a smaller dim end-to-end —
the wire payload always used the model default while the Float32Array
return type and getDimensions() still reported config.dimensions, so
the runtime vector size and the configured one could disagree.

- ZeroEntropyEmbeddingService now mirrors OpenAIEmbeddingService:
  reads `config.sendDimensions ?? true` into a `sendDimensions` field
  and emits `dimensions: this.dims` in the request body when set.
- Class docstring corrected — the "rejects explicit overrides" line
  is replaced with the documented Matryoshka set. Server still
  rejects out-of-set values, but that's a config choice the user
  owns; we forward verbatim instead of clamping silently.

Signed-off-by: 李冠辰 <liguanchen@xiaomi.com>

---------

Signed-off-by: 李冠辰 <liguanchen@xiaomi.com>
2026-06-04 16:31:29 +08:00
Yuntong8888 b50c2eb723 Update README_CN.md (#145) 2026-06-04 15:51:16 +08:00
Ruida Xu 32ba4d303d feat(timezone): make all user/LLM-facing timestamps timezone-configurable (#129)
Add top-level `timezone` config option (default: "system") supporting
IANA names and UTC offset strings (ECMA-402 2024).

- Introduce unified `src/utils/time.ts` module with formatForLLM,
  formatLocalDate, formatLocalDateTime, startOfLocalDay, nowInstantISO
- Converge 4 scattered time helpers into the single module
- L1 extraction / auto-recall / scene-extraction / persona-generation
  prompts now emit ISO 8601 with explicit UTC offset
- Add timezone declaration to LLM system prompts
- Local-day shard boundaries and cleaner cutoff follow configured tz
- Storage instants (SQLite/TCVDB) remain UTC — no data migration needed
- 38 unit tests covering IANA, offset, DST, half-hour zones, fallback
2026-06-04 11:44:01 +08:00
Akhilesh Arora c6ed755835 fix(recall): truncate recalled context by code point, not code unit (#109)
truncateRecallLine capped lines with line.length and line.slice, which
count and index by UTF-16 code unit. When recall.maxCharsPerMemory or
recall.maxTotalRecallChars is set and the cut lands between the halves of
a surrogate pair, the line keeps a lone surrogate that becomes U+FFFD once
UTF-8 encoded for the request, corrupting any non-BMP character (emoji,
CJK Ext-B) in the injected context. Slice on Array.from(line) code points
instead. Both recall call sites route through this function. Same class as
the sanitizeText fix in #31, reintroduced by the #71 budget path.

Signed-off-by: Akhilesh Arora <akhildawra@gmail.com>
2026-06-02 21:08:59 +08:00
Radian 3d588b0a0f Merge pull request #128 from withRiver/fix/remove-tools-clean-context-runner
fix: pass disableTools:true when enableTools=false in CleanContextRunner
2026-06-02 20:40:24 +08:00
Rocke Dong 15585548ec docs: fix OpenClaw context engine slot (#124) 2026-06-02 17:30:42 +08:00
Yuntong8888 f0c683dc24 Update README_CN.md (#126)
更新 README 中的微信社群二维码图片为最新版本,方便用户扫码加入社群。

Update the WeChat community QR code in README to the latest version, making it easier for users to join the community.

共替换 4 处二维码图片引用,仅修改图片 src 地址,保持原有显示尺寸(width="360" / width="200")和布局(居中对齐)不变。
2026-06-02 17:29:41 +08:00
Andy He d1534e488f refactor: unify duplicate Logger interfaces into single canonical type (#14)
* refactor: unify duplicate Logger interfaces into single canonical type

23 files had local Logger/StoreLogger/PluginLogger/PipelineLogger/RunnerLogger/ExtractorLogger/TriggerLogger
interface definitions with identical shapes ({debug?, info, warn, error}).

Replace all with imports from the canonical `Logger` in `src/core/types.ts`:
- 17 files: local `interface Logger` → `import type { Logger }`
- 6 files: named variants (StoreLogger, PluginLogger, etc.) → `type X = Logger` alias

Two intentionally different interfaces are preserved:
- `CheckpointLogger` (only info + optional warn) — different contract
- `ensure-hook-policy.ts` Logger (no error) — different contract

Net: -120 lines, zero behavioral change.

Signed-off-by: yuanrengu <heyonggang0811@126.com>

* docs: update Logger JSDoc to reflect canonical relationship

StoreLogger, PluginLogger, etc. are now type aliases of Logger, not the
other way around. Update the comment to clarify this inverted relationship.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Signed-off-by: yuanrengu <heyonggang0811@126.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 15:12:46 +08:00
chrishuan 438869bec8 feat: release v0.3.6 v0.3.6 2026-05-28 14:32:52 +08:00
YOMXXX 1bdcf28c5e feat(recall): cap injected memory context (#71)
- Add `recall.maxCharsPerMemory` and `recall.maxTotalRecallChars` with defaults of `0`, which do not alter existing behavior. Users can opt in by setting positive values to cap injected memory context.
- Apply the budget after L1 search and before `<relevant-memories>` injection, preserving score order while truncating oversized entries and dropping overflow.
- Document the new guards in README, README_CN, and `openclaw.plugin.json`.
2026-05-26 21:19:38 +08:00
十五便士 d92cbd3840 Increase package size limit from 512KB to 2048KB 2026-05-25 17:26:27 +08:00
Siren.W dc34ec5283 Do not expose tools for standalone text-only LLMRunner tasks (#59)
Removes tool exposure from the standalone `LLMRunner` when `enableTools=false`.

Some standalone text-only tasks, such as L1 extraction, expect plain text output and do not need tool access. Passing even a read-only tool subset can still encourage tool-calling behavior on OpenAI-compatible backends, which makes this path less stable than necessary.

With this change:

- `enableTools=true` keeps the existing sandboxed tool behavior
- `enableTools=false` sends no tools at all
2026-05-25 15:30:54 +08:00
Ruida Xu acc2665389 Merge pull request #85 from YOMXXX/fix/openclaw-state-dir-fallback
fix(plugin): add OpenClaw state dir fallback in ESM-safe method
2026-05-25 15:24:30 +08:00
noFloat e334591bde Merge pull request #81 from yuanrengu/fix/api-key-in-config-yaml
fix: add missing api_key field for custom provider in Dockerfile.hermes
2026-05-25 14:36:59 +08:00
李冠辰 49788fc085 fix(plugin): add OpenClaw state dir fallback 2026-05-25 00:10:57 +08:00
yuanrengu 69a95536ad fix: add missing api_key field for custom provider in Dockerfile.hermes
The CMD script writes MODEL_API_KEY to .env as OPENAI_API_KEY but
does not include it in config.yaml's model section. Hermes with
provider: custom reads api_key from model.api_key in config.yaml,
not from OPENAI_API_KEY in .env. This causes 401 Authentication
Fails when users start a conversation inside the container.

Fix: add api_key field to the generated config.yaml model section.
2026-05-24 11:25:43 +08:00
十五便士 be998adeb2 Replace WeChat group QR code image
Updated the WeChat group QR code image in the README_CN.md file.
2026-05-23 21:20:19 +08:00
honchow bfddda6d3e Merge pull request #31 from akhilesharora/fix/sanitize-text-preserve-non-bmp
fix(offload): preserve non-BMP characters in sanitizeText
2026-05-21 14:46:19 +08:00
chrishuan 0d462e0b63 chore: release v0.3.5 v0.3.5 2026-05-20 22:58:05 +08:00
noFloat f81b79e4ac Merge pull request #55 from YOMXXX/fix/install-root-su-recursion
fix(install): prevent infinite su recursion when running as root
2026-05-20 19:30:55 +08:00
chrishuan 3d965dfbb6 fix(docs): add cd docker/opensource before docker build command 2026-05-20 18:21:34 +08:00
李冠辰 e2223bd532 fix(install): prevent infinite su recursion when running as root
If install_hermes_memory_tencentdb.sh is invoked directly by the root
user (e.g. fresh server with root SSH login), the prior logic:

  USERNAME=$(whoami)             # → "root"
  if [ "$(id -u)" -eq 0 ]; then
      su - $USERNAME -c "bash $TEMP_SCRIPT"   # → su - root → root → loops
  fi

would spin forever: ``su - root`` enters a fresh root shell that re-runs
the script, which sees EUID=0 again and ``su -``-s itself once more.
Symptom (per issue #20):

  [memory-tencentdb] Running as root, switching to root for installation...
  [memory-tencentdb] Running as root, switching to root for installation...
  ...   (only Ctrl+C stops it)

Fix:

  1. ``USERNAME`` resolution adds two precedence steps before
     ``$(whoami)`` so admins running ``sudo bash install.sh`` end up
     installing for the original user instead of for root:
       a. ``INSTALL_AS_USER`` env override (explicit admin choice)
       b. ``SUDO_USER`` (sudo's own record of the calling user)
       c. ``whoami`` (final fallback)

  2. The ``id -u == 0`` branch now skips the ``su -`` step when the
     target user is also root — that's the recursion-trigger case. The
     script proceeds inline as root for the rest of the install.

  3. A new ``elif`` arm logs a clear ``"Running as root; target user is
     also root — installing in place."`` so the operator sees what's
     happening.

Verified by dry-run simulation of 5 scenarios:

  | Case                                    | Branch        | USERNAME |
  | --------------------------------------- | ------------- | -------- |
  | root SSH direct (#20 reproducer)        | INLINE        | root     |
  | non-root user direct                    | NORMAL        | <user>   |
  | sudo bash install.sh from non-root user | SU            | <user>   |
  | root + INSTALL_AS_USER=bar              | SU            | bar      |
  | root + INSTALL_AS_USER=root             | INLINE        | root     |

Closes #20.

Signed-off-by: 李冠辰 <liguanchen@xiaomi.com>
2026-05-19 07:30:35 +08:00
Yuntong8888 c13d020047 Update README_CN.md 2026-05-18 18:22:59 +08:00
Akhilesh Arora bf58853343 fix(offload): preserve non-BMP characters in sanitizeText
UNSAFE_CHAR_RE included the surrogate range [\uD800-\uDFFF] without the `u`
flag, so JS treated strings as UTF-16 code units and stripped each half of
every well-formed non-BMP code point. sanitizeText and sanitizeJsonLine
therefore destroyed emoji, CJK Extension B, math bold, etc. in tool params,
tool results, and ref-md archives.

Adding the `u` flag makes paired surrogates combine into a single code point
before matching, so the [\uD800-\uDFFF] entry now matches only lone (malformed)
surrogates, which is the original intent. All other entries (replacement char,
C0/C1 controls, zero-width chars, line separators, BOM) keep their behavior.

Added a vitest suite covering the preserved and stripped cases.

Closes #30
2026-05-16 22:23:45 +02:00
十五便士 5736acc871 feat: add question/consultation issue template
Add a question template for issue submissions with categories and fields for detailed inquiries.
2026-05-16 20:17:22 +08:00
Yuntong8888 96870953e3 Update README_CN.md 2026-05-16 08:05:38 +08:00
Yuntong8888 4a3f8238d4 Update README_CN.md 2026-05-15 15:12:02 +08:00
Yuntong8888 285896f899 Update README_CN.md 2026-05-14 16:31:56 +08:00
Yuntong8888 e0efaab4db Update README_CN.md 2026-05-14 16:15:13 +08:00
Yuntong8888 0f2894eed9 Update README_CN.md 2026-05-14 15:21:35 +08:00
Yuntong8888 3f69f3c92d Update README.md 2026-05-14 15:21:30 +08:00
Yuntong8888 31d3542ba9 Update README.md 2026-05-14 04:19:15 +08:00
Yuntong8888 d3f220ce15 Update README_CN.md 2026-05-14 04:19:10 +08:00
Yuntong8888 5717b4aab0 Update README.md v0.3.4 2026-05-13 17:51:10 +08:00
Yuntong8888 209420727c Update README_CN.md 2026-05-13 17:51:06 +08:00
Yuntong8888 2488ae2c7a Update README_CN.md 2026-05-13 17:38:18 +08:00
Yuntong8888 7608894156 Update README.md 2026-05-13 17:37:58 +08:00
Yuntong8888 79bf24fbe4 Update README.md 2026-05-13 16:09:43 +08:00
Yuntong8888 a657499c72 Update README_CN.md 2026-05-13 16:01:54 +08:00
十五便士 910be30bbe Change security issue reporting email 2026-05-13 15:40:25 +08:00
十五便士 f6263da67c Change security issue reporting email
Updated the contact method for reporting security issues.
2026-05-13 15:38:19 +08:00
chrishuan f7794f198e docs: sync README, SKILL, and image updates from GitHub 2026-05-13 15:02:10 +08:00
chrishuan d377b09fbc feat: release v0.3.4 — offload local LLM, CLI restore, bugfix scripts 2026-05-13 14:56:56 +08:00