chore: checkpoint 第一版
ci / verify (push) Canceled after 0s

This commit is contained in:
Codex Local
2026-09-06 17:04:11 +08:00
parent a8cdec98d1
commit 0c2151ace9
659 changed files with 185855 additions and 554 deletions
+41 -10
View File
@@ -27,6 +27,7 @@ type ConversationSummary struct {
SubjectID string `json:"subject_id"`
DeviceID string `json:"device_id"`
Status string `json:"status"`
RuntimeType string `json:"runtime_type"`
EngineMode string `json:"engine_mode"`
RetentionMode string `json:"retention_mode"`
AudioRetentionEnabled bool `json:"audio_retention_enabled"`
@@ -71,12 +72,23 @@ type RTCTaskSummary struct {
LastCheckedAt *time.Time `json:"last_checked_at,omitempty"`
}
type HardwareAgentTaskSummary struct {
Provider string `json:"provider"`
Status string `json:"status"`
Transport string `json:"transport"`
ProviderStartedAt *time.Time `json:"provider_started_at,omitempty"`
ProviderEndedAt *time.Time `json:"provider_ended_at,omitempty"`
LastEventAt *time.Time `json:"last_event_at,omitempty"`
LastEventSequence int64 `json:"last_event_sequence"`
}
type ConversationDetail struct {
ConversationSummary
HouseholdID string `json:"household_id"`
Snapshots ConversationSnapshotSummary `json:"snapshots"`
RTC *RTCTaskSummary `json:"rtc,omitempty"`
History []ConversationStateEntry `json:"history"`
HouseholdID string `json:"household_id"`
Snapshots ConversationSnapshotSummary `json:"snapshots"`
RTC *RTCTaskSummary `json:"rtc,omitempty"`
HardwareAgent *HardwareAgentTaskSummary `json:"hardware_agent,omitempty"`
History []ConversationStateEntry `json:"history"`
}
type ConversationUsageSummary struct {
@@ -109,7 +121,7 @@ func (s *Service) ListSubjectConversations(ctx context.Context, principal identi
cursorID = &decoded.ID
}
rows, err := s.pool.Query(ctx, `
SELECT c.public_id::text,$1::text,d.public_id::text,c.status,c.engine_mode,c.retention_mode,
SELECT c.public_id::text,$1::text,d.public_id::text,c.status,c.runtime_type,c.engine_mode,c.retention_mode,
c.started_at,c.ended_at,CASE WHEN c.started_at IS NOT NULL AND c.ended_at IS NOT NULL THEN (EXTRACT(EPOCH FROM (c.ended_at-c.started_at))*1000)::bigint END,
c.stop_reason,c.failure_code,c.created_at,c.updated_at
FROM conversation c JOIN device d ON d.id=c.device_id AND d.tenant_id=c.tenant_id
@@ -154,13 +166,17 @@ func (s *Service) GetConversation(ctx context.Context, principal identity.Princi
var rtcProvider, rtcStatus *string
var rtcLeaseExpiresAt, rtcLastCheckedAt *time.Time
var rtcStartAttempts, rtcStopAttempts *int
var hardwareProvider, hardwareStatus, hardwareTransport *string
var hardwareStartedAt, hardwareEndedAt, hardwareLastEventAt *time.Time
var hardwareLastSequence *int64
err := s.pool.QueryRow(ctx, `
SELECT c.public_id::text,sp.public_id::text,d.public_id::text,c.status,c.engine_mode,c.retention_mode,
SELECT c.public_id::text,sp.public_id::text,d.public_id::text,c.status,c.runtime_type,c.engine_mode,c.retention_mode,
c.started_at,c.ended_at,CASE WHEN c.started_at IS NOT NULL AND c.ended_at IS NOT NULL THEN (EXTRACT(EPOCH FROM (c.ended_at-c.started_at))*1000)::bigint END,
c.stop_reason,c.failure_code,c.created_at,c.updated_at,h.public_id::text,
cs.public_id::text,cs.snapshot_version,xs.public_id::text,xs.profile_version,xs.prompt_bundle_version,
xs.preparation_status,xs.preparation_failure_code,
r.provider,r.status,r.lease_expires_at,r.start_attempts,r.stop_attempts,r.last_checked_at
r.provider,r.status,r.lease_expires_at,r.start_attempts,r.stop_attempts,r.last_checked_at,
hs.provider,hs.status,hs.transport,hs.provider_started_at,hs.provider_ended_at,hs.last_event_at,hs.last_event_sequence
FROM conversation c
JOIN household h ON h.id=c.household_id AND h.tenant_id=c.tenant_id AND h.status <> 'deleted'
JOIN subject_profile sp ON sp.id=c.subject_id AND sp.tenant_id=c.tenant_id AND sp.status IN ('active','suspended')
@@ -168,14 +184,16 @@ func (s *Service) GetConversation(ctx context.Context, principal identity.Princi
JOIN consent_snapshot cs ON cs.id=c.consent_snapshot_id AND cs.tenant_id=c.tenant_id
JOIN context_snapshot xs ON xs.id=c.context_snapshot_id AND xs.tenant_id=c.tenant_id
LEFT JOIN rtc_task r ON r.conversation_id=c.id
LEFT JOIN hardware_agent_session hs ON hs.conversation_id=c.id AND hs.tenant_id=c.tenant_id
JOIN household_member hm ON hm.household_id=h.id AND hm.tenant_id=h.tenant_id AND hm.status='active'
JOIN user_account ua ON ua.id=hm.user_id AND ua.tenant_id=h.tenant_id AND ua.status='active'
WHERE c.public_id=$1::uuid AND ua.oidc_issuer=$2 AND ua.oidc_subject=$3`, conversationPublicID, principal.Issuer, principal.Subject).Scan(
&result.ID, &result.SubjectID, &result.DeviceID, &result.Status, &result.EngineMode, &result.RetentionMode,
&result.ID, &result.SubjectID, &result.DeviceID, &result.Status, &result.RuntimeType, &result.EngineMode, &result.RetentionMode,
&result.StartedAt, &result.EndedAt, &duration, &result.StopReason, &result.FailureCode, &result.CreatedAt, &result.UpdatedAt, &result.HouseholdID,
&result.Snapshots.ConsentSnapshotID, &result.Snapshots.ConsentSnapshotVersion, &result.Snapshots.ContextSnapshotID, &result.Snapshots.ProfileVersion, &result.Snapshots.PromptBundleVersion,
&result.Snapshots.ContextPreparationStatus, &result.Snapshots.ContextPreparationFailureCode,
&rtcProvider, &rtcStatus, &rtcLeaseExpiresAt, &rtcStartAttempts, &rtcStopAttempts, &rtcLastCheckedAt)
&rtcProvider, &rtcStatus, &rtcLeaseExpiresAt, &rtcStartAttempts, &rtcStopAttempts, &rtcLastCheckedAt,
&hardwareProvider, &hardwareStatus, &hardwareTransport, &hardwareStartedAt, &hardwareEndedAt, &hardwareLastEventAt, &hardwareLastSequence)
if errors.Is(err, pgx.ErrNoRows) {
return ConversationDetail{}, ErrAccessDenied
}
@@ -196,6 +214,19 @@ func (s *Service) GetConversation(ctx context.Context, principal identity.Princi
result.RTC.StopAttempts = *rtcStopAttempts
}
}
if hardwareProvider != nil {
result.HardwareAgent = &HardwareAgentTaskSummary{Provider: *hardwareProvider, ProviderStartedAt: hardwareStartedAt,
ProviderEndedAt: hardwareEndedAt, LastEventAt: hardwareLastEventAt}
if hardwareStatus != nil {
result.HardwareAgent.Status = *hardwareStatus
}
if hardwareTransport != nil {
result.HardwareAgent.Transport = *hardwareTransport
}
if hardwareLastSequence != nil {
result.HardwareAgent.LastEventSequence = *hardwareLastSequence
}
}
rows, err := s.pool.Query(ctx, `
SELECT h.from_status,h.to_status,h.reason,h.source,h.occurred_at
FROM conversation_state_history h JOIN conversation c ON c.id=h.conversation_id
@@ -264,7 +295,7 @@ func (s *Service) GetConversationUsage(ctx context.Context, principal identity.P
func scanConversationSummary(row rowScanner) (ConversationSummary, error) {
var item ConversationSummary
if err := row.Scan(&item.ID, &item.SubjectID, &item.DeviceID, &item.Status, &item.EngineMode, &item.RetentionMode,
if err := row.Scan(&item.ID, &item.SubjectID, &item.DeviceID, &item.Status, &item.RuntimeType, &item.EngineMode, &item.RetentionMode,
&item.StartedAt, &item.EndedAt, &item.DurationMS, &item.StopReason, &item.FailureCode, &item.CreatedAt, &item.UpdatedAt); err != nil {
return ConversationSummary{}, err
}