agentle 0.9.40__py3-none-any.whl → 0.9.41__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.
@@ -77,18 +77,69 @@ class WhatsAppWebhookPayload(BaseModel):
77
77
  ForwardedFrom: str | None = Field(default=None) # For forwarded messages
78
78
  FrequentlyForwarded: str | None = Field(default=None) # "true" or "false" as string
79
79
 
80
+ # Root level fallbacks for robust extraction
81
+ remoteJid: str | None = Field(default=None)
82
+ remoteJidAlt: str | None = Field(default=None)
83
+
80
84
  def model_post_init(self, context: Any, /) -> None:
81
- if self.phone_number_id or not self.data:
85
+ if self.phone_number_id:
86
+ return
87
+
88
+ # Initialize data if missing but root fields are present
89
+ if not self.data and (self.remoteJid or self.remoteJidAlt):
90
+ # This is a bit of a hack to ensure we have a structure to hold the key
91
+ # if we only got root level JIDs
92
+ from agentle.agents.whatsapp.models.key import Key
93
+ from agentle.agents.whatsapp.models.data import Data
94
+
95
+ self.data = Data(
96
+ key=Key(
97
+ remoteJid=self.remoteJid or self.remoteJidAlt or "", fromMe=False
98
+ )
99
+ )
100
+
101
+ if not self.data:
82
102
  return
83
103
 
84
104
  key = self.data.key
85
- if "@lid" in key.remoteJid:
86
- remote_jid_alt = key.remoteJidAlt
87
- if remote_jid_alt is None:
88
- raise ValueError("No remotejidalt was provided.")
89
105
 
90
- self.phone_number_id = remote_jid_alt.split("@")[0]
91
- self.data.key.remoteJid = remote_jid_alt
106
+ # Extraction logic:
107
+ # 1. key.remoteJid
108
+ # 2. remoteJid (root)
109
+ # 3. key.remoteJidAlt
110
+ # 4. remoteJidAlt (root)
111
+
112
+ candidates = [
113
+ key.remoteJid,
114
+ self.remoteJid,
115
+ key.remoteJidAlt,
116
+ self.remoteJidAlt,
117
+ ]
118
+
119
+ # Find first valid candidate
120
+ selected_jid = next((c for c in candidates if c), None)
121
+
122
+ if not selected_jid:
123
+ # Should we raise? For now let's just return and let validation fail if strict
92
124
  return
125
+
126
+ # Optimization: treating @lid
127
+ # If the selected JID is an LID, verify if we have an ALT available
128
+ if "@lid" in selected_jid:
129
+ # If we selected a main JID that is LID, try to find an Alt
130
+ # candidates for alt: key.remoteJidAlt, self.remoteJidAlt
131
+ alt_candidates = [key.remoteJidAlt, self.remoteJidAlt]
132
+ alt_jid = next((c for c in alt_candidates if c), None)
133
+
134
+ if alt_jid:
135
+ selected_jid = alt_jid
136
+ elif not key.remoteJidAlt and not self.remoteJidAlt:
137
+ # If we have an LID but no ALT, we might be in trouble depending on the use case,
138
+ # but we proceed with what we have or raise as before
139
+ # The original code raised ValueError here
140
+ pass
93
141
 
94
- self.phone_number_id = key.remoteJid.split("@")[0]
142
+ self.phone_number_id = selected_jid.split("@")[0]
143
+
144
+ # Normalize the key inside data so the rest of the app uses the "best" JID
145
+ self.data.key.remoteJid = selected_jid
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentle
3
- Version: 0.9.40
3
+ Version: 0.9.41
4
4
  Summary: ...
5
5
  Author-email: Arthur Brenno <64020210+arthurbrenno@users.noreply.github.com>
6
6
  License-File: LICENSE
@@ -165,7 +165,7 @@ agentle/agents/whatsapp/models/whatsapp_response_base.py,sha256=IIDONx9Ipt593tAZ
165
165
  agentle/agents/whatsapp/models/whatsapp_session.py,sha256=9G1HC-A2G9jTdpwYy3w9bnYkOGK2vvA7kdYAf32oWMU,15640
166
166
  agentle/agents/whatsapp/models/whatsapp_text_message.py,sha256=GpSwFrPC4qpQlVCWKKgYjQJKNv0qvwgYfuoD3ttLzdQ,441
167
167
  agentle/agents/whatsapp/models/whatsapp_video_message.py,sha256=-d-4hnkkxyLVNoje3a1pOEAvzWqoCLFcBn70wUpnyXY,346
168
- agentle/agents/whatsapp/models/whatsapp_webhook_payload.py,sha256=aY9pnUt4WJdvrRsXZIkmR8hP7oV9gdOJ1wJiYzFhU8w,4270
168
+ agentle/agents/whatsapp/models/whatsapp_webhook_payload.py,sha256=qtLlJJ1RxHkj89bU9tFHplv9qcV_5SqIsp1GOzQFCEU,6207
169
169
  agentle/agents/whatsapp/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
170
170
  agentle/agents/whatsapp/providers/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
171
171
  agentle/agents/whatsapp/providers/base/whatsapp_provider.py,sha256=Iaywrv0xer4fhZprMttC-NP4-rRYdU_45UzIZQ7dkYA,5349
@@ -1018,7 +1018,7 @@ agentle/web/actions/scroll.py,sha256=WqVVAORNDK3BL1oASZBPmXJYeSVkPgAOmWA8ibYO82I
1018
1018
  agentle/web/actions/viewport.py,sha256=KCwm88Pri19Qc6GLHC69HsRxmdJz1gEEAODfggC_fHo,287
1019
1019
  agentle/web/actions/wait.py,sha256=IKEywjf-KC4ni9Gkkv4wgc7bY-hk7HwD4F-OFWlyf2w,571
1020
1020
  agentle/web/actions/write_text.py,sha256=9mxfHcpKs_L7BsDnJvOYHQwG8M0GWe61SRJAsKk3xQ8,748
1021
- agentle-0.9.40.dist-info/METADATA,sha256=gPlRkCIx8kIOt4O70scPrcbgMuVbGXGLjc67cW2rQeU,86879
1022
- agentle-0.9.40.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
1023
- agentle-0.9.40.dist-info/licenses/LICENSE,sha256=T90S9vqRS6qP-voULxAcvwEs558wRRo6dHuZrjgcOUI,1085
1024
- agentle-0.9.40.dist-info/RECORD,,
1021
+ agentle-0.9.41.dist-info/METADATA,sha256=AYTLK3-J2KRaGK_AwjNjyzxsUlgOJciq4GxvsPgW2wI,86879
1022
+ agentle-0.9.41.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
1023
+ agentle-0.9.41.dist-info/licenses/LICENSE,sha256=T90S9vqRS6qP-voULxAcvwEs558wRRo6dHuZrjgcOUI,1085
1024
+ agentle-0.9.41.dist-info/RECORD,,