feat: enable S2S with native Viking memory
This commit is contained in:
@@ -42,13 +42,28 @@ func (s *Service) CreateHardwareAgent(ctx context.Context, identity deviceauth.I
|
||||
return HardwareAgentCreateResponse{}, false, err
|
||||
}
|
||||
var vikingSubject, vikingContext string
|
||||
var vikingNativeMemory *HardwareAgentMemoryConfig
|
||||
if s.viking != nil {
|
||||
readContext, cancel := context.WithTimeout(ctx, 3*time.Second)
|
||||
var readErr error
|
||||
vikingSubject, vikingContext, readErr = s.viking.PrepareForDevice(readContext, identity.TenantID, identity.ID)
|
||||
native, readErr := s.viking.NativeAccessForDevice(readContext, identity.TenantID, identity.ID)
|
||||
cancel()
|
||||
if readErr != nil {
|
||||
slog.WarnContext(ctx, "Viking startup memory unavailable", "error", readErr)
|
||||
slog.WarnContext(ctx, "Viking native memory configuration unavailable", "error", readErr)
|
||||
} else if native != nil {
|
||||
vikingSubject = native.SubjectID
|
||||
vikingNativeMemory = &HardwareAgentMemoryConfig{
|
||||
CollectionName: native.CollectionName, UserID: native.UserID, AssistantID: native.AssistantID,
|
||||
MemoryTypes: native.MemoryTypes, Limit: native.Limit, TransitionWords: native.TransitionWords,
|
||||
}
|
||||
} else {
|
||||
// Older deployments without a native collection name keep the
|
||||
// platform-side startup retrieval path as a compatibility fallback.
|
||||
fallbackContext, fallbackCancel := context.WithTimeout(ctx, 3*time.Second)
|
||||
vikingSubject, vikingContext, readErr = s.viking.PrepareForDevice(fallbackContext, identity.TenantID, identity.ID)
|
||||
fallbackCancel()
|
||||
if readErr != nil {
|
||||
slog.WarnContext(ctx, "Viking startup memory unavailable", "error", readErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
result, err := s.executor.Execute(ctx, request, func(operationContext context.Context, tx pgx.Tx) (idempotency.Result, error) {
|
||||
@@ -61,7 +76,7 @@ func (s *Service) CreateHardwareAgent(ctx context.Context, identity deviceauth.I
|
||||
TokenExpires: now.Add(s.options.TokenTTL), RTCAppID: s.options.RTCAppID,
|
||||
VoiceProvider: s.options.VoiceProvider, EngineMode: s.options.EngineMode,
|
||||
HeartbeatInterval: s.options.HeartbeatInterval, MemoryQueryVector: memoryVector,
|
||||
VikingSubjectID: vikingSubject, VikingContext: vikingContext,
|
||||
VikingSubjectID: vikingSubject, VikingContext: vikingContext, VikingNativeMemory: vikingNativeMemory,
|
||||
MemoryPolicy: memoryPolicy, RequirePublishedRouting: s.options.RequirePublishedRouting,
|
||||
RuntimeType: RuntimeVolcHardwareAgent, HardwareBotID: s.options.HardwareBotID,
|
||||
HardwareTransport: s.options.HardwareTransport, HardwareCapabilities: input.Capabilities,
|
||||
|
||||
Reference in New Issue
Block a user