appkit-assistant 0.15.0__py3-none-any.whl → 0.15.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,8 +84,17 @@ class OpenAIResponsesProcessor(BaseOpenAIProcessor):
84
84
  },
85
85
  )
86
86
  except Exception as e:
87
- logger.error("Error during response processing: %s", e)
88
- # Continue to yield auth chunks if any
87
+ error_msg = str(e)
88
+ logger.error("Error during response processing: %s", error_msg)
89
+ # Yield error chunk to show user-friendly error message
90
+ yield Chunk(
91
+ type=ChunkType.ERROR,
92
+ text=f"Ein Fehler ist aufgetreten: {error_msg}",
93
+ chunk_metadata={
94
+ "source": "responses_api",
95
+ "error_type": type(e).__name__,
96
+ },
97
+ )
89
98
 
90
99
  # After processing (or on error), yield any pending auth requirements
91
100
  logger.debug(
@@ -105,9 +114,6 @@ class OpenAIResponsesProcessor(BaseOpenAIProcessor):
105
114
  return None
106
115
 
107
116
  event_type = event.type
108
- logger.debug("Event: %s", event)
109
-
110
- # Try different handlers in order
111
117
  handlers = [
112
118
  self._handle_lifecycle_events,
113
119
  lambda et: self._handle_text_events(et, event),
@@ -121,16 +127,15 @@ class OpenAIResponsesProcessor(BaseOpenAIProcessor):
121
127
  for handler in handlers:
122
128
  result = handler(event_type)
123
129
  if result:
124
- content_preview = result.text[:50] if result.text else ""
125
- logger.debug(
126
- "Event %s → Chunk: type=%s, content=%s",
127
- event_type,
128
- result.type,
129
- content_preview,
130
- )
130
+ # content_preview = result.text[:50] if result.text else ""
131
+ # logger.debug(
132
+ # "Event %s → Chunk: type=%s, content=%s",
133
+ # event_type,
134
+ # result.type,
135
+ # content_preview,
136
+ # )
131
137
  return result
132
138
 
133
- # Log unhandled events for debugging
134
139
  logger.debug("Unhandled event type: %s", event_type)
135
140
  return None
136
141
 
@@ -549,7 +554,6 @@ class OpenAIResponsesProcessor(BaseOpenAIProcessor):
549
554
  **(payload or {}),
550
555
  }
551
556
 
552
- logger.debug("Responses API request params: %s", params)
553
557
  return await self.client.responses.create(**params)
554
558
 
555
559
  async def _configure_mcp_tools(
@@ -229,6 +229,54 @@ class MessageComponent:
229
229
  style=message_styles,
230
230
  )
231
231
 
232
+ @staticmethod
233
+ def error_message(message: str) -> rx.Component:
234
+ return rx.hstack(
235
+ rx.avatar(
236
+ fallback="!",
237
+ size="3",
238
+ variant="soft",
239
+ radius="full",
240
+ margin_top="16px",
241
+ color_scheme="red",
242
+ ),
243
+ rx.callout(
244
+ message,
245
+ icon="triangle-alert",
246
+ color_scheme="red",
247
+ max_width="90%",
248
+ size="1",
249
+ padding="0.5em",
250
+ border_radius="9px",
251
+ margin_top="18px",
252
+ ),
253
+ style=message_styles,
254
+ )
255
+
256
+ @staticmethod
257
+ def system_message(message: str) -> rx.Component:
258
+ return rx.hstack(
259
+ rx.avatar(
260
+ fallback="⚙",
261
+ size="3",
262
+ variant="soft",
263
+ radius="full",
264
+ margin_top="16px",
265
+ color_scheme="gray",
266
+ ),
267
+ rx.callout(
268
+ message,
269
+ icon="info",
270
+ color_scheme="gray",
271
+ max_width="90%",
272
+ size="1",
273
+ padding="0.5em",
274
+ border_radius="9px",
275
+ margin_top="18px",
276
+ ),
277
+ style=message_styles,
278
+ )
279
+
232
280
  @staticmethod
233
281
  def render_message(
234
282
  message: Message,
@@ -245,6 +293,14 @@ class MessageComponent:
245
293
  MessageType.ASSISTANT,
246
294
  MessageComponent.assistant_message(message),
247
295
  ),
296
+ (
297
+ MessageType.ERROR,
298
+ MessageComponent.error_message(message.text),
299
+ ),
300
+ (
301
+ MessageType.SYSTEM,
302
+ MessageComponent.system_message(message.text),
303
+ ),
248
304
  MessageComponent.info_message(message.text),
249
305
  )
