agents-relay 1.0.12 → 1.0.14
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.
package/package.json
CHANGED
|
@@ -55,6 +55,15 @@ def _composer_text(selector):
|
|
|
55
55
|
}})()""") or ""
|
|
56
56
|
|
|
57
57
|
|
|
58
|
+
def _same_text(observed, expected):
|
|
59
|
+
normalize = lambda value: re.sub(r"\\s+", " ", value or "").strip()
|
|
60
|
+
return normalize(expected) in normalize(observed)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _normalized_text(value):
|
|
64
|
+
return re.sub(r"\s+", " ", value or "").strip()
|
|
65
|
+
|
|
66
|
+
|
|
58
67
|
def _attachment_names():
|
|
59
68
|
return js(r"""(() => [...document.querySelectorAll('button[aria-label^="Remove file"]')]
|
|
60
69
|
.map(b => (b.getAttribute('aria-label') || '').replace(/^Remove file\s+\d+:\s*/, ''))
|
|
@@ -104,7 +113,7 @@ def _wait_user_turn(before_count, prompt, timeout=20):
|
|
|
104
113
|
deadline = time.time() + timeout
|
|
105
114
|
while time.time() < deadline:
|
|
106
115
|
turns = _user_turns()
|
|
107
|
-
if len(turns) > before_count and prompt
|
|
116
|
+
if len(turns) > before_count and _normalized_text(prompt) in _normalized_text(turns[-1]["text"]):
|
|
108
117
|
return turns[-1]
|
|
109
118
|
time.sleep(.25)
|
|
110
119
|
raise RuntimeError("Temporary Chat prompt did not become an observed user turn")
|
|
@@ -145,7 +154,7 @@ attachments = _upload_files(CFG.get("file", []))
|
|
|
145
154
|
selector = _composer()
|
|
146
155
|
before_count = len(_user_turns())
|
|
147
156
|
fill_input(selector, CFG["prompt"], clear_first=True)
|
|
148
|
-
if CFG["prompt"]
|
|
157
|
+
if not _same_text(_composer_text(selector), CFG["prompt"]):
|
|
149
158
|
info = js(f"""(() => {{
|
|
150
159
|
const e=document.querySelector({json.dumps(selector)});
|
|
151
160
|
const r=e.getBoundingClientRect();
|
|
@@ -154,7 +163,7 @@ if CFG["prompt"].strip() not in _composer_text(selector):
|
|
|
154
163
|
click_at_xy(info["x"], info["y"])
|
|
155
164
|
press_key("CTRL+A")
|
|
156
165
|
type_text(CFG["prompt"])
|
|
157
|
-
if CFG["prompt"]
|
|
166
|
+
if _normalized_text(CFG["prompt"]) not in _normalized_text(_composer_text(selector)):
|
|
158
167
|
raise RuntimeError("Temporary Chat prompt was not observed in the composer")
|
|
159
168
|
|
|
160
169
|
_click_send()
|