mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-11-13 15:57:22 +01:00
Delete the Eino model adapters, callbacks, middleware, orchestration, summarization and single-agent runner together with their dependencies. Chat, batch tasks, workflow Agent nodes and sub-agents now share the Pi runtime, and dispatch is a single code path instead of an engine switch. Configuration migrates eino_middleware/eino_skills to runtime/skills and drops the retired callback settings while old files still load. Settings, i18n and docs describe Pi only. Also carry the Pi follow-up fixes: empty required lists are omitted from tool schemas, historical tool results stay with their call batch, model proxies work over HTTP/1.1, single-query retrieval skips query expansion, and finalization docs match Pi lifecycle events.
56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
package agentruntime
|
|
|
|
import (
|
|
"context"
|
|
"crypto/sha256"
|
|
"fmt"
|
|
"path/filepath"
|
|
"sync"
|
|
)
|
|
|
|
// ConversationStorageKey keeps every session/child scope for a conversation under one cleanup boundary.
|
|
func ConversationStorageKey(conversationID string) string {
|
|
return fmt.Sprintf("%x", sha256.Sum256([]byte(conversationID)))
|
|
}
|
|
|
|
type sessionLock struct {
|
|
token chan struct{}
|
|
refs int
|
|
}
|
|
|
|
var sessionLockMu sync.Mutex
|
|
var sessionLocks = map[string]*sessionLock{}
|
|
|
|
func acquireSession(ctx context.Context, dir string) (func(), error) {
|
|
if dir == "" {
|
|
return func() {}, nil
|
|
}
|
|
key, err := filepath.Abs(dir)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
sessionLockMu.Lock()
|
|
lock := sessionLocks[key]
|
|
if lock == nil {
|
|
lock = &sessionLock{token: make(chan struct{}, 1)}
|
|
sessionLocks[key] = lock
|
|
}
|
|
lock.refs++
|
|
sessionLockMu.Unlock()
|
|
remove := func() {
|
|
sessionLockMu.Lock()
|
|
defer sessionLockMu.Unlock()
|
|
lock.refs--
|
|
if lock.refs == 0 {
|
|
delete(sessionLocks, key)
|
|
}
|
|
}
|
|
select {
|
|
case lock.token <- struct{}{}:
|
|
return func() { <-lock.token; remove() }, nil
|
|
case <-ctx.Done():
|
|
remove()
|
|
return nil, ctx.Err()
|
|
}
|
|
}
|