@korso/shepherd-ui 0.2.1 → 0.3.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/dist/lib/index.js CHANGED
@@ -1,374 +1,444 @@
1
- import { u as O, d as N, D as $ } from "./Dashboard-B7nioe5N.js";
2
- import { E as Y, S as Z, a as ee, c as ne } from "./Dashboard-B7nioe5N.js";
3
- import { jsxs as y, jsx as e } from "react/jsx-runtime";
4
- import { useId as U, useState as a, useEffect as H, useCallback as F } from "react";
5
- function K({ workspaceId: c, refreshKey: t = 0, canRemove: i = !1, onLeft: k }) {
6
- const m = O(), C = U(), [g, b] = a([]), [u, p] = a(null), [h, o] = a(null), [w, d] = a(!0), [s, v] = a(null), [R, S] = a(!1);
7
- async function I({ keepError: l = !1 } = {}) {
8
- l || p(null);
9
- try {
10
- const f = await m.listMembers(c);
11
- b(f.members);
12
- } catch (f) {
13
- p(N(f));
14
- } finally {
15
- d(!1);
16
- }
17
- }
18
- H(() => {
19
- d(!0), I();
20
- }, [m, c, t]);
21
- async function L(l, f) {
22
- if (!s) {
23
- v(l), p(null), o(null), b((E) => E.filter((r) => r.accountId !== l));
24
- try {
25
- await m.removeMember(c, l), o(`Removed ${f}`);
26
- } catch (E) {
27
- p(N(E)), I({ keepError: !0 });
28
- } finally {
29
- v(null);
30
- }
31
- }
32
- }
33
- async function x() {
34
- if (!R) {
35
- S(!0), p(null), o(null);
1
+ import { u as U, d as N, f as F, D as W } from "./Dashboard-Bgi50wCo.js";
2
+ import { E as ie, S as ae, a as le, c as re } from "./Dashboard-Bgi50wCo.js";
3
+ import { jsxs as a, jsx as e } from "react/jsx-runtime";
4
+ import { useId as B, useState as i, useEffect as $, useCallback as D } from "react";
5
+ function K({
6
+ workspaces: l,
7
+ selected: t,
8
+ onChanged: r,
9
+ onSelect: b,
10
+ onMembersChanged: d
11
+ }) {
12
+ const y = U(), C = B(), [g, k] = i(""), [m, u] = i(""), [o, w] = i(null), [h, s] = i(null), [p, v] = i(!1), [S, R] = i(""), [x, E] = i(null), [c, f] = i(!1), _ = (t == null ? void 0 : t.role) === "admin";
13
+ async function I() {
14
+ if (!(!g.trim() || p)) {
15
+ v(!0), s(null);
36
16
  try {
37
- await m.leave(c), o("Left workspace"), k == null || k();
38
- } catch (l) {
39
- p(N(l));
17
+ await y.createWorkspace({ name: g.trim() }), k(""), r();
18
+ } catch (n) {
19
+ s(N(n));
40
20
  } finally {
41
- S(!1);
21
+ v(!1);
42
22
  }
43
23
  }
44
24
  }
45
- return /* @__PURE__ */ y("section", { className: "shepherd-members", "aria-labelledby": C, children: [
46
- /* @__PURE__ */ e("h3", { id: C, children: "Members" }),
47
- u && /* @__PURE__ */ e("p", { role: "alert", children: u }),
48
- h && /* @__PURE__ */ e("p", { role: "status", children: h }),
49
- w ? /* @__PURE__ */ e("p", { role: "status", children: "Loading…" }) : g.length === 0 ? /* @__PURE__ */ e("p", { children: "No members." }) : /* @__PURE__ */ e("ul", { children: g.map((l) => {
50
- const f = l.displayName ?? l.githubLogin ?? l.accountId;
51
- return /* @__PURE__ */ y("li", { children: [
52
- /* @__PURE__ */ e("span", { children: f }),
53
- /* @__PURE__ */ e("span", { className: "role", children: l.role }),
54
- i && /* @__PURE__ */ e(
55
- "button",
56
- {
57
- type: "button",
58
- "aria-label": `Remove ${f}`,
59
- onClick: () => void L(l.accountId, f),
60
- disabled: s === l.accountId,
61
- children: "Remove"
62
- }
63
- )
64
- ] }, l.accountId);
65
- }) }),
66
- /* @__PURE__ */ e("button", { type: "button", onClick: () => void x(), disabled: R, children: "Leave workspace" })
67
- ] });
68
- }
69
- function M({ workspaces: c, selected: t, onChanged: i, onSelect: k }) {
70
- const m = O(), C = U(), [g, b] = a(""), [u, p] = a(""), [h, o] = a(null), [w, d] = a(null), [s, v] = a(!1), [R, S] = a(0), I = (t == null ? void 0 : t.role) === "admin";
71
25
  async function L() {
72
- if (!(!g.trim() || s)) {
73
- v(!0), d(null);
26
+ if (!(!m.trim() || p)) {
27
+ v(!0), s(null);
74
28
  try {
75
- await m.createWorkspace({ name: g.trim() }), b(""), i();
76
- } catch (r) {
77
- d(N(r));
29
+ await y.redeemInvite(m.trim()), u(""), r(), d == null || d();
30
+ } catch (n) {
31
+ s(N(n));
78
32
  } finally {
79
33
  v(!1);
80
34
  }
81
35
  }
82
36
  }
83
- async function x() {
84
- if (!(!u.trim() || s)) {
85
- v(!0), d(null);
37
+ async function H() {
38
+ if (!(!t || p)) {
39
+ v(!0), s(null);
86
40
  try {
87
- await m.redeemInvite(u.trim()), p(""), i(), S((r) => r + 1);
88
- } catch (r) {
89
- d(N(r));
41
+ const n = await y.createInvite(t.id, {});
42
+ w(n), d == null || d();
43
+ } catch (n) {
44
+ s(N(n));
90
45
  } finally {
91
46
  v(!1);
92
47
  }
93
48
  }
94
49
  }
95
- async function l() {
96
- if (!(!t || s)) {
97
- v(!0), d(null);
50
+ async function O() {
51
+ if (!(!t || !S.trim() || c)) {
52
+ f(!0), E(null);
98
53
  try {
99
- const r = await m.createInvite(t.id, {});
100
- o(r), S((j) => j + 1);
101
- } catch (r) {
102
- d(N(r));
54
+ const n = await y.inviteByEmail(t.id, S.trim());
55
+ E(`Invite sent to ${n.email}.`), R(""), d == null || d();
56
+ } catch (n) {
57
+ E(N(n));
103
58
  } finally {
104
- v(!1);
59
+ f(!1);
105
60
  }
106
61
  }
107
62
  }
108
- async function f() {
109
- if (!(!t || !h || s)) {
110
- v(!0), d(null);
63
+ async function A() {
64
+ if (!(!t || !o || p)) {
65
+ v(!0), s(null);
111
66
  try {
112
- await m.revokeInvite(t.id, h.code), o(null);
113
- } catch (r) {
114
- d(N(r));
67
+ await y.revokeInvite(t.id, o.code), w(null);
68
+ } catch (n) {
69
+ s(N(n));
115
70
  } finally {
116
71
  v(!1);
117
72
  }
118
73
  }
119
74
  }
120
- H(() => {
121
- o(null);
75
+ $(() => {
76
+ w(null), E(null);
122
77
  }, [t == null ? void 0 : t.id]);
123
- const E = h ? `${window.location.origin}/join/${encodeURIComponent(h.code)}` : null;
124
- return /* @__PURE__ */ y("section", { className: "shepherd-workspaces", "aria-labelledby": C, children: [
125
- /* @__PURE__ */ e("h3", { id: C, children: "Workspace management" }),
126
- w && /* @__PURE__ */ e("p", { role: "alert", children: w }),
127
- c.length > 1 && k && /* @__PURE__ */ y("div", { className: "switcher", children: [
128
- /* @__PURE__ */ e("label", { htmlFor: "ws-switcher", children: "Active workspace" }),
129
- /* @__PURE__ */ e(
130
- "select",
131
- {
132
- id: "ws-switcher",
133
- value: (t == null ? void 0 : t.id) ?? "",
134
- onChange: (r) => k(r.target.value),
135
- children: c.map((r) => /* @__PURE__ */ e("option", { value: r.id, children: r.name }, r.id))
136
- }
137
- )
78
+ const j = o ? `${window.location.origin}/join/${encodeURIComponent(o.code)}` : null;
79
+ return /* @__PURE__ */ a("section", { className: "shepherd-workspaces", "aria-labelledby": C, children: [
80
+ /* @__PURE__ */ a("div", { className: "card-head", children: [
81
+ /* @__PURE__ */ e("h3", { id: C, children: "Workspace management" }),
82
+ /* @__PURE__ */ e("p", { className: "card-sub", children: "Create a workspace to get started, or join an existing one with an invite code." })
138
83
  ] }),
139
- /* @__PURE__ */ y("div", { className: "create", children: [
140
- /* @__PURE__ */ e("label", { htmlFor: "ws-name", children: "Workspace name" }),
141
- /* @__PURE__ */ e(
142
- "input",
143
- {
144
- id: "ws-name",
145
- type: "text",
146
- value: g,
147
- onChange: (r) => b(r.target.value)
148
- }
149
- ),
150
- /* @__PURE__ */ e("button", { type: "button", onClick: () => void L(), disabled: s, children: "Create workspace" })
151
- ] }),
152
- /* @__PURE__ */ y("div", { className: "join", children: [
153
- /* @__PURE__ */ e("label", { htmlFor: "invite-code", children: "Invite code" }),
154
- /* @__PURE__ */ e(
155
- "input",
156
- {
157
- id: "invite-code",
158
- type: "text",
159
- value: u,
160
- onChange: (r) => p(r.target.value)
161
- }
162
- ),
163
- /* @__PURE__ */ e("button", { type: "button", onClick: () => void x(), disabled: s, children: "Join" })
164
- ] }),
165
- I && t && /* @__PURE__ */ y("div", { className: "admin", children: [
166
- /* @__PURE__ */ y("div", { className: "invites", children: [
167
- /* @__PURE__ */ e("button", { type: "button", onClick: () => void l(), disabled: s, children: "Create invite" }),
168
- h && /* @__PURE__ */ y("div", { className: "invite-result", children: [
169
- /* @__PURE__ */ e("code", { children: h.code }),
170
- /* @__PURE__ */ e("a", { href: E ?? void 0, children: E }),
171
- /* @__PURE__ */ y("span", { className: "invite-uses", children: [
172
- h.useCount,
173
- " / ",
174
- h.maxUses,
175
- " uses"
176
- ] }),
177
- /* @__PURE__ */ e("button", { type: "button", onClick: () => void f(), disabled: s, children: "Revoke invite" })
84
+ /* @__PURE__ */ a("div", { className: "card-body", children: [
85
+ h && /* @__PURE__ */ e("p", { role: "alert", children: h }),
86
+ l.length > 1 && b && /* @__PURE__ */ a("div", { className: "field switcher", children: [
87
+ /* @__PURE__ */ e("label", { htmlFor: "ws-switcher", children: "Active workspace" }),
88
+ /* @__PURE__ */ e(
89
+ "select",
90
+ {
91
+ id: "ws-switcher",
92
+ value: (t == null ? void 0 : t.id) ?? "",
93
+ onChange: (n) => b(n.target.value),
94
+ children: l.map((n) => /* @__PURE__ */ e("option", { value: n.id, children: n.name }, n.id))
95
+ }
96
+ )
97
+ ] }),
98
+ /* @__PURE__ */ a("div", { className: "field create", children: [
99
+ /* @__PURE__ */ e("label", { htmlFor: "ws-name", children: "Workspace name" }),
100
+ /* @__PURE__ */ e("p", { className: "helper", children: "Start a fresh workspace — you'll be its admin." }),
101
+ /* @__PURE__ */ a("div", { className: "field__row", children: [
102
+ /* @__PURE__ */ e(
103
+ "input",
104
+ {
105
+ id: "ws-name",
106
+ type: "text",
107
+ placeholder: "e.g. Acme Engineering",
108
+ value: g,
109
+ onChange: (n) => k(n.target.value)
110
+ }
111
+ ),
112
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void I(), disabled: p, children: "Create workspace" })
178
113
  ] })
179
114
  ] }),
180
- /* @__PURE__ */ e(
181
- K,
182
- {
183
- workspaceId: t.id,
184
- refreshKey: R,
185
- onLeft: i,
186
- canRemove: !0
187
- }
188
- )
115
+ /* @__PURE__ */ a("div", { className: "field join", children: [
116
+ /* @__PURE__ */ e("label", { htmlFor: "invite-code", children: "Invite code" }),
117
+ /* @__PURE__ */ e("p", { className: "helper", children: "Paste an invite code someone shared to join their workspace." }),
118
+ /* @__PURE__ */ a("div", { className: "field__row", children: [
119
+ /* @__PURE__ */ e(
120
+ "input",
121
+ {
122
+ id: "invite-code",
123
+ type: "text",
124
+ placeholder: "Invite code",
125
+ value: m,
126
+ onChange: (n) => u(n.target.value)
127
+ }
128
+ ),
129
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void L(), disabled: p, children: "Join" })
130
+ ] })
131
+ ] }),
132
+ _ && t && /* @__PURE__ */ a("div", { className: "admin", children: [
133
+ /* @__PURE__ */ a("div", { className: "invites", children: [
134
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void H(), disabled: p, children: "Create invite" }),
135
+ o && /* @__PURE__ */ a("div", { className: "invite-result", children: [
136
+ /* @__PURE__ */ a("div", { className: "invite-result__row", children: [
137
+ /* @__PURE__ */ e("code", { children: o.code }),
138
+ /* @__PURE__ */ e("span", { className: "invite-uses", children: o.maxUses === null ? `${o.useCount} uses` : `${o.useCount} / ${o.maxUses} uses` }),
139
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void A(), disabled: p, children: "Revoke invite" })
140
+ ] }),
141
+ /* @__PURE__ */ e("a", { href: j ?? void 0, children: j })
142
+ ] })
143
+ ] }),
144
+ /* @__PURE__ */ a("div", { className: "field email-invite", children: [
145
+ /* @__PURE__ */ e("label", { htmlFor: "invite-email", children: "Email invite" }),
146
+ /* @__PURE__ */ e("p", { className: "helper", children: "Send a one-time-use join link directly to someone's inbox." }),
147
+ /* @__PURE__ */ a("div", { className: "field__row", children: [
148
+ /* @__PURE__ */ e(
149
+ "input",
150
+ {
151
+ id: "invite-email",
152
+ type: "email",
153
+ placeholder: "name@example.com",
154
+ value: S,
155
+ onChange: (n) => R(n.target.value)
156
+ }
157
+ ),
158
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void O(), disabled: c, children: "Send invite" })
159
+ ] }),
160
+ x && /* @__PURE__ */ e("p", { className: "email-invite__status", children: x })
161
+ ] })
162
+ ] })
163
+ ] })
164
+ ] });
165
+ }
166
+ function G({ workspaceId: l, refreshKey: t = 0, canRemove: r = !1, onLeft: b }) {
167
+ const d = U(), y = B(), [C, g] = i([]), [k, m] = i(null), [u, o] = i(null), [w, h] = i(!0), [s, p] = i(null), [v, S] = i(!1);
168
+ async function R({ keepError: c = !1 } = {}) {
169
+ c || m(null);
170
+ try {
171
+ const f = await d.listMembers(l);
172
+ g(f.members);
173
+ } catch (f) {
174
+ m(N(f));
175
+ } finally {
176
+ h(!1);
177
+ }
178
+ }
179
+ $(() => {
180
+ h(!0), R();
181
+ }, [d, l, t]);
182
+ async function x(c, f) {
183
+ if (!s) {
184
+ p(c), m(null), o(null), g((_) => _.filter((I) => I.accountId !== c));
185
+ try {
186
+ await d.removeMember(l, c), o(`Removed ${f}`);
187
+ } catch (_) {
188
+ m(N(_)), R({ keepError: !0 });
189
+ } finally {
190
+ p(null);
191
+ }
192
+ }
193
+ }
194
+ async function E() {
195
+ if (!v) {
196
+ S(!0), m(null), o(null);
197
+ try {
198
+ await d.leave(l), o("Left workspace"), b == null || b();
199
+ } catch (c) {
200
+ m(N(c));
201
+ } finally {
202
+ S(!1);
203
+ }
204
+ }
205
+ }
206
+ return /* @__PURE__ */ a("section", { className: "shepherd-members", "aria-labelledby": y, children: [
207
+ /* @__PURE__ */ e("div", { className: "card-head", children: /* @__PURE__ */ e("h3", { id: y, children: "Members" }) }),
208
+ /* @__PURE__ */ a("div", { className: "card-body", children: [
209
+ k && /* @__PURE__ */ e("p", { role: "alert", children: k }),
210
+ u && /* @__PURE__ */ e("p", { role: "status", children: u }),
211
+ w ? /* @__PURE__ */ e("p", { role: "status", children: "Loading…" }) : C.length === 0 ? /* @__PURE__ */ e("p", { children: "No members." }) : /* @__PURE__ */ e("ul", { children: C.map((c) => {
212
+ const f = c.displayName ?? c.githubLogin ?? c.accountId;
213
+ return /* @__PURE__ */ a("li", { children: [
214
+ /* @__PURE__ */ e("span", { children: f }),
215
+ /* @__PURE__ */ e("span", { className: "role", children: c.role }),
216
+ r && /* @__PURE__ */ e(
217
+ "button",
218
+ {
219
+ type: "button",
220
+ "aria-label": `Remove ${f}`,
221
+ onClick: () => void x(c.accountId, f),
222
+ disabled: s === c.accountId,
223
+ children: "Remove"
224
+ }
225
+ )
226
+ ] }, c.accountId);
227
+ }) }),
228
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void E(), disabled: v, children: "Leave workspace" })
189
229
  ] })
190
230
  ] });
191
231
  }
192
- const P = [
232
+ const J = [
193
233
  { id: "claude", label: "Claude Code" },
194
234
  { id: "codex", label: "Codex" },
195
235
  { id: "pi", label: "Pi" },
196
236
  { id: "generic", label: "Generic (JSON)" }
197
- ], A = "shp_<paste-after-generating>", D = {
237
+ ], X = "shp_<paste-after-generating>", q = {
198
238
  claude: "claude mcp add shepherd -s user \\",
199
239
  codex: "codex mcp add shepherd \\",
200
240
  pi: "pi mcp add shepherd \\"
201
241
  };
202
- function B(c, t, i) {
203
- return c === "generic" ? JSON.stringify(
242
+ function z(l, t) {
243
+ const r = `created ${F(l.createdAt, t)}`, b = l.lastUsedAt ? `last used ${F(l.lastUsedAt, t)}` : "never used";
244
+ return `${r} · ${b}`;
245
+ }
246
+ function Q(l, t, r) {
247
+ return l === "generic" ? JSON.stringify(
204
248
  {
205
249
  mcpServers: {
206
250
  shepherd: {
207
251
  command: "npx",
208
252
  args: ["-y", "@korso/shepherd"],
209
- env: { HUB_URL: t, SHEPHERD_TOKEN: i }
253
+ env: { HUB_URL: t, SHEPHERD_TOKEN: r }
210
254
  }
211
255
  }
212
256
  },
213
257
  null,
214
258
  2
215
259
  ) : [
216
- D[c],
260
+ q[l],
217
261
  ` -e HUB_URL=${t} \\`,
218
- ` -e SHEPHERD_TOKEN=${i} \\`,
262
+ ` -e SHEPHERD_TOKEN=${r} \\`,
219
263
  " -- npx -y @korso/shepherd"
220
264
  ].join(`
221
265
  `);
222
266
  }
223
- function J({ workspaceId: c, hubUrl: t }) {
224
- const i = O(), k = t ?? i.baseUrl, m = U(), [C, g] = a("claude"), [b, u] = a(""), [p, h] = a(null), [o, w] = a([]), [d, s] = a(null), [v, R] = a(null), [S, I] = a(!1), [L, x] = a(!0), [l, f] = a(null);
225
- async function E() {
267
+ function V({ workspaceId: l, hubUrl: t }) {
268
+ const r = U(), b = t ?? r.baseUrl, d = B(), [y, C] = i("claude"), [g, k] = i(""), [m, u] = i(null), [o, w] = i([]), [h, s] = i(null), [p, v] = i(null), [S, R] = i(!1), [x, E] = i(!1), [c, f] = i(!0), [_, I] = i(null);
269
+ async function L() {
226
270
  try {
227
- const n = await i.listTokens(c);
271
+ const n = await r.listTokens(l);
228
272
  w(n.tokens);
229
273
  } catch (n) {
230
274
  s(N(n));
231
275
  } finally {
232
- x(!1);
276
+ f(!1);
233
277
  }
234
278
  }
235
- H(() => {
236
- x(!0), E();
237
- }, [i, c]), H(() => {
238
- h(null);
239
- }, [c]);
240
- async function r() {
241
- I(!0), s(null);
279
+ $(() => {
280
+ f(!0), L();
281
+ }, [r, l]), $(() => {
282
+ u(null);
283
+ }, [l]);
284
+ async function H() {
285
+ R(!0), s(null);
242
286
  try {
243
- const n = await i.mintToken(
244
- c,
245
- b.trim() ? { name: b.trim() } : {}
287
+ const n = await r.mintToken(
288
+ l,
289
+ g.trim() ? { name: g.trim() } : {}
246
290
  );
247
- h(n.token), u(""), await E();
291
+ u(n.token), k(""), await L();
248
292
  } catch (n) {
249
293
  s(N(n));
250
294
  } finally {
251
- I(!1);
295
+ R(!1);
252
296
  }
253
297
  }
254
- async function j(n) {
255
- if (!l) {
256
- f(n), s(null), R(null);
298
+ async function O(n) {
299
+ if (!_) {
300
+ I(n), s(null), v(null);
257
301
  try {
258
- await i.revokeToken(c, n), w((T) => T.filter((_) => _.id !== n)), R("Token revoked");
302
+ await r.revokeToken(l, n), w((T) => T.filter((P) => P.id !== n)), v("Token revoked");
259
303
  } catch (T) {
260
304
  s(N(T));
261
305
  } finally {
262
- f(null);
306
+ I(null);
263
307
  }
264
308
  }
265
309
  }
266
- const W = B(C, k, p ?? A);
267
- return /* @__PURE__ */ y("section", { className: "shepherd-connect-agent", "aria-labelledby": m, children: [
268
- /* @__PURE__ */ e("h3", { id: m, children: "Connect your agent" }),
269
- /* @__PURE__ */ e("label", { htmlFor: "connect-tool", children: "Tool" }),
270
- /* @__PURE__ */ e(
271
- "select",
272
- {
273
- id: "connect-tool",
274
- value: C,
275
- onChange: (n) => g(n.target.value),
276
- children: P.map((n) => /* @__PURE__ */ e("option", { value: n.id, children: n.label }, n.id))
277
- }
278
- ),
279
- /* @__PURE__ */ y("div", { className: "generate", children: [
280
- /* @__PURE__ */ e("label", { htmlFor: "token-name", children: "Token name (optional)" }),
281
- /* @__PURE__ */ e(
282
- "input",
283
- {
284
- id: "token-name",
285
- type: "text",
286
- value: b,
287
- onChange: (n) => u(n.target.value),
288
- placeholder: "e.g. laptop"
289
- }
290
- ),
291
- /* @__PURE__ */ e("button", { type: "button", onClick: () => void r(), disabled: S, children: "Generate token" })
310
+ const A = Q(y, b, m ?? X);
311
+ async function j() {
312
+ await navigator.clipboard.writeText(A), E(!0), setTimeout(() => E(!1), 2e3);
313
+ }
314
+ return /* @__PURE__ */ a("section", { className: "shepherd-connect-agent", "aria-labelledby": d, children: [
315
+ /* @__PURE__ */ a("div", { className: "card-head", children: [
316
+ /* @__PURE__ */ e("h3", { id: d, children: "Connect your agent" }),
317
+ /* @__PURE__ */ e("p", { className: "card-sub", children: "Generate a token, then paste the command into your coding tool." })
292
318
  ] }),
293
- d && /* @__PURE__ */ e("p", { role: "alert", children: d }),
294
- v && /* @__PURE__ */ e("p", { role: "status", children: v }),
295
- p && /* @__PURE__ */ e("p", { className: "token-once", role: "status", children: "Copy this token now — it won't be shown again." }),
296
- /* @__PURE__ */ e("pre", { "data-testid": "install-command", children: W }),
297
- /* @__PURE__ */ e("h4", { children: "Existing tokens" }),
298
- L ? /* @__PURE__ */ e("p", { role: "status", children: "Loading…" }) : o.length === 0 ? /* @__PURE__ */ e("p", { children: "No tokens yet." }) : /* @__PURE__ */ e("ul", { children: o.map((n) => {
299
- const T = n.name ?? n.id;
300
- return /* @__PURE__ */ y("li", { children: [
301
- /* @__PURE__ */ e("span", { children: T }),
302
- n.revokedAt ? /* @__PURE__ */ e("span", { className: "revoked", children: "revoked" }) : /* @__PURE__ */ e(
303
- "button",
319
+ /* @__PURE__ */ a("div", { className: "card-body", children: [
320
+ /* @__PURE__ */ a("div", { className: "field", children: [
321
+ /* @__PURE__ */ e("label", { htmlFor: "connect-tool", children: "Tool" }),
322
+ /* @__PURE__ */ e(
323
+ "select",
304
324
  {
305
- type: "button",
306
- "aria-label": `Revoke token ${T}`,
307
- onClick: () => void j(n.id),
308
- disabled: l === n.id,
309
- children: "Revoke"
325
+ id: "connect-tool",
326
+ value: y,
327
+ onChange: (n) => C(n.target.value),
328
+ children: J.map((n) => /* @__PURE__ */ e("option", { value: n.id, children: n.label }, n.id))
310
329
  }
311
330
  )
312
- ] }, n.id);
313
- }) })
331
+ ] }),
332
+ /* @__PURE__ */ a("div", { className: "field generate", children: [
333
+ /* @__PURE__ */ e("label", { htmlFor: "token-name", children: "Token name (optional)" }),
334
+ /* @__PURE__ */ a("div", { className: "field__row", children: [
335
+ /* @__PURE__ */ e(
336
+ "input",
337
+ {
338
+ id: "token-name",
339
+ type: "text",
340
+ value: g,
341
+ onChange: (n) => k(n.target.value),
342
+ placeholder: "e.g. laptop"
343
+ }
344
+ ),
345
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void H(), disabled: S, children: "Generate token" })
346
+ ] })
347
+ ] }),
348
+ h && /* @__PURE__ */ e("p", { role: "alert", children: h }),
349
+ p && /* @__PURE__ */ e("p", { role: "status", children: p }),
350
+ m && /* @__PURE__ */ e("p", { className: "token-once", role: "status", children: "Copy this token now — it won't be shown again." }),
351
+ /* @__PURE__ */ a("div", { className: "install-command", children: [
352
+ /* @__PURE__ */ e("pre", { "data-testid": "install-command", children: A }),
353
+ /* @__PURE__ */ e("button", { type: "button", className: "install-command__copy", onClick: () => void j(), children: x ? "Copied" : "Copy" })
354
+ ] }),
355
+ /* @__PURE__ */ e("h4", { children: "Existing tokens" }),
356
+ c ? /* @__PURE__ */ e("p", { role: "status", children: "Loading…" }) : o.length === 0 ? /* @__PURE__ */ e("p", { children: "No tokens yet." }) : /* @__PURE__ */ e("ul", { children: o.map((n) => {
357
+ const T = n.name ?? n.id;
358
+ return /* @__PURE__ */ a("li", { children: [
359
+ /* @__PURE__ */ e("span", { children: T }),
360
+ /* @__PURE__ */ e("span", { className: "token-meta", children: z(n, Date.now()) }),
361
+ n.revokedAt ? /* @__PURE__ */ e("span", { className: "revoked", children: "revoked" }) : /* @__PURE__ */ e(
362
+ "button",
363
+ {
364
+ type: "button",
365
+ "aria-label": `Revoke token ${T}`,
366
+ onClick: () => void O(n.id),
367
+ disabled: _ === n.id,
368
+ children: "Revoke"
369
+ }
370
+ )
371
+ ] }, n.id);
372
+ }) })
373
+ ] })
314
374
  ] });
315
375
  }
316
- function z({ hubUrl: c }) {
317
- const t = O(), [i, k] = a({ status: "loading" }), [m, C] = a(null), g = F(async () => {
376
+ function ee({ hubUrl: l }) {
377
+ const t = U(), [r, b] = i({ status: "loading" }), [d, y] = i(null), [C, g] = i(0), k = D(async () => {
318
378
  try {
319
- const o = await t.listWorkspaces();
320
- k({ status: "ready", workspaces: o.workspaces }), C(
321
- (w) => {
322
- var d;
323
- return w && o.workspaces.some((s) => s.id === w) ? w : ((d = o.workspaces[0]) == null ? void 0 : d.id) ?? null;
379
+ const h = await t.listWorkspaces();
380
+ b({ status: "ready", workspaces: h.workspaces }), y(
381
+ (s) => {
382
+ var p;
383
+ return s && h.workspaces.some((v) => v.id === s) ? s : ((p = h.workspaces[0]) == null ? void 0 : p.id) ?? null;
324
384
  }
325
385
  );
326
- } catch (o) {
327
- k({ status: "error", message: N(o) });
386
+ } catch (h) {
387
+ b({ status: "error", message: N(h) });
328
388
  }
329
389
  }, [t]);
330
- H(() => {
331
- g();
332
- }, [g]);
333
- const b = i.status === "ready" ? i.workspaces : [], u = b.find((o) => o.id === m) ?? null;
334
- if (i.status === "loading")
390
+ $(() => {
391
+ k();
392
+ }, [k]);
393
+ const m = r.status === "ready" ? r.workspaces : [], u = m.find((h) => h.id === d) ?? null;
394
+ if (r.status === "loading")
335
395
  return /* @__PURE__ */ e("div", { className: "shepherd-root", children: /* @__PURE__ */ e("p", { role: "status", children: "Loading…" }) });
336
- if (i.status === "error")
337
- return /* @__PURE__ */ e("div", { className: "shepherd-root", children: /* @__PURE__ */ e("p", { role: "alert", children: i.message }) });
338
- const p = b.length > 0, h = /* @__PURE__ */ y("section", { className: "shepherd-config", "aria-labelledby": "config-heading", children: [
396
+ if (r.status === "error")
397
+ return /* @__PURE__ */ e("div", { className: "shepherd-root", children: /* @__PURE__ */ e("p", { role: "alert", children: r.message }) });
398
+ const o = m.length > 0, w = /* @__PURE__ */ a("section", { className: "shepherd-config", "aria-labelledby": "config-heading", children: [
339
399
  /* @__PURE__ */ e("h2", { id: "config-heading", children: "Configuration" }),
340
400
  /* @__PURE__ */ e(
341
- M,
401
+ K,
342
402
  {
343
- workspaces: b,
403
+ workspaces: m,
344
404
  selected: u,
345
405
  onChanged: () => {
346
- g();
406
+ k();
347
407
  },
348
- onSelect: C
408
+ onSelect: y,
409
+ onMembersChanged: () => g((h) => h + 1)
410
+ }
411
+ ),
412
+ u && /* @__PURE__ */ e(
413
+ G,
414
+ {
415
+ workspaceId: u.id,
416
+ refreshKey: C,
417
+ canRemove: u.role === "admin",
418
+ onLeft: () => void k()
349
419
  }
350
420
  ),
351
- u && /* @__PURE__ */ e(J, { workspaceId: u.id, hubUrl: c })
421
+ u && /* @__PURE__ */ e(V, { workspaceId: u.id, hubUrl: l })
352
422
  ] });
353
423
  return /* @__PURE__ */ e("div", { className: "shepherd-root", children: /* @__PURE__ */ e(
354
- $,
424
+ W,
355
425
  {
356
426
  workspaceId: u == null ? void 0 : u.id,
357
- config: h,
358
- hasWorkspace: p
427
+ config: w,
428
+ hasWorkspace: o
359
429
  }
360
430
  ) });
361
431
  }
362
432
  export {
363
- J as ConnectAgent,
364
- $ as Dashboard,
365
- Y as EmptyState,
366
- K as Members,
367
- Z as ShepherdClientError,
368
- ee as ShepherdClientProvider,
369
- z as ShepherdRoot,
370
- M as Workspaces,
371
- ne as createShepherdClient,
433
+ V as ConnectAgent,
434
+ W as Dashboard,
435
+ ie as EmptyState,
436
+ G as Members,
437
+ ae as ShepherdClientError,
438
+ le as ShepherdClientProvider,
439
+ ee as ShepherdRoot,
440
+ K as Workspaces,
441
+ re as createShepherdClient,
372
442
  N as describeError,
373
- O as useShepherdClient
443
+ U as useShepherdClient
374
444
  };