@ronakgajjar/paperclip-plugin-gchat 0.1.4 → 0.1.5

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/worker.js CHANGED
@@ -29344,19 +29344,18 @@ function startWorkerRpcHost(options) {
29344
29344
  var plugin = definePlugin({
29345
29345
  async setup(ctx) {
29346
29346
  ctx.events.on("agent.run.finished", async (event) => {
29347
- const companyId = event.companyId;
29348
- const config2 = await ctx.config.get(companyId);
29347
+ ctx.logger.info("agent.run.finished payload", { payload: event.payload, entityId: event.entityId, entityType: event.entityType });
29348
+ const config2 = await ctx.config.get(event.companyId);
29349
29349
  const webhookUrl = config2.webhookUrl;
29350
29350
  if (!webhookUrl) return;
29351
- const agentName = event.payload?.agentName ?? "An agent";
29352
- const summary = event.payload?.summary ?? "finished a run.";
29353
- const text = `*${agentName}*: ${summary}`;
29351
+ const p = event.payload;
29352
+ const agentName = p?.agentName ?? p?.agent?.name ?? event.entityId ?? "An agent";
29353
+ const summary = p?.summary ?? p?.title ?? p?.status ?? "finished a run.";
29354
29354
  await fetch(webhookUrl, {
29355
29355
  method: "POST",
29356
29356
  headers: { "Content-Type": "application/json" },
29357
- body: JSON.stringify({ text })
29357
+ body: JSON.stringify({ text: `*${agentName}*: ${summary}` })
29358
29358
  });
29359
- ctx.logger.info("Sent Google Chat notification", { companyId });
29360
29359
  });
29361
29360
  ctx.data.register("health", async () => ({ status: "ok", checkedAt: (/* @__PURE__ */ new Date()).toISOString() }));
29362
29361
  },