paperclip-plugin-mattermost 0.14.0 → 0.15.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
@@ -17,6 +17,7 @@ Your [Paperclip](https://github.com/paperclipai/paperclip) agents as Mattermost
17
17
  - **Agents work with agents.** An agent mentioning another agent starts it, and it answers in the thread. After a set number of agent-to-agent messages in a thread (10 by default, set in settings), they pause until a person replies.
18
18
  - **Work channels.** For an investigation, incident or project, an agent opens a private channel (`inc-checkout-5xx`), pulls in the people and agents it needs, and ties it to a Paperclip task. Task comments and status changes show up in the channel. When the task is done or cancelled, the channel is archived and the outcome is posted back where the work was asked for.
19
19
  - **Ask first.** Some actions wait for an approver to click Approve: `@channel`, `@all` and `@here`, public channels, and adding people to a channel the agent didn't create. Agents can't change or archive channels they didn't create, remove anyone, or touch team and server settings.
20
+ - **Agent computer requests.** With the Agent computer plugin installed, an agent that needs a person in its browser (a login, 2FA, a password) posts in the thread it is working in, or the approvals channel, with a link to take over.
20
21
  - **One install, many companies.** Each Paperclip company connects its own Mattermost, with its own settings, bots and state.
21
22
 
22
23
  ## Requirements
@@ -82,7 +83,7 @@ PAPERCLIP_REF=<commit> node build.mjs # build for another Paperclip version
82
83
  Bump `version` in `package.json` and `src/manifest.ts`, commit, then tag and push:
83
84
 
84
85
  ```bash
85
- git tag -a v0.14.0 -m v0.14.0 && git push origin main v0.14.0
86
+ git tag -a v0.15.0 -m v0.15.0 && git push origin main v0.15.0
86
87
  ```
87
88
 
88
89
  GitHub Actions builds, tests and publishes to npm through npm trusted publishing, so no npm token is involved.
package/dist/manifest.js CHANGED
@@ -74,7 +74,7 @@ var route = (routeKey, method, path) => ({ routeKey, method, path, auth: "agent"
74
74
  var manifest = {
75
75
  id: "mattermost-bridge",
76
76
  apiVersion: 1,
77
- version: "0.14.0",
77
+ version: "0.15.0",
78
78
  displayName: "Mattermost",
79
79
  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.",
80
80
  author: "Haseeb Azhar",
package/dist/worker.js CHANGED
@@ -46211,7 +46211,7 @@ var route = (routeKey, method, path3) => ({ routeKey, method, path: path3, auth:
46211
46211
  var manifest = {
46212
46212
  id: "mattermost-bridge",
46213
46213
  apiVersion: 1,
46214
- version: "0.14.0",
46214
+ version: "0.15.0",
46215
46215
  displayName: "Mattermost",
46216
46216
  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.",
46217
46217
  author: "Haseeb Azhar",
@@ -46366,6 +46366,8 @@ var Tenant = class {
46366
46366
  work = null;
46367
46367
  key = "";
46368
46368
  approvers = /* @__PURE__ */ new Map();
46369
+ paperclipUrl = "";
46370
+ approvalsChannel = "";
46369
46371
  timers = [];
46370
46372
  agents() {
46371
46373
  const companyId = this.companyId;
@@ -46555,7 +46557,7 @@ var Tenant = class {
46555
46557
  task: async (issueId) => await ctx.issues.get(issueId, companyId),
46556
46558
  comments: async (issueId) => (await ctx.issues.listComments(issueId, companyId)).map((c) => ({ id: c.id, body: c.body, authorAgentId: c.authorAgentId }))
46557
46559
  });
46558
- Object.assign(this, { manager, bots: roster, bridge, approvals, cards, actions, work, key, approvers });
46560
+ Object.assign(this, { manager, bots: roster, bridge, approvals, cards, actions, work, key, approvers, paperclipUrl, approvalsChannel });
46559
46561
  this.status = `connecting to ${url2} as @${manager.botUsername}`;
46560
46562
  detached(() => {
46561
46563
  manager.connect(onPosted);
@@ -46602,6 +46604,17 @@ var Tenant = class {
46602
46604
  if (!this.actions) return { status: 503, body: { error: `Mattermost is not connected for this company (${this.status})` } };
46603
46605
  return this.actions.handle(agentId, routeKey, params, input2);
46604
46606
  }
46607
+ /** The Agent computer plugin: an agent wants a person in its browser. Posted where the agent is working. */
46608
+ async computerNeedsPerson(p) {
46609
+ if (!this.manager || !this.bots || !this.bridge || !p.agentId) return;
46610
+ const poster = this.poster(this.manager, this.bots);
46611
+ const where = this.bridge.activeThread(p.agentId) ?? (this.approvalsChannel ? await poster.channel(this.approvalsChannel).then((id) => id ? { channelId: id, rootId: "" } : null) : null);
46612
+ if (!where) return;
46613
+ const link = this.paperclipUrl && p.path ? `${this.paperclipUrl}${p.path}` : null;
46614
+ const on = p.url ? ` on ${p.url}` : "";
46615
+ const message2 = p.kind === "password" ? `:key: I ${p.reason ?? "need a password"}${on}. ${link ? `[Enter it here](${link})` : "Enter it from Computers in Paperclip"}: it goes straight into the page, and I never see it.` : `:raising_hand: I need a person in my browser${on}: ${p.reason ?? "I am stuck"}. ${link ? `[Take over](${link})` : "Take over from Computers in Paperclip"}, then hand it back.`;
46616
+ await poster.post(p.agentId, where, message2, { ...FROM_PAPERCLIP });
46617
+ }
46605
46618
  async notify(req, notice) {
46606
46619
  if (notice && req.user_id && req.channel_id) {
46607
46620
  await this.manager?.request("POST", "/posts/ephemeral", { user_id: req.user_id, post: { channel_id: req.channel_id, message: notice } }).catch(() => {
@@ -46742,6 +46755,9 @@ var plugin = definePlugin({
46742
46755
  ctx.events.on("issue.updated", (e) => quietly("could not follow a task update", async () => {
46743
46756
  if (e.entityId) await tenants.get(e.companyId)?.work?.updated(e.entityId);
46744
46757
  }));
46758
+ ctx.events.on("plugin.agent-computer.needs-person", (e) => quietly("could not post a computer help request", async () => {
46759
+ await tenants.get(e.companyId)?.computerNeedsPerson(e.payload ?? {});
46760
+ }));
46745
46761
  ctx.events.on("approval.decided", (e) => quietly("could not update approval", async () => {
46746
46762
  if (e.entityId) await tenants.get(e.companyId)?.approvals?.decided(e.entityId);
46747
46763
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-plugin-mattermost",
3
- "version": "0.14.0",
3
+ "version": "0.15.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",