Stateful Apps API¶
Package Exports¶
PARE applications extending Meta ARE with stateful navigation.
AppState
¶
Bases: ABC
Base class for navigation states.
Each state represents a screen/view of the app on the mobile phone. Navigation states form an MDP where each state has specific available actions.
Note: Different from Meta AREs data state (JSON)
Source code in pare/apps/core.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
app
property
¶
Get the app this state is bound to.
__init__()
¶
Initialize the app tools.
Source code in pare/apps/core.py
31 32 33 34 | |
bind_to_app(app)
¶
Bind this state to an app (late binding).
Called automatically by StatefulApp.set_current_state().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
App
|
The app this state belongs to |
required |
Source code in pare/apps/core.py
36 37 38 39 40 41 42 43 44 | |
get_available_actions()
¶
Get user tools (actions) available from this navigation state.
These are valid actions for the user in this App MDP from this state.
Returns:
| Type | Description |
|---|---|
list[AppTool]
|
list[AppTool]: A list of AppTool objects representing the available actions. |
Source code in pare/apps/core.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
on_enter()
abstractmethod
¶
Called when transitioning into this state.
Override to handle state initialization, load data, update anything, etc. We don't know if this is useful yet.
Source code in pare/apps/core.py
76 77 78 79 80 81 82 | |
on_exit()
abstractmethod
¶
Called when transitioning out of this state.
Override to handle state cleanup, save data, etc. We don't know if this is useful yet.
Source code in pare/apps/core.py
84 85 86 87 88 89 90 | |
HomeScreenSystemApp
¶
Bases: SystemApp
System app that exposes user tools for switching contexts.
Source code in pare/apps/system.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
__init__(*args, **kwargs)
¶
Initialise the system app (callbacks will be set by environment).
Source code in pare/apps/system.py
18 19 20 21 22 23 | |
go_home()
¶
Return to the home screen. This will allow the user to open a new app.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A message indicating the home screen action. |
Source code in pare/apps/system.py
36 37 38 39 40 41 42 43 44 45 46 | |
open_app(app_name)
¶
Open the requested app. If the app is already open and it is in background, then the phone will switch to it. If the app is not open, then a it is opened to the home page of that app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_name
|
str
|
The name of the app to open (case-sensitive). The app must be availabe in the environment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A message indicating the open app action. |
Source code in pare/apps/system.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
set_callbacks(switch_app_callback, open_app_callback, go_home_callback)
¶
Set the navigation callbacks (called by environment after initialization).
Source code in pare/apps/system.py
25 26 27 28 29 30 31 32 33 34 | |
switch_app(app_name)
¶
Switch to the requested app and preserve the current app state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_name
|
str
|
The name of the app to switch to (case-sensitive). The app must be open and availabe in the environment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A message indicating the switch app action. |
Source code in pare/apps/system.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
PAREAgentUserInterface
¶
Bases: AgentUserInterface
Agent-user interface extended with proactive proposal acceptance and rejection support.
Adds tools which the user agent uses to accept or reject the proactive agent's proposal.
Source code in pare/apps/proactive_aui.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
__init__(*args, **kwargs)
¶
Initialize the proactive agent-user interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Any
|
Arguments to pass to the app |
()
|
kwargs
|
Any
|
Keyword arguments to pass to the app |
{}
|
Source code in pare/apps/proactive_aui.py
21 22 23 24 25 26 27 28 | |
accept_proposal(content='')
¶
User accepts the pending proactive proposal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
The content of the message to send to the agent |
''
|
Returns:
| Type | Description |
|---|---|
str
|
The message ID that was generated for this message, can be used for tracking |
Source code in pare/apps/proactive_aui.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
reject_proposal(content='')
¶
User rejects the pending proactive proposal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
The content of the message to send to the agent |
''
|
Returns:
| Type | Description |
|---|---|
str
|
The message ID that was generated for this message, can be used for tracking |
Source code in pare/apps/proactive_aui.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
wait()
¶
Observe and wait without taking action.
Use this when you want to continue monitoring but don't have a specific proposal or message for the user yet.
Returns:
| Type | Description |
|---|---|
str
|
Confirmation that the agent is in observation mode. |
Source code in pare/apps/proactive_aui.py
60 61 62 63 64 65 66 67 68 69 70 71 72 | |
StatefulApartmentApp
¶
Bases: StatefulApp, ApartmentListingApp
Apartment app with navigation-aware PARE behavior.
Source code in pare/apps/apartment/app.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
__init__(*args, **kwargs)
¶
Initialize apartment app and load the root navigation state.
Source code in pare/apps/apartment/app.py
24 25 26 27 | |
create_root_state()
¶
Return the root navigation state for the apartment app.
Source code in pare/apps/apartment/app.py
29 30 31 | |
handle_state_transition(event)
¶
Update navigation state after an apartment operation completes.
Source code in pare/apps/apartment/app.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
StatefulApp
¶
Bases: App
Base class for a stateful app.
This class implements the basic functionality needed for a finite state machine based mobile app.
Source code in pare/apps/core.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |
__init__(name=None, *args, **kwargs)
¶
Initialize the stateful app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name of the app. |
None
|
args
|
Any
|
The arguments to pass to the app. |
()
|
kwargs
|
Any
|
The keyword arguments to pass to the app. |
{}
|
Source code in pare/apps/core.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
create_root_state()
abstractmethod
¶
Return a freshly constructed root navigation state.
Source code in pare/apps/core.py
146 147 148 | |
get_meta_are_user_tools()
¶
Return Meta ARE-compatible tool adapters for the current navigation state.
Source code in pare/apps/core.py
193 194 195 196 197 198 199 200 201 202 203 204 | |
get_reachable_states(from_state)
¶
Get the reachable states from the given state.
TODO: implement after MVP
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_state
|
AppState
|
The state to get the reachable states from. |
required |
Returns:
| Type | Description |
|---|---|
list[type[AppState]]
|
list[type[AppState]]: The reachable states from the given state. |
Source code in pare/apps/core.py
230 231 232 233 234 235 236 237 238 239 240 241 | |
get_state_graph()
¶
Get the state graph of the app.
TODO: implement after MVP
Returns:
| Type | Description |
|---|---|
dict[str, list[str]]
|
dict[str, list[str]]: The state graph of the app. |
Source code in pare/apps/core.py
220 221 222 223 224 225 226 227 228 | |
get_tools()
¶
Get the tools of the app.
Source code in pare/apps/core.py
206 207 208 | |
get_tools_with_attribute(attribute, tool_type)
¶
Return tools by attribute/tool type, extended for PARE stateful apps.
- If tool_type/attribute correspond to USER tools, include state-bound user tools.
- Otherwise, defer to Meta-ARE base implementation.
- Special case: if both tool_type and attribute are None, return "event-only" tools: methods decorated with @event_registered-like decorator but without any of @app_tool, @user_tool, @env_tool, @data_tool. Detected via AST across the MRO.
Source code in pare/apps/core.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
get_user_tools()
¶
Get user tools from the current state of the app.
User tools are state dependent and manage context. Each state will only enable some of the available actions in the app.
Returns:
| Type | Description |
|---|---|
list[AppTool]
|
list[AppTool]: A list of AppTool objects representing the available user tools. |
Source code in pare/apps/core.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
go_back()
¶
Navigate back to the previous state of the app.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A message indicating the navigation back action. |
Source code in pare/apps/core.py
161 162 163 164 165 166 167 168 169 170 171 172 173 | |
handle_state_transition(event)
¶
Update the current state of the app based on the tool events.
This implements the state transition function T(s,a) -> s' for app specific transitions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
CompletedEvent
|
The completed event. |
required |
Source code in pare/apps/core.py
210 211 212 213 214 215 216 217 218 | |
load_root_state()
¶
Reset the app to its root navigation state.
Source code in pare/apps/core.py
150 151 152 153 | |
reset_to_root()
¶
Reset to the root navigation state and report the new view.
Source code in pare/apps/core.py
155 156 157 158 159 | |
set_current_state(app_state)
¶
Set the current state of the app.
This is called by handle_state_transition to update the current state of the app. This function will
1. Binds the state to app
2. Calls on_exit on the old state
3. Pushes the old state to the navigation stack (for go_back())
4. Calls on_enter on the new state (initialization/data loading)
5. Sets the current state to the new state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_state
|
AppState
|
The state to set. |
required |
Source code in pare/apps/core.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
StatefulCabApp
¶
Bases: StatefulApp, CabApp
Cab client with navigation-aware user tool exposure.
Source code in pare/apps/cab/app.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
__init__(*args, **kwargs)
¶
Initialise the cab app and load the default home screen.
Source code in pare/apps/cab/app.py
24 25 26 27 | |
create_root_state()
¶
Return the root navigation state for the cab app.
Source code in pare/apps/cab/app.py
29 30 31 | |
handle_state_transition(event)
¶
Update navigation state after a cab operation completes.
Source code in pare/apps/cab/app.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
StatefulCalendarApp
¶
Bases: StatefulApp, CalendarV2
Calendar client with navigation-aware user tool exposure.
Source code in pare/apps/calendar/app.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
__init__(*args, **kwargs)
¶
Initialise the calendar app and seed the agenda with the current day.
Source code in pare/apps/calendar/app.py
23 24 25 26 | |
create_root_state()
¶
Return the root agenda view scoped to the current day.
Source code in pare/apps/calendar/app.py
177 178 179 180 | |
get_reachable_states(from_state)
¶
Return the reachable states from the provided state.
Source code in pare/apps/calendar/app.py
186 187 188 | |
get_state_graph()
¶
Return the navigation graph for the calendar app.
Source code in pare/apps/calendar/app.py
182 183 184 | |
handle_state_transition(event)
¶
Update navigation state in response to user tool completions.
Source code in pare/apps/calendar/app.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
StatefulContactsApp
¶
Bases: StatefulApp, ContactsApp
Contacts application with explicit navigation states.
Source code in pare/apps/contacts/app.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
__init__(*args, **kwargs)
¶
Initialise the contacts app and load the list view as the default state.
Source code in pare/apps/contacts/app.py
35 36 37 38 39 40 41 | |
clear_contact_transition()
¶
Reset any queued contact transition intent.
Source code in pare/apps/contacts/app.py
47 48 49 | |
create_root_state()
¶
Return the root navigation state for the contacts app.
Source code in pare/apps/contacts/app.py
128 129 130 | |
handle_state_transition(event)
¶
Update navigation state based on completed contact operations.
Source code in pare/apps/contacts/app.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
queue_contact_transition(intent, contact_id)
¶
Record a desired transition that should fire after the next contacts API call.
Source code in pare/apps/contacts/app.py
43 44 45 | |
StatefulEmailApp
¶
Bases: StatefulApp, EmailClientV2
Email client with navigation state management for user tool filtering.
Source code in pare/apps/email/app.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init__(*args, **kwargs)
¶
Initialise the email app with the inbox as the starting state.
Source code in pare/apps/email/app.py
22 23 24 25 26 | |
create_root_state()
¶
Return the mailbox view rooted in the inbox.
Source code in pare/apps/email/app.py
255 256 257 | |
handle_state_transition(event)
¶
Update navigation state in response to completed tool events.
Source code in pare/apps/email/app.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
send_email_to_user_with_id(email_id, sender, subject='', content='', attachment_paths=None)
¶
Create an incoming email with a specified ID (optionally with attachments) and add it to user's INBOX.
This is a PARE-specific environment tool that allows scenarios to reference the email_id in subsequent events (e.g., for replying to the email).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email_id
|
str
|
The ID to assign to this email. |
required |
sender
|
str
|
The sender of the email. |
required |
subject
|
str
|
The subject of the email. |
''
|
content
|
str
|
The content of the email. |
''
|
attachment_paths
|
list[str] | None
|
Optional list of attachment paths to add to the email.
NOTE: Attachments are read from |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The email_id that was provided. |
Source code in pare/apps/email/app.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
send_reply_from_draft(draft)
¶
Send a reply using the draft metadata, preserving user edits.
Source code in pare/apps/email/app.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
StatefulMessagingApp
¶
Bases: StatefulApp, MessagingAppV2
Messaging app with navigation state management.
// RL NOTE: This implements a simple 2-state MDP for messaging: // States: ConversationList, ConversationOpened // Transitions: open_conversation, go_back
Source code in pare/apps/messaging/app.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
__init__(*args, **kwargs)
¶
Initialize the stateful messaging app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Variable length argument list passed to parent classes. |
()
|
**kwargs
|
Any
|
Arbitrary keyword arguments passed to parent classes. |
{}
|
Source code in pare/apps/messaging/app.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
add_contacts(contacts)
¶
Add contacts (name, phone) to the internal name/id maps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contacts
|
list[tuple[str, str]]
|
Pairs of (user_name, phone). |
required |
Source code in pare/apps/messaging/app.py
51 52 53 54 55 56 57 58 59 60 | |
add_users(user_names)
¶
Add users to the internal name/id maps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_names
|
list[str]
|
User display names to ensure exist in the mapping. |
required |
Source code in pare/apps/messaging/app.py
39 40 41 42 43 44 45 46 47 48 49 | |
create_root_state()
¶
Return the conversation list root state.
Source code in pare/apps/messaging/app.py
85 86 87 | |
handle_state_transition(event)
¶
Handle state transitions based on tool events.
// RL NOTE: This implements T(s,a) -> s' for the messaging MDP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
CompletedEvent
|
Completed event from tool execution |
required |
Source code in pare/apps/messaging/app.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
StatefulNotesApp
dataclass
¶
Bases: StatefulApp
A Notes application that manages user's notes and folder organization. This class provides comprehensive functionality for handling notes including creating, updating, deleting, and searching notes.
This app maintains the notes in different folders. Default folders are "Inbox", "Personal", and "Work". New folders can be created by the user.
Key Features: - Note Management: Create, update, move and delete notes - Folder Management: Create, delete, and search folders (Default folders cannot be deleted) - Attachment Management: Handle note attachments (upload and download) - Search Functionality: Search notes across folders with text-based queries - State Management: Save and load application state
Key Components: - Folders: Each NotesFolder instance maintains its own collection of notes - View Limits: Configurable limit for note viewing and pagination - Event Registration: All operations are tracked through event registration
Notes: - Note IDs are automatically generated when creating new notes. - Attachments are handled using base64 encoding. - Search operations are case-insensitive. - All notes operations maintain folder integrity.
Source code in pare/apps/note/app.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | |
__post_init__()
¶
Initialize app with default folders.
Source code in pare/apps/note/app.py
183 184 185 186 187 188 189 190 191 192 193 | |
add_attachment(note, attachment_path)
¶
Add a file attachment to a note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note
|
Note
|
The note to add the attachment to. |
required |
attachment_path
|
str
|
The path to the attachment to add. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Note |
Note
|
The updated note object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If file does not exist. |
Source code in pare/apps/note/app.py
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 | |
add_attachment_to_note(note_id, attachment_path)
¶
Add a file attachment to a note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
The ID of the note to add the attachment to. |
required |
attachment_path
|
str
|
The path to the attachment to add. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ID of the note that the attachment was added to. |
Source code in pare/apps/note/app.py
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | |
connect_to_protocols(protocols)
¶
Connect to the given list of protocols.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
protocols
|
dict[Protocol, Any]
|
Dictionary of protocols. |
required |
Source code in pare/apps/note/app.py
195 196 197 198 199 200 201 202 203 | |
create_note(folder='Inbox', title='', content='', pinned=False)
¶
Create a new note with title and content. If title string is empty, it will be set to the first 50 characters of the content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Folder to create the note under. |
'Inbox'
|
title
|
str
|
Title of the note. |
''
|
content
|
str
|
Content of the note. |
''
|
pinned
|
bool
|
Whether the note should be pinned. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
ID of the newly created note. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If specified folder is not found. |
Source code in pare/apps/note/app.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
create_note_with_time(folder='Inbox', title='', content='', pinned=False, created_at=datetime.now(UTC).strftime('%Y-%m-%d %H:%M:%S'), updated_at=None)
¶
Create a new note with title and content at a specific time. If title string is empty, it will be set to the first 50 characters of the content. If specified folder is not found, a new folder will be created.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Folder to create the note under. |
'Inbox'
|
title
|
str
|
Title of the note. |
''
|
content
|
str
|
Content of the note. |
''
|
pinned
|
bool
|
Whether the note should be pinned. |
False
|
created_at
|
str
|
Time of the note creation. Defaults to the current time. |
strftime('%Y-%m-%d %H:%M:%S')
|
updated_at
|
str
|
Time of the note update. Defaults to the creation time. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
ID of the newly created note. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If creation or update time is invalid, or if updated time is before creation time. |
Source code in pare/apps/note/app.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
create_root_state()
¶
Return the root navigation state.
Returns:
| Name | Type | Description |
|---|---|---|
NoteList |
NoteList
|
Default folder view. |
Source code in pare/apps/note/app.py
205 206 207 208 209 210 211 | |
delete_folder(folder_name)
¶
Delete a folder and all it's notes. Default folders "Inbox", "Personal", and "Work" cannot be deleted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_name
|
str
|
Name of the folder to delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Name of the deleted folder if successful. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If folder does not exist, or if the folder to be deleted is one of the default folders. |
Source code in pare/apps/note/app.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
delete_note(note_id)
¶
Delete a note with the specified ID. Deleted Note ID is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
ID of note to delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
ID of the deleted note. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If note ID is not a string. |
ValueError
|
If note ID is empty. |
KeyError
|
If note not found. |
Source code in pare/apps/note/app.py
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | |
duplicate_note(folder_name, note_id)
¶
Create a duplicated copy of a note. The new note is added to the same folder as the original note and the title is "Copy of
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_name
|
str
|
The folder of the original note. Defaults to Inbox. |
required |
note_id
|
str
|
The ID of the note to copy. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ID of the newly created duplicate. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If folder not found or note not found in folder. |
Source code in pare/apps/note/app.py
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | |
get_note_by_id(note_id)
¶
Retrieve a note by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
Target note ID. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Note |
Note
|
The retrieved note object. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If note not found. |
Source code in pare/apps/note/app.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | |
get_state()
¶
Serialize app state.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Complete app state. |
Source code in pare/apps/note/app.py
213 214 215 216 217 218 219 220 221 222 | |
handle_state_transition(event)
¶
Core navigation handler mapping backend operations to state transitions.
Source code in pare/apps/note/app.py
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 | |
list_attachments(note_id)
¶
List attachment identifiers for a note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
Target note ID. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: Attachment list. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If note not found. |
Source code in pare/apps/note/app.py
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 | |
list_folders()
¶
List all folder names.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: Folder list. |
Source code in pare/apps/note/app.py
564 565 566 567 568 569 570 571 572 573 | |
list_notes(folder, offset=0, limit=10)
¶
List notes in the specific folder with a specified offset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
The folder to list notes from. |
required |
offset
|
int
|
The offset of the first note to return. |
0
|
limit
|
int
|
The maximum number of notes to return. |
10
|
Returns:
| Name | Type | Description |
|---|---|---|
ReturnedNotes |
ReturnedNotes
|
Notes with additional metadata about the range of notes retrieved and total number of notes |
Source code in pare/apps/note/app.py
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
load_state(state_dict)
¶
Deserialize app state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_dict
|
dict[str, Any]
|
State to restore. |
required |
Source code in pare/apps/note/app.py
224 225 226 227 228 229 230 231 232 233 234 235 | |
move_note(note_id, source_folder_name='Inbox', dest_folder_name='Personal')
¶
Move a note with the specified ID to the specified folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
The ID of the note to move. |
required |
source_folder_name
|
str
|
The folder to move the note from. Defaults to Inbox. |
'Inbox'
|
dest_folder_name
|
str
|
The folder to move the note to. Defaults to Personal. |
'Personal'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ID of the moved note |
Raises:
| Type | Description |
|---|---|
KeyError
|
If source or destination folder not found or note not found in source folder. |
Source code in pare/apps/note/app.py
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | |
new_folder(folder_name)
¶
Create a new empty folder with the given name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_name
|
str
|
Name of the new folder. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Name of the newly created folder. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If folder already exists. |
Source code in pare/apps/note/app.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
open_folder(folder)
¶
Open a folder and return the notes in the folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Name of the folder to open. |
required |
Returns:
| Type | Description |
|---|---|
list[Note]
|
list[Note]: List of notes in the folder. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If folder does not exist. |
ValueError
|
If folder name is empty. |
Source code in pare/apps/note/app.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
remove_attachment(note_id, attachment)
¶
Remove an attachment from a note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
Target note ID. |
required |
attachment
|
str
|
Attachment to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ID of the note that the attachment was removed from. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If note not found in any folder or attachment not found in note. |
Source code in pare/apps/note/app.py
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 | |
rename_folder(folder, new_folder)
¶
Rename an already existing folder. Default folders "Inbox", "Personal", and "Work" cannot be renamed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Name of the folder to rename. |
required |
new_folder
|
str
|
New name for the folder. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Name of the renamed folder. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If folder_name does not exist, a folder with the new name already exists or if the folder to be renamed is one of the default folders. |
Source code in pare/apps/note/app.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
reset()
¶
Reset the app to empty state.
Source code in pare/apps/note/app.py
237 238 239 240 241 | |
search_notes(query)
¶
Search for notes across all folders based on a query string. The search looks for partial matches in title, and content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The search query string. |
required |
Returns:
| Type | Description |
|---|---|
list[Note]
|
list[Note]: A list of notes that match the query. |
Source code in pare/apps/note/app.py
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | |
search_notes_in_folder(query, folder_name)
¶
Search for notes in a specific folder based on a query string. The search looks for partial matches in title, and content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The search query string. |
required |
folder_name
|
str
|
The folder to search in. Defaults to Inbox. |
required |
Returns:
| Type | Description |
|---|---|
list[Note]
|
list[Note]: A list of notes that match the query. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If folder not found. |
Source code in pare/apps/note/app.py
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | |
update_note(note_id, title=None, content=None)
¶
Update the title or the content of the note. At least one of title or content must be provided.
Notes: - If both title and content are provided, both will be updated. - If the note has no title and new title is provided, the title will be set to the new title. - If the note has no title and content is provided, the title will be set to the first 50 characters of the content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
Target note ID. |
required |
title
|
str | None
|
New title for the note. |
None
|
content
|
str | None
|
New content for the note. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Note ID of the updated note. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If note not found. |
ValueError
|
If both title and content are empty. |
Source code in pare/apps/note/app.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | |
StatefulReminderApp
¶
Bases: StatefulApp, ReminderApp
Reminder application with PARE navigation support.
Source code in pare/apps/reminder/app.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
__init__(*args, **kwargs)
¶
Initialize the reminder app and load the root navigation state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments passed to ReminderApp. |
()
|
**kwargs
|
Any
|
Keyword arguments passed to ReminderApp. |
{}
|
Source code in pare/apps/reminder/app.py
26 27 28 29 30 31 32 33 34 | |
create_root_state()
¶
Create and return the root navigation state.
Returns:
| Type | Description |
|---|---|
ReminderList
|
The initial ReminderList state. |
Source code in pare/apps/reminder/app.py
36 37 38 39 40 41 42 | |
get_reminder_with_id(reminder_id)
¶
Retrieve a reminder by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reminder_id
|
str
|
The ID of the reminder to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
Reminder
|
The Reminder object corresponding to the given ID. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the reminder ID does not exist. |
Source code in pare/apps/reminder/app.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
handle_state_transition(event)
¶
Update navigation state after a reminder operation completes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
CompletedEvent
|
Completed event containing tool invocation information. |
required |
Source code in pare/apps/reminder/app.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
update_reminder(reminder_id, title, description, due_datetime, repetition_unit, repetition_value)
¶
Update an existing reminder and regenerate its repetitions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reminder_id
|
str
|
ID of the reminder to update. |
required |
title
|
str
|
Updated title. |
required |
description
|
str
|
Updated description. |
required |
due_datetime
|
str
|
Updated due datetime in "YYYY-MM-DD HH:MM:SS" format. |
required |
repetition_unit
|
str | None
|
Repetition unit (e.g., "day", "week"), or None. |
required |
repetition_value
|
int | None
|
Repetition interval value, or None. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The reminder ID after update. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the reminder ID does not exist. |
Source code in pare/apps/reminder/app.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
StatefulShoppingApp
¶
Bases: StatefulApp, ShoppingApp
Shopping app with PARE-aware navigation.
Source code in pare/apps/shopping/app.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
__init__(*args, **kwargs)
¶
Initialise shopping app with root state.
Source code in pare/apps/shopping/app.py
28 29 30 31 | |
add_order(order_id, order_status, order_date, order_total, item_id, quantity)
¶
Add an order (used for scenario seeding).
The upstream are ShoppingApp currently returns extra keys (e.g. name,
product_id) from _get_item(), but its CartItem dataclass does not
accept them. We defensively filter to the fields CartItem supports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order_id
|
str
|
The ID of the order. |
required |
order_status
|
str
|
The status of the order. |
required |
order_date
|
float
|
The date of the order as a timestamp. |
required |
order_total
|
float
|
The total amount of the order. |
required |
item_id
|
str
|
The ID of the item to add to the order. |
required |
quantity
|
int
|
The quantity of the item to add to the order. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ID of the created order. |
Source code in pare/apps/shopping/app.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
add_order_multiple_items(order_id, order_status, order_date, order_total, items)
¶
Add an order with multiple items (used for scenario seeding).
The upstream are ShoppingApp currently returns extra keys (e.g. name,
product_id) from _get_item(), but its CartItem dataclass does not
accept them. We defensively filter to the fields CartItem supports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order_id
|
str
|
The ID of the order. |
required |
order_status
|
str
|
The status of the order. |
required |
order_date
|
float
|
The date of the order as a timestamp. |
required |
order_total
|
float
|
The total amount of the order. |
required |
items
|
dict[str, int]
|
A dictionary mapping item IDs to quantities. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ID of the created order. |
Source code in pare/apps/shopping/app.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
create_root_state()
¶
Return root navigation state.
Source code in pare/apps/shopping/app.py
274 275 276 | |
get_cart()
¶
Wrapper for list_cart() used by states.
Source code in pare/apps/shopping/app.py
282 283 284 | |
get_item(item_id)
¶
Wrapper for _get_item for compatibility.
Source code in pare/apps/shopping/app.py
278 279 280 | |
handle_state_transition(event)
¶
Update navigation state based on completed operations.
Source code in pare/apps/shopping/app.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
Core Framework¶
AppState
¶
Bases: ABC
Base class for navigation states.
Each state represents a screen/view of the app on the mobile phone. Navigation states form an MDP where each state has specific available actions.
Note: Different from Meta AREs data state (JSON)
Source code in pare/apps/core.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
app
property
¶
Get the app this state is bound to.
__init__()
¶
Initialize the app tools.
Source code in pare/apps/core.py
31 32 33 34 | |
bind_to_app(app)
¶
Bind this state to an app (late binding).
Called automatically by StatefulApp.set_current_state().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
App
|
The app this state belongs to |
required |
Source code in pare/apps/core.py
36 37 38 39 40 41 42 43 44 | |
get_available_actions()
¶
Get user tools (actions) available from this navigation state.
These are valid actions for the user in this App MDP from this state.
Returns:
| Type | Description |
|---|---|
list[AppTool]
|
list[AppTool]: A list of AppTool objects representing the available actions. |
Source code in pare/apps/core.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
on_enter()
abstractmethod
¶
Called when transitioning into this state.
Override to handle state initialization, load data, update anything, etc. We don't know if this is useful yet.
Source code in pare/apps/core.py
76 77 78 79 80 81 82 | |
on_exit()
abstractmethod
¶
Called when transitioning out of this state.
Override to handle state cleanup, save data, etc. We don't know if this is useful yet.
Source code in pare/apps/core.py
84 85 86 87 88 89 90 | |
StatefulApp
¶
Bases: App
Base class for a stateful app.
This class implements the basic functionality needed for a finite state machine based mobile app.
Source code in pare/apps/core.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |
__init__(name=None, *args, **kwargs)
¶
Initialize the stateful app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name of the app. |
None
|
args
|
Any
|
The arguments to pass to the app. |
()
|
kwargs
|
Any
|
The keyword arguments to pass to the app. |
{}
|
Source code in pare/apps/core.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
create_root_state()
abstractmethod
¶
Return a freshly constructed root navigation state.
Source code in pare/apps/core.py
146 147 148 | |
get_meta_are_user_tools()
¶
Return Meta ARE-compatible tool adapters for the current navigation state.
Source code in pare/apps/core.py
193 194 195 196 197 198 199 200 201 202 203 204 | |
get_reachable_states(from_state)
¶
Get the reachable states from the given state.
TODO: implement after MVP
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_state
|
AppState
|
The state to get the reachable states from. |
required |
Returns:
| Type | Description |
|---|---|
list[type[AppState]]
|
list[type[AppState]]: The reachable states from the given state. |
Source code in pare/apps/core.py
230 231 232 233 234 235 236 237 238 239 240 241 | |
get_state_graph()
¶
Get the state graph of the app.
TODO: implement after MVP
Returns:
| Type | Description |
|---|---|
dict[str, list[str]]
|
dict[str, list[str]]: The state graph of the app. |
Source code in pare/apps/core.py
220 221 222 223 224 225 226 227 228 | |
get_tools()
¶
Get the tools of the app.
Source code in pare/apps/core.py
206 207 208 | |
get_tools_with_attribute(attribute, tool_type)
¶
Return tools by attribute/tool type, extended for PARE stateful apps.
- If tool_type/attribute correspond to USER tools, include state-bound user tools.
- Otherwise, defer to Meta-ARE base implementation.
- Special case: if both tool_type and attribute are None, return "event-only" tools: methods decorated with @event_registered-like decorator but without any of @app_tool, @user_tool, @env_tool, @data_tool. Detected via AST across the MRO.
Source code in pare/apps/core.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
get_user_tools()
¶
Get user tools from the current state of the app.
User tools are state dependent and manage context. Each state will only enable some of the available actions in the app.
Returns:
| Type | Description |
|---|---|
list[AppTool]
|
list[AppTool]: A list of AppTool objects representing the available user tools. |
Source code in pare/apps/core.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
go_back()
¶
Navigate back to the previous state of the app.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A message indicating the navigation back action. |
Source code in pare/apps/core.py
161 162 163 164 165 166 167 168 169 170 171 172 173 | |
handle_state_transition(event)
¶
Update the current state of the app based on the tool events.
This implements the state transition function T(s,a) -> s' for app specific transitions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
CompletedEvent
|
The completed event. |
required |
Source code in pare/apps/core.py
210 211 212 213 214 215 216 217 218 | |
load_root_state()
¶
Reset the app to its root navigation state.
Source code in pare/apps/core.py
150 151 152 153 | |
reset_to_root()
¶
Reset to the root navigation state and report the new view.
Source code in pare/apps/core.py
155 156 157 158 159 | |
set_current_state(app_state)
¶
Set the current state of the app.
This is called by handle_state_transition to update the current state of the app. This function will
1. Binds the state to app
2. Calls on_exit on the old state
3. Pushes the old state to the navigation stack (for go_back())
4. Calls on_enter on the new state (initialization/data loading)
5. Sets the current state to the new state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_state
|
AppState
|
The state to set. |
required |
Source code in pare/apps/core.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
PARE-specific tool decorators that extend Meta ARE functionality.
pare_event_registered(operation_type=OperationType.READ, event_type=EventType.USER)
¶
PARE-specific event registration decorator that handles AppState instances.
This is an adaptation of Meta ARE's native @event_registered decorator to support
PARE's AppState pattern where methods are defined on state classes that don't have
direct access to self.name or self.time_manager, but instead access them via
self.app.name and self.app.time_manager.
The decorator follows Meta ARE's event registration pattern but adapts it for: - AppState instances (which have self.app.name and self.app.time_manager) - StatefulApp instances (which have self.name and self.time_manager)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_type
|
OperationType
|
Whether this is a READ or WRITE operation |
READ
|
event_type
|
EventType
|
The type of event to generate (default: EventType.AGENT) |
USER
|
Example
@user_tool() @pare_event_registered(operation_type=OperationType.WRITE) def forward(self, recipients: list[str]) -> str: with disable_events(): return self.app.forward_email(...)
Source code in pare/apps/tool_decorators.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
System and Agent UI Apps¶
PARE extensions around the Meta-ARE system app.
HomeScreenSystemApp
¶
Bases: SystemApp
System app that exposes user tools for switching contexts.
Source code in pare/apps/system.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
__init__(*args, **kwargs)
¶
Initialise the system app (callbacks will be set by environment).
Source code in pare/apps/system.py
18 19 20 21 22 23 | |
go_home()
¶
Return to the home screen. This will allow the user to open a new app.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A message indicating the home screen action. |
Source code in pare/apps/system.py
36 37 38 39 40 41 42 43 44 45 46 | |
open_app(app_name)
¶
Open the requested app. If the app is already open and it is in background, then the phone will switch to it. If the app is not open, then a it is opened to the home page of that app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_name
|
str
|
The name of the app to open (case-sensitive). The app must be availabe in the environment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A message indicating the open app action. |
Source code in pare/apps/system.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
set_callbacks(switch_app_callback, open_app_callback, go_home_callback)
¶
Set the navigation callbacks (called by environment after initialization).
Source code in pare/apps/system.py
25 26 27 28 29 30 31 32 33 34 | |
switch_app(app_name)
¶
Switch to the requested app and preserve the current app state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_name
|
str
|
The name of the app to switch to (case-sensitive). The app must be open and availabe in the environment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A message indicating the switch app action. |
Source code in pare/apps/system.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
Proactive Agent User Interface with proposal management.
PAREAgentUserInterface
¶
Bases: AgentUserInterface
Agent-user interface extended with proactive proposal acceptance and rejection support.
Adds tools which the user agent uses to accept or reject the proactive agent's proposal.
Source code in pare/apps/proactive_aui.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
__init__(*args, **kwargs)
¶
Initialize the proactive agent-user interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Any
|
Arguments to pass to the app |
()
|
kwargs
|
Any
|
Keyword arguments to pass to the app |
{}
|
Source code in pare/apps/proactive_aui.py
21 22 23 24 25 26 27 28 | |
accept_proposal(content='')
¶
User accepts the pending proactive proposal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
The content of the message to send to the agent |
''
|
Returns:
| Type | Description |
|---|---|
str
|
The message ID that was generated for this message, can be used for tracking |
Source code in pare/apps/proactive_aui.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
reject_proposal(content='')
¶
User rejects the pending proactive proposal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
The content of the message to send to the agent |
''
|
Returns:
| Type | Description |
|---|---|
str
|
The message ID that was generated for this message, can be used for tracking |
Source code in pare/apps/proactive_aui.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
wait()
¶
Observe and wait without taking action.
Use this when you want to continue monitoring but don't have a specific proposal or message for the user yet.
Returns:
| Type | Description |
|---|---|
str
|
Confirmation that the agent is in observation mode. |
Source code in pare/apps/proactive_aui.py
60 61 62 63 64 65 66 67 68 69 70 71 72 | |
Contacts App¶
Stateful contacts app built on top of the Meta-ARE ContactsApp.
StatefulContactsApp
¶
Bases: StatefulApp, ContactsApp
Contacts application with explicit navigation states.
Source code in pare/apps/contacts/app.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
__init__(*args, **kwargs)
¶
Initialise the contacts app and load the list view as the default state.
Source code in pare/apps/contacts/app.py
35 36 37 38 39 40 41 | |
clear_contact_transition()
¶
Reset any queued contact transition intent.
Source code in pare/apps/contacts/app.py
47 48 49 | |
create_root_state()
¶
Return the root navigation state for the contacts app.
Source code in pare/apps/contacts/app.py
128 129 130 | |
handle_state_transition(event)
¶
Update navigation state based on completed contact operations.
Source code in pare/apps/contacts/app.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
queue_contact_transition(intent, contact_id)
¶
Record a desired transition that should fire after the next contacts API call.
Source code in pare/apps/contacts/app.py
43 44 45 | |
Navigation states for the stateful contacts app.
ContactDetail
¶
Bases: AppState
State for viewing a specific contact's details.
Source code in pare/apps/contacts/states.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
__init__(contact_id)
¶
Bind the detail view to the supplied contact identifier.
Source code in pare/apps/contacts/states.py
136 137 138 139 | |
delete_contact()
¶
Delete the currently opened contact.
Source code in pare/apps/contacts/states.py
164 165 166 167 168 169 170 | |
on_enter()
¶
No-op hook for detail entry; data retrieval happens via user tools.
Source code in pare/apps/contacts/states.py
141 142 | |
on_exit()
¶
Clear any queued edit intents when leaving detail view.
Source code in pare/apps/contacts/states.py
144 145 146 147 | |
start_edit_contact()
¶
Queue an edit transition and return the latest contact data.
Source code in pare/apps/contacts/states.py
156 157 158 159 160 161 162 | |
view_contact()
¶
Retrieve the currently opened contact.
Source code in pare/apps/contacts/states.py
149 150 151 152 153 154 | |
ContactEdit
¶
Bases: AppState
State representing the contact edit surface.
Source code in pare/apps/contacts/states.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
__init__(contact_id)
¶
Initialise the edit state for a particular contact.
Source code in pare/apps/contacts/states.py
176 177 178 179 | |
on_enter()
¶
No special entry behaviour for the edit form.
Source code in pare/apps/contacts/states.py
181 182 | |
on_exit()
¶
Clear edit-specific transition intent when leaving the edit view.
Source code in pare/apps/contacts/states.py
184 185 186 187 | |
update_contact(updates)
¶
Persist updates to the contact and stay in edit mode until a transition occurs.
Source code in pare/apps/contacts/states.py
196 197 198 199 200 201 | |
view_contact()
¶
Read the contact being edited without leaving edit mode.
Source code in pare/apps/contacts/states.py
189 190 191 192 193 194 | |
ContactsList
¶
Bases: AppState
Initial navigation state showing the list of contacts.
Source code in pare/apps/contacts/states.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
__init__()
¶
Initialise the list state.
Source code in pare/apps/contacts/states.py
44 45 46 | |
create_contact(first_name, last_name, gender=None, age=None, nationality=None, city_living=None, country=None, status=None, job=None, description=None, phone=None, email=None, address=None)
¶
Create a new contact and return its identifier.
Source code in pare/apps/contacts/states.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
get_available_actions()
¶
Annotate tool argument descriptions for the current state.
Source code in pare/apps/contacts/states.py
83 84 85 86 87 88 89 90 91 92 93 94 | |
list_contacts(offset=0)
¶
List contacts using the native paginated API.
Source code in pare/apps/contacts/states.py
54 55 56 57 58 59 | |
on_enter()
¶
No-op hook for entering the contacts list.
Source code in pare/apps/contacts/states.py
48 49 | |
on_exit()
¶
No-op hook for exiting the contacts list.
Source code in pare/apps/contacts/states.py
51 52 | |
open_contact(contact_id)
¶
Open a contact from the list, queuing a transition to the detail view.
Source code in pare/apps/contacts/states.py
68 69 70 71 72 73 74 | |
search_contacts(query)
¶
Search contacts by name, phone or email.
Source code in pare/apps/contacts/states.py
61 62 63 64 65 66 | |
view_current_user()
¶
View the contact card for the current user persona.
Source code in pare/apps/contacts/states.py
76 77 78 79 80 81 | |
Messaging App¶
StatefulMessagingApp
¶
Bases: StatefulApp, MessagingAppV2
Messaging app with navigation state management.
// RL NOTE: This implements a simple 2-state MDP for messaging: // States: ConversationList, ConversationOpened // Transitions: open_conversation, go_back
Source code in pare/apps/messaging/app.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
__init__(*args, **kwargs)
¶
Initialize the stateful messaging app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Variable length argument list passed to parent classes. |
()
|
**kwargs
|
Any
|
Arbitrary keyword arguments passed to parent classes. |
{}
|
Source code in pare/apps/messaging/app.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
add_contacts(contacts)
¶
Add contacts (name, phone) to the internal name/id maps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contacts
|
list[tuple[str, str]]
|
Pairs of (user_name, phone). |
required |
Source code in pare/apps/messaging/app.py
51 52 53 54 55 56 57 58 59 60 | |
add_users(user_names)
¶
Add users to the internal name/id maps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_names
|
list[str]
|
User display names to ensure exist in the mapping. |
required |
Source code in pare/apps/messaging/app.py
39 40 41 42 43 44 45 46 47 48 49 | |
create_root_state()
¶
Return the conversation list root state.
Source code in pare/apps/messaging/app.py
85 86 87 | |
handle_state_transition(event)
¶
Handle state transitions based on tool events.
// RL NOTE: This implements T(s,a) -> s' for the messaging MDP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
CompletedEvent
|
Completed event from tool execution |
required |
Source code in pare/apps/messaging/app.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
ConversationList
¶
Bases: AppState
Navigation state representing the conversations list view.
// RL NOTE: This is typically an initial/hub state in the messaging app navigation graph.
Source code in pare/apps/messaging/states.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
__init__()
¶
Create conversation list state.
Note: No app parameter - uses late binding pattern.
Source code in pare/apps/messaging/states.py
84 85 86 87 88 89 | |
list_recent_conversations(offset=0, limit=5, offset_recent_messages_per_conversation=0, limit_recent_messages_per_conversation=10)
¶
List recent conversations ordered by most recent modification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
Starting index from which to list conversations |
0
|
limit
|
int
|
Number of conversations to list |
5
|
offset_recent_messages_per_conversation
|
int
|
Starting index for messages per conversation |
0
|
limit_recent_messages_per_conversation
|
int
|
Number of messages to list per conversation |
10
|
Returns:
| Type | Description |
|---|---|
list[ConversationV2]
|
List of conversation details |
Source code in pare/apps/messaging/states.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
on_enter()
¶
Called when entering conversation list state.
Source code in pare/apps/messaging/states.py
91 92 93 | |
on_exit()
¶
Called when exiting conversation list state.
Source code in pare/apps/messaging/states.py
95 96 97 | |
open_conversation(conversation_id, offset=0, limit=20)
¶
Open specific conversation (triggers state transition).
Returns conversation data as the observation when opening.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conversation_id
|
str
|
The conversation to open |
required |
offset
|
int
|
Message offset |
0
|
limit
|
int
|
Number of messages to load |
20
|
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Conversation data with messages |
Source code in pare/apps/messaging/states.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
search_conversations(query, min_date=None, max_date=None, limit=10)
¶
Search conversations by query string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Search query |
required |
min_date
|
str | None
|
Minimum date (YYYY-MM-DD %H:%M:%S format) |
None
|
max_date
|
str | None
|
Maximum date (YYYY-MM-DD %H:%M:%S format) |
None
|
limit
|
int
|
Maximum number of results |
10
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of matching conversations |
Source code in pare/apps/messaging/states.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
ConversationOpened
¶
Bases: AppState
Navigation state representing an open conversation view.
// RL NOTE: This is a conversation-specific state in the navigation MDP. // Context (conversation_id) is part of the state representation.
Source code in pare/apps/messaging/states.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
__init__(conversation_id)
¶
Initialize conversation state with the id of the conversation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conversation_id
|
str
|
The conversation context |
required |
Source code in pare/apps/messaging/states.py
16 17 18 19 20 21 22 23 | |
on_enter()
¶
Called when entering the conversation state.
Source code in pare/apps/messaging/states.py
25 26 27 28 | |
on_exit()
¶
Called when exiting the conversation state.
Source code in pare/apps/messaging/states.py
30 31 32 33 | |
read_messages(offset=0, limit=10, min_date=None, max_date=None)
¶
Read the conversation with the given conversation_id.
Shows the last 'limit' messages after offset. Which means messages between offset and offset + limit will be shown. Messages are sorted by timestamp, most recent first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
Offset to shift the view window |
0
|
limit
|
int
|
Number of messages to show |
10
|
min_date
|
str | None
|
Minimum date (YYYY-MM-DD %H:%M:%S format). Default is None, which means no minimum date. |
None
|
max_date
|
str | None
|
Maximum date (YYYY-MM-DD %H:%M:%S format). Default is None, which means no maximum date. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Dict with messages and additional info |
Source code in pare/apps/messaging/states.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
send_message(content, attachment_path=None)
¶
Send message in current conversation (context-aware).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
The message content |
required |
attachment_path
|
str | None
|
The path to the attachment file |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The id of the conversation the message was sent to |
Source code in pare/apps/messaging/states.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
Email App¶
Stateful email app combining Meta-ARE's email backend with PARE navigation.
StatefulEmailApp
¶
Bases: StatefulApp, EmailClientV2
Email client with navigation state management for user tool filtering.
Source code in pare/apps/email/app.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init__(*args, **kwargs)
¶
Initialise the email app with the inbox as the starting state.
Source code in pare/apps/email/app.py
22 23 24 25 26 | |
create_root_state()
¶
Return the mailbox view rooted in the inbox.
Source code in pare/apps/email/app.py
255 256 257 | |
handle_state_transition(event)
¶
Update navigation state in response to completed tool events.
Source code in pare/apps/email/app.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
send_email_to_user_with_id(email_id, sender, subject='', content='', attachment_paths=None)
¶
Create an incoming email with a specified ID (optionally with attachments) and add it to user's INBOX.
This is a PARE-specific environment tool that allows scenarios to reference the email_id in subsequent events (e.g., for replying to the email).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email_id
|
str
|
The ID to assign to this email. |
required |
sender
|
str
|
The sender of the email. |
required |
subject
|
str
|
The subject of the email. |
''
|
content
|
str
|
The content of the email. |
''
|
attachment_paths
|
list[str] | None
|
Optional list of attachment paths to add to the email.
NOTE: Attachments are read from |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The email_id that was provided. |
Source code in pare/apps/email/app.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
send_reply_from_draft(draft)
¶
Send a reply using the draft metadata, preserving user edits.
Source code in pare/apps/email/app.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
Navigation state implementations for the stateful email app.
ComposeDraft
dataclass
¶
In-memory representation of an email draft during composition.
Source code in pare/apps/email/states.py
28 29 30 31 32 33 34 35 36 37 38 39 40 | |
ComposeEmail
¶
Bases: AppState
Compose state exposing draft editing and submission tools.
Source code in pare/apps/email/states.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
__init__(draft=None)
¶
Initialise the compose state with an optional existing draft.
Source code in pare/apps/email/states.py
229 230 231 232 233 234 235 236 | |
add_recipient(recipient)
¶
Append a single recipient to the draft.
Source code in pare/apps/email/states.py
258 259 260 261 262 263 264 | |
attach_file(attachment_path)
¶
Attach a file path to the draft.
Source code in pare/apps/email/states.py
288 289 290 291 292 293 | |
discard_draft()
¶
Discard the current draft without sending.
Source code in pare/apps/email/states.py
324 325 326 327 328 329 | |
on_enter()
¶
Reset cached tools to ensure latest draft mutations are reflected.
Source code in pare/apps/email/states.py
238 239 240 | |
on_exit()
¶
Clear cached tools and reset draft state.
Source code in pare/apps/email/states.py
242 243 244 | |
save_draft()
¶
Persist the draft into the DRAFT folder.
Source code in pare/apps/email/states.py
312 313 314 315 316 317 318 319 320 321 322 | |
send_composed_email()
¶
Send the draft using the underlying email client.
Source code in pare/apps/email/states.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
set_body(body)
¶
Update the body content for the draft.
Source code in pare/apps/email/states.py
281 282 283 284 285 286 | |
set_cc(cc)
¶
Replace the CC list for the draft.
Source code in pare/apps/email/states.py
266 267 268 269 270 271 272 | |
set_recipients(recipients)
¶
Replace the draft recipients list.
Source code in pare/apps/email/states.py
250 251 252 253 254 255 256 | |
set_subject(subject)
¶
Update the subject line for the draft.
Source code in pare/apps/email/states.py
274 275 276 277 278 279 | |
EmailDetail
¶
Bases: AppState
Email detail state allowing follow-up actions on a single email.
Source code in pare/apps/email/states.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
email
property
¶
Return the cached email if available.
__init__(email_id, folder_name=EmailFolderName.INBOX.value)
¶
Bind the detail view to a specific email and folder.
Source code in pare/apps/email/states.py
136 137 138 139 140 141 | |
delete()
¶
Delete the current email (moves it to trash).
Source code in pare/apps/email/states.py
191 192 193 194 195 196 | |
download_attachments(path_to_save)
¶
Download attachments from the current email to a path.
Source code in pare/apps/email/states.py
198 199 200 201 202 203 204 205 | |
forward(recipients)
¶
Forward the current email to new recipients.
Source code in pare/apps/email/states.py
173 174 175 176 177 178 | |
move(destination_folder)
¶
Move the current email to a different folder.
Source code in pare/apps/email/states.py
180 181 182 183 184 185 186 187 188 189 | |
on_enter()
¶
Attempt to refresh cached email details on entry.
Source code in pare/apps/email/states.py
143 144 145 | |
on_exit()
¶
Clear cached email data when leaving the detail view.
Source code in pare/apps/email/states.py
147 148 | |
refresh()
¶
Fetch the latest version of the current email.
Source code in pare/apps/email/states.py
157 158 159 160 161 162 | |
reply(content='', attachment_paths=None)
¶
Send a reply to the current email.
Source code in pare/apps/email/states.py
164 165 166 167 168 169 170 171 | |
start_compose_reply()
¶
Return metadata required to seed a reply draft in compose view.
Source code in pare/apps/email/states.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
MailboxView
¶
Bases: AppState
Mailbox listing state exposing folder-scoped navigation actions.
Source code in pare/apps/email/states.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
__init__(folder=EmailFolderName.INBOX.value)
¶
Initialise the mailbox view with the provided folder.
Source code in pare/apps/email/states.py
46 47 48 49 | |
list_emails(offset=0, limit=10)
¶
List emails in the current folder with pagination support.
Source code in pare/apps/email/states.py
57 58 59 60 61 62 63 64 65 66 | |
on_enter()
¶
No-op hook; future implementations may pre-fetch folder metadata.
Source code in pare/apps/email/states.py
51 52 | |
on_exit()
¶
No-op hook for symmetry with on_enter.
Source code in pare/apps/email/states.py
54 55 | |
open_email_by_id(email_id)
¶
Open a specific email by id within the current folder.
Source code in pare/apps/email/states.py
104 105 106 107 108 109 | |
open_email_by_index(index)
¶
Open a specific email by index within the current folder.
Source code in pare/apps/email/states.py
111 112 113 114 115 116 | |
search_emails(query, min_date=None, max_date=None, limit=10)
¶
Search for emails within the current folder.
min/max filters are applied client-side because the backend API does not expose them. Invalid date strings are ignored.
Source code in pare/apps/email/states.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
start_compose()
¶
Begin a new compose flow originating from the mailbox view.
Source code in pare/apps/email/states.py
126 127 128 129 130 | |
switch_folder(folder_name)
¶
Switch to a different folder and return its contents.
Source code in pare/apps/email/states.py
118 119 120 121 122 123 124 | |
Calendar App¶
Stateful calendar app combining Meta-ARE calendar backend with PARE navigation.
StatefulCalendarApp
¶
Bases: StatefulApp, CalendarV2
Calendar client with navigation-aware user tool exposure.
Source code in pare/apps/calendar/app.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
__init__(*args, **kwargs)
¶
Initialise the calendar app and seed the agenda with the current day.
Source code in pare/apps/calendar/app.py
23 24 25 26 | |
create_root_state()
¶
Return the root agenda view scoped to the current day.
Source code in pare/apps/calendar/app.py
177 178 179 180 | |
get_reachable_states(from_state)
¶
Return the reachable states from the provided state.
Source code in pare/apps/calendar/app.py
186 187 188 | |
get_state_graph()
¶
Return the navigation graph for the calendar app.
Source code in pare/apps/calendar/app.py
182 183 184 | |
handle_state_transition(event)
¶
Update navigation state in response to user tool completions.
Source code in pare/apps/calendar/app.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
Navigation state implementations for the stateful calendar app.
AgendaView
¶
Bases: AppState
Calendar listing view for a specific time window and optional filters.
Source code in pare/apps/calendar/states.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
__init__(*, start_datetime, end_datetime, tag_filter=None, attendee_filter=None)
¶
Create an agenda view scoped to a datetime window and optional filters.
Source code in pare/apps/calendar/states.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
add_calendar_event_by_attendee(who_add, title='Event', start_datetime=None, end_datetime=None, tag=None, description=None, location=None, attendees=None)
¶
Create an event on behalf of a specific attendee.
Source code in pare/apps/calendar/states.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
filter_by_attendee(attendee)
¶
Preview events containing a specific attendee.
Source code in pare/apps/calendar/states.py
142 143 144 145 146 147 148 149 | |
filter_by_tag(tag)
¶
Preview events with a specific tag.
Source code in pare/apps/calendar/states.py
136 137 138 139 140 | |
get_all_tags()
¶
List all tags present in the calendar.
Source code in pare/apps/calendar/states.py
182 183 184 185 186 | |
get_calendar_events_by_tag(tag)
¶
Fetch events associated with a specific tag directly from the backend.
Source code in pare/apps/calendar/states.py
188 189 190 191 192 | |
list_events(offset=0, limit=10)
¶
List events within the active time window respecting current filters.
Source code in pare/apps/calendar/states.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
on_enter()
¶
No-op hook reserved for future caching.
Source code in pare/apps/calendar/states.py
65 66 | |
on_exit()
¶
No cleanup required when leaving the agenda view.
Source code in pare/apps/calendar/states.py
68 69 | |
open_event_by_id(event_id)
¶
Open an event by identifier within the current window.
Source code in pare/apps/calendar/states.py
121 122 123 124 125 | |
open_event_by_index(index)
¶
Open the n-th event in the current window according to ordering.
Source code in pare/apps/calendar/states.py
127 128 129 130 131 132 133 134 | |
read_today_calendar_events()
¶
Return today's events via the backend helper.
Source code in pare/apps/calendar/states.py
176 177 178 179 180 | |
search_events(query)
¶
Search events, applying local filters and window constraints.
Source code in pare/apps/calendar/states.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
set_day(date)
¶
Switch the agenda view to the supplied UTC date string (YYYY-MM-DD).
Source code in pare/apps/calendar/states.py
194 195 196 197 198 199 200 | |
start_create_event()
¶
Begin a new event creation flow.
Source code in pare/apps/calendar/states.py
202 203 204 205 206 | |
EditDraft
dataclass
¶
Mutable draft representation for creating or editing events.
Source code in pare/apps/calendar/states.py
33 34 35 36 37 38 39 40 41 42 43 44 | |
EditEvent
¶
Bases: AppState
Compose/edit state for calendar events.
Source code in pare/apps/calendar/states.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
__init__(draft=None)
¶
Initialise the edit state, optionally seeding it with an existing draft.
Source code in pare/apps/calendar/states.py
285 286 287 288 289 290 291 292 293 294 295 | |
add_attendee(attendee)
¶
Append an attendee to the draft if not already present.
Source code in pare/apps/calendar/states.py
355 356 357 358 359 360 361 362 | |
discard()
¶
Discard current draft and stay within compose state.
Source code in pare/apps/calendar/states.py
401 402 403 404 405 406 407 408 | |
on_enter()
¶
Invalidate cached tools to pick up latest draft mutations.
Source code in pare/apps/calendar/states.py
297 298 299 | |
on_exit()
¶
Reset tool cache on exit.
Source code in pare/apps/calendar/states.py
301 302 303 | |
remove_attendee(attendee)
¶
Remove an attendee from the draft if included.
Source code in pare/apps/calendar/states.py
364 365 366 367 368 369 370 | |
save()
¶
Persist current draft to backend, returning the event id.
Source code in pare/apps/calendar/states.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
set_attendees(attendees)
¶
Overwrite the current attendee list.
Source code in pare/apps/calendar/states.py
347 348 349 350 351 352 353 | |
set_description(description)
¶
Replace the draft description.
Source code in pare/apps/calendar/states.py
333 334 335 336 337 338 | |
set_location(location)
¶
Update the draft location.
Source code in pare/apps/calendar/states.py
340 341 342 343 344 345 | |
set_tag(tag)
¶
Assign a label/tag to the draft.
Source code in pare/apps/calendar/states.py
325 326 327 328 329 330 331 | |
set_time_range(start_datetime, end_datetime)
¶
Set the draft start/end datetimes.
Source code in pare/apps/calendar/states.py
316 317 318 319 320 321 322 323 | |
set_title(title)
¶
Update the draft title.
Source code in pare/apps/calendar/states.py
308 309 310 311 312 313 314 | |
EventDetail
¶
Bases: AppState
Detailed view of a single calendar event.
Source code in pare/apps/calendar/states.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
event
property
¶
Return the cached event instance if available.
__init__(event_id)
¶
Create a detail view bound to the provided event identifier.
Source code in pare/apps/calendar/states.py
212 213 214 215 216 | |
delete()
¶
Delete this event from the calendar.
Source code in pare/apps/calendar/states.py
242 243 244 245 246 | |
delete_by_attendee(who_delete)
¶
Delete the event as a particular attendee.
Source code in pare/apps/calendar/states.py
248 249 250 251 252 | |
edit_event()
¶
Prepare a draft payload for editing this event.
Source code in pare/apps/calendar/states.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
list_attendees()
¶
Return the attendee list for this event.
Source code in pare/apps/calendar/states.py
254 255 256 257 258 259 | |
on_enter()
¶
Fetch the underlying event when entering the detail view.
Source code in pare/apps/calendar/states.py
218 219 220 | |
on_exit()
¶
No teardown required; keep cached copy for go_back.
Source code in pare/apps/calendar/states.py
222 223 | |
refresh()
¶
Reload event data from the backend.
Source code in pare/apps/calendar/states.py
235 236 237 238 239 240 | |
Cab App¶
Stateful cab app combining Meta-ARE cab backend with PARE navigation.
StatefulCabApp
¶
Bases: StatefulApp, CabApp
Cab client with navigation-aware user tool exposure.
Source code in pare/apps/cab/app.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
__init__(*args, **kwargs)
¶
Initialise the cab app and load the default home screen.
Source code in pare/apps/cab/app.py
24 25 26 27 | |
create_root_state()
¶
Return the root navigation state for the cab app.
Source code in pare/apps/cab/app.py
29 30 31 | |
handle_state_transition(event)
¶
Update navigation state after a cab operation completes.
Source code in pare/apps/cab/app.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
CabHome
¶
Bases: AppState
Home view for cab operations such as listing rides, quotations, and history.
This state provides the main interface for users to interact with the cab service, including listing available rides, getting quotations, ordering rides, and viewing ride history.
Source code in pare/apps/cab/states.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
get_ride_history(offset=0, limit=10)
¶
Fetch ride history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
The number of records to skip (default: 0). |
0
|
limit
|
int
|
The maximum number of records to return (default: 10). |
10
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Collection of historical ride records. |
Source code in pare/apps/cab/states.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
list_rides(start_location, end_location, ride_time=None)
¶
List available ride quotations for all service types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_location
|
str
|
The starting location for the ride. |
required |
end_location
|
str
|
The destination location for the ride. |
required |
ride_time
|
str | None
|
The time for the ride in format 'YYYY-MM-DD HH:MM:SS'. If None, the current time is used. |
None
|
Returns:
| Type | Description |
|---|---|
list[Ride]
|
list[Ride]: Available ride objects with quotations for all service types. |
Source code in pare/apps/cab/states.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
on_enter()
¶
Called when entering this state.
Source code in pare/apps/cab/states.py
24 25 26 | |
on_exit()
¶
Called when exiting this state.
Source code in pare/apps/cab/states.py
28 29 30 | |
open_current_ride()
¶
Get the details for the current ride.
Returns:
| Name | Type | Description |
|---|---|---|
Ride |
Ride
|
Current ride object if there is an ongoing ride. |
Source code in pare/apps/cab/states.py
59 60 61 62 63 64 65 66 67 68 69 | |
CabQuotationDetail
¶
Bases: AppState
Screen displaying a quotation (Ride before booking).
This state shows the details of a quotation and allows the user to confirm and book the ride.
Attributes:
| Name | Type | Description |
|---|---|---|
ride |
The Ride object containing the quotation details. |
Source code in pare/apps/cab/states.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
__init__(ride)
¶
Initialize quotation detail view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ride
|
Ride
|
The Ride object containing the quotation to display. |
required |
Source code in pare/apps/cab/states.py
208 209 210 211 212 213 214 215 | |
on_enter()
¶
Called when entering this state.
Source code in pare/apps/cab/states.py
217 218 219 | |
on_exit()
¶
Called when exiting this state.
Source code in pare/apps/cab/states.py
221 222 223 | |
order_ride()
¶
Confirm and book the ride from the quotation.
Returns:
| Name | Type | Description |
|---|---|---|
Ride |
Ride
|
The confirmed and booked ride. |
Source code in pare/apps/cab/states.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
show_quotation()
¶
Show the quotation details.
Returns:
| Name | Type | Description |
|---|---|---|
Ride |
Ride
|
The quotation details. |
Source code in pare/apps/cab/states.py
225 226 227 228 229 230 231 232 233 | |
CabRideDetail
¶
Bases: AppState
Detail view for a specific ride.
This state provides detailed information and operations for a specific ride, including viewing ride details, checking status, and canceling or ending the ride.
Source code in pare/apps/cab/states.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
__init__(ride)
¶
Initialize ride detail view with a ride index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ride
|
Ride
|
The ride object to display. |
required |
Source code in pare/apps/cab/states.py
96 97 98 99 100 101 102 103 | |
cancel_ride()
¶
Cancel the current ride.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Cancellation confirmation message. |
Source code in pare/apps/cab/states.py
113 114 115 116 117 118 119 120 121 122 123 | |
on_enter()
¶
Called when entering this state.
Source code in pare/apps/cab/states.py
105 106 107 | |
on_exit()
¶
Called when exiting this state.
Source code in pare/apps/cab/states.py
109 110 111 | |
CabServiceOptions
¶
Bases: AppState
Screen displaying available service types.
This state allows users to browse available service types and view quotations for specific service types based on their journey details.
Attributes:
| Name | Type | Description |
|---|---|---|
start_location |
The starting location for the ride. |
|
end_location |
The destination location for the ride. |
|
ride_time |
Optional scheduled time for the ride. |
Source code in pare/apps/cab/states.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
__init__(start_location, end_location, ride_time=None)
¶
Initialize service options view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_location
|
str
|
The starting location for the ride. |
required |
end_location
|
str
|
The destination location for the ride. |
required |
ride_time
|
str | None
|
Optional scheduled time for the ride. |
None
|
Source code in pare/apps/cab/states.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
get_quotation(service_type)
¶
View quotation for a specific service type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service_type
|
str
|
The type of service to get a quotation for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Ride |
Ride
|
Quotation for the specified service type. |
Source code in pare/apps/cab/states.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
list_service_types()
¶
List all available service types.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: Sorted list of available service type names. |
Source code in pare/apps/cab/states.py
165 166 167 168 169 170 171 172 173 174 | |
on_enter()
¶
Called when entering this state.
Source code in pare/apps/cab/states.py
157 158 159 | |
on_exit()
¶
Called when exiting this state.
Source code in pare/apps/cab/states.py
161 162 163 | |
Apartment App¶
Stateful Apartment app combining ARE ApartmentListingApp with PARE navigation.
StatefulApartmentApp
¶
Bases: StatefulApp, ApartmentListingApp
Apartment app with navigation-aware PARE behavior.
Source code in pare/apps/apartment/app.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
__init__(*args, **kwargs)
¶
Initialize apartment app and load the root navigation state.
Source code in pare/apps/apartment/app.py
24 25 26 27 | |
create_root_state()
¶
Return the root navigation state for the apartment app.
Source code in pare/apps/apartment/app.py
29 30 31 | |
handle_state_transition(event)
¶
Update navigation state after an apartment operation completes.
Source code in pare/apps/apartment/app.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
ApartmentDetail
¶
Bases: AppState
Detail screen for a specific apartment.
Source code in pare/apps/apartment/states.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
__init__(apartment_id)
¶
Initialize the detail screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
apartment_id
|
str
|
Unique identifier for the apartment. |
required |
Source code in pare/apps/apartment/states.py
90 91 92 93 94 95 96 97 | |
on_enter()
¶
Run when entering the detail screen.
Source code in pare/apps/apartment/states.py
99 100 101 | |
on_exit()
¶
Run when exiting the detail screen.
Source code in pare/apps/apartment/states.py
103 104 105 | |
save()
¶
Save this apartment to saved apartments lists.
Source code in pare/apps/apartment/states.py
107 108 109 110 111 112 113 | |
unsave()
¶
Remove this apartment from the saved list.
Source code in pare/apps/apartment/states.py
115 116 117 118 119 120 121 | |
ApartmentFavorites
¶
Bases: AppState
Screen showing saved apartments.
Source code in pare/apps/apartment/states.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
on_enter()
¶
Run when entering the saved apartments screen.
Source code in pare/apps/apartment/states.py
199 200 201 | |
on_exit()
¶
Run when exiting the saved apartments screen.
Source code in pare/apps/apartment/states.py
203 204 205 | |
view_apartment(apartment_id)
¶
View an apartment from the saved list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
apartment_id
|
str
|
Unique identifier for the apartment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Apartment |
Apartment
|
Apartment details. |
Source code in pare/apps/apartment/states.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
ApartmentHome
¶
Bases: AppState
Main screen for listing apartments and navigating to other views.
Source code in pare/apps/apartment/states.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
list_apartments()
¶
List all apartments.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: All available apartment records. |
Source code in pare/apps/apartment/states.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
on_enter()
¶
Run when entering the home screen.
Source code in pare/apps/apartment/states.py
24 25 26 | |
on_exit()
¶
Run when exiting the home screen.
Source code in pare/apps/apartment/states.py
28 29 30 | |
open_favorites()
¶
Navigate to the saved apartments page.
Returns:
| Type | Description |
|---|---|
dict[str, Apartment]
|
dict[str, Apartment]: Saved apartments. |
Source code in pare/apps/apartment/states.py
73 74 75 76 77 78 79 80 81 82 83 | |
open_search()
¶
Navigate to the search page.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Confirmation that the search view is open. |
Source code in pare/apps/apartment/states.py
63 64 65 66 67 68 69 70 71 | |
view_apartment(apartment_id)
¶
Open the detail screen for a specific apartment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
apartment_id
|
str
|
Unique identifier for the apartment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Apartment |
Apartment
|
Apartment details. |
Source code in pare/apps/apartment/states.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
ApartmentSearch
¶
Bases: AppState
Screen for searching apartments with optional filtering.
Source code in pare/apps/apartment/states.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
on_enter()
¶
Run when entering the search screen.
Source code in pare/apps/apartment/states.py
128 129 130 | |
on_exit()
¶
Run when exiting the search screen.
Source code in pare/apps/apartment/states.py
132 133 134 | |
search(name=None, location=None, zip_code=None, min_price=None, max_price=None, number_of_bedrooms=None, number_of_bathrooms=None, property_type=None, square_footage=None, furnished_status=None, floor_level=None, pet_policy=None, lease_term=None, amenities=None)
¶
Search apartments using optional filtering criteria.
Returns:
| Type | Description |
|---|---|
dict[str, Apartment]
|
dict[str, Apartment]: Filtered apartment results. |
Source code in pare/apps/apartment/states.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
view_apartment(apartment_id)
¶
Open detail page from search results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
apartment_id
|
str
|
Unique identifier for the apartment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Apartment |
Apartment
|
Apartment details. |
Source code in pare/apps/apartment/states.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
Reminder App¶
Stateful reminder app combining ARE ReminderApp with PARE navigation.
StatefulReminderApp
¶
Bases: StatefulApp, ReminderApp
Reminder application with PARE navigation support.
Source code in pare/apps/reminder/app.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
__init__(*args, **kwargs)
¶
Initialize the reminder app and load the root navigation state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments passed to ReminderApp. |
()
|
**kwargs
|
Any
|
Keyword arguments passed to ReminderApp. |
{}
|
Source code in pare/apps/reminder/app.py
26 27 28 29 30 31 32 33 34 | |
create_root_state()
¶
Create and return the root navigation state.
Returns:
| Type | Description |
|---|---|
ReminderList
|
The initial ReminderList state. |
Source code in pare/apps/reminder/app.py
36 37 38 39 40 41 42 | |
get_reminder_with_id(reminder_id)
¶
Retrieve a reminder by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reminder_id
|
str
|
The ID of the reminder to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
Reminder
|
The Reminder object corresponding to the given ID. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the reminder ID does not exist. |
Source code in pare/apps/reminder/app.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
handle_state_transition(event)
¶
Update navigation state after a reminder operation completes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
CompletedEvent
|
Completed event containing tool invocation information. |
required |
Source code in pare/apps/reminder/app.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
update_reminder(reminder_id, title, description, due_datetime, repetition_unit, repetition_value)
¶
Update an existing reminder and regenerate its repetitions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reminder_id
|
str
|
ID of the reminder to update. |
required |
title
|
str
|
Updated title. |
required |
description
|
str
|
Updated description. |
required |
due_datetime
|
str
|
Updated due datetime in "YYYY-MM-DD HH:MM:SS" format. |
required |
repetition_unit
|
str | None
|
Repetition unit (e.g., "day", "week"), or None. |
required |
repetition_value
|
int | None
|
Repetition interval value, or None. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The reminder ID after update. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the reminder ID does not exist. |
Source code in pare/apps/reminder/app.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
EditReminder
¶
Bases: AppState
State enabling editing of an existing reminder.
Source code in pare/apps/reminder/states.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
__init__(reminder_id=None)
¶
Initialize the edit wizard.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reminder_id
|
str | None
|
ID of the reminder to edit. |
None
|
Source code in pare/apps/reminder/states.py
155 156 157 158 159 160 161 162 163 | |
cancel()
¶
Abort editing and go back.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Confirmation of cancellation. |
Source code in pare/apps/reminder/states.py
271 272 273 274 275 276 277 278 279 | |
on_enter()
¶
Load existing reminder fields into draft.
Source code in pare/apps/reminder/states.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
on_exit()
¶
Lifecycle hook called when exiting EditReminder.
Source code in pare/apps/reminder/states.py
181 182 183 | |
save()
¶
Save the changes to the reminder.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Reminder ID after update. |
Source code in pare/apps/reminder/states.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
set_description(description)
¶
Update description in draft.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description
|
str
|
New description. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ReminderDraft |
ReminderDraft
|
Updated draft with new description. |
Source code in pare/apps/reminder/states.py
199 200 201 202 203 204 205 206 207 208 209 210 211 | |
set_due_datetime(due_datetime)
¶
Update due datetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
due_datetime
|
str
|
New datetime. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ReminderDraft |
ReminderDraft
|
Updated draft with new due datetime. |
Source code in pare/apps/reminder/states.py
213 214 215 216 217 218 219 220 221 222 223 224 225 | |
set_repetition(unit, value=None)
¶
Update repetition settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str | None
|
Repetition unit. |
required |
value
|
int | None
|
Repetition count. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ReminderDraft |
ReminderDraft
|
Updated draft with new repetition settings. |
Source code in pare/apps/reminder/states.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
set_title(title)
¶
Update title in the draft.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
New title. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ReminderDraft |
ReminderDraft
|
Updated draft with new title. |
Source code in pare/apps/reminder/states.py
185 186 187 188 189 190 191 192 193 194 195 196 197 | |
ReminderDetail
¶
Bases: AppState
State displaying the full details of a single reminder.
Source code in pare/apps/reminder/states.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
__init__(reminder_id)
¶
Initialize the detail view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reminder_id
|
str
|
The ID of the reminder being displayed. |
required |
Source code in pare/apps/reminder/states.py
111 112 113 114 115 116 117 118 | |
delete()
¶
Delete this reminder.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
ID of deleted reminder. |
Source code in pare/apps/reminder/states.py
138 139 140 141 142 143 144 145 146 147 148 | |
edit()
¶
Request to edit this reminder.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
ID of reminder to edit. |
Source code in pare/apps/reminder/states.py
128 129 130 131 132 133 134 135 136 | |
on_enter()
¶
Lifecycle hook called when entering ReminderDetail.
Source code in pare/apps/reminder/states.py
120 121 122 | |
on_exit()
¶
Lifecycle hook called when leaving ReminderDetail.
Source code in pare/apps/reminder/states.py
124 125 126 | |
ReminderDraft
dataclass
¶
Container representing mutable reminder fields during editing or creation.
Source code in pare/apps/reminder/states.py
17 18 19 20 21 22 23 24 25 | |
ReminderList
¶
Bases: AppState
State showing the full list of reminders.
Source code in pare/apps/reminder/states.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
create_new()
¶
Request to start creating a new reminder. Initially the reminder is empty.
Returns:
| Name | Type | Description |
|---|---|---|
ReminderDraft |
ReminderDraft
|
Draft Reminder object to be filled out. |
Source code in pare/apps/reminder/states.py
96 97 98 99 100 101 102 103 104 | |
list_all_reminders()
¶
Get all the reminders from the reminder system.
Returns:
| Type | Description |
|---|---|
list[Reminder]
|
list[Reminder]: A list of reminders as returned by the backend. |
Source code in pare/apps/reminder/states.py
40 41 42 43 44 45 46 47 48 49 50 | |
list_due_reminders()
¶
Get due reminders from the reminder system. Due reminders are those that are past their due datetime.
Returns:
| Type | Description |
|---|---|
list[Reminder]
|
list[Reminder]: A list of due reminders as returned by the backend. |
Source code in pare/apps/reminder/states.py
70 71 72 73 74 75 76 77 78 79 80 | |
list_upcoming_reminders()
¶
Get upcoming reminders from the reminder system. Upcoming reminders are those that are due in the near future.
Returns:
| Type | Description |
|---|---|
list[Reminder]
|
list[Reminder]: A list of upcoming reminders as returned by the backend. |
Source code in pare/apps/reminder/states.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
on_enter()
¶
Lifecycle hook called when entering ReminderList.
Source code in pare/apps/reminder/states.py
32 33 34 | |
on_exit()
¶
Lifecycle hook called when leaving ReminderList.
Source code in pare/apps/reminder/states.py
36 37 38 | |
open_reminder(reminder_id)
¶
Request to view details of a specific reminder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reminder_id
|
str
|
ID of the reminder to view. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Reminder |
Reminder
|
The Reminder object corresponding to the given ID. |
Source code in pare/apps/reminder/states.py
82 83 84 85 86 87 88 89 90 91 92 93 94 | |
Shopping App¶
Stateful shopping app combining Meta-ARE shopping backend with PARE navigation.
StatefulShoppingApp
¶
Bases: StatefulApp, ShoppingApp
Shopping app with PARE-aware navigation.
Source code in pare/apps/shopping/app.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
__init__(*args, **kwargs)
¶
Initialise shopping app with root state.
Source code in pare/apps/shopping/app.py
28 29 30 31 | |
add_order(order_id, order_status, order_date, order_total, item_id, quantity)
¶
Add an order (used for scenario seeding).
The upstream are ShoppingApp currently returns extra keys (e.g. name,
product_id) from _get_item(), but its CartItem dataclass does not
accept them. We defensively filter to the fields CartItem supports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order_id
|
str
|
The ID of the order. |
required |
order_status
|
str
|
The status of the order. |
required |
order_date
|
float
|
The date of the order as a timestamp. |
required |
order_total
|
float
|
The total amount of the order. |
required |
item_id
|
str
|
The ID of the item to add to the order. |
required |
quantity
|
int
|
The quantity of the item to add to the order. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ID of the created order. |
Source code in pare/apps/shopping/app.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
add_order_multiple_items(order_id, order_status, order_date, order_total, items)
¶
Add an order with multiple items (used for scenario seeding).
The upstream are ShoppingApp currently returns extra keys (e.g. name,
product_id) from _get_item(), but its CartItem dataclass does not
accept them. We defensively filter to the fields CartItem supports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order_id
|
str
|
The ID of the order. |
required |
order_status
|
str
|
The status of the order. |
required |
order_date
|
float
|
The date of the order as a timestamp. |
required |
order_total
|
float
|
The total amount of the order. |
required |
items
|
dict[str, int]
|
A dictionary mapping item IDs to quantities. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ID of the created order. |
Source code in pare/apps/shopping/app.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
create_root_state()
¶
Return root navigation state.
Source code in pare/apps/shopping/app.py
274 275 276 | |
get_cart()
¶
Wrapper for list_cart() used by states.
Source code in pare/apps/shopping/app.py
282 283 284 | |
get_item(item_id)
¶
Wrapper for _get_item for compatibility.
Source code in pare/apps/shopping/app.py
278 279 280 | |
handle_state_transition(event)
¶
Update navigation state based on completed operations.
Source code in pare/apps/shopping/app.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
Navigation state implementations for the stateful shopping app.
This module defines the navigation-aware states used by
StatefulShoppingApp, providing product browsing, variant inspection,
cart interaction, and order history viewing.
Output format conventions
- READ operations → dict | list | object
- WRITE operations → str | dict
CartView
¶
Bases: AppState
Navigation state showing cart contents.
Source code in pare/apps/shopping/states.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
__init__()
¶
Initialise the cart view.
Source code in pare/apps/shopping/states.py
169 170 171 | |
checkout(discount_code=None)
¶
Checkout the cart and create an order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
discount_code
|
str | None
|
Optional discount code. |
None
|
Returns:
| Type | Description |
|---|---|
str | dict[str, Any]
|
str | dict[str, Any]: Order confirmation. |
Source code in pare/apps/shopping/states.py
196 197 198 199 200 201 202 203 204 205 206 207 208 | |
on_enter()
¶
No-op entry hook.
Source code in pare/apps/shopping/states.py
173 174 175 | |
on_exit()
¶
No-op exit hook.
Source code in pare/apps/shopping/states.py
177 178 179 | |
remove_item(item_id, quantity=1)
¶
Remove an item or reduce its quantity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
str
|
Identifier of the variant to remove. |
required |
quantity
|
int
|
Quantity to remove. |
1
|
Returns:
| Type | Description |
|---|---|
str | dict[str, Any]
|
str | dict[str, Any]: Backend removal result. |
Source code in pare/apps/shopping/states.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
OrderDetailView
¶
Bases: AppState
Detailed view for a single order.
Source code in pare/apps/shopping/states.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
__init__(order_id)
¶
Bind state to a specific order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order_id
|
str
|
Identifier of the order to display. |
required |
Source code in pare/apps/shopping/states.py
246 247 248 249 250 251 252 253 | |
on_enter()
¶
No-op entry hook.
Source code in pare/apps/shopping/states.py
255 256 257 | |
on_exit()
¶
No-op exit hook.
Source code in pare/apps/shopping/states.py
259 260 261 | |
view_order()
¶
Retrieve backend data for the current order.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Order detail payload. |
Source code in pare/apps/shopping/states.py
263 264 265 266 267 268 269 270 271 272 | |
OrderListView
¶
Bases: AppState
State listing all completed orders.
Source code in pare/apps/shopping/states.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
__init__()
¶
Initialise the order list view.
Source code in pare/apps/shopping/states.py
215 216 217 | |
on_enter()
¶
No-op entry hook.
Source code in pare/apps/shopping/states.py
219 220 221 | |
on_exit()
¶
No-op exit hook.
Source code in pare/apps/shopping/states.py
223 224 225 | |
view_order(order_id)
¶
Open details for a specific order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order_id
|
str
|
Order identifier. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Order detail payload. |
Source code in pare/apps/shopping/states.py
227 228 229 230 231 232 233 234 235 236 237 238 239 | |
ProductDetail
¶
Bases: AppState
Detail view for a specific product.
Source code in pare/apps/shopping/states.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
__init__(product_id)
¶
Bind this state to a product identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_id
|
str
|
Product ID for which details are displayed. |
required |
Source code in pare/apps/shopping/states.py
97 98 99 100 101 102 103 104 | |
on_enter()
¶
No-op entry hook.
Source code in pare/apps/shopping/states.py
106 107 108 | |
on_exit()
¶
No-op exit hook.
Source code in pare/apps/shopping/states.py
110 111 112 | |
view_variant(item_id)
¶
Open a specific variant for this product.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
str
|
Variant (item) identifier. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Variant detail payload. |
Source code in pare/apps/shopping/states.py
114 115 116 117 118 119 120 121 122 123 124 125 126 | |
ShoppingHome
¶
Bases: AppState
Root navigation state providing product catalog access.
Source code in pare/apps/shopping/states.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
__init__()
¶
Initialise the home state.
Source code in pare/apps/shopping/states.py
29 30 31 | |
list_orders()
¶
List all previous orders.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: Summaries of past orders. |
Source code in pare/apps/shopping/states.py
81 82 83 84 85 86 87 88 89 90 | |
list_products(offset=0, limit=10)
¶
List all available products.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
Pagination offset. |
0
|
limit
|
int
|
Maximum number of products to return. |
10
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Backend payload containing products and metadata. |
Source code in pare/apps/shopping/states.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
on_enter()
¶
No-op hook for entering the home screen.
Source code in pare/apps/shopping/states.py
33 34 35 | |
on_exit()
¶
No-op hook for exiting the home screen.
Source code in pare/apps/shopping/states.py
37 38 39 | |
view_cart()
¶
Open the cart screen.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Cart contents. |
Source code in pare/apps/shopping/states.py
70 71 72 73 74 75 76 77 78 79 | |
view_product(product_id)
¶
Retrieve product details and navigate to ProductDetail.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_id
|
str
|
Identifier for the product to open. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Detailed product information. |
Source code in pare/apps/shopping/states.py
56 57 58 59 60 61 62 63 64 65 66 67 68 | |
VariantDetail
¶
Bases: AppState
Detail view for a single product variant.
Source code in pare/apps/shopping/states.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
__init__(item_id)
¶
Initialise the state with an item identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
str
|
The variant being displayed. |
required |
Source code in pare/apps/shopping/states.py
133 134 135 136 137 138 139 140 | |
add_to_cart(quantity=1)
¶
Add this variant to the cart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quantity
|
int
|
Number of units to add. |
1
|
Returns:
| Type | Description |
|---|---|
str | dict[str, Any]
|
str | dict[str, Any]: Backend confirmation or cart update result. |
Source code in pare/apps/shopping/states.py
150 151 152 153 154 155 156 157 158 159 160 161 162 | |
on_enter()
¶
No-op entry hook.
Source code in pare/apps/shopping/states.py
142 143 144 | |
on_exit()
¶
No-op exit hook.
Source code in pare/apps/shopping/states.py
146 147 148 | |
Notes App¶
NotesFolder
¶
Container managing notes within a single folder.
Source code in pare/apps/note/app.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
__init__(folder_name)
¶
Initialize a note folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_name
|
str
|
Name of the folder. |
required |
Source code in pare/apps/note/app.py
33 34 35 36 37 38 39 40 | |
add_note(note)
¶
Add a note and sort by timestamp.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note
|
Note
|
Note to add. |
required |
Source code in pare/apps/note/app.py
42 43 44 45 46 47 48 49 50 | |
get_note(idx)
¶
Get a note by index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int
|
Index of the note. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Note |
Note
|
The note at the given index. |
Source code in pare/apps/note/app.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
get_note_by_id(note_id)
¶
Lookup a note by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
Target note ID. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Note |
Note | None
|
Found note. |
Source code in pare/apps/note/app.py
109 110 111 112 113 114 115 116 117 118 119 120 | |
get_notes(offset=0, limit=5)
¶
Retrieve paginated notes with the most recently updated notes first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
Starting index. |
0
|
limit
|
int
|
Maximum number of notes to return. |
5
|
Returns:
| Name | Type | Description |
|---|---|---|
ReturnedNotes |
ReturnedNotes
|
Paginated result container. |
Source code in pare/apps/note/app.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
get_state()
¶
Serialize folder state.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Serialized state. |
Source code in pare/apps/note/app.py
134 135 136 137 138 139 140 | |
load_state(state_dict)
¶
Deserialize folder state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_dict
|
dict[str, Any]
|
State to load. |
required |
Source code in pare/apps/note/app.py
142 143 144 145 146 147 148 149 150 | |
remove_note(note_id)
¶
Remove a note by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
ID of note to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if removed, False if not found. |
Source code in pare/apps/note/app.py
52 53 54 55 56 57 58 59 60 61 62 63 64 | |
search_notes(query)
¶
Search notes within this folder using a query string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Search query. |
required |
Returns:
| Type | Description |
|---|---|
list[Note]
|
list[Note]: Matched notes. |
Source code in pare/apps/note/app.py
122 123 124 125 126 127 128 129 130 131 132 | |
StatefulNotesApp
dataclass
¶
Bases: StatefulApp
A Notes application that manages user's notes and folder organization. This class provides comprehensive functionality for handling notes including creating, updating, deleting, and searching notes.
This app maintains the notes in different folders. Default folders are "Inbox", "Personal", and "Work". New folders can be created by the user.
Key Features: - Note Management: Create, update, move and delete notes - Folder Management: Create, delete, and search folders (Default folders cannot be deleted) - Attachment Management: Handle note attachments (upload and download) - Search Functionality: Search notes across folders with text-based queries - State Management: Save and load application state
Key Components: - Folders: Each NotesFolder instance maintains its own collection of notes - View Limits: Configurable limit for note viewing and pagination - Event Registration: All operations are tracked through event registration
Notes: - Note IDs are automatically generated when creating new notes. - Attachments are handled using base64 encoding. - Search operations are case-insensitive. - All notes operations maintain folder integrity.
Source code in pare/apps/note/app.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | |
__post_init__()
¶
Initialize app with default folders.
Source code in pare/apps/note/app.py
183 184 185 186 187 188 189 190 191 192 193 | |
add_attachment(note, attachment_path)
¶
Add a file attachment to a note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note
|
Note
|
The note to add the attachment to. |
required |
attachment_path
|
str
|
The path to the attachment to add. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Note |
Note
|
The updated note object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If file does not exist. |
Source code in pare/apps/note/app.py
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 | |
add_attachment_to_note(note_id, attachment_path)
¶
Add a file attachment to a note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
The ID of the note to add the attachment to. |
required |
attachment_path
|
str
|
The path to the attachment to add. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ID of the note that the attachment was added to. |
Source code in pare/apps/note/app.py
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | |
connect_to_protocols(protocols)
¶
Connect to the given list of protocols.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
protocols
|
dict[Protocol, Any]
|
Dictionary of protocols. |
required |
Source code in pare/apps/note/app.py
195 196 197 198 199 200 201 202 203 | |
create_note(folder='Inbox', title='', content='', pinned=False)
¶
Create a new note with title and content. If title string is empty, it will be set to the first 50 characters of the content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Folder to create the note under. |
'Inbox'
|
title
|
str
|
Title of the note. |
''
|
content
|
str
|
Content of the note. |
''
|
pinned
|
bool
|
Whether the note should be pinned. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
ID of the newly created note. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If specified folder is not found. |
Source code in pare/apps/note/app.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
create_note_with_time(folder='Inbox', title='', content='', pinned=False, created_at=datetime.now(UTC).strftime('%Y-%m-%d %H:%M:%S'), updated_at=None)
¶
Create a new note with title and content at a specific time. If title string is empty, it will be set to the first 50 characters of the content. If specified folder is not found, a new folder will be created.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Folder to create the note under. |
'Inbox'
|
title
|
str
|
Title of the note. |
''
|
content
|
str
|
Content of the note. |
''
|
pinned
|
bool
|
Whether the note should be pinned. |
False
|
created_at
|
str
|
Time of the note creation. Defaults to the current time. |
strftime('%Y-%m-%d %H:%M:%S')
|
updated_at
|
str
|
Time of the note update. Defaults to the creation time. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
ID of the newly created note. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If creation or update time is invalid, or if updated time is before creation time. |
Source code in pare/apps/note/app.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
create_root_state()
¶
Return the root navigation state.
Returns:
| Name | Type | Description |
|---|---|---|
NoteList |
NoteList
|
Default folder view. |
Source code in pare/apps/note/app.py
205 206 207 208 209 210 211 | |
delete_folder(folder_name)
¶
Delete a folder and all it's notes. Default folders "Inbox", "Personal", and "Work" cannot be deleted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_name
|
str
|
Name of the folder to delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Name of the deleted folder if successful. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If folder does not exist, or if the folder to be deleted is one of the default folders. |
Source code in pare/apps/note/app.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
delete_note(note_id)
¶
Delete a note with the specified ID. Deleted Note ID is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
ID of note to delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
ID of the deleted note. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If note ID is not a string. |
ValueError
|
If note ID is empty. |
KeyError
|
If note not found. |
Source code in pare/apps/note/app.py
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | |
duplicate_note(folder_name, note_id)
¶
Create a duplicated copy of a note. The new note is added to the same folder as the original note and the title is "Copy of
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_name
|
str
|
The folder of the original note. Defaults to Inbox. |
required |
note_id
|
str
|
The ID of the note to copy. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ID of the newly created duplicate. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If folder not found or note not found in folder. |
Source code in pare/apps/note/app.py
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | |
get_note_by_id(note_id)
¶
Retrieve a note by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
Target note ID. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Note |
Note
|
The retrieved note object. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If note not found. |
Source code in pare/apps/note/app.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | |
get_state()
¶
Serialize app state.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Complete app state. |
Source code in pare/apps/note/app.py
213 214 215 216 217 218 219 220 221 222 | |
handle_state_transition(event)
¶
Core navigation handler mapping backend operations to state transitions.
Source code in pare/apps/note/app.py
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 | |
list_attachments(note_id)
¶
List attachment identifiers for a note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
Target note ID. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: Attachment list. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If note not found. |
Source code in pare/apps/note/app.py
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 | |
list_folders()
¶
List all folder names.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: Folder list. |
Source code in pare/apps/note/app.py
564 565 566 567 568 569 570 571 572 573 | |
list_notes(folder, offset=0, limit=10)
¶
List notes in the specific folder with a specified offset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
The folder to list notes from. |
required |
offset
|
int
|
The offset of the first note to return. |
0
|
limit
|
int
|
The maximum number of notes to return. |
10
|
Returns:
| Name | Type | Description |
|---|---|---|
ReturnedNotes |
ReturnedNotes
|
Notes with additional metadata about the range of notes retrieved and total number of notes |
Source code in pare/apps/note/app.py
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
load_state(state_dict)
¶
Deserialize app state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_dict
|
dict[str, Any]
|
State to restore. |
required |
Source code in pare/apps/note/app.py
224 225 226 227 228 229 230 231 232 233 234 235 | |
move_note(note_id, source_folder_name='Inbox', dest_folder_name='Personal')
¶
Move a note with the specified ID to the specified folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
The ID of the note to move. |
required |
source_folder_name
|
str
|
The folder to move the note from. Defaults to Inbox. |
'Inbox'
|
dest_folder_name
|
str
|
The folder to move the note to. Defaults to Personal. |
'Personal'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ID of the moved note |
Raises:
| Type | Description |
|---|---|
KeyError
|
If source or destination folder not found or note not found in source folder. |
Source code in pare/apps/note/app.py
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | |
new_folder(folder_name)
¶
Create a new empty folder with the given name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_name
|
str
|
Name of the new folder. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Name of the newly created folder. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If folder already exists. |
Source code in pare/apps/note/app.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
open_folder(folder)
¶
Open a folder and return the notes in the folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Name of the folder to open. |
required |
Returns:
| Type | Description |
|---|---|
list[Note]
|
list[Note]: List of notes in the folder. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If folder does not exist. |
ValueError
|
If folder name is empty. |
Source code in pare/apps/note/app.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
remove_attachment(note_id, attachment)
¶
Remove an attachment from a note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
Target note ID. |
required |
attachment
|
str
|
Attachment to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ID of the note that the attachment was removed from. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If note not found in any folder or attachment not found in note. |
Source code in pare/apps/note/app.py
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 | |
rename_folder(folder, new_folder)
¶
Rename an already existing folder. Default folders "Inbox", "Personal", and "Work" cannot be renamed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Name of the folder to rename. |
required |
new_folder
|
str
|
New name for the folder. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Name of the renamed folder. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If folder_name does not exist, a folder with the new name already exists or if the folder to be renamed is one of the default folders. |
Source code in pare/apps/note/app.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
reset()
¶
Reset the app to empty state.
Source code in pare/apps/note/app.py
237 238 239 240 241 | |
search_notes(query)
¶
Search for notes across all folders based on a query string. The search looks for partial matches in title, and content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The search query string. |
required |
Returns:
| Type | Description |
|---|---|
list[Note]
|
list[Note]: A list of notes that match the query. |
Source code in pare/apps/note/app.py
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | |
search_notes_in_folder(query, folder_name)
¶
Search for notes in a specific folder based on a query string. The search looks for partial matches in title, and content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The search query string. |
required |
folder_name
|
str
|
The folder to search in. Defaults to Inbox. |
required |
Returns:
| Type | Description |
|---|---|
list[Note]
|
list[Note]: A list of notes that match the query. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If folder not found. |
Source code in pare/apps/note/app.py
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | |
update_note(note_id, title=None, content=None)
¶
Update the title or the content of the note. At least one of title or content must be provided.
Notes: - If both title and content are provided, both will be updated. - If the note has no title and new title is provided, the title will be set to the new title. - If the note has no title and content is provided, the title will be set to the first 50 characters of the content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
Target note ID. |
required |
title
|
str | None
|
New title for the note. |
None
|
content
|
str | None
|
New content for the note. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Note ID of the updated note. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If note not found. |
ValueError
|
If both title and content are empty. |
Source code in pare/apps/note/app.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | |
EditNote
¶
Bases: AppState
State enabling editing capabilities for an existing note.
Source code in pare/apps/note/states.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
__init__(note_id)
¶
Initialize editing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
The note to modify. |
required |
Source code in pare/apps/note/states.py
247 248 249 250 251 252 253 254 255 | |
on_enter()
¶
Lifecycle hook when entering EditNote.
Source code in pare/apps/note/states.py
257 258 259 260 | |
on_exit()
¶
Lifecycle hook when leaving EditNote.
Source code in pare/apps/note/states.py
262 263 264 | |
update(title, content)
¶
Update note content and title.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Updated title. |
required |
content
|
str
|
Updated content. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Note ID of the updated note. |
Source code in pare/apps/note/states.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
FolderList
¶
Bases: AppState
State displaying the list of folders.
Source code in pare/apps/note/states.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
list_folders()
¶
Return all folders.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: Folder names. |
Source code in pare/apps/note/states.py
293 294 295 296 297 298 299 300 301 302 | |
on_enter()
¶
Lifecycle hook when entering FolderList.
Source code in pare/apps/note/states.py
285 286 287 | |
on_exit()
¶
Lifecycle hook when leaving FolderList.
Source code in pare/apps/note/states.py
289 290 291 | |
open(folder)
¶
Open the selected folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Folder name. |
required |
Returns:
| Type | Description |
|---|---|
list[Note]
|
list[Note]: Notes in the opened folder. |
Source code in pare/apps/note/states.py
304 305 306 307 308 309 310 311 312 313 314 315 | |
NoteDetail
¶
Bases: AppState
State showing detailed view of a single note.
Source code in pare/apps/note/states.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
__init__(note_id)
¶
Initialize NoteDetail.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
ID of the note being viewed. |
required |
Source code in pare/apps/note/states.py
110 111 112 113 114 115 116 117 118 | |
add_attachment(attachment_path)
¶
Add a file attachment to the note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attachment_path
|
str
|
Path to the attachment to add. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Returns note ID to which the attachment was added. |
Source code in pare/apps/note/states.py
159 160 161 162 163 164 165 166 167 168 169 170 171 | |
delete()
¶
Delete the note.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Returns note ID of the deleted note. |
Source code in pare/apps/note/states.py
187 188 189 190 191 192 193 194 195 196 | |
duplicate()
¶
Create a duplicate copy of this note in the same folder.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Note ID of the newly created duplicate. |
Source code in pare/apps/note/states.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
edit()
¶
Open edit mode for this note.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The note_id being edited. |
Source code in pare/apps/note/states.py
198 199 200 201 202 203 204 205 206 | |
go_back()
¶
Navigate back to the previous state.
Source code in pare/apps/note/states.py
129 130 131 132 133 | |
list_attachments()
¶
List attachments associated with the note.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: Attachment names. |
Source code in pare/apps/note/states.py
148 149 150 151 152 153 154 155 156 157 | |
move(dest_folder_name)
¶
Move this note to another folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dest_folder_name
|
str
|
The destination folder name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Note ID of the moved note. |
Source code in pare/apps/note/states.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
on_enter()
¶
Lifecycle hook when entering NoteDetail.
Source code in pare/apps/note/states.py
120 121 122 123 | |
on_exit()
¶
Lifecycle hook when leaving NoteDetail.
Source code in pare/apps/note/states.py
125 126 127 | |
refresh()
¶
Reload the note content.
Returns:
| Name | Type | Description |
|---|---|---|
Note |
Note
|
Updated note object. |
Source code in pare/apps/note/states.py
135 136 137 138 139 140 141 142 143 144 145 146 | |
remove_attachment(attachment)
¶
Remove an attachment from the note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attachment
|
str
|
Attachment identifier. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Returns note ID from which the attachment was removed. |
Source code in pare/apps/note/states.py
173 174 175 176 177 178 179 180 181 182 183 184 185 | |
NoteList
¶
Bases: AppState
State representing a list of notes within a folder or search mode.
Source code in pare/apps/note/states.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
__init__(folder='Inbox')
¶
Initialize the list view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Folder name to filter notes. |
'Inbox'
|
Source code in pare/apps/note/states.py
18 19 20 21 22 23 24 25 | |
go_back()
¶
Navigate back to the previous state.
Source code in pare/apps/note/states.py
35 36 37 38 39 | |
list_folders()
¶
List all folders.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: Folder names. |
Source code in pare/apps/note/states.py
95 96 97 98 99 100 101 102 103 104 | |
list_notes(offset=0, limit=10)
¶
Return paginated notes under the current folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
Starting index for pagination. |
0
|
limit
|
int
|
Maximum number of notes to return. |
10
|
Returns:
| Name | Type | Description |
|---|---|---|
ReturnedNotes |
ReturnedNotes
|
Paginated notes container. |
Source code in pare/apps/note/states.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
new_note()
¶
Create a new note in the current folder.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
ID of newly created note. |
Source code in pare/apps/note/states.py
70 71 72 73 74 75 76 77 78 79 | |
on_enter()
¶
Lifecycle hook when entering NoteList.
Source code in pare/apps/note/states.py
27 28 29 | |
on_exit()
¶
Lifecycle hook when leaving NoteList.
Source code in pare/apps/note/states.py
31 32 33 | |
open(note_id)
¶
Open a note by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_id
|
str
|
ID of the note to open. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Note |
Note
|
Note object from backend. |
Source code in pare/apps/note/states.py
56 57 58 59 60 61 62 63 64 65 66 67 68 | |
search(keyword)
¶
Search notes by keyword.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keyword
|
str
|
Search keyword. |
required |
Returns:
| Type | Description |
|---|---|
list[Note]
|
list[Note]: List of matched notes. |
Source code in pare/apps/note/states.py
81 82 83 84 85 86 87 88 89 90 91 92 93 | |
Type definitions for the Note app.
These are separated to avoid circular imports between app.py and states.py.
Note
dataclass
¶
Simple note data container.
Source code in pare/apps/note/types.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
add_attachment(path)
¶
Add an attachment to the note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the attachment. |
required |
Source code in pare/apps/note/types.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
ReturnedNotes
dataclass
¶
Container for paginated note results.
Source code in pare/apps/note/types.py
68 69 70 71 72 73 74 75 | |