@ronakgajjar/paperclip-plugin-gchat 0.1.8 → 0.1.9

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
@@ -29343,46 +29343,20 @@ function startWorkerRpcHost(options) {
29343
29343
  // src/worker.ts
29344
29344
  var plugin = definePlugin({
29345
29345
  async setup(ctx) {
29346
- ctx.events.on("agent.run.finished", async (event) => {
29346
+ ctx.events.on("issue.comment.created", async (event) => {
29347
+ const p = event.payload;
29348
+ if (event.actorType !== "agent") return;
29347
29349
  const config2 = await ctx.config.get(event.companyId);
29348
29350
  const webhookUrl = config2.webhookUrl;
29349
29351
  if (!webhookUrl) return;
29350
- const p = event.payload;
29351
- let agentName = "An agent";
29352
- try {
29353
- if (event.entityId) {
29354
- const agent = await ctx.agents.get(event.entityId, event.companyId);
29355
- if (agent?.name) agentName = agent.name;
29356
- }
29357
- } catch {
29358
- }
29359
- const status = p?.status ?? "finished a run";
29360
- const taskId = p?.issueId ?? p?.taskId;
29361
- let taskTitle;
29362
- let reportBody;
29363
- if (taskId) {
29364
- try {
29365
- const issue2 = await ctx.issues.get(taskId, event.companyId);
29366
- taskTitle = issue2?.title;
29367
- } catch {
29368
- }
29369
- try {
29370
- const docs = await ctx.issues.documents.list(taskId, event.companyId);
29371
- if (docs.length > 0) {
29372
- const latest = docs[docs.length - 1];
29373
- const full = await ctx.issues.documents.get(taskId, latest.key, event.companyId);
29374
- reportBody = full?.body;
29375
- }
29376
- } catch {
29377
- }
29378
- }
29379
- let text = taskTitle ? `*${agentName}* ${status}: ${taskTitle}` : `*${agentName}* ${status}.`;
29380
- if (reportBody) {
29381
- const trimmed = reportBody.length > 3500 ? reportBody.slice(0, 3500) + "\n...(truncated)" : reportBody;
29382
- text += `
29352
+ const body = p?.body ?? "";
29353
+ if (!body || body.length < 50) return;
29354
+ const issue2 = event.entityId ? await ctx.issues.get(event.entityId, event.companyId).catch(() => null) : null;
29355
+ const title = issue2?.title ?? "Update";
29356
+ const trimmed = body.length > 3500 ? body.slice(0, 3500) + "\n...(truncated)" : body;
29357
+ const text = `*${title}*
29383
29358
 
29384
29359
  ${trimmed}`;
29385
- }
29386
29360
  await fetch(webhookUrl, {
29387
29361
  method: "POST",
29388
29362
  headers: { "Content-Type": "application/json" },