paperclip-plugin-mattermost 0.16.1 → 0.17.0

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/README.md CHANGED
@@ -84,7 +84,7 @@ PAPERCLIP_REF=<commit> node build.mjs # build for another Paperclip version
84
84
  Bump `version` in `package.json` and `src/manifest.ts`, commit, then tag and push:
85
85
 
86
86
  ```bash
87
- git tag -a v0.16.1 -m v0.16.1 && git push origin main v0.16.1
87
+ git tag -a v0.17.0 -m v0.17.0 && git push origin main v0.17.0
88
88
  ```
89
89
 
90
90
  GitHub Actions builds, tests and publishes to npm through npm trusted publishing, so no npm token is involved.
package/dist/manifest.js CHANGED
@@ -82,13 +82,14 @@ var route = (routeKey, method, path) => ({ routeKey, method, path, auth: "agent"
82
82
  var manifest = {
83
83
  id: "mattermost-bridge",
84
84
  apiVersion: 1,
85
- version: "0.16.1",
85
+ version: "0.17.0",
86
86
  displayName: "Mattermost",
87
87
  description: "Every agent becomes its own Mattermost bot. DM an agent or mention it in a channel and it answers in the thread, showing its steps as it works; follow-ups continue the conversation. Paperclip approvals arrive with Approve / Reject buttons.",
88
88
  author: "Haseeb Azhar",
89
89
  categories: ["connector"],
90
90
  capabilities: [
91
91
  "agents.read",
92
+ "companies.read",
92
93
  "agent.sessions.create",
93
94
  "agent.sessions.send",
94
95
  "agent.sessions.list",
package/dist/worker.js CHANGED
@@ -45192,7 +45192,7 @@ var Actions = class {
45192
45192
  return ok(await this.doPost(bot, ch.id, threadId, text2));
45193
45193
  }
45194
45194
  async doPost(bot, channelId, threadId, text2) {
45195
- const p = await bot.request("POST", "/posts", { channel_id: channelId, root_id: threadId, message: text2 });
45195
+ const p = await bot.request("POST", "/posts", { channel_id: channelId, root_id: threadId, message: this.d.format ? this.d.format(text2) : text2 });
45196
45196
  return { posted: p.id, threadId: p.root_id || p.id };
45197
45197
  }
45198
45198
  async react(bot, input2) {
@@ -45529,6 +45529,13 @@ function absoluteLinks(text2, base) {
45529
45529
  const root = base.replace(/\/+$/, "");
45530
45530
  return text2.replace(/\]\((\/(?!\/)[^)\s]*)\)/g, (_m, path3) => `](${root}${path3})`);
45531
45531
  }
45532
+ function linkTasks(text2, base, prefix) {
45533
+ if (!base || !/^[A-Z][A-Z0-9]{0,15}$/.test(prefix)) return text2;
45534
+ const root = base.replace(/\/+$/, "");
45535
+ const skip = /(```[\s\S]*?```|`[^`\n]*`|\[[^\]]*\]\([^)]*\)|<[^>\s]+>|https?:\/\/[^\s)]+)/;
45536
+ const id = new RegExp(`(?<![\\w/-])(${prefix}-\\d+)(?![\\w-])`, "g");
45537
+ return text2.split(skip).map((part, i) => i % 2 ? part : part.replace(id, (m) => `[${m}](${root}/${prefix}/issues/${m})`)).join("");
45538
+ }
45532
45539
  function splitMessage(text2, max = MAX_POST) {
45533
45540
  const parts = [];
45534
45541
  let rest = text2;
@@ -45554,8 +45561,9 @@ var Bridge = class {
45554
45561
  choiceButtons;
45555
45562
  canTalk;
45556
45563
  turnLimit;
45557
- /** Paperclip's public URL, for agents' relative links. */
45564
+ /** Paperclip's public URL, for agents' relative links, and the company's task prefix (BAD). */
45558
45565
  linkBase = "";
45566
+ taskPrefix = "";
45559
45567
  /**
45560
45568
  * Steering: messages people send in a thread while its agent is mid-run, kept for that agent to
45561
45569
  * read in the same run (`takeInbox`). One it read is not run again afterwards.
@@ -45777,7 +45785,7 @@ To send files back with your reply, save them in ${outbox}` : "");
45777
45785
  }
45778
45786
  if (this.active.get(member.agentId) === here) this.active.delete(member.agentId);
45779
45787
  this.inbox.delete(member.agentId);
45780
- const { text: body, choices } = extractChoices(absoluteLinks(reply ?? "", this.linkBase));
45788
+ const { text: body, choices } = extractChoices(linkTasks(absoluteLinks(reply ?? "", this.linkBase), this.linkBase, this.taskPrefix));
45781
45789
  const origin = { channelId: post.channel_id, rootId, channelType: evt.channelType, channelName: evt.channelName };
45782
45790
  const buttons = choices.length && this.choiceButtons ? this.choiceButtons(origin, choices) : null;
45783
45791
  const shown = choices.length && !buttons ? `${body}
@@ -46275,13 +46283,14 @@ var route = (routeKey, method, path3) => ({ routeKey, method, path: path3, auth:
46275
46283
  var manifest = {
46276
46284
  id: "mattermost-bridge",
46277
46285
  apiVersion: 1,
46278
- version: "0.16.1",
46286
+ version: "0.17.0",
46279
46287
  displayName: "Mattermost",
46280
46288
  description: "Every agent becomes its own Mattermost bot. DM an agent or mention it in a channel and it answers in the thread, showing its steps as it works; follow-ups continue the conversation. Paperclip approvals arrive with Approve / Reject buttons.",
46281
46289
  author: "Haseeb Azhar",
46282
46290
  categories: ["connector"],
46283
46291
  capabilities: [
46284
46292
  "agents.read",
46293
+ "companies.read",
46285
46294
  "agent.sessions.create",
46286
46295
  "agent.sessions.send",
46287
46296
  "agent.sessions.list",
@@ -46555,6 +46564,8 @@ var Tenant = class {
46555
46564
  void bridge.handle(evt);
46556
46565
  };
46557
46566
  bridge.linkBase = paperclipUrl;
46567
+ const company = await ctx.companies.get(companyId).catch(() => null);
46568
+ bridge.taskPrefix = company?.issuePrefix ?? "";
46558
46569
  bridge.onSteer = (agentId, postId) => {
46559
46570
  void ctx.events.emit("person-wrote", companyId, { agentId, postId }).catch(() => {
46560
46571
  });
@@ -46601,6 +46612,7 @@ var Tenant = class {
46601
46612
  agents: () => roster.all().map((m) => ({ agentId: m.agentId, agentName: m.agentName, username: m.username, botUserId: m.botUserId })),
46602
46613
  canTalk: async (userId, agentId) => !canTalk || canTalk(userId, agentId),
46603
46614
  origin: (agentId) => bridge.activeThread(agentId),
46615
+ format: (text2) => linkTasks(absoluteLinks(text2, paperclipUrl), paperclipUrl, bridge.taskPrefix),
46604
46616
  // The task this run works on (its execution or checkout run), and the thread it was asked for in.
46605
46617
  taskThread: async (agentId, runId, channelId) => {
46606
46618
  if (!runId) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-plugin-mattermost",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "description": "Paperclip agents in Mattermost: a bot per agent, live progress, files, approval and decision buttons, and per-person access, for each Paperclip company.",
5
5
  "type": "module",
6
6
  "license": "MIT",