paperclip-plugin-mattermost 0.11.0 → 0.11.2

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
@@ -74,6 +74,16 @@ PAPERCLIP_REF=<commit> node build.mjs # build for another Paperclip version
74
74
  - `scripts/deploy-remote.sh` copies a build to a Paperclip running in Docker on another machine over ssh, and reloads it with Paperclip's CLI.
75
75
  - `test/live-mattermost.ts` and `test/live-roster.ts` run against a real Mattermost.
76
76
 
77
+ ## Releasing
78
+
79
+ Bump `version` in `package.json` and `src/manifest.ts`, commit, then tag and push:
80
+
81
+ ```bash
82
+ git tag v0.12.0 && git push origin main v0.12.0
83
+ ```
84
+
85
+ GitHub Actions builds, tests and publishes to npm through npm trusted publishing, so no npm token is involved.
86
+
77
87
  ## License
78
88
 
79
89
  MIT
package/dist/manifest.js CHANGED
@@ -2,7 +2,7 @@
2
2
  var manifest = {
3
3
  id: "mattermost-bridge",
4
4
  apiVersion: 1,
5
- version: "0.11.0",
5
+ version: "0.11.2",
6
6
  displayName: "Mattermost",
7
7
  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.",
8
8
  author: "Haseeb Azhar",
package/dist/ui/index.js CHANGED
@@ -122,6 +122,37 @@ function AccessList({ members, agents, grants, accounts, onChange }) {
122
122
  ] })
123
123
  ] });
124
124
  }
125
+ function TokenHelp({ mattermostUrl }) {
126
+ const base = /^https?:\/\/\S+/.test(mattermostUrl.trim()) ? mattermostUrl.trim().replace(/\/+$/, "") : null;
127
+ const page = (path, label) => base ? /* @__PURE__ */ jsx("a", { href: `${base}${path}`, target: "_blank", rel: "noreferrer", children: label }) : /* @__PURE__ */ jsx("b", { children: label });
128
+ return /* @__PURE__ */ jsxs("details", { style: { marginTop: 8 }, children: [
129
+ /* @__PURE__ */ jsx("summary", { style: { cursor: "pointer", opacity: 0.9 }, children: "Don't see Personal Access Tokens?" }),
130
+ /* @__PURE__ */ jsxs("ol", { style: { margin: "8px 0 0", paddingLeft: 20, lineHeight: 1.6 }, children: [
131
+ /* @__PURE__ */ jsx("li", { children: "Sign in to Mattermost as a System Admin." }),
132
+ /* @__PURE__ */ jsxs("li", { children: [
133
+ "System Console \u2192 Integrations \u2192 ",
134
+ page("/admin_console/integrations/integration_management", "Integration Management"),
135
+ ": set ",
136
+ /* @__PURE__ */ jsx("b", { children: "Enable Personal Access Tokens" }),
137
+ " to true and save."
138
+ ] }),
139
+ /* @__PURE__ */ jsxs("li", { children: [
140
+ "System Console \u2192 Integrations \u2192 ",
141
+ page("/admin_console/integrations/bot_accounts", "Bot Accounts"),
142
+ ": make sure ",
143
+ /* @__PURE__ */ jsx("b", { children: "Enable Bot Account Creation" }),
144
+ " is true."
145
+ ] }),
146
+ /* @__PURE__ */ jsxs("li", { children: [
147
+ "Back in Mattermost: Profile \u2192 Security \u2192 ",
148
+ /* @__PURE__ */ jsx("b", { children: "Personal Access Tokens" }),
149
+ " \u2192 Create Token, and copy it."
150
+ ] }),
151
+ /* @__PURE__ */ jsx("li", { children: "In Paperclip: Settings \u2192 Secrets \u2192 add a secret with that token, then choose it above." })
152
+ ] }),
153
+ /* @__PURE__ */ jsx("div", { style: { marginTop: 6 }, children: "Still missing after step 2? The account you are signed in with is not a System Admin." })
154
+ ] });
155
+ }
125
156
  function validate(c) {
126
157
  const errors = {};
127
158
  const url = String(c.mattermostUrl ?? "").trim();
@@ -268,7 +299,10 @@ function SettingsPage({ context }) {
268
299
  ] }) : null
269
300
  ] }),
