Compare commits

..

176 Commits

Author SHA1 Message Date
Tak Hoffman
5553d610e8 fix(ui): preserve interleaved tool card pairing 2026-04-11 07:33:11 -05:00
Tak Hoffman
18fa036d06 Merge remote-tracking branch 'origin/main' into codex/ui-canvas-origin-main
# Conflicts:
#	src/agents/system-prompt-params.ts
#	src/gateway/server-http.ts
2026-04-11 07:30:42 -05:00
Vincent Koc
af428d9b8a fix(cycles): split runtime taskflow type surface 2026-04-11 13:26:50 +01:00
Vincent Koc
543c14a4ed fix(cycles): split runtime delivery and registry seams 2026-04-11 13:26:50 +01:00
Vincent Koc
41ab0f7d5c fix(gateway): add shared request handler types 2026-04-11 13:26:50 +01:00
Vincent Koc
74e7b8d47b fix(cycles): bulk extract leaf type surfaces 2026-04-11 13:26:50 +01:00
Vincent Koc
1167093773 test(qa): drop rebase conflict marker 2026-04-11 13:24:45 +01:00
Vincent Koc
afbc4a2ed5 docs(changelog): note codex qa leak fix 2026-04-11 13:23:26 +01:00
Vincent Koc
d21573d3a1 fix(qa): catch leaked harness meta replies 2026-04-11 13:23:26 +01:00
Tak Hoffman
a0f0f0553b fix(ci): resolve remaining branch check failures 2026-04-11 07:19:50 -05:00
Peter Steinberger
d72fb7efb9 fix: harden QA scenario matcher validation 2026-04-11 13:19:13 +01:00
Peter Steinberger
f9331fbe68 test(install): add docker tgz update smoke flow 2026-04-11 13:13:11 +01:00
Peter Steinberger
cd89892b1f fix(release): keep private QA bundles out of npm pack 2026-04-11 13:13:11 +01:00
Peter Steinberger
a733e92c45 test: exercise real updater in Parallels npm flow 2026-04-11 13:04:14 +01:00
Peter Steinberger
48ac72f0ee perf: prefilter extension boundary parsing 2026-04-11 13:02:56 +01:00
Peter Steinberger
850182b502 test: combine extension import boundary checks 2026-04-11 12:59:53 +01:00
Tak Hoffman
5d17b21787 fix(ci): repair rebased branch drift 2026-04-11 06:58:45 -05:00
Peter Steinberger
d5f199adaf perf: cache parsed guard sources 2026-04-11 12:57:09 +01:00
Vincent Koc
4c5573653d docs(changelog): note qa packaging release fix 2026-04-11 12:55:13 +01:00
Peter Steinberger
53dea1d9c7 test: narrow web provider artifact invariants 2026-04-11 12:54:00 +01:00
Vincent Koc
636fe1c2db fix(qa): ship scenario pack and isolate completion cache 2026-04-11 12:53:56 +01:00
Peter Steinberger
8a8fdc971c perf: share web boundary source scans 2026-04-11 12:50:45 +01:00
Peter Steinberger
893a0f469a test: combine web provider boundary checks 2026-04-11 12:46:49 +01:00
Peter Steinberger
5f162973cf test: move send-keys validation to helper 2026-04-11 12:43:16 +01:00
Peter Steinberger
f770206311 test: combine task boundary scans 2026-04-11 12:38:18 +01:00
Peter Steinberger
1851aa7944 test: stage live external plugins 2026-04-11 12:36:09 +01:00
Vincent Koc
79c3dbecd1 feat(plugins): add manifest activation and setup descriptors (#64780) 2026-04-11 12:35:59 +01:00
Tak Hoffman
05d100aa1a feat(ui): gate external embed urls behind config 2026-04-11 06:35:20 -05:00
Luke
d7479dc61a Agents: log proxy route summary (#64754)
Merged via squash.

Prepared head SHA: 3a668e9ba8
Co-authored-by: ImLukeF <92253590+ImLukeF@users.noreply.github.com>
Co-authored-by: ImLukeF <92253590+ImLukeF@users.noreply.github.com>
Reviewed-by: @ImLukeF
2026-04-11 21:30:58 +10:00
Tak Hoffman
43c80e7350 Merge origin/main into codex/ui-canvas-origin-main 2026-04-11 06:15:25 -05:00
Tak Hoffman
a67e91fd84 fix(gateway): enforce auth rotation and media cleanup 2026-04-11 06:04:40 -05:00
Vincent Koc
68fcd85bff fix(tasks): narrow control runtime override type 2026-04-11 12:03:16 +01:00
Vincent Koc
a866c51b9d test(video): narrow buffered live asset helper 2026-04-11 12:03:16 +01:00
Vincent Koc
d6fa67701e test(config): refresh generated base schema 2026-04-11 12:03:16 +01:00
Vincent Koc
75d7325e32 test(tasks): add control runtime override seam 2026-04-11 12:03:16 +01:00
Vincent Koc
8b29736b9c fix(tasks): shard test state by vitest worker 2026-04-11 12:03:16 +01:00
Vincent Koc
2d4209c1bf test(ci): align node shard check names 2026-04-11 12:03:16 +01:00
Vincent Koc
7899f5c5ce fix(dev): throttle local tsgo by default 2026-04-11 11:56:23 +01:00
Vincent Koc
571483a13d fix(test): narrow live video asset buffers 2026-04-11 11:19:46 +01:00
Vincent Koc
25c47231bb ci(checks): shorten node shard names 2026-04-11 11:12:33 +01:00
qiziAI
e339038cc0 Fix: Sync asyncCompletion config in zod-schema.ts to resolve "Unrecog… (#63618)
Merged via squash.

Prepared head SHA: dcce839c07
Co-authored-by: qiziAI <17017936+qiziAI@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
2026-04-11 11:12:09 +01:00
xieyongliang
e0a2c568b2 video_generate: support url-only delivery (#61988) (thanks @xieyongliang) (#61988)
Co-authored-by: George Zhang <georgezhangtj97@gmail.com>
2026-04-11 03:08:30 -07:00
Vincent Koc
52800131d2 fix(video): restore generation runtime params 2026-04-11 11:01:07 +01:00
Vincent Koc
08ba5a72f7 fix(cycles): add remaining seam files 2026-04-11 10:43:22 +01:00
Vincent Koc
7308e72fac fix(cycles): continue seam extraction 2026-04-11 10:43:22 +01:00
Vincent Koc
688327311c test(gateway): harden tools invoke cron regression harness 2026-04-11 10:39:56 +01:00
wittam-01
ebb72baba3 feat(feishu): improve document comment session, rich parsing, and typing feedback (#63785)
* Feishu: upgrade comment session, context parsing, and typing reaction

* test(feishu): align comment prompt assertions
2026-04-11 17:26:21 +08:00
xieyongliang
2c57ec7b5f video_generate: add providerOptions, inputAudios, and imageRoles (#61987)
* video_generate: add providerOptions, inputAudios, and imageRoles

- VideoGenerationSourceAsset gains an optional `role` field (e.g.
  "first_frame", "last_frame"); core treats it as opaque and forwards it
  to the provider unchanged.

- VideoGenerationRequest gains `inputAudios` (reference audio assets,
  e.g. background music) and `providerOptions` (arbitrary
  provider-specific key/value pairs forwarded as-is).

- VideoGenerationProviderCapabilities gains `maxInputAudios`.

- video_generate tool schema adds:
  - `imageRoles` array (parallel to `images`, sets role per asset)
  - `audioRef` / `audioRefs` (single/multi reference audio inputs)
  - `providerOptions` (JSON object passed through to the provider)
  - `MAX_INPUT_IMAGES` bumped 5 → 9; `MAX_INPUT_AUDIOS` = 3

- Capability validation extended to gate on `maxInputAudios`.

- runtime.ts threads `inputAudios` and `providerOptions` through to
  `provider.generateVideo`.

- Docs and runtime tests updated.

Made-with: Cursor

* docs: fix BytePlus Seedance capability table — split 1.5 and 2.0 rows

1.5 Pro supports at most 2 input images (first_frame + last_frame);
2.0 supports up to 9 reference images, 3 videos, and 3 audios.
Provider notes section updated accordingly.

Made-with: Cursor

* docs: list all Seedance 1.0 models in video-generation provider table

- Default model updated to seedance-1-0-pro-250528 (was the T2V lite)
- Provider notes now enumerate all five 1.0 model IDs with T2V/I2V capability notes

Made-with: Cursor

* video_generate: address review feedback (P1/P2)

P1: Add "adaptive" to SUPPORTED_ASPECT_RATIOS so provider-specific ratio
passthrough (used by Seedance 1.5/2.0) is accepted instead of throwing.
Update error message to include "adaptive" in the allowed list.

P1: Fix audio input capability default — when a provider does not declare
maxInputAudios, default to 0 (no audio support) instead of MAX_INPUT_AUDIOS.
Providers must explicitly opt in via maxInputAudios to accept audio inputs.

P2: Remove unnecessary type cast in imageRoles assignment; VideoGenerationSourceAsset
already declares role?: string so a non-null assertion suffices.

P2: Add videoRoles and audioRoles tool parameters, parallel to imageRoles,
so callers can assign semantic role hints to reference video and audio assets
(e.g. "reference_video", "reference_audio" for Seedance 2.0).

Made-with: Cursor

* video_generate: fix check-docs formatting and snake_case param reading

Made-with: Cursor

* video_generate: clarify *Roles are parallel to combined input list (P2)

Made-with: Cursor

* video_generate: add missing duration import; fix corrupted docs section

Made-with: Cursor

* video_generate: pass mode inputs to duration resolver; note plugin requirement (P2)

Made-with: Cursor

* plugin-sdk: sync new video-gen fields — role, inputAudios, providerOptions, maxInputAudios

Add fields introduced by core in the PR1 batch to the public plugin-sdk
mirror so TypeScript provider plugins can declare and consume them
without type assertions:
- VideoGenerationSourceAsset.role?: string
- VideoGenerationRequest.inputAudios and .providerOptions
- VideoGenerationModeCapabilities.maxInputAudios

The AssertAssignable bidirectional checks still pass because all new
fields are optional; this change makes the SDK surface complete.

Made-with: Cursor

* video-gen runtime: skip failover candidates lacking audio capability

Made-with: Cursor

* video-gen: fall back to flat capabilities.maxInputAudios in failover and tool validation

Made-with: Cursor

* video-gen: defer audio-count check to runtime, enabling fallback for audio-capable candidates

Made-with: Cursor

* video-gen: defer maxDurationSeconds check to runtime, enabling fallback for higher-cap candidates

Made-with: Cursor

* video-gen: add VideoGenerationAssetRole union and typed providerOptions capability

Introduces a canonical VideoGenerationAssetRole union (first_frame,
last_frame, reference_image, reference_video, reference_audio) for the
source-asset role hint, and a VideoGenerationProviderOptionType tag
('number' | 'boolean' | 'string') plus a new capabilities.providerOptions
schema that providers use to declare which opaque providerOptions keys
they accept and with what primitive type.

Types are additive and backwards compatible. The role field accepts both
canonical union values and arbitrary provider-specific strings via a
`VideoGenerationAssetRole | (string & {})` union, so autocomplete works
for the common case without blocking provider-specific extensions.

Runtime enforcement of providerOptions (skip-in-fallback, unknown key
and type mismatch) lands in a follow-up commit.

Co-authored-by: yongliang.xie <yongliang.xie@bytedance.com>

* video-gen: enforce typed providerOptions schema via skip-in-fallback

Adds `validateProviderOptionsAgainstDeclaration` in the video-generation
runtime and wires it into the `generateVideo` candidate loop alongside
the existing audio-count and duration-cap skip guards.

Behavior:
  - Candidates with no declared `capabilities.providerOptions` skip any
    non-empty providerOptions payload with a clear skip reason, so a
    provider that would ignore `{seed: 42}` and succeed without the
    caller's intent never gets reached.
  - Candidates that declare a schema reject unknown keys with the list
    of accepted keys in the error.
  - Candidates that declare a schema reject type mismatches (expected
    number/boolean/string) with the declared type in the error.
  - All skip reasons push into `attempts` so the aggregated failure
    message at the end of the fallback chain explains exactly why each
    candidate was rejected.

Also hardens the tool boundary: `providerOptions` that is not a plain
JSON object (including bogus arrays like `["seed", 42]`) now throws a
`ToolInputError` up front instead of being cast to `Record` and
forwarded with numeric-string keys.

Consistent with the audio/duration skip-in-fallback pattern introduced
by yongliang.xie in earlier commits on this branch.

Co-authored-by: yongliang.xie <yongliang.xie@bytedance.com>

* video-gen: harden *Roles parity + document canonical role values

Replaces the inline `parseRolesArg` lambda with a dedicated
`parseRoleArray` helper that throws a ToolInputError when the caller
supplies more roles than assets. Off-by-one alignment mistakes in
`imageRoles` / `videoRoles` / `audioRoles` now fail loudly at the tool
boundary instead of silently dropping trailing roles.

Also tightens the schema descriptions to document the canonical
VideoGenerationAssetRole values (first_frame, last_frame, reference_*)
and the skip-in-fallback contract on providerOptions, and rejects
non-array inputs to any `*Roles` field early rather than coercing them
to an empty list.

Co-authored-by: yongliang.xie <yongliang.xie@bytedance.com>

* video-gen: surface dropped aspectRatio sentinels in ignoredOverrides

"adaptive" and other provider-specific sentinel aspect ratios are
unparseable as numeric ratios, so when the active provider does not
declare the sentinel in caps.aspectRatios, `resolveClosestAspectRatio`
returns undefined and the previous code silently nulled out
`aspectRatio` without surfacing a warning.

Push the dropped value into `ignoredOverrides` so the tool result
warning path ("Ignored unsupported overrides for …") picks it up, and
the caller gets visible feedback that the request was dropped instead
of a silent no-op. Also corrects the tool-side comment on
SUPPORTED_ASPECT_RATIOS to describe actual behavior.

Co-authored-by: yongliang.xie <yongliang.xie@bytedance.com>

* video-gen: surface declared providerOptions + maxInputAudios in action=list

`video_generate action=list` now includes the declared providerOptions
schema (key:type) per provider, so agents can discover which opaque
keys each provider accepts without trial and error. Both mode-level and
flat-provider providerOptions declarations are merged, matching the
runtime lookup order in `generateVideo`.

Also surfaces `maxInputAudios` alongside the other max-input counts for
completeness — previously the list output did not expose the audio cap
at all, even though the tool validates against it.

Co-authored-by: yongliang.xie <yongliang.xie@bytedance.com>

* video-gen: warn once per request when runtime skips a fallback candidate

The skip-in-fallback guards (audio cap, duration cap, providerOptions)
all logged at debug level, which meant operators had no visible signal
when the primary provider was silently passed over in favor of a
fallback. Add a first-skip log.warn in the runtime loop so the reason
for the first rejection is surfaced once per request, and leave the
rest of the skip events at debug to avoid flooding on long chains.

Co-authored-by: yongliang.xie <yongliang.xie@bytedance.com>

* video-gen: cover new tool-level behavior with regression tests

Adds regression tests for:
  - providerOptions shape rejection (arrays, strings)
  - providerOptions happy-path forwarding to runtime
  - imageRoles length-parity guard
  - *Roles non-array rejection
  - positional role attachment to loaded reference images
  - audio data: URL templated rejection branch
  - aspectRatio='adaptive' acceptance and forwarding
  - unsupported aspectRatio rejection (mentions 'adaptive' in the error)

All eight new cases run in the existing video-generate-tool suite and
use the same provider-mock pattern already established in the file.

Co-authored-by: yongliang.xie <yongliang.xie@bytedance.com>

* video-gen: cover runtime providerOptions skip-in-fallback branches

Adds runtime regression tests for the new typed-providerOptions guard:
  - candidates without a declared providerOptions schema are skipped
    when any providerOptions is supplied (prevents silent drop)
  - candidates that declare a schema skip on unknown keys with the
    accepted-key list surfaced in the error
  - candidates that declare a schema skip on type mismatches with the
    declared type surfaced in the error
  - end-to-end fallback: openai (no providerOptions) is skipped and
    byteplus (declared schema) accepts the same request, with an
    attempt entry recording the first skip reason

Also updates the existing 'forwards providerOptions to the provider
unchanged' case so the destination provider declares the matching
typed schema, and wires a `warn` stub into the hoisted logger mock
so the new first-skip log.warn call path does not blow up.

Co-authored-by: yongliang.xie <yongliang.xie@bytedance.com>

* changelog: note video_generate providerOptions / inputAudios / role hints

Adds an Unreleased Changes entry describing the user-visible surface
expansion for video_generate: typed providerOptions capability,
inputAudios reference audio, per-asset role hints via the canonical
VideoGenerationAssetRole union, the 'adaptive' aspect-ratio sentinel,
maxInputAudios capability, and the relaxed 9-image cap.

Credits the original PR author.

Co-authored-by: yongliang.xie <yongliang.xie@bytedance.com>

* byteplus: declare providerOptions schema (seed, draft, camerafixed) and forward to API

Made-with: Cursor

* byteplus: fix camera_fixed body field (API uses underscore, not camerafixed)

Made-with: Cursor

* fix(byteplus): normalize resolution to lowercase before API call

The Seedance API rejects resolution values with uppercase letters —
"480P", "720P" etc return InvalidParameter, while "480p", "720p"
are accepted. This was breaking the video generation live test
(resolveLiveVideoResolution returns "480P").

Normalize req.resolution to lowercase at the provider layer before
setting body.resolution, so any caller-supplied casing is corrected
without requiring changes to the VideoGenerationResolution type or
live-test helpers.

Verified via direct API call:
  body.resolution = "480P" → HTTP 400 InvalidParameter
  body.resolution = "480p" → task created successfully
  body.resolution = "720p" → task created successfully (t2v, i2v, 1.5-pro)
  body.resolution = "1080p" → task created successfully

Made-with: Cursor

* video-gen/byteplus: auto-select i2v model when input images provided with t2v model

Seedance 1.0 uses separate model IDs for T2V (seedance-1-0-lite-t2v-250428)
and I2V (seedance-1-0-lite-i2v-250428). When the caller requests a T2V model
but also provides inputImages, the API rejects with task_type i2v not supported
on t2v model.

Fix: when inputImages are present and the requested model contains "-t2v-",
auto-substitute "-i2v-" so the API receives the correct model. Seedance 1.5 Pro
uses a single model ID for both modes and is unaffected by this substitution.

Verified via live test: both mode=generate and mode=imageToVideo pass for
byteplus/seedance-1-0-lite-t2v-250428 with no failures.

Co-authored-by: odysseus0 <odysseus0@example.com>
Made-with: Cursor

* video-gen: fix duration rounding + align BytePlus (1.0) docs (P2)

Made-with: Cursor

* video-gen: relax providerOptions gate for undeclared-schema providers (P1)

Distinguish undefined (not declared = backward-compat pass-through) from
{} (explicitly declared empty = no options accepted) in
validateProviderOptionsAgainstDeclaration. Providers without a declared
schema receive providerOptions as-is; providers with an explicit empty
schema still skip. Typed schemas continue to validate key names and types.

Also: restore camera_fixed (underscore) in BytePlus provider schema and
body key (regression from earlier rebase), remove duplicate local
readBooleanToolParam definition now imported from media-tool-shared,
update tests and docs accordingly.

Made-with: Cursor

* video_generate: add landing follow-up coverage

* video_generate: finalize plugin-sdk baseline (#61987) (thanks @xieyongliang)

---------

Co-authored-by: yongliang.xie <yongliang.xie@bytedance.com>
Co-authored-by: George Zhang <georgezhangtj97@gmail.com>
Co-authored-by: odysseus0 <odysseus0@example.com>
2026-04-11 02:23:14 -07:00
Radek Sienkiewicz
f2a4a5ac21 fix(google): omit unsupported numberOfVideos in Veo requests (#64723)
Merged via squash.

Prepared head SHA: dadfd3351f
Co-authored-by: velvet-shark <126378+velvet-shark@users.noreply.github.com>
Co-authored-by: velvet-shark <126378+velvet-shark@users.noreply.github.com>
Reviewed-by: @velvet-shark
2026-04-11 11:17:01 +02:00
fuller-stack-dev
58708e6f88 fix: preserve Codex OAuth scopes (#64713) (thanks @fuller-stack-dev)
* fix(auth): preserve upstream Codex OAuth scopes

* test(auth): drop stale Codex OAuth helper test

* test(auth): colocate codex oauth coverage

* fix: preserve Codex OAuth scopes (#64713) (thanks @fuller-stack-dev)

* fix: place Codex OAuth changelog entry in Unreleased (#64713) (thanks @fuller-stack-dev)

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-04-11 14:38:19 +05:30
Gustavo Garcia
bb543f71d9 fix(talk): fix ensure permissions on first execution of Talk Mode in MacOS (#62459)
* fix(talk): fix ensure permissions on first execution of Talk Mode in MacOS

* macos: fix talk mode formatting

* test: fix CI shard regressions

* docs: add talk mode changelog

---------

Co-authored-by: ImLukeF <92253590+ImLukeF@users.noreply.github.com>
2026-04-11 18:08:45 +10:00
Peter Steinberger
2681bbd9e7 test: move plugin list formatting to pure tests 2026-04-11 08:22:36 +01:00
Peter Steinberger
e2477ff726 test: move node pairing authz to pure coverage 2026-04-11 08:18:35 +01:00
Peter Steinberger
367043d1d1 test: fold sessions timeout checks into pure coverage 2026-04-11 08:15:19 +01:00
Peter Steinberger
7e66a8fcfe test: move plugin uninstall selection to pure tests 2026-04-11 08:12:34 +01:00
Peter Steinberger
5ca92b0498 test: move plugin update selection to pure tests 2026-04-11 08:08:41 +01:00
Peter Steinberger
10dcd57846 perf: keep queue and group parsing pure 2026-04-11 08:05:05 +01:00
Peter Steinberger
2cfd1459ef perf: split command body normalization 2026-04-11 08:00:26 +01:00
Peter Steinberger
66a081442f test: consolidate directive coverage 2026-04-11 07:54:50 +01:00
Peter Steinberger
7273cae36b test: move spawn and doctor coverage to owners 2026-04-11 07:54:19 +01:00
Peter Steinberger
32b252cabf test: move inline directive stripping coverage 2026-04-11 07:42:01 +01:00
Peter Steinberger
2b1d154533 test: narrow model override directive check 2026-04-11 07:37:52 +01:00
Peter Steinberger
36c412d81e test: move reserved help alias coverage 2026-04-11 07:33:55 +01:00
Peter Steinberger
8fb482268f perf: import queue settings directly 2026-04-11 07:33:54 +01:00
BitToby
c50d7183d6 fix: Fix webchat TTS tool audio delivery (#63514)
Merged via squash.

Prepared head SHA: ba92cbbd7c
Co-authored-by: bittoby <218712309+bittoby@users.noreply.github.com>
Co-authored-by: mukhtharcm <56378562+mukhtharcm@users.noreply.github.com>
Reviewed-by: @mukhtharcm
2026-04-11 12:02:07 +05:30
Peter Steinberger
be9b70c815 perf: short-circuit exact reply suppression targets 2026-04-11 07:26:19 +01:00
Peter Steinberger
9d45866038 test: mock telegram reply suppression fallback 2026-04-11 07:26:19 +01:00
ImLukeF
7f2814fc4a agents: honor explicit run timeout for LLM idle watchdog 2026-04-11 16:25:41 +10:00
Peter Steinberger
5605c89cb3 test: mock channel plugin lookup in media read policy 2026-04-11 07:20:06 +01:00
Peter Steinberger
01060d283d test: install task flow owner memory store after reset 2026-04-11 07:17:31 +01:00
Peter Steinberger
61ee69e110 test: isolate task flow owner registry 2026-04-11 07:15:36 +01:00
Peter Steinberger
b25c735684 test: make fuzzy model directive checks pure 2026-04-11 07:08:23 +01:00
Peter Steinberger
e2d93fb5bc perf: short-circuit static doctor channel capabilities 2026-04-11 07:03:48 +01:00
Peter Steinberger
9e3f4ed22f test: narrow elevated and queue directive checks 2026-04-11 07:00:06 +01:00
Peter Steinberger
7b29cb6ef6 test: narrow queue directive validation checks 2026-04-11 06:52:04 +01:00
Peter Steinberger
455535a4f9 perf: avoid plugin index for target normalization 2026-04-11 06:49:08 +01:00
ImLukeF
ddefce3c18 Config: align LLM idle timeout defaults 2026-04-11 15:48:58 +10:00
Peter Steinberger
3edc8d3028 test: mock message action aliases in normalization 2026-04-11 06:45:53 +01:00
Peter Steinberger
28291eba62 perf: avoid plugin registry in reply threading 2026-04-11 06:42:35 +01:00
Peter Steinberger
7a1cc53b18 test: mock message action channel aliases 2026-04-11 06:41:41 +01:00
Peter Steinberger
2721245848 perf: avoid reply payload barrel in followups 2026-04-11 06:36:48 +01:00
Peter Steinberger
e34e714c76 test: narrow think status directive checks 2026-04-11 06:33:45 +01:00
Peter Steinberger
d35bd8d264 test: narrow standalone directive checks 2026-04-11 06:30:58 +01:00
Peter Steinberger
e4e6f42192 test: narrow directive status checks 2026-04-11 06:28:44 +01:00
Peter Steinberger
f9afdf0a07 perf: avoid signal approval plugin lookup 2026-04-11 06:22:21 +01:00
Peter Steinberger
d86377acfd test: narrow doctor legacy config aliases 2026-04-11 06:19:17 +01:00
Peter Steinberger
279cbfc61c fix: restore memory wiki and dreaming checks 2026-04-11 06:15:21 +01:00
Ayaan Zaidi
6aafca5b5e fix: avoid qa scenario pack reads during packaged CLI startup (#64648) 2026-04-11 10:41:19 +05:30
Ayaan Zaidi
d8ab47d6af refactor: remove qa cli pass-through wrapper 2026-04-11 10:41:19 +05:30
Ayaan Zaidi
478a2e15c5 fix: narrow qa cli facade startup path 2026-04-11 10:41:19 +05:30
Peter Steinberger
788f0c625e test: shrink oversized image fixture 2026-04-11 06:10:01 +01:00
Peter Steinberger
850cdc3201 test: mock open-policy channel modes 2026-04-11 06:08:11 +01:00
Peter Steinberger
2e0ec2324c test: complete directive hook-runner mock 2026-04-11 06:06:09 +01:00
Mariano
64693d2e96 [codex] Dreaming: surface memory wiki imports and palace (#64505)
Merged via squash.

Prepared head SHA: 12d5e37222
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
2026-04-11 07:04:08 +02:00
Peter Steinberger
6492cc7428 test: isolate doctor repair sequencing 2026-04-11 06:01:40 +01:00
Peter Steinberger
cb01b0072d test: narrow doctor shared channel mocks 2026-04-11 05:58:47 +01:00
Peter Steinberger
c836fd22d0 test: narrow plugin auto-enable manifest coverage 2026-04-11 05:54:36 +01:00
Peter Steinberger
8ab84bceb3 test: make talk and compaction config checks pure 2026-04-11 05:52:03 +01:00
Peter Steinberger
d72cb14f78 test: make compaction config checks pure 2026-04-11 05:49:37 +01:00
Peter Steinberger
7591d01bdb perf: defer bundled channel metadata lookups 2026-04-11 05:44:40 +01:00
Tak Hoffman
f5bd97ea36 fix(prompt): restore channel-aware approval guidance 2026-04-10 23:44:10 -05:00
Peter Steinberger
2d6519dcb9 perf: defer bundled channel presence lookups 2026-04-11 05:42:01 +01:00
Peter Steinberger
70c0a64595 test: mock channel configured state seams 2026-04-11 05:37:03 +01:00
Peter Steinberger
9f5e476d27 test: avoid channel contract imports in config policy tests 2026-04-11 05:34:31 +01:00
Peter Steinberger
f25fd327c3 test: reduce config validation imports 2026-04-11 05:32:20 +01:00
Peter Steinberger
3d9792b6d0 test: make imessage legacy config checks pure 2026-04-11 05:27:38 +01:00
Tak Hoffman
09e51bcacf fix(ui): harden local attachment preview checks 2026-04-10 23:25:55 -05:00
Peter Steinberger
12e11342cb test: use discord schema in config tests 2026-04-11 05:20:29 +01:00
Peter Steinberger
97c9a362f7 test: use channel schemas for webhook validation 2026-04-11 05:16:51 +01:00
Peter Steinberger
feef387a75 test: narrow config defaults regressions 2026-04-11 05:11:47 +01:00
Peter Steinberger
fcf31eef64 test: narrow whatsapp auto-enable validation 2026-04-11 05:07:01 +01:00
Tak Hoffman
80f217ec65 fix(prompt): restore stable runtime prompt rendering 2026-04-10 23:06:35 -05:00
Tak Hoffman
bf544bc9e9 docs: fix active memory gateway command 2026-04-10 23:02:13 -05:00
Peter Steinberger
40975ec9f1 test: use channel schemas in config regressions 2026-04-11 05:01:14 +01:00
Peter Steinberger
ad7ad62632 test: narrow allowed-values validation coverage 2026-04-11 04:57:11 +01:00
Peter Steinberger
c38d4438c6 test: use provider schemas for config policy checks 2026-04-11 04:53:23 +01:00
Peter Steinberger
1ab6e5dbf0 chore(release): bump version to 2026.4.11 2026-04-11 04:51:17 +01:00
Tak Hoffman
d95c549dee fix(ci): repair merged branch type drift 2026-04-10 22:46:29 -05:00
Peter Steinberger
af41acc8a6 chore(release): update macOS appcast for v2026.4.10 2026-04-11 04:32:55 +01:00
Peter Steinberger
dfd4e9f8a1 fix(release): write npm auth for latest promotion 2026-04-11 04:29:25 +01:00
Yonatan
38cd7f72b6 fix(whatsapp): resolve configured default account in single-arg setActiveWebListener overload (#53918)
Merged via squash.

Prepared head SHA: ad9be63835
Co-authored-by: yhyatt <10474956+yhyatt@users.noreply.github.com>
Co-authored-by: mcaxtr <7562095+mcaxtr@users.noreply.github.com>
Reviewed-by: @mcaxtr
2026-04-11 00:25:16 -03:00
Tak Hoffman
a9034d117c Merge remote-tracking branch 'origin/main' into codex/ui-canvas-origin-main 2026-04-10 22:21:39 -05:00
Ayaan Zaidi
959b1472dc test(qa-lab): include telegram mentioned-message scenario 2026-04-11 08:48:42 +05:30
Ayaan Zaidi
b0b0fb308d feat(qa-lab): add telegram mentioned-message scenario 2026-04-11 08:48:42 +05:30
Ayaan Zaidi
a0b5c7b0c4 test(qa-lab): cover telegram command demo scenarios 2026-04-11 08:48:42 +05:30
Ayaan Zaidi
7c14d8b0f4 feat(qa-lab): add telegram command demo scenarios 2026-04-11 08:48:42 +05:30
Ayaan Zaidi
f9a03f0f4b test(qa-lab): cover telegram mention-gating 2026-04-11 08:48:42 +05:30
Ayaan Zaidi
355690a72c feat(qa-lab): add telegram mention-gating scenario 2026-04-11 08:48:42 +05:30
Tak Hoffman
abe7beb603 fix(gateway): tighten embed follow-up review fixes 2026-04-10 22:12:09 -05:00
Peter Steinberger
d515009c53 fix(ci): stabilize auto-reply CI tests 2026-04-11 04:09:10 +01:00
Peter Steinberger
44e5b62c27 fix(macos): harden shell executor timeouts 2026-04-11 03:58:20 +01:00
Tak Hoffman
b5eb259741 fix(gateway): restrict canvas history hoisting to tool entries 2026-04-10 21:55:56 -05:00
George Zhang
9a4a9a5993 Heartbeat: spread interval runs across stable phases (#64560)
Merged via squash.

Prepared head SHA: 774ede6408
Co-authored-by: odysseus0 <8635094+odysseus0@users.noreply.github.com>
Co-authored-by: odysseus0 <8635094+odysseus0@users.noreply.github.com>
Reviewed-by: @odysseus0
2026-04-10 19:40:21 -07:00
Peter Steinberger
e11d902b7d fix(ci): stop telegram debounce media leak 2026-04-11 03:36:48 +01:00
Tak Hoffman
256d9d2524 Merge remote-tracking branch 'origin/main' into codex/ui-canvas-origin-main 2026-04-10 21:32:23 -05:00
Peter Steinberger
df7e61b546 fix(ci): align compact count assertion 2026-04-11 03:32:03 +01:00
Tak Hoffman
1457a6a2ff Merge remote-tracking branch 'origin/main' into codex/ui-canvas-origin-main 2026-04-10 21:31:50 -05:00
Peter Steinberger
5b2888e1fd test(install): pin smoke docker platform 2026-04-11 03:31:47 +01:00
Peter Steinberger
421338f585 test(install): quiet smoke npm output 2026-04-11 03:31:47 +01:00
Peter Steinberger
05659cfbc3 test: harden macOS Parallels permission check 2026-04-11 03:30:01 +01:00
Peter Steinberger
896eb888a8 fix(ci): align target session alias fixture 2026-04-11 03:27:20 +01:00
Peter Steinberger
05521242cd fix(ci): stabilize agentic compact tests 2026-04-11 03:25:32 +01:00
Tak Hoffman
fa24589921 Merge remote-tracking branch 'origin/main' into codex/ui-canvas-origin-main 2026-04-10 21:22:50 -05:00
Tak Hoffman
1ca1322067 docs(ui): document embed sandbox modes 2026-04-10 21:10:19 -05:00
Tak Hoffman
d11192da46 Merge origin/main into codex/ui-canvas-origin-main 2026-04-10 21:03:26 -05:00
Tak Hoffman
45a56d6093 Merge origin/main into codex/ui-canvas-origin-main 2026-04-10 21:02:09 -05:00
Tak Hoffman
0995e474be Merge origin/main into codex/ui-canvas-origin-main 2026-04-10 20:58:03 -05:00
Tak Hoffman
e2cfb8be4e fix(ui): preserve relative media directives in history 2026-04-10 20:47:12 -05:00
Tak Hoffman
79d62d833f feat(ui): add granular embed sandbox modes 2026-04-10 20:43:04 -05:00
Tak Hoffman
d104ebbacc Merge origin/main into codex/ui-canvas-origin-main 2026-04-10 20:17:25 -05:00
Tak Hoffman
cf5b2e64c5 fix(ui): suppress silent transcript tokens with media 2026-04-10 20:08:08 -05:00
Tak Hoffman
27e9d327b7 fix(ui): forward password auth for assistant media 2026-04-10 19:25:44 -05:00
Tak Hoffman
ec2d36cf41 fix(ui): address latest history and directive reviews 2026-04-10 19:11:40 -05:00
Tak Hoffman
0c6622a610 fix(ui): restore prompt contribution wiring 2026-04-10 18:51:31 -05:00
Tak Hoffman
188209b1a0 fix(ui): address history and attachment review findings 2026-04-10 17:52:50 -05:00
Tak Hoffman
4fb2cbee11 fix(ui): restore stop control and tool card inputs 2026-04-10 17:33:12 -05:00
Tak Hoffman
84b1440f23 fix(ui): address remaining embed and attachment review findings 2026-04-10 17:06:07 -05:00
Tak Hoffman
320617fb93 fix(ui): address remaining media and gateway review issues 2026-04-10 17:06:07 -05:00
Tak Hoffman
2fc8240de0 feat(ui): rename public canvas tag to embed 2026-04-10 17:06:07 -05:00
Tak Hoffman
76e2a5504b fix(gateway): restore media root and auth getter compatibility 2026-04-10 17:06:07 -05:00
Tak Hoffman
64eccc4545 Fix control UI reconnect cleanup regressions 2026-04-10 17:05:21 -05:00
Tak Hoffman
5fdfee4c74 Restore dropped control UI shell wiring 2026-04-10 17:05:21 -05:00
Tak Hoffman
2f8fdb9b8e fix(gateway): restore ws hello policy details 2026-04-10 17:05:21 -05:00
Tak Hoffman
6d08483e93 fix(gateway): restore websocket pairing handshake flows 2026-04-10 17:05:21 -05:00
Tak Hoffman
93e5cd9304 fix(gateway): harden assistant media and auth rotation 2026-04-10 17:05:21 -05:00
Tak Hoffman
041deaa0ce feat(ui): add configurable embed sandbox mode 2026-04-10 17:05:21 -05:00
Tak Hoffman
23e10c373f Fix embed review follow-ups 2026-04-10 17:05:21 -05:00
Tak Hoffman
8f83ef151b Harden hook and media routing 2026-04-10 17:05:21 -05:00
Tak Hoffman
b4dac31d2a Restore offloaded chat attachment persistence 2026-04-10 17:05:21 -05:00
Tak Hoffman
251ec5fcea Fix embed follow-up review regressions 2026-04-10 17:05:21 -05:00
Tak Hoffman
a131324aea Harden embed iframe URL handling 2026-04-10 17:05:21 -05:00
Tak Hoffman
0504806af8 Fix chat media and history regressions 2026-04-10 17:05:21 -05:00
Tak Hoffman
1df0c62de8 Secure assistant media route and preserve UI avatar override 2026-04-10 17:05:20 -05:00
Tak Hoffman
e14aa30fde Harden canvas path resolution and stage isolation 2026-04-10 17:05:20 -05:00
Tak Hoffman
d14fd10c2f Add changelog entry for embed rendering 2026-04-10 17:05:20 -05:00
Tak Hoffman
82b3bd69dc Add embed rendering for Control UI assistant output 2026-04-10 17:05:20 -05:00
1241 changed files with 43757 additions and 9230 deletions

View File

@@ -29,7 +29,13 @@ Use this skill for Parallels guest workflows and smoke interpretation. Do not lo
## npm install then update
- Preferred entrypoint: `pnpm test:parallels:npm-update`
- Flow: fresh snapshot -> install npm package baseline -> smoke -> install current main tgz on the same guest -> smoke again.
- Required coverage: every release/update regression run must include both lanes:
- fresh snapshot -> install requested package/baseline -> smoke
- same guest baseline -> run the guest's installed `openclaw update ...` command -> smoke again
- The update lane must exercise OpenClaw's internal updater. Do not count a direct `npm install -g <tgz-or-spec>` or harness-side package swap as update-flow coverage; those are install smokes only.
- For published targets, install the old baseline package first (for example `openclaw@2026.4.9`), then run the installed guest CLI with the intended channel/tag (for example `openclaw update --channel beta --yes --json`) and verify `openclaw --version`, `openclaw update status --json`, gateway RPC, and an agent turn after the command.
- For unpublished targets, pack the candidate on the host, serve the `.tgz` over the harness HTTP server, and point the guest updater at that served package. Prefer `openclaw update --tag http://<host-ip>:<port>/openclaw-<version>.tgz --yes --json`; when channel persistence also matters, pass `--channel <stable|beta>` and set `OPENCLAW_UPDATE_PACKAGE_SPEC` to the same served URL in the guest update environment. The command under test must still be `openclaw update`, not direct npm.
- For unpublished local-fix validation, remember the old baseline updater code still controls the first hop. A fix that lives only in the new updater code cannot change that already-running old process; the served candidate must either keep package/plugin metadata compatible with the baseline host or the baseline itself must include the updater fix.
- For beta/stable verification, resolve the tag immediately before the run (`npm view openclaw@beta version dist.tarball` or `npm view openclaw@latest ...`). Tags can move while a long VM matrix is already running; restart the matrix when the intended prerelease appears after an earlier registry 404/tag-lag check.
- Source Peter's profile in the host shell (`set -a; source "$HOME/.profile"; set +a`) before OpenAI/Anthropic lanes. Do not print profile contents or env dumps; pass provider secrets through the guest exec environment.
- Same-guest update verification should set the default model explicitly to `openai/gpt-5.4` before the agent turn and use a fresh explicit `--session-id` so old session model state does not leak into the check.

View File

@@ -694,7 +694,7 @@ jobs:
EOF
checks-node-core-test:
name: checks-node-core-test
name: checks-node-core
needs: [preflight, checks-node-core-test-shard]
if: always() && needs.preflight.outputs.run_checks == 'true'
runs-on: blacksmith-16vcpu-ubuntu-2404

View File

@@ -194,6 +194,13 @@ jobs:
push: false
provenance: false
- name: Setup Node environment for local pack smoke
uses: ./.github/actions/setup-node-env
with:
install-bun: "false"
install-deps: "true"
use-sticky-disk: "false"
- name: Run installer docker tests
env:
OPENCLAW_INSTALL_URL: https://openclaw.ai/install.sh

View File

@@ -493,6 +493,7 @@ jobs:
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
run: |
set -euo pipefail
printf '//registry.npmjs.org/:_authToken=%s\n' "${NODE_AUTH_TOKEN}" > "${HOME}/.npmrc"
npm whoami >/dev/null
npm dist-tag add "openclaw@${RELEASE_VERSION}" latest
promoted_latest="$(npm view openclaw dist-tags.latest)"

View File

@@ -17,6 +17,5 @@
"typescript.preferences.importModuleSpecifierEnding": "js",
"typescript.reportStyleChecksAsWarnings": false,
"typescript.updateImportsOnFileMove.enabled": "always",
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.experimental.useTsgo": true
"typescript.tsdk": "node_modules/typescript/lib"
}

View File

@@ -6,8 +6,20 @@ Docs: https://docs.openclaw.ai
### Changes
- Tools/video_generate: allow providers and plugins to return URL-only generated video assets so agent delivery and `openclaw capability video generate --output ...` can forward or stream large videos without requiring the full file in memory first. (#61988) Thanks @xieyongliang.
- Models/providers: surface how configured OpenAI-compatible endpoints are classified in embedded-agent debug logs, so local and proxy routing issues are easier to diagnose. (#64754) Thanks @ImLukeF.
### Fixes
- WhatsApp: honor the configured default account when the active listener helper is used without an explicit account id, so named default accounts do not get registered under `default`. (#53918) Thanks @yhyatt.
- QA/packaging: stop packaged CLI startup and completion cache generation from reading repo-only QA scenario markdown by routing QA command registration through a narrow facade. (#64648) Thanks @obviyus.
- QA/packaging: ship the bundled QA scenario pack in npm releases and keep `openclaw completion --write-state` working even if QA setup is broken, so missing QA content only degrades QA instead of breaking broader CLI startup-adjacent flows. Thanks @vincentkoc.
- Codex/QA: keep Codex app-server coordination chatter out of visible replies, add a live QA leak scenario, and classify leaked harness meta text as a QA failure instead of a successful reply. Thanks @vincentkoc.
- Control UI/webchat: persist agent-run TTS audio replies into webchat history before finalization so tool-generated audio reaches webchat clients again. (#63514) thanks @bittoby
- macOS/Talk Mode: after granting microphone permission on first enable, continue starting Talk Mode instead of requiring a second toggle. (#62459) Thanks @ggarber.
- OpenAI/Codex OAuth: stop rewriting the upstream authorize URL scopes so new Codex sign-ins do not fail with `invalid_scope` before returning an authorization code. (#64713) Thanks @fuller-stack-dev.
- Google/Veo: stop sending the unsupported `numberOfVideos` request field so Gemini Developer API Veo runs do not fail before OpenClaw can complete the intended Google video generation path. (#64723) thanks @velvet-shark
## 2026.4.10
### Changes
@@ -24,11 +36,14 @@ Docs: https://docs.openclaw.ai
- Gateway: add a `commands.list` RPC so remote gateway clients can discover runtime-native, text, skill, and plugin commands with surface-aware naming and serialized argument metadata. (#62656) Thanks @samzong.
- Models/providers: add per-provider `models.providers.*.request.allowPrivateNetwork` for trusted self-hosted OpenAI-compatible endpoints, keep the opt-in scoped to model request surfaces, and refresh cached WebSocket managers when request transport overrides change. (#63671) Thanks @qas.
- Feishu: standardize request user agents and register the bot as an AI agent so Feishu deployments identify OpenClaw consistently. (#63835) Thanks @evandance.
- Docs i18n: chunk raw doc translation, reject truncated tagged outputs, avoid ambiguous body-only wrapper unwrapping, and recover from terminated Pi translation sessions without changing the default `openai/gpt-5.4` path. (#62969, #63808) Thanks @hxy91819.
- Gateway: split startup and runtime seams so gateway lifecycle sequencing, reload state, and shutdown behavior stay easier to maintain without changing observed behavior. (#63975) Thanks @gumadeiras.
- Control UI/webchat: normalize assistant `MEDIA:`/reply/voice directives into structured bubble rendering, rename the unreleased rich web shortcode to `[embed ...]`, and surface session runtime roots so hosted web content is written to the correct document path instead of guessed local files.
- Matrix/partial streaming: add MSC4357 live markers to draft preview sends and edits so supporting Matrix clients can render a live/typewriter animation and stop it when the final edit lands. (#63513) Thanks @TigerInYourDream.
- Control UI/dreaming: simplify the Scene and Diary surfaces, preserve unknown phase state for partial status payloads, and stabilize waiting-entry recency ordering so Dreaming status and review lists stay clear and deterministic. (#64035) Thanks @davemorin.
- Agents: add an opt-in strict-agentic embedded Pi execution contract for GPT-5-family runs so plan-only or filler turns keep acting until they hit a real blocker. (#64241) Thanks @100yenadmin.
- Agents/OpenAI: add provider-owned OpenAI/Codex tool schema compatibility and surface embedded-run replay/liveness state for long-running runs. (#64300) Thanks @100yenadmin.
- Docs i18n: chunk raw doc translation, reject truncated tagged outputs, avoid ambiguous body-only wrapper unwrapping, and recover from terminated Pi translation sessions without changing the default `openai/gpt-5.4` path. (#62969, #63808) Thanks @hxy91819.
- Dreaming/memory-wiki: add ChatGPT import ingestion plus new `Imported Insights` and `Memory Palace` diary subtabs so Dreaming can inspect imported source chats, compiled wiki pages, and full source pages directly from the UI. (#64505)
### Fixes
@@ -115,12 +130,20 @@ Docs: https://docs.openclaw.ai
- Daemon/gateway: prevent systemd restart storms on configuration errors by exiting with `EX_CONFIG` and adding generated unit restart-prevention guards. (#63913) Thanks @neo1027144-creator.
- Agents/exec: prevent gateway crash ("Agent listener invoked outside active run") when a subagent exec tool produces stdout/stderr after the agent run has ended or been aborted. (#62821) Thanks @openperf.
- Gateway/OpenAI compat: return real `usage` for non-stream `/v1/chat/completions` responses, emit the final usage chunk when `stream_options.include_usage=true`, and bound usage-gated stream finalization after lifecycle end. (#62986) Thanks @Lellansin.
- Matrix/migration: keep packaged warning-only crypto migrations from being misclassified as actionable when only helper chunks are present, so startup and doctor stay on the warning-only path instead of creating unnecessary migration snapshots. (#64373) Thanks @gumadeiras.
- Matrix/ACP thread bindings: preserve canonical room casing and parent conversation routing during ACP session spawn so mixed-case room ids bind correctly from top-level rooms and existing Matrix threads. (#64343) Thanks @gumadeiras.
- Agents/subagents: deduplicate delivered completion announces so retry or re-entry cleanup does not inject duplicate internal-context completion turns into the parent session. (#61525) Thanks @100yenadmin.
- Agents/exec: keep sandboxed `tools.exec.host=auto` sessions from honoring per-call `host=node` or `host=gateway` overrides while a sandbox runtime is active, and stop advertising node routing in that state so exec stays on the sandbox host. (#63880)
- Agents/subagents: preserve archived delete-mode runs until `sessions.delete` succeeds and prevent overlapping archive sweeps from duplicating in-flight cleanup attempts. (#61801) Thanks @100yenadmin.
- Cron/isolated agent: run scheduled agent turns as non-owner senders so owner-only tools stay unavailable during cron execution. (#63878)
- Discord/sandbox: include `image` in sandbox media param normalization so Discord event cover images cannot bypass sandbox path rewriting. (#64377) Thanks @mmaps.
- Agents/exec: extend exec completion detection to cover local background exec formats so the owner-downgrade fires correctly for all exec paths. (#64376) Thanks @mmaps.
- Security/dependencies: pin axios to 1.15.0 and add a plugin install dependency denylist that blocks known malicious packages before install. (#63891) Thanks @mmaps.
- Browser/security: apply three-phase interaction navigation guard to pressKey and type(submit) so delayed JS redirects from keypress cannot bypass SSRF policy. (#63889) Thanks @mmaps.
- Browser/security: guard existing-session Chrome MCP interaction routes with SSRF post-checks so delayed navigation from click, type, press, and evaluate cannot bypass the configured policy. (#64370) Thanks @eleqtrizit.
- Browser/security: default browser SSRF policy to strict mode so unconfigured installs block private-network navigation, and align external-content marker span mapping so ZWS-injected boundary spoofs are fully sanitized. (#63885) Thanks @eleqtrizit.
- Browser/security: apply SSRF navigation policy to subframe document navigations so iframe-targeted private-network hops are blocked without quarantining the parent page. (#64371) Thanks @eleqtrizit.
- Hooks/security: mark agent hook system events as untrusted and sanitize hook display names before cron metadata reuse. (#64372) Thanks @eleqtrizit.
- Daemon/launchd: keep `openclaw gateway stop` persistent without uninstalling the macOS LaunchAgent, re-enable it on explicit restart or repair, and harden launchd label handling. (#64447) Thanks @ngutman.
- Plugins/context engines: preserve `plugins.slots.contextEngine` through normalization and keep explicitly selected workspace context-engine plugins enabled, so loader diagnostics and plugin activation stop dropping that slot selection. (#64192) Thanks @hclsys.
@@ -131,6 +154,8 @@ Docs: https://docs.openclaw.ai
- Media/security: honor sender-scoped `toolsBySender` policy for outbound host-media reads so denied senders cannot trigger host file disclosure via attachment hydration. (#64459) Thanks @eleqtrizit.
- Browser/security: reject strict-policy hostname navigation unless the hostname is an explicit allowlist exception or IP literal, and route CDP HTTP discovery through the pinned SSRF fetch path. (#64367) Thanks @eleqtrizit.
- Models/vLLM: ignore empty `tool_calls` arrays from reasoning-model OpenAI-compatible replies, reset false `toolUse` stop reasons when no actual tool calls were parsed, and stop sending `tool_choice` unless tools are present so vLLM reasoning responses no longer hang indefinitely. (#61197, #61534) Thanks @balajisiva.
- Heartbeat/scheduling: spread interval heartbeats across stable per-agent phases derived from gateway identity, so provider traffic is distributed more uniformly across the configured interval instead of clustering around startup-relative times. (#64560) Thanks @odysseus0.
- Config/media: accept `tools.media.asyncCompletion.directSend` in strict config validation so gateways no longer reject the generated-schema-backed async media completion setting at startup. (#63618) Thanks @qiziAI.
## 2026.4.9
@@ -141,6 +166,7 @@ Docs: https://docs.openclaw.ai
- QA/lab: add character-vibes evaluation reports with model selection and parallel runs so live QA can compare candidate behavior faster.
- Plugins/provider-auth: let provider manifests declare `providerAuthAliases` so provider variants can share env vars, auth profiles, config-backed auth, and API-key onboarding choices without core-specific wiring.
- iOS: pin release versioning to an explicit CalVer in `apps/ios/version.json`, keep TestFlight iteration on the same short version until maintainers intentionally promote the next gateway version, and add the documented `pnpm ios:version:pin -- --from-gateway` workflow for release trains. (#63001) Thanks @ngutman.
- Tools/video_generate: extend the tool and the Plugin SDK with `providerOptions` (vendor-specific options forwarded as a JSON object), `inputAudios` / `audioRef` / `audioRefs` reference audio inputs, per-asset semantic role hints (`imageRoles` / `videoRoles` / `audioRoles`) using a typed `VideoGenerationAssetRole` union, a new `"adaptive"` aspect-ratio sentinel, and `maxInputAudios` provider capability declarations. Providers opt into `providerOptions` by declaring a typed `capabilities.providerOptions` schema (`{ seed: "number", draft: "boolean", ... }`); unknown keys and type mismatches cause the runtime fallback loop to skip the candidate with a visible warning and an `attempts` entry, so vendor-specific options never silently reach the wrong provider. Also raises the in-tool image input cap to 9 and updates the docs table to list all new parameters. (#61987) Thanks @xieyongliang.
### Fixes

View File

@@ -2,6 +2,150 @@
<rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" version="2.0">
<channel>
<title>OpenClaw</title>
<item>
<title>2026.4.10</title>
<pubDate>Sat, 11 Apr 2026 03:17:02 +0000</pubDate>
<link>https://raw.githubusercontent.com/openclaw/openclaw/main/appcast.xml</link>
<sparkle:version>2026041090</sparkle:version>
<sparkle:shortVersionString>2026.4.10</sparkle:shortVersionString>
<sparkle:minimumSystemVersion>15.0</sparkle:minimumSystemVersion>
<description><![CDATA[<h2>OpenClaw 2026.4.10</h2>
<h3>Changes</h3>
<ul>
<li>Models/Codex: add the bundled Codex provider and plugin-owned app-server harness so <code>codex/gpt-*</code> models use Codex-managed auth, native threads, model discovery, and compaction while <code>openai/gpt-*</code> stays on the normal OpenAI provider path. (#64298)</li>
<li>Memory/Active Memory: add a new optional Active Memory plugin that gives OpenClaw a dedicated memory sub-agent right before the main reply, so ongoing chats can automatically pull in relevant preferences, context, and past details without making users remember to manually say "remember this" or "search memory" first. Includes configurable message/recent/full context modes, live <code>/verbose</code> inspection, advanced prompt/thinking overrides for tuning, and opt-in transcript persistence for debugging. Docs: https://docs.openclaw.ai/concepts/active-memory. (#63286) Thanks @Takhoffman.</li>
<li>macOS/Talk: add an experimental local MLX speech provider for Talk Mode, with explicit provider selection, local utterance playback, interruption handling, and system-voice fallback. (#63539) Thanks @ImLukeF.</li>
<li>Tools/video generation: add Seedance 2.0 model refs to the bundled fal provider and submit the provider-specific duration, resolution, audio, and seed metadata fields needed for live Seedance 2.0 runs.</li>
<li>Microsoft Teams: add message actions for pin, unpin, read, react, and listing reactions. (#53432) Thanks @sudie-codes.</li>
<li>QA/Matrix: add a live <code>openclaw qa matrix</code> lane backed by a disposable Matrix homeserver, shared live-transport seams, and Matrix-specific transport coverage for threading, reactions, restart, and allowlist behavior. (#64489) Thanks @gumadeiras.</li>
<li>QA/Telegram: add a live <code>openclaw qa telegram</code> lane for private-group bot-to-bot checks, harden its artifact handling, and preserve native Telegram command reply threading for QA verification. (#64303) Thanks @obviyus.</li>
<li>QA/testing: add a <code>--runner multipass</code> lane for <code>openclaw qa suite</code> so repo-backed QA scenarios can run inside a disposable Linux VM and write back the usual report, summary, and VM logs. (#63426) Thanks @shakkernerd.</li>
<li>CLI/exec policy: add a local <code>openclaw exec-policy</code> command with <code>show</code>, <code>preset</code>, and <code>set</code> subcommands for synchronizing requested <code>tools.exec.*</code> config with the local exec approvals file, plus follow-up hardening for node-host rejection, rollback safety, and sync conflict detection. (#64050)</li>
<li>Gateway: add a <code>commands.list</code> RPC so remote gateway clients can discover runtime-native, text, skill, and plugin commands with surface-aware naming and serialized argument metadata. (#62656) Thanks @samzong.</li>
<li>Models/providers: add per-provider <code>models.providers.*.request.allowPrivateNetwork</code> for trusted self-hosted OpenAI-compatible endpoints, keep the opt-in scoped to model request surfaces, and refresh cached WebSocket managers when request transport overrides change. (#63671) Thanks @qas.</li>
<li>Feishu: standardize request user agents and register the bot as an AI agent so Feishu deployments identify OpenClaw consistently. (#63835) Thanks @evandance.</li>
<li>Matrix/partial streaming: add MSC4357 live markers to draft preview sends and edits so supporting Matrix clients can render a live/typewriter animation and stop it when the final edit lands. (#63513) Thanks @TigerInYourDream.</li>
<li>Control UI/dreaming: simplify the Scene and Diary surfaces, preserve unknown phase state for partial status payloads, and stabilize waiting-entry recency ordering so Dreaming status and review lists stay clear and deterministic. (#64035) Thanks @davemorin.</li>
<li>Agents: add an opt-in strict-agentic embedded Pi execution contract for GPT-5-family runs so plan-only or filler turns keep acting until they hit a real blocker. (#64241) Thanks @100yenadmin.</li>
<li>Agents/OpenAI: add provider-owned OpenAI/Codex tool schema compatibility and surface embedded-run replay/liveness state for long-running runs. (#64300) Thanks @100yenadmin.</li>
<li>Docs i18n: chunk raw doc translation, reject truncated tagged outputs, avoid ambiguous body-only wrapper unwrapping, and recover from terminated Pi translation sessions without changing the default <code>openai/gpt-5.4</code> path. (#62969, #63808) Thanks @hxy91819.</li>
</ul>
<h3>Fixes</h3>
<ul>
<li>Browser/security: tighten browser and sandbox navigation defenses across strict SSRF defaults, hostname allowlists, interaction-driven redirects, subframes, CDP discovery, existing sessions, tab actions, noVNC, marker-span sanitization, and Docker CDP source-range enforcement. (#61404, #63332, #63882, #63885, #63889, #64367, #64370, #64371)</li>
<li>Security/tools: harden exec preflight reads, host env denylisting, node output boundaries, outbound host-media reads, profile-mutation authorization, plugin install dependency scanning, ACPX tool hooks, Gmail watcher token redaction, and oversized realtime WebSocket frame handling. (#62333, #62661, #62662, #63277, #63551, #63553, #63886, #63890, #63891, #64459)</li>
<li>OpenAI/Codex: add required Codex OAuth scopes, classify provider/runtime failures more clearly, stop suggesting <code>/elevated full</code> when auto-approved host exec is unavailable, add OpenAI/Codex tool-schema compatibility, and preserve embedded-run replay/liveness truth across compaction retries and mutating side effects. (#64300, #64439) Thanks @100yenadmin.</li>
<li>CLI/WhatsApp media sends: route gateway-mode outbound sends with <code>--media</code> through the channel <code>sendMedia</code> path and preserve media access context, so WhatsApp document and attachment sends stop silently dropping the file while still delivering the caption. (#64478, #64492) Thanks @ShionEria.</li>
<li>Microsoft Teams: restore media downloads for personal DMs, Bot Framework <code>a:</code> conversations, OneDrive/SharePoint shared files, and Graph-backed chat IDs; accept Bot Framework audience tokens; prevent feedback-learning filename collisions; keep long tool chains alive with typing indicators; add SSO sign-in callbacks; inject parent context for thread replies; and deliver cron announcements to Teams conversation IDs. (#54932, #55383, #55386, #58001, #58249, #58774, #59731, #60956, #62219, #62674, #63063, #63942, #63945, #63949, #63951, #63953, #64087, #64088, #64089)</li>
<li>Gateway/tailscale: start Tailscale exposure and the gateway update check before awaiting channel and plugin sidecar startup so remote operators are not locked out when startup sidecars stall.</li>
<li>Gateway/startup: keep WebSocket RPC available while channels and plugin sidecars start, hold <code>chat.history</code> unavailable until startup sidecars finish so synchronous history reads cannot stall startup (reported in #63450), refresh advertised gateway methods after deferred plugin reloads, and enforce the pre-auth WebSocket upgrade budget before the no-handler 503 path so upgrade floods cannot bypass connection limits during that window. (#63480) Thanks @neeravmakwana.</li>
<li>WhatsApp: keep inbound replies, media, composing indicators, and queued outbound deliveries attached to the current socket across reconnect gaps, including fresh retry-eligible sends after the listener comes back. (#30806, #46299, #62892, #63916) Thanks @mcaxtr.</li>
<li>Gateway/thread routing: preserve Slack, Telegram, Mattermost, Matrix, ACP, restart-sentinel, and agent announce delivery targets so subagent, cron, stream-relay, session fallback, and restart messages land back in the originating thread, topic, or room casing. (#54840, #57056, #63143, #63228, #63506, #64343, #64391)</li>
<li>Models/fallback: preserve <code>/models</code> selection across transient primary-model failures and config reloads, allow timeout cooldown probes, classify OpenRouter no-endpoints responses, detect llama.cpp context overflows, and keep provider/runtime context metadata stable through reloads. (#61472, #64196, #64471)</li>
<li>Agents/BTW: keep <code>/btw</code> side questions working after tool-use turns by stripping replayed tool blocks, hidden reasoning, and malformed image payloads, omitting empty tool arrays, allowing Bedrock <code>auth: "aws-sdk"</code>, and routing Feishu <code>/btw</code> plus <code>/stop</code> through bounded out-of-band lanes. (#64218, #64219, #64225, #64324) Thanks @ngutman.</li>
<li>Control UI/BTW: render <code>/btw</code> side results as dismissible ephemeral cards in the browser, send <code>/btw</code> immediately during active runs, and clear stale BTW cards on reset flows so webchat matches the intended detached side-question behavior. (#64290) Thanks @ngutman.</li>
<li>Commands/targeting: use the selected agent or session for command output, send policy, usage/cost, context reports, model lists, bash sandbox hints, BTW/compact working directories, plugin commands, and session exports so multi-agent commands describe and mutate the intended target instead of the requester.</li>
<li>Conversation bindings: normalize focused/current conversation ids, preserve binding metadata on account and Discord rebinds, avoid stale Discord lifecycle windows, and keep generic activity touches persisted so reply routing survives rebinds and restarts.</li>
<li>iMessage/self-chat: distinguish normal DM outbound rows from true self-chat using <code>destination_caller_id</code> plus chat participants, preserve multi-handle self-chat aliases, drop ambiguous reflected echoes, and strip wrapped imsg RPC text fields. (#61619, #63868, #63980, #63989, #64000) Thanks @neeravmakwana.</li>
<li>Matrix: keep multi-account room scoping consistent, keep packaged crypto migrations warning-only when appropriate, preserve ordered block streaming, add explicit Matrix block-streaming opt-in, and resolve verification/bootstrap from the packaged runtime entry. (#58449, #59249, #59266, #64373) Thanks @gumadeiras.</li>
<li>Telegram/security: tighten Telegram <code>allowFrom</code> sender validation and keep <code>/whoami</code> allowlist reporting in sync with command auth checks.</li>
<li>Agents/timeouts: extend the default LLM idle window to 120s and keep silent no-token idle timeouts on recovery paths, so slow models can retry or fall back before users see an error.</li>
<li>Gateway/agents: preserve configured model selection and richer <code>IDENTITY.md</code> content across agent create/update flows and workspace moves, and fail safely instead of silently overwriting unreadable identity files. (#61577) Thanks @samzong.</li>
<li>Skills/TaskFlow: restore valid frontmatter fences for the bundled <code>taskflow</code> and <code>taskflow-inbox-triage</code> skills and copy bundled <code>SKILL.md</code> files as hard dist-runtime copies so skills stay discoverable and loadable after updates. (#64166, #64469) Thanks @extrasmall0.</li>
<li>Skills: respect overridden home directories when loading personal skills so service, test, and custom launch environments read the intended user skill directory instead of the process home.</li>
<li>Windows/exec: settle supervisor waits from child exit state after stdout and stderr drain even when <code>close</code> never arrives, so CLI commands stop hanging or dying with forced <code>SIGKILL</code> on Windows. (#64072) Thanks @obviyus.</li>
<li>Browser/sandbox: prevent sandbox browser CDP startup hangs by recreating containers when the browser security hash changes and by waiting on the correct sandbox browser lifecycle. (#62873) Thanks @Syysean.</li>
<li>QQBot/streaming: make block streaming configurable per QQ bot account via <code>streaming.mode</code> (<code>"partial"</code> | <code>"off"</code>, default <code>"partial"</code>) instead of hardcoding it off, so responses can be delivered incrementally. (#63746)</li>
<li>QQBot/config: allow extra fields in <code>channels.qqbot</code> and <code>channels.qqbot.accounts.*</code> so extended qqbot builds can add new config options without gateway startup failing on schema validation. (#64075) Thanks @WideLee.</li>
<li>Dreaming/gateway: require <code>operator.admin</code> for persistent <code>/dreaming on|off</code> changes and treat missing gateway client scopes as unprivileged instead of silently allowing config writes. (#63872) Thanks @mbelinky.</li>
<li>Gateway/pairing: prefer explicit QR bootstrap auth over earlier Tailscale auth classification so iOS <code>/pair qr</code> silent bootstrap pairing does not fall through to <code>pairing required</code>. (#59232) Thanks @ngutman.</li>
<li>Browser/control: auto-generate browser-control auth tokens for <code>none</code> and <code>trusted-proxy</code> modes, and route browser auth/profile/doctor helpers through the public browser plugin facades. (#63280, #63957) Thanks @pgondhi987.</li>
<li>Browser/act: centralize <code>/act</code> request normalization and execution dispatch while adding stable machine-readable route-level error codes for invalid requests, selector misuse, evaluate-disabled gating, target mismatch, and existing-session unsupported actions. (#63977) Thanks @joshavant.</li>
<li>Security/QQBot: enforce media storage boundaries for all outbound local file paths and route image-size probes through SSRF-guarded media fetching instead of raw <code>fetch()</code>. (#63271, #63495) Thanks @pgondhi987.</li>
<li>Channel setup: ignore workspace plugin shadows when resolving trusted channel setup catalog entries so onboarding and setup flows keep using the bundled, trusted setup contract.</li>
<li>Gateway/memory startup: load the explicitly selected memory-slot plugin during gateway startup, while keeping restrictive allowlists and implicit default memory slots from auto-starting unrelated memory plugins. (#64423) Thanks @EronFan.</li>
<li>Config/plugins: let config writes keep disabled plugin entries without forcing required plugin config schemas or crashing raw plugin validation, and avoid re-activating plugin registry state during schema checks. (#54971, #63296) Thanks @fuller-stack-dev.</li>
<li>Config validation: surface the actual offending field for strict-schema union failures in bindings, including top-level unexpected keys on the matching ACP branch. (#40841) Thanks @Hollychou924.</li>
<li>Wizard/plugin config: coerce integer-typed plugin config fields from interactive text input so integer schema values persist as numbers instead of failing validation. (#63346) Thanks @jalehman.</li>
<li>Daemon/gateway install: preserve safe custom service env vars on forced reinstall, merge prior custom PATH segments behind the managed service PATH, and stop removed managed env keys from persisting as custom carryover. (#63136) Thanks @WarrenJones.</li>
<li>Cron/scheduling: treat <code>nextRunAtMs <= 0</code> as invalid across cron update, maintenance, timer, and stale-delivery paths so corrupted zero timestamps self-heal instead of causing immediate runs or skipped deliveries. (#63507) Thanks @WarrenJones.</li>
<li>Cron/auth: resolve auth profiles consistently for isolated cron jobs so scheduled runs use the same configured provider credentials as interactive sessions. (#62797) Thanks @neeravmakwana.</li>
<li>Tasks: let <code>openclaw tasks cancel</code> cancel stuck background tasks that never reached a normal terminal state. (#62506) Thanks @neeravmakwana.</li>
<li>Sessions/model selection: preserve catalog-backed session model labels, provider-qualified context limits, and already-qualified session model refs when catalog metadata is unavailable, so model selection and memory/context budgets survive reloads without bogus provider prefixes. (#61382, #62493) Thanks @Mule-ME.</li>
<li>Status: show configured fallback models in <code>/status</code> and shared session status cards so per-agent fallback configuration is visible before a live failover happens. (#33111) Thanks @AnCoSONG.</li>
<li><code>/context detail</code> now compares the tracked prompt estimate with cached context usage and surfaces untracked provider/runtime overhead when present. (#28391) Thanks @ImLukeF.</li>
<li>Gateway/sessions: scope bare <code>sessions.create</code> aliases like <code>main</code> to the requested agent while preserving the canonical <code>global</code> and <code>unknown</code> sentinel keys. (#58207) Thanks @jalehman.</li>
<li>Gateway/session reset: emit the typed <code>before_reset</code> hook for gateway <code>/new</code> and <code>/reset</code>, preserving reset-hook behavior even when the previous transcript has already been archived. (#53872) Thanks @VACInc.</li>
<li>Plugins/commands: pass the active host <code>sessionKey</code> into plugin command contexts, and include <code>sessionId</code> when it is already available from the active session entry, so bundled and third-party commands can resolve the current conversation reliably. (#59044) Thanks @jalehman.</li>
<li>Agents/auth: honor <code>models.providers.*.authHeader</code> for pi embedded runner model requests by injecting <code>Authorization: Bearer <apiKey></code> when requested. (#54390) Thanks @lndyzwdxhs.</li>
<li>Claude CLI: clear inherited Anthropic auth/header environment aliases before spawning Claude Code and add sanitized CLI backend auth-env diagnostics for debugging gateway-run provider selection.</li>
<li>Agents/failover: classify AbortError and stream-abort messages as timeout so Ollama NDJSON stream aborts stop showing <code>reason=unknown</code> in model fallback logs. (#58324) Thanks @yelog.</li>
<li>Fireworks/FirePass: disable Kimi K2.5 Turbo reasoning output by forcing thinking off on the FirePass path and hardening the provider wrapper so hidden reasoning no longer leaks into visible replies. (#63607) Thanks @frankekn.</li>
<li>Discord: update Carbon to v0.15.0. Thanks @thewilloftheshadow.</li>
<li>Config/Discord: coerce safe integer numeric Discord IDs to strings during config validation, keep unsafe or precision-losing numeric snowflakes rejected, and align <code>openclaw doctor</code> repair guidance with the same fail-closed behavior. (#45125) Thanks @moliendocode.</li>
<li>BlueBubbles/config: accept <code>enrichGroupParticipantsFromContacts</code> in the core strict config schema so gateways no longer fail validation or startup when the BlueBubbles plugin writes that field. (#56889) Thanks @zqchris.</li>
<li>Feishu/webhooks: read webhook bodies through the pre-auth guard so unauthenticated webhook traffic stays under the same body budget as other protected channel ingress paths.</li>
<li>Tools/web_fetch: add an opt-in <code>tools.web.fetch.ssrfPolicy.allowRfc2544BenchmarkRange</code> config so fake-IP proxy environments that resolve public sites into <code>198.18.0.0/15</code> can use <code>web_fetch</code> without weakening the default SSRF block. (#61830) Thanks @xing-xing-coder.</li>
<li>Dreaming/cron: reconcile managed dreaming cron from startup config and runtime lifecycle changes, but only recover managed dreaming cron state during heartbeat-triggered dreaming checks so ordinary chat traffic does not recreate removed jobs. (#63873, #63929, #63938) Thanks @mbelinky.</li>
<li>Memory/lancedb: accept <code>dreaming</code> config when <code>memory-lancedb</code> owns the memory slot so Dreaming surfaces can read slot-owner settings without schema rejection. (#63874) Thanks @mbelinky.</li>
<li>Control UI/dreaming: keep the Dreaming trace area contained and scrollable so overlays no longer cover tabs or blow out the page layout. (#63875) Thanks @mbelinky.</li>
<li>Dreaming/narrative: harden request-scoped diary fallback so scheduled dreaming only falls back on the dedicated subagent-runtime error, stop trusting spoofable raw error-code objects, and avoid leaking workspace paths when local fallback writes fail. (#64156) Thanks @mbelinky.</li>
<li>Dreaming/diary: add idempotent narrative subagent runs, preserve restrictive <code>DREAMS.md</code> permissions during atomic writes, and surface temp cleanup failures so repeated sweeps do not double-run the same narrative request or silently weaken diary safety. (#63876) Thanks @mbelinky.</li>
<li>Heartbeats/sessions: remove stale accumulated isolated heartbeat session keys when the next tick converges them back to the canonical sibling, so repaired sessions stop showing orphaned <code>:heartbeat:heartbeat</code> variants in session listings. (#59606) Thanks @rogerdigital.</li>
<li>Gateway/run cleanup: fix stale run-context TTL cleanup so the new maintenance sweep resets orphaned run sequence state and prevents unbounded run-context growth. (#52731) Thanks @artwalker.</li>
<li>UI/compaction: keep the compaction indicator in a retry-pending state until the run actually finishes, so the UI does not show <code>Context compacted</code> before compaction actually finishes. (#55132) Thanks @mpz4life.</li>
<li>Cron/tool schemas: keep cron tool schemas strict-model-friendly while still preserving <code>failureAlert=false</code>, nullable <code>agentId</code>/<code>sessionKey</code>, and flattened add/update recovery for the newly exposed cron job fields. (#55043) Thanks @brunolorente.</li>
<li>Git metadata: read commit ids from packed refs as well as loose refs so version and status metadata stay accurate after repository maintenance. (#63943)</li>
<li>Gateway: keep <code>commands.list</code> skill entries categorized under tools and include provider-aware plugin <code>nativeName</code> metadata even when <code>scope=text</code>, so remote clients can group skills correctly and map text-surface plugin commands back to native aliases. (#64147)</li>
<li>TUI: reset footer activity to idle when switching sessions so a stale streaming indicator cannot persist after the selection changes. (#63988) Thanks @neeravmakwana.</li>
<li>Claude CLI: stop marking spawned Claude Code runs as host-managed so they keep using normal CLI subscription behavior. (#64023) Thanks @Alex-Alaniz.</li>
<li>Codex auth: brand Codex OAuth flows as OpenClaw in user-visible auth prompts and diagnostics.</li>
<li>Gateway/pairing: fail closed for paired device records that have no device tokens, and reject pairing approvals whose requested scopes do not match the requested device roles.</li>
<li>ACP/gateway chat: classify lifecycle errors before forwarding them to ACP clients so refusals use ACP's refusal stop reason while transient backend errors continue to finish as normal turns.</li>
<li>Claude CLI/skills: pass eligible OpenClaw skills into CLI runs, including native Claude Code skill resolution via a temporary plugin plus per-run skill env/API key injection. (#62686, #62723) Thanks @zomars.</li>
<li>Discord: keep generated auto-thread names working with reasoning models by giving title generation enough output budget for thinking plus visible title text. (#64172) Thanks @hanamizuki.</li>
<li>Heartbeat: ignore doc-only Markdown fence markers in the default <code>HEARTBEAT.md</code> template so comment-only heartbeat scaffolds skip API calls again. (#61690, #63434) Thanks @ravyg.</li>
<li>Reply/skills: keep resolved skill and memory secret config stable through embedded reply runs so raw SecretRefs in secondary skill settings no longer crash replies when the gateway already has the live env. (#64249) Thanks @mbelinky.</li>
<li>Dreaming/startup: keep plugin-registered startup hooks alive across workspace hook reloads and include dreaming startup owners in the gateway startup plugin scope, so managed Dreaming cron registration comes back reliably after gateway boot. (#62327, #64258) Thanks @mbelinky.</li>
<li>Plugins: treat duplicate <code>registerService</code> calls from the same plugin id as idempotent so snapshot and activation loads no longer emit spurious <code>service already registered</code> diagnostics. (#62033, #64128) Thanks @ly85206559.</li>
<li>Discord/TTS: route auto voice replies through the native voice-note path so Discord receives Opus voice messages instead of regular audio attachments. (#64096) Thanks @LiuHuaize.</li>
<li>Config/plugins: use plugin-owned command alias metadata when <code>plugins.allow</code> contains runtime command names like <code>dreaming</code>, and point users at the owning plugin instead of stale plugin-not-found guidance. (#64191, #64242) Thanks @feiskyer.</li>
<li>Agents/Gemini: strip orphaned <code>required</code> entries from Gemini tool schemas so provider validation no longer rejects tools after schema cleanup or union flattening. (#64284) Thanks @xxxxxmax.</li>
<li>Assistant text: strip Qwen-style XML tool call payloads from visible replies so web and channel messages no longer show raw <code><tool_call><function=...></code> output. (#63999, #64214) Thanks @MoerAI.</li>
<li>Daemon/gateway: prevent systemd restart storms on configuration errors by exiting with <code>EX_CONFIG</code> and adding generated unit restart-prevention guards. (#63913) Thanks @neo1027144-creator.</li>
<li>Agents/exec: prevent gateway crash ("Agent listener invoked outside active run") when a subagent exec tool produces stdout/stderr after the agent run has ended or been aborted. (#62821) Thanks @openperf.</li>
<li>Gateway/OpenAI compat: return real <code>usage</code> for non-stream <code>/v1/chat/completions</code> responses, emit the final usage chunk when <code>stream_options.include_usage=true</code>, and bound usage-gated stream finalization after lifecycle end. (#62986) Thanks @Lellansin.</li>
<li>Matrix/migration: keep packaged warning-only crypto migrations from being misclassified as actionable when only helper chunks are present, so startup and doctor stay on the warning-only path instead of creating unnecessary migration snapshots. (#64373) Thanks @gumadeiras.</li>
<li>Matrix/ACP thread bindings: preserve canonical room casing and parent conversation routing during ACP session spawn so mixed-case room ids bind correctly from top-level rooms and existing Matrix threads. (#64343) Thanks @gumadeiras.</li>
<li>Agents/subagents: deduplicate delivered completion announces so retry or re-entry cleanup does not inject duplicate internal-context completion turns into the parent session. (#61525) Thanks @100yenadmin.</li>
<li>Agents/exec: keep sandboxed <code>tools.exec.host=auto</code> sessions from honoring per-call <code>host=node</code> or <code>host=gateway</code> overrides while a sandbox runtime is active, and stop advertising node routing in that state so exec stays on the sandbox host. (#63880)</li>
<li>Agents/subagents: preserve archived delete-mode runs until <code>sessions.delete</code> succeeds and prevent overlapping archive sweeps from duplicating in-flight cleanup attempts. (#61801) Thanks @100yenadmin.</li>
<li>Cron/isolated agent: run scheduled agent turns as non-owner senders so owner-only tools stay unavailable during cron execution. (#63878)</li>
<li>Discord/sandbox: include <code>image</code> in sandbox media param normalization so Discord event cover images cannot bypass sandbox path rewriting. (#64377) Thanks @mmaps.</li>
<li>Agents/exec: extend exec completion detection to cover local background exec formats so the owner-downgrade fires correctly for all exec paths. (#64376) Thanks @mmaps.</li>
<li>Security/dependencies: pin axios to 1.15.0 and add a plugin install dependency denylist that blocks known malicious packages before install. (#63891) Thanks @mmaps.</li>
<li>Browser/security: apply three-phase interaction navigation guard to pressKey and type(submit) so delayed JS redirects from keypress cannot bypass SSRF policy. (#63889) Thanks @mmaps.</li>
</ul>
<ul>
<li>Browser/security: guard existing-session Chrome MCP interaction routes with SSRF post-checks so delayed navigation from click, type, press, and evaluate cannot bypass the configured policy. (#64370) Thanks @eleqtrizit.</li>
<li>Browser/security: default browser SSRF policy to strict mode so unconfigured installs block private-network navigation, and align external-content marker span mapping so ZWS-injected boundary spoofs are fully sanitized. (#63885) Thanks @eleqtrizit.</li>
<li>Browser/security: apply SSRF navigation policy to subframe document navigations so iframe-targeted private-network hops are blocked without quarantining the parent page. (#64371) Thanks @eleqtrizit.</li>
<li>Hooks/security: mark agent hook system events as untrusted and sanitize hook display names before cron metadata reuse. (#64372) Thanks @eleqtrizit.</li>
<li>Daemon/launchd: keep <code>openclaw gateway stop</code> persistent without uninstalling the macOS LaunchAgent, re-enable it on explicit restart or repair, and harden launchd label handling. (#64447) Thanks @ngutman.</li>
<li>Plugins/context engines: preserve <code>plugins.slots.contextEngine</code> through normalization and keep explicitly selected workspace context-engine plugins enabled, so loader diagnostics and plugin activation stop dropping that slot selection. (#64192) Thanks @hclsys.</li>
<li>Heartbeat: stop top-level <code>interval:</code> and <code>prompt:</code> fields outside the <code>tasks:</code> block from bleeding into the last parsed heartbeat task. (#64488) Thanks @Rahulkumar070.</li>
<li>Agents/OpenAI replay: preserve malformed function-call arguments in stored assistant history, avoid double-encoding preserved raw strings on replay, and coerce replayed string args back to objects at Anthropic and Google provider boundaries. (#61956) Thanks @100yenadmin.</li>
<li>Heartbeat/config: accept and honor <code>agents.defaults.heartbeat.timeoutSeconds</code> and per-agent heartbeat timeout overrides for heartbeat agent turns. (#64491) Thanks @cedillarack.</li>
<li>CLI/devices: make implicit <code>openclaw devices approve</code> selection preview-only and require approving the exact request ID, preventing latest-request races during device pairing. (#64160) Thanks @coygeek.</li>
<li>Media/security: honor sender-scoped <code>toolsBySender</code> policy for outbound host-media reads so denied senders cannot trigger host file disclosure via attachment hydration. (#64459) Thanks @eleqtrizit.</li>
<li>Browser/security: reject strict-policy hostname navigation unless the hostname is an explicit allowlist exception or IP literal, and route CDP HTTP discovery through the pinned SSRF fetch path. (#64367) Thanks @eleqtrizit.</li>
<li>Models/vLLM: ignore empty <code>tool_calls</code> arrays from reasoning-model OpenAI-compatible replies, reset false <code>toolUse</code> stop reasons when no actual tool calls were parsed, and stop sending <code>tool_choice</code> unless tools are present so vLLM reasoning responses no longer hang indefinitely. (#61197, #61534) Thanks @balajisiva.</li>
<li>Heartbeat/scheduling: spread interval heartbeats across stable per-agent phases derived from gateway identity, so provider traffic is distributed more uniformly across the configured interval instead of clustering around startup-relative times. (#64560) Thanks @odysseus0.</li>
</ul>
<p><a href="https://github.com/openclaw/openclaw/blob/main/CHANGELOG.md">View full changelog</a></p>
]]></description>
<enclosure url="https://github.com/openclaw/openclaw/releases/download/v2026.4.10/OpenClaw-2026.4.10.zip" length="47259509" type="application/octet-stream" sparkle:edSignature="XY9FHxx09r2O9rlFs3t5UV9Zk2rGXSpWw5InazJhb661kgp6OKiOrrNTV631b2StWze5tnSEPXakkOCXq7O6DQ=="/>
</item>
<item>
<title>2026.4.9</title>
<pubDate>Thu, 09 Apr 2026 02:38:08 +0000</pubDate>
@@ -82,112 +226,5 @@
]]></description>
<enclosure url="https://github.com/openclaw/openclaw/releases/download/v2026.4.8/OpenClaw-2026.4.8.zip" length="25324810" type="application/octet-stream" sparkle:edSignature="aogl3hJf+FeRvQj0W4WDGMQnIRPpxXPQam50U7SBT3ljA1CeSbIGsnaj20aLF0Qc9DikPEXt5AEg7LMOen4+BQ=="/>
</item>
<item>
<title>2026.4.7</title>
<pubDate>Wed, 08 Apr 2026 02:54:26 +0000</pubDate>
<link>https://raw.githubusercontent.com/openclaw/openclaw/main/appcast.xml</link>
<sparkle:version>2026040790</sparkle:version>
<sparkle:shortVersionString>2026.4.7</sparkle:shortVersionString>
<sparkle:minimumSystemVersion>15.0</sparkle:minimumSystemVersion>
<description><![CDATA[<h2>OpenClaw 2026.4.7</h2>
<h3>Changes</h3>
<ul>
<li>CLI/infer: add a first-class <code>openclaw infer ...</code> hub for provider-backed inference workflows across model, media, web, and embedding tasks. Thanks @Takhoffman.</li>
<li>Tools/media generation: auto-fallback across auth-backed image, music, and video providers by default, preserve intent during provider switches, remap size/aspect/resolution/duration hints to the closest supported option, and surface provider capabilities plus mode-aware video-to-video support.</li>
<li>Memory/wiki: restore the bundled <code>memory-wiki</code> stack with plugin, CLI, sync/query/apply tooling, memory-host integration, structured claim/evidence fields, compiled digest retrieval, claim-health linting, contradiction clustering, staleness dashboards, and freshness-weighted search. Thanks @vincentkoc.</li>
<li>Plugins/webhooks: add a bundled webhook ingress plugin so external automation can create and drive bound TaskFlows through per-route shared-secret endpoints. (#61892) Thanks @mbelinky.</li>
<li>Gateway/sessions: add persisted compaction checkpoints plus Sessions UI branch/restore actions so operators can inspect and recover pre-compaction session state. (#62146) Thanks @scoootscooob.</li>
<li>Compaction: add pluggable compaction provider registry so plugins can replace the built-in summarization pipeline. Configure via <code>agents.defaults.compaction.provider</code>; falls back to LLM summarization on provider failure. (#56224) Thanks @DhruvBhatia0.</li>
<li>Agents/system prompt: add <code>agents.defaults.systemPromptOverride</code> for controlled prompt experiments plus heartbeat prompt-section controls so heartbeat runtime behavior can stay enabled without injecting heartbeat instructions every turn.</li>
<li>Providers/Google: add Gemma 4 model support and keep Google fallback resolution on the requested provider path so native Google Gemma routes work again. (#61507) Thanks @eyjohn.</li>
<li>Providers/Google: preserve explicit thinking-off semantics for Gemma 4 while still enabling Gemma reasoning support in compatibility wrappers. (#62127) Thanks @romgenie.</li>
<li>Providers/Arcee AI: add a bundled Arcee AI provider plugin with Trinity catalog entries, OpenRouter support, and updated onboarding/auth guidance. (#62068) Thanks @arthurbr11.</li>
<li>Providers/Anthropic: restore Claude CLI as the preferred local Anthropic path in onboarding, model-auth guidance, doctor flows, and Docker Claude CLI live lanes again.</li>
<li>Providers/Ollama: detect vision capability from the <code>/api/show</code> response and set image input on models that support it so Ollama vision models accept image attachments. (#62193) Thanks @BruceMacD.</li>
<li>Memory/dreaming: ingest redacted session transcripts into the dreaming corpus with per-day session-corpus notes, cursor checkpointing, and promotion/doctor support. (#62227) Thanks @vignesh07.</li>
<li>Providers/inferrs: add string-content compatibility for stricter OpenAI-compatible chat backends, document <code>inferrs</code> setup with a full config example, and add troubleshooting guidance for local backends that pass direct probes but fail on full agent-runtime prompts.</li>
<li>Agents/context engine: expose prompt-cache runtime context to context engines and keep current-turn prompt-cache usage aligned with the active attempt instead of stale prior-turn assistant state. (#62179) Thanks @jalehman.</li>
<li>Plugin SDK/context engines: pass <code>availableTools</code> and <code>citationsMode</code> into <code>assemble()</code>, and expose memory-artifact and memory-prompt seams so companion plugins and non-legacy context engines can consume active memory state without reaching into internals. Thanks @vincentkoc.</li>
<li>ACP/ACPX plugin: bump the bundled <code>acpx</code> pin to <code>0.5.1</code> so plugin-local installs and strict version checks pick up the latest published runtime release. (#62148) Thanks @onutc.</li>
<li>Discord/events: allow <code>event-create</code> to accept a cover image URL or local file path, load and validate PNG/JPG/GIF event cover media, and pass the encoded image payload through Discord admin action/runtime paths. (#60883) Thanks @bittoby.</li>
</ul>
<h3>Fixes</h3>
<ul>
<li>CLI/infer: keep provider-backed infer behavior aligned with actual runtime execution by fixing explicit TTS override handling, profile-aware gateway TTS prefs resolution, per-request transcription <code>prompt</code>/<code>language</code> overrides, image output MIME/extension mismatches, configured web-search fallback behavior, and agent-vs-CLI web-search execution drift.</li>
<li>Plugins/media: when <code>plugins.allow</code> is set, capability fallback now merges bundled capability plugin ids into the allowlist (not only <code>plugins.entries</code>), so media understanding providers such as OpenAI-compatible STT load for voice transcription without requiring <code>openai</code> in <code>plugins.allow</code>. (#62205) Thanks @neeravmakwana.</li>
<li>Agents/history and replies: buffer phaseless OpenAI WS text until a real assistant phase arrives, keep replay and SSE history sequence tracking aligned, hide commentary and leaked tool XML from user-visible history, and keep history-based follow-up replies on <code>final_answer</code> text only. (#61729, #61747, #61829, #61855, #61954) Thanks @100yenadmin and contributors.</li>
<li>Control UI: show <code>/tts</code> audio replies in webchat, detect mistaken <code>?token=</code> auth links with the correct <code>#token=</code> hint, and keep Copy, Canvas, and mobile exec-approval UI from covering chat content on narrow screens. (#54842, #61514, #61598) Thanks @neeravmakwana.</li>
<li>iOS/gateway: replace string-matched connection error UI with structured gateway connection problems, preserve actionable pairing/auth failures over later generic disconnect noise, and surface reusable problem banners and details across onboarding, settings, and root status surfaces. (#62650) Thanks @ngutman.</li>
<li>TUI: route <code>/status</code> through the shared session-status command, keep commentary hidden in history, strip raw envelope metadata from async command notices, preserve fallback streaming before per-attempt failures finalize, and restore Kitty keyboard state on exit or fatal crashes. (#49130, #59985, #60043, #61463) Thanks @biefan and contributors.</li>
<li>iOS/Watch exec approvals: keep Apple Watch review and approval recovery working while the iPhone is locked or backgrounded, including reconnect recovery, pending approval persistence, notification cleanup, and APNs-backed watch refresh recovery. (#61757) Thanks @ngutman.</li>
<li>Agents/context overflow: combine oversized and aggregate tool-result recovery in one pass and restore a total-context overflow backstop so recoverable sessions retry instead of failing early. (#61651) Thanks @Takhoffman.</li>
<li>Auth/OpenAI Codex OAuth: reload fresh on-disk credentials inside the locked refresh path and retry once after <code>refresh_token_reused</code> rotates only the stored refresh token, so relogin/restart recovery stops getting stuck on stale cached auth state. Thanks @owen-ever.</li>
<li>Auth/OpenAI Codex OAuth: keep native <code>/model ...@profile</code> selections on the target session and honor explicit user-locked auth profiles even when per-agent auth order excludes them. (#62744) Thanks @jalehman.</li>
<li>Providers/Anthropic: preserve thinking blocks for Claude Opus 4.5+, Sonnet 4.5+, and newer Claude 4-family models so prompt-cache prefixes keep matching, and skip <code>service_tier</code> injection on OAuth-authenticated stream wrapper requests so Claude OAuth streaming stops failing with HTTP 401. (#60356, #61793)</li>
<li>Agents/Claude CLI: surface nested API error messages from structured CLI output so billing/auth/provider failures show the real provider error instead of an opaque CLI failure.</li>
<li>Agents/exec: preserve explicit <code>host=node</code> routing under elevated defaults when <code>tools.exec.host=auto</code>, fail loud on invalid elevated cross-host overrides, and keep <code>strictInlineEval</code> commands blocked after approval timeouts instead of falling through to automatic execution. (#61739) Thanks @obviyus.</li>
<li>Nodes/exec approvals: keep <code>host=node</code> POSIX transport shell wrappers (<code>/bin/sh -lc ...</code>) aligned with inner-command allowlist analysis so allowlisted scripts stop prompting unnecessarily, while Windows <code>cmd.exe</code> wrapper runs stay approval-gated. (#62401) Thanks @ngutman.</li>
<li>Nodes/exec approvals: keep Windows <code>cmd.exe /c</code> wrapper runs approval-gated even when <code>env</code> carriers, including env-assignment carriers, wrap the shell invocation. (#62439) Thanks @ngutman.</li>
<li>Gateway tool/exec config: block model-facing <code>gateway config.apply</code> and <code>config.patch</code> writes from changing exec approval paths such as <code>safeBins</code>, <code>safeBinProfiles</code>, <code>safeBinTrustedDirs</code>, and <code>strictInlineEval</code>, while still allowing unchanged structured values through. (#62001) Thanks @eleqtrizit.</li>
<li>Host exec/env sanitization: block dangerous Java, Rust, Cargo, Git, Kubernetes, cloud credential, config-path, and Helm env overrides so host-run tools cannot be redirected to attacker-chosen code, config, credentials, or repository state. (#59119, #62002, #62291) Thanks @eleqtrizit and contributors.</li>
<li>Commands/allowlist: require owner authorization for <code>/allowlist add</code> and <code>/allowlist remove</code> before channel resolution, so non-owner but command-authorized senders can no longer persistently rewrite allowlist policy state. (#62383) Thanks @pgondhi987.</li>
<li>Feishu/docx uploads: honor <code>tools.fs.workspaceOnly</code> for local <code>upload_file</code> and <code>upload_image</code> paths by forwarding workspace-constrained <code>localRoots</code> into the media loader, so docx uploads can no longer read host-local files outside the workspace when workspace-only mode is active. (#62369) Thanks @pgondhi987.</li>
<li>Network/fetch guard: drop request bodies and body-describing headers on cross-origin <code>307</code> and <code>308</code> redirects by default, so attacker-controlled redirect hops cannot receive secret-bearing POST payloads from SSRF-guarded fetch flows unless a caller explicitly opts in. (#62357) Thanks @pgondhi987.</li>
<li>Browser/SSRF: treat main-frame <code>document</code> redirect hops as navigations even when Playwright does not flag them as <code>isNavigationRequest()</code>, so strict private-network blocking still stops forbidden redirect pivots before the browser reaches the internal target. (#62355) Thanks @pgondhi987.</li>
<li>Browser/node invoke: block persistent browser profile create, reset, and delete mutations through <code>browser.proxy</code> on both gateway-forwarded <code>node.invoke</code> and the node-host proxy path, even when no profile allowlist is configured. (#60489)</li>
<li>Gateway/node pairing: require a fresh pairing request when a previously paired node reconnects with additional declared commands, and keep the live session pinned to the earlier approved command set until the upgrade is approved. (#62658) Thanks @eleqtrizit.</li>
<li>Gateway/auth: invalidate existing shared-token and password WebSocket sessions when the configured secret rotates, so stale authenticated sockets cannot stay attached after token or password changes. (#62350) Thanks @pgondhi987.</li>
<li>MS Teams/security: validate file-consent upload URLs against HTTPS, Microsoft/SharePoint host allowlists, and private-IP DNS checks before uploading attachments, blocking SSRF-style consent-upload abuse. (#23596)</li>
<li>Media/base64 decode guards: enforce byte limits before decoding missed base64-backed Teams, Signal, QQ Bot, and image-tool payloads so oversized inbound media and data URLs no longer bypass pre-decode size checks. (#62007) Thanks @eleqtrizit.</li>
<li>Runtime event trust: mark background <code>notifyOnExit</code> summaries, ACP parent-stream relays, and wake-hook payloads as untrusted system events so lower-trust runtime output no longer re-enters later turns as trusted <code>System:</code> text. (#62003)</li>
<li>Auto-reply/media: allow managed generated-media <code>MEDIA:</code> paths from normal reply text again while still blocking arbitrary host-local media and document paths, so generated media keep delivering without reopening host-path injection holes.</li>
<li>Gateway/status and containers: auto-bind to <code>0.0.0.0</code> inside Docker and Podman environments, and probe local TLS gateways over <code>wss://</code> with self-signed fingerprint forwarding so container startup and loopback TLS status checks work again. (#61818, #61935) Thanks @openperf and contributors.</li>
<li>Gateway/OpenAI-compatible HTTP: abort in-flight <code>/v1/chat/completions</code> and <code>/v1/responses</code> turns when clients disconnect so abandoned HTTP requests stop wasting agent runtime. (#54388) Thanks @Lellansin.</li>
<li>macOS/gateway version: strip trailing commit metadata from CLI version output before semver parsing so the Mac app recognizes installed gateway versions like <code>OpenClaw 2026.4.2 (d74a122)</code> again. (#61111) Thanks @oliviareid-svg.</li>
<li>Sessions/model selection: resolve the explicitly selected session model separately from runtime fallback resolution so session status and live model switching stay aligned with the chosen model.</li>
<li>Discord/ACP bindings: canonicalize DM conversation identity across inbound messages, component interactions, native commands, and current-conversation binding resolution so <code>--bind here</code> in Discord DMs keeps routing follow-up replies to the bound agent instead of falling back to the default agent.</li>
<li>Discord: recover forwarded referenced message text and attachments when snapshots are missing, use <code>ws://</code> again for gateway monitor sockets, stop forcing a hardcoded temperature for Codex-backed auto-thread titles, and harden voice receive recovery so rapid speaker restarts keep their next utterance. (#41536, #61670) Thanks @artwalker and contributors.</li>
<li>Slack/thread mentions: add <code>channels.slack.thread.requireExplicitMention</code> so Slack channels that already require mentions can also require explicit <code>@bot</code> mentions inside bot-participated threads. (#58276) Thanks @praktika-engineer.</li>
<li>Slack/threading: keep legacy thread stickiness for real replies when older callers omit <code>isThreadReply</code>, while still honoring <code>replyToMode</code> for Slack's auto-created top-level <code>thread_ts</code>. (#61835) Thanks @kaonash.</li>
<li>Slack/media: keep attachment downloads on the SSRF-guarded dispatcher path so Slack media fetching works on Node 22 without dropping pinned transport enforcement. (#62239) Thanks @openperf.</li>
<li>Matrix/onboarding: add an invite auto-join setup step with explicit off warnings and strict stable-target validation so new Matrix accounts stop silently ignoring invited rooms and fresh DM-style invites unless operators opt in. (#62168) Thanks @gumadeiras.</li>
<li>Matrix/formatting: preserve multi-paragraph and loose-list rendering in Element so numbered and bulleted Markdown keeps their content attached to the correct list item. (#60997) Thanks @gucasbrg.</li>
<li>Telegram/doctor: keep top-level access-control fallback in place during multi-account normalization while still promoting legacy default auth into <code>accounts.default</code>, so existing named bots keep inherited allowlists without dropping the legacy default bot. (#62263) Thanks @obviyus.</li>
<li>Plugins/loaders: centralize bundled <code>dist/**</code> Jiti native-load policy and keep channel, public-surface, facade, and config-metadata loader seams off native Jiti on Windows so onboarding and configure flows stop tripping <code>ERR_UNSUPPORTED_ESM_URL_SCHEME</code>. (#62286) Thanks @chen-zhang-cs-code.</li>
<li>Plugins/channels: keep bundled channel artifact and secret-contract loading stable under lazy loading, preserve plugin-schema defaults during install, and fix Windows <code>file://</code> plus native-Jiti plugin loader paths so onboarding, doctor, <code>openclaw secret</code>, and bundled plugin installs work again. (#61832, #61836, #61853, #61856) Thanks @Zeesejo and contributors.</li>
<li>Plugins/ClawHub: verify downloaded plugin archives against version metadata SHA-256, fail closed when archive integrity metadata is missing or malformed, and tighten fallback ZIP verification so plugin installs cannot proceed on mismatched or incomplete ClawHub package metadata. (#60517) Thanks @mappel-nv.</li>
<li>Plugins/provider hooks: stop recursive provider snapshot loads from overflowing the stack during plugin initialization, while still preserving cached nested provider-hook results. (#61922, #61938, #61946, #61951)</li>
<li>Docker/plugins: stop forcing bundled plugin discovery to <code>/app/extensions</code> in runtime images so packaged installs use compiled <code>dist/extensions</code> artifacts again and Node 24 containers do not boot through source-only plugin entry paths. Fixes #62044. (#62316) Thanks @gumadeiras.</li>
<li>Providers/Ollama: honor the selected provider's <code>baseUrl</code> during streaming so multi-Ollama setups stop routing every stream to the first configured Ollama endpoint. (#61678)</li>
<li>Providers/Ollama: stop warning that Ollama could not be reached when discovery only sees empty default local stubs, while still keeping real explicit Ollama overrides loud when the endpoint is unreachable.</li>
<li>Providers/xAI: recognize <code>api.grok.x.ai</code> as an xAI-native endpoint again and keep legacy <code>x_search</code> auth resolution working so older xAI web-search configs continue to load. (#61377) Thanks @jjjojoj.</li>
<li>Providers/Mistral: send <code>reasoning_effort</code> for <code>mistral/mistral-small-latest</code> (Mistral Small 4) with thinking-level mapping, and mark the catalog entry as reasoning-capable so adjustable reasoning matches Mistrals Chat Completions API. (#62162) Thanks @neeravmakwana.</li>
<li>OpenAI TTS/Groq: send <code>wav</code> to Groq-compatible speech endpoints, honor explicit <code>responseFormat</code> overrides on OpenAI-compatible paths, and only mark voice-note output as voice-compatible when the actual format is <code>opus</code>. (#62233) Thanks @neeravmakwana.</li>
<li>Tools/web_fetch and web_search: fix <code>TypeError: fetch failed</code> caused by undici 8.0 enabling HTTP/2 by default; pinned SSRF-guard dispatchers now explicitly set <code>allowH2: false</code> to restore HTTP/1.1 behavior and keep the custom DNS-pinning lookup compatible. (#61738, #61777) Thanks @zozo123.</li>
<li>Tools/web search/Exa: show Exa Search in onboarding and configure provider pickers again by marking the bundled Exa provider as setup-visible. Thanks @vincentkoc.</li>
<li>Memory/vector recall: surface explicit warnings when <code>sqlite-vec</code> is unavailable or vector writes are degraded, and strip managed Light Sleep and REM blocks before daily-note ingestion so memory indexing and dreaming stop reporting false-success or re-ingesting staged output. (#61720) Thanks @MonkeyLeeT.</li>
<li>Memory/dreaming: make Dreams config reads and writes respect the selected memory slot plugin instead of always targeting <code>memory-core</code>. (#62275) Thanks @SnowSky1.</li>
<li>QQ Bot/media: route gateway-side attachment and fallback downloads through guarded QQ/Tencent HTTPS fetches so QQ media handling no longer follows arbitrary remote hosts.</li>
<li>Browser/remote CDP: retry the DevTools websocket once after remote browser restarts so healthy remote browser profiles do not fail availability checks during CDP warm-up. (#57397) Thanks @ThanhNguyxn07.</li>
<li>UI/light mode: target both root and nested WebKit scrollbar thumbs in the light theme so page-level and container scrollbars stay visible on light backgrounds. (#61753) Thanks @chziyue.</li>
<li>Agents/subagents: honor <code>sessions_spawn(lightContext: true)</code> for spawned subagent runs by preserving lightweight bootstrap context through the gateway and embedded runner instead of silently falling back to full workspace bootstrap injection. (#62264) Thanks @theSamPadilla.</li>
<li>Cron: load <code>jobId</code> into <code>id</code> when the on-disk store omits <code>id</code>, matching doctor migration and fixing <code>unknown cron job id</code> for hand-edited <code>jobs.json</code>. (#62246) Thanks @neeravmakwana.</li>
<li>Agents/model fallback: classify minimal HTTP 404 API errors (for example <code>404 status code (no body)</code>) as <code>model_not_found</code> so assistant failures throw into the fallback chain instead of stopping at the first fallback candidate. (#62119) Thanks @neeravmakwana.</li>
<li>BlueBubbles/network: respect explicit private-network opt-out for loopback and private <code>serverUrl</code> values across account resolution, status probes, monitor startup, and attachment downloads, while keeping public-host attachment hostname pinning intact. (#59373) Thanks @jpreagan.</li>
<li>Agents/heartbeat: keep heartbeat runs pinned to the main session so active subagent transcripts are not overwritten by heartbeat status messages. (#61803) Thanks @100yenadmin.</li>
<li>Agents/heartbeat: respect disabled heartbeat prompt guidance so operators can suppress heartbeat prompt instructions without disabling heartbeat runtime behavior.</li>
<li>Agents/compaction: stop compaction-wait aborts from re-entering prompt failover and replaying completed tool turns. (#62600) Thanks @i-dentifier.</li>
<li>Approvals/runtime: move native approval lifecycle assembly into shared core bootstrap/runtime seams driven by channel capabilities and runtime contexts, and remove the legacy bundled approval fallback wiring. (#62135) Thanks @gumadeiras.</li>
<li>Security/fetch-guard: stop rejecting operator-configured proxy hostnames against the target-scoped hostname allowlist in SSRF-guarded fetches, restoring proxy-based media downloads for Telegram and other channels. (#62312) Thanks @ademczuk.</li>
<li>Logging: make <code>logging.level</code> and <code>logging.consoleLevel</code> honor the documented severity threshold ordering again, and keep child loggers inheriting the parent <code>minLevel</code>. (#44646) Thanks @zhumengzhu.</li>
<li>Agents/sessions_send: pass <code>threadId</code> through announce delivery so cross-session notifications land in the correct Telegram forum topic instead of the group's general thread. (#62758) Thanks @jalehman.</li>
<li>Daemon/systemd: keep sudo systemctl calls scoped to the invoking user when machine-scoped systemctl fails, while still avoiding machine fallback for permission-denied user bus errors. (#62337) Thanks @Aftabbs.</li>
<li>Docs/i18n: relocalize final localized-page links after translation and remove the zh-CN homepage redirect override so localized Mintlify pages resolve to the correct language roots again. (#61796) Thanks @hxy91819.</li>
<li>Agents/exec: keep timed-out shell-backgrounded commands on the failed path and point long-running jobs to exec background/yield sessions so process polling is only suggested for registered sessions.</li>
</ul>
<p><a href="https://github.com/openclaw/openclaw/blob/main/CHANGELOG.md">View full changelog</a></p>
]]></description>
<enclosure url="https://github.com/openclaw/openclaw/releases/download/v2026.4.7/OpenClaw-2026.4.7.zip" length="25324827" type="application/octet-stream" sparkle:edSignature="RyFWRz1trE/qvOiInD4vR6je9wx7fUTtHpZ94W8rMlZDByux9CyXOm/Anai96b9KyjTeQyC7YnJp5SRnYY3iCg=="/>
</item>
</channel>
</rss>

View File

@@ -65,8 +65,8 @@ android {
applicationId = "ai.openclaw.app"
minSdk = 31
targetSdk = 36
versionCode = 2026041001
versionName = "2026.4.10"
versionCode = 2026041101
versionName = "2026.4.11"
ndk {
// Support all major ABIs — native libs are tiny (~47 KB per ABI)
abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")

View File

@@ -2,8 +2,8 @@
// Source of truth: apps/ios/version.json
// Generated by scripts/ios-sync-versioning.ts.
OPENCLAW_IOS_VERSION = 2026.4.10
OPENCLAW_MARKETING_VERSION = 2026.4.10
OPENCLAW_IOS_VERSION = 2026.4.11
OPENCLAW_MARKETING_VERSION = 2026.4.11
OPENCLAW_BUILD_VERSION = 1
#include? "../build/Version.xcconfig"

View File

@@ -1,3 +1,3 @@
{
"version": "2026.4.10"
"version": "2026.4.11"
}

View File

@@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2026.4.10</string>
<string>2026.4.11</string>
<key>CFBundleVersion</key>
<string>2026041001</string>
<string>2026041101</string>
<key>CFBundleIconFile</key>
<string>OpenClaw</string>
<key>CFBundleURLTypes</key>

View File

@@ -11,6 +11,40 @@ enum ShellExecutor {
var errorMessage: String?
}
private final class CompletionBox: @unchecked Sendable {
private let lock = NSLock()
private var finished = false
private let continuation: CheckedContinuation<ShellResult, Never>
init(continuation: CheckedContinuation<ShellResult, Never>) {
self.continuation = continuation
}
func finish(_ result: ShellResult) {
self.lock.lock()
defer { self.lock.unlock() }
guard !self.finished else { return }
self.finished = true
self.continuation.resume(returning: result)
}
}
private static func completedResult(
status: Int,
outTask: Task<Data, Never>,
errTask: Task<Data, Never>) async -> ShellResult
{
let out = await outTask.value
let err = await errTask.value
return ShellResult(
stdout: String(bytes: out, encoding: .utf8) ?? "",
stderr: String(bytes: err, encoding: .utf8) ?? "",
exitCode: status,
timedOut: false,
success: status == 0,
errorMessage: status == 0 ? nil : "exit \(status)")
}
static func runDetailed(
command: [String],
cwd: String?,
@@ -38,6 +72,53 @@ enum ShellExecutor {
process.standardOutput = stdoutPipe
process.standardError = stderrPipe
let outTask = Task { stdoutPipe.fileHandleForReading.readToEndSafely() }
let errTask = Task { stderrPipe.fileHandleForReading.readToEndSafely() }
if let timeout, timeout > 0 {
return await withCheckedContinuation { continuation in
let completion = CompletionBox(continuation: continuation)
process.terminationHandler = { terminatedProcess in
let status = Int(terminatedProcess.terminationStatus)
Task {
let result = await self.completedResult(
status: status,
outTask: outTask,
errTask: errTask)
completion.finish(result)
}
}
do {
try process.run()
} catch {
completion.finish(
ShellResult(
stdout: "",
stderr: "",
exitCode: nil,
timedOut: false,
success: false,
errorMessage: "failed to start: \(error.localizedDescription)"))
return
}
DispatchQueue.global(qos: .userInitiated).asyncAfter(deadline: .now() + timeout) {
guard process.isRunning else { return }
process.terminate()
completion.finish(
ShellResult(
stdout: "",
stderr: "",
exitCode: nil,
timedOut: true,
success: false,
errorMessage: "timeout"))
}
}
}
do {
try process.run()
} catch {
@@ -50,48 +131,11 @@ enum ShellExecutor {
errorMessage: "failed to start: \(error.localizedDescription)")
}
let outTask = Task { stdoutPipe.fileHandleForReading.readToEndSafely() }
let errTask = Task { stderrPipe.fileHandleForReading.readToEndSafely() }
let waitTask = Task { () -> ShellResult in
process.waitUntilExit()
let out = await outTask.value
let err = await errTask.value
let status = Int(process.terminationStatus)
return ShellResult(
stdout: String(bytes: out, encoding: .utf8) ?? "",
stderr: String(bytes: err, encoding: .utf8) ?? "",
exitCode: status,
timedOut: false,
success: status == 0,
errorMessage: status == 0 ? nil : "exit \(status)")
}
if let timeout, timeout > 0 {
let nanos = UInt64(timeout * 1_000_000_000)
return await withTaskGroup(of: ShellResult.self) { group in
group.addTask { await waitTask.value }
group.addTask {
try? await Task.sleep(nanoseconds: nanos)
guard process.isRunning else {
return await waitTask.value
}
process.terminate()
return ShellResult(
stdout: "",
stderr: "",
exitCode: nil,
timedOut: true,
success: false,
errorMessage: "timeout")
}
let first = await group.next()!
group.cancelAll()
return first
}
}
return await waitTask.value
process.waitUntilExit()
return await self.completedResult(
status: Int(process.terminationStatus),
outTask: outTask,
errTask: errTask)
}
static func run(command: [String], cwd: String?, env: [String: String]?, timeout: Double?) async -> Response {

View File

@@ -128,8 +128,9 @@ actor TalkModeRuntime {
private func start() async {
let gen = self.lifecycleGeneration
guard voiceWakeSupported else { return }
guard PermissionManager.voiceWakePermissionsGranted() else {
self.logger.debug("talk runtime not starting: permissions missing")
guard await PermissionManager.ensureVoiceWakePermissions(interactive: true) else {
self.logger.error("talk runtime not starting: permissions missing")
return
}
await self.reloadConfig()

View File

@@ -1,2 +1,2 @@
ee16273fa5ad8c5408e9dad8d96fde86dfa666ef8eb44840b78135814ff97173 plugin-sdk-api-baseline.json
2bd0d5edf23e6a889d6bedb74d0d06411dd7750dac6ebf24971c789f8a69253a plugin-sdk-api-baseline.jsonl
7a5c71593c9efbb936b9632f0b381a6c603e9bce44706b312a0172504fa51ef6 plugin-sdk-api-baseline.json
0b044de57266d20561838a5ae0edbaacaa53b323d4c8c068e701a48f92f0a264 plugin-sdk-api-baseline.jsonl

View File

@@ -2895,6 +2895,8 @@ See [Plugins](/tools/plugin).
enabled: true,
basePath: "/openclaw",
// root: "dist/control-ui",
// embedSandbox: "scripts", // strict | scripts | trusted
// allowExternalEmbedUrls: false, // dangerous: allow absolute external http(s) embed URLs
// allowedOrigins: ["https://control.example.com"], // required for non-loopback Control UI
// dangerouslyAllowHostHeaderOriginFallback: false, // dangerous Host-header origin fallback mode
// allowInsecureAuth: false,

View File

@@ -519,10 +519,15 @@ The manifest is the control-plane source of truth. OpenClaw uses it to:
- validate `plugins.entries.<id>.config`
- augment Control UI labels/placeholders
- show install/catalog metadata
- preserve cheap activation and setup descriptors without loading plugin runtime
For native plugins, the runtime module is the data-plane part. It registers
actual behavior such as hooks, tools, commands, or provider flows.
Optional manifest `activation` and `setup` blocks stay on the control plane.
They are metadata-only descriptors for activation planning and setup discovery;
they do not replace runtime registration, `register(...)`, or `setupEntry`.
### What the loader caches
OpenClaw keeps short in-process caches for:

View File

@@ -47,6 +47,10 @@ Use it for:
- config validation
- auth and onboarding metadata that should be available without booting plugin
runtime
- cheap activation hints that control-plane surfaces can inspect before runtime
loads
- cheap setup descriptors that setup/onboarding surfaces can inspect before
runtime loads
- alias and auto-enable metadata that should resolve before plugin runtime loads
- shorthand model-family ownership metadata that should auto-activate the
plugin before runtime loads
@@ -152,6 +156,8 @@ Those belong in your plugin code and `package.json`.
| `providerAuthAliases` | No | `Record<string, string>` | Provider ids that should reuse another provider id for auth lookup, for example a coding provider that shares the base provider API key and auth profiles. |
| `channelEnvVars` | No | `Record<string, string[]>` | Cheap channel env metadata that OpenClaw can inspect without loading plugin code. Use this for env-driven channel setup or auth surfaces that generic startup/config helpers should see. |
| `providerAuthChoices` | No | `object[]` | Cheap auth-choice metadata for onboarding pickers, preferred-provider resolution, and simple CLI flag wiring. |
| `activation` | No | `object` | Cheap activation hints for provider, command, channel, route, and capability-triggered loading. Metadata only; plugin runtime still owns actual behavior. |
| `setup` | No | `object` | Cheap setup/onboarding descriptors that discovery and setup surfaces can inspect without loading plugin runtime. |
| `contracts` | No | `object` | Static bundled capability snapshot for speech, realtime transcription, realtime voice, media-understanding, image-generation, music-generation, video-generation, web-fetch, web search, and tool ownership. |
| `channelConfigs` | No | `Record<string, object>` | Manifest-owned channel config metadata merged into discovery and validation surfaces before runtime loads. |
| `skills` | No | `string[]` | Skill directories to load, relative to the plugin root. |
@@ -208,6 +214,77 @@ uses this metadata for diagnostics without importing plugin runtime code.
| `kind` | No | `"runtime-slash"` | Marks the alias as a chat slash command rather than a root CLI command. |
| `cliCommand` | No | `string` | Related root CLI command to suggest for CLI operations, if one exists. |
## activation reference
Use `activation` when the plugin can cheaply declare which control-plane events
should activate it later.
This block is metadata only. It does not register runtime behavior, and it does
not replace `register(...)`, `setupEntry`, or other runtime/plugin entrypoints.
```json
{
"activation": {
"onProviders": ["openai"],
"onCommands": ["models"],
"onChannels": ["web"],
"onRoutes": ["gateway-webhook"],
"onCapabilities": ["provider", "tool"]
}
}
```
| Field | Required | Type | What it means |
| ---------------- | -------- | ---------------------------------------------------- | ----------------------------------------------------------------- |
| `onProviders` | No | `string[]` | Provider ids that should activate this plugin when requested. |
| `onCommands` | No | `string[]` | Command ids that should activate this plugin. |
| `onChannels` | No | `string[]` | Channel ids that should activate this plugin. |
| `onRoutes` | No | `string[]` | Route kinds that should activate this plugin. |
| `onCapabilities` | No | `Array<"provider" \| "channel" \| "tool" \| "hook">` | Broad capability hints used by control-plane activation planning. |
## setup reference
Use `setup` when setup and onboarding surfaces need cheap plugin-owned metadata
before runtime loads.
```json
{
"setup": {
"providers": [
{
"id": "openai",
"authMethods": ["api-key"],
"envVars": ["OPENAI_API_KEY"]
}
],
"cliBackends": ["openai-cli"],
"configMigrations": ["legacy-openai-auth"],
"requiresRuntime": false
}
}
```
Top-level `cliBackends` stays valid and continues to describe CLI inference
backends. `setup.cliBackends` is the setup-specific descriptor surface for
control-plane/setup flows that should stay metadata-only.
### setup.providers reference
| Field | Required | Type | What it means |
| ------------- | -------- | ---------- | ---------------------------------------------------------------------------------- |
| `id` | Yes | `string` | Provider id exposed during setup or onboarding. |
| `authMethods` | No | `string[]` | Setup/auth method ids this provider supports without loading full runtime. |
| `envVars` | No | `string[]` | Env vars that generic setup/status surfaces can check before plugin runtime loads. |
### setup fields
| Field | Required | Type | What it means |
| ------------------ | -------- | ---------- | --------------------------------------------------------------------------- |
| `providers` | No | `object[]` | Provider setup descriptors exposed during setup and onboarding. |
| `cliBackends` | No | `string[]` | Setup-time backend ids available without full runtime activation. |
| `configMigrations` | No | `string[]` | Config migration ids owned by this plugin's setup surface. |
| `requiresRuntime` | No | `boolean` | Whether setup still needs plugin runtime execution after descriptor lookup. |
## uiHints reference
`uiHints` is a map from config field names to small rendering hints.

View File

@@ -0,0 +1,50 @@
# Rich Output Protocol
Assistant output can carry a small set of delivery/render directives:
- `MEDIA:` for attachment delivery
- `[[audio_as_voice]]` for audio presentation hints
- `[[reply_to_current]]` / `[[reply_to:<id>]]` for reply metadata
- `[embed ...]` for Control UI rich rendering
These directives are separate. `MEDIA:` and reply/voice tags remain delivery metadata; `[embed ...]` is the web-only rich render path.
## `[embed ...]`
`[embed ...]` is the only agent-facing rich render syntax for the Control UI.
Self-closing example:
```text
[embed ref="cv_123" title="Status" /]
```
Rules:
- `[view ...]` is no longer valid for new output.
- Embed shortcodes render in the assistant message surface only.
- Only URL-backed embeds are rendered. Use `ref="..."` or `url="..."`.
- Block-form inline HTML embed shortcodes are not rendered.
- The web UI strips the shortcode from visible text and renders the embed inline.
- `MEDIA:` is not an embed alias and should not be used for rich embed rendering.
## Stored Rendering Shape
The normalized/stored assistant content block is a structured `canvas` item:
```json
{
"type": "canvas",
"preview": {
"kind": "canvas",
"surface": "assistant_message",
"render": "url",
"viewId": "cv_123",
"url": "/__openclaw__/canvas/documents/cv_123/index.html",
"title": "Status",
"preferredHeight": 320
}
}
```
Stored/rendered rich blocks use this `canvas` shape directly. `present_view` is not recognized.

View File

@@ -1,5 +1,5 @@
---
summary: "Generate videos from text, images, or existing videos using 12 provider backends"
summary: "Generate videos from text, images, or existing videos using 14 provider backends"
read_when:
- Generating videos via the agent
- Configuring video generation providers and models
@@ -9,7 +9,7 @@ title: "Video Generation"
# Video Generation
OpenClaw agents can generate videos from text prompts, reference images, or existing videos. Twelve provider backends are supported, each with different model options, input modes, and feature sets. The agent picks the right provider automatically based on your configuration and available API keys.
OpenClaw agents can generate videos from text prompts, reference images, or existing videos. Fourteen provider backends are supported, each with different model options, input modes, and feature sets. The agent picks the right provider automatically based on your configuration and available API keys.
<Note>
The `video_generate` tool only appears when at least one video-generation provider is available. If you do not see it in your agent tools, set a provider API key or configure `agents.defaults.videoGenerationModel`.
@@ -78,20 +78,22 @@ Duplicate prevention: if a video task is already `queued` or `running` for the c
## Supported providers
| Provider | Default model | Text | Image ref | Video ref | API key |
| -------- | ------------------------------- | ---- | ----------------- | ---------------- | ---------------------------------------- |
| Alibaba | `wan2.6-t2v` | Yes | Yes (remote URL) | Yes (remote URL) | `MODELSTUDIO_API_KEY` |
| BytePlus | `seedance-1-0-lite-t2v-250428` | Yes | 1 image | No | `BYTEPLUS_API_KEY` |
| ComfyUI | `workflow` | Yes | 1 image | No | `COMFY_API_KEY` or `COMFY_CLOUD_API_KEY` |
| fal | `fal-ai/minimax/video-01-live` | Yes | 1 image | No | `FAL_KEY` |
| Google | `veo-3.1-fast-generate-preview` | Yes | 1 image | 1 video | `GEMINI_API_KEY` |
| MiniMax | `MiniMax-Hailuo-2.3` | Yes | 1 image | No | `MINIMAX_API_KEY` |
| OpenAI | `sora-2` | Yes | 1 image | 1 video | `OPENAI_API_KEY` |
| Qwen | `wan2.6-t2v` | Yes | Yes (remote URL) | Yes (remote URL) | `QWEN_API_KEY` |
| Runway | `gen4.5` | Yes | 1 image | 1 video | `RUNWAYML_API_SECRET` |
| Together | `Wan-AI/Wan2.2-T2V-A14B` | Yes | 1 image | No | `TOGETHER_API_KEY` |
| Vydra | `veo3` | Yes | 1 image (`kling`) | No | `VYDRA_API_KEY` |
| xAI | `grok-imagine-video` | Yes | 1 image | 1 video | `XAI_API_KEY` |
| Provider | Default model | Text | Image ref | Video ref | API key |
| --------------------- | ------------------------------- | ---- | ---------------------------------------------------- | ---------------- | ---------------------------------------- |
| Alibaba | `wan2.6-t2v` | Yes | Yes (remote URL) | Yes (remote URL) | `MODELSTUDIO_API_KEY` |
| BytePlus (1.0) | `seedance-1-0-pro-250528` | Yes | Up to 2 images (I2V models only; first + last frame) | No | `BYTEPLUS_API_KEY` |
| BytePlus Seedance 1.5 | `seedance-1-5-pro-251215` | Yes | Up to 2 images (first + last frame via role) | No | `BYTEPLUS_API_KEY` |
| BytePlus Seedance 2.0 | `dreamina-seedance-2-0-260128` | Yes | Up to 9 reference images | Up to 3 videos | `BYTEPLUS_API_KEY` |
| ComfyUI | `workflow` | Yes | 1 image | No | `COMFY_API_KEY` or `COMFY_CLOUD_API_KEY` |
| fal | `fal-ai/minimax/video-01-live` | Yes | 1 image | No | `FAL_KEY` |
| Google | `veo-3.1-fast-generate-preview` | Yes | 1 image | 1 video | `GEMINI_API_KEY` |
| MiniMax | `MiniMax-Hailuo-2.3` | Yes | 1 image | No | `MINIMAX_API_KEY` |
| OpenAI | `sora-2` | Yes | 1 image | 1 video | `OPENAI_API_KEY` |
| Qwen | `wan2.6-t2v` | Yes | Yes (remote URL) | Yes (remote URL) | `QWEN_API_KEY` |
| Runway | `gen4.5` | Yes | 1 image | 1 video | `RUNWAYML_API_SECRET` |
| Together | `Wan-AI/Wan2.2-T2V-A14B` | Yes | 1 image | No | `TOGETHER_API_KEY` |
| Vydra | `veo3` | Yes | 1 image (`kling`) | No | `VYDRA_API_KEY` |
| xAI | `grok-imagine-video` | Yes | 1 image | 1 video | `XAI_API_KEY` |
Some providers accept additional or alternate API key env vars. See individual [provider pages](#related) for details.
@@ -128,31 +130,49 @@ and the shared live sweep.
### Content inputs
| Parameter | Type | Description |
| --------- | -------- | ------------------------------------ |
| `image` | string | Single reference image (path or URL) |
| `images` | string[] | Multiple reference images (up to 5) |
| `video` | string | Single reference video (path or URL) |
| `videos` | string[] | Multiple reference videos (up to 4) |
| Parameter | Type | Description |
| ------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `image` | string | Single reference image (path or URL) |
| `images` | string[] | Multiple reference images (up to 9) |
| `imageRoles` | string[] | Optional per-position role hints parallel to the combined image list. Canonical values: `first_frame`, `last_frame`, `reference_image` |
| `video` | string | Single reference video (path or URL) |
| `videos` | string[] | Multiple reference videos (up to 4) |
| `videoRoles` | string[] | Optional per-position role hints parallel to the combined video list. Canonical value: `reference_video` |
| `audioRef` | string | Single reference audio (path or URL). Used for e.g. background music or voice reference when the provider supports audio inputs |
| `audioRefs` | string[] | Multiple reference audios (up to 3) |
| `audioRoles` | string[] | Optional per-position role hints parallel to the combined audio list. Canonical value: `reference_audio` |
Role hints are forwarded to the provider as-is. Canonical values come from
the `VideoGenerationAssetRole` union but providers may accept additional
role strings. `*Roles` arrays must not have more entries than the
corresponding reference list; off-by-one mistakes fail with a clear error.
Use an empty string to leave a slot unset.
### Style controls
| Parameter | Type | Description |
| ----------------- | ------- | ------------------------------------------------------------------------ |
| `aspectRatio` | string | `1:1`, `2:3`, `3:2`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, `21:9` |
| `resolution` | string | `480P`, `720P`, `768P`, or `1080P` |
| `durationSeconds` | number | Target duration in seconds (rounded to nearest provider-supported value) |
| `size` | string | Size hint when the provider supports it |
| `audio` | boolean | Enable generated audio when supported |
| `watermark` | boolean | Toggle provider watermarking when supported |
| Parameter | Type | Description |
| ----------------- | ------- | --------------------------------------------------------------------------------------- |
| `aspectRatio` | string | `1:1`, `2:3`, `3:2`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, `21:9`, or `adaptive` |
| `resolution` | string | `480P`, `720P`, `768P`, or `1080P` |
| `durationSeconds` | number | Target duration in seconds (rounded to nearest provider-supported value) |
| `size` | string | Size hint when the provider supports it |
| `audio` | boolean | Enable generated audio in the output when supported. Distinct from `audioRef*` (inputs) |
| `watermark` | boolean | Toggle provider watermarking when supported |
`adaptive` is a provider-specific sentinel: it is forwarded as-is to
providers that declare `adaptive` in their capabilities (e.g. BytePlus
Seedance uses it to auto-detect the ratio from the input image
dimensions). Providers that do not declare it surface the value via
`details.ignoredOverrides` in the tool result so the drop is visible.
### Advanced
| Parameter | Type | Description |
| ---------- | ------ | ----------------------------------------------- |
| `action` | string | `"generate"` (default), `"status"`, or `"list"` |
| `model` | string | Provider/model override (e.g. `runway/gen4.5`) |
| `filename` | string | Output filename hint |
| Parameter | Type | Description |
| ----------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `action` | string | `"generate"` (default), `"status"`, or `"list"` |
| `model` | string | Provider/model override (e.g. `runway/gen4.5`) |
| `filename` | string | Output filename hint |
| `providerOptions` | object | Provider-specific options as a JSON object (e.g. `{"seed": 42, "draft": true}`). Providers that declare a typed schema validate the keys and types; unknown keys or mismatches skip the candidate during fallback. Providers without a declared schema receive the options as-is. Run `video_generate action=list` to see what each provider accepts |
Not all providers support all parameters. OpenClaw already normalizes duration to the closest provider-supported value, and it also remaps translated geometry hints such as size-to-aspect-ratio when a fallback provider exposes a different control surface. Truly unsupported overrides are ignored on a best-effort basis and reported as warnings in the tool result. Hard capability limits (such as too many reference inputs) fail before submission.
@@ -163,10 +183,37 @@ Reference inputs also select the runtime mode:
- No reference media: `generate`
- Any image reference: `imageToVideo`
- Any video reference: `videoToVideo`
- Reference audio inputs do not change the resolved mode; they apply on top of whatever mode the image/video references select, and only work with providers that declare `maxInputAudios`
Mixed image and video references are not a stable shared capability surface.
Prefer one reference type per request.
#### Fallback and typed options
Some capability checks are applied at the fallback layer rather than the
tool boundary so that a request that exceeds the primary provider's limits
can still run on a capable fallback:
- If the active candidate declares no `maxInputAudios` (or declares it as
`0`), it is skipped when the request contains audio references, and the
next candidate is tried.
- If the active candidate's `maxDurationSeconds` is below the requested
`durationSeconds` and the candidate does not declare a
`supportedDurationSeconds` list, it is skipped.
- If the request contains `providerOptions` and the active candidate
explicitly declares a typed `providerOptions` schema, the candidate is
skipped when the supplied keys are not in the schema or the value types do
not match. Providers that have not yet declared a schema receive the
options as-is (backward-compatible pass-through). A provider can
explicitly opt out of all provider options by declaring an empty schema
(`capabilities.providerOptions: {}`), which causes the same skip as a
type mismatch.
The first skip reason in a request is logged at `warn` so operators see
when their primary provider was passed over; subsequent skips log at
`debug` to keep long fallback chains quiet. If every candidate is skipped,
the aggregated error includes the skip reason for each.
## Actions
- **generate** (default) -- create a video from the given prompt and optional reference inputs.
@@ -201,50 +248,24 @@ entries.
}
```
HeyGen video-agent on fal can be pinned with:
```json5
{
agents: {
defaults: {
videoGenerationModel: {
primary: "fal/fal-ai/heygen/v2/video-agent",
},
},
},
}
```
Seedance 2.0 on fal can be pinned with:
```json5
{
agents: {
defaults: {
videoGenerationModel: {
primary: "fal/bytedance/seedance-2.0/fast/text-to-video",
},
},
},
}
```
## Provider notes
| Provider | Notes |
| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Alibaba | Uses DashScope/Model Studio async endpoint. Reference images and videos must be remote `http(s)` URLs. |
| BytePlus | Single image reference only. |
| ComfyUI | Workflow-driven local or cloud execution. Supports text-to-video and image-to-video through the configured graph. |
| fal | Uses queue-backed flow for long-running jobs. Single image reference only. Includes HeyGen video-agent and Seedance 2.0 text-to-video and image-to-video model refs. |
| Google | Uses Gemini/Veo. Supports one image or one video reference. |
| MiniMax | Single image reference only. |
| OpenAI | Only `size` override is forwarded. Other style overrides (`aspectRatio`, `resolution`, `audio`, `watermark`) are ignored with a warning. |
| Qwen | Same DashScope backend as Alibaba. Reference inputs must be remote `http(s)` URLs; local files are rejected upfront. |
| Runway | Supports local files via data URIs. Video-to-video requires `runway/gen4_aleph`. Text-only runs expose `16:9` and `9:16` aspect ratios. |
| Together | Single image reference only. |
| Vydra | Uses `https://www.vydra.ai/api/v1` directly to avoid auth-dropping redirects. `veo3` is bundled as text-to-video only; `kling` requires a remote image URL. |
| xAI | Supports text-to-video, image-to-video, and remote video edit/extend flows. |
| Provider | Notes |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Alibaba | Uses DashScope/Model Studio async endpoint. Reference images and videos must be remote `http(s)` URLs. |
| BytePlus (1.0) | Provider id `byteplus`. Models: `seedance-1-0-pro-250528` (default), `seedance-1-0-pro-t2v-250528`, `seedance-1-0-pro-fast-251015`, `seedance-1-0-lite-t2v-250428`, `seedance-1-0-lite-i2v-250428`. T2V models (`*-t2v-*`) do not accept image inputs; I2V models and general `*-pro-*` models support a single reference image (first frame). Pass the image positionally or set `role: "first_frame"`. T2V model IDs are automatically switched to the corresponding I2V variant when an image is provided. Supported `providerOptions` keys: `seed` (number), `draft` (boolean, forces 480p), `camera_fixed` (boolean). |
| BytePlus Seedance 1.5 | Requires the [`@openclaw/byteplus-modelark`](https://www.npmjs.com/package/@openclaw/byteplus-modelark) plugin. Provider id `byteplus-seedance15`. Model: `seedance-1-5-pro-251215`. Uses the unified `content[]` API. Supports at most 2 input images (first_frame + last_frame). All inputs must be remote `https://` URLs. Set `role: "first_frame"` / `"last_frame"` on each image, or pass images positionally. `aspectRatio: "adaptive"` auto-detects ratio from the input image. `audio: true` maps to `generate_audio`. `providerOptions.seed` (number) is forwarded. |
| BytePlus Seedance 2.0 | Requires the [`@openclaw/byteplus-modelark`](https://www.npmjs.com/package/@openclaw/byteplus-modelark) plugin. Provider id `byteplus-seedance2`. Models: `dreamina-seedance-2-0-260128`, `dreamina-seedance-2-0-fast-260128`. Uses the unified `content[]` API. Supports up to 9 reference images, 3 reference videos, and 3 reference audios. All inputs must be remote `https://` URLs. Set `role` on each asset — supported values: `"first_frame"`, `"last_frame"`, `"reference_image"`, `"reference_video"`, `"reference_audio"`. `aspectRatio: "adaptive"` auto-detects ratio from the input image. `audio: true` maps to `generate_audio`. `providerOptions.seed` (number) is forwarded. |
| ComfyUI | Workflow-driven local or cloud execution. Supports text-to-video and image-to-video through the configured graph. |
| fal | Uses queue-backed flow for long-running jobs. Single image reference only. |
| Google | Uses Gemini/Veo. Supports one image or one video reference. |
| MiniMax | Single image reference only. |
| OpenAI | Only `size` override is forwarded. Other style overrides (`aspectRatio`, `resolution`, `audio`, `watermark`) are ignored with a warning. |
| Qwen | Same DashScope backend as Alibaba. Reference inputs must be remote `http(s)` URLs; local files are rejected upfront. |
| Runway | Supports local files via data URIs. Video-to-video requires `runway/gen4_aleph`. Text-only runs expose `16:9` and `9:16` aspect ratios. |
| Together | Single image reference only. |
| Vydra | Uses `https://www.vydra.ai/api/v1` directly to avoid auth-dropping redirects. `veo3` is bundled as text-to-video only; `kling` requires a remote image URL. |
| xAI | Supports text-to-video, image-to-video, and remote video edit/extend flows. |
## Provider capability modes

View File

@@ -138,6 +138,38 @@ Cron jobs panel notes:
- Gateway persists aborted partial assistant text into transcript history when buffered output exists
- Persisted entries include abort metadata so transcript consumers can tell abort partials from normal completion output
## Hosted embeds
Assistant messages can render hosted web content inline with the `[embed ...]`
shortcode. The iframe sandbox policy is controlled by
`gateway.controlUi.embedSandbox`:
- `strict`: disables script execution inside hosted embeds
- `scripts`: allows interactive embeds while keeping origin isolation; this is
the default and is usually enough for self-contained browser games/widgets
- `trusted`: adds `allow-same-origin` on top of `allow-scripts` for same-site
documents that intentionally need stronger privileges
Example:
```json5
{
gateway: {
controlUi: {
embedSandbox: "scripts",
},
},
}
```
Use `trusted` only when the embedded document genuinely needs same-origin
behavior. For most agent-generated games and interactive canvases, `scripts` is
the safer choice.
Absolute external `http(s)` embed URLs stay blocked by default. If you
intentionally want `[embed url="https://..."]` to load third-party pages, set
`gateway.controlUi.allowExternalEmbedUrls: true`.
## Tailnet access (recommended)
### Integrated Tailscale Serve (preferred)

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/acpx",
"version": "2026.4.10",
"version": "2026.4.11",
"description": "OpenClaw ACP runtime backend",
"type": "module",
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/alibaba-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Alibaba Model Studio video provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/amazon-bedrock-mantle-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Amazon Bedrock Mantle (OpenAI-compatible) provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/amazon-bedrock-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Amazon Bedrock provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/anthropic-vertex-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Anthropic Vertex provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/anthropic-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Anthropic provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/arcee-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Arcee provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/bluebubbles",
"version": "2026.4.10",
"version": "2026.4.11",
"description": "OpenClaw BlueBubbles channel plugin",
"type": "module",
"devDependencies": {
@@ -8,7 +8,7 @@
"openclaw": "workspace:*"
},
"peerDependencies": {
"openclaw": ">=2026.4.10"
"openclaw": ">=2026.4.11"
},
"peerDependenciesMeta": {
"openclaw": {
@@ -40,13 +40,13 @@
"install": {
"npmSpec": "@openclaw/bluebubbles",
"defaultChoice": "npm",
"minHostVersion": ">=2026.4.10"
"minHostVersion": ">=2026.4.11"
},
"compat": {
"pluginApi": ">=2026.4.10"
"pluginApi": ">=2026.4.11"
},
"build": {
"openclawVersion": "2026.4.10"
"openclawVersion": "2026.4.11"
},
"release": {
"publishToClawHub": true,

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/brave-plugin",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Brave plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/browser-plugin",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw browser tool plugin",
"type": "module",

View File

@@ -3,8 +3,8 @@ import {
normalizeLowercaseStringOrEmpty,
normalizeOptionalString,
} from "openclaw/plugin-sdk/text-runtime";
import type { OpenClawConfig } from "../config/config.js";
import { loadConfig, writeConfigFile } from "../config/config.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import { resolveGatewayAuth } from "../gateway/auth.js";
import { ensureGatewayStartupAuth } from "../gateway/startup-auth.js";

View File

@@ -5,7 +5,7 @@ import {
readBrowserVersion,
resolveGoogleChromeExecutableForPlatform,
} from "./browser/chrome.executables.js";
import type { OpenClawConfig } from "./config/config.js";
import type { OpenClawConfig } from "./config/types.openclaw.js";
import { asRecord } from "./record-shared.js";
const CHROME_MCP_MIN_MAJOR = 144;

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/byteplus-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw BytePlus provider plugin",
"type": "module",

View File

@@ -14,31 +14,35 @@ beforeAll(async () => {
installProviderHttpMockCleanup();
function mockSuccessfulBytePlusTask(params?: { model?: string }) {
postJsonRequestMock.mockResolvedValue({
response: {
json: async () => ({
id: "task_123",
}),
},
release: vi.fn(async () => {}),
});
fetchWithTimeoutMock
.mockResolvedValueOnce({
json: async () => ({
id: "task_123",
status: "succeeded",
content: {
video_url: "https://example.com/byteplus.mp4",
},
model: params?.model ?? "seedance-1-0-lite-t2v-250428",
}),
})
.mockResolvedValueOnce({
headers: new Headers({ "content-type": "video/mp4" }),
arrayBuffer: async () => Buffer.from("mp4-bytes"),
});
}
describe("byteplus video generation provider", () => {
it("creates a content-generation task, polls, and downloads the video", async () => {
postJsonRequestMock.mockResolvedValue({
response: {
json: async () => ({
id: "task_123",
}),
},
release: vi.fn(async () => {}),
});
fetchWithTimeoutMock
.mockResolvedValueOnce({
json: async () => ({
id: "task_123",
status: "succeeded",
content: {
video_url: "https://example.com/byteplus.mp4",
},
model: "seedance-1-0-lite-t2v-250428",
}),
})
.mockResolvedValueOnce({
headers: new Headers({ "content-type": "video/mp4" }),
arrayBuffer: async () => Buffer.from("mp4-bytes"),
});
mockSuccessfulBytePlusTask();
const provider = buildBytePlusVideoGenerationProvider();
const result = await provider.generateVideo({
@@ -60,4 +64,57 @@ describe("byteplus video generation provider", () => {
}),
);
});
it("switches t2v image requests to i2v models and lowercases resolution", async () => {
mockSuccessfulBytePlusTask({ model: "seedance-1-0-lite-i2v-250428" });
const provider = buildBytePlusVideoGenerationProvider();
await provider.generateVideo({
provider: "byteplus",
model: "seedance-1-0-lite-t2v-250428",
prompt: "Animate this still image",
resolution: "720P",
inputImages: [{ url: "https://example.com/first-frame.png" }],
cfg: {},
});
const request = postJsonRequestMock.mock.calls[0]?.[0] as { body?: Record<string, unknown> };
expect(request.body).toMatchObject({
model: "seedance-1-0-lite-i2v-250428",
resolution: "720p",
content: [
{ type: "text", text: "Animate this still image" },
{
type: "image_url",
image_url: { url: "https://example.com/first-frame.png" },
role: "first_frame",
},
],
});
});
it("maps declared providerOptions into the request body", async () => {
mockSuccessfulBytePlusTask({ model: "seedance-1-0-pro-250528" });
const provider = buildBytePlusVideoGenerationProvider();
await provider.generateVideo({
provider: "byteplus",
model: "seedance-1-0-pro-250528",
prompt: "A cinematic lobster montage",
providerOptions: {
seed: 42,
draft: true,
camera_fixed: false,
},
cfg: {},
});
const request = postJsonRequestMock.mock.calls[0]?.[0] as { body?: Record<string, unknown> };
expect(request.body).toMatchObject({
model: "seedance-1-0-pro-250528",
seed: 42,
resolution: "480p",
camera_fixed: false,
});
});
});

View File

@@ -141,6 +141,11 @@ export function buildBytePlusVideoGenerationProvider(): VideoGenerationProvider
agentDir,
}),
capabilities: {
providerOptions: {
seed: "number",
draft: "boolean",
camera_fixed: "boolean",
},
generate: {
maxVideos: 1,
maxDurationSeconds: 12,
@@ -191,6 +196,17 @@ export function buildBytePlusVideoGenerationProvider(): VideoGenerationProvider
capability: "video",
transport: "http",
});
// Seedance 1.0 has separate T2V and I2V model IDs (e.g. seedance-1-0-lite-t2v-250428 vs
// seedance-1-0-lite-i2v-250428). When input images are provided with a T2V model, auto-
// switch to the corresponding I2V variant so the API does not reject with task_type mismatch.
// 1.5 Pro uses a single model ID for both modes and is unaffected by this substitution.
const hasInputImages = (req.inputImages?.length ?? 0) > 0;
const requestedModel = normalizeOptionalString(req.model) || DEFAULT_BYTEPLUS_VIDEO_MODEL;
const resolvedModel =
hasInputImages && requestedModel.includes("-t2v-")
? requestedModel.replace("-t2v-", "-i2v-")
: requestedModel;
const content: Array<Record<string, unknown>> = [{ type: "text", text: req.prompt }];
const imageUrl = resolveBytePlusImageUrl(req);
if (imageUrl) {
@@ -201,15 +217,18 @@ export function buildBytePlusVideoGenerationProvider(): VideoGenerationProvider
});
}
const body: Record<string, unknown> = {
model: normalizeOptionalString(req.model) || DEFAULT_BYTEPLUS_VIDEO_MODEL,
model: resolvedModel,
content,
};
const aspectRatio = normalizeOptionalString(req.aspectRatio);
if (aspectRatio) {
body.ratio = aspectRatio;
}
if (req.resolution) {
body.resolution = req.resolution;
// Seedance API requires lowercase resolution values (e.g. "480p", "720p"); uppercase
// variants like "480P" are rejected with InvalidParameter.
const resolution = normalizeOptionalString(req.resolution)?.toLowerCase();
if (resolution) {
body.resolution = resolution;
}
if (typeof req.durationSeconds === "number" && Number.isFinite(req.durationSeconds)) {
body.duration = Math.max(1, Math.round(req.durationSeconds));
@@ -221,6 +240,23 @@ export function buildBytePlusVideoGenerationProvider(): VideoGenerationProvider
body.watermark = req.watermark;
}
// Forward declared providerOptions: seed, draft, camerafixed.
// draft=true forces 480p resolution for faster generation.
const opts = req.providerOptions ?? {};
const seed = typeof opts.seed === "number" ? opts.seed : undefined;
const draft = opts.draft === true;
// Official JSON body field is camera_fixed (with underscore).
const cameraFixed = typeof opts.camera_fixed === "boolean" ? opts.camera_fixed : undefined;
if (seed != null) {
body.seed = seed;
}
if (draft && !body.resolution) {
body.resolution = "480p";
}
if (cameraFixed != null) {
body.camera_fixed = cameraFixed;
}
const { response, release } = await postJsonRequest({
url: `${baseUrl}/contents/generations/tasks`,
headers,
@@ -255,7 +291,7 @@ export function buildBytePlusVideoGenerationProvider(): VideoGenerationProvider
});
return {
videos: [video],
model: completed.model ?? req.model ?? DEFAULT_BYTEPLUS_VIDEO_MODEL,
model: completed.model ?? resolvedModel,
metadata: {
taskId,
status: completed.status,

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/chutes-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Chutes.ai provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/cloudflare-ai-gateway-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Cloudflare AI Gateway provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/codex",
"version": "2026.4.9",
"version": "2026.4.11",
"description": "OpenClaw Codex harness and model provider plugin",
"type": "module",
"dependencies": {

View File

@@ -79,7 +79,7 @@ describe("CodexAppServerEventProjector", () => {
});
expect(onAssistantMessageStart).toHaveBeenCalledTimes(1);
expect(onPartialReply).toHaveBeenLastCalledWith({ text: "hello" });
expect(onPartialReply).not.toHaveBeenCalled();
expect(result.assistantTexts).toEqual(["hello"]);
expect(result.messagesSnapshot.map((message) => message.role)).toEqual(["user", "assistant"]);
expect(result.lastAssistant?.content).toEqual([{ type: "text", text: "hello" }]);
@@ -87,6 +87,79 @@ describe("CodexAppServerEventProjector", () => {
expect(result.replayMetadata.replaySafe).toBe(true);
});
it("keeps intermediate agentMessage items out of the final visible reply", async () => {
const onAssistantMessageStart = vi.fn();
const onPartialReply = vi.fn();
const params = {
...createParams(),
onAssistantMessageStart,
onPartialReply,
};
const projector = new CodexAppServerEventProjector(params, "thread-1", "turn-1");
await projector.handleNotification({
method: "item/agentMessage/delta",
params: {
threadId: "thread-1",
turnId: "turn-1",
itemId: "msg-commentary",
delta: "checking thread context; then post a tight progress reply here.",
},
});
await projector.handleNotification({
method: "item/agentMessage/delta",
params: {
threadId: "thread-1",
turnId: "turn-1",
itemId: "msg-final",
delta: "release fixes first. please drop affected PRs, failing checks, and blockers here.",
},
});
await projector.handleNotification({
method: "turn/completed",
params: {
threadId: "thread-1",
turnId: "turn-1",
turn: {
id: "turn-1",
status: "completed",
items: [
{
type: "agentMessage",
id: "msg-commentary",
text: "checking thread context; then post a tight progress reply here.",
},
{
type: "agentMessage",
id: "msg-final",
text: "release fixes first. please drop affected PRs, failing checks, and blockers here.",
},
],
},
},
});
const result = projector.buildResult({
didSendViaMessagingTool: false,
messagingToolSentTexts: [],
messagingToolSentMediaUrls: [],
messagingToolSentTargets: [],
});
expect(onAssistantMessageStart).toHaveBeenCalledTimes(1);
expect(onPartialReply).not.toHaveBeenCalled();
expect(result.assistantTexts).toEqual([
"release fixes first. please drop affected PRs, failing checks, and blockers here.",
]);
expect(result.lastAssistant?.content).toEqual([
{
type: "text",
text: "release fixes first. please drop affected PRs, failing checks, and blockers here.",
},
]);
expect(JSON.stringify(result.messagesSnapshot)).not.toContain("checking thread context");
});
it("ignores notifications for other turns", async () => {
const params = createParams();
const projector = new CodexAppServerEventProjector(params, "thread-1", "turn-1");

View File

@@ -44,6 +44,7 @@ const ZERO_USAGE: Usage = {
export class CodexAppServerEventProjector {
private readonly assistantTextByItem = new Map<string, string>();
private readonly assistantItemOrder: string[] = [];
private readonly reasoningTextByItem = new Map<string, string>();
private readonly planTextByItem = new Map<string, string>();
private readonly activeItemIds = new Set<string>();
@@ -210,9 +211,12 @@ export class CodexAppServerEventProjector {
this.assistantStarted = true;
await this.params.onAssistantMessageStart?.();
}
this.rememberAssistantItem(itemId);
const text = `${this.assistantTextByItem.get(itemId) ?? ""}${delta}`;
this.assistantTextByItem.set(itemId, text);
await this.params.onPartialReply?.({ text });
// Codex app-server can emit multiple agentMessage items per turn, including
// intermediate coordination/progress prose. Keep those deltas internal until
// turn completion chooses the last assistant item as the user-visible reply.
}
private async handleReasoningDelta(params: JsonObject): Promise<void> {
@@ -291,6 +295,7 @@ export class CodexAppServerEventProjector {
this.completedItemIds.add(itemId);
}
if (item?.type === "agentMessage" && typeof item.text === "string" && item.text) {
this.rememberAssistantItem(item.id);
this.assistantTextByItem.set(item.id, item.text);
}
if (item?.type === "plan" && typeof item.text === "string" && item.text) {
@@ -348,6 +353,7 @@ export class CodexAppServerEventProjector {
}
for (const item of turn.items ?? []) {
if (item.type === "agentMessage" && typeof item.text === "string" && item.text) {
this.rememberAssistantItem(item.id);
this.assistantTextByItem.set(item.id, item.text);
}
if (item.type === "plan" && typeof item.text === "string" && item.text) {
@@ -425,7 +431,29 @@ export class CodexAppServerEventProjector {
}
private collectAssistantTexts(): string[] {
return [...this.assistantTextByItem.values()].filter((text) => text.trim().length > 0);
const finalText = this.resolveFinalAssistantText();
return finalText ? [finalText] : [];
}
private resolveFinalAssistantText(): string | undefined {
for (let i = this.assistantItemOrder.length - 1; i >= 0; i -= 1) {
const itemId = this.assistantItemOrder[i];
if (!itemId) {
continue;
}
const text = this.assistantTextByItem.get(itemId)?.trim();
if (text) {
return text;
}
}
return undefined;
}
private rememberAssistantItem(itemId: string): void {
if (!itemId || this.assistantItemOrder.includes(itemId)) {
return;
}
this.assistantItemOrder.push(itemId);
}
private createAssistantMessage(text: string): AssistantMessage {

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/comfy-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw ComfyUI provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/copilot-proxy",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Copilot Proxy provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/deepgram-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Deepgram media-understanding provider",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/deepseek-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw DeepSeek provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/diagnostics-otel",
"version": "2026.4.10",
"version": "2026.4.11",
"description": "OpenClaw diagnostics OpenTelemetry exporter",
"type": "module",
"dependencies": {
@@ -24,10 +24,10 @@
"./index.ts"
],
"compat": {
"pluginApi": ">=2026.4.10"
"pluginApi": ">=2026.4.11"
},
"build": {
"openclawVersion": "2026.4.10"
"openclawVersion": "2026.4.11"
},
"release": {
"publishToClawHub": true,

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/diffs",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw diff viewer plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/discord",
"version": "2026.4.10",
"version": "2026.4.11",
"description": "OpenClaw Discord channel plugin",
"type": "module",
"dependencies": {
@@ -16,7 +16,7 @@
"openclaw": "workspace:*"
},
"peerDependencies": {
"openclaw": ">=2026.4.10"
"openclaw": ">=2026.4.11"
},
"peerDependenciesMeta": {
"openclaw": {
@@ -49,13 +49,13 @@
"install": {
"npmSpec": "@openclaw/discord",
"defaultChoice": "npm",
"minHostVersion": ">=2026.4.10"
"minHostVersion": ">=2026.4.11"
},
"compat": {
"pluginApi": ">=2026.4.10"
"pluginApi": ">=2026.4.11"
},
"build": {
"openclawVersion": "2026.4.10"
"openclawVersion": "2026.4.11"
},
"bundle": {
"stageRuntimeDependencies": true

View File

@@ -96,6 +96,47 @@ describe("discord doctor", () => {
).toEqual(["Moved channels.discord.streamMode → channels.discord.streaming.mode (block)."]);
});
it("moves account voice.tts.edge into providers.microsoft", () => {
const normalize = discordDoctor.normalizeCompatibilityConfig;
expect(normalize).toBeDefined();
if (!normalize) {
return;
}
const result = normalize({
cfg: {
channels: {
discord: {
accounts: {
main: {
voice: {
tts: {
edge: {
voice: "en-US-JennyNeural",
},
},
},
},
},
},
},
} as never,
});
expect(result.changes).toContain(
"Moved channels.discord.accounts.main.voice.tts.edge → channels.discord.accounts.main.voice.tts.providers.microsoft.",
);
const mainTts = result.config.channels?.discord?.accounts?.main?.voice?.tts as
| Record<string, unknown>
| undefined;
expect(mainTts?.providers).toEqual({
microsoft: {
voice: "en-US-JennyNeural",
},
});
expect(mainTts?.edge).toBeUndefined();
});
it("finds numeric id entries across discord scopes", () => {
const cfg = {
channels: {

View File

@@ -407,9 +407,7 @@ describe("DiscordVoiceManager", () => {
await manager.join({ guildId: "g1", channelId: "1001" });
const entry = (manager as unknown as { sessions: Map<string, unknown> }).sessions.get(
"g1",
) as
const entry = (manager as unknown as { sessions: Map<string, unknown> }).sessions.get("g1") as
| {
guildId: string;
channelId: string;

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/duckduckgo-plugin",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw DuckDuckGo plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/elevenlabs-speech",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw ElevenLabs speech plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/exa-plugin",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Exa plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/fal-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw fal provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/feishu",
"version": "2026.4.10",
"version": "2026.4.11",
"description": "OpenClaw Feishu/Lark channel plugin (community maintained by @m1heng)",
"type": "module",
"dependencies": {
@@ -12,7 +12,7 @@
"openclaw": "workspace:*"
},
"peerDependencies": {
"openclaw": ">=2026.4.10"
"openclaw": ">=2026.4.11"
},
"peerDependenciesMeta": {
"openclaw": {
@@ -40,13 +40,13 @@
"install": {
"npmSpec": "@openclaw/feishu",
"defaultChoice": "npm",
"minHostVersion": ">=2026.4.10"
"minHostVersion": ">=2026.4.11"
},
"compat": {
"pluginApi": ">=2026.4.10"
"pluginApi": ">=2026.4.11"
},
"build": {
"openclawVersion": "2026.4.10"
"openclawVersion": "2026.4.11"
},
"bundle": {
"stageRuntimeDependencies": true

View File

@@ -0,0 +1,160 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
const resolveFeishuRuntimeAccountMock = vi.hoisted(() => vi.fn());
const createFeishuClientMock = vi.hoisted(() => vi.fn());
const createReplyPrefixContextMock = vi.hoisted(() => vi.fn());
const createCommentTypingReactionLifecycleMock = vi.hoisted(() => vi.fn());
const deliverCommentThreadTextMock = vi.hoisted(() => vi.fn());
const createReplyDispatcherWithTypingMock = vi.hoisted(() => vi.fn());
const getFeishuRuntimeMock = vi.hoisted(() => vi.fn());
vi.mock("./accounts.js", () => ({
resolveFeishuRuntimeAccount: resolveFeishuRuntimeAccountMock,
}));
vi.mock("./client.js", () => ({
createFeishuClient: createFeishuClientMock,
}));
vi.mock("./comment-dispatcher-runtime-api.js", () => ({
createReplyPrefixContext: createReplyPrefixContextMock,
}));
vi.mock("./comment-reaction.js", () => ({
createCommentTypingReactionLifecycle: createCommentTypingReactionLifecycleMock,
}));
vi.mock("./drive.js", () => ({
deliverCommentThreadText: deliverCommentThreadTextMock,
}));
vi.mock("./runtime.js", () => ({
getFeishuRuntime: getFeishuRuntimeMock,
}));
import { createFeishuCommentReplyDispatcher } from "./comment-dispatcher.js";
describe("createFeishuCommentReplyDispatcher", () => {
beforeEach(() => {
vi.clearAllMocks();
resolveFeishuRuntimeAccountMock.mockReturnValue({
accountId: "main",
appId: "app_id",
appSecret: "app_secret",
domain: "feishu",
config: {},
});
createFeishuClientMock.mockReturnValue({});
createReplyPrefixContextMock.mockReturnValue({
responsePrefix: undefined,
responsePrefixContextProvider: undefined,
});
deliverCommentThreadTextMock.mockResolvedValue({
delivery_mode: "reply_comment",
reply_id: "reply_1",
});
createCommentTypingReactionLifecycleMock.mockReturnValue({
start: vi.fn(async () => {}),
cleanup: vi.fn(async () => {}),
});
createReplyDispatcherWithTypingMock.mockImplementation(() => ({
dispatcher: {
markComplete: vi.fn(),
waitForIdle: vi.fn(async () => {}),
},
replyOptions: {},
markDispatchIdle: vi.fn(),
markRunComplete: vi.fn(),
}));
getFeishuRuntimeMock.mockReturnValue({
channel: {
text: {
resolveTextChunkLimit: vi.fn(() => 4000),
resolveChunkMode: vi.fn(() => "line"),
chunkTextWithMode: vi.fn((text: string) => [text]),
},
reply: {
createReplyDispatcherWithTyping: createReplyDispatcherWithTypingMock,
resolveHumanDelayConfig: vi.fn(() => undefined),
},
},
});
});
it("sends final comment text without waiting for typing cleanup", async () => {
let resolveCleanup: (() => void) | undefined;
const cleanup = vi.fn(
() =>
new Promise<void>((resolve) => {
resolveCleanup = resolve;
}),
);
createCommentTypingReactionLifecycleMock.mockReturnValue({
start: vi.fn(async () => {}),
cleanup,
});
createFeishuCommentReplyDispatcher({
cfg: {} as never,
agentId: "main",
runtime: { log: vi.fn(), error: vi.fn() } as never,
accountId: "main",
fileToken: "doc_token_1",
fileType: "docx",
commentId: "comment_1",
replyId: "reply_1",
isWholeComment: false,
});
const options = createReplyDispatcherWithTypingMock.mock.calls.at(-1)?.[0];
const deliverPromise = options.deliver({ text: "hello world" }, { kind: "final" });
const status = await Promise.race([
deliverPromise.then(() => "done"),
new Promise<string>((resolve) => setTimeout(() => resolve("pending"), 0)),
]);
expect(status).toBe("done");
expect(deliverCommentThreadTextMock).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
file_token: "doc_token_1",
file_type: "docx",
comment_id: "comment_1",
content: "hello world",
is_whole_comment: false,
}),
);
expect(cleanup).not.toHaveBeenCalled();
options.onCleanup?.();
expect(cleanup).toHaveBeenCalledTimes(1);
resolveCleanup?.();
await deliverPromise;
});
it("starts the typing reaction from dispatcher onReplyStart", async () => {
const start = vi.fn(async () => {});
createCommentTypingReactionLifecycleMock.mockReturnValue({
start,
cleanup: vi.fn(async () => {}),
});
createFeishuCommentReplyDispatcher({
cfg: {} as never,
agentId: "main",
runtime: { log: vi.fn(), error: vi.fn() } as never,
accountId: "main",
fileToken: "doc_token_1",
fileType: "docx",
commentId: "comment_1",
replyId: "reply_1",
isWholeComment: false,
});
const options = createReplyDispatcherWithTypingMock.mock.calls.at(-1)?.[0];
await options.onReplyStart?.();
expect(start).toHaveBeenCalledTimes(1);
});
});

View File

@@ -7,6 +7,7 @@ import {
type ReplyPayload,
type RuntimeEnv,
} from "./comment-dispatcher-runtime-api.js";
import { createCommentTypingReactionLifecycle } from "./comment-reaction.js";
import type { CommentFileType } from "./comment-target.js";
import { deliverCommentThreadText } from "./drive.js";
import { getFeishuRuntime } from "./runtime.js";
@@ -19,6 +20,7 @@ export type CreateFeishuCommentReplyDispatcherParams = {
fileToken: string;
fileType: CommentFileType;
commentId: string;
replyId?: string;
isWholeComment?: boolean;
};
@@ -43,12 +45,23 @@ export function createFeishuCommentReplyDispatcher(
},
);
const chunkMode = core.channel.text.resolveChunkMode(params.cfg, "feishu");
const typingReaction = createCommentTypingReactionLifecycle({
cfg: params.cfg,
fileToken: params.fileToken,
fileType: params.fileType,
replyId: params.replyId,
accountId: params.accountId,
runtime: params.runtime,
});
const { dispatcher, replyOptions, markDispatchIdle } =
const { dispatcher, replyOptions, markDispatchIdle, markRunComplete } =
core.channel.reply.createReplyDispatcherWithTyping({
responsePrefix: prefixContext.responsePrefix,
responsePrefixContextProvider: prefixContext.responsePrefixContextProvider,
humanDelay: core.channel.reply.resolveHumanDelayConfig(params.cfg, params.agentId),
onReplyStart: async () => {
await typingReaction.start();
},
deliver: async (payload: ReplyPayload, info) => {
if (info.kind !== "final") {
return;
@@ -78,7 +91,17 @@ export function createFeishuCommentReplyDispatcher(
`feishu[${params.accountId ?? "default"}]: comment dispatcher failed kind=${info.kind} comment=${params.commentId}: ${String(err)}`,
);
},
onCleanup: () => {
void typingReaction.cleanup();
},
});
return { dispatcher, replyOptions, markDispatchIdle };
return {
dispatcher,
replyOptions,
markDispatchIdle,
markRunComplete,
startTypingReaction: typingReaction.start,
cleanupTypingReaction: typingReaction.cleanup,
};
}

View File

@@ -164,6 +164,9 @@ describe("handleFeishuCommentEvent", () => {
},
replyOptions: {},
markDispatchIdle: vi.fn(),
markRunComplete: vi.fn(),
startTypingReaction: vi.fn(async () => {}),
cleanupTypingReaction: vi.fn(async () => {}),
});
});
@@ -198,9 +201,15 @@ describe("handleFeishuCommentEvent", () => {
OriginatingChannel: "feishu",
OriginatingTo: "comment:docx:doc_token_1:comment_1",
MessageSid: "drive-comment:evt_1",
MessageThreadId: "reply_1",
}),
);
expect(recordInboundSession).toHaveBeenCalledTimes(1);
expect(recordInboundSession).toHaveBeenCalledWith(
expect.objectContaining({
sessionKey: "agent:main:feishu:direct:comment-doc:docx:doc_token_1",
}),
);
expect(dispatchReplyFromConfig).toHaveBeenCalledTimes(1);
});
@@ -309,8 +318,124 @@ describe("handleFeishuCommentEvent", () => {
commentId: "comment_whole",
fileToken: "doc_token_1",
fileType: "docx",
replyId: "reply_whole",
isWholeComment: true,
}),
);
});
it("always finalizes comment typing cleanup even when dispatch fails", async () => {
const dispatchReplyFromConfig = vi.fn(async () => {
throw new Error("dispatch failed");
});
const runtime = createTestRuntime({ dispatchReplyFromConfig });
setFeishuRuntime(runtime);
const markRunComplete = vi.fn();
const markDispatchIdle = vi.fn();
const cleanupTypingReaction = vi.fn(async () => {});
createFeishuCommentReplyDispatcherMock.mockReturnValue({
dispatcher: {
markComplete: vi.fn(),
waitForIdle: vi.fn(async () => {}),
},
replyOptions: {},
markDispatchIdle,
markRunComplete,
startTypingReaction: vi.fn(async () => {}),
cleanupTypingReaction,
});
await expect(
handleFeishuCommentEvent({
cfg: buildConfig(),
accountId: "default",
event: { event_id: "evt_1" },
botOpenId: "ou_bot",
runtime: {
log: vi.fn(),
error: vi.fn(),
} as never,
}),
).rejects.toThrow("dispatch failed");
expect(markRunComplete).toHaveBeenCalledTimes(1);
expect(markDispatchIdle).toHaveBeenCalledTimes(1);
expect(cleanupTypingReaction).toHaveBeenCalledTimes(1);
});
it("does not wait for comment typing cleanup before returning", async () => {
let resolveCleanup: (() => void) | undefined;
const cleanupTypingReaction = vi.fn(
() =>
new Promise<void>((resolve) => {
resolveCleanup = resolve;
}),
);
createFeishuCommentReplyDispatcherMock.mockReturnValue({
dispatcher: {
markComplete: vi.fn(),
waitForIdle: vi.fn(async () => {}),
},
replyOptions: {},
markDispatchIdle: vi.fn(),
markRunComplete: vi.fn(),
startTypingReaction: vi.fn(async () => {}),
cleanupTypingReaction,
});
const eventPromise = handleFeishuCommentEvent({
cfg: buildConfig(),
accountId: "default",
event: { event_id: "evt_1" },
botOpenId: "ou_bot",
runtime: {
log: vi.fn(),
error: vi.fn(),
} as never,
});
const status = await Promise.race([
eventPromise.then(() => "done"),
new Promise<string>((resolve) => setTimeout(() => resolve("pending"), 0)),
]);
expect(status).toBe("done");
expect(cleanupTypingReaction).toHaveBeenCalledTimes(1);
resolveCleanup?.();
await eventPromise;
});
it("does not start comment typing reaction before dispatch begins", async () => {
const startTypingReaction = vi.fn(async () => {});
createFeishuCommentReplyDispatcherMock.mockReturnValue({
dispatcher: {
markComplete: vi.fn(),
waitForIdle: vi.fn(async () => {}),
},
replyOptions: {},
markDispatchIdle: vi.fn(),
markRunComplete: vi.fn(),
startTypingReaction,
cleanupTypingReaction: vi.fn(async () => {}),
});
await handleFeishuCommentEvent({
cfg: buildConfig(),
accountId: "default",
event: { event_id: "evt_1" },
botOpenId: "ou_bot",
runtime: {
log: vi.fn(),
error: vi.fn(),
} as never,
});
expect(startTypingReaction).not.toHaveBeenCalled();
const runtime = (await import("./runtime.js")).getFeishuRuntime();
const dispatchReplyFromConfig = runtime.channel.reply.dispatchReplyFromConfig as ReturnType<
typeof vi.fn
>;
expect(dispatchReplyFromConfig).toHaveBeenCalledTimes(1);
});
});

View File

@@ -29,7 +29,8 @@ type HandleFeishuCommentEventParams = {
function buildCommentSessionKey(params: {
core: ReturnType<typeof getFeishuRuntime>;
route: ResolvedAgentRoute;
commentTarget: string;
fileType: string;
fileToken: string;
}): string {
return params.core.channel.routing.buildAgentSessionKey({
agentId: params.route.agentId,
@@ -37,7 +38,7 @@ function buildCommentSessionKey(params: {
accountId: params.route.accountId,
peer: {
kind: "direct",
id: params.commentTarget,
id: `comment-doc:${params.fileType}:${params.fileToken}`,
},
dmScope: "per-account-channel-peer",
});
@@ -172,7 +173,8 @@ export async function handleFeishuCommentEvent(
const commentSessionKey = buildCommentSessionKey({
core,
route,
commentTarget,
fileType: turn.fileType,
fileToken: turn.fileToken,
});
const bodyForAgent = `[message_id: ${turn.messageId}]\n${turn.prompt}`;
const ctxPayload = core.channel.reply.finalizeInboundContext({
@@ -193,6 +195,9 @@ export async function handleFeishuCommentEvent(
Provider: "feishu",
Surface: "feishu-comment",
MessageSid: turn.messageId,
// For Feishu comment turns, MessageThreadId carries the inbound reply_id so
// comment-aware tools can clean typing reaction before sending visible output.
MessageThreadId: turn.replyId,
Timestamp: parseTimestampMs(turn.timestamp),
WasMentioned: turn.isMentioned,
CommandAuthorized: false,
@@ -214,36 +219,41 @@ export async function handleFeishuCommentEvent(
},
});
const { dispatcher, replyOptions, markDispatchIdle } = createFeishuCommentReplyDispatcher({
cfg: effectiveCfg,
agentId: route.agentId,
runtime,
accountId: account.accountId,
fileToken: turn.fileToken,
fileType: turn.fileType,
commentId: turn.commentId,
isWholeComment: turn.isWholeComment,
});
const { dispatcher, replyOptions, markDispatchIdle, markRunComplete, cleanupTypingReaction } =
createFeishuCommentReplyDispatcher({
cfg: effectiveCfg,
agentId: route.agentId,
runtime,
accountId: account.accountId,
fileToken: turn.fileToken,
fileType: turn.fileType,
commentId: turn.commentId,
replyId: turn.replyId,
isWholeComment: turn.isWholeComment,
});
log(
`feishu[${account.accountId}]: dispatching drive comment to agent ` +
`(session=${commentSessionKey} comment=${turn.commentId} type=${turn.noticeType})`,
);
const { queuedFinal, counts } = await core.channel.reply.withReplyDispatcher({
dispatcher,
onSettled: () => {
markDispatchIdle();
},
run: () =>
core.channel.reply.dispatchReplyFromConfig({
ctx: ctxPayload,
cfg: effectiveCfg,
dispatcher,
replyOptions,
}),
});
log(
`feishu[${account.accountId}]: drive comment dispatch complete ` +
`(queuedFinal=${queuedFinal}, replies=${counts.final}, session=${commentSessionKey})`,
);
try {
log(
`feishu[${account.accountId}]: dispatching drive comment to agent ` +
`(session=${commentSessionKey} comment=${turn.commentId} type=${turn.noticeType})`,
);
const { queuedFinal, counts } = await core.channel.reply.withReplyDispatcher({
dispatcher,
run: () =>
core.channel.reply.dispatchReplyFromConfig({
ctx: ctxPayload,
cfg: effectiveCfg,
dispatcher,
replyOptions,
}),
});
log(
`feishu[${account.accountId}]: drive comment dispatch complete ` +
`(queuedFinal=${queuedFinal}, replies=${counts.final}, session=${commentSessionKey})`,
);
} finally {
markRunComplete();
markDispatchIdle();
void cleanupTypingReaction();
}
}

View File

@@ -0,0 +1,190 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { ClawdbotConfig } from "../runtime-api.js";
import {
cleanupAmbientCommentTypingReaction,
createCommentTypingReactionLifecycle,
} from "./comment-reaction.js";
const resolveFeishuRuntimeAccountMock = vi.hoisted(() => vi.fn());
const createFeishuClientMock = vi.hoisted(() => vi.fn());
vi.mock("./accounts.js", () => ({
resolveFeishuRuntimeAccount: resolveFeishuRuntimeAccountMock,
}));
vi.mock("./client.js", () => ({
createFeishuClient: createFeishuClientMock,
}));
describe("createCommentTypingReactionLifecycle", () => {
const request = vi.fn();
beforeEach(() => {
vi.clearAllMocks();
resolveFeishuRuntimeAccountMock.mockReturnValue({
accountId: "default",
configured: true,
config: {
typingIndicator: true,
},
});
createFeishuClientMock.mockReturnValue({
request,
});
request.mockResolvedValue({
code: 0,
data: {},
});
});
it("adds and removes a comment typing reaction using reply_id", async () => {
const lifecycle = createCommentTypingReactionLifecycle({
cfg: {} as ClawdbotConfig,
fileToken: "doc_token_1",
fileType: "docx",
replyId: "reply_1",
runtime: {
log: vi.fn(),
} as never,
});
await lifecycle.start();
await lifecycle.cleanup();
expect(request).toHaveBeenNthCalledWith(
1,
expect.objectContaining({
method: "POST",
url: "/open-apis/drive/v2/files/doc_token_1/comments/reaction?file_type=docx",
data: {
action: "add",
reply_id: "reply_1",
reaction_type: "Typing",
},
}),
);
expect(request).toHaveBeenNthCalledWith(
2,
expect.objectContaining({
method: "POST",
url: "/open-apis/drive/v2/files/doc_token_1/comments/reaction?file_type=docx",
data: {
action: "delete",
reply_id: "reply_1",
reaction_type: "Typing",
},
}),
);
});
it("skips requests when reply_id is missing", async () => {
const lifecycle = createCommentTypingReactionLifecycle({
cfg: {} as ClawdbotConfig,
fileToken: "doc_token_1",
fileType: "docx",
replyId: undefined,
runtime: {
log: vi.fn(),
} as never,
});
await lifecycle.start();
await lifecycle.cleanup();
expect(request).not.toHaveBeenCalled();
});
it("shares cleanup state so ambient cleanup and finally cleanup do not delete twice", async () => {
const lifecycle = createCommentTypingReactionLifecycle({
cfg: {} as ClawdbotConfig,
fileToken: "doc_token_1",
fileType: "docx",
replyId: "reply_1",
runtime: {
log: vi.fn(),
} as never,
});
await lifecycle.start();
await cleanupAmbientCommentTypingReaction({
client: { request } as never,
deliveryContext: {
channel: "feishu",
to: "comment:docx:doc_token_1:comment_1",
threadId: "reply_1",
},
});
await lifecycle.cleanup();
expect(request).toHaveBeenCalledTimes(2);
expect(request).toHaveBeenNthCalledWith(
2,
expect.objectContaining({
data: {
action: "delete",
reply_id: "reply_1",
reaction_type: "Typing",
},
}),
);
});
it("retries delete during later cleanup after an ambient delete failure", async () => {
request
.mockResolvedValueOnce({
code: 0,
data: {},
})
.mockResolvedValueOnce({
code: 5001,
msg: "temporary failure",
})
.mockResolvedValueOnce({
code: 0,
data: {},
});
const lifecycle = createCommentTypingReactionLifecycle({
cfg: {} as ClawdbotConfig,
fileToken: "doc_token_1",
fileType: "docx",
replyId: "reply_1",
runtime: {
log: vi.fn(),
} as never,
});
await lifecycle.start();
await cleanupAmbientCommentTypingReaction({
client: { request } as never,
deliveryContext: {
channel: "feishu",
to: "comment:docx:doc_token_1:comment_1",
threadId: "reply_1",
},
});
await lifecycle.cleanup();
expect(request).toHaveBeenCalledTimes(3);
expect(request).toHaveBeenNthCalledWith(
2,
expect.objectContaining({
data: {
action: "delete",
reply_id: "reply_1",
reaction_type: "Typing",
},
}),
);
expect(request).toHaveBeenNthCalledWith(
3,
expect.objectContaining({
data: {
action: "delete",
reply_id: "reply_1",
reaction_type: "Typing",
},
}),
);
});
});

View File

@@ -0,0 +1,281 @@
import type { ClawdbotConfig, RuntimeEnv } from "../runtime-api.js";
import { resolveFeishuRuntimeAccount } from "./accounts.js";
import { createFeishuClient } from "./client.js";
import { encodeQuery, isRecord, readString } from "./comment-shared.js";
import { parseFeishuCommentTarget, type CommentFileType } from "./comment-target.js";
const COMMENT_TYPING_REACTION_TYPE = "Typing";
const COMMENT_REACTION_TIMEOUT_MS = 30_000;
const commentTypingReactionState = new Map<
string,
{
active: boolean;
cleaned: boolean;
cleanupPromise?: Promise<boolean>;
}
>();
type FeishuCommentReactionClient = ReturnType<typeof createFeishuClient> & {
request(params: {
method: "POST";
url: string;
data: unknown;
timeout: number;
}): Promise<unknown>;
};
function buildCommentTypingReactionKey(params: {
fileToken: string;
fileType: CommentFileType;
replyId: string;
}): string {
return `${params.fileType}:${params.fileToken}:${params.replyId}`;
}
function ensureCommentTypingReactionState(key: string) {
const existing = commentTypingReactionState.get(key);
if (existing) {
return existing;
}
const created = {
active: false,
cleaned: false,
cleanupPromise: undefined,
};
commentTypingReactionState.set(key, created);
return created;
}
async function requestCommentTypingReactionWithClient(params: {
client: FeishuCommentReactionClient;
fileToken: string;
fileType: CommentFileType;
replyId: string;
action: "add" | "delete";
runtime?: RuntimeEnv;
logPrefix?: string;
}): Promise<boolean> {
try {
const response = (await params.client.request({
method: "POST",
url:
`/open-apis/drive/v2/files/${encodeURIComponent(params.fileToken)}/comments/reaction` +
encodeQuery({
file_type: params.fileType,
}),
data: {
action: params.action,
reply_id: params.replyId,
reaction_type: COMMENT_TYPING_REACTION_TYPE,
},
timeout: COMMENT_REACTION_TIMEOUT_MS,
})) as {
code?: number;
msg?: string;
log_id?: string;
error?: { log_id?: string };
};
if (response.code === 0) {
return true;
}
params.runtime?.log?.(
`${params.logPrefix ?? "[feishu]"}: comment typing reaction ${params.action} failed ` +
`reply=${params.replyId} file=${params.fileType}:${params.fileToken} ` +
`code=${response.code ?? "unknown"} msg=${response.msg ?? "unknown"} ` +
`log_id=${response.log_id ?? response.error?.log_id ?? "unknown"}`,
);
} catch (error) {
params.runtime?.log?.(
`${params.logPrefix ?? "[feishu]"}: comment typing reaction ${params.action} threw ` +
`reply=${params.replyId} file=${params.fileType}:${params.fileToken} ` +
`error=${formatCommentReactionFailure(error)}`,
);
}
return false;
}
function formatCommentReactionFailure(error: unknown): string {
if (!isRecord(error)) {
return typeof error === "string" ? error : JSON.stringify(error);
}
const response = isRecord(error.response) ? error.response : undefined;
const responseData = isRecord(response?.data) ? response?.data : undefined;
return JSON.stringify({
message:
typeof error.message === "string"
? error.message
: typeof error === "string"
? error
: JSON.stringify(error),
code: readString(error.code),
method: readString(isRecord(error.config) ? error.config.method : undefined),
url: readString(isRecord(error.config) ? error.config.url : undefined),
http_status: typeof response?.status === "number" ? response.status : undefined,
feishu_code:
typeof responseData?.code === "number" ? responseData.code : readString(responseData?.code),
feishu_msg: readString(responseData?.msg),
feishu_log_id:
readString(responseData?.log_id) ||
readString(isRecord(responseData?.error) ? responseData.error.log_id : undefined),
});
}
async function requestCommentTypingReaction(params: {
cfg: ClawdbotConfig;
fileToken: string;
fileType: CommentFileType;
replyId: string;
action: "add" | "delete";
accountId?: string;
runtime?: RuntimeEnv;
}): Promise<boolean> {
const account = resolveFeishuRuntimeAccount({ cfg: params.cfg, accountId: params.accountId });
if (!account.configured || !(account.config.typingIndicator ?? true)) {
return false;
}
const client = createFeishuClient(account) as FeishuCommentReactionClient;
return requestCommentTypingReactionWithClient({
client,
fileToken: params.fileToken,
fileType: params.fileType,
replyId: params.replyId,
action: params.action,
runtime: params.runtime,
logPrefix: `feishu[${account.accountId}]`,
});
}
async function cleanupCommentTypingReactionByKey(params: {
key: string;
performDelete: () => Promise<boolean>;
}): Promise<boolean> {
const state = ensureCommentTypingReactionState(params.key);
if (state.cleaned) {
return false;
}
if (state.cleanupPromise) {
return await state.cleanupPromise;
}
const cleanupPromise = (async (): Promise<boolean> => {
if (!state.active) {
state.cleaned = true;
return false;
}
const deleted = await params.performDelete();
if (deleted) {
state.cleaned = true;
state.active = false;
}
return deleted;
})();
state.cleanupPromise = cleanupPromise;
try {
return await cleanupPromise;
} finally {
state.cleanupPromise = undefined;
if (state.cleaned) {
state.active = false;
commentTypingReactionState.delete(params.key);
}
}
}
export async function cleanupAmbientCommentTypingReaction(params: {
client: FeishuCommentReactionClient;
deliveryContext?: {
channel?: string;
to?: string;
threadId?: string | number;
};
runtime?: RuntimeEnv;
}): Promise<boolean> {
const deliveryContext = params.deliveryContext;
if (
deliveryContext?.channel &&
deliveryContext.channel !== "feishu" &&
deliveryContext.channel !== "feishu-comment"
) {
return false;
}
const target = parseFeishuCommentTarget(deliveryContext?.to);
const replyId =
typeof deliveryContext?.threadId === "string" || typeof deliveryContext?.threadId === "number"
? String(deliveryContext.threadId).trim()
: "";
if (!target || !replyId) {
return false;
}
const key = buildCommentTypingReactionKey({
fileToken: target.fileToken,
fileType: target.fileType,
replyId,
});
return cleanupCommentTypingReactionByKey({
key,
performDelete: () =>
requestCommentTypingReactionWithClient({
client: params.client,
fileToken: target.fileToken,
fileType: target.fileType,
replyId,
action: "delete",
runtime: params.runtime,
logPrefix: "[feishu]",
}),
});
}
export function createCommentTypingReactionLifecycle(params: {
cfg: ClawdbotConfig;
fileToken: string;
fileType: CommentFileType;
replyId?: string;
accountId?: string;
runtime?: RuntimeEnv;
}) {
const key = params.replyId?.trim()
? buildCommentTypingReactionKey({
fileToken: params.fileToken,
fileType: params.fileType,
replyId: params.replyId.trim(),
})
: undefined;
const state = key ? ensureCommentTypingReactionState(key) : undefined;
return {
start: async (): Promise<void> => {
const replyId = params.replyId?.trim();
if (!state || state.cleaned || state.active || !replyId) {
return;
}
state.active = await requestCommentTypingReaction({
cfg: params.cfg,
fileToken: params.fileToken,
fileType: params.fileType,
replyId,
action: "add",
accountId: params.accountId,
runtime: params.runtime,
});
},
cleanup: async (): Promise<void> => {
const replyId = params.replyId?.trim();
if (!key || !replyId) {
return;
}
await cleanupCommentTypingReactionByKey({
key,
performDelete: () =>
requestCommentTypingReaction({
cfg: params.cfg,
fileToken: params.fileToken,
fileType: params.fileType,
replyId,
action: "delete",
accountId: params.accountId,
runtime: params.runtime,
}),
});
},
};
}

View File

@@ -0,0 +1,182 @@
import { describe, expect, it } from "vitest";
import {
parseCommentContentElements,
resolveCommentLinkedDocumentFromUrl,
} from "./comment-shared.js";
const VALID_TOKEN_22 = "ABCDEFGHIJKLMNOPQRSTUV";
const VALID_TOKEN_27 = "ZsJfdxrBFo0RwuxteOLc1Ekvneb";
describe("resolveCommentLinkedDocumentFromUrl", () => {
it.each([
{
label: "doc",
url: `https://example.test/doc/${VALID_TOKEN_22}`,
expectedKind: "doc",
expectedResolvedType: "doc",
expectedToken: VALID_TOKEN_22,
},
{
label: "docs",
url: `https://example.test/docs/${VALID_TOKEN_22}`,
expectedKind: "doc",
expectedResolvedType: "doc",
expectedToken: VALID_TOKEN_22,
},
{
label: "space/doc",
url: `https://example.test/space/doc/${VALID_TOKEN_22}`,
expectedKind: "doc",
expectedResolvedType: "doc",
expectedToken: VALID_TOKEN_22,
},
{
label: "sheet",
url: `https://example.test/sheet/${VALID_TOKEN_22}`,
expectedKind: "sheet",
expectedResolvedType: "sheet",
expectedToken: VALID_TOKEN_22,
},
{
label: "sheets",
url: `https://example.test/sheets/${VALID_TOKEN_22}`,
expectedKind: "sheet",
expectedResolvedType: "sheet",
expectedToken: VALID_TOKEN_22,
},
{
label: "space/sheet",
url: `https://example.test/space/sheet/${VALID_TOKEN_22}`,
expectedKind: "sheet",
expectedResolvedType: "sheet",
expectedToken: VALID_TOKEN_22,
},
{
label: "docx with hash",
url: `https://bytedance.larkoffice.com/docx/${VALID_TOKEN_27}#share-Huggdiqveo5N7NxyA01ck4gLnHh`,
expectedKind: "docx",
expectedResolvedType: "docx",
expectedToken: VALID_TOKEN_27,
},
{
label: "mindnote",
url: `https://example.test/mindnote/${VALID_TOKEN_22}`,
expectedKind: "mindnote",
expectedResolvedType: "mindnote",
expectedToken: VALID_TOKEN_22,
},
{
label: "mindnotes",
url: `https://example.test/mindnotes/${VALID_TOKEN_22}`,
expectedKind: "mindnote",
expectedResolvedType: "mindnote",
expectedToken: VALID_TOKEN_22,
},
{
label: "space/mindnote",
url: `https://example.test/space/mindnote/${VALID_TOKEN_22}`,
expectedKind: "mindnote",
expectedResolvedType: "mindnote",
expectedToken: VALID_TOKEN_22,
},
{
label: "bitable",
url: `https://example.test/bitable/${VALID_TOKEN_22}?table=tbl_123`,
expectedKind: "bitable",
expectedResolvedType: "bitable",
expectedToken: VALID_TOKEN_22,
},
{
label: "base",
url: `https://example.test/base/${VALID_TOKEN_22}`,
expectedKind: "base",
expectedResolvedType: "base",
expectedToken: VALID_TOKEN_22,
},
{
label: "space/bitable",
url: `https://example.test/space/bitable/${VALID_TOKEN_22}`,
expectedKind: "bitable",
expectedResolvedType: "bitable",
expectedToken: VALID_TOKEN_22,
},
{
label: "file",
url: `https://example.test/file/${VALID_TOKEN_22}`,
expectedKind: "file",
expectedResolvedType: "file",
expectedToken: VALID_TOKEN_22,
},
{
label: "space/file",
url: `https://example.test/space/file/${VALID_TOKEN_22}`,
expectedKind: "file",
expectedResolvedType: "file",
expectedToken: VALID_TOKEN_22,
},
{
label: "wiki",
url: `https://example.test/wiki/${VALID_TOKEN_22}`,
expectedKind: "wiki",
expectedResolvedType: undefined,
expectedToken: VALID_TOKEN_22,
},
{
label: "space/wiki",
url: `https://example.test/space/wiki/${VALID_TOKEN_22}`,
expectedKind: "wiki",
expectedResolvedType: undefined,
expectedToken: VALID_TOKEN_22,
},
])("$label", ({ url, expectedKind, expectedResolvedType, expectedToken }) => {
const linked = resolveCommentLinkedDocumentFromUrl({ rawUrl: url });
expect(linked.urlKind).toBe(expectedKind);
expect(linked.resolvedObjType).toBe(expectedResolvedType);
expect(linked.resolvedObjToken ?? linked.wikiNodeToken).toBe(expectedToken);
});
it("does not resolve doc-like paths with short tokens", () => {
expect(
resolveCommentLinkedDocumentFromUrl({
rawUrl: "https://www.baidu.com/docx/guide",
}),
).toEqual({
rawUrl: "https://www.baidu.com/docx/guide",
urlKind: "unknown",
});
});
});
describe("parseCommentContentElements", () => {
it("keeps raw external urls in text but excludes unresolved links from structured references", () => {
const parsed = parseCommentContentElements({
elements: [
{
type: "docs_link",
docs_link: { url: `https://bytedance.larkoffice.com/docx/${VALID_TOKEN_27}` },
},
{
type: "text_run",
text_run: { text: " 和 " },
},
{
type: "docs_link",
docs_link: { url: "https://www.baidu.com/docx/guide" },
},
],
});
expect(parsed.plainText).toBe(
`https://bytedance.larkoffice.com/docx/${VALID_TOKEN_27} 和 https://www.baidu.com/docx/guide`,
);
expect(parsed.linkedDocuments).toEqual([
expect.objectContaining({
rawUrl: `https://bytedance.larkoffice.com/docx/${VALID_TOKEN_27}`,
urlKind: "docx",
resolvedObjType: "docx",
resolvedObjToken: VALID_TOKEN_27,
}),
]);
});
});

View File

@@ -5,6 +5,7 @@ import {
normalizeOptionalString,
readStringValue,
} from "openclaw/plugin-sdk/text-runtime";
import { FEISHU_COMMENT_FILE_TYPES, type CommentFileType } from "./comment-target.js";
export function encodeQuery(params: Record<string, string | undefined>): string {
const query = new URLSearchParams();
@@ -28,51 +29,309 @@ export const asRecord = asOptionalRecord;
export const hasNonEmptyString = sharedHasNonEmptyString;
export function extractCommentElementText(element: unknown): string | undefined {
if (!isRecord(element)) {
return undefined;
}
const type = normalizeString(element.type);
if (type === "text_run" && isRecord(element.text_run)) {
return normalizeString(element.text_run.content) || normalizeString(element.text_run.text);
}
if (type === "mention") {
const mention = isRecord(element.mention) ? element.mention : undefined;
const mentionName =
normalizeString(mention?.name) ||
normalizeString(mention?.display_name) ||
normalizeString(element.name);
return mentionName ? `@${mentionName}` : "@mention";
}
if (type === "docs_link") {
const docsLink = isRecord(element.docs_link) ? element.docs_link : undefined;
return (
normalizeString(docsLink?.text) ||
normalizeString(docsLink?.url) ||
normalizeString(element.text) ||
normalizeString(element.url) ||
undefined
);
}
export type ParsedCommentDocumentRef = {
fileType?: CommentFileType;
fileToken?: string;
};
export type ParsedCommentMention = {
userId: string;
displayText: string;
isBotMention: boolean;
};
export type ParsedCommentLinkedDocumentKind =
| CommentFileType
| "wiki"
| "mindnote"
| "bitable"
| "base"
| "unknown";
export type ParsedCommentResolvedDocumentType = Exclude<
ParsedCommentLinkedDocumentKind,
"wiki" | "unknown"
>;
export type ParsedCommentLinkedDocument = {
rawUrl: string;
urlKind: ParsedCommentLinkedDocumentKind;
wikiNodeToken?: string;
resolvedObjType?: ParsedCommentResolvedDocumentType;
resolvedObjToken?: string;
isCurrentDocument?: boolean;
};
export type ParsedCommentContent = {
plainText?: string;
semanticText?: string;
mentions: ParsedCommentMention[];
linkedDocuments: ParsedCommentLinkedDocument[];
botMentioned: boolean;
};
function readDocsLinkUrl(element: Record<string, unknown>): string | undefined {
const docsLink = isRecord(element.docs_link) ? element.docs_link : undefined;
return (
normalizeString(element.text) ||
normalizeString(element.content) ||
normalizeString(element.name) ||
normalizeString(docsLink?.url) ||
normalizeString(docsLink?.link) ||
normalizeString(element.url) ||
normalizeString(element.link) ||
undefined
);
}
function readMentionUserId(element: Record<string, unknown>): string | undefined {
const mention = isRecord(element.mention) ? element.mention : undefined;
const person = isRecord(element.person) ? element.person : undefined;
return (
normalizeString(person?.user_id) ||
normalizeString(mention?.user_id) ||
normalizeString(mention?.open_id) ||
normalizeString(element.mention_user) ||
normalizeString(element.user_id) ||
undefined
);
}
function readMentionDisplayText(element: Record<string, unknown>, userId: string): string {
const mention = isRecord(element.mention) ? element.mention : undefined;
const mentionName =
normalizeString(mention?.name) ||
normalizeString(mention?.display_name) ||
normalizeString(element.name);
return mentionName ? `@${mentionName}` : `@${userId}`;
}
function normalizeCommentText(parts: string[]): string | undefined {
const text = parts.join("").trim();
return text || undefined;
}
function normalizeCommentSemanticText(parts: string[]): string | undefined {
const text = parts.join("").replace(/\s+/g, " ").trim();
return text || undefined;
}
function readElementTextPreservingWhitespace(element: Record<string, unknown>): string | undefined {
return (
(isRecord(element.text_run)
? readString(element.text_run.content) || readString(element.text_run.text)
: undefined) ||
readString(element.text) ||
readString(element.content) ||
readString(element.name) ||
undefined
);
}
const FEISHU_LINK_TOKEN_MIN_LENGTH = 22;
const FEISHU_LINK_TOKEN_MAX_LENGTH = 28;
const COMMENT_LINK_KIND_ALIASES = new Map<string, ParsedCommentResolvedDocumentType | "wiki">([
["doc", "doc"],
["docs", "doc"],
["docx", "docx"],
["sheet", "sheet"],
["sheets", "sheet"],
["slide", "slides"],
["slides", "slides"],
["file", "file"],
["files", "file"],
["wiki", "wiki"],
["mindnote", "mindnote"],
["mindnotes", "mindnote"],
["bitable", "bitable"],
["base", "base"],
]);
function isCommentFileType(
value: ParsedCommentResolvedDocumentType | "wiki" | undefined,
): value is CommentFileType {
return (
typeof value === "string" && (FEISHU_COMMENT_FILE_TYPES as readonly string[]).includes(value)
);
}
function isReasonableFeishuLinkToken(token: string | undefined): token is string {
return (
typeof token === "string" &&
token.length >= FEISHU_LINK_TOKEN_MIN_LENGTH &&
token.length <= FEISHU_LINK_TOKEN_MAX_LENGTH
);
}
function parseCommentLinkedDocumentPath(pathname: string): {
urlKind: ParsedCommentResolvedDocumentType | "wiki";
token: string;
} | null {
const segments = pathname
.split("/")
.map((segment) => segment.trim())
.filter(Boolean);
const offset = segments[0]?.toLowerCase() === "space" ? 1 : 0;
const kind = COMMENT_LINK_KIND_ALIASES.get(segments[offset]?.toLowerCase() ?? "");
const token = normalizeString(segments[offset + 1]);
if (!kind || !isReasonableFeishuLinkToken(token)) {
return null;
}
return { urlKind: kind, token };
}
function hasResolvedLinkedDocumentReference(link: ParsedCommentLinkedDocument): boolean {
return (
link.urlKind !== "unknown" && (Boolean(link.resolvedObjToken) || Boolean(link.wikiNodeToken))
);
}
export function resolveCommentLinkedDocumentFromUrl(params: {
rawUrl: string;
currentDocument?: ParsedCommentDocumentRef;
}): ParsedCommentLinkedDocument {
const link: ParsedCommentLinkedDocument = {
rawUrl: params.rawUrl,
urlKind: "unknown",
};
try {
const parsed = new URL(params.rawUrl);
const parsedPath = parseCommentLinkedDocumentPath(parsed.pathname);
if (!parsedPath) {
return link;
}
const { urlKind, token } = parsedPath;
link.urlKind = urlKind;
if (urlKind === "wiki") {
link.urlKind = "wiki";
link.wikiNodeToken = token;
} else {
link.resolvedObjType = urlKind;
link.resolvedObjToken = token;
}
if (
link.resolvedObjType &&
link.resolvedObjToken &&
isCommentFileType(link.resolvedObjType) &&
params.currentDocument?.fileType === link.resolvedObjType &&
params.currentDocument.fileToken === link.resolvedObjToken
) {
link.isCurrentDocument = true;
} else if (
link.resolvedObjType &&
link.resolvedObjToken &&
isCommentFileType(link.resolvedObjType)
) {
link.isCurrentDocument = false;
}
} catch {
return link;
}
return link;
}
export function parseCommentContentElements(params: {
elements?: unknown[];
botOpenIds?: Iterable<string | undefined>;
currentDocument?: ParsedCommentDocumentRef;
}): ParsedCommentContent {
const elements = Array.isArray(params.elements) ? params.elements : [];
const plainTextParts: string[] = [];
const semanticTextParts: string[] = [];
const mentions: ParsedCommentMention[] = [];
const linkedDocuments: ParsedCommentLinkedDocument[] = [];
const botIds = new Set(
Array.from(params.botOpenIds ?? [])
.map((value) => normalizeString(value))
.filter((value): value is string => Boolean(value)),
);
const linkedDocumentKeys = new Set<string>();
let botMentioned = false;
for (const rawElement of elements) {
if (!isRecord(rawElement)) {
continue;
}
const element = rawElement;
const type = normalizeString(element.type);
const text =
(type === "text_run" ? readElementTextPreservingWhitespace(element) : undefined) ||
(type === "text" ? readElementTextPreservingWhitespace(element) : undefined) ||
(type === "docs_link" || type === "link" ? readDocsLinkUrl(element) : undefined) ||
(type === "mention" || type === "mention_user" || type === "person"
? (() => {
const userId = readMentionUserId(element);
return userId ? readMentionDisplayText(element, userId) : undefined;
})()
: undefined) ||
readElementTextPreservingWhitespace(element) ||
undefined;
if (type === "mention" || type === "mention_user" || type === "person") {
const userId = readMentionUserId(element);
if (userId) {
const displayText = readMentionDisplayText(element, userId);
const isBotMention = botIds.has(userId);
mentions.push({ userId, displayText, isBotMention });
plainTextParts.push(displayText);
if (!isBotMention) {
semanticTextParts.push(displayText);
} else {
botMentioned = true;
}
continue;
}
}
if (type === "docs_link" || type === "link") {
const rawUrl = readDocsLinkUrl(element);
if (rawUrl) {
plainTextParts.push(rawUrl);
semanticTextParts.push(rawUrl);
const linkedDocument = resolveCommentLinkedDocumentFromUrl({
rawUrl,
currentDocument: params.currentDocument,
});
if (hasResolvedLinkedDocumentReference(linkedDocument)) {
const key = [
linkedDocument.rawUrl,
linkedDocument.urlKind,
linkedDocument.resolvedObjType,
linkedDocument.resolvedObjToken,
linkedDocument.wikiNodeToken,
].join(":");
if (!linkedDocumentKeys.has(key)) {
linkedDocumentKeys.add(key);
linkedDocuments.push(linkedDocument);
}
}
continue;
}
}
if (text) {
plainTextParts.push(text);
semanticTextParts.push(text);
}
}
return {
plainText: normalizeCommentText(plainTextParts),
semanticText: normalizeCommentSemanticText(semanticTextParts),
mentions,
linkedDocuments,
botMentioned,
};
}
export function extractCommentElementText(element: unknown): string | undefined {
return parseCommentContentElements({ elements: [element] }).plainText;
}
export function extractReplyText(
reply: { content?: { elements?: unknown[] } } | undefined,
): string | undefined {
if (!reply || !isRecord(reply.content)) {
return undefined;
}
const elements = Array.isArray(reply.content.elements) ? reply.content.elements : [];
const text = elements
.map(extractCommentElementText)
.filter((part): part is string => Boolean(part && part.trim()))
.join("")
.trim();
return text || undefined;
return parseCommentContentElements({
elements: Array.isArray(reply.content.elements) ? reply.content.elements : [],
}).plainText;
}

View File

@@ -4,12 +4,17 @@ import type { OpenClawPluginApi, PluginRuntime } from "../runtime-api.js";
const createFeishuToolClientMock = vi.hoisted(() => vi.fn());
const resolveAnyEnabledFeishuToolsConfigMock = vi.hoisted(() => vi.fn());
const cleanupAmbientCommentTypingReactionMock = vi.hoisted(() => vi.fn(async () => false));
vi.mock("./tool-account.js", () => ({
createFeishuToolClient: createFeishuToolClientMock,
resolveAnyEnabledFeishuToolsConfig: resolveAnyEnabledFeishuToolsConfigMock,
}));
vi.mock("./comment-reaction.js", () => ({
cleanupAmbientCommentTypingReaction: cleanupAmbientCommentTypingReactionMock,
}));
let registerFeishuDriveTools: typeof import("./drive.js").registerFeishuDriveTools;
function createFeishuToolRuntime(): PluginRuntime {
@@ -51,6 +56,7 @@ describe("registerFeishuDriveTools", () => {
createFeishuToolClientMock.mockReturnValue({
request: requestMock,
});
cleanupAmbientCommentTypingReactionMock.mockResolvedValue(false);
});
it("registers feishu_drive and handles comment actions", async () => {
@@ -491,7 +497,7 @@ describe("registerFeishuDriveTools", () => {
);
});
it("defaults reply_comment target fields from the ambient Feishu comment delivery context", async () => {
it("does not wait for ambient typing cleanup before reply_comment sends visible output", async () => {
const registerTool = vi.fn();
registerFeishuDriveTools(
createDriveToolApi({
@@ -515,6 +521,7 @@ describe("registerFeishuDriveTools", () => {
deliveryContext: {
channel: "feishu",
to: "comment:docx:doc_1:c1",
threadId: "reply_ambient_1",
},
});
@@ -530,11 +537,24 @@ describe("registerFeishuDriveTools", () => {
data: { reply_id: "r6" },
});
const replyCommentResult = await tool.execute("call-ambient", {
let resolveCleanup: ((value: boolean) => void) | undefined;
cleanupAmbientCommentTypingReactionMock.mockImplementationOnce(
() =>
new Promise<boolean>((resolve) => {
resolveCleanup = resolve;
}),
);
const replyCommentPromise = tool.execute("call-ambient", {
action: "reply_comment",
content: "ambient success",
});
const status = await Promise.race([
replyCommentPromise.then(() => "done"),
new Promise<string>((resolve) => setTimeout(() => resolve("pending"), 0)),
]);
expect(status).toBe("done");
expect(requestMock).toHaveBeenNthCalledWith(
1,
expect.objectContaining({
@@ -565,9 +585,97 @@ describe("registerFeishuDriveTools", () => {
},
}),
);
expect(cleanupAmbientCommentTypingReactionMock).toHaveBeenCalledWith({
client: expect.anything(),
deliveryContext: {
channel: "feishu",
to: "comment:docx:doc_1:c1",
threadId: "reply_ambient_1",
},
});
const replyCommentResult = await replyCommentPromise;
expect(replyCommentResult.details).toEqual(
expect.objectContaining({ success: true, reply_id: "r6" }),
);
resolveCleanup?.(false);
});
it("does not wait for ambient typing cleanup before add_comment sends visible output", async () => {
const registerTool = vi.fn();
registerFeishuDriveTools(
createDriveToolApi({
config: {
channels: {
feishu: {
enabled: true,
appId: "app_id",
appSecret: "app_secret", // pragma: allowlist secret
tools: { drive: true },
},
},
},
registerTool,
}),
);
const toolFactory = registerTool.mock.calls[0]?.[0];
const tool = toolFactory?.({
agentAccountId: undefined,
deliveryContext: {
channel: "feishu",
to: "comment:docx:doc_1:c1",
threadId: "reply_ambient_1",
},
});
requestMock.mockResolvedValueOnce({
code: 0,
data: { comment_id: "c_add" },
});
let resolveCleanup: ((value: boolean) => void) | undefined;
cleanupAmbientCommentTypingReactionMock.mockImplementationOnce(
() =>
new Promise<boolean>((resolve) => {
resolveCleanup = resolve;
}),
);
const addCommentPromise = tool.execute("call-add-ambient", {
action: "add_comment",
content: "ambient top-level comment",
});
const status = await Promise.race([
addCommentPromise.then(() => "done"),
new Promise<string>((resolve) => setTimeout(() => resolve("pending"), 0)),
]);
expect(status).toBe("done");
expect(requestMock).toHaveBeenCalledWith(
expect.objectContaining({
method: "POST",
url: "/open-apis/drive/v1/files/doc_1/new_comments",
data: {
file_type: "docx",
reply_elements: [{ type: "text", text: "ambient top-level comment" }],
},
}),
);
expect(cleanupAmbientCommentTypingReactionMock).toHaveBeenCalledWith({
client: expect.anything(),
deliveryContext: {
channel: "feishu",
to: "comment:docx:doc_1:c1",
threadId: "reply_ambient_1",
},
});
const addCommentResult = await addCommentPromise;
expect(addCommentResult.details).toEqual(
expect.objectContaining({ success: true, comment_id: "c_add" }),
);
resolveCleanup?.(false);
});
it("does not inherit non-doc ambient file types for add_comment", async () => {

View File

@@ -2,6 +2,7 @@ import type * as Lark from "@larksuiteoapi/node-sdk";
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
import type { OpenClawPluginApi } from "../runtime-api.js";
import { listEnabledFeishuAccounts } from "./accounts.js";
import { cleanupAmbientCommentTypingReaction } from "./comment-reaction.js";
import { encodeQuery, extractReplyText, isRecord, readString } from "./comment-shared.js";
import { parseFeishuCommentTarget, type CommentFileType } from "./comment-target.js";
import { FeishuDriveSchema, type FeishuDriveParams } from "./drive-schema.js";
@@ -104,6 +105,7 @@ type FeishuDriveToolContext = {
deliveryContext?: {
channel?: string;
to?: string;
threadId?: string | number;
};
};
@@ -808,14 +810,28 @@ export function registerFeishuDriveTools(api: OpenClawPluginApi) {
}
case "add_comment": {
const resolved = applyAddCommentDefaults(applyAddCommentAmbientDefaults(p, ctx));
return jsonToolResult(await addComment(client, resolved));
try {
return jsonToolResult(await addComment(client, resolved));
} finally {
void cleanupAmbientCommentTypingReaction({
client: getDriveInternalClient(client),
deliveryContext: ctx.deliveryContext,
});
}
}
case "reply_comment": {
const resolved = applyCommentFileTypeDefault(
applyAmbientCommentDefaults(p, ctx),
"reply_comment",
);
return jsonToolResult(await deliverCommentThreadText(client, resolved));
try {
return jsonToolResult(await deliverCommentThreadText(client, resolved));
} finally {
void cleanupAmbientCommentTypingReaction({
client: getDriveInternalClient(client),
deliveryContext: ctx.deliveryContext,
});
}
}
default:
return unknownToolActionResult((p as { action?: unknown }).action);

View File

@@ -292,6 +292,16 @@ function parseFeishuCardActionEventPayload(value: unknown): FeishuCardActionEven
};
}
function buildCommentNoticeQueueKey(event: {
notice_meta?: {
file_type?: string;
file_token?: string;
};
}): string {
const fileType = event.notice_meta?.file_type?.trim() || "unknown";
const fileToken = event.notice_meta?.file_token?.trim() || "unknown";
return `comment-doc:${fileType}:${fileToken}`;
}
function mergeFeishuDebounceMentions(
entries: FeishuMessageEvent[],
): FeishuMessageEvent["message"]["mentions"] | undefined {
@@ -619,12 +629,14 @@ function registerEventHandlers(
`mentioned=${event.is_mentioned === true ? "yes" : "no"}`,
);
try {
await handleFeishuCommentEvent({
cfg,
accountId,
event,
botOpenId: botOpenIds.get(accountId),
runtime,
await enqueue(buildCommentNoticeQueueKey(event), async () => {
await handleFeishuCommentEvent({
cfg,
accountId,
event,
botOpenId: botOpenIds.get(accountId),
runtime,
});
});
if (syntheticMessageId) {
await recordProcessedFeishuMessage(syntheticMessageId, accountId, log);

View File

@@ -23,7 +23,8 @@ const monitorWebhookMock = vi.hoisted(() => vi.fn(async () => {}));
const createFeishuThreadBindingManagerMock = vi.hoisted(() => vi.fn(() => ({ stop: vi.fn() })));
let handlers: Record<string, (data: unknown) => Promise<void>> = {};
const TEST_DOC_TOKEN = "doxxxxxxx";
const TEST_DOC_TOKEN = "ZsJfdxrBFo0RwuxteOLc1Ekvneb";
const TEST_WIKI_TOKEN = "OtYpd5pKOoMeQzxrzkocv9KIn4H";
vi.mock("./client.js", () => ({
createEventDispatcher: createEventDispatcherMock,
@@ -287,19 +288,127 @@ describe("resolveDriveCommentEventTurn", () => {
expect(turn?.messageId).toBe("drive-comment:10d9d60b990db39f96a4c2fd357fb877");
expect(turn?.fileType).toBe("docx");
expect(turn?.fileToken).toBe(TEST_DOC_TOKEN);
expect(turn?.prompt).toContain('The user added a comment in "Comment event handling request".');
expect(turn?.prompt).toContain(
'The user added a comment in "Comment event handling request": Also send it to the agent after receiving the comment event',
'Current user comment text: "Also send it to the agent after receiving the comment event"',
);
expect(turn?.prompt).toContain(
"This is a Feishu document comment-thread event, not a Feishu IM conversation.",
);
expect(turn?.prompt).toContain("Prefer plain text suitable for a comment thread.");
expect(turn?.prompt).toContain("Do not include internal reasoning");
expect(turn?.prompt).toContain("Do not narrate your plan or execution process");
expect(turn?.prompt).toContain("reply only with the user-facing result itself");
expect(turn?.prompt).toContain("Current comment card timeline (primary context");
expect(turn?.prompt).toContain("This is a Feishu document comment thread.");
expect(turn?.prompt).toContain("It is not a Feishu IM chat.");
expect(turn?.prompt).toContain("Use plain text only.");
expect(turn?.prompt).toContain("Do not show reasoning.");
expect(turn?.prompt).toContain("Do not describe your plan.");
expect(turn?.prompt).toContain("Output only the final user-facing reply.");
expect(turn?.prompt).toContain("comment_id: 7623358762119646411");
expect(turn?.prompt).toContain("reply_id: 7623358762136374451");
expect(turn?.prompt).toContain("The system will automatically reply with your final answer");
expect(turn?.prompt).toContain(
"Your final text reply will be posted to the current comment thread automatically.",
);
});
it("parses bot mentions plus current and referenced document links from comment content", async () => {
const wikiGetNode = vi.fn(async () => ({
code: 0,
data: {
node: {
obj_type: "docx",
obj_token: "doc_ref_1",
},
},
}));
const client = {
request: vi.fn(async (request: { method: "GET" | "POST"; url: string; data: unknown }) => {
if (request.url === "/open-apis/drive/v1/metas/batch_query") {
return {
code: 0,
data: {
metas: [
{
doc_token: TEST_DOC_TOKEN,
title: "Comment event handling request",
url: `https://www.larksuite.com/docx/${TEST_DOC_TOKEN}`,
},
],
},
};
}
if (request.url.includes("/comments/batch_query")) {
return {
code: 0,
data: {
items: [
{
comment_id: "7623358762119646411",
is_whole: false,
reply_list: {
replies: [
{
reply_id: "7623358762136374451",
user_id: "ou_509d4d7ace4a9addec2312676ffcba9b",
content: {
elements: [
{ type: "text_run", text_run: { text: "请 " } },
{ type: "person", person: { user_id: "ou_bot" } },
{ type: "text_run", text_run: { text: " 总结下 " } },
{
type: "docs_link",
docs_link: {
url: `https://www.larksuite.com/docx/${TEST_DOC_TOKEN}`,
},
},
{ type: "text_run", text_run: { text: " 和 " } },
{
type: "docs_link",
docs_link: {
url: `https://www.larksuite.com/wiki/${TEST_WIKI_TOKEN}`,
},
},
],
},
},
],
},
},
],
},
};
}
throw new Error(`unexpected request: ${request.method} ${request.url}`);
}),
wiki: {
space: {
getNode: wikiGetNode,
},
},
};
const turn = await resolveDriveCommentEventTurn({
cfg: buildMonitorConfig(),
accountId: "default",
event: makeDriveCommentEvent(),
botOpenId: "ou_bot",
createClient: () => client as never,
});
expect(turn?.targetReplyText).toBe(
`请 总结下 https://www.larksuite.com/docx/${TEST_DOC_TOKEN} 和 https://www.larksuite.com/wiki/${TEST_WIKI_TOKEN}`,
);
expect(turn?.prompt).toContain("Bot routing mention detected in the current user comment.");
expect(turn?.prompt).toContain("Referenced documents from current user comment:");
expect(turn?.prompt).toContain(
`raw_url=https://www.larksuite.com/docx/${TEST_DOC_TOKEN} url_kind=docx`,
);
expect(turn?.prompt).toContain("same_as_current_document=yes");
expect(turn?.prompt).toContain(
`raw_url=https://www.larksuite.com/wiki/${TEST_WIKI_TOKEN} url_kind=wiki ` +
`wiki_node_token=${TEST_WIKI_TOKEN} resolved_type=docx ` +
"resolved_token=doc_ref_1 same_as_current_document=no",
);
expect(wikiGetNode).toHaveBeenCalledWith({
params: {
token: TEST_WIKI_TOKEN,
},
});
});
it("preserves whole-document comment metadata for downstream delivery mode selection", async () => {
@@ -321,6 +430,277 @@ describe("resolveDriveCommentEventTurn", () => {
expect(turn?.prompt).toContain("Whole-document comments do not support direct replies.");
});
it("builds a whole-comment timeline and highlights the nearest bot-authored follow-up", async () => {
const client = {
request: vi.fn(async (request: { method: "GET" | "POST"; url: string; data: unknown }) => {
if (request.url === "/open-apis/drive/v1/metas/batch_query") {
return {
code: 0,
data: {
metas: [
{
doc_token: TEST_DOC_TOKEN,
title: "Comment event handling request",
url: `https://www.larksuite.com/docx/${TEST_DOC_TOKEN}`,
},
],
},
};
}
if (request.url.includes("/comments/batch_query")) {
return {
code: 0,
data: {
items: [
{
comment_id: "7623358762119646411",
is_whole: true,
reply_list: {
replies: [
{
reply_id: "7623358762136374451",
user_id: "ou_509d4d7ace4a9addec2312676ffcba9b",
create_time: 1775531531,
content: {
elements: [
{
type: "text_run",
text_run: {
text: "请帮我总结这个文档",
},
},
],
},
},
],
},
},
],
},
};
}
if (request.url.includes("/comments?file_type=docx&is_whole=true")) {
return {
code: 0,
data: {
has_more: false,
items: [
{
comment_id: "7623358762119646411",
create_time: 1775531531,
user_id: "ou_509d4d7ace4a9addec2312676ffcba9b",
is_whole: true,
reply_list: {
replies: [
{
reply_id: "reply_a",
user_id: "ou_509d4d7ace4a9addec2312676ffcba9b",
create_time: 1775531531,
content: {
elements: [
{
type: "text_run",
text_run: {
text: "请帮我总结这个文档",
},
},
],
},
},
],
},
},
{
comment_id: "comment_bot_followup",
create_time: 1775531540,
user_id: "ou_bot",
is_whole: true,
reply_list: {
replies: [
{
reply_id: "reply_b",
user_id: "ou_bot",
create_time: 1775531540,
content: {
elements: [
{
type: "text_run",
text_run: {
text: "这是刚才的总结结果",
},
},
],
},
},
],
},
},
{
comment_id: "comment_other_user",
create_time: 1775531550,
user_id: "ou_other",
is_whole: true,
reply_list: {
replies: [
{
reply_id: "reply_c",
user_id: "ou_other",
create_time: 1775531550,
content: {
elements: [
{
type: "text_run",
text_run: {
text: "另一个 whole comment",
},
},
],
},
},
],
},
},
],
},
};
}
throw new Error(`unexpected request: ${request.method} ${request.url}`);
}),
wiki: {
space: {
getNode: vi.fn(async () => ({ code: 0, data: { node: {} } })),
},
},
};
const turn = await resolveDriveCommentEventTurn({
cfg: buildMonitorConfig(),
accountId: "default",
event: makeDriveCommentEvent(),
botOpenId: "ou_bot",
createClient: () => client as never,
});
expect(turn?.isWholeComment).toBe(true);
expect(turn?.prompt).toContain(
"Whole-document comment timeline (primary context for whole-comment follow-ups):",
);
expect(turn?.prompt).toContain("comment_id=7623358762119646411");
expect(turn?.prompt).toContain("comment_id=comment_bot_followup");
expect(turn?.prompt).toContain(
'Nearest bot-authored whole-comment after the current comment: comment_id=comment_bot_followup text="这是刚才的总结结果"',
);
expect(turn?.prompt).toContain("Document-level session history is auxiliary background only.");
});
it("treats replies with missing user_id as user-authored even when bot id hints are missing", async () => {
const client = {
request: vi.fn(async (request: { method: "GET" | "POST"; url: string; data: unknown }) => {
if (request.url === "/open-apis/drive/v1/metas/batch_query") {
return {
code: 0,
data: {
metas: [
{
doc_token: TEST_DOC_TOKEN,
title: "Comment event handling request",
url: `https://www.larksuite.com/docx/${TEST_DOC_TOKEN}`,
},
],
},
};
}
if (request.url.includes("/comments/batch_query")) {
return {
code: 0,
data: {
items: [
{
comment_id: "7623358762119646411",
is_whole: true,
reply_list: {
replies: [
{
reply_id: "reply_missing_user",
create_time: 1775531531,
content: {
elements: [
{
type: "text_run",
text_run: {
text: "reply without user id",
},
},
],
},
},
],
},
},
],
},
};
}
if (request.url.includes("/comments?file_type=docx&is_whole=true")) {
return {
code: 0,
data: {
has_more: false,
items: [
{
comment_id: "7623358762119646411",
create_time: 1775531531,
is_whole: true,
reply_list: {
replies: [
{
reply_id: "reply_missing_user",
create_time: 1775531531,
content: {
elements: [
{
type: "text_run",
text_run: {
text: "reply without user id",
},
},
],
},
},
],
},
},
],
},
};
}
throw new Error(`unexpected request: ${request.method} ${request.url}`);
}),
wiki: {
space: {
getNode: vi.fn(async () => ({ code: 0, data: { node: {} } })),
},
},
};
const turn = await resolveDriveCommentEventTurn({
cfg: buildMonitorConfig(),
accountId: "default",
event: makeDriveCommentEvent({
reply_id: "reply_missing_user",
}),
botOpenId: "ou_bot",
createClient: () => client as never,
});
expect(turn?.prompt).toContain(
"comment_id=7623358762119646411 author=user user_id=UNKNOWN current_comment=yes",
);
expect(turn?.prompt).not.toContain(
"author=assistant user_id=UNKNOWN reply_id=reply_missing_user",
);
});
it("does not trust whole-comment metadata from a mismatched batch_query item", async () => {
const client = makeOpenApiClient({
includeTargetReplyInBatch: true,
@@ -383,11 +763,10 @@ describe("resolveDriveCommentEventTurn", () => {
createClient: () => client as never,
});
expect(turn?.prompt).toContain('The user added a reply in "Comment event handling request".');
expect(turn?.prompt).toContain('Current user comment text: "Please follow up on this comment"');
expect(turn?.prompt).toContain(
'The user added a reply in "Comment event handling request": Please follow up on this comment',
);
expect(turn?.prompt).toContain(
"Original comment: Also send it to the agent after receiving the comment event",
'Original comment text: "Also send it to the agent after receiving the comment event"',
);
expect(turn?.prompt).toContain(`file_token: ${TEST_DOC_TOKEN}`);
expect(turn?.prompt).toContain("Event type: add_reply");
@@ -525,6 +904,52 @@ describe("drive.notice.comment_add_v1 monitor handler", () => {
);
});
it("serializes same-document comment notices before invoking handleFeishuCommentEvent", async () => {
const onComment = await setupCommentMonitorHandler();
let resolveFirst: (() => void) | undefined;
handleFeishuCommentEventMock
.mockImplementationOnce(
() =>
new Promise<void>((resolve) => {
resolveFirst = resolve;
}),
)
.mockImplementationOnce(async () => {});
await onComment(
makeDriveCommentEvent({
event_id: "evt_1",
reply_id: "reply_1",
}),
);
await new Promise((resolve) => setTimeout(resolve, 0));
await onComment(
makeDriveCommentEvent({
event_id: "evt_2",
reply_id: "reply_2",
}),
);
await new Promise((resolve) => setTimeout(resolve, 0));
expect(handleFeishuCommentEventMock).toHaveBeenCalledTimes(1);
resolveFirst?.();
await new Promise((resolve) => setTimeout(resolve, 0));
expect(handleFeishuCommentEventMock).toHaveBeenCalledTimes(2);
const firstCallArgs = handleFeishuCommentEventMock.mock.calls.at(0) as
| [{ event?: { event_id?: string } }]
| undefined;
const secondCallArgs = handleFeishuCommentEventMock.mock.calls.at(1) as
| [{ event?: { event_id?: string } }]
| undefined;
const firstCall = firstCallArgs?.[0];
const secondCall = secondCallArgs?.[0];
expect(firstCall?.event?.event_id).toBe("evt_1");
expect(secondCall?.event?.event_id).toBe("evt_2");
});
it("drops duplicate comment events before dispatch", async () => {
vi.spyOn(dedup, "hasProcessedFeishuMessage").mockResolvedValue(true);
const onComment = await setupCommentMonitorHandler();

View File

@@ -8,16 +8,24 @@ import {
extractReplyText,
isRecord,
normalizeString,
parseCommentContentElements,
type ParsedCommentContent,
type ParsedCommentLinkedDocument,
readString,
} from "./comment-shared.js";
import { normalizeCommentFileType, type CommentFileType } from "./comment-target.js";
import type { ResolvedFeishuAccount } from "./types.js";
const FEISHU_COMMENT_VERIFY_TIMEOUT_MS = 3_000;
const FEISHU_COMMENT_LIST_PAGE_SIZE = 100;
const FEISHU_COMMENT_LIST_PAGE_LIMIT = 5;
const FEISHU_COMMENT_REPLY_PAGE_SIZE = 100;
const FEISHU_COMMENT_REPLY_PAGE_LIMIT = 5;
const FEISHU_COMMENT_REPLY_MISS_RETRY_DELAY_MS = 1_000;
const FEISHU_COMMENT_REPLY_MISS_RETRY_LIMIT = 6;
const FEISHU_COMMENT_THREAD_PROMPT_LIMIT = 20;
const FEISHU_WHOLE_COMMENT_PROMPT_LIMIT = 12;
const FEISHU_PROMPT_TEXT_LIMIT = 220;
type FeishuDriveCommentUserId = {
open_id?: string;
@@ -100,6 +108,9 @@ type FeishuDriveMetaBatchQueryResponse = FeishuOpenApiResponse<{
type FeishuDriveCommentReply = {
reply_id?: string;
user_id?: string;
create_time?: number;
update_time?: number;
content?: {
elements?: unknown[];
};
@@ -107,7 +118,12 @@ type FeishuDriveCommentReply = {
type FeishuDriveCommentCard = {
comment_id?: string;
user_id?: string;
create_time?: number;
update_time?: number;
is_whole?: boolean;
has_more?: boolean;
page_token?: string;
quote?: string;
reply_list?: {
replies?: FeishuDriveCommentReply[];
@@ -118,12 +134,35 @@ type FeishuDriveCommentBatchQueryResponse = FeishuOpenApiResponse<{
items?: FeishuDriveCommentCard[];
}>;
type FeishuDriveCommentListResponse = FeishuOpenApiResponse<{
has_more?: boolean;
items?: FeishuDriveCommentCard[];
page_token?: string;
}>;
type FeishuDriveCommentRepliesListResponse = FeishuOpenApiResponse<{
has_more?: boolean;
items?: FeishuDriveCommentReply[];
page_token?: string;
}>;
type ResolvedCommentReplyContext = {
replyId?: string;
userId?: string;
createTime?: number;
isBotAuthored: boolean;
content: ParsedCommentContent;
};
type ResolvedWholeCommentTimelineEntry = {
commentId: string;
userId?: string;
createTime?: number;
isCurrentComment: boolean;
isBotAuthored: boolean;
content: ParsedCommentContent;
};
function readBoolean(value: unknown): boolean | undefined {
return typeof value === "boolean" ? value : undefined;
}
@@ -138,6 +177,96 @@ function safeJsonStringify(value: unknown): string {
}
}
function truncatePromptText(
text: string | undefined,
maxLength = FEISHU_PROMPT_TEXT_LIMIT,
): string {
const normalized = normalizeString(text);
if (!normalized) {
return "";
}
return normalized.length > maxLength ? `${normalized.slice(0, maxLength - 1)}` : normalized;
}
function formatPromptTextValue(text: string | undefined): string {
return safeJsonStringify(truncatePromptText(text) || "");
}
function formatPromptBoolean(value: boolean | undefined): string {
return value === true ? "yes" : "no";
}
function buildDriveCommentsListUrl(params: {
fileToken: string;
fileType: CommentFileType;
pageToken?: string;
isWholeOnly?: boolean;
}): string {
return (
`/open-apis/drive/v1/files/${encodeURIComponent(params.fileToken)}/comments` +
encodeQuery({
file_type: params.fileType,
is_whole: params.isWholeOnly === true ? "true" : undefined,
page_size: String(FEISHU_COMMENT_LIST_PAGE_SIZE),
page_token: params.pageToken,
user_id_type: "open_id",
})
);
}
function compareCommentTimelineEntries(
left: { createTime?: number; stableId?: string },
right: { createTime?: number; stableId?: string },
): number {
const leftTime = left.createTime ?? Number.MAX_SAFE_INTEGER;
const rightTime = right.createTime ?? Number.MAX_SAFE_INTEGER;
if (leftTime !== rightTime) {
return leftTime - rightTime;
}
return (left.stableId ?? "").localeCompare(right.stableId ?? "");
}
function formatLinkedDocumentInline(link: ParsedCommentLinkedDocument): string {
const parts = [
`raw_url=${link.rawUrl}`,
`url_kind=${link.urlKind}`,
link.wikiNodeToken ? `wiki_node_token=${link.wikiNodeToken}` : null,
`resolved_type=${link.resolvedObjType ?? "UNKNOWN"}`,
`resolved_token=${link.resolvedObjToken ?? "UNKNOWN"}`,
`same_as_current_document=${formatPromptBoolean(link.isCurrentDocument)}`,
].filter((part): part is string => Boolean(part));
return parts.join(" ");
}
function formatLinkedDocumentsPromptLines(params: {
title: string;
linkedDocuments: ParsedCommentLinkedDocument[];
}): string[] {
if (params.linkedDocuments.length === 0) {
return [];
}
return [
params.title,
...params.linkedDocuments.map(
(link, index) => `- [${index + 1}] ${formatLinkedDocumentInline(link)}`,
),
];
}
function formatLinkedDocumentsInlineSummary(
linkedDocuments: ParsedCommentLinkedDocument[],
): string {
if (linkedDocuments.length === 0) {
return "none";
}
return linkedDocuments
.map(
(link) =>
`${link.resolvedObjType ?? link.urlKind}:${link.resolvedObjToken ?? link.wikiNodeToken ?? "UNKNOWN"}`,
)
.join(",");
}
function summarizeCommentRepliesForLog(replies: FeishuDriveCommentReply[]): string {
return safeJsonStringify(
replies.map((reply) => ({
@@ -147,6 +276,93 @@ function summarizeCommentRepliesForLog(replies: FeishuDriveCommentReply[]): stri
);
}
async function resolveParsedCommentContent(params: {
elements?: unknown[];
botOpenIds?: Iterable<string | undefined>;
currentDocument: {
fileType: CommentFileType;
fileToken: string;
};
client: FeishuRequestClient;
wikiCache: Map<
string,
Promise<{
resolvedObjType?: CommentFileType;
resolvedObjToken?: string;
} | null>
>;
logger?: (message: string) => void;
accountId: string;
}): Promise<ParsedCommentContent> {
const parsed = parseCommentContentElements({
elements: params.elements,
botOpenIds: params.botOpenIds,
currentDocument: params.currentDocument,
});
if (!parsed.linkedDocuments.some((link) => link.urlKind === "wiki" && link.wikiNodeToken)) {
return parsed;
}
const resolvedLinkedDocuments = await Promise.all(
parsed.linkedDocuments.map(async (link) => {
if (link.urlKind !== "wiki" || !link.wikiNodeToken) {
return link;
}
let pending = params.wikiCache.get(link.wikiNodeToken);
if (!pending) {
pending = params.client.wiki.space
.getNode({
params: {
token: link.wikiNodeToken,
},
})
.then((response) => {
if (response.code !== 0) {
params.logger?.(
`feishu[${params.accountId}]: wiki link resolution failed token=${link.wikiNodeToken} ` +
`code=${response.code ?? "unknown"} msg=${response.msg ?? "unknown"}`,
);
return null;
}
const objType = normalizeCommentFileType(response.data?.node?.obj_type);
const objToken = normalizeString(response.data?.node?.obj_token);
if (!objType || !objToken) {
return null;
}
return {
resolvedObjType: objType,
resolvedObjToken: objToken,
};
})
.catch((error) => {
params.logger?.(
`feishu[${params.accountId}]: wiki link resolution threw token=${link.wikiNodeToken} error=${formatErrorMessage(error)}`,
);
return null;
});
params.wikiCache.set(link.wikiNodeToken, pending);
}
const resolved = await pending;
if (!resolved) {
return link;
}
return {
...link,
resolvedObjType: resolved.resolvedObjType,
resolvedObjToken: resolved.resolvedObjToken,
isCurrentDocument:
resolved.resolvedObjType === params.currentDocument.fileType &&
resolved.resolvedObjToken === params.currentDocument.fileToken,
};
}),
);
return {
...parsed,
linkedDocuments: resolvedLinkedDocuments,
};
}
async function delayMs(ms: number): Promise<void> {
await new Promise((resolve) => setTimeout(resolve, ms));
}
@@ -183,6 +399,49 @@ function buildDriveCommentRepliesUrl(params: {
);
}
async function fetchDriveComments(params: {
client: FeishuRequestClient;
fileToken: string;
fileType: CommentFileType;
isWholeOnly?: boolean;
timeoutMs: number;
logger?: (message: string) => void;
accountId: string;
}): Promise<FeishuDriveCommentCard[]> {
const comments: FeishuDriveCommentCard[] = [];
let pageToken: string | undefined;
for (let page = 0; page < FEISHU_COMMENT_LIST_PAGE_LIMIT; page += 1) {
const response = await requestFeishuOpenApi<FeishuDriveCommentListResponse>({
client: params.client,
method: "GET",
url: buildDriveCommentsListUrl({
fileToken: params.fileToken,
fileType: params.fileType,
isWholeOnly: params.isWholeOnly,
pageToken,
}),
timeoutMs: params.timeoutMs,
logger: params.logger,
errorLabel: `feishu[${params.accountId}]: failed to list drive comments for ${params.fileToken}`,
});
if (response?.code !== 0) {
if (response) {
params.logger?.(
`feishu[${params.accountId}]: failed to list drive comments for ${params.fileToken}: ` +
`${response.msg ?? "unknown error"} log_id=${response.log_id?.trim() || "unknown"}`,
);
}
break;
}
comments.push(...(response.data?.items ?? []));
if (response.data?.has_more !== true || !response.data.page_token?.trim()) {
break;
}
pageToken = response.data.page_token.trim();
}
return comments;
}
async function requestFeishuOpenApi<T>(params: {
client: FeishuRequestClient;
method: "GET" | "POST";
@@ -285,12 +544,189 @@ async function fetchDriveCommentReplies(params: {
return { replies, logIds };
}
async function resolveCommentReplyContext(params: {
reply: FeishuDriveCommentReply;
botOpenIds?: Iterable<string | undefined>;
currentDocument: {
fileType: CommentFileType;
fileToken: string;
};
client: FeishuRequestClient;
wikiCache: Map<
string,
Promise<{
resolvedObjType?: CommentFileType;
resolvedObjToken?: string;
} | null>
>;
logger?: (message: string) => void;
accountId: string;
}): Promise<ResolvedCommentReplyContext> {
const userId = normalizeString(params.reply.user_id);
const normalizedBotOpenIds = new Set(
Array.from(params.botOpenIds ?? [])
.map((botId) => normalizeString(botId))
.filter((botId): botId is string => Boolean(botId)),
);
return {
replyId: normalizeString(params.reply.reply_id),
userId,
createTime: typeof params.reply.create_time === "number" ? params.reply.create_time : undefined,
isBotAuthored: typeof userId === "string" && normalizedBotOpenIds.has(userId),
content: await resolveParsedCommentContent({
elements: isRecord(params.reply.content) ? params.reply.content.elements : undefined,
botOpenIds: params.botOpenIds,
currentDocument: params.currentDocument,
client: params.client,
wikiCache: params.wikiCache,
logger: params.logger,
accountId: params.accountId,
}),
};
}
function selectCommentThreadPromptReplies(
replies: ResolvedCommentReplyContext[],
targetReplyId?: string,
): ResolvedCommentReplyContext[] {
if (replies.length <= FEISHU_COMMENT_THREAD_PROMPT_LIMIT) {
return replies;
}
const targetIndex = replies.findIndex((reply) => reply.replyId === targetReplyId);
const currentIndex = targetIndex >= 0 ? targetIndex : replies.length - 1;
const selected = new Set<number>([0, currentIndex, replies.length - 1]);
for (let radius = 1; selected.size < FEISHU_COMMENT_THREAD_PROMPT_LIMIT; radius += 1) {
const before = currentIndex - radius;
const after = currentIndex + radius;
if (before >= 0) {
selected.add(before);
}
if (selected.size >= FEISHU_COMMENT_THREAD_PROMPT_LIMIT) {
break;
}
if (after < replies.length) {
selected.add(after);
}
if (before < 0 && after >= replies.length) {
break;
}
}
return [...selected]
.toSorted((left, right) => left - right)
.map((index) => replies[index])
.filter((reply): reply is ResolvedCommentReplyContext => Boolean(reply));
}
function formatCommentThreadPromptLines(params: {
replies: ResolvedCommentReplyContext[];
targetReplyId?: string;
}): string[] {
const promptReplies = selectCommentThreadPromptReplies(params.replies, params.targetReplyId);
return promptReplies.map((reply, index) => {
const text = reply.content.semanticText ?? reply.content.plainText;
return (
`- [${index + 1}] author=${reply.isBotAuthored ? "assistant" : "user"} ` +
`user_id=${reply.userId ?? "UNKNOWN"} ` +
`reply_id=${reply.replyId ?? "UNKNOWN"} ` +
`current_event=${reply.replyId === params.targetReplyId ? "yes" : "no"} ` +
`text=${formatPromptTextValue(text)} ` +
`referenced_docs=${formatLinkedDocumentsInlineSummary(reply.content.linkedDocuments)}`
);
});
}
function findNearestBotTimelineEntry(params: {
entries: ResolvedWholeCommentTimelineEntry[];
currentIndex: number;
direction: "before" | "after";
}): ResolvedWholeCommentTimelineEntry | undefined {
const step = params.direction === "after" ? 1 : -1;
for (
let index = params.currentIndex + step;
index >= 0 && index < params.entries.length;
index += step
) {
const candidate = params.entries[index];
if (candidate?.isBotAuthored) {
return candidate;
}
}
return undefined;
}
function selectWholeCommentTimelineEntries(params: {
entries: ResolvedWholeCommentTimelineEntry[];
currentCommentId: string;
}): ResolvedWholeCommentTimelineEntry[] {
if (params.entries.length <= FEISHU_WHOLE_COMMENT_PROMPT_LIMIT) {
return params.entries;
}
const currentIndex = params.entries.findIndex(
(entry) => entry.commentId === params.currentCommentId,
);
if (currentIndex < 0) {
return params.entries.slice(-FEISHU_WHOLE_COMMENT_PROMPT_LIMIT);
}
const selected = new Set<number>([currentIndex]);
const nearestBotAfter = params.entries.findIndex(
(entry, index) => index > currentIndex && entry.isBotAuthored,
);
if (nearestBotAfter >= 0) {
selected.add(nearestBotAfter);
}
for (let index = currentIndex - 1; index >= 0; index -= 1) {
if (params.entries[index]?.isBotAuthored) {
selected.add(index);
break;
}
}
for (let radius = 1; selected.size < FEISHU_WHOLE_COMMENT_PROMPT_LIMIT; radius += 1) {
const before = currentIndex - radius;
const after = currentIndex + radius;
if (before >= 0) {
selected.add(before);
}
if (selected.size >= FEISHU_WHOLE_COMMENT_PROMPT_LIMIT) {
break;
}
if (after < params.entries.length) {
selected.add(after);
}
if (before < 0 && after >= params.entries.length) {
break;
}
}
return [...selected]
.toSorted((left, right) => left - right)
.map((index) => params.entries[index])
.filter((entry): entry is ResolvedWholeCommentTimelineEntry => Boolean(entry));
}
function formatWholeCommentTimelinePromptLines(params: {
entries: ResolvedWholeCommentTimelineEntry[];
currentCommentId: string;
}): string[] {
return selectWholeCommentTimelineEntries(params).map((entry, index) => {
const text = entry.content.semanticText ?? entry.content.plainText;
return (
`- [${index + 1}] create_time=${entry.createTime ?? "UNKNOWN"} ` +
`comment_id=${entry.commentId} ` +
`author=${entry.isBotAuthored ? "assistant" : "user"} ` +
`user_id=${entry.userId ?? "UNKNOWN"} ` +
`current_comment=${entry.commentId === params.currentCommentId ? "yes" : "no"} ` +
`text=${formatPromptTextValue(text)} ` +
`referenced_docs=${formatLinkedDocumentsInlineSummary(entry.content.linkedDocuments)}`
);
});
}
async function fetchDriveCommentContext(params: {
client: FeishuRequestClient;
fileToken: string;
fileType: CommentFileType;
commentId: string;
replyId?: string;
botOpenIds?: Iterable<string | undefined>;
timeoutMs: number;
logger?: (message: string) => void;
accountId: string;
@@ -302,6 +738,12 @@ async function fetchDriveCommentContext(params: {
quoteText?: string;
rootCommentText?: string;
targetReplyText?: string;
rootCommentContent?: ParsedCommentContent;
targetReplyContent?: ParsedCommentContent;
currentCommentThreadReplies: ResolvedCommentReplyContext[];
wholeCommentTimeline: ResolvedWholeCommentTimelineEntry[];
nearestBotWholeCommentAfter?: ResolvedWholeCommentTimelineEntry;
nearestBotWholeCommentBefore?: ResolvedWholeCommentTimelineEntry;
}> {
const [metaResponse, commentResponse] = await Promise.all([
requestFeishuOpenApi<FeishuDriveMetaBatchQueryResponse>({
@@ -331,6 +773,13 @@ async function fetchDriveCommentContext(params: {
errorLabel: `feishu[${params.accountId}]: failed to fetch drive comment ${params.commentId}`,
}),
]);
const wikiCache = new Map<
string,
Promise<{
resolvedObjType?: CommentFileType;
resolvedObjToken?: string;
} | null>
>();
const commentCard =
commentResponse?.code === 0
@@ -351,12 +800,15 @@ async function fetchDriveCommentContext(params: {
let fetchedMatchedReply = params.replyId
? replies.find((reply) => reply.reply_id?.trim() === params.replyId?.trim())
: undefined;
if (!embeddedTargetReply || replies.length === 0) {
const needsExtraReplies =
!embeddedTargetReply || replies.length === 0 || commentCard?.has_more === true;
if (needsExtraReplies) {
params.logger?.(
`feishu[${params.accountId}]: fetching extra comment replies comment=${params.commentId} ` +
`requested_reply=${params.replyId ?? "none"} ` +
`embedded_count=${embeddedReplies.length} ` +
`embedded_hit=${embeddedTargetReply ? "yes" : "no"}`,
`embedded_hit=${embeddedTargetReply ? "yes" : "no"} ` +
`embedded_has_more=${commentCard?.has_more === true ? "yes" : "no"}`,
);
const fetched = await fetchDriveCommentReplies(params);
if (fetched.replies.length > 0) {
@@ -419,14 +871,137 @@ async function fetchDriveCommentContext(params: {
`target=${safeJsonStringify({ reply_id: targetReply?.reply_id, text_len: extractReplyText(targetReply)?.length ?? 0 })}`,
);
const meta = metaResponse?.code === 0 ? metaResponse.data?.metas?.[0] : undefined;
const currentDocument = {
fileType: params.fileType,
fileToken: params.fileToken,
};
const resolvedReplies = await Promise.all(
replies.map((reply) =>
resolveCommentReplyContext({
reply,
botOpenIds: params.botOpenIds,
currentDocument,
client: params.client,
wikiCache,
logger: params.logger,
accountId: params.accountId,
}),
),
);
resolvedReplies.sort((left, right) =>
compareCommentTimelineEntries(
{
createTime: left.createTime,
stableId: left.replyId,
},
{
createTime: right.createTime,
stableId: right.replyId,
},
),
);
const rootReplyContext =
resolvedReplies.find((reply) => reply.replyId === normalizeString(rootReply?.reply_id)) ??
resolvedReplies[0];
const targetReplyContext =
resolvedReplies.find((reply) => reply.replyId === normalizeString(targetReply?.reply_id)) ??
(params.replyId ? undefined : (resolvedReplies.at(-1) ?? rootReplyContext));
let wholeCommentTimeline: ResolvedWholeCommentTimelineEntry[] = [];
if (commentCard?.is_whole === true) {
const allComments = await fetchDriveComments({
client: params.client,
fileToken: params.fileToken,
fileType: params.fileType,
isWholeOnly: true,
timeoutMs: params.timeoutMs,
logger: params.logger,
accountId: params.accountId,
});
const wholeComments = allComments.filter((comment) => comment.is_whole === true);
wholeCommentTimeline = await Promise.all(
wholeComments.map(async (comment) => {
const rootWholeReply = comment.reply_list?.replies?.[0];
const normalizedBotOpenIds = new Set(
Array.from(params.botOpenIds ?? [])
.map((botId) => normalizeString(botId))
.filter((botId): botId is string => Boolean(botId)),
);
const content = await resolveParsedCommentContent({
elements: isRecord(rootWholeReply?.content) ? rootWholeReply.content.elements : undefined,
botOpenIds: params.botOpenIds,
currentDocument,
client: params.client,
wikiCache,
logger: params.logger,
accountId: params.accountId,
});
const commentUserId =
normalizeString(rootWholeReply?.user_id) || normalizeString(comment.user_id);
return {
commentId: normalizeString(comment.comment_id) ?? "",
userId: commentUserId,
createTime:
typeof comment.create_time === "number"
? comment.create_time
: typeof rootWholeReply?.create_time === "number"
? rootWholeReply.create_time
: undefined,
isCurrentComment: normalizeString(comment.comment_id) === params.commentId,
isBotAuthored:
typeof commentUserId === "string" && normalizedBotOpenIds.has(commentUserId),
content,
};
}),
);
wholeCommentTimeline = wholeCommentTimeline
.filter((entry) => Boolean(entry.commentId))
.toSorted((left, right) =>
compareCommentTimelineEntries(
{
createTime: left.createTime,
stableId: left.commentId,
},
{
createTime: right.createTime,
stableId: right.commentId,
},
),
);
}
const currentWholeCommentIndex = wholeCommentTimeline.findIndex(
(entry) => entry.commentId === params.commentId,
);
return {
documentTitle: normalizeString(meta?.title),
documentUrl: normalizeString(meta?.url),
isWholeComment: commentCard?.is_whole,
quoteText: normalizeString(commentCard?.quote),
rootCommentText: extractReplyText(rootReply),
targetReplyText: extractReplyText(targetReply),
rootCommentText: rootReplyContext?.content.semanticText ?? rootReplyContext?.content.plainText,
targetReplyText:
targetReplyContext?.content.semanticText ?? targetReplyContext?.content.plainText,
rootCommentContent: rootReplyContext?.content,
targetReplyContent: targetReplyContext?.content,
currentCommentThreadReplies: resolvedReplies,
wholeCommentTimeline,
nearestBotWholeCommentAfter:
currentWholeCommentIndex >= 0
? findNearestBotTimelineEntry({
entries: wholeCommentTimeline,
currentIndex: currentWholeCommentIndex,
direction: "after",
})
: undefined,
nearestBotWholeCommentBefore:
currentWholeCommentIndex >= 0
? findNearestBotTimelineEntry({
entries: wholeCommentTimeline,
currentIndex: currentWholeCommentIndex,
direction: "before",
})
: undefined,
};
}
@@ -443,24 +1018,31 @@ function buildDriveCommentSurfacePrompt(params: {
quoteText?: string;
rootCommentText?: string;
targetReplyText?: string;
rootCommentContent?: ParsedCommentContent;
targetReplyContent?: ParsedCommentContent;
currentCommentThreadReplies: ResolvedCommentReplyContext[];
wholeCommentTimeline: ResolvedWholeCommentTimelineEntry[];
nearestBotWholeCommentAfter?: ResolvedWholeCommentTimelineEntry;
nearestBotWholeCommentBefore?: ResolvedWholeCommentTimelineEntry;
}): string {
const documentLabel = params.documentTitle
? `"${params.documentTitle}"`
: `${params.fileType} document ${params.fileToken}`;
const actionLabel = params.noticeType === "add_reply" ? "reply" : "comment";
const firstLine = params.targetReplyText
? `The user added a ${actionLabel} in ${documentLabel}: ${params.targetReplyText}`
: `The user added a ${actionLabel} in ${documentLabel}.`;
const firstLine = `The user added a ${actionLabel} in ${documentLabel}.`;
const lines = [firstLine];
if (params.targetReplyText) {
lines.push(`Current user comment text: ${formatPromptTextValue(params.targetReplyText)}`);
}
if (
params.noticeType === "add_reply" &&
params.rootCommentText &&
params.rootCommentText !== params.targetReplyText
) {
lines.push(`Original comment: ${params.rootCommentText}`);
lines.push(`Original comment text: ${formatPromptTextValue(params.rootCommentText)}`);
}
if (params.quoteText) {
lines.push(`Quoted content: ${params.quoteText}`);
lines.push(`Quoted content: ${formatPromptTextValue(params.quoteText)}`);
}
if (params.isMentioned === true) {
lines.push("This comment mentioned you.");
@@ -468,6 +1050,17 @@ function buildDriveCommentSurfacePrompt(params: {
if (params.documentUrl) {
lines.push(`Document link: ${params.documentUrl}`);
}
lines.push(
"Current commented document:",
`- file_type=${params.fileType}`,
`- file_token=${params.fileToken}`,
);
if (params.documentTitle) {
lines.push(`- title=${params.documentTitle}`);
}
if (params.documentUrl) {
lines.push(`- url=${params.documentUrl}`);
}
lines.push(
`Event type: ${params.noticeType}`,
`file_token: ${params.fileToken}`,
@@ -480,29 +1073,124 @@ function buildDriveCommentSurfacePrompt(params: {
if (params.replyId?.trim()) {
lines.push(`reply_id: ${params.replyId.trim()}`);
}
if (params.targetReplyContent?.semanticText) {
lines.push(
`Current user comment semantic text: ${formatPromptTextValue(
params.targetReplyContent.semanticText,
)}`,
);
}
if (params.targetReplyContent?.botMentioned) {
lines.push(
"Bot routing mention detected in the current user comment. Treat that mention as routing only, not task content.",
);
}
const nonBotMentions = (params.targetReplyContent?.mentions ?? [])
.filter((mention) => !mention.isBotMention)
.map((mention) => mention.displayText);
if (nonBotMentions.length > 0) {
lines.push(`Other mentioned users in current comment: ${nonBotMentions.join(", ")}`);
}
lines.push(
"This is a Feishu document comment-thread event, not a Feishu IM conversation. Your final text reply will be posted automatically to the current comment thread and will not be sent as an instant message.",
"If you need to inspect or handle the comment thread, prefer the feishu_drive tools: use list_comments / list_comment_replies to inspect comments, and use reply_comment/add_comment to notify the user after modifying the document.",
"Whole-document comments do not support direct replies. When the current comment is whole-document, use feishu_drive.add_comment for any user-visible follow-up instead of reply_comment.",
'If the comment asks you to modify document content, such as adding, inserting, replacing, or deleting text, tables, or headings, you must first use feishu_doc to actually modify the document. Do not reply with only "done", "I\'ll handle it", or a restated plan without calling tools.',
'If the comment quotes document content, that quoted text is usually the edit anchor. For requests like "insert xxx below this content", first locate the position around the quoted content, then use feishu_doc to make the change.',
'If the comment asks you to summarize, explain, rewrite, translate, refine, continue, or review the document content "below", "above", "this paragraph", "this section", or the quoted content, you must also treat the quoted content as the primary target anchor instead of defaulting to the whole document.',
'For requests like "summarize the content below", "explain this section", or "continue writing from here", first locate the relevant document fragment based on the comment\'s quoted content. If the quote is not sufficient to support the answer, then use feishu_doc.read or feishu_doc.list_blocks to read nearby context.',
"Do not guess document content based only on the comment text, and do not output a vague summary before reading enough context. Unless the user explicitly asks to summarize the entire document, default to handling only the local scope related to the quoted content.",
"When document edits are involved, first use feishu_doc.read or feishu_doc.list_blocks to confirm the context, then use feishu_doc writing or updating capabilities to complete the change. After the edit succeeds, notify the user through feishu_drive.reply_comment.",
"If the document edit fails or you cannot locate the anchor, do not pretend it succeeded. Reply clearly in the comment thread with the reason for failure or the missing information.",
"If this is a reading-comprehension task, such as summarization, explanation, or extraction, you may directly output the final answer text after confirming the context. The system will automatically reply with that answer in the current comment thread.",
"Prefer plain text suitable for a comment thread. Unless the user explicitly asks for Markdown, do not use Markdown headings, bullet lists, numbered lists, tables, blockquotes, or fenced code blocks in the final reply.",
"If source content was read in Markdown form, rewrite it into normal plain-text prose before replying in the comment thread instead of copying Markdown syntax through.",
'Do not include internal reasoning, analysis, chain-of-thought, scratch work, or any "Reasoning:" / "Thinking:" section in a user-visible reply. Output only the final answer meant for the user, or NO_REPLY when appropriate.',
'Do not narrate your plan or execution process in the user-visible reply. Avoid meta lead-ins such as "I will...", "Ill first...", "I need to...", "The user wants...", "I have updated...", or "I am going to...".',
"When the task is complete, reply only with the user-facing result itself, such as the final answer or a concise completion confirmation. Do not include preambles about what you plan to do next.",
"When you produce a user-visible reply, keep it in the same language as the user's original comment or reply unless they explicitly ask for another language.",
"If you have already completed the user-visible action through feishu_drive.reply_comment or feishu_drive.add_comment, output NO_REPLY at the end to avoid duplicate sending.",
"If the user directly asks a question in the comment and a plain text answer is sufficient, output the answer text directly. The system will automatically reply with your final answer in the current comment thread.",
"If you determine that the current comment does not require any user-visible action, output NO_REPLY at the end.",
...formatLinkedDocumentsPromptLines({
title: "Referenced documents from current user comment:",
linkedDocuments: params.targetReplyContent?.linkedDocuments ?? [],
}),
);
if (!params.isWholeComment && params.currentCommentThreadReplies.length > 0) {
lines.push(
"Current comment card timeline (primary context for follow-ups on this comment card):",
...formatCommentThreadPromptLines({
replies: params.currentCommentThreadReplies,
targetReplyId: params.replyId,
}),
"For this non-whole comment, use the current comment card timeline above as the primary source for phrases like 'above', 'previous result', 'that summary', or 'insert it'.",
"Document-level session history is auxiliary background only. Do not use another comment card's recent output as the primary referent.",
);
}
if (params.isWholeComment && params.wholeCommentTimeline.length > 0) {
lines.push(
"Whole-document comment timeline (primary context for whole-comment follow-ups):",
...formatWholeCommentTimelinePromptLines({
entries: params.wholeCommentTimeline,
currentCommentId: params.commentId,
}),
);
if (params.nearestBotWholeCommentAfter) {
lines.push(
`Nearest bot-authored whole-comment after the current comment: comment_id=${params.nearestBotWholeCommentAfter.commentId} text=${formatPromptTextValue(
params.nearestBotWholeCommentAfter.content.semanticText ??
params.nearestBotWholeCommentAfter.content.plainText,
)}`,
);
}
if (params.nearestBotWholeCommentBefore) {
lines.push(
`Nearest bot-authored whole-comment before the current comment: comment_id=${params.nearestBotWholeCommentBefore.commentId} text=${formatPromptTextValue(
params.nearestBotWholeCommentBefore.content.semanticText ??
params.nearestBotWholeCommentBefore.content.plainText,
)}`,
);
}
lines.push(
"For this whole-document comment, use the whole-comment timeline above as the primary source for phrases like 'just now', 'previous result', 'that summary', or 'write it back'.",
"Document-level session history is auxiliary background only. Do not resolve whole-comment follow-ups by blindly using the most recent document-session output.",
);
}
lines.push(
"This is a Feishu document comment thread.",
"It is not a Feishu IM chat.",
"Your final text reply will be posted to the current comment thread automatically.",
"Use the thread timeline above as the main context for follow-up requests.",
"Do not use another comment card or document-session output as the main reference.",
"If you need comment thread context, use feishu_drive.list_comments or feishu_drive.list_comment_replies.",
"If you modify the document, post a user-visible follow-up in the comment thread.",
"Use feishu_drive.reply_comment or feishu_drive.add_comment for that follow-up.",
"Whole-document comments do not support direct replies.",
"For whole-document comments, use feishu_drive.add_comment.",
'Only treat URLs listed under "Referenced documents from current user comment" as structured Feishu document references.',
"URLs that appear only in comment text are plain links unless you verify them.",
"If the user asks about a linked Feishu document or wiki page, treat that linked document as the read target.",
"If the user asks you to use a linked document as guidance, treat the linked document as the reference source and the current commented document as the edit target.",
"If a referenced document resolves to the same file_token and file_type as the current commented document, treat it as the current document.",
"If the user asks you to modify document content, you must use feishu_doc to make the change.",
'Do not reply with only "done", "I\'ll handle it", or a restated plan without calling tools.',
"If the comment quotes document content, treat the quoted content as the main anchor.",
'For requests like "insert xxx below this content", locate the quoted content first, then edit the document.',
'For requests like "summarize the content below", "explain this section", or "continue writing from here", use the quoted content as the main target.',
"If the quote is not enough, use feishu_doc.read or feishu_doc.list_blocks to read nearby context.",
"Do not guess document content from the comment alone.",
"Do not give a vague answer before reading enough context.",
"Unless the user asks for the whole document, handle only the local content around the quoted anchor.",
"If document edits are involved, read the anchor first, then edit.",
"If the edit fails or the anchor cannot be found, say so clearly.",
"If this is a reading task, such as summarization, explanation, or extraction, you may output the final answer directly after confirming the context.",
"Use the same language as the user's comment or reply, unless the user asks for another language.",
"Use plain text only.",
"Do not use Markdown.",
"Do not use headings.",
"Do not use bullet lists.",
"Do not use numbered lists.",
"Do not use tables.",
"Do not use blockquotes.",
"Do not use code blocks.",
"Do not show reasoning.",
"Do not show analysis.",
"Do not show chain-of-thought.",
"Do not show scratch work.",
"Do not describe your plan.",
"Do not describe your steps.",
"Do not describe tool use.",
'Do not start with phrases like "I will", "Ill first", "I need to", "The user wants", or "I have updated".',
"Output only the final user-facing reply.",
"If you already sent the user-visible reply with feishu_drive.reply_comment or feishu_drive.add_comment, output exactly NO_REPLY.",
"If no user-visible reply is needed, output exactly NO_REPLY.",
"Be concise.",
"Do not omit requested content.",
);
lines.push(
"Choose one outcome: output the final plain-text reply, edit the document and then post a user-visible follow-up in the comment thread, or output exactly NO_REPLY.",
);
lines.push(`Decide what to do next based on this document ${actionLabel} event.`);
return lines.join("\n");
}
@@ -524,6 +1212,12 @@ async function resolveDriveCommentEventCore(params: ResolveDriveCommentEventPara
quoteText?: string;
rootCommentText?: string;
targetReplyText?: string;
rootCommentContent?: ParsedCommentContent;
targetReplyContent?: ParsedCommentContent;
currentCommentThreadReplies: ResolvedCommentReplyContext[];
wholeCommentTimeline: ResolvedWholeCommentTimelineEntry[];
nearestBotWholeCommentAfter?: ResolvedWholeCommentTimelineEntry;
nearestBotWholeCommentBefore?: ResolvedWholeCommentTimelineEntry;
};
} | null> {
const {
@@ -576,6 +1270,7 @@ async function resolveDriveCommentEventCore(params: ResolveDriveCommentEventPara
fileType,
commentId,
replyId,
botOpenIds: [botOpenId, event.notice_meta?.to_user_id?.open_id],
timeoutMs: verificationTimeoutMs,
logger,
accountId,
@@ -655,6 +1350,12 @@ export async function resolveDriveCommentEventTurn(
quoteText: resolved.context.quoteText,
rootCommentText: resolved.context.rootCommentText,
targetReplyText: resolved.context.targetReplyText,
rootCommentContent: resolved.context.rootCommentContent,
targetReplyContent: resolved.context.targetReplyContent,
currentCommentThreadReplies: resolved.context.currentCommentThreadReplies,
wholeCommentTimeline: resolved.context.wholeCommentTimeline,
nearestBotWholeCommentAfter: resolved.context.nearestBotWholeCommentAfter,
nearestBotWholeCommentBefore: resolved.context.nearestBotWholeCommentBefore,
});
const preview = prompt.replace(/\s+/g, " ").slice(0, 160);
return {

View File

@@ -8,7 +8,8 @@ const sendMediaFeishuMock = vi.hoisted(() => vi.fn());
const sendMessageFeishuMock = vi.hoisted(() => vi.fn());
const sendMarkdownCardFeishuMock = vi.hoisted(() => vi.fn());
const sendStructuredCardFeishuMock = vi.hoisted(() => vi.fn());
const replyCommentMock = vi.hoisted(() => vi.fn());
const deliverCommentThreadTextMock = vi.hoisted(() => vi.fn());
const cleanupAmbientCommentTypingReactionMock = vi.hoisted(() => vi.fn(async () => false));
vi.mock("./media.js", () => ({
sendMediaFeishu: sendMediaFeishuMock,
@@ -35,7 +36,11 @@ vi.mock("./client.js", () => ({
}));
vi.mock("./drive.js", () => ({
replyComment: replyCommentMock,
deliverCommentThreadText: deliverCommentThreadTextMock,
}));
vi.mock("./comment-reaction.js", () => ({
cleanupAmbientCommentTypingReaction: cleanupAmbientCommentTypingReactionMock,
}));
import { feishuOutbound } from "./outbound.js";
@@ -55,7 +60,11 @@ function resetOutboundMocks() {
sendMarkdownCardFeishuMock.mockResolvedValue({ messageId: "card_msg" });
sendStructuredCardFeishuMock.mockResolvedValue({ messageId: "card_msg" });
sendMediaFeishuMock.mockResolvedValue({ messageId: "media_msg" });
replyCommentMock.mockResolvedValue({ reply_id: "reply_msg" });
deliverCommentThreadTextMock.mockResolvedValue({
delivery_mode: "reply_comment",
reply_id: "reply_msg",
});
cleanupAmbientCommentTypingReactionMock.mockResolvedValue(false);
}
describe("feishuOutbound.sendText local-image auto-convert", () => {
@@ -214,7 +223,7 @@ describe("feishuOutbound comment-thread routing", () => {
resetOutboundMocks();
});
it("routes comment-thread text through replyComment", async () => {
it("routes comment-thread text through deliverCommentThreadText", async () => {
const result = await sendText({
cfg: emptyConfig,
to: "comment:docx:doxcn123:7623358762119646411",
@@ -222,7 +231,7 @@ describe("feishuOutbound comment-thread routing", () => {
accountId: "main",
});
expect(replyCommentMock).toHaveBeenCalledWith(
expect(deliverCommentThreadTextMock).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
file_token: "doxcn123",
@@ -235,7 +244,7 @@ describe("feishuOutbound comment-thread routing", () => {
expect(result).toEqual(expect.objectContaining({ channel: "feishu", messageId: "reply_msg" }));
});
it("routes comment-thread code-block replies through replyComment instead of IM cards", async () => {
it("routes comment-thread code-block replies through deliverCommentThreadText instead of IM cards", async () => {
const result = await sendText({
cfg: emptyConfig,
to: "comment:docx:doxcn123:7623358762119646411",
@@ -243,7 +252,7 @@ describe("feishuOutbound comment-thread routing", () => {
accountId: "main",
});
expect(replyCommentMock).toHaveBeenCalledWith(
expect(deliverCommentThreadTextMock).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
file_token: "doxcn123",
@@ -257,7 +266,7 @@ describe("feishuOutbound comment-thread routing", () => {
expect(result).toEqual(expect.objectContaining({ channel: "feishu", messageId: "reply_msg" }));
});
it("routes comment-thread replies through replyComment even when renderMode=card", async () => {
it("routes comment-thread replies through deliverCommentThreadText even when renderMode=card", async () => {
const result = await sendText({
cfg: cardRenderConfig,
to: "comment:docx:doxcn123:7623358762119646411",
@@ -265,7 +274,7 @@ describe("feishuOutbound comment-thread routing", () => {
accountId: "main",
});
expect(replyCommentMock).toHaveBeenCalledWith(
expect(deliverCommentThreadTextMock).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
file_token: "doxcn123",
@@ -288,7 +297,7 @@ describe("feishuOutbound comment-thread routing", () => {
accountId: "main",
});
expect(replyCommentMock).toHaveBeenCalledWith(
expect(deliverCommentThreadTextMock).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
content: "see attachment\n\nhttps://example.com/file.png",
@@ -297,6 +306,74 @@ describe("feishuOutbound comment-thread routing", () => {
expect(sendMediaFeishuMock).not.toHaveBeenCalled();
expect(result).toEqual(expect.objectContaining({ channel: "feishu", messageId: "reply_msg" }));
});
it("preserves comment-thread routing when deliverCommentThreadText falls back to add_comment", async () => {
deliverCommentThreadTextMock.mockResolvedValueOnce({
delivery_mode: "add_comment",
comment_id: "comment_msg",
reply_id: "reply_from_add_comment",
});
const result = await sendText({
cfg: emptyConfig,
to: "comment:docx:doxcn123:7623358762119646411",
text: "whole-comment follow-up",
accountId: "main",
});
expect(deliverCommentThreadTextMock).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
file_token: "doxcn123",
file_type: "docx",
comment_id: "7623358762119646411",
content: "whole-comment follow-up",
}),
);
expect(result).toEqual(
expect.objectContaining({
channel: "feishu",
messageId: "reply_from_add_comment",
}),
);
});
it("does not wait for ambient comment typing cleanup before sending comment-thread replies", async () => {
let resolveCleanup: ((value: boolean) => void) | undefined;
cleanupAmbientCommentTypingReactionMock.mockImplementationOnce(
() =>
new Promise<boolean>((resolve) => {
resolveCleanup = resolve;
}),
);
const sendPromise = sendText({
cfg: emptyConfig,
to: "comment:docx:doxcn123:7623358762119646411",
text: "handled in thread",
replyToId: "reply_ambient_1",
accountId: "main",
});
const status = await Promise.race([
sendPromise.then(() => "done"),
new Promise<string>((resolve) => setTimeout(() => resolve("pending"), 0)),
]);
expect(status).toBe("done");
expect(deliverCommentThreadTextMock).toHaveBeenCalled();
expect(cleanupAmbientCommentTypingReactionMock).toHaveBeenCalledWith({
client: expect.anything(),
deliveryContext: {
channel: "feishu",
to: "comment:docx:doxcn123:7623358762119646411",
threadId: "reply_ambient_1",
},
});
resolveCleanup?.(false);
await sendPromise;
});
});
describe("feishuOutbound.sendText replyToId forwarding", () => {

View File

@@ -4,8 +4,9 @@ import { createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
import { resolveFeishuAccount } from "./accounts.js";
import { createFeishuClient } from "./client.js";
import { cleanupAmbientCommentTypingReaction } from "./comment-reaction.js";
import { parseFeishuCommentTarget } from "./comment-target.js";
import { replyComment } from "./drive.js";
import { deliverCommentThreadText } from "./drive.js";
import { sendMediaFeishu } from "./media.js";
import { chunkTextForOutbound, type ChannelOutboundAdapter } from "./outbound-runtime-api.js";
import { sendMarkdownCardFeishu, sendMessageFeishu, sendStructuredCardFeishu } from "./send.js";
@@ -80,6 +81,7 @@ async function sendCommentThreadReply(params: {
cfg: Parameters<typeof sendMessageFeishu>[0]["cfg"];
to: string;
text: string;
replyId?: string;
accountId?: string;
}) {
const target = parseFeishuCommentTarget(params.to);
@@ -88,17 +90,34 @@ async function sendCommentThreadReply(params: {
}
const account = resolveFeishuAccount({ cfg: params.cfg, accountId: params.accountId });
const client = createFeishuClient(account);
const result = await replyComment(client, {
file_token: target.fileToken,
file_type: target.fileType,
comment_id: target.commentId,
content: params.text,
});
return {
messageId: typeof result.reply_id === "string" ? result.reply_id : "",
chatId: target.commentId,
result,
};
const replyId = params.replyId?.trim();
try {
const result = await deliverCommentThreadText(client, {
file_token: target.fileToken,
file_type: target.fileType,
comment_id: target.commentId,
content: params.text,
});
return {
messageId:
(typeof result.reply_id === "string" && result.reply_id) ||
(typeof result.comment_id === "string" && result.comment_id) ||
"",
chatId: target.commentId,
result,
};
} finally {
if (replyId) {
void cleanupAmbientCommentTypingReaction({
client,
deliveryContext: {
channel: "feishu",
to: params.to,
threadId: replyId,
},
});
}
}
}
async function sendOutboundText(params: {
@@ -113,6 +132,7 @@ async function sendOutboundText(params: {
cfg,
to,
text,
replyId: replyToMessageId,
accountId,
});
if (commentResult) {

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/firecrawl-plugin",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Firecrawl plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/fireworks-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Fireworks provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/github-copilot-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw GitHub Copilot provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/google-plugin",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Google plugin",
"type": "module",

View File

@@ -67,12 +67,13 @@ describe("google video generation provider", () => {
audio: true,
});
expect(generateVideosMock).toHaveBeenCalledWith(
expect(generateVideosMock).toHaveBeenCalledTimes(1);
const [request] = generateVideosMock.mock.calls[0] ?? [];
expect(request).toEqual(
expect.objectContaining({
model: "veo-3.1-fast-generate-preview",
prompt: "A tiny robot watering a windowsill garden",
config: expect.objectContaining({
numberOfVideos: 1,
durationSeconds: 4,
aspectRatio: "16:9",
resolution: "720p",
@@ -80,6 +81,7 @@ describe("google video generation provider", () => {
}),
}),
);
expect(request?.config).not.toHaveProperty("numberOfVideos");
expect(result.videos).toHaveLength(1);
expect(result.videos[0]?.mimeType).toBe("video/mp4");
expect(GoogleGenAIMock).toHaveBeenCalledWith(

View File

@@ -238,7 +238,6 @@ export function buildGoogleVideoGenerationProvider(): VideoGenerationProvider {
image: resolveInputImage(req),
video: resolveInputVideo(req),
config: {
numberOfVideos: 1,
...(typeof durationSeconds === "number" ? { durationSeconds } : {}),
...(resolveAspectRatio({ aspectRatio: req.aspectRatio, size: req.size })
? { aspectRatio: resolveAspectRatio({ aspectRatio: req.aspectRatio, size: req.size }) }

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/googlechat",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Google Chat channel plugin",
"type": "module",
@@ -12,7 +12,7 @@
"openclaw": "workspace:*"
},
"peerDependencies": {
"openclaw": ">=2026.4.10"
"openclaw": ">=2026.4.11"
},
"peerDependenciesMeta": {
"openclaw": {
@@ -43,7 +43,7 @@
"install": {
"npmSpec": "@openclaw/googlechat",
"defaultChoice": "npm",
"minHostVersion": ">=2026.4.10"
"minHostVersion": ">=2026.4.11"
}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/groq-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Groq media-understanding provider",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/huggingface-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Hugging Face provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/image-generation-core",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw image generation runtime package",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/imessage",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw iMessage channel plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/irc",
"version": "2026.4.10",
"version": "2026.4.11",
"description": "OpenClaw IRC channel plugin",
"type": "module",
"devDependencies": {
@@ -11,7 +11,7 @@
"./index.ts"
],
"install": {
"minHostVersion": ">=2026.4.10"
"minHostVersion": ">=2026.4.11"
},
"setupEntry": "./setup-entry.ts",
"channel": {

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/kilocode-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Kilo Gateway provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/kimi-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw Kimi provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/line",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw LINE channel plugin",
"type": "module",
@@ -9,7 +9,7 @@
"openclaw": "workspace:*"
},
"peerDependencies": {
"openclaw": ">=2026.4.10"
"openclaw": ">=2026.4.11"
},
"peerDependenciesMeta": {
"openclaw": {
@@ -36,7 +36,7 @@
"install": {
"npmSpec": "@openclaw/line",
"defaultChoice": "npm",
"minHostVersion": ">=2026.4.10"
"minHostVersion": ">=2026.4.11"
}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/litellm-provider",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw LiteLLM provider plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/llm-task",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw JSON-only LLM task plugin",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/lobster",
"version": "2026.4.10",
"version": "2026.4.11",
"description": "Lobster workflow tool plugin (typed pipelines + resumable approvals)",
"type": "module",
"dependencies": {
@@ -15,10 +15,10 @@
"./index.ts"
],
"compat": {
"pluginApi": ">=2026.4.10"
"pluginApi": ">=2026.4.11"
},
"build": {
"openclawVersion": "2026.4.10"
"openclawVersion": "2026.4.11"
},
"release": {
"publishToClawHub": true,

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/matrix",
"version": "2026.4.10",
"version": "2026.4.11",
"description": "OpenClaw Matrix channel plugin",
"type": "module",
"dependencies": {
@@ -16,7 +16,7 @@
"openclaw": "workspace:*"
},
"peerDependencies": {
"openclaw": ">=2026.4.10"
"openclaw": ">=2026.4.11"
},
"peerDependenciesMeta": {
"openclaw": {
@@ -45,7 +45,7 @@
"install": {
"npmSpec": "@openclaw/matrix",
"defaultChoice": "npm",
"minHostVersion": ">=2026.4.10",
"minHostVersion": ">=2026.4.11",
"allowInvalidConfigRecovery": true
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/mattermost",
"version": "2026.4.10",
"version": "2026.4.11",
"description": "OpenClaw Mattermost channel plugin",
"type": "module",
"dependencies": {
@@ -12,7 +12,7 @@
"openclaw": "workspace:*"
},
"peerDependencies": {
"openclaw": ">=2026.4.10"
"openclaw": ">=2026.4.11"
},
"peerDependenciesMeta": {
"openclaw": {
@@ -36,7 +36,7 @@
"install": {
"npmSpec": "@openclaw/mattermost",
"defaultChoice": "npm",
"minHostVersion": ">=2026.4.10"
"minHostVersion": ">=2026.4.11"
}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/media-understanding-core",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw media understanding runtime package",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/memory-core",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw core memory search plugin",
"type": "module",
@@ -9,7 +9,7 @@
"openclaw": "workspace:*"
},
"peerDependencies": {
"openclaw": ">=2026.4.10"
"openclaw": ">=2026.4.11"
},
"peerDependenciesMeta": {
"openclaw": {

View File

@@ -1,7 +1,4 @@
export function resolveMemorySearchPreflight(params: {
query: string;
hasIndexedContent: boolean;
}):
export function resolveMemorySearchPreflight(params: { query: string; hasIndexedContent: boolean }):
| {
normalizedQuery: string;
shouldInitializeProvider: boolean;

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/memory-lancedb",
"version": "2026.4.10",
"version": "2026.4.11",
"description": "OpenClaw LanceDB-backed long-term memory plugin with auto-recall/capture",
"type": "module",
"dependencies": {
@@ -18,13 +18,13 @@
"install": {
"npmSpec": "@openclaw/memory-lancedb",
"defaultChoice": "npm",
"minHostVersion": ">=2026.4.10"
"minHostVersion": ">=2026.4.11"
},
"compat": {
"pluginApi": ">=2026.4.10"
"pluginApi": ">=2026.4.11"
},
"build": {
"openclawVersion": "2026.4.10"
"openclawVersion": "2026.4.11"
},
"release": {
"publishToClawHub": true,

View File

@@ -21,6 +21,9 @@ describe("memory-wiki plugin", () => {
expect(registerMemoryPromptSupplement).toHaveBeenCalledTimes(1);
expect(registerGatewayMethod.mock.calls.map((call) => call[0])).toEqual([
"wiki.status",
"wiki.importRuns",
"wiki.importInsights",
"wiki.palace",
"wiki.init",
"wiki.doctor",
"wiki.compile",

View File

@@ -1,6 +1,6 @@
{
"name": "@openclaw/memory-wiki",
"version": "2026.4.10",
"version": "2026.4.11",
"private": true,
"description": "OpenClaw persistent wiki plugin",
"type": "module",
@@ -12,7 +12,7 @@
"openclaw": "workspace:*"
},
"peerDependencies": {
"openclaw": ">=2026.4.10"
"openclaw": ">=2026.4.11"
},
"peerDependenciesMeta": {
"openclaw": {

View File

@@ -0,0 +1,903 @@
import { createHash } from "node:crypto";
import fs from "node:fs/promises";
import path from "node:path";
import {
replaceManagedMarkdownBlock,
withTrailingNewline,
} from "openclaw/plugin-sdk/memory-host-markdown";
import { compileMemoryWikiVault } from "./compile.js";
import type { ResolvedMemoryWikiConfig } from "./config.js";
import { appendMemoryWikiLog } from "./log.js";
import {
parseWikiMarkdown,
renderWikiMarkdown,
WIKI_RELATED_END_MARKER,
WIKI_RELATED_START_MARKER,
} from "./markdown.js";
import { initializeMemoryWikiVault } from "./vault.js";
const CHATGPT_PREFERENCE_SIGNAL_RE =
/\b(prefer|prefers|preference|want|wants|need|needs|avoid|avoids|hate|hates|love|loves|default to|should default to|always use|don't want|does not want|likes|dislikes)\b/i;
const HUMAN_START_MARKER = "<!-- openclaw:human:start -->";
const HUMAN_END_MARKER = "<!-- openclaw:human:end -->";
const CHATGPT_RISK_RULES: Array<{ label: string; pattern: RegExp }> = [
{
label: "relationships",
pattern:
/\b(relationship|dating|breakup|jealous|sex|intimacy|partner|apology|trust|boyfriend|girlfriend|husband|wife)\b/i,
},
{
label: "health",
pattern:
/\b(supplement|medication|diagnosis|symptom|therapy|depression|anxiety|mri|migraine|injury|pain|cortisol|sleep)\b/i,
},
{
label: "legal_tax",
pattern:
/\b(contract|tax|legal|law|lawsuit|visa|immigration|license|insurance|claim|non-residence|residency)\b/i,
},
{
label: "finance",
pattern:
/\b(investment|invest|portfolio|dividend|yield|coupon|valuation|mortgage|loan|crypto|covered call|call option|put option)\b/i,
},
{
label: "drugs",
pattern: /\b(vape|weed|cannabis|nicotine|opioid|ketamine)\b/i,
},
];
type ChatGptMessage = {
role: string;
text: string;
};
type ChatGptRiskAssessment = {
level: "low" | "medium" | "high";
reasons: string[];
};
type ChatGptConversationRecord = {
conversationId: string;
title: string;
createdAt?: string;
updatedAt?: string;
sourcePath: string;
pageId: string;
pagePath: string;
labels: string[];
risk: ChatGptRiskAssessment;
userMessageCount: number;
assistantMessageCount: number;
preferenceSignals: string[];
firstUserLine?: string;
lastUserLine?: string;
transcript: ChatGptMessage[];
};
type ChatGptImportOperation = "create" | "update" | "skip";
export type ChatGptImportAction = {
conversationId: string;
title: string;
pagePath: string;
operation: ChatGptImportOperation;
riskLevel: ChatGptRiskAssessment["level"];
labels: string[];
userMessageCount: number;
assistantMessageCount: number;
preferenceSignals: string[];
};
type ChatGptImportRunEntry = {
path: string;
snapshotPath?: string;
};
type ChatGptImportRunRecord = {
version: 1;
runId: string;
importType: "chatgpt";
exportPath: string;
sourcePath: string;
appliedAt: string;
conversationCount: number;
createdCount: number;
updatedCount: number;
skippedCount: number;
createdPaths: string[];
updatedPaths: ChatGptImportRunEntry[];
rolledBackAt?: string;
};
export type ChatGptImportResult = {
dryRun: boolean;
exportPath: string;
sourcePath: string;
conversationCount: number;
createdCount: number;
updatedCount: number;
skippedCount: number;
actions: ChatGptImportAction[];
pagePaths: string[];
runId?: string;
indexUpdatedFiles: string[];
};
export type ChatGptRollbackResult = {
runId: string;
removedCount: number;
restoredCount: number;
pagePaths: string[];
indexUpdatedFiles: string[];
alreadyRolledBack: boolean;
};
function asRecord(value: unknown): Record<string, unknown> | null {
if (!value || typeof value !== "object" || Array.isArray(value)) {
return null;
}
return value as Record<string, unknown>;
}
function normalizeWhitespace(value: string): string {
return value.trim().replace(/\s+/g, " ");
}
function resolveConversationSourcePath(exportInputPath: string): {
exportPath: string;
conversationsPath: string;
} {
const resolved = path.resolve(exportInputPath);
const conversationsPath = resolved.endsWith(".json")
? resolved
: path.join(resolved, "conversations.json");
return {
exportPath: resolved,
conversationsPath,
};
}
async function loadConversations(exportInputPath: string): Promise<{
exportPath: string;
conversationsPath: string;
conversations: Record<string, unknown>[];
}> {
const { exportPath, conversationsPath } = resolveConversationSourcePath(exportInputPath);
const raw = await fs.readFile(conversationsPath, "utf8");
const parsed = JSON.parse(raw) as unknown;
if (Array.isArray(parsed)) {
return {
exportPath,
conversationsPath,
conversations: parsed.filter(
(entry): entry is Record<string, unknown> => asRecord(entry) !== null,
),
};
}
const record = asRecord(parsed);
if (record) {
for (const value of Object.values(record)) {
if (Array.isArray(value)) {
return {
exportPath,
conversationsPath,
conversations: value.filter(
(entry): entry is Record<string, unknown> => asRecord(entry) !== null,
),
};
}
}
}
throw new Error(`Unrecognized ChatGPT conversations export format: ${conversationsPath}`);
}
function isoFromUnix(raw: unknown): string | undefined {
if (typeof raw !== "number" && typeof raw !== "string") {
return undefined;
}
const numeric = Number(raw);
if (!Number.isFinite(numeric)) {
return undefined;
}
return new Date(numeric * 1000).toISOString();
}
function cleanMessageText(value: string): string {
const trimmed = value.trim();
if (!trimmed) {
return "";
}
if (
(trimmed.includes("asset_pointer") ||
trimmed.includes("image_asset_pointer") ||
trimmed.includes("dalle") ||
trimmed.includes("file_service")) &&
trimmed.length > 40
) {
return "";
}
if (
trimmed.startsWith("{") &&
trimmed.length > 80 &&
(trimmed.includes(":") || trimmed.includes("content_type"))
) {
const textMatch = trimmed.match(/["']text["']\s*:\s*(["'])(.+?)\1/s);
return textMatch?.[2] ? normalizeWhitespace(textMatch[2]) : "";
}
return trimmed;
}
function extractMessageText(message: Record<string, unknown>): string {
const content = asRecord(message.content);
if (content) {
const parts = content.parts;
if (Array.isArray(parts)) {
const collected: string[] = [];
for (const part of parts) {
if (typeof part === "string") {
const cleaned = cleanMessageText(part);
if (cleaned) {
collected.push(cleaned);
}
continue;
}
const partRecord = asRecord(part);
if (partRecord && typeof partRecord.text === "string" && partRecord.text.trim()) {
collected.push(partRecord.text.trim());
}
}
return collected.join("\n").trim();
}
if (typeof content.text === "string") {
return cleanMessageText(content.text);
}
}
return typeof message.text === "string" ? cleanMessageText(message.text) : "";
}
function activeBranchMessages(conversation: Record<string, unknown>): ChatGptMessage[] {
const mapping = asRecord(conversation.mapping);
if (!mapping) {
return [];
}
let currentNode =
typeof conversation.current_node === "string" ? conversation.current_node : undefined;
const seen = new Set<string>();
const chain: ChatGptMessage[] = [];
while (currentNode && !seen.has(currentNode)) {
seen.add(currentNode);
const node = asRecord(mapping[currentNode]);
if (!node) {
break;
}
const message = asRecord(node.message);
if (message) {
const author = asRecord(message.author);
const role = typeof author?.role === "string" ? author.role : "unknown";
const text = extractMessageText(message);
if (text) {
chain.push({ role, text });
}
}
currentNode = typeof node.parent === "string" ? node.parent : undefined;
}
return chain.toReversed();
}
function inferRisk(title: string, sampleText: string): ChatGptRiskAssessment {
const blob = `${title}\n${sampleText}`.toLowerCase();
const reasons = CHATGPT_RISK_RULES.filter((rule) => rule.pattern.test(blob)).map(
(rule) => rule.label,
);
if (reasons.length > 0) {
return { level: "high", reasons: [...new Set(reasons)] };
}
if (/\b(career|job|salary|interview|offer|resume|cover letter)\b/i.test(blob)) {
return { level: "medium", reasons: ["work_career"] };
}
return { level: "low", reasons: [] };
}
function inferLabels(title: string, sampleText: string): string[] {
const blob = `${title}\n${sampleText}`.toLowerCase();
const labels = new Set<string>(["domain/personal"]);
const addAreaTopic = (area: string, topics: string[]) => {
labels.add(area);
for (const topic of topics) {
labels.add(topic);
}
};
const hasTranslation =
/\b(translate|translation|traduc\w*|traducc\w*|traduç\w*|traducci[oó]n|traduccio|traducció|traduzione)\b/i.test(
blob,
);
const hasLearning =
/\b(anki|flashcards?|grammar|conjugat\w*|declension|pronunciation|vocab(?:ular(?:y|io))?|lesson|tutor|teacher|jlpt|kanji|hiragana|katakana|study|learn|practice)\b/i.test(
blob,
);
const hasLanguageName =
/\b(japanese|portuguese|catalan|castellano|espa[nñ]ol|franc[eé]s|french|italian|german|spanish)\b/i.test(
blob,
);
if (hasTranslation) {
labels.add("topic/translation");
}
if (
hasLearning ||
(hasLanguageName && /\b(learn|study|practice|lesson|tutor|grammar)\b/i.test(blob))
) {
addAreaTopic("area/language-learning", ["topic/language-learning"]);
}
if (
/\b(hike|trail|hotel|flight|trip|travel|airport|itinerary|booking|airbnb|train|stay)\b/i.test(
blob,
)
) {
labels.add("area/travel");
labels.add("topic/travel");
}
if (
/\b(recipe|cook|cooking|bread|sourdough|pizza|espresso|coffee|mousse|cast iron|meatballs?)\b/i.test(
blob,
)
) {
addAreaTopic("area/cooking", ["topic/cooking"]);
}
if (
/\b(garden|orchard|plant|soil|compost|agroforestry|permaculture|mulch|beds?|irrigation|seeds?)\b/i.test(
blob,
)
) {
addAreaTopic("area/gardening", ["topic/gardening"]);
}
if (/\b(dating|relationship|partner|jealous|breakup|trust)\b/i.test(blob)) {
addAreaTopic("area/relationships", ["topic/relationships"]);
}
if (
/\b(investment|invest|portfolio|dividend|yield|coupon|valuation|return|mortgage|loan|kraken|crypto|covered call|call option|put option|option chain|bond|stocks?)\b/i.test(
blob,
)
) {
addAreaTopic("area/finance", ["topic/finance"]);
}
if (
/\b(contract|mou|tax|impuesto|legal|law|lawsuit|visa|immigration|license|licencia|dispute|claim|insurance|non-residence|residency)\b/i.test(
blob,
)
) {
addAreaTopic("area/legal-tax", ["topic/legal-tax"]);
}
if (
/\b(supplement|medication|diagnos(?:is|e)|symptom|therapy|depress(?:ion|ed)|anxiet(?:y|ies)|mri|migraine|injur(?:y|ies)|pain|cortisol|sleep|dentist|dermatolog(?:ist|y))\b/i.test(
blob,
)
) {
addAreaTopic("area/health", ["topic/health"]);
}
if (
/\b(book (an )?appointment|rebook|open (a )?new account|driving test|exam|gestor(?:a)?|itv)\b/i.test(
blob,
)
) {
addAreaTopic("area/life-admin", ["topic/life-admin"]);
}
if (/\b(frc|robot|robotics|wpilib|limelight|chiefdelphi)\b/i.test(blob)) {
addAreaTopic("area/work", ["topic/robotics"]);
} else if (
/\b(docker|git|python|node|npm|pip|sql|postgres|api|bug|stack trace|permission denied)\b/i.test(
blob,
)
) {
addAreaTopic("area/work", ["topic/software"]);
} else if (/\b(job|interview|cover letter|resume|cv)\b/i.test(blob)) {
addAreaTopic("area/work", ["topic/career"]);
}
if (/\b(wifi|wi-fi|starlink|router|mesh|network|orbi|milesight|coverage)\b/i.test(blob)) {
addAreaTopic("area/home", ["topic/home-infrastructure"]);
}
if (
/\b(p38|range rover|porsche|bmw|bobcat|excavator|auger|trailer|chainsaw|stihl)\b/i.test(blob)
) {
addAreaTopic("area/vehicles", ["topic/vehicles"]);
}
if (![...labels].some((label) => label.startsWith("area/"))) {
labels.add("area/other");
}
return [...labels];
}
function collectPreferenceSignals(userTexts: string[]): string[] {
const signals: string[] = [];
const seen = new Set<string>();
for (const text of userTexts.slice(0, 25)) {
for (const rawLine of text.split(/\r?\n/)) {
const line = normalizeWhitespace(rawLine);
if (!line || !CHATGPT_PREFERENCE_SIGNAL_RE.test(line)) {
continue;
}
const key = line.toLowerCase();
if (seen.has(key)) {
continue;
}
seen.add(key);
signals.push(line);
if (signals.length >= 10) {
return signals;
}
}
}
return signals;
}
function buildTranscript(messages: ChatGptMessage[]): string {
if (messages.length === 0) {
return "_No active-branch transcript could be reconstructed._";
}
return messages
.flatMap((message) => [
`### ${message.role[0]?.toUpperCase() ?? "U"}${message.role.slice(1)}`,
"",
message.text,
"",
])
.join("\n")
.trim();
}
function resolveConversationPagePath(record: { conversationId: string; createdAt?: string }): {
pageId: string;
pagePath: string;
} {
const conversationSlug = record.conversationId.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
const pageId = `source.chatgpt.${conversationSlug || createHash("sha1").update(record.conversationId).digest("hex").slice(0, 12)}`;
const datePrefix = record.createdAt?.slice(0, 10) ?? "undated";
const shortId = conversationSlug.slice(0, 8) || "export";
return {
pageId,
pagePath: path
.join("sources", `chatgpt-${datePrefix}-${conversationSlug || shortId}.md`)
.replace(/\\/g, "/"),
};
}
function toConversationRecord(
conversation: Record<string, unknown>,
sourcePath: string,
): ChatGptConversationRecord | null {
const conversationId =
typeof conversation.conversation_id === "string" ? conversation.conversation_id.trim() : "";
if (!conversationId) {
return null;
}
const title =
typeof conversation.title === "string" && conversation.title.trim()
? conversation.title.trim()
: "Untitled conversation";
const transcript = activeBranchMessages(conversation);
const userTexts = transcript.filter((entry) => entry.role === "user").map((entry) => entry.text);
const assistantTexts = transcript.filter((entry) => entry.role === "assistant");
const sampleText = userTexts.slice(0, 6).join("\n");
const risk = inferRisk(title, sampleText);
const labels = inferLabels(title, sampleText);
const { pageId, pagePath } = resolveConversationPagePath({
conversationId,
createdAt: isoFromUnix(conversation.create_time),
});
return {
conversationId,
title,
createdAt: isoFromUnix(conversation.create_time),
updatedAt: isoFromUnix(conversation.update_time) ?? isoFromUnix(conversation.create_time),
sourcePath,
pageId,
pagePath,
labels,
risk,
userMessageCount: userTexts.length,
assistantMessageCount: assistantTexts.length,
preferenceSignals: risk.level === "low" ? collectPreferenceSignals(userTexts) : [],
firstUserLine: userTexts[0]?.split(/\r?\n/)[0]?.trim(),
lastUserLine: userTexts.at(-1)?.split(/\r?\n/)[0]?.trim(),
transcript,
};
}
function renderConversationPage(record: ChatGptConversationRecord): string {
const autoDigestLines =
record.risk.level === "low"
? [
`- User messages: ${record.userMessageCount}`,
`- Assistant messages: ${record.assistantMessageCount}`,
...(record.firstUserLine ? [`- First user line: ${record.firstUserLine}`] : []),
...(record.lastUserLine ? [`- Last user line: ${record.lastUserLine}`] : []),
...(record.preferenceSignals.length > 0
? ["- Preference signals:", ...record.preferenceSignals.map((line) => ` - ${line}`)]
: ["- Preference signals: none detected"]),
]
: [
"- Auto digest withheld from durable-candidate generation until reviewed.",
`- Risk reasons: ${record.risk.reasons.length > 0 ? record.risk.reasons.join(", ") : "none recorded"}`,
];
return renderWikiMarkdown({
frontmatter: {
pageType: "source",
id: record.pageId,
title: `ChatGPT Export: ${record.title}`,
sourceType: "chatgpt-export",
sourceSystem: "chatgpt",
sourcePath: record.sourcePath,
conversationId: record.conversationId,
riskLevel: record.risk.level,
riskReasons: record.risk.reasons,
labels: record.labels,
status: "draft",
...(record.createdAt ? { createdAt: record.createdAt } : {}),
...(record.updatedAt ? { updatedAt: record.updatedAt } : {}),
},
body: [
`# ChatGPT Export: ${record.title}`,
"",
"## Source",
`- Conversation id: \`${record.conversationId}\``,
`- Export file: \`${record.sourcePath}\``,
...(record.createdAt ? [`- Created: ${record.createdAt}`] : []),
...(record.updatedAt ? [`- Updated: ${record.updatedAt}`] : []),
"",
"## Auto Triage",
`- Risk level: \`${record.risk.level}\``,
`- Labels: ${record.labels.join(", ")}`,
`- Active-branch messages: ${record.transcript.length}`,
"",
"## Auto Digest",
...autoDigestLines,
"",
"## Active Branch Transcript",
buildTranscript(record.transcript),
"",
"## Notes",
HUMAN_START_MARKER,
HUMAN_END_MARKER,
"",
].join("\n"),
});
}
function replaceSimpleManagedBlock(params: {
original: string;
startMarker: string;
endMarker: string;
replacement: string;
}): string {
const escapedStart = params.startMarker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const escapedEnd = params.endMarker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const blockPattern = new RegExp(`${escapedStart}[\\s\\S]*?${escapedEnd}`);
return params.original.replace(blockPattern, params.replacement);
}
function extractSimpleManagedBlock(params: {
body: string;
startMarker: string;
endMarker: string;
}): string | null {
const escapedStart = params.startMarker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const escapedEnd = params.endMarker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const blockPattern = new RegExp(`${escapedStart}[\\s\\S]*?${escapedEnd}`);
return params.body.match(blockPattern)?.[0] ?? null;
}
function extractManagedBlockBody(params: {
body: string;
startMarker: string;
endMarker: string;
}): string | null {
const escapedStart = params.startMarker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const escapedEnd = params.endMarker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const blockPattern = new RegExp(`${escapedStart}\\n?([\\s\\S]*?)\\n?${escapedEnd}`);
const captured = params.body.match(blockPattern)?.[1];
return typeof captured === "string" ? captured.trim() : null;
}
function preserveExistingPageBlocks(rendered: string, existing: string): string {
if (!existing.trim()) {
return withTrailingNewline(rendered);
}
const parsedExisting = parseWikiMarkdown(existing);
const parsedRendered = parseWikiMarkdown(rendered);
let nextBody = parsedRendered.body;
const humanBlock = extractSimpleManagedBlock({
body: parsedExisting.body,
startMarker: HUMAN_START_MARKER,
endMarker: HUMAN_END_MARKER,
});
if (humanBlock) {
nextBody = replaceSimpleManagedBlock({
original: nextBody,
startMarker: HUMAN_START_MARKER,
endMarker: HUMAN_END_MARKER,
replacement: humanBlock,
});
}
const relatedBody = extractManagedBlockBody({
body: parsedExisting.body,
startMarker: WIKI_RELATED_START_MARKER,
endMarker: WIKI_RELATED_END_MARKER,
});
if (relatedBody) {
nextBody = replaceManagedMarkdownBlock({
original: nextBody,
heading: "## Related",
startMarker: WIKI_RELATED_START_MARKER,
endMarker: WIKI_RELATED_END_MARKER,
body: relatedBody,
});
}
return withTrailingNewline(
renderWikiMarkdown({
frontmatter: parsedRendered.frontmatter,
body: nextBody,
}),
);
}
function buildRunId(exportPath: string, nowIso: string): string {
const seed = `${exportPath}:${nowIso}:${Math.random()}`;
return `chatgpt-${createHash("sha1").update(seed).digest("hex").slice(0, 12)}`;
}
function resolveImportRunsDir(vaultRoot: string): string {
return path.join(vaultRoot, ".openclaw-wiki", "import-runs");
}
function resolveImportRunPath(vaultRoot: string, runId: string): string {
return path.join(resolveImportRunsDir(vaultRoot), `${runId}.json`);
}
function normalizeConversationActions(
records: ChatGptConversationRecord[],
operations: Map<string, ChatGptImportOperation>,
): ChatGptImportAction[] {
return records.map((record) => ({
conversationId: record.conversationId,
title: record.title,
pagePath: record.pagePath,
operation: operations.get(record.pagePath) ?? "skip",
riskLevel: record.risk.level,
labels: record.labels,
userMessageCount: record.userMessageCount,
assistantMessageCount: record.assistantMessageCount,
preferenceSignals: record.preferenceSignals,
}));
}
async function writeImportRunRecord(
vaultRoot: string,
record: ChatGptImportRunRecord,
): Promise<void> {
const recordPath = resolveImportRunPath(vaultRoot, record.runId);
await fs.mkdir(path.dirname(recordPath), { recursive: true });
await fs.writeFile(recordPath, `${JSON.stringify(record, null, 2)}\n`, "utf8");
}
async function readImportRunRecord(
vaultRoot: string,
runId: string,
): Promise<ChatGptImportRunRecord> {
const recordPath = resolveImportRunPath(vaultRoot, runId);
const raw = await fs.readFile(recordPath, "utf8");
return JSON.parse(raw) as ChatGptImportRunRecord;
}
async function writeTrackedImportPage(params: {
vaultRoot: string;
runDir: string;
relativePath: string;
content: string;
record: ChatGptImportRunRecord;
}): Promise<ChatGptImportOperation> {
const absolutePath = path.join(params.vaultRoot, params.relativePath);
const existing = await fs.readFile(absolutePath, "utf8").catch(() => "");
const rendered = preserveExistingPageBlocks(params.content, existing);
if (existing === rendered) {
return "skip";
}
await fs.mkdir(path.dirname(absolutePath), { recursive: true });
if (!existing) {
await fs.writeFile(absolutePath, rendered, "utf8");
params.record.createdPaths.push(params.relativePath);
return "create";
}
const snapshotHash = createHash("sha1").update(params.relativePath).digest("hex").slice(0, 12);
const snapshotRelativePath = path.join("snapshots", `${snapshotHash}.md`).replace(/\\/g, "/");
const snapshotAbsolutePath = path.join(params.runDir, snapshotRelativePath);
await fs.mkdir(path.dirname(snapshotAbsolutePath), { recursive: true });
await fs.writeFile(snapshotAbsolutePath, existing, "utf8");
await fs.writeFile(absolutePath, rendered, "utf8");
params.record.updatedPaths.push({
path: params.relativePath,
snapshotPath: snapshotRelativePath,
});
return "update";
}
export async function importChatGptConversations(params: {
config: ResolvedMemoryWikiConfig;
exportPath: string;
dryRun?: boolean;
nowMs?: number;
}): Promise<ChatGptImportResult> {
await initializeMemoryWikiVault(params.config, { nowMs: params.nowMs });
const { exportPath, conversationsPath, conversations } = await loadConversations(
params.exportPath,
);
const records = conversations
.map((conversation) => toConversationRecord(conversation, conversationsPath))
.filter((entry): entry is ChatGptConversationRecord => entry !== null)
.toSorted((left, right) => left.pagePath.localeCompare(right.pagePath));
const operations = new Map<string, ChatGptImportOperation>();
let createdCount = 0;
let updatedCount = 0;
let skippedCount = 0;
let runId: string | undefined;
const nowIso = new Date(params.nowMs ?? Date.now()).toISOString();
let importRunRecord: ChatGptImportRunRecord | undefined;
let importRunDir = "";
if (!params.dryRun) {
runId = buildRunId(exportPath, nowIso);
importRunDir = path.join(resolveImportRunsDir(params.config.vault.path), runId);
importRunRecord = {
version: 1,
runId,
importType: "chatgpt",
exportPath,
sourcePath: conversationsPath,
appliedAt: nowIso,
conversationCount: records.length,
createdCount: 0,
updatedCount: 0,
skippedCount: 0,
createdPaths: [],
updatedPaths: [],
};
}
for (const record of records) {
const rendered = renderConversationPage(record);
const absolutePath = path.join(params.config.vault.path, record.pagePath);
const existing = await fs.readFile(absolutePath, "utf8").catch(() => "");
const stabilized = preserveExistingPageBlocks(rendered, existing);
const operation: ChatGptImportOperation =
existing === stabilized ? "skip" : existing ? "update" : "create";
operations.set(record.pagePath, operation);
if (operation === "create") {
createdCount += 1;
} else if (operation === "update") {
updatedCount += 1;
} else {
skippedCount += 1;
}
if (!params.dryRun && importRunRecord) {
await writeTrackedImportPage({
vaultRoot: params.config.vault.path,
runDir: importRunDir,
relativePath: record.pagePath,
content: rendered,
record: importRunRecord,
});
}
}
let indexUpdatedFiles: string[] = [];
if (!params.dryRun && importRunRecord) {
importRunRecord.createdCount = createdCount;
importRunRecord.updatedCount = updatedCount;
importRunRecord.skippedCount = skippedCount;
if (importRunRecord.createdPaths.length > 0 || importRunRecord.updatedPaths.length > 0) {
const compile = await compileMemoryWikiVault(params.config);
indexUpdatedFiles = compile.updatedFiles;
await writeImportRunRecord(params.config.vault.path, importRunRecord);
await appendMemoryWikiLog(params.config.vault.path, {
type: "ingest",
timestamp: nowIso,
details: {
sourceType: "chatgpt-export",
runId: importRunRecord.runId,
exportPath,
sourcePath: conversationsPath,
conversationCount: records.length,
createdCount: importRunRecord.createdPaths.length,
updatedCount: importRunRecord.updatedPaths.length,
skippedCount,
},
});
} else {
runId = undefined;
}
}
return {
dryRun: Boolean(params.dryRun),
exportPath,
sourcePath: conversationsPath,
conversationCount: records.length,
createdCount,
updatedCount,
skippedCount,
actions: normalizeConversationActions(records, operations),
pagePaths: records.map((record) => record.pagePath),
...(runId ? { runId } : {}),
indexUpdatedFiles,
};
}
export async function rollbackChatGptImportRun(params: {
config: ResolvedMemoryWikiConfig;
runId: string;
}): Promise<ChatGptRollbackResult> {
await initializeMemoryWikiVault(params.config);
const record = await readImportRunRecord(params.config.vault.path, params.runId);
if (record.rolledBackAt) {
return {
runId: record.runId,
removedCount: 0,
restoredCount: 0,
pagePaths: [
...record.createdPaths,
...record.updatedPaths.map((entry) => entry.path),
].toSorted((left, right) => left.localeCompare(right)),
indexUpdatedFiles: [],
alreadyRolledBack: true,
};
}
let removedCount = 0;
for (const relativePath of record.createdPaths) {
await fs
.rm(path.join(params.config.vault.path, relativePath), { force: true })
.catch(() => undefined);
removedCount += 1;
}
let restoredCount = 0;
const runDir = path.join(resolveImportRunsDir(params.config.vault.path), record.runId);
for (const entry of record.updatedPaths) {
if (!entry.snapshotPath) {
continue;
}
const snapshotPath = path.join(runDir, entry.snapshotPath);
const snapshot = await fs.readFile(snapshotPath, "utf8");
const targetPath = path.join(params.config.vault.path, entry.path);
await fs.mkdir(path.dirname(targetPath), { recursive: true });
await fs.writeFile(targetPath, snapshot, "utf8");
restoredCount += 1;
}
const compile = await compileMemoryWikiVault(params.config);
record.rolledBackAt = new Date().toISOString();
await writeImportRunRecord(params.config.vault.path, record);
await appendMemoryWikiLog(params.config.vault.path, {
type: "ingest",
timestamp: record.rolledBackAt,
details: {
sourceType: "chatgpt-export",
runId: record.runId,
rollback: true,
removedCount,
restoredCount,
},
});
return {
runId: record.runId,
removedCount,
restoredCount,
pagePaths: [...record.createdPaths, ...record.updatedPaths.map((entry) => entry.path)].toSorted(
(left, right) => left.localeCompare(right),
),
indexUpdatedFiles: compile.updatedFiles,
alreadyRolledBack: false,
};
}

View File

@@ -3,7 +3,7 @@ import os from "node:os";
import path from "node:path";
import { Command } from "commander";
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { registerWikiCli } from "./cli.js";
import { registerWikiCli, runWikiChatGptImport, runWikiChatGptRollback } from "./cli.js";
import type { MemoryWikiPluginConfig } from "./config.js";
import { parseWikiMarkdown, renderWikiMarkdown } from "./markdown.js";
import { createMemoryWikiTestHarness } from "./test-helpers.js";
@@ -47,6 +47,47 @@ describe("memory-wiki cli", () => {
});
}
async function createChatGptExport(rootDir: string) {
const exportDir = path.join(rootDir, "chatgpt-export");
await fs.mkdir(exportDir, { recursive: true });
const conversations = [
{
conversation_id: "12345678-1234-1234-1234-1234567890ab",
title: "Travel preference check",
create_time: 1_712_363_200,
update_time: 1_712_366_800,
current_node: "assistant-1",
mapping: {
root: {},
"user-1": {
parent: "root",
message: {
author: { role: "user" },
content: {
parts: ["I prefer aisle seats and I don't want a hotel far from the airport."],
},
},
},
"assistant-1": {
parent: "user-1",
message: {
author: { role: "assistant" },
content: {
parts: ["Noted. I will keep travel options close to the airport."],
},
},
},
},
},
];
await fs.writeFile(
path.join(exportDir, "conversations.json"),
`${JSON.stringify(conversations, null, 2)}\n`,
"utf8",
);
return exportDir;
}
it("registers apply synthesis and writes a synthesis page", async () => {
const { rootDir, config } = await createCliVault();
const program = new Command();
@@ -153,4 +194,57 @@ cli note
expect(process.exitCode).toBe(1);
});
it("imports ChatGPT exports with dry-run, apply, and rollback", async () => {
const { rootDir, config } = await createCliVault({ initialize: true });
const exportDir = await createChatGptExport(rootDir);
const dryRun = await runWikiChatGptImport({
config,
exportPath: exportDir,
dryRun: true,
json: true,
});
expect(dryRun.dryRun).toBe(true);
expect(dryRun.createdCount).toBe(1);
await expect(fs.readdir(path.join(rootDir, "sources"))).resolves.toEqual([]);
const applied = await runWikiChatGptImport({
config,
exportPath: exportDir,
json: true,
});
expect(applied.runId).toBeTruthy();
expect(applied.createdCount).toBe(1);
const sourceFiles = (await fs.readdir(path.join(rootDir, "sources"))).filter(
(entry) => entry !== "index.md",
);
expect(sourceFiles).toHaveLength(1);
const pageContent = await fs.readFile(path.join(rootDir, "sources", sourceFiles[0]), "utf8");
expect(pageContent).toContain("ChatGPT Export: Travel preference check");
expect(pageContent).toContain("I prefer aisle seats");
expect(pageContent).toContain("Preference signals:");
const secondDryRun = await runWikiChatGptImport({
config,
exportPath: exportDir,
dryRun: true,
json: true,
});
expect(secondDryRun.createdCount).toBe(0);
expect(secondDryRun.updatedCount).toBe(0);
expect(secondDryRun.skippedCount).toBe(1);
const rollback = await runWikiChatGptRollback({
config,
runId: applied.runId!,
json: true,
});
expect(rollback.alreadyRolledBack).toBe(false);
await expect(
fs
.readdir(path.join(rootDir, "sources"))
.then((entries) => entries.filter((entry) => entry !== "index.md")),
).resolves.toEqual([]);
});
});

View File

@@ -2,6 +2,12 @@ import fs from "node:fs/promises";
import type { Command } from "commander";
import type { OpenClawConfig } from "../api.js";
import { applyMemoryWikiMutation } from "./apply.js";
import {
importChatGptConversations,
rollbackChatGptImportRun,
type ChatGptImportResult,
type ChatGptRollbackResult,
} from "./chatgpt-import.js";
import { compileMemoryWikiVault } from "./compile.js";
import {
resolveMemoryWikiConfig,
@@ -98,6 +104,16 @@ type WikiUnsafeLocalImportCommandOptions = {
json?: boolean;
};
type WikiChatGptImportCommandOptions = {
json?: boolean;
dryRun?: boolean;
export?: string;
};
type WikiChatGptRollbackCommandOptions = {
json?: boolean;
};
type WikiObsidianSearchCommandOptions = {
json?: boolean;
};
@@ -592,6 +608,59 @@ export async function runWikiObsidianDailyCli(params: {
});
}
function formatChatGptImportSummary(result: ChatGptImportResult): string {
if (result.dryRun) {
return `ChatGPT import dry run scanned ${result.conversationCount} conversations (${result.createdCount} new, ${result.updatedCount} updated, ${result.skippedCount} unchanged).`;
}
const runSuffix = result.runId ? ` Run id: ${result.runId}.` : "";
return `ChatGPT import applied ${result.conversationCount} conversations (${result.createdCount} new, ${result.updatedCount} updated, ${result.skippedCount} unchanged). Refreshed ${result.indexUpdatedFiles.length} index file${result.indexUpdatedFiles.length === 1 ? "" : "s"}.${runSuffix}`;
}
function formatChatGptRollbackSummary(result: ChatGptRollbackResult): string {
if (result.alreadyRolledBack) {
return `ChatGPT import run ${result.runId} was already rolled back.`;
}
return `Rolled back ChatGPT import run ${result.runId} (${result.removedCount} removed, ${result.restoredCount} restored). Refreshed ${result.indexUpdatedFiles.length} index file${result.indexUpdatedFiles.length === 1 ? "" : "s"}.`;
}
export async function runWikiChatGptImport(params: {
config: ResolvedMemoryWikiConfig;
exportPath: string;
dryRun?: boolean;
json?: boolean;
stdout?: Pick<NodeJS.WriteStream, "write">;
}) {
return runWikiCommandWithSummary({
json: params.json,
stdout: params.stdout,
run: () =>
importChatGptConversations({
config: params.config,
exportPath: params.exportPath,
dryRun: params.dryRun,
}),
render: formatChatGptImportSummary,
});
}
export async function runWikiChatGptRollback(params: {
config: ResolvedMemoryWikiConfig;
runId: string;
json?: boolean;
stdout?: Pick<NodeJS.WriteStream, "write">;
}) {
return runWikiCommandWithSummary({
json: params.json,
stdout: params.stdout,
run: () =>
rollbackChatGptImportRun({
config: params.config,
runId: params.runId,
}),
render: formatChatGptRollbackSummary,
});
}
export function registerWikiCli(
program: Command,
pluginConfig?: MemoryWikiPluginConfig | ResolvedMemoryWikiConfig,
@@ -764,6 +833,36 @@ export function registerWikiCli(
await runWikiUnsafeLocalImport({ config, appConfig, json: opts.json });
});
const chatgpt = wiki
.command("chatgpt")
.description("Import ChatGPT export history into wiki source pages");
chatgpt
.command("import")
.description("Import a ChatGPT export into draft wiki source pages")
.requiredOption("--export <path>", "ChatGPT export directory or conversations.json path")
.option("--dry-run", "Preview changes without writing", false)
.option("--json", "Print JSON")
.action(async (opts: WikiChatGptImportCommandOptions) => {
await runWikiChatGptImport({
config,
exportPath: opts.export!,
dryRun: opts.dryRun,
json: opts.json,
});
});
chatgpt
.command("rollback")
.description("Roll back a previously applied ChatGPT import run")
.argument("<run-id>", "Import run id")
.option("--json", "Print JSON")
.action(async (runId: string, opts: WikiChatGptRollbackCommandOptions) => {
await runWikiChatGptRollback({
config,
runId,
json: opts.json,
});
});
const obsidian = wiki.command("obsidian").description("Run official Obsidian CLI helpers");
obsidian
.command("status")

View File

@@ -5,7 +5,10 @@ import {
type ApplyMemoryWikiMutation,
} from "./apply.js";
import { registerMemoryWikiGatewayMethods } from "./gateway.js";
import { listMemoryWikiImportInsights } from "./import-insights.js";
import { listMemoryWikiImportRuns } from "./import-runs.js";
import { ingestMemoryWikiSource } from "./ingest.js";
import { listMemoryWikiPalace } from "./memory-palace.js";
import { searchMemoryWiki } from "./query.js";
import { syncMemoryWikiImportedSources } from "./source-sync.js";
import { resolveMemoryWikiStatus } from "./status.js";
@@ -24,10 +27,22 @@ vi.mock("./ingest.js", () => ({
ingestMemoryWikiSource: vi.fn(),
}));
vi.mock("./import-insights.js", () => ({
listMemoryWikiImportInsights: vi.fn(),
}));
vi.mock("./import-runs.js", () => ({
listMemoryWikiImportRuns: vi.fn(),
}));
vi.mock("./lint.js", () => ({
lintMemoryWikiVault: vi.fn(),
}));
vi.mock("./memory-palace.js", () => ({
listMemoryWikiPalace: vi.fn(),
}));
vi.mock("./obsidian.js", () => ({
probeObsidianCli: vi.fn(),
runObsidianCommand: vi.fn(),
@@ -90,6 +105,25 @@ describe("memory-wiki gateway methods", () => {
vi.mocked(ingestMemoryWikiSource).mockResolvedValue({
pagePath: "sources/alpha-notes.md",
} as never);
vi.mocked(listMemoryWikiImportRuns).mockResolvedValue({
runs: [],
totalRuns: 0,
activeRuns: 0,
rolledBackRuns: 0,
} as never);
vi.mocked(listMemoryWikiImportInsights).mockResolvedValue({
sourceType: "chatgpt",
totalItems: 0,
totalClusters: 0,
clusters: [],
} as never);
vi.mocked(listMemoryWikiPalace).mockResolvedValue({
totalItems: 0,
totalClaims: 0,
totalQuestions: 0,
totalContradictions: 0,
clusters: [],
} as never);
vi.mocked(normalizeMemoryWikiMutationInput).mockReturnValue({
op: "create_synthesis",
title: "Gateway Alpha",
@@ -135,6 +169,169 @@ describe("memory-wiki gateway methods", () => {
);
});
it("returns recent import runs over the gateway", async () => {
const { config } = await createVault({ prefix: "memory-wiki-gateway-" });
const { api, registerGatewayMethod } = createPluginApi();
vi.mocked(listMemoryWikiImportRuns).mockResolvedValue({
runs: [
{
runId: "chatgpt-abc123",
importType: "chatgpt",
appliedAt: "2026-04-10T10:00:00.000Z",
exportPath: "/tmp/chatgpt",
sourcePath: "/tmp/chatgpt/conversations.json",
conversationCount: 12,
createdCount: 4,
updatedCount: 2,
skippedCount: 6,
status: "applied",
pagePaths: ["sources/chatgpt-2026-04-10-alpha.md"],
samplePaths: ["sources/chatgpt-2026-04-10-alpha.md"],
},
],
totalRuns: 1,
activeRuns: 1,
rolledBackRuns: 0,
} as never);
registerMemoryWikiGatewayMethods({ api, config });
const handler = findGatewayHandler(registerGatewayMethod, "wiki.importRuns");
if (!handler) {
throw new Error("wiki.importRuns handler missing");
}
const respond = vi.fn();
await handler({
params: {
limit: 5,
},
respond,
});
expect(listMemoryWikiImportRuns).toHaveBeenCalledWith(config, { limit: 5 });
expect(respond).toHaveBeenCalledWith(
true,
expect.objectContaining({
totalRuns: 1,
activeRuns: 1,
}),
);
});
it("returns import insights over the gateway", async () => {
const { config } = await createVault({ prefix: "memory-wiki-gateway-" });
const { api, registerGatewayMethod } = createPluginApi();
vi.mocked(listMemoryWikiImportInsights).mockResolvedValue({
sourceType: "chatgpt",
totalItems: 2,
totalClusters: 1,
clusters: [
{
key: "topic/travel",
label: "Travel",
itemCount: 2,
highRiskCount: 1,
withheldCount: 1,
preferenceSignalCount: 0,
updatedAt: "2026-04-10T10:00:00.000Z",
items: [
{
pagePath: "sources/chatgpt-2026-04-10-alpha.md",
title: "BA flight receipts process",
riskLevel: "low",
labels: ["domain/personal", "area/travel", "topic/travel"],
topicKey: "topic/travel",
topicLabel: "Travel",
digestStatus: "available",
firstUserLine: "how do i get receipts?",
lastUserLine: "that option does not exist",
preferenceSignals: [],
},
],
},
],
} as never);
registerMemoryWikiGatewayMethods({ api, config });
const handler = findGatewayHandler(registerGatewayMethod, "wiki.importInsights");
if (!handler) {
throw new Error("wiki.importInsights handler missing");
}
const respond = vi.fn();
await handler({
params: {},
respond,
});
expect(syncMemoryWikiImportedSources).toHaveBeenCalledWith({ config, appConfig: undefined });
expect(listMemoryWikiImportInsights).toHaveBeenCalledWith(config);
expect(respond).toHaveBeenCalledWith(
true,
expect.objectContaining({
sourceType: "chatgpt",
totalItems: 2,
totalClusters: 1,
}),
);
});
it("returns memory palace overview over the gateway", async () => {
const { config } = await createVault({ prefix: "memory-wiki-gateway-" });
const { api, registerGatewayMethod } = createPluginApi();
vi.mocked(listMemoryWikiPalace).mockResolvedValue({
totalItems: 3,
totalClaims: 4,
totalQuestions: 1,
totalContradictions: 1,
clusters: [
{
key: "synthesis",
label: "Syntheses",
itemCount: 1,
claimCount: 2,
questionCount: 1,
contradictionCount: 0,
items: [
{
pagePath: "syntheses/travel-system.md",
title: "Travel system",
kind: "synthesis",
claimCount: 2,
questionCount: 1,
contradictionCount: 0,
claims: ["prefers direct receipts"],
questions: ["should this become a playbook?"],
contradictions: [],
},
],
},
],
} as never);
registerMemoryWikiGatewayMethods({ api, config });
const handler = findGatewayHandler(registerGatewayMethod, "wiki.palace");
if (!handler) {
throw new Error("wiki.palace handler missing");
}
const respond = vi.fn();
await handler({
params: {},
respond,
});
expect(syncMemoryWikiImportedSources).toHaveBeenCalledWith({ config, appConfig: undefined });
expect(listMemoryWikiPalace).toHaveBeenCalledWith(config);
expect(respond).toHaveBeenCalledWith(
true,
expect.objectContaining({
totalItems: 3,
totalClaims: 4,
}),
);
});
it("validates required query params for wiki.search", async () => {
const { config } = await createVault({ prefix: "memory-wiki-gateway-" });
const { api, registerGatewayMethod } = createPluginApi();

View File

@@ -7,8 +7,11 @@ import {
WIKI_SEARCH_CORPORA,
type ResolvedMemoryWikiConfig,
} from "./config.js";
import { listMemoryWikiImportInsights } from "./import-insights.js";
import { listMemoryWikiImportRuns } from "./import-runs.js";
import { ingestMemoryWikiSource } from "./ingest.js";
import { lintMemoryWikiVault } from "./lint.js";
import { listMemoryWikiPalace } from "./memory-palace.js";
import {
probeObsidianCli,
runObsidianCommand,
@@ -115,6 +118,45 @@ export function registerMemoryWikiGatewayMethods(params: {
{ scope: READ_SCOPE },
);
api.registerGatewayMethod(
"wiki.importRuns",
async ({ params: requestParams, respond }) => {
try {
const limit = readNumberParam(requestParams, "limit");
respond(true, await listMemoryWikiImportRuns(config, limit !== undefined ? { limit } : {}));
} catch (error) {
respondError(respond, error);
}
},
{ scope: READ_SCOPE },
);
api.registerGatewayMethod(
"wiki.importInsights",
async ({ respond }) => {
try {
await syncImportedSourcesIfNeeded(config, appConfig);
respond(true, await listMemoryWikiImportInsights(config));
} catch (error) {
respondError(respond, error);
}
},
{ scope: READ_SCOPE },
);
api.registerGatewayMethod(
"wiki.palace",
async ({ respond }) => {
try {
await syncImportedSourcesIfNeeded(config, appConfig);
respond(true, await listMemoryWikiPalace(config));
} catch (error) {
respondError(respond, error);
}
},
{ scope: READ_SCOPE },
);
api.registerGatewayMethod(
"wiki.init",
async ({ respond }) => {

Some files were not shown because too many files have changed in this diff Show More