@meetopenbot/firecrawl 1.0.3 → 1.0.4
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/dist/index.js +22 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -151,6 +151,11 @@ var plugin = definePlugin({
|
|
|
151
151
|
const apiKey = getApiKey();
|
|
152
152
|
if (!apiKey) {
|
|
153
153
|
yield buildApiKeyWidget(context.agentId, threadId);
|
|
154
|
+
yield agentOutput({
|
|
155
|
+
agentId: context.agentId,
|
|
156
|
+
content: "API key required. Please provide it in the widget.",
|
|
157
|
+
threadId
|
|
158
|
+
});
|
|
154
159
|
return;
|
|
155
160
|
}
|
|
156
161
|
try {
|
|
@@ -167,6 +172,11 @@ var plugin = definePlugin({
|
|
|
167
172
|
const errMsg = started?.error || "Unknown error";
|
|
168
173
|
if (isAuthError(errMsg)) {
|
|
169
174
|
yield buildApiKeyWidget(context.agentId, threadId, errMsg);
|
|
175
|
+
yield agentOutput({
|
|
176
|
+
agentId: context.agentId,
|
|
177
|
+
content: `Authentication failed: ${errMsg}. Please update the API key in the widget.`,
|
|
178
|
+
threadId
|
|
179
|
+
});
|
|
170
180
|
} else {
|
|
171
181
|
yield agentOutput({
|
|
172
182
|
agentId: context.agentId,
|
|
@@ -178,7 +188,7 @@ var plugin = definePlugin({
|
|
|
178
188
|
}
|
|
179
189
|
yield agentOutput({
|
|
180
190
|
agentId: context.agentId,
|
|
181
|
-
content: `
|
|
191
|
+
content: `Task created (id: ${started.id}). Waiting for results...`,
|
|
182
192
|
threadId
|
|
183
193
|
});
|
|
184
194
|
const startTime = Date.now();
|
|
@@ -187,7 +197,7 @@ var plugin = definePlugin({
|
|
|
187
197
|
if (Date.now() - startTime > POLL_TIMEOUT_MS) {
|
|
188
198
|
yield agentOutput({
|
|
189
199
|
agentId: context.agentId,
|
|
190
|
-
content: `
|
|
200
|
+
content: `Timed out after ${Math.round(POLL_TIMEOUT_MS / 1e3)}s.`,
|
|
191
201
|
threadId
|
|
192
202
|
});
|
|
193
203
|
return;
|
|
@@ -200,7 +210,7 @@ var plugin = definePlugin({
|
|
|
200
210
|
if (status.status === "completed") {
|
|
201
211
|
yield agentOutput({
|
|
202
212
|
agentId: context.agentId,
|
|
203
|
-
content: "
|
|
213
|
+
content: "Completed successfully.",
|
|
204
214
|
threadId
|
|
205
215
|
});
|
|
206
216
|
yield agentOutput({
|
|
@@ -213,7 +223,7 @@ var plugin = definePlugin({
|
|
|
213
223
|
if (status.status === "failed" || status.status === "cancelled") {
|
|
214
224
|
yield agentOutput({
|
|
215
225
|
agentId: context.agentId,
|
|
216
|
-
content: `
|
|
226
|
+
content: `Agent ${status.status}: ${status.error || "no details provided"}`,
|
|
217
227
|
threadId
|
|
218
228
|
});
|
|
219
229
|
return;
|
|
@@ -232,6 +242,11 @@ var plugin = definePlugin({
|
|
|
232
242
|
const message = error instanceof Error ? error.message : "Firecrawl request failed.";
|
|
233
243
|
if (isAuthError(message)) {
|
|
234
244
|
yield buildApiKeyWidget(context.agentId, threadId, message);
|
|
245
|
+
yield agentOutput({
|
|
246
|
+
agentId: context.agentId,
|
|
247
|
+
content: `Authentication failed: ${message}. Please update the API key in the widget.`,
|
|
248
|
+
threadId
|
|
249
|
+
});
|
|
235
250
|
} else {
|
|
236
251
|
yield agentOutput({
|
|
237
252
|
agentId: context.agentId,
|
|
@@ -242,7 +257,7 @@ var plugin = definePlugin({
|
|
|
242
257
|
}
|
|
243
258
|
});
|
|
244
259
|
builder.on(
|
|
245
|
-
"
|
|
260
|
+
"client:ui:widget:response",
|
|
246
261
|
async function* (event, handlerCtx) {
|
|
247
262
|
const { metadata, values, widgetId } = event.data;
|
|
248
263
|
if (!metadata || metadata.type !== "api_key_request" || metadata.source !== "firecrawl") {
|
|
@@ -270,14 +285,14 @@ var plugin = definePlugin({
|
|
|
270
285
|
});
|
|
271
286
|
yield agentOutput({
|
|
272
287
|
agentId: context.agentId,
|
|
273
|
-
content: "
|
|
288
|
+
content: "API key saved to workspace variables. Re-send your last message to retry.",
|
|
274
289
|
meta: { agentId: handlerCtx.state.agentId }
|
|
275
290
|
});
|
|
276
291
|
} catch (error) {
|
|
277
292
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
278
293
|
yield agentOutput({
|
|
279
294
|
agentId: context.agentId,
|
|
280
|
-
content: `
|
|
295
|
+
content: `Failed to save API key: ${errorMessage}`,
|
|
281
296
|
meta: { agentId: handlerCtx.state.agentId }
|
|
282
297
|
});
|
|
283
298
|
}
|