@nanocollective/roster 0.1.0-beta.24 → 0.1.0-beta.25

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.
@@ -114,7 +114,19 @@ other key.
114
114
 
115
115
  ## A service that is not in the catalogue
116
116
 
117
- Write it out in `org.yaml`, with a `url` or a `command`, and the names of the keys it needs:
117
+ On the Connectors screen, pick **Custom server** and give it a name and its MCP URL (https).
118
+ Then choose how it signs in:
119
+
120
+ - **Key**: a header name (`Authorization` unless you change it) and its value, for example
121
+ `Bearer sk_…`. The value is stored as the secret `CONNECTOR_<NAME>_TOKEN`.
122
+ - **Sign in**: on the hosted portal, for a server that signs in with a browser the way Notion
123
+ does. It has to let a new app register itself, as MCP servers that sign in usually do.
124
+ - **No key**: for a server that needs none.
125
+
126
+ Read only cannot be enforced on a server roster has no entry for, so give it a key that can only
127
+ read if that is what you want.
128
+
129
+ A server run as a command, or one with more than one key, is written out in `org.yaml`, with a `url` or a `command`, and the names of the keys it needs:
118
130
 
119
131
  ```yaml
120
132
  connectors:
package/docs/hosting.md CHANGED
@@ -105,6 +105,9 @@ and commits two files to the ops repo:
105
105
  - `portal/wrangler.jsonc`: the Worker's name, the domain, the org. Nothing secret.
106
106
  - `.github/workflows/portal.yaml`: redeploys it.
107
107
 
108
+ To show your own icon on the sign-in page and in the portal, commit a square image as
109
+ `portal/icon.png` (or `.svg`, `.jpg`, `.webp`). The push redeploys the portal with it.
110
+
108
111
  ## Keeping it up to date
109
112
 
110
113
  The workflow redeploys the portal when its config changes, every morning, and when you run it
package/docs/portal.md CHANGED
@@ -19,6 +19,11 @@ It can also be hosted, on your own URL behind Sign in with GitHub: see [hosting]
19
19
 
20
20
  ## The sidebar
21
21
 
22
+ **Your own icon.** Put a square image in the ops repo at `portal/icon.png` (or `.svg`, `.jpg`,
23
+ `.webp`) and it replaces roster's mark in the sidebar and the browser tab, and on a hosted
24
+ portal's sign-in page. Locally it shows on the next reload; a hosted portal picks it up when it
25
+ redeploys, which a push to `portal/` does.
26
+
22
27
  **Search everything** with ⌘K (Ctrl+K off a Mac), from anywhere, or the Search field at the
23
28
  top of the sidebar, which opens the same dialog. It searches as you type, across:
24
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanocollective/roster",
3
- "version": "0.1.0-beta.24",
3
+ "version": "0.1.0-beta.25",
4
4
  "description": "An agent-run org, powered by GitHub. Scaffold AI staff members whose brain is a repo.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,9 +8,9 @@
8
8
  .brand{padding:4px 10px 16px;font:600 15px/1.2 var(--sans);letter-spacing:-.02em;
9
9
  display:grid;grid-template-columns:auto 1fr;column-gap:10px;align-items:center}
10
10
  /* The tab icon, in the corner it belongs in. Drawn rather than fetched so it takes the
11
- theme's accent and costs no request. */
11
+ theme's accent and costs no request, unless the org has its own (app.js, initIcon). */
12
12
  .brand .mark{grid-row:1/3;display:inline-block;width:24px;height:24px;border-radius:7px;
13
- background:var(--accent-fill)}
13
+ background:var(--accent-fill);object-fit:cover}
14
14
  .brand small{display:block;color:var(--ink-faint);font-weight:400;font-size:11.5px;
15
15
  letter-spacing:0;margin-top:2px;overflow:hidden;text-overflow:ellipsis;
16
16
  white-space:nowrap}
@@ -78,6 +78,7 @@ const NAV = [
78
78
 
79
79
  export async function boot() {
80
80
  initTheme();
81
+ initIcon();
81
82
 
82
83
  /* Bound before the first request rather than after it. The sidebar is markup, so it is on
83
84
  screen and clickable while /api/org is still building the export, and a click in that
@@ -490,6 +491,18 @@ function applyTheme(name) {
490
491
  }
491
492
  }
492
493
 
494
+ /* The org's own icon, if its ops repo has one at portal/icon.*: in the sidebar and the tab. */
495
+ function initIcon() {
496
+ const img = document.createElement("img");
497
+ img.className = "mark";
498
+ img.alt = "";
499
+ img.onload = () => {
500
+ document.querySelector(".brand .mark")?.replaceWith(img);
501
+ document.querySelector('link[rel="icon"]')?.setAttribute("href", "/icon");
502
+ };
503
+ img.src = "/icon";
504
+ }
505
+
493
506
  function initTheme() {
494
507
  let theme = store("roster.theme") ?? "system";
495
508
  if (!THEMES.includes(theme)) theme = "system";
@@ -64,6 +64,12 @@ function draw(body, d) {
64
64
  card.onclick = () => open(e, null, d);
65
65
  grid.append(card);
66
66
  }
67
+ const own = el("button", { className: "conncard" }, [
68
+ el("span", { className: "connicon" }, [icon("plug")]),
69
+ el("span", {}, [el("b", { textContent: "Custom server" }), el("small", { textContent: "Any MCP server, by its URL." })]),
70
+ ]);
71
+ own.onclick = () => openCustom(d);
72
+ grid.append(own);
67
73
  body.append(el("h2", { className: "connhead", textContent: d.connectors.length ? "Add another" : "Add a service" }), grid);
68
74
  }
69
75
 
@@ -92,7 +98,7 @@ function row(c, d) {
92
98
 
93
99
  const edit = el("button", { className: "ghbtn", textContent: "Edit" });
94
100
  edit.onclick = () => open(e ?? custom(c), c, d);
95
- edit.disabled = !d.canWrite || !e;
101
+ edit.disabled = !d.canWrite || (!e && Boolean(c.problem));
96
102
  const remove = el("button", { className: "ghbtn", textContent: "Remove" });
97
103
  remove.disabled = !d.canWrite;
98
104
  remove.onclick = () => confirmRemove(c, remove);
@@ -108,9 +114,104 @@ function row(c, d) {
108
114
  ]);
109
115
  }
110
116
 
111
- /** A hand-written connector the catalogue does not describe: editable in org.yaml only. */
117
+ /** A server the catalogue does not describe: who has it, and its key when it takes one. */
112
118
  function custom(c) {
113
- return { id: c.id, name: c.name, fields: [], steps: [], auth: c.auth };
119
+ const fields = c.auth === "key" && c.secrets.length === 1 ? [{ id: "token", label: c.secrets[0].label, secret: true }] : [];
120
+ return { id: c.id, name: c.name, summary: c.url ?? "", fields, steps: [], auth: c.auth };
121
+ }
122
+
123
+ /* --------------------------- a server of your own ---------------------------- */
124
+
125
+ function openCustom(d) {
126
+ let box = null;
127
+ const node = customForm(d, () => box?.close());
128
+ box = sheet({ node, onClose: () => {} });
129
+ if (!box) document.querySelector("#main")?.append(node);
130
+ }
131
+
132
+ function customForm(d, close) {
133
+ const out = el("div", { className: "connform" });
134
+ out.append(el("h2", { className: "sheettitle", textContent: "Connect a custom server" }));
135
+
136
+ const input = (placeholder, type = "text") => el("input", { type, autocomplete: "off", spellcheck: false, placeholder });
137
+ const name = input("acme");
138
+ const url = input("https://mcp.acme.dev/mcp");
139
+ const header = input("Authorization");
140
+ header.value = "Authorization";
141
+ const key = input("Bearer …", "password");
142
+ const field = (label, node) => el("label", { className: "field" }, [el("span", { textContent: label }), node]);
143
+ out.append(el("div", { className: "setupform" }, [field("Name", name), field("URL", url)]));
144
+
145
+ // How it signs in: a key in a header, the hosted portal's sign-in, or nothing.
146
+ let auth = "key";
147
+ const keyFields = el("div", { className: "setupform" }, [field("Header", header), field("Value", key)]);
148
+ const choices = el("div", { className: "connstaff" });
149
+ for (const [value, label] of [["key", "Key"], ["oauth", "Sign in"], ["none", "No key"]]) {
150
+ if (value === "oauth" && !d.signIn) continue;
151
+ const radio = el("input", { type: "radio", name: "connauth", checked: value === auth });
152
+ radio.onchange = () => {
153
+ auth = value;
154
+ keyFields.hidden = auth !== "key";
155
+ save.textContent = auth === "oauth" ? "Sign in" : "Save";
156
+ };
157
+ choices.append(el("label", { className: "conntick" }, [radio, el("span", { textContent: label })]));
158
+ }
159
+ out.append(el("h3", { className: "connsub", textContent: "Sign-in" }), choices, keyFields);
160
+
161
+ const picked = new Set(d.staff.length === 1 ? [d.staff[0].handle] : []);
162
+ out.append(el("h3", { className: "connsub", textContent: "Who can use it" }), staffPicker(d, picked));
163
+
164
+ const status = el("div");
165
+ const cancel = el("button", { className: "ghbtn", textContent: "Cancel" });
166
+ cancel.onclick = close;
167
+ const save = el("button", { className: "ghbtn primary", textContent: "Save" });
168
+ save.disabled = !d.canWrite;
169
+ const fail = (msg) => status.replaceChildren(el("p", { className: "err", textContent: msg }));
170
+ save.onclick = async () => {
171
+ const id = name.value.trim().toLowerCase();
172
+ if (!id) return fail("Give it a name.");
173
+ if (!picked.size) return fail("Pick at least one staff member.");
174
+ if (auth === "key" && !key.value.trim()) return fail("Paste the key, or pick No key.");
175
+ const label = save.textContent;
176
+ save.disabled = true;
177
+ save.textContent = auth === "oauth" ? "Opening…" : "Saving…";
178
+ try {
179
+ if (auth === "oauth") {
180
+ const r = await post({ id, staff: [...picked], custom: { url: url.value.trim() } }, "/api/connectors/signin");
181
+ location.href = r.url;
182
+ return;
183
+ }
184
+ await post(
185
+ {
186
+ id,
187
+ staff: [...picked],
188
+ custom: { url: url.value.trim(), header: header.value.trim() },
189
+ values: { token: auth === "key" ? key.value.trim() : "" },
190
+ },
191
+ "/api/connectors/save",
192
+ );
193
+ last = null;
194
+ close();
195
+ render();
196
+ } catch (err) {
197
+ save.disabled = false;
198
+ save.textContent = label;
199
+ fail(String(err.message || err));
200
+ }
201
+ };
202
+
203
+ out.append(status, el("div", { className: "row connfoot" }, [save, cancel]));
204
+ return out;
205
+ }
206
+
207
+ function staffPicker(d, picked) {
208
+ const who = el("div", { className: "connstaff" });
209
+ for (const s of d.staff) {
210
+ const box = el("input", { type: "checkbox", checked: picked.has(s.handle) });
211
+ box.onchange = () => (box.checked ? picked.add(s.handle) : picked.delete(s.handle));
212
+ who.append(el("label", { className: "conntick" }, [box, el("span", { textContent: s.name })]));
213
+ }
214
+ return who;
114
215
  }
115
216
 
116
217
  async function confirmRemove(c, btn) {
@@ -143,7 +244,7 @@ function open(e, c, d) {
143
244
  function form(e, c, d, close) {
144
245
  const out = el("div", { className: "connform" });
145
246
  out.append(el("h2", { className: "sheettitle", textContent: (c ? "" : "Connect ") + shortName(e) }));
146
- if (!c) out.append(el("p", { className: "sub", textContent: e.summary }));
247
+ if (!c || !c.known) out.append(el("p", { className: "sub", textContent: e.summary }));
147
248
 
148
249
  const oauth = e.auth === "oauth";
149
250
  if (!c && e.steps.length && !oauth) {
@@ -194,13 +295,7 @@ function form(e, c, d, close) {
194
295
 
195
296
  const picked = new Set(c ? c.staff : (e.suggest ?? []).filter((h) => d.staff.some((s) => s.handle === h)));
196
297
  if (!picked.size && d.staff.length === 1) picked.add(d.staff[0].handle);
197
- const who = el("div", { className: "connstaff" });
198
- for (const s of d.staff) {
199
- const box = el("input", { type: "checkbox", checked: picked.has(s.handle) });
200
- box.onchange = () => (box.checked ? picked.add(s.handle) : picked.delete(s.handle));
201
- who.append(el("label", { className: "conntick" }, [box, el("span", { textContent: s.name })]));
202
- }
203
- out.append(el("h3", { className: "connsub", textContent: "Who can use it" }), who);
298
+ out.append(el("h3", { className: "connsub", textContent: "Who can use it" }), staffPicker(d, picked));
204
299
 
205
300
  let ro = null;
206
301
  if (e.readOnly) {