Commit Graph

98 Commits

Author SHA1 Message Date
1013aa0aa9 feat(sdk): add RegisterStopHandler/RunStopHandlers and wire stop cleanup into registry lifecycle
- SDK PluginSDK gains RegisterStopHandler(fn func()) + RunStopHandlers()
  (LIFO, idempotent, cleared after running); synced to third_party copy
- Registry keeps per-plugin SDK refs (sdkRefs); StopAll/ReloadOne/
  DisablePlugin run handlers before calling Stop()
- timer built-in plugin demonstrates handler-based shutdown cleanup
- z_bridge (linux/windows templates) runs handlers before plugin.Stop()
2026-08-02 10:23:40 +08:00
94312d714a fix(webui): capture all-channel chat history and correct input source
- handleChat now injects with source=webui so the LLM no longer sees
  cli as the input channel
- subscribe to EventRawInput/EventAgentOutput to persist every
  conversation turn from all channels (cli/qq/webui), replacing the
  manual webui-only addChatMsg to avoid duplicates
- ChatMsg gains a source field; GUI shows a channel badge for
  non-webui messages
2026-08-01 14:06:18 +08:00
dbbd73b930 refactor: migrate built-in plugins to SDK-only interface
- Six-phase plan complete: webui/cli/healthcheck/pluginmgr/clawhubadapter
  now interact with the kernel exclusively via internal/sdk interfaces;
  all Configure() calls and package-level global injection removed
- buildSDK in internal/plugin/registry.go is the single assembly point
- Add internal/sdk/events.go exporting event types/constants
- Fix ProviderManager cooldown sharing: LuaAdaptedProvider.Name() now
  returns the source name instead of lua_<adapter>, so multiple sources
  sharing an adapter (single script load via shared VM AdapterCache) no
  longer share failure-cooldown state
- Verified: build/vet/tests green, deployed to homeagent.service with
  full plugin capability testing via local OpenAI-compatible mock
2026-08-01 12:17:17 +08:00
0f68608403 feat(lua plugin): align Lua plugin bridge with C ABI surface, accept table args in sdk.memory.recall
- Lua 桥接层补齐 register_def/no_memory/cleaner/own_tools/output+input channels/register_api/set_auto_restart 等 v0.8.0 能力,与 C ABI 插件面一致
- sdk.memory.recall 兼容表参数(多 key 批量 recall),修复 Lua 插件传表报 bad argument
- 新增 TestLuaAlignedAPIs 覆盖对齐后的 API 面(含 recall 数组回归断言)
- sdk.lua 同步子表 mock(memory/doc/knowledge/text_memory/llm/social/settings)
- 更新 PLUGIN_DEV.md 中英文示例插件参考表
2026-07-31 11:42:23 +08:00
64615a9b19 fix(all lua adapters): type-safe field access in transform_response
All 5 adapters (deepseek, github, groq, mistral, openai) now:
- Guard against json.decode returning nil (null body)
- Use type() == "table" instead of truthy checks for table access
- Prevents 'attempt to index a non-table object(nil)' crashes
2026-07-30 18:32:17 +08:00
548b750b1a fix(openai adapter): handle null response body and use type-safe field access
- Fix transform_response crash when json.decode returns nil (null body)
- Replace truthy checks with type() == "table" for safer field access
- Prevents 'attempt to index a non-table object(nil)' errors
2026-07-30 17:09:51 +08:00
3a5a16c916 bump version to v0.8.0 2026-07-29 15:45:24 +08:00
1f3595b35d cabi: parse ChannelDef from a3 in CORE_REGISTER_OUTPUT_CH; embed sdk example/qq fix 2026-07-29 15:24:42 +08:00
796a48dae5 plugin disable system: kernel→SDK PluginManager + WebUI/CLI
- New disabled_plugins table (name, disabled_at, disabled_by)
- SDK.PluginManager interface: DisablePlugin/EnablePlugin/ListDisabledPlugins
- Registry implements PluginManager, wired into PluginSDK
- WebUI: POST /api/v1/plugins/<name>/disable|enable + plugins page with toggle
- Disabling webui shows confirmation dialog
- CLI: /plugin disable <name> / /plugin enable <name>
- pluginmgr removePlugin sync-cleanup from disabled_plugins table
2026-07-29 15:07:32 +08:00
a899d777c3 sdk: embed non-toolchain SDK in third_party, add NoMemory/Cleaner support
- Embed sdk/, example/, meta/, go.mod from homeagent-sdk (no .git)
- Core .gitignore excludes SDK toolchain: bin/, tools/, package/
- RegisterInputChannel + ChannelDef(NoMemory, Cleaner) in SDK
- IOManager input channel registry with GetInputChannelDef
- eventloop: apply channel Cleaner/NoMemory to interrupt text
- context engine: channelDefLookup applied in textForVector
- document store: ChannelCleaner param for archive functions
- All callers/adapters updated with ChannelDef{} default
2026-07-29 14:48:23 +08:00
4218890aed docs: 修复记忆分层引用错误 + 补充内置/外部插件说明 + 同步中英文文档 2026-07-28 21:56:53 +08:00
51f190e0b6 core: pass ReasoningContent to assistant messages in process.go
- process.go: attach resp.ReasoningContent when building assistant messages
- deepseek.lua v2.1.0: remove last_reasoning closure hack; rely on
  core-provided reasoning_content in messages