250
306
  )
@@ -177,77 +177,104 @@ class Assistant:
177
177
  return;
178
178
  }
179
179
  window._mcpOAuthListenerInstalled = true;
180
- var processing = false;
180
+ var lastProcessedTimestamp = 0;
181
181
 
182
182
  function getCurrentUserId() {
183
183
  var el = document.getElementById('mcp-oauth-user-id');
184
184
  return el ? el.value : '';
185
185
  }
186
186
  function processOAuthResult(data) {
187
- if (processing) {
188
- console.log('[OAuth] Already processing, skip');
187
+ // Simple timestamp-based debouncing
188
+ var now = Date.now();
189
+ if (data.timestamp && data.timestamp === lastProcessedTimestamp) {
190
+ console.log('[OAuth] Already processed this timestamp, skip');
189
191
  return false;
190
192
  }
191
- processing = true;
193
+ lastProcessedTimestamp = data.timestamp || now;
192
194
 
193
195
  var currentUserId = getCurrentUserId();
194
196
  console.log('[OAuth] Processing, userId:', data.userId,
195
- 'current:', currentUserId);
197
+ 'current:', currentUserId, 'timestamp:', data.timestamp);
198
+
196
199
  // Security: only process if user_id matches (or not set)
197
200
  if (data.userId && currentUserId &&
198
201
  String(data.userId) !== String(currentUserId)) {
199
202
  console.log('[OAuth] Ignoring - user mismatch');
200
- processing = false;
201
203
  return false;
202
204
  }
205
+
203
206
  window._mcpOAuthData = data;
204
- var btn = document.getElementById(
205
- 'mcp-oauth-success-trigger'
206
- );
207
+ console.log('[OAuth] Stored data in window._mcpOAuthData');
208
+
209
+ var btn = document.getElementById('mcp-oauth-success-trigger');
207
210
  if (btn) {
208
211
  console.log('[OAuth] Clicking trigger button');
209
212
  btn.click();
213
+ console.log('[OAuth] Button clicked successfully');
214
+ } else {
215
+ console.error('[OAuth] Trigger button not found!');
210
216
  }
211
- // Reset after short delay to allow for page navigation
212
- setTimeout(function() { processing = false; }, 5000);
213
217
  return true;
214
218
  }
219
+
215
220
  function checkLocalStorage() {
216
- if (processing) return false;
217
221
  var stored = localStorage.getItem('mcp-oauth-result');
218
222
  if (stored) {
219
- console.log('[OAuth] Found in localStorage');
223
+ console.log('[OAuth] Found in localStorage:', stored);
220
224
  try {
221
225
  var data = JSON.parse(stored);
222
226
  if (data.type === 'mcp-oauth-success') {
227
+ console.log('[OAuth] Valid OAuth data, removing from localStorage');
223
228
  localStorage.removeItem('mcp-oauth-result');
224
229
  return processOAuthResult(data);
225
230
  }
226
- } catch(e) { console.error('[OAuth] Parse error:', e); }
231
+ } catch(e) {
232
+ console.error('[OAuth] Parse error:', e);
233
+ }
227
234
  }
228
235
  return false;
229
236
  }
237
+
230
238
  console.log('[OAuth] Installing listeners');
239
+
231
240
  window.addEventListener('storage', function(event) {
241
+ console.log('[OAuth] Storage event:', event.key);
232
242
  if (event.key === 'mcp-oauth-result') {
233
- checkLocalStorage();
243
+ setTimeout(checkLocalStorage, 100);
234
244
  }
235
245
  });
246
+
236
247
  window.addEventListener('focus', function() {
237
- checkLocalStorage();
248
+ console.log('[OAuth] Window focus event');
249
+ setTimeout(checkLocalStorage, 100);
238
250
  });
251
+
239
252
  document.addEventListener('visibilitychange', function() {
240
- if (!document.hidden) checkLocalStorage();
253
+ if (!document.hidden) {
254
+ console.log('[OAuth] Document visible');
255
+ setTimeout(checkLocalStorage, 100);
256
+ }
241
257
  });
