repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import { createSlice, PayloadAction } from '@reduxjs/toolkit'; |
| #2 | |
| #3 | export interface AppMemory { |
| #4 | id: string; |
| #5 | user_id: string; |
| #6 | content: string; |
| #7 | state: string; |
| #8 | updated_at: string; |
| #9 | deleted_at: string | null; |
| #10 | app_id: string; |
| #11 | vector: any; |
| #12 | metadata_: Record<string, any>; |
| #13 | created_at: string; |
| #14 | archived_at: string | null; |
| #15 | categories: string[]; |
| #16 | app_name: string; |
| #17 | } |
| #18 | |
| #19 | export interface AccessedMemory { |
| #20 | memory: AppMemory; |
| #21 | access_count: number; |
| #22 | } |
| #23 | |
| #24 | export interface AppDetails { |
| #25 | is_active: boolean; |
| #26 | total_memories_created: number; |
| #27 | total_memories_accessed: number; |
| #28 | first_accessed: string | null; |
| #29 | last_accessed: string | null; |
| #30 | } |
| #31 | |
| #32 | export interface App { |
| #33 | id: string; |
| #34 | name: string; |
| #35 | total_memories_created: number; |
| #36 | total_memories_accessed: number; |
| #37 | is_active?: boolean; |
| #38 | } |
| #39 | |
| #40 | interface MemoriesState { |
| #41 | items: AppMemory[]; |
| #42 | total: number; |
| #43 | page: number; |
| #44 | loading: boolean; |
| #45 | error: string | null; |
| #46 | } |
| #47 | |
| #48 | interface AccessedMemoriesState { |
| #49 | items: AccessedMemory[]; |
| #50 | total: number; |
| #51 | page: number; |
| #52 | loading: boolean; |
| #53 | error: string | null; |
| #54 | } |
| #55 | |
| #56 | interface AppsState { |
| #57 | apps: App[]; |
| #58 | status: 'idle' | 'loading' | 'succeeded' | 'failed'; |
| #59 | error: string | null; |
| #60 | filters: { |
| #61 | searchQuery: string; |
| #62 | isActive: 'all' | true | false; |
| #63 | sortBy: 'name' | 'memories' | 'memories_accessed'; |
| #64 | sortDirection: 'asc' | 'desc'; |
| #65 | }; |
| #66 | selectedApp: { |
| #67 | details: AppDetails | null; |
| #68 | memories: { |
| #69 | created: MemoriesState; |
| #70 | accessed: AccessedMemoriesState; |
| #71 | }; |
| #72 | loading: boolean; |
| #73 | error: string | null; |
| #74 | }; |
| #75 | } |
| #76 | |
| #77 | const initialMemoriesState: MemoriesState = { |
| #78 | items: [], |
| #79 | total: 0, |
| #80 | page: 1, |
| #81 | loading: false, |
| #82 | error: null, |
| #83 | }; |
| #84 | |
| #85 | const initialAccessedMemoriesState: AccessedMemoriesState = { |
| #86 | items: [], |
| #87 | total: 0, |
| #88 | page: 1, |
| #89 | loading: false, |
| #90 | error: null, |
| #91 | }; |
| #92 | |
| #93 | const initialState: AppsState = { |
| #94 | apps: [], |
| #95 | status: 'idle', |
| #96 | error: null, |
| #97 | filters: { |
| #98 | searchQuery: '', |
| #99 | isActive: 'all', |
| #100 | sortBy: 'name', |
| #101 | sortDirection: 'asc' |
| #102 | }, |
| #103 | selectedApp: { |
| #104 | details: null, |
| #105 | memories: { |
| #106 | created: initialMemoriesState, |
| #107 | accessed: initialAccessedMemoriesState, |
| #108 | }, |
| #109 | loading: false, |
| #110 | error: null, |
| #111 | }, |
| #112 | }; |
| #113 | |
| #114 | const appsSlice = createSlice({ |
| #115 | name: 'apps', |
| #116 | initialState, |
| #117 | reducers: { |
| #118 | setAppsLoading: (state) => { |
| #119 | state.status = 'loading'; |
| #120 | state.error = null; |
| #121 | }, |
| #122 | setAppsSuccess: (state, action: PayloadAction<App[]>) => { |
| #123 | state.status = 'succeeded'; |
| #124 | state.apps = action.payload; |
| #125 | state.error = null; |
| #126 | }, |
| #127 | setAppsError: (state, action: PayloadAction<string>) => { |
| #128 | state.status = 'failed'; |
| #129 | state.error = action.payload; |
| #130 | }, |
| #131 | resetAppsState: (state) => { |
| #132 | state.status = 'idle'; |
| #133 | state.error = null; |
| #134 | state.apps = []; |
| #135 | state.selectedApp = initialState.selectedApp; |
| #136 | }, |
| #137 | setSelectedAppLoading: (state) => { |
| #138 | state.selectedApp.loading = true; |
| #139 | }, |
| #140 | setSelectedAppDetails: (state, action: PayloadAction<AppDetails>) => { |
| #141 | state.selectedApp.details = action.payload; |
| #142 | state.selectedApp.loading = false; |
| #143 | state.selectedApp.error = null; |
| #144 | }, |
| #145 | setSelectedAppError: (state, action: PayloadAction<string>) => { |
| #146 | state.selectedApp.loading = false; |
| #147 | state.selectedApp.error = action.payload; |
| #148 | }, |
| #149 | setCreatedMemoriesLoading: (state) => { |
| #150 | state.selectedApp.memories.created.loading = true; |
| #151 | state.selectedApp.memories.created.error = null; |
| #152 | }, |
| #153 | setCreatedMemoriesSuccess: (state, action: PayloadAction<{ items: AppMemory[]; total: number; page: number }>) => { |
| #154 | state.selectedApp.memories.created.items = action.payload.items; |
| #155 | state.selectedApp.memories.created.total = action.payload.total; |
| #156 | state.selectedApp.memories.created.page = action.payload.page; |
| #157 | state.selectedApp.memories.created.loading = false; |
| #158 | state.selectedApp.memories.created.error = null; |
| #159 | }, |
| #160 | setCreatedMemoriesError: (state, action: PayloadAction<string>) => { |
| #161 | state.selectedApp.memories.created.loading = false; |
| #162 | state.selectedApp.memories.created.error = action.payload; |
| #163 | }, |
| #164 | setAccessedMemoriesLoading: (state) => { |
| #165 | state.selectedApp.memories.accessed.loading = true; |
| #166 | state.selectedApp.memories.accessed.error = null; |
| #167 | }, |
| #168 | setAccessedMemoriesSuccess: (state, action: PayloadAction<{ items: AccessedMemory[]; total: number; page: number }>) => { |
| #169 | state.selectedApp.memories.accessed.items = action.payload.items; |
| #170 | state.selectedApp.memories.accessed.total = action.payload.total; |
| #171 | state.selectedApp.memories.accessed.page = action.payload.page; |
| #172 | state.selectedApp.memories.accessed.loading = false; |
| #173 | state.selectedApp.memories.accessed.error = null; |
| #174 | }, |
| #175 | setAccessedMemoriesError: (state, action: PayloadAction<string>) => { |
| #176 | state.selectedApp.memories.accessed.loading = false; |
| #177 | state.selectedApp.memories.accessed.error = action.payload; |
| #178 | }, |
| #179 | setAppDetails: (state, action: PayloadAction<{ appId: string; isActive: boolean }>) => { |
| #180 | const app = state.apps.find(app => app.id === action.payload.appId); |
| #181 | if (app) { |
| #182 | app.is_active = action.payload.isActive; |
| #183 | } |
| #184 | if (state.selectedApp.details) { |
| #185 | state.selectedApp.details.is_active = action.payload.isActive; |
| #186 | } |
| #187 | }, |
| #188 | setSearchQuery: (state, action: PayloadAction<string>) => { |
| #189 | state.filters.searchQuery = action.payload; |
| #190 | }, |
| #191 | setActiveFilter: (state, action: PayloadAction<'all' | true | false>) => { |
| #192 | state.filters.isActive = action.payload; |
| #193 | }, |
| #194 | setSortBy: (state, action: PayloadAction<'name' | 'memories' | 'memories_accessed'>) => { |
| #195 | state.filters.sortBy = action.payload; |
| #196 | }, |
| #197 | setSortDirection: (state, action: PayloadAction<'asc' | 'desc'>) => { |
| #198 | state.filters.sortDirection = action.payload; |
| #199 | }, |
| #200 | }, |
| #201 | }); |
| #202 | |
| #203 | export const { |
| #204 | setAppsLoading, |
| #205 | setAppsSuccess, |
| #206 | setAppsError, |
| #207 | resetAppsState, |
| #208 | setSelectedAppLoading, |
| #209 | setSelectedAppDetails, |
| #210 | setSelectedAppError, |
| #211 | setCreatedMemoriesLoading, |
| #212 | setCreatedMemoriesSuccess, |
| #213 | setCreatedMemoriesError, |
| #214 | setAccessedMemoriesLoading, |
| #215 | setAccessedMemoriesSuccess, |
| #216 | setAccessedMemoriesError, |
| #217 | setAppDetails, |
| #218 | setSearchQuery, |
| #219 | setActiveFilter, |
| #220 | setSortBy, |
| #221 | setSortDirection, |
| #222 | } = appsSlice.actions; |
| #223 | |
| #224 | export default appsSlice.reducer; |