chore(go): audit providers kimi grok qwen letta

Move Kimi, Grok, and Qwen onto managed_runtime.go and shell_command.go;
share the encoded and shell command builders and the quoted Windows
legacy parser with Droid; split managed_changes.go; dedupe Letta's hook
entry filtering and stop swallowing settings read errors.

Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq
This commit is contained in:
雷电芽衣 committed 2026-09-03 02:16:58 -04:00
1 parent 1ede03d989
commit 34ff4c1ea8
34 files changed
+421 -1876

No files matched your search

+13 -29
View File
@@ -2,9 +2,7 @@ package plugins
import (
"fmt"
"runtime"
"sort"
"strings"
)
const (
@@ -54,20 +52,10 @@ type kimiHook struct {
}
type kimiRuntimeContract struct {
agentID string
guardPath string
auditPath string
managedRuntimeContract
configPath string
}
func stringSet(values ...string) map[string]struct{} {
result := make(map[string]struct{}, len(values))
for _, value := range values {
result[value] = struct{}{}
}
return result
}
func mergeStringSets(sets ...map[string]struct{}) map[string]struct{} {
result := map[string]struct{}{}
for _, set := range sets {
@@ -173,7 +161,7 @@ func managedKimiReference(
hook kimiHook,
event string,
scriptName string,
) (*kimiRuntimeReference, error) {
) (*managedScriptReference, error) {
if hook.fieldCount != 3 || hook.event != event || hook.matcher != nil ||
hook.timeout == nil || *hook.timeout != kimiHookTimeoutSeconds {
return nil, nil
@@ -196,7 +184,7 @@ func keptKimiHookIndices(hooks []kimiHook, agentID string) ([]int, error) {
indices := make([]int, 0, len(hooks))
for index, hook := range hooks {
event, scriptName, managedEvent := managedKimiEvent(hook.event)
var reference *kimiRuntimeReference
var reference *managedScriptReference
var err error
if managedEvent {
reference, err = managedKimiReference(hook, event, scriptName)
@@ -205,7 +193,7 @@ func keptKimiHookIndices(hooks []kimiHook, agentID string) ([]int, error) {
}
}
remove := reference != nil &&
(agentID == "" || sameKimiAgentID(reference.agentID, agentID))
(agentID == "" || sameManagedAgentID(reference.agentID, agentID))
if !remove {
indices = append(indices, index)
}
@@ -213,19 +201,12 @@ func keptKimiHookIndices(hooks []kimiHook, agentID string) ([]int, error) {
return indices, nil
}
func kimiReferenceKey(agentID string) string {
if runtime.GOOS == "windows" {
return strings.ToLower(agentID)
}
return agentID
}
func kimiReferencesForEvent(
hooks []kimiHook,
event string,
scriptName string,
) (map[string][]kimiRuntimeReference, error) {
result := map[string][]kimiRuntimeReference{}
) (map[string][]managedScriptReference, error) {
result := map[string][]managedScriptReference{}
for _, hook := range hooks {
reference, err := managedKimiReference(hook, event, scriptName)
if err != nil {
@@ -234,7 +215,7 @@ func kimiReferencesForEvent(
if reference == nil {
continue
}
key := kimiReferenceKey(reference.agentID)
key := managedReferenceKey(reference.agentID)
result[key] = append(result[key], *reference)
}
return result, nil
@@ -267,12 +248,15 @@ func kimiRuntimeContracts(documents []kimiDocument) ([]kimiRuntimeContract, erro
success := successes[key]
failure := failures[key]
if len(guard) != 1 || len(success) != 1 || len(failure) != 1 ||
!sameKimiPath(success[0].scriptPath, failure[0].scriptPath) {
!sameManagedPath(success[0].scriptPath, failure[0].scriptPath) {
continue
}
contracts = append(contracts, kimiRuntimeContract{
agentID: guard[0].agentID, guardPath: guard[0].scriptPath,
auditPath: success[0].scriptPath, configPath: document.contract.configPath,
managedRuntimeContract: managedRuntimeContract{
agentID: guard[0].agentID, guardPath: guard[0].scriptPath,
auditPath: success[0].scriptPath,
},
configPath: document.contract.configPath,
})
}
}