feat: expand companion platform, device controls, and memoir workflows
ci / verify (push) Canceled after 0s
ci / verify (push) Canceled after 0s
Add customer and operator login, BLE provisioning, device fleet controls, call memory, memoir generation, and refreshed family and maintenance portals. Include API contracts, migrations, firmware sources, tests, assets, and deployment documentation.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package callmemory
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"data-terminal-cloud/internal/elderagent"
|
||||
"data-terminal-cloud/internal/memoryidentity"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type nativeMemoryTestProvider struct{ configs []map[string]any }
|
||||
|
||||
func (p *nativeMemoryTestProvider) Ensure(context.Context, string, map[string]any, map[string]any) (elderagent.Bot, error) {
|
||||
panic("not used")
|
||||
}
|
||||
func (p *nativeMemoryTestProvider) Update(_ context.Context, _ string, c, a map[string]any) error {
|
||||
p.configs = append(p.configs, c)
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestDirectNativeMemoryUsesVikingWithoutPlatformFactsAndDisablesAfterWithdrawal(t *testing.T) {
|
||||
f, d := directFixture(t)
|
||||
f.add(t)
|
||||
f.exec(t, `UPDATE subject_voice_agent SET config='{"S2SConfig":{"ProviderParams":{"dialog":{"system_role":"基础人设"}}},"MemoryConfig":{"Enable":false}}'::jsonb WHERE subject_id=$1::uuid`, f.subject)
|
||||
provider := &nativeMemoryTestProvider{}
|
||||
agent := &elderagent.Service{Pool: f.p, Provider: provider, VikingCollectionName: "aiphone", VikingEventType: "event_v1", CallbackURL: "https://example.com/callback", CallbackSecret: []byte(strings.Repeat("k", 32))}
|
||||
f.s.direct.Prepare = agent.Prepare
|
||||
ctx := context.Background()
|
||||
sid := uuid.NewString()
|
||||
if _, err := f.s.DirectRequest(ctx, d, "start", DirectInput{SessionID: sid}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(provider.configs) != 1 {
|
||||
t.Fatal("provider not prepared")
|
||||
}
|
||||
c := provider.configs[0]
|
||||
m := c["MemoryConfig"].(map[string]any)
|
||||
filter := m["ProviderParams"].(map[string]any)["filter"].(map[string]any)
|
||||
if m["Enable"] != true || filter["user_id"].([]string)[0] != memoryidentity.UserID(f.tenant, f.subject) {
|
||||
t.Fatal("Viking identity does not match uploads", m)
|
||||
}
|
||||
role := c["S2SConfig"].(map[string]any)["ProviderParams"].(map[string]any)["dialog"].(map[string]any)["system_role"].(string)
|
||||
if strings.Contains(role, "喜欢喝淡茶") || strings.Contains(role, "<资料>") {
|
||||
t.Fatal("platform facts entered prompt")
|
||||
}
|
||||
var mode string
|
||||
if err := f.p.QueryRow(ctx, `SELECT memory_mode FROM call_session WHERE id=$1::uuid`, sid).Scan(&mode); err != nil || mode != "NATIVE_VIKING" {
|
||||
t.Fatal("incorrect frozen memory mode", mode, err)
|
||||
}
|
||||
if _, err := f.s.DirectRequest(ctx, d, "end", DirectInput{SessionID: sid, Reason: "hangup", SDKStopped: true}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f.exec(t, `UPDATE consent_record SET withdrawn_at=now() WHERE subject_id=$1::uuid AND consent_type='personalized_memory' AND withdrawn_at IS NULL`, f.subject)
|
||||
if _, err := f.s.DirectRequest(ctx, d, "start", DirectInput{SessionID: uuid.NewString()}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m = provider.configs[1]["MemoryConfig"].(map[string]any)
|
||||
if m["Enable"] != false || len(m) != 1 {
|
||||
t.Fatal("withdrawn memory still has retrieval filters", m)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user