process-gpt-agent-sdk 0.2.4__tar.gz → 0.2.6__tar.gz

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.

Files changed (25) hide show
  1. {process_gpt_agent_sdk-0.2.4/process_gpt_agent_sdk.egg-info → process_gpt_agent_sdk-0.2.6}/PKG-INFO +1 -1
  2. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6/process_gpt_agent_sdk.egg-info}/PKG-INFO +1 -1
  3. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/core/database.py +3 -13
  4. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/server.py +22 -5
  5. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/utils/event_handler.py +14 -5
  6. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/utils/summarizer.py +2 -2
  7. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/pyproject.toml +1 -1
  8. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/MANIFEST.in +0 -0
  9. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/README.md +0 -0
  10. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/function.sql +0 -0
  11. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/process_gpt_agent_sdk.egg-info/SOURCES.txt +0 -0
  12. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/process_gpt_agent_sdk.egg-info/dependency_links.txt +0 -0
  13. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/process_gpt_agent_sdk.egg-info/requires.txt +0 -0
  14. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/process_gpt_agent_sdk.egg-info/top_level.txt +0 -0
  15. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/__init__.py +0 -0
  16. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/core/__init__.py +0 -0
  17. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/tools/__init__.py +0 -0
  18. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/tools/human_query_tool.py +0 -0
  19. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/tools/knowledge_tools.py +0 -0
  20. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/tools/safe_tool_loader.py +0 -0
  21. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/utils/__init__.py +0 -0
  22. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/utils/context_manager.py +0 -0
  23. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/utils/crewai_event_listener.py +0 -0
  24. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/processgpt_agent_sdk/utils/logger.py +0 -0
  25. {process_gpt_agent_sdk-0.2.4 → process_gpt_agent_sdk-0.2.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: process-gpt-agent-sdk
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: Supabase 기반 이벤트/작업 폴링으로 A2A AgentExecutor를 실행하는 SDK
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/your-org/process-gpt-agent-sdk
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: process-gpt-agent-sdk
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: Supabase 기반 이벤트/작업 폴링으로 A2A AgentExecutor를 실행하는 SDK
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/your-org/process-gpt-agent-sdk
@@ -142,7 +142,7 @@ async def fetch_done_data(proc_inst_id: Optional[str]) -> List[Any]:
142
142
  resp = await _async_retry(_call, name="fetch_done_data", fallback=lambda: None)
143
143
  if not resp:
144
144
  return []
145
- return [row.get("output") for row in (resp.data or [])]
145
+ return [row.get("output") for row in (resp.data or []) if row.get("output")]
146
146
 
147
147
 
148
148
  def fetch_human_response_sync(job_id: str) -> Optional[Dict[str, Any]]:
@@ -359,20 +359,10 @@ async def fetch_human_users_by_proc_inst_id(proc_inst_id: str) -> str:
359
359
  # 데이터 저장
360
360
  # 설명: 이벤트/알림/작업 결과 저장
361
361
  # ============================================================================
362
- async def record_event(todo: Dict[str, Any], data: Dict[str, Any], event_type: Optional[str] = None) -> None:
363
- """UI용 events 테이블에 이벤트 기록"""
362
+ async def record_event(payload: Dict[str, Any]) -> None:
363
+ """UI용 events 테이블에 이벤트 기록 (전달된 payload 그대로 저장)"""
364
364
  def _call():
365
365
  client = get_db_client()
366
- payload: Dict[str, Any] = {
367
- "id": str(uuid.uuid4()),
368
- "job_id": todo.get("proc_inst_id") or str(todo.get("id")),
369
- "todo_id": str(todo.get("id")),
370
- "proc_inst_id": todo.get("proc_inst_id"),
371
- "crew_type": todo.get("agent_orch"),
372
- "data": data,
373
- }
374
- if event_type is not None:
375
- payload["event_type"] = event_type
376
366
  return client.table("events").insert(payload).execute()
377
367
 
378
368
  resp = await _async_retry(_call, name="record_event", fallback=lambda: None)
@@ -114,6 +114,7 @@ class ProcessGPTAgentServer:
114
114
  "agent_list": agent_list or [],
115
115
  "mcp_config": mcp_config,
116
116
  "form_id": form_id,
117
+ "todo_id": str(task_record.get("id")),
117
118
  "form_types": form_types or [],
118
119
  "form_html": form_html or "",
119
120
  "activity_name": str(task_record.get("activity_name", "")),
@@ -132,7 +133,8 @@ class ProcessGPTAgentServer:
132
133
  executor = self._executor
133
134
 
134
135
  context = ProcessGPTRequestContext(prepared_data)
135
- event_queue = ProcessGPTEventQueue(task_record)
136
+ loop = asyncio.get_running_loop()
137
+ event_queue = ProcessGPTEventQueue(task_record, loop=loop)
136
138
 
137
139
  try:
138
140
  set_context(
@@ -234,9 +236,10 @@ class ProcessGPTRequestContext(RequestContext):
234
236
  # 설명: 실행기 이벤트를 내부 큐에 넣고, 비동기 처리 태스크를 생성해 저장 로직 호출
235
237
  # =============================================================================
236
238
  class ProcessGPTEventQueue(EventQueue):
237
- def __init__(self, task_record: Dict[str, Any]):
239
+ def __init__(self, task_record: Dict[str, Any], loop: asyncio.AbstractEventLoop | None = None):
238
240
  """현재 처리 중인 작업 레코드를 보관한다."""
239
241
  self.todo = task_record
242
+ self._loop = loop
240
243
  super().__init__()
241
244
 
242
245
  def enqueue_event(self, event: Event):
@@ -263,13 +266,27 @@ class ProcessGPTEventQueue(EventQueue):
263
266
  pass
264
267
 
265
268
  def _create_bg_task(self, coro: Any, label: str) -> None:
266
- """백그라운드 태스크 생성 및 완료 콜백으로 예외 로깅."""
269
+ """백그라운드 태스크 생성 및 완료 콜백으로 예외 로깅.
270
+
271
+ - 실행 중인 이벤트 루프가 없을 때도 전달된 루프에 안전하게 예약한다.
272
+ """
267
273
  try:
268
- task = asyncio.create_task(coro)
274
+ loop = self._loop
275
+ if loop is None:
276
+ try:
277
+ loop = asyncio.get_running_loop()
278
+ except RuntimeError:
279
+ raise
280
+
269
281
  def _cb(t: asyncio.Task):
270
282
  exc = t.exception()
271
283
  if exc:
272
284
  handle_application_error(f"백그라운드 태스크 오류({label})", exc, raise_error=False)
273
- task.add_done_callback(_cb)
285
+
286
+ def _schedule():
287
+ task = loop.create_task(coro)
288
+ task.add_done_callback(_cb)
289
+
290
+ loop.call_soon_threadsafe(_schedule)
274
291
  except Exception as e:
275
292
  handle_application_error(f"백그라운드 태스크 생성 실패({label})", e, raise_error=False)
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from typing import Any, Dict
4
+ import uuid
4
5
 
5
6
  from a2a.server.events import Event
6
7
  from .logger import handle_application_error, write_log_message
@@ -40,8 +41,10 @@ async def process_event_message(todo: Dict[str, Any], event: Event) -> None:
40
41
 
41
42
  # done: 종료 이벤트 → 기록 후 MCP 정리
42
43
  if evt_type == "done":
43
- # 워커에서 전달한 데이터를 그대로 보존해 기록
44
- await record_event(todo, data, event_type="done")
44
+ payload = data.get("data") or {}
45
+ if isinstance(payload, dict) and "id" not in payload:
46
+ payload["id"] = str(uuid.uuid4())
47
+ await record_event(payload)
45
48
  try:
46
49
  SafeToolLoader.shutdown_all_adapters()
47
50
  write_log_message("MCP 리소스 정리 완료")
@@ -53,11 +56,17 @@ async def process_event_message(todo: Dict[str, Any], event: Event) -> None:
53
56
  if evt_type == "output":
54
57
  payload = data.get("data") or {}
55
58
  is_final = bool(payload.get("final") or payload.get("is_final")) if isinstance(payload, dict) else False
56
- content = payload.get("content") if isinstance(payload, dict) else payload
59
+ content = payload.get("content") or payload.get("data") if isinstance(payload, dict) else payload
57
60
  await save_task_result(str(todo.get("id")), content, final=is_final)
58
61
  return
62
+
63
+ # event : 일반 이벤트 저장 (워커 데이터 그대로 보존)
64
+ if evt_type == "event":
65
+ payload = data.get("data") or {}
66
+ if isinstance(payload, dict) and "id" not in payload:
67
+ payload["id"] = str(uuid.uuid4())
68
+ await record_event(payload)
69
+ return
59
70
 
60
- # event: 일반 이벤트 저장 (워커 데이터 그대로 보존)
61
- await record_event(todo, data, event_type="event")
62
71
  except Exception as e:
63
72
  handle_application_error("process_event_message 처리 실패", e, raise_error=False)
@@ -24,12 +24,12 @@ async def summarize_async(outputs: Any, feedbacks: Any, contents: Any = None) ->
24
24
  output_summary = ""
25
25
  feedback_summary = ""
26
26
 
27
- if outputs_str:
27
+ if outputs_str and outputs_str not in ("[]", "{}", "[{}]"):
28
28
  write_log_message("요약 호출(이전결과물)")
29
29
  output_prompt = _create_output_summary_prompt(outputs_str)
30
30
  output_summary = await _call_openai_api_async(output_prompt, task_name="output")
31
31
 
32
- if feedbacks_str or contents_str:
32
+ if feedbacks_str and feedbacks_str not in ("[]", "{}"):
33
33
  write_log_message("요약 호출(피드백)")
34
34
  feedback_prompt = _create_feedback_summary_prompt(feedbacks_str, contents_str)
35
35
  feedback_summary = await _call_openai_api_async(feedback_prompt, task_name="feedback")
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "process-gpt-agent-sdk"
7
- version = "0.2.4"
7
+ version = "0.2.6"
8
8
  description = "Supabase 기반 이벤트/작업 폴링으로 A2A AgentExecutor를 실행하는 SDK"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"