social-agent-cli 2.3.0 → 2.3.2
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/ai/runner.ts +19 -13
- package/package.json +1 -1
package/ai/runner.ts
CHANGED
|
@@ -175,23 +175,29 @@ async function executeStep(page: any, step: any, post: Post, params: Record<stri
|
|
|
175
175
|
const filePath = rp(step.value || "{{IMAGE}}");
|
|
176
176
|
if (!filePath || filePath.includes("{{")) break;
|
|
177
177
|
|
|
178
|
-
// 1.
|
|
179
|
-
for (const sel of selectors) {
|
|
180
|
-
try {
|
|
181
|
-
const fcp = page.waitForEvent("filechooser", { timeout: 5000 });
|
|
182
|
-
await page.click(sel).catch(() => {});
|
|
183
|
-
const fc = await fcp;
|
|
184
|
-
await fc.setFiles(filePath);
|
|
185
|
-
return;
|
|
186
|
-
} catch {}
|
|
187
|
-
}
|
|
188
|
-
// 2. input[type=file] direkt
|
|
178
|
+
// 1. input[type=file] direkt (file picker açmaz)
|
|
189
179
|
try {
|
|
190
180
|
const inputs = await page.locator('input[type="file"]').all();
|
|
191
|
-
for (const
|
|
192
|
-
try { await
|
|
181
|
+
for (const inp of inputs) {
|
|
182
|
+
try { await inp.setInputFiles(filePath); return; } catch {}
|
|
193
183
|
}
|
|
194
184
|
} catch {}
|
|
185
|
+
|
|
186
|
+
// 2. fileChooser event listener ile butona tıkla
|
|
187
|
+
for (const sel of selectors) {
|
|
188
|
+
let done = false;
|
|
189
|
+
const handler = async (fc: any) => { await fc.setFiles(filePath); done = true; };
|
|
190
|
+
page.on("filechooser", handler);
|
|
191
|
+
try {
|
|
192
|
+
await page.click(sel);
|
|
193
|
+
// fileChooser event'inin tetiklenmesini bekle
|
|
194
|
+
for (let w = 0; w < 20 && !done; w++) await page.waitForTimeout(250);
|
|
195
|
+
page.removeListener("filechooser", handler);
|
|
196
|
+
if (done) return;
|
|
197
|
+
} catch {
|
|
198
|
+
page.removeListener("filechooser", handler);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
195
201
|
throw new Error(`Upload: ${filePath}`);
|
|
196
202
|
}
|
|
197
203
|
}
|