270
301
  /* @__PURE__ */ jsx(Field, { label: "Mattermost URL", error: fieldErrors.mattermostUrl, help: "Your Mattermost address, for example https://chat.example.com", children: /* @__PURE__ */ jsx("input", { style: s.input, value: String(config.mattermostUrl ?? ""), onChange: (e) => set({ mattermostUrl: e.target.value }), placeholder: "https://chat.example.com" }) }),
271
- /* @__PURE__ */ jsx(Field, { label: "Mattermost admin token", error: fieldErrors.botToken, help: "A Paperclip secret holding a personal access token of a Mattermost System Admin (Profile \u2192 Security \u2192 Personal Access Tokens). It creates one bot per agent and keeps them in sync.", children: /* @__PURE__ */ jsxs("select", { style: s.input, value: token?.secretId ?? "", onChange: (e) => set({ botToken: e.target.value ? { type: "secret_ref", version: "latest", secretId: e.target.value } : void 0 }), children: [
302
+ /* @__PURE__ */ jsx(Field, { label: "Mattermost admin token", error: fieldErrors.botToken, help: /* @__PURE__ */ jsxs(Fragment, { children: [
303
+ "A Paperclip secret holding a personal access token of a Mattermost System Admin (Profile \u2192 Security \u2192 Personal Access Tokens). It creates one bot per agent and keeps them in sync.",
304
+ /* @__PURE__ */ jsx(TokenHelp, { mattermostUrl: String(config.mattermostUrl ?? "") })
305
+ ] }), children: /* @__PURE__ */ jsxs("select", { style: s.input, value: token?.secretId ?? "", onChange: (e) => set({ botToken: e.target.value ? { type: "secret_ref", version: "latest", secretId: e.target.value } : void 0 }), children: [
272
306
  /* @__PURE__ */ jsx("option", { value: "", children: "Choose a secret\u2026" }),
273
307
  secrets.map((x) => /* @__PURE__ */ jsx("option", { value: x.id, children: x.name || x.key || x.id }, x.id))
274
308
  ] }) }),
package/dist/worker.js CHANGED
@@ -45683,7 +45683,7 @@ var AgentBots = class {
45683
45683
  var manifest = {
45684
45684
  id: "mattermost-bridge",
45685
45685
  apiVersion: 1,
45686
- version: "0.11.0",
45686
+ version: "0.11.2",
45687
45687
  displayName: "Mattermost",
45688
45688
  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.",
45689
45689
  author: "Haseeb Azhar",
@@ -45875,12 +45875,19 @@ var Tenant = class {
45875
45875
  await manager.request("PUT", `/posts/${postId}/patch`, { message: message2, props: this.tag(props) });
45876
45876
  },
45877
45877
  async channel(name) {
45878
- for (const team of await manager.request("GET", "/users/me/teams")) {
45878
+ const wanted = name.replace(/^[#~]/, "").trim();
45879
+ const teams = await manager.request("GET", "/users/me/teams");
45880
+ for (const team of teams) {
45879
45881
  try {
45880
- return (await manager.request("GET", `/teams/${team.id}/channels/name/${encodeURIComponent(name.replace(/^[#~]/, ""))}`)).id;
45882
+ return (await manager.request("GET", `/teams/${team.id}/channels/name/${encodeURIComponent(wanted.toLowerCase())}`)).id;
45881
45883
  } catch {
45882
45884
  }
45883
45885
  }
45886
+ for (const team of teams) {
45887
+ const list = await manager.request("GET", `/teams/${team.id}/channels?per_page=200`).catch(() => []);
45888
+ const hit = list.find((ch) => ch.display_name.trim().toLowerCase() === wanted.toLowerCase());
45889
+ if (hit) return hit.id;
45890
+ }
45884
45891
  return null;
45885
45892
  },
45886
45893
  async email(userId) {
@@ -46044,6 +46051,9 @@ async function saveBoot(companyId, config2) {
46044
46051
  await ctx.state.set(BOOT, all);
46045
46052
  }
46046
46053
  var plugin = definePlugin({
46054
+ // One worker serves every company, each with its own Mattermost (Tenant above).
46055
+ // Without this Paperclip refuses a second company's settings as a cross-tenant risk.
46056
+ multiCompanyConfig: true,
46047
46057
  async setup(c) {
46048
46058
  ctx = c;
46049
46059
  ctx.data.register("setup", async (params) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-plugin-mattermost",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
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",