langchain-trigger-server 0.1.0__tar.gz → 0.1.2__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 langchain-trigger-server might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langchain-trigger-server
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Generic event-driven triggers framework
5
5
  Project-URL: Homepage, https://github.com/langchain-ai/open-agent-platform
6
6
  Project-URL: Repository, https://github.com/langchain-ai/open-agent-platform
@@ -9,7 +9,6 @@ from typing import Any, Callable, Dict, List, Optional
9
9
  import httpx
10
10
 
11
11
  from fastapi import FastAPI, HTTPException, Request, Depends
12
- from fastapi.middleware.cors import CORSMiddleware
13
12
  from starlette.middleware.base import BaseHTTPMiddleware
14
13
  from starlette.responses import Response
15
14
 
@@ -72,8 +71,7 @@ class TriggerServer:
72
71
  def __init__(
73
72
  self,
74
73
  auth_handler: Callable,
75
- cors_origins: Optional[List[str]] = None,
76
- database: Optional[TriggerDatabaseInterface] = None,
74
+ langgraph_headers_builder: Callable,
77
75
  ):
78
76
  self.app = FastAPI(
79
77
  title="Triggers Server",
@@ -81,8 +79,9 @@ class TriggerServer:
81
79
  version="0.1.0"
82
80
  )
83
81
 
84
- self.database = database or create_database() # Default to Supabase
82
+ self.database = create_database()
85
83
  self.auth_handler = auth_handler
84
+ self.langgraph_headers_builder = langgraph_headers_builder
86
85
 
87
86
  # LangGraph configuration
88
87
  self.langgraph_api_url = os.getenv("LANGGRAPH_API_URL")
@@ -107,18 +106,6 @@ class TriggerServer:
107
106
 
108
107
  self.triggers: List[TriggerTemplate] = []
109
108
 
110
- # Setup CORS
111
- if cors_origins is None:
112
- cors_origins = ["*"] # Allow all origins by default
113
-
114
- self.app.add_middleware(
115
- CORSMiddleware,
116
- allow_origins=cors_origins,
117
- allow_credentials=True,
118
- allow_methods=["*"],
119
- allow_headers=["*"],
120
- )
121
-
122
109
  # Setup authentication middleware
123
110
  self.app.add_middleware(AuthenticationMiddleware, auth_handler=auth_handler)
124
111
 
@@ -282,7 +269,7 @@ class TriggerServer:
282
269
  except Exception as e:
283
270
  raise HTTPException(
284
271
  status_code=400,
285
- detail=f"Invalid payload for trigger {trigger_type}: {str(e)}"
272
+ detail=f"Invalid payload for trigger: {str(e)}"
286
273
  )
287
274
 
288
275
  # Call the trigger's registration handler with parsed registration model
@@ -500,7 +487,7 @@ class TriggerServer:
500
487
  )
501
488
 
502
489
  # Step 5: Call handler with parsed registration data
503
- result = await trigger.trigger_handler(payload, resource_data, auth_user, metadata_manager)
490
+ result = await trigger.trigger_handler(payload, auth_user, metadata_manager)
504
491
  registration_id = registration["id"]
505
492
 
506
493
  # Check if we should invoke agents
@@ -569,18 +556,12 @@ class TriggerServer:
569
556
  input_data: Dict[str, Any],
570
557
  ) -> Dict[str, Any]:
571
558
  """Invoke LangGraph agent directly."""
572
- headers = {
573
- "Content-Type": "application/json",
574
- "x-auth-scheme": "langchain-trigger-server-event",
575
- }
576
-
577
- # Add API key if provided
578
- if self.langgraph_api_key:
579
- headers["Authorization"] = f"Bearer {self.langgraph_api_key}"
580
-
581
- # Add user-specific headers
582
- if user_id:
583
- headers["x-supabase-user-id"] = user_id
559
+ # Build headers using the custom function
560
+ headers = await self.langgraph_headers_builder(
561
+ user_id=user_id,
562
+ api_key=self.langgraph_api_key,
563
+ agent_id=agent_id
564
+ )
584
565
 
585
566
  payload = {
586
567
  "input": input_data,
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "langchain-trigger-server"
7
- version = "0.1.0"
7
+ version = "0.1.2"
8
8
  description = "Generic event-driven triggers framework"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"