- openai.lua: strip reasoning_content from messages in transform_request
  (not supported by OpenAI API)
2026-07-28 17:07:17 +08:00
f91b20ee16 v0.7.3: 重构 Provider 层 + 计算层隔离 + Cleaner/NoMemory 架构
- 删除 OpenAIProvider/OllamaProvider 死代码,LuaAdaptedProvider 独存
- DisableThinking 从 ExtraBody 移到 CompletionRequest 顶层字段
- ContextWindow 从 Provider 签名移到 BaseConfig/ModelContextWindow() 统管
- 确认 CleanText 仅做基本空白 trim,QQ 模板剥离归插件 Cleaner
- Cleaner/NoMemory 仅作用于向量计算和 jieba 分词层,原文不变
- context.ContextEvent/Doc.Content 始终保存原文
- 删除 nlp/download.go 死代码
- media.go: context.Background() -> a.ctx 级联
- clawhubadapter: HTTP 超时
- cut.go: 跨平台 mod cache 路径 (GOMODCACHE->GOPATH->HomeDir)
- bridge_e2e_test: 移除未用 runtime import
- lua 适配器: disable_thinking 传参
2026-07-28 11:42:29 +08:00
2c5f9ff262 v0.7.2: 根目录清理 + Agent 心跳重构 + 内嵌 ONNX 模型
- 根目录清理: branding/docs/knowledge -> assets/, package/tools/deploy -> deploy/
- meta.go: Version 0.7.2, SDKCompatibleVersion 语义改为最高兼容
- Makefile: 版本回退 0.7.2
- registry.go: 系统提示词改用 meta.Version 格式化
- Agent 心跳: reorgGraph 拆分为三个独立循环(archive/merge/review),各自可配间隔
- GraphDB: 新增 sentences 表 + 关系句子溯源 + ClearSentenceID + CleanupOrphanedSentences
- Knowledge: 支持词嵌入向量化器
- NLP 四阶段流水线: Parse -> Extract -> Verify -> Fuse + SentenceRef
- 移除远程 HTTP 解析器(remote_parser.go)
- 新增内嵌 ONNX 模型(vocab + dep_parser.onnx):
  +build onnxruntime: 全量 ONNX Runtime 推理
  !build onnxruntime: 内嵌词表规则式降级解析器
