process-gpt-agent-sdk 0.1.4__py3-none-any.whl → 0.1.6__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.

Potentially problematic release.


This version of process-gpt-agent-sdk might be problematic. Click here for more details.

@@ -9,7 +9,7 @@ from typing import Any, Optional, Dict, List
9
9
  from crewai.utilities.events import CrewAIEventsBus, ToolUsageStartedEvent, ToolUsageFinishedEvent
10
10
  from crewai.utilities.events.task_events import TaskStartedEvent, TaskCompletedEvent
11
11
 
12
- from .logger import handle_error as _err, log as _log
12
+ from .logger import handle_application_error, write_log_message
13
13
  from .context_manager import todo_id_var, proc_id_var, crew_type_var, form_id_var, form_key_var
14
14
  from ..core.database import initialize_db, get_db_client
15
15
 
@@ -23,7 +23,7 @@ class CrewAIEventLogger:
23
23
  def __init__(self):
24
24
  initialize_db()
25
25
  self.supabase = get_db_client()
26
- _log("CrewAIEventLogger 초기화 완료")
26
+ write_log_message("CrewAIEventLogger 초기화 완료")
27
27
 
28
28
  # =============================================================================
29
29
  # Job ID Generation
@@ -150,12 +150,12 @@ class CrewAIEventLogger:
150
150
  return
151
151
  except Exception as e:
152
152
  if attempt < 3:
153
- _err("이벤트저장오류(재시도)", e, raise_error=False)
153
+ handle_application_error("이벤트저장오류(재시도)", e, raise_error=False)
154
154
  # 지수 백오프: 0.3s, 0.6s
155
155
  import time
156
156
  time.sleep(0.3 * attempt)
157
157
  continue
158
- _err("이벤트저장오류(최종)", e, raise_error=False)
158
+ handle_application_error("이벤트저장오류(최종)", e, raise_error=False)
159
159
  return
160
160
 
161
161
  # =============================================================================
@@ -173,9 +173,9 @@ class CrewAIEventLogger:
173
173
  crew_type = crew_type_var.get() or "action"
174
174
  rec = self._create_event_record(etype, data, job_id, crew_type, todo_id_var.get(), proc_id_var.get())
175
175
  self._save_event(rec)
176
- _log(f"[{etype}] [{job_id[:8]}] 저장 완료")
176
+ write_log_message(f"[{etype}] [{job_id[:8]}] 저장 완료")
177
177
  except Exception as e:
178
- _err("이벤트처리오류", e, raise_error=False)
178
+ handle_application_error("이벤트처리오류", e, raise_error=False)
179
179
 
180
180
 
181
181
 
@@ -196,6 +196,6 @@ class CrewConfigManager:
196
196
  for evt in (TaskStartedEvent, TaskCompletedEvent, ToolUsageStartedEvent, ToolUsageFinishedEvent):
197
197
  bus.on(evt)(lambda source, event, logger=self.logger: logger.on_event(event, source))
198
198
  self._registered_by_pid.add(pid)
199
- _log("CrewAI event listeners 등록 완료")
199
+ write_log_message("CrewAI event listeners 등록 완료")
200
200
  except Exception as e:
201
- _err("CrewAI 이벤트 버스 등록 실패", e, raise_error=False)
201
+ handle_application_error("CrewAI 이벤트 버스 등록 실패", e, raise_error=False)
@@ -6,43 +6,61 @@ from datetime import datetime, timezone
6
6
  from typing import Any, Dict
7
7
 
8
8
  from a2a.server.events import Event
9
- from .logger import handle_error as _emit_error, log as _emit_log
9
+ from .logger import handle_application_error, write_log_message
10
10
  from ..core.database import record_event, save_task_result
11
+ from ..tools.safe_tool_loader import SafeToolLoader
11
12
 
12
13
 
13
- def _event_to_dict(event: Event) -> Dict[str, Any]:
14
+ def convert_event_to_dictionary(event: Event) -> Dict[str, Any]:
14
15
  try:
15
16
  if hasattr(event, "__dict__"):
16
17
  return {k: v for k, v in event.__dict__.items() if not k.startswith("_")}
17
18
  return {"event": str(event)}
18
19
  except Exception as e:
19
- _emit_error("event dict 변환 실패", e, raise_error=False)
20
+ handle_application_error("event dict 변환 실패", e, raise_error=False)
20
21
  return {"event": str(event)}
21
22
 
22
23
 
23
- async def route_event(todo: Dict[str, Any], event: Event) -> None:
24
+ async def process_event_message(todo: Dict[str, Any], event: Event) -> None:
24
25
  """이벤트(dict)와 출력(output)을 구분해 처리.
25
26
 
26
- - "event": CrewAI 등에서 발생한 실행 이벤트 → events 테이블 저장
27
- - "output": 실행 결과 → save_task_result 통해 중간/최종 여부에 따라 저장
27
+ - "event": 일반 이벤트 → events 테이블 저장
28
+ - "output": 실행 결과 → save_task_result 중간/최종 여부에 따라 저장
29
+ - "done": 실행 종료 신호 → 이벤트 기록 후 MCP 리소스 정리
28
30
  """
29
31
  try:
30
- data = _event_to_dict(event)
32
+ data = convert_event_to_dictionary(event)
33
+ evt_type = str(data.get("type") or data.get("event_type") or "").lower()
31
34
 
