71c7672545
* feat(skill-hub): add Skill Hub catalog, publish flow, and lite materialize pipeline Introduce Skill Hub for browsing, importing, publishing, and installing skills, with lite instance package materialization and runtime sync support. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(skill-hub): remove token-governance hooks from Skill Hub PR Strip validateManagedRuntimeEnvironmentOverrides, network lock policy sync, and egress proxy audit wiring that belong to the upcoming token-usage work, so the Skill Hub branch compiles independently. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(skill-hub): update migration number in materialize docs Co-authored-by: Cursor <cursoragent@cursor.com> * fix(skill-hub): make RuntimeAgentClient test stub and hub tests compile-safe Add ResyncInstanceSkills to the runtime pool handler fake client, and harden skill hub payload helpers/tests against nil storage/instance repos so go test passes. Co-authored-by: Cursor <cursoragent@cursor.com> * feat: add Skill Hub hardening with session usage tracking and egress governance Unify Skill Hub runtime sync improvements with session-token observability, egress network policy, and admin/instance usage reporting for reopenable PR. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(skill-hub): repair CI tests and nested skill install * fix(ci): restore release deployment configuration --------- Co-authored-by: heshengran <heshengran@ieisystem.com> Co-authored-by: Cursor <cursoragent@cursor.com>
64 lines
1.7 KiB
Go
64 lines
1.7 KiB
Go
package aigateway
|
|
|
|
import "strings"
|
|
|
|
const defaultManagedSessionKey = "main"
|
|
|
|
// IsManagedInstanceType reports whether an instance type participates in managed
|
|
// runtime LLM governance (OpenClaw / Hermes).
|
|
func IsManagedInstanceType(instanceType string) bool {
|
|
switch strings.ToLower(strings.TrimSpace(instanceType)) {
|
|
case "openclaw", "hermes":
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
// HasExplicitSessionIdentity returns true when the caller supplied a stable
|
|
// session identifier via header or request body fields.
|
|
func HasExplicitSessionIdentity(req ChatCompletionRequest) bool {
|
|
if req.OpenClawSessionKey != nil && strings.TrimSpace(*req.OpenClawSessionKey) != "" {
|
|
return true
|
|
}
|
|
if normalizeOptionalString(req.SessionID) != "" {
|
|
return true
|
|
}
|
|
if normalizeOptionalString(req.User) != "" {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// ApplyManagedInstanceSessionDefaults fills in the default OpenClaw/Hermes session
|
|
// key for instance gateway token calls that omitted explicit session identity.
|
|
func ApplyManagedInstanceSessionDefaults(req *ChatCompletionRequest, gatewayAuthType, instanceType string) {
|
|
if req == nil {
|
|
return
|
|
}
|
|
if strings.TrimSpace(gatewayAuthType) != "instance" {
|
|
return
|
|
}
|
|
instanceType = strings.TrimSpace(instanceType)
|
|
if !IsManagedInstanceType(instanceType) {
|
|
return
|
|
}
|
|
req.ManagedAgentType = stringPtr(instanceType)
|
|
if HasExplicitSessionIdentity(*req) {
|
|
return
|
|
}
|
|
req.OpenClawSessionKey = stringPtr(defaultManagedSessionKey)
|
|
}
|
|
|
|
func sessionNormalizationRuntimeType(req ChatCompletionRequest) string {
|
|
if req.ManagedAgentType != nil {
|
|
if runtimeType := strings.TrimSpace(*req.ManagedAgentType); runtimeType != "" {
|
|
return runtimeType
|
|
}
|
|
}
|
|
if req.RuntimeType != nil {
|
|
return strings.TrimSpace(*req.RuntimeType)
|
|
}
|
|
return ""
|
|
}
|