- config: core.agent.onnx_model_path 替代 dep_parser_url
2026-07-28 09:56:26 +08:00
1cb3e87dde feat: 完整实现 NLP 三元组提取系统 + token budget 上下文分配
- 重写 extractor.go: 分句、17条 POS 模板、依存模板 + COO 链、ATT合并
- parser.go: 分句循环 + TransE 向量验证(h+r≈t)
- fallback.go: jieba POS 降级解析器
- bridge.go: nlp.Triple ↔ memory.Triple 转换
- pipeline.go: extractKeyTriples 改用 NLP 提取器, 删除5条旧前缀规则
- distill.go: docToTriples 改用 NLP 提取器
- reorgGraph: 语义相似度增强检测, 保持纯 LLM 决断
- Provider 接口加 MaxContextTokens() + 模型窗口映射表
- tokenbudget.go: 中文 token 估算器 + budget 分配(80%利用率)
- process.go/buildSystemPrompt: 按 token 预算截断 memory+timeline
2026-07-27 15:26:23 +08:00
d19b7bd13e fix: 修复记忆系统自循环与计算层污染
- 删 syncGraphToDocs(): Graph 快照不再写入 Document,避免污染向量索引和三层隔离
- 删 toolCallRing(): 已被工具 NoMemory/Cleaner 机制取代,不再需要独立环形缓冲
- 加 toolOutputClean 回调线程 Prune→ContextToDoc: 归档时按 NoMemory 跳过、Cleaner 清洗后再过 jieba,原文保留
- 加 eval_status 持久化 (RecallPending/UpdateEvalStatus/ResolveEvaluating): 避免重复 LLM 评估
2026-07-26 19:36:25 +08:00
db4844c6c6 fix(memory_recall): add jieba keyword extraction for natural language queries 2026-07-25 18:27:36 +08:00
634c3ff4ad fix: doc_query chronological insert, register cli/webui output channels
- context.go: add InsertByTimestamp for chronological context insertion
- toolcall.go: doc_query uses InsertByTimestamp instead of Append
- agent_tools_test.go: update tests to use payload/type keys
- cli/plugin.go: register output_send__cli channel
- webui/plugin.go: register output_send__webui channel
2026-07-25 16:25:06 +08:00
87ad88b174 refactor: centralize ABI metadata into internal/meta/meta.go
- internal/meta/meta.go: add ABIVersion, ABIVersionMin, 45 dispatch
  method IDs, SDKCompatibleVersion (single source of truth)
- internal/plugin/cabi/types.go: re-export from meta.go
- internal/plugin/cabi/loader.go: reject plugin when version > ABIVersion;
  pass ABIVersion in Start instead of hardcoded 1
- loader.{go,c}: comments reference meta.go as canonical
2026-07-25 14:42:35 +08:00
e992e1ff84 v0.7.2: fix cfgmgr plugin list and core config key prefix 2026-07-25 12:18:35 +08:00
31664a7853 feat: NoMemory/Cleaner memory system + doc update
- _sdk_local/ removed (moved to standalone sdk repo)
- internal/agent/core: NoMemory/Cleaner data-flow breakpoints
- internal/memory: clean_text, document store refactor
- internal/plugin/registry.go: plugin API alignment
- docs: PLUGIN_DEV.md, ARCHITECTURE.md NoMemory/Cleaner docs
- plan.md, review.md: status update
2026-07-25 11:17:31 +08:00
4a2df503ed add: log management module (compressor, manager, retention) 2026-07-24 17:04:37 +08:00
3fc2151588 refactor: pluginize text cleaning and tool NoMemory control
- SDK: ToolDef.NoMemory field, PluginSDK.RegisterTextCleaner/TextCleaners
- Registry: aggregate text cleaners from plugins, expose CleanText()
- Memory: replace hardcoded QQ regex CleanTemplateText with dynamic CleanText/SetTextCleaner
- StageHost: add ToolDef(name) lookup
- eventloop: check ToolDef.NoMemory before emitMemoryCandidate
- context/Prune: replace hardcoded agentcli/terminal source filter with ToolsUsed NoMemory check
- agentcli/cmd: mark tools with NoMemory: true
- main.go: wire memory.SetTextCleaner(pluginReg.CleanText)
2026-07-24 14:49:08 +08:00
d4cb9cb8cc refactor(clawhubadapter): merge manager/simulator, fix provider dispatch, add OC plugin load delegation
- Manager now handles OC plugin loading via plugins/load JSON-RPC
  instead of launching a separate simulator process