242
- var intervalId = setInterval(function() {
243
- if (checkLocalStorage()) clearInterval(intervalId);
244
- }, 2000);
245
- checkLocalStorage();
258
+
246
259
  window.addEventListener('message', function(event) {
260
+ console.log('[OAuth] postMessage received:', event.data);
247
261
  if (event.data && event.data.type === 'mcp-oauth-success') {
262
+ console.log('[OAuth] Processing postMessage data');
248
263
  processOAuthResult(event.data);
249
264
  }
250
265
  });
266
+
267
+ // Aggressive polling - check every 500ms
268
+ var intervalId = setInterval(function() {
269
+ if (checkLocalStorage()) {
270
+ console.log('[OAuth] Success via polling, clearing interval');
271
+ clearInterval(intervalId);
272
+ }
273
+ }, 500);
274
+
275
+ // Initial check
276
+ console.log('[OAuth] Initial localStorage check');
277
+ checkLocalStorage();
251
278
  })();
252
279
  """
253
280
  ),
@@ -100,7 +100,7 @@ class ThreadListState(rx.State):
100
100
 
101
101
  # Reset ThreadState
102
102
  thread_state: ThreadState = await self.get_state(ThreadState)
103
- thread_state.new_thread()
103
+ await thread_state.new_thread()
104
104
 
105
105
  if self._initialized:
106
106
  self.loading = False
@@ -239,7 +239,7 @@ class ThreadListState(rx.State):
239
239
  self.active_thread_id = ""
240
240
  # Reset ThreadState to empty thread
241
241
  thread_state: ThreadState = await self.get_state(ThreadState)
242
- thread_state.new_thread()
242
+ await thread_state.new_thread()
243
243
 
244
244
  yield rx.toast.info(
245
245
  f"Chat '{thread_to_delete.title}' gelöscht.",
@@ -952,25 +952,21 @@ class ThreadState(rx.State):
952
952
  # Remove the incomplete assistant message from the failed attempt
953
953
  if self.messages and self.messages[-1].type == MessageType.ASSISTANT:
954
954
  self.messages = self.messages[:-1]
955
- # Add success message
956
- self.messages.append(
957
- Message(
958
- text=f"Erfolgreich mit {server_name} verbunden. "
959
- "Anfrage wird erneut gesendet...",
960
- type=MessageType.INFO,
961
- )
955
+ # Show success toast instead of adding to messages
956
+ yield rx.toast.success(
957
+ f"Erfolgreich mit {server_name} verbunden. "
958
+ "Anfrage wird erneut gesendet...",
959
+ position="top-right",
962
960
  )
963
961
  # Resend the original message by setting prompt and yielding the event
964
962
  self.prompt = pending_message
965
963
  self._skip_user_message = True # User message already in list
966
964
  yield ThreadState.submit_message
967
965
  else:
968
- # No pending message - just show success
969
- self.messages.append(
970
- Message(
971
- text=f"Erfolgreich mit {server_name} verbunden.",
972
- type=MessageType.INFO,
973
- )
966
+ # No pending message - just show success toast
967
+ yield rx.toast.success(
968
+ f"Erfolgreich mit {server_name} verbunden.",
969
+ position="top-right",
974
970
  )
975
971
 
976
972
  @rx.event
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: appkit-assistant
3
- Version: 0.15.0
3
+ Version: 0.15.2
4
4
  Summary: Add your description here
5
5
  Project-URL: Homepage, https://github.com/jenreh/appkit
6
6
  Project-URL: Documentation, https://github.com/jenreh/appkit/tree/main/docs
@@ -8,22 +8,22 @@ appkit_assistant/backend/system_prompt_cache.py,sha256=83OIyixeTb3HKOy3XIzPyTAE-
8
8
  appkit_assistant/backend/processors/lorem_ipsum_processor.py,sha256=j-MZhzibrtabzbGB2Pf4Xcdlr1TlTYWNRdE22LsDp9Q,4635
9
9
  appkit_assistant/backend/processors/openai_base.py,sha256=IQS4m375BOD_K0PBFOk4i7wL1z5MEiPFxbSmC-HBNgU,4414
10
10
  appkit_assistant/backend/processors/openai_chat_completion_processor.py,sha256=nTxouoXDU6VcQr8UhA2KiMNt60KvIwM8cH9Z8lo4dXY,4218
11
- appkit_assistant/backend/processors/openai_responses_processor.py,sha256=MWBZsvtqE-knviY_-3km9zgmm7WPno5WDBXcbZHOZjE,28360
11
+ appkit_assistant/backend/processors/openai_responses_processor.py,sha256=gRmSrAGxZW5bsHZwba8vHLajo87tpW07BKJTTVCe5bQ,28565
12
12
  appkit_assistant/backend/processors/perplexity_processor.py,sha256=weHukv78MSCF_uSCKGSMpNYHsET9OB8IhpvUiMfPQ8A,3355
13
13
  appkit_assistant/components/__init__.py,sha256=5tzK5VjX9FGKK-qTUHLjr8-ohT4ykb4a-zC-I3yeRLY,916
14
14
  appkit_assistant/components/composer.py,sha256=F4VPxWp4P6fvTW4rQ7S-YWn0eje5c3jGsWrpC1aewss,3885
15
15
  appkit_assistant/components/composer_key_handler.py,sha256=KyZYyhxzFR8DH_7F_DrvTFNT6v5kG6JihlGTmCv2wv0,1028
16
16
  appkit_assistant/components/mcp_server_dialogs.py,sha256=afIImmhfrNyLmxDZBpCxHxvD8HKpDanIloLEC8dJgro,23444
17
17
  appkit_assistant/components/mcp_server_table.py,sha256=1dziN7hDDvE8Y3XcdIs0wUPv1H64kP9gRAEjgH9Yvzo,2323
18
- appkit_assistant/components/message.py,sha256=gbHp3VJmOTS6aF4QOhNhCrvh5ra38UhJxVTLtY8_o6A,11927
18
+ appkit_assistant/components/message.py,sha256=rMInKDgAha-ctKxvVwUFPyCkjWsvwtOouxrBCG61OHo,13554
19
19
  appkit_assistant/components/system_prompt_editor.py,sha256=REl33zFmcpYRe9kxvFrBRYg40dV4L4FtVC_3ibLsmrU,2940
20
- appkit_assistant/components/thread.py,sha256=Hyb09R_zsRUzFXN4a2ndkbH-EvHy9Pnl-Q3y6-djjP0,12660
20
+ appkit_assistant/components/thread.py,sha256=1GfiKJl1nHHmoDiIvUqpWqN6Xq-lLnXoFWfobnG9i6E,13834
21
21
  appkit_assistant/components/threadlist.py,sha256=1xVakSTQYi5-wgED3fTJVggeIjL_fkthehce0wKUYtM,4896
22
22
  appkit_assistant/components/tools_modal.py,sha256=12iiAVahy3j4JwjGfRlegVEa4ePhGsEu7Bq92JLn1ZI,3353
23
23
  appkit_assistant/state/mcp_server_state.py,sha256=3AFvy53xx_eLTxw-LfJklPTgq4Ohqu4xs1QlLs-kU4U,11387
24
24
  appkit_assistant/state/system_prompt_state.py,sha256=zdnYrTnl7EszALRiodu6pcuQUd2tmtPG1eJ10j_OotI,7705
25
- appkit_assistant/state/thread_list_state.py,sha256=j_juff-I1PQfvVTDF8OVTp5kiw1kuhyOX9eXDoCBKs0,10238
26
- appkit_assistant/state/thread_state.py,sha256=3LNnEmdp6oU8npt1MEUBYA31cdF-QAP_-Nfh7sVCEFQ,38735
27
- appkit_assistant-0.15.0.dist-info/METADATA,sha256=CF3zVOvepmSBULI1nv-4BmP8eRSfbjYvtGZ4CbwMEZE,9403
28
- appkit_assistant-0.15.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
29
- appkit_assistant-0.15.0.dist-info/RECORD,,
25
+ appkit_assistant/state/thread_list_state.py,sha256=DEOR5Nklj1qfYaxSRMXCZdZRv2iq2Jb37JSg739_wL4,10250
26
+ appkit_assistant/state/thread_state.py,sha256=d7EjWQoUHh7gjW6vpsLV9n-oypRsssjdwOMyroojZLA,38656
27
+ appkit_assistant-0.15.2.dist-info/METADATA,sha256=-YYr-QtVMHNv1FPZgH4uD-zLnJalQXA0JUukohI2N-g,9403
28
+ appkit_assistant-0.15.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
29
+ appkit_assistant-0.15.2.dist-info/RECORD,,