32
- # output 이벤트 처리
33
- if data.get("type") == "output" or data.get("event_type") == "output":
35
+ # done: 종료 이벤트 → 기록 후 MCP 정리
36
+ if evt_type == "done":
37
+ normalized = {
38
+ "id": str(uuid.uuid4()),
39
+ "timestamp": datetime.now(timezone.utc).isoformat(),
40
+ **data,
41
+ }
42
+ await record_event(todo, normalized, event_type="done")
43
+ try:
44
+ SafeToolLoader.shutdown_all_adapters()
45
+ write_log_message("MCP 리소스 정리 완료")
46
+ except Exception as ce:
47
+ handle_application_error("MCP 리소스 정리 실패", ce, raise_error=False)
48
+ return
49
+
50
+ # output: 결과 저장만 수행
51
+ if evt_type == "output":
34
52
  payload = data.get("data") or data.get("payload") or {}
35
53
  is_final = bool(payload.get("final") or payload.get("is_final"))
36
54
  content = payload.get("content") if isinstance(payload, dict) else payload
37
55
  await save_task_result(str(todo.get("id")), content, final=is_final)
38
56
  return
39
57
 
40
- # 일반 event 처리 (원형 + 타임스탬프)
58
+ # event: 일반 이벤트 저장
41
59
  normalized = {
42
60
  "id": str(uuid.uuid4()),
43
61
  "timestamp": datetime.now(timezone.utc).isoformat(),
44
62
  **data,
45
63
  }
46
- await record_event(todo, normalized, event_type=str(data.get("type") or data.get("event_type") or "event"))
64
+ await record_event(todo, normalized, event_type="event")
47
65
  except Exception as e:
48
- _emit_error("route_event 처리 실패", e, raise_error=False)
66
+ handle_application_error("process_event_message 처리 실패", e, raise_error=False)
@@ -11,20 +11,20 @@ if not logging.getLogger().handlers:
11
11
  format="%(asctime)s %(levelname)s %(name)s - %(message)s",
12
12
  )
13
13
 
14
- _logger = logging.getLogger("process-gpt-agent-framework")
14
+ APPLICATION_LOGGER = logging.getLogger("process-gpt-agent-framework")
15
15
 
16
16
 
17
- def log(message: str, level: int = logging.INFO) -> None:
17
+ def write_log_message(message: str, level: int = logging.INFO) -> None:
18
18
  spaced = os.getenv("LOG_SPACED", "1") != "0"
19
19
  suffix = "\n" if spaced else ""
20
- _logger.log(level, f"{message}{suffix}")
20
+ APPLICATION_LOGGER.log(level, f"{message}{suffix}")
21
21
 
22
22
 
23
- def handle_error(title: str, error: Exception, *, raise_error: bool = True, extra: Optional[Dict] = None) -> None:
23
+ def handle_application_error(title: str, error: Exception, *, raise_error: bool = True, extra: Optional[Dict] = None) -> None:
24
24
  spaced = os.getenv("LOG_SPACED", "1") != "0"
25
25
  suffix = "\n" if spaced else ""
26
26
  context = f" | extra={extra}" if extra else ""
27
- _logger.error(f"{title}: {error}{context}{suffix}")
28
- _logger.error(traceback.format_exc())
27
+ APPLICATION_LOGGER.error(f"{title}: {error}{context}{suffix}")
28
+ APPLICATION_LOGGER.error(traceback.format_exc())
29
29
  if raise_error:
30
30
  raise error
@@ -1,17 +0,0 @@
1
- processgpt_agent_sdk/__init__.py,sha256=IvAL5WBZhI83LYQogRP6-i04bxZkhmkgmES4FRQY888,185
2
- processgpt_agent_sdk/server.py,sha256=cMta6gk0NVxJSN778skGaT0cCTlpK7UKiMzER2UTRcU,8115
3
- processgpt_agent_sdk/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- processgpt_agent_sdk/core/database.py,sha256=a87Y1DLxMIm3Yu_-6LWWANnZKJgU265Nn7cKjOB1s8Y,13667
5
- processgpt_agent_sdk/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- processgpt_agent_sdk/tools/knowledge_tools.py,sha256=-IPQB6A59wMTBsZUDM-7q10IHMz30X-m_vp6RgB6yHA,8995
7
- processgpt_agent_sdk/tools/safe_tool_loader.py,sha256=a2Twnldu4VliHk41OY03lxqM91cK6-MRmjXuSHbcKqk,5647
8
- processgpt_agent_sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- processgpt_agent_sdk/utils/context_manager.py,sha256=Vqx3PUSNR_V3t7CbK6_W0xU5eb2IJPpn-YFLlfncIL4,1174
10
- processgpt_agent_sdk/utils/crewai_event_listener.py,sha256=-YIJCvrTCsS1Tz0JBqgXRcj2ziv3Pqkak_iez-pQUBI,8686
11
- processgpt_agent_sdk/utils/event_handler.py,sha256=Kga4uc4qSTywkFA0dJy699wcbogVkjbx90-psLXNnv0,1718
12
- processgpt_agent_sdk/utils/logger.py,sha256=JmA5_A1DO3oRqZpiT4ZpNrPjYGWRAR38V-aBNr4-R1c,878
13
- processgpt_agent_sdk/utils/summarizer.py,sha256=XV7e4pyKEK7NiGK_PAc1xorKSO2MKlSHCAiV7slOdus,4527
14
- process_gpt_agent_sdk-0.1.4.dist-info/METADATA,sha256=9gqChy6DknuWhMSliDzN1_n5usQFKGpUzZ0a8ezOOP8,12935
15
- process_gpt_agent_sdk-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- process_gpt_agent_sdk-0.1.4.dist-info/top_level.txt,sha256=Xe6zrj3_3Vv7d0pl5RRtenVUckwOVBVLQn2P03j5REo,21
17
- process_gpt_agent_sdk-0.1.4.dist-info/RECORD,,