From 1fa3c843ab729547e03f77d2d6e605a6f5b28177 Mon Sep 17 00:00:00 2001 From: JianFeeeee <109188060+JianFeeeee@users.noreply.github.com> Date: Sat, 25 Jul 2026 14:42:32 +0800 Subject: [PATCH] refactor: centralize ABI metadata into meta/meta.go - meta/meta.go: add ABIVersion, ABIVersionMin, 45 dispatch method IDs - tools/plugindev/cmd_init.go: cabiVersion -> meta.ABIVersion - tools/plugindev/templates.go: C header comments reference meta.go --- meta/meta.go | 64 ++++++++++++++++++++++++++++++++++++ tools/plugindev/cmd_init.go | 6 ++-- tools/plugindev/go.mod | 6 +++- tools/plugindev/templates.go | 2 ++ 4 files changed, 74 insertions(+), 4 deletions(-) diff --git a/meta/meta.go b/meta/meta.go index 037ac21..5064097 100644 --- a/meta/meta.go +++ b/meta/meta.go @@ -1,5 +1,6 @@ // Package meta 收集 HomeAgent SDK 的全部元数据。 // 版本号应与核心 meta.Version 保持一致。 +// ABI 版本与 Dispatch Method ID 应与核心仓 internal/meta/meta.go 保持一致。 package meta var ( @@ -15,9 +16,72 @@ var ( // SDKName 是 SDK 名称。 SDKName = "HomeAgent SDK" + + // CoreModule 是核心仓的 Go module path,供 plugindev 生成 go.mod 时使用。 + CoreModule = "gitcode.com/JianFeeeee/HomeAgent" + + // CoreVersion 是此 SDK 所兼容的最低核心版本。 + CoreVersion = "0.7.2" ) // FullVersion 返回完整的版本字符串。 func FullVersion() string { return SDKName + " v" + Version + " (" + Commit + ")" } + +// ---- ABI 版本(与核心仓 internal/meta/meta.go 同步) ---- +// 修改时需确保核心仓与 SDK 仓的值一致。 + +const ( + ABIVersion = 1 + ABIVersionMin = 1 +) + +// ---- Dispatch Method IDs(与核心仓 internal/meta/meta.go 同步) ---- +const ( + CoreRegisterTool = 1 + CoreRegisterStage = 2 + CoreRegisterOutputCh = 3 + CoreRegisterPluginAPI = 4 + CoreInjectText = 5 + CoreInjectInterruptText = 6 + CoreInjectTextNoMemory = 7 + CoreSetAutoRestart = 8 + CoreMemoryRecall = 9 + CoreMemoryCommit = 10 + CoreMemoryIntrospect = 11 + CoreMemoryMerge = 12 + CoreMemoryPurge = 13 + CoreDocQuery = 14 + CoreKnowledgeSearch = 15 + CoreSettingsGet = 16 + CoreSettingsSet = 17 + CoreSettingsRegisterDef = 18 + CoreLLMListSources = 19 + CoreLLMSetSource = 20 + CoreSocialGetPerson = 21 + CoreSocialGetNetwork = 22 + CoreSubscribe = 23 + CoreUnsubscribe = 24 + CoreFreeString = 25 + CoreSettingsGetCore = 26 + CoreSettingsSetCore = 27 + CoreSettingsListCore = 28 + CoreSettingsGetPlugin = 29 + CoreSettingsSetPlugin = 30 + CoreSettingsListPlugin = 31 + CoreDocInsert = 32 + CoreDocRemove = 33 + CoreDocStats = 34 + CoreKnowledgeAdd = 35 + CoreKnowledgeList = 36 + CoreLLMCurrentSource = 37 + CoreSocialGetTrait = 38 + CoreSocialGetRelations = 39 + CoreSocialListPersons = 40 + CoreTextMemoryAppend = 41 + CoreSettingsList = 42 + CoreSettingsDefs = 43 + CoreSettingsDump = 44 + CoreSettingsPlugins = 45 +) diff --git a/tools/plugindev/cmd_init.go b/tools/plugindev/cmd_init.go index 9a974c1..a5bd176 100644 --- a/tools/plugindev/cmd_init.go +++ b/tools/plugindev/cmd_init.go @@ -6,9 +6,9 @@ import ( "path/filepath" "strings" "text/template" -) -const cabiVersion = 1 + "gitcode.com/JianFeeeee/homeagent-sdk/meta" +) type PlgConfig struct { Name string `json:"name"` @@ -84,7 +84,7 @@ func cmdInit(args []string) { Targets: targets, }, IsLua: isLua, - CABIVersion: cabiVersion, + CABIVersion: meta.ABIVersion, CABIHeader: tmplCABIHeader, } diff --git a/tools/plugindev/go.mod b/tools/plugindev/go.mod index b5fe1f4..0055fa8 100644 --- a/tools/plugindev/go.mod +++ b/tools/plugindev/go.mod @@ -1,3 +1,7 @@ module github.com/JianFeeeee/homeagent-sdk/tools/plugindev -go 1.21 +go 1.25.0 + +require gitcode.com/JianFeeeee/homeagent-sdk v0.0.0 + +replace gitcode.com/JianFeeeee/homeagent-sdk => ../../ diff --git a/tools/plugindev/templates.go b/tools/plugindev/templates.go index 073ebdd..2e9a7f8 100644 --- a/tools/plugindev/templates.go +++ b/tools/plugindev/templates.go @@ -279,9 +279,11 @@ func main() {} ` // tmplCABIHeader — shared C ABI type definitions for both core and plugin +// 此模板中的常量应与 core/internal/meta/meta.go 保持一致(ABI 版本、dispatch method IDs)。 const tmplCABIHeader = ` #ifndef HOMEAGENT_CABI_H #define HOMEAGENT_CABI_H +// HOMEAGENT_ABI_VERSION 与 sdk/meta/meta.go ABIVersion 同步 #define HOMEAGENT_ABI_VERSION 1 #ifdef __cplusplus extern "C" {