- Added 8 missing provider registration methods to manager
- Added explicit registeredChannels declaration in manager
- Provider dispatch now strips _provider suffix correctly (lookupType)
- Skip .simulator directory in skills scanning
- detect OC via package.json openclaw field (hasOCPackage)
- All registration notifications include plugin name for correct tool prefix
- Fix ToolRegistry/ProviderRegistry/ChannelRegistry to use plugin name
  from notification data instead of hardcoded 'manager'
- test: add mockSettings, fix TestLoadOCPluginViaPluginStart panic
2026-07-23 16:34:26 +08:00
4b6caae605 feat(clawhubadapter): bridge OC channels to HomeAgent output/input channels
- registry.go: replace channelDevice+RegisterChannel with RegisterOutputChannel
  handler routes output via sp.CallTool to JS manager outbound handlers
  register {plugin}_read_{ch}_input tool for agent to poll buffered input
- plugin.go: handle channel_input notifications in translateAndRegister
  buffer payload in channelInputBuf + InjectInterruptText to notify agent
- manager/main.js: registerChannel supports {plugin: ChannelPlugin} format
  tools/call routes channel names to outbound.sendText/sendMedia
  submitInput sends channel_input notification to Go side
2026-07-23 14:45:10 +08:00
3a5f548326 fix(clawhubadapter): manager CLI improvements, pysimulator updates, sidecar fixes 2026-07-23 13:54:04 +08:00
9b4d0cb50d feat(clawhubadapter): rename plugin tools, universal uninstall; feat(mcp): add dynamic server management; feat(prompt): long-task guidance 2026-07-22 17:32:45 +08:00
bd0f84c1f7 fix: deduplicate assistant content in multi-tool turns to prevent premature loop exit
- process.go: only emit resp.Content on the first tool call per batch,
  subsequent assistant messages use empty content (serialized as null)
- provider.go: MarshalJSON outputs null content when empty with tool_calls
  to comply with DeepSeek/OpenAI expected format
- output.go: update parameter interface (payload/type/meta) to match
  tool definitions (uncommitted from previous refactor)
