mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-29 09:57:31 +08:00
feat: harden jsonl runtime reliability
This commit is contained in:
@@ -151,8 +151,11 @@ func gatewayCmd() {
|
||||
}
|
||||
return loop.ProcessDirect(cctx, content, sessionKey)
|
||||
})
|
||||
registryServer.SetChatHistoryHandler(func(sessionKey string) []map[string]interface{} {
|
||||
h := loop.GetSessionHistory(sessionKey)
|
||||
registryServer.SetChatHistoryHandler(func(query api.ChatHistoryQuery) []map[string]interface{} {
|
||||
h := loop.GetSessionHistory(query.Session)
|
||||
if query.Around > 0 || query.Before > 0 || query.After > 0 || query.Limit > 0 {
|
||||
h = loop.GetSessionHistoryWindow(query.Session, query.Around, query.Before, query.After, query.Limit)
|
||||
}
|
||||
out := make([]map[string]interface{}, 0, len(h))
|
||||
for _, m := range h {
|
||||
entry := map[string]interface{}{"role": m.Role, "content": m.Content}
|
||||
@@ -166,6 +169,35 @@ func gatewayCmd() {
|
||||
}
|
||||
return out
|
||||
})
|
||||
registryServer.SetSessionSearchHandler(func(query api.SessionSearchQuery) []map[string]interface{} {
|
||||
excludeKey := ""
|
||||
if query.ExcludeCurrent {
|
||||
excludeKey = strings.TrimSpace(query.Session)
|
||||
}
|
||||
results := loop.SearchSessions(query.Query, query.Kinds, excludeKey, query.Limit)
|
||||
out := make([]map[string]interface{}, 0, len(results))
|
||||
for _, item := range results {
|
||||
entry := map[string]interface{}{
|
||||
"key": item.Key,
|
||||
"kind": item.Kind,
|
||||
"updated_at": item.UpdatedAt.UnixMilli(),
|
||||
"summary": item.Summary,
|
||||
"score": item.Score,
|
||||
}
|
||||
snippets := make([]map[string]interface{}, 0, len(item.Snippets))
|
||||
for _, snippet := range item.Snippets {
|
||||
snippets = append(snippets, map[string]interface{}{
|
||||
"seq": snippet.Seq,
|
||||
"role": snippet.Role,
|
||||
"segment": snippet.Segment,
|
||||
"content": snippet.Content,
|
||||
})
|
||||
}
|
||||
entry["snippets"] = snippets
|
||||
out = append(out, entry)
|
||||
}
|
||||
return out
|
||||
})
|
||||
registryServer.SetToolsCatalogHandler(func() interface{} {
|
||||
return loop.GetToolCatalog()
|
||||
})
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
clawgoassets "github.com/YspCoder/clawgo"
|
||||
"github.com/YspCoder/clawgo/pkg/config"
|
||||
)
|
||||
|
||||
@@ -42,7 +43,7 @@ func copyEmbeddedToTarget(targetDir string, overwrite func(relPath string) bool)
|
||||
return fmt.Errorf("failed to create target directory: %w", err)
|
||||
}
|
||||
|
||||
return fs.WalkDir(embeddedFiles, "workspace", func(path string, d fs.DirEntry, err error) error {
|
||||
return fs.WalkDir(clawgoassets.WorkspaceTemplates, "workspace", func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -50,7 +51,7 @@ func copyEmbeddedToTarget(targetDir string, overwrite func(relPath string) bool)
|
||||
return nil
|
||||
}
|
||||
|
||||
data, err := embeddedFiles.ReadFile(path)
|
||||
data, err := clawgoassets.WorkspaceTemplates.ReadFile(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read embedded file %s: %w", path, err)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -16,9 +15,6 @@ import (
|
||||
"github.com/YspCoder/clawgo/pkg/logger"
|
||||
)
|
||||
|
||||
//go:embed workspace
|
||||
var embeddedFiles embed.FS
|
||||
|
||||
var version = "0.0.2"
|
||||
var buildTime = "unknown"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user