2026-07-22 17:05:13 +08:00
85992902d9 refactor: split agent.go into 12 files + add mcp_restart_server tool 2026-07-22 15:40:27 +08:00
76a4619ed5 refactor: rename openclaw -> clawhubadapter, add ClawHub search/install, fix agent interrupt
- Rename internal/plugins/openclaw/ -> internal/plugins/clawhubadapter/
- Add RegistryDispatcher with 5 sub-registries (Tool, Provider, Channel, Stage, Cap)
- Add clawhubadapter_search tool for ClawHub marketplace search
- Add clawhub: prefix support for installing from ClawHub (ZIP/tgz auto-detect)
- Add CallProvider RPC and provider/call routing
- Fix QQ interrupt: check interceptCh before/after each tool execution
2026-07-21 22:47:14 +08:00
906d117bdd feat: add cfgmgr built-in plugin 2026-07-21 21:07:37 +08:00
54fa2ca93d fix: merge os.Environ() with custom env in NewStdioTransport 2026-07-21 12:45:26 +08:00
cfb4b72587 fix: CORE_REGISTER_TOOL fallback to raw string on unmarshal error
Previously the wrapper silently ignored json.Unmarshal errors and returned
nil, causing tools returning raw JSON strings (via C ABI bridge's
json.Marshal) to appear as empty map[] to the agent.
2026-07-20 17:51:56 +08:00
7609c39191 fix(webui,gui): terminal/cmd count badge ID mismatch 2026-07-19 14:52:17 +08:00
4495447b85 fix(document memory): dedup graph sync, filter terminal output from archive, add min relevance threshold 2026-07-19 14:21:04 +08:00
4e13bbba5e fix: use platformBinaries for bundle skip (keep main.lua/SKILL.md) 2026-07-19 12:12:11 +08:00
4da2ad5376 feat: multi-platform .hmap bundle + platform auto-selection
- PluginManifest: add platforms field declaring supported OS
- validatePackage: accept bundle .hmap with platform-aware binary check
- extractPackage: extract only current OS binary, skip others (macOS renames .dylib → .so)
- installFromPath/installFromURL: path install keeps source, URL install auto-cleanup
- cabi/loader.go + dynamic.go: add linux/darwin build constraints for Windows cross-compile
- dynamic_loader_unix/windows: split SO loading with proper build tags
- package/build.sh: enable windows/amd64 for homed, add CXX export for arm64
- tryLoadSO: fallback to plugin.dylib on macOS
- docs: update PLUGIN_DEV.md for bundle format and install methods
2026-07-19 12:01:35 +08:00
24698e7c82 fix: include openclaw manager/pysimulator sources, remove from gitignore
manager/main.js, pysimulator/main.py, and simulator/main.js are
production source files for the OpenClaw sidecar system, not build
artifacts. Remove them from .gitignore so fresh clones can make build
without manual stub creation.
2026-07-19 11:07:18 +08:00
8ae1d19869 refactor: output channel interface (payload/meta/type) + memory fixes
- Redesign output_send__ tools: content JSON string -> structured
  payload/meta/type params for LLM reliability
- executeOutputSendTool: route by type with capability check
- executeOutputSendHelp: show meta format + type enum
- Updated system prompt rules for new interface
- docToTriples: use jieba exact mode adjacent co-occurrence
- Unify vector space: Doc.Vector field, ContextToDoc vectorizer,
  ReindexWithVectorizer on startup
2026-07-19 10:29:21 +08:00
9b3a751d98 fix: correct system prompt — remove misleading auto-reply statement, agent must use output_send__ tool 2026-07-18 21:28:59 +08:00
c9e67d3d55 docs: 修正全部文档使其与源码实现一致
主仓库:
- 修复 4 份英文文档语言切换链接指向错误 (../zh/ → ../en/)
- ARCHITECTURE.md 标题 "三种加载方式" → "四种加载方式" (实际表格4行)
- PLUGIN_DEV.md 示例表: 添加 webfetch, 移除不存在的 luaplugintest/testlua
- PLUGIN_DEV.md 代码示例: InjectInput/InjectInterrupt → InjectText/InjectInterruptText
- PLUGIN_DEV.md 代码示例: Memory/Knowledge/LLM/Events 接口签名修正
- PLUGIN_DEV.md .hmap 内容统一, plugindev 编译去除 .exe 后缀

SDK 仓库:
- Plugin.Start(sdk *PluginSDK) 接口签名改为指针
- 方法表重写: 移除 CallLLM/QueryKnowledge/SetMemory 等不存在方法
- IOInjector 参数顺序修正为 (source, channel, text)
- 删除虚构 SDKConfig, 替换为实际 New() 构造函数签名
- .hmap 内容描述一致化

修正前一次会话中的 QQ/Bili 插件问题:
- qq napcat() 超时, fetchBotInfo 竞态, handleWebhook 同步阻塞
- bili CDN 直连失败, 添加 HTTP_PROXY 代理
2026-07-18 20:46:58 +08:00
10638f1308 feat: mascot integration - WebUI/GUI icons, chat avatar, system prompt, docs 2026-07-17 21:41:03 +08:00
69ceedf0ab feat: register embedding_model_path in ConfigRegistry instead of JSON config
- Add core.agent.embedding_model_path to seedDBValues and seedCoreDefs
- Wire cfgReg.GetString in main.go to AgentConfig.EmbeddingModelPath
- Follow existing core.agent.* ConfigRegistry pattern
2026-07-17 21:07:54 +08:00
7892d7b0f2 feat: multi-language embedding with CleanTemplateText + three-branch vector strategy
- StaticEmbedder: pre-trained ConceptNet Numberbatch/fastText word embeddings,
  auto-download with TF-IDF fallback, comma-separated multi-model paths
- CleanTemplateText: regex stripping of QQ tool call templates and noise
- textForVector: per-source vector strategy (agent→Response, user→Input,
  cold_storage→both)
- Indexer.BuildContext and ExtractKeywords now clean input before vectorization
- Protect recent 10 events in Prune (regression fix: use local var not const)
2026-07-17 21:02:35 +08:00
3cad4b635f RegisterStage: add scope parameter, remove RegisterStageOwnTools
- SDK: RegisterStage(stage, handler, scope...) with StageScopeGlobal/StageScopeOwnTools
- Delete RegisterStageOwnTools, migrate cmd and qq plugins
- Internal SDK: add StageScope alias
- Docs: update all zh/en docs for C ABI buildmode and stage scope
- C ABI: fix nil errorOut in Handle.Start/Handle.Stop (SIGSEGV fix)
- C ABI header: add dispatch IDs 26-45 for Settings/Doc/Knowledge/LLM/Social/TextMemory
2026-07-17 11:25:54 +08:00
724febf7b4 fix: remove closure-captured h.api, use stateless pluginMap lookup
- Replace invokeTool/invokeOutput/invokeStage callbacks with standalone
  functions pluginInvokeTool/pluginInvokeOutput/pluginInvokeStage
- Case 1: sync tool invocation (not async - LLM needs return value)
- Case 2/3: use pluginID + pluginMap lookup instead of closures
- Store ps.api in pluginState for direct C function calls
2026-07-17 09:59:17 +08:00
a00198a9b0 feat: complete SDK dispatch - all methods implemented (32-41)
- DocMemory: Insert/Remove/Stats dispatch (32-34)
- Knowledge: Add/List dispatch (35-36)
- LLM: CurrentSource dispatch (37)
- Social: GetTrait/GetRelations/ListPersons dispatch (38-40)
- TextMemory: Append dispatch (41)
- EventBus: subscribe stub (not wired for external plugins)
- All bridge template stubs replaced with real dispatch calls
2026-07-17 09:46:33 +08:00
babef149b5 fix: comprehensive dispatch fixes
- go_core_dispatch case 1: tool handler now calls back to plugin via invokeTool
- go_core_dispatch case 2: stage handler sends full StageContext (11 fields)
- New dispatch methods 26-31: Settings.GetCore/SetCore/ListCore/GetPlugin/SetPlugin/ListPlugin
- Remove dlclose (plugin goroutines may still be running after Stop)
- invokeTool/invokeOutput/invokeStage callbacks with proper error handling
- Fix n2 unused variable
2026-07-17 09:33:53 +08:00
f9fe852ded fix: RegisterOutputChannel and RegisterStage now route through plugin callbacks
- go_core_dispatch case 2/3 no longer stub - real callbacks to plugin
- pluginState.invokeOutput/invokeStage call plugin's go_invoke_output/stage
- OutputChannel registration via IOManager.RegisterDevice
- Stage handler registration via PluginSDK.RegisterStage
2026-07-17 09:26:46 +08:00
1624c57867 fix: CoreAPI lifecycle - don't FreeCoreAPI until Stop
- Move FreeCoreAPI from defer in Start() to Stop()
- Call handle.Stop() before freeing resources
- This prevents SIGSEGV from plugins accessing freed CoreAPI memory
- Plugin's Go bridge code is safe (no C memory bugs)
2026-07-17 09:21:50 +08:00