bazilion 0.14.2 → 0.16.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.
Files changed (122) hide show
  1. package/dist/cli.js +1752 -825
  2. package/dist/cli.js.map +1 -1
  3. package/dist/daemon.js +16624 -9803
  4. package/dist/daemon.js.map +1 -1
  5. package/dist/migrations/0001_init.sql +218 -3
  6. package/dist/web/client/assets/ChatPane-CQZzxOir.js +76 -0
  7. package/dist/web/client/assets/{ConfirmDialog-_bmG-wVG.js → ConfirmDialog-MicTTwdy.js} +1 -1
  8. package/dist/web/client/assets/{FieldRow-Do1cBkRc.js → FieldRow-DJ2Gx4Du.js} +1 -1
  9. package/dist/web/client/assets/{ProductionTeamPolicyEditor-XP-QJul4.js → ProductionTeamPolicyEditor-DqUnN_ce.js} +1 -1
  10. package/dist/web/client/assets/{ProfileCommunicationEditor-CwdFPdpk.js → ProfileCommunicationEditor-DArXub0b.js} +1 -1
  11. package/dist/web/client/assets/ResultCard-Cps_lXVN.js +1 -0
  12. package/dist/web/client/assets/ResultSourceConversation-CtzJ8QA-.js +1 -0
  13. package/dist/web/client/assets/TeamTabs-DbIk5vvT.js +1 -0
  14. package/dist/web/client/assets/{TemplatesTabs-D4WHvs6b.js → TemplatesTabs-CatJIjGi.js} +1 -1
  15. package/dist/web/client/assets/{UnsavedChangesGuard-B1aLqiK5.js → UnsavedChangesGuard-BCsLw-mU.js} +1 -1
  16. package/dist/web/client/assets/_id-B5Ov7cdO.js +1 -0
  17. package/dist/web/client/assets/{_id-BH3v_vI_.js → _id-BEDmIXVf.js} +1 -1
  18. package/dist/web/client/assets/_id-BFM_tn_s.js +1 -0
  19. package/dist/web/client/assets/_id-CrnEVcw8.js +1 -0
  20. package/dist/web/client/assets/{_id-3w4PFfma.js → _id-DxopIW-y.js} +1 -1
  21. package/dist/web/client/assets/{activity-A_HrG1Tv.js → activity-CrG8Bg60.js} +1 -1
  22. package/dist/web/client/assets/{agents-C8OVKq3N.js → agents-CMPOFcs-.js} +1 -1
  23. package/dist/web/client/assets/{agents-BeeFCt2c.js → agents-O4soKZND.js} +1 -1
  24. package/dist/web/client/assets/{approvals-BIdZ9BSn.js → approvals-CwDu_lrA.js} +1 -1
  25. package/dist/web/client/assets/{attention-B9bUrxiU.js → attention-BY8MMuM_.js} +1 -1
  26. package/dist/web/client/assets/chevron-right-Cf6vKeLq.js +1 -0
  27. package/dist/web/client/assets/{config-By86S7k-.js → config-Cn4iBJFz.js} +1 -1
  28. package/dist/web/client/assets/{inbox-DlXQCJLe.js → inbox-CWXql0K3.js} +1 -1
  29. package/dist/web/client/assets/{index-CLdmsmiN.js → index-Bq2zrG2_.js} +2 -2
  30. package/dist/web/client/assets/{learning-BqZIw2nA.js → learning-DAm4dyyc.js} +1 -1
  31. package/dist/web/client/assets/login-BsABI8Ux.js +1 -0
  32. package/dist/web/client/assets/{mcp-DKSY2yVa.js → mcp-loLB0wuh.js} +1 -1
  33. package/dist/web/client/assets/{members-9GuOiq6J.js → members-BJ0ikkTl.js} +1 -1
  34. package/dist/web/client/assets/{memory-DiGMI6FC.js → memory-Drn9Gv53.js} +1 -1
  35. package/dist/web/client/assets/{policy-TBGQffw5.js → policy-pQadZyk0.js} +1 -1
  36. package/dist/web/client/assets/results-9exU6f7m.js +1 -0
  37. package/dist/web/client/assets/routes-jw1PuqiR.js +1 -0
  38. package/dist/web/client/assets/{services-1Z398CES.js → services-BLso1BhA.js} +1 -1
  39. package/dist/web/client/assets/{skills-BP2gciFt.js → skills-BodqX3OI.js} +1 -1
  40. package/dist/web/client/assets/styles-d1yjBpud.css +2 -0
  41. package/dist/web/client/assets/{teams-DBIivGT7.js → teams-ByQedXZi.js} +1 -1
  42. package/dist/web/client/assets/{teams-tNoMDJ_M.js → teams-SYsF1bOR.js} +1 -1
  43. package/dist/web/client/assets/telegram-DC9PLFbB.js +1 -0
  44. package/dist/web/client/assets/{tokens-eDWCGQQ2.js → tokens-DGy8Ijpo.js} +1 -1
  45. package/dist/web/client/assets/{triggers-DZME3IcK.js → triggers-BXpVmHDG.js} +1 -1
  46. package/dist/web/client/assets/{welcome-B49sh_uf.js → welcome-BKsnsCxJ.js} +1 -1
  47. package/dist/web/client/assets/wire-constants-CBD-lTaa.js +1 -0
  48. package/dist/web/client/assets/{x-CHc7_-TH.js → x-BK4xNCzS.js} +1 -1
  49. package/dist/web/server/assets/ChatPane-CS5oI7ef.js +2666 -0
  50. package/dist/web/server/assets/ResultCard-B3zD9N0t.js +143 -0
  51. package/dist/web/server/assets/ResultSourceConversation-BpVWBRYq.js +64 -0
  52. package/dist/web/server/assets/{TeamTabs-Co3n2exj.js → TeamTabs-TCKjCvMA.js} +4 -0
  53. package/dist/web/server/assets/{_id-sNu5aXZt.js → _id-5pgKoid8.js} +2 -1
  54. package/dist/web/server/assets/_id-BDEpe6k0.js +6 -0
  55. package/dist/web/server/assets/{_id-DxCnEFpm.js → _id-BG2nkGxa.js} +3 -4
  56. package/dist/web/server/assets/{_id-BqWTB8Wl.js → _id-B_-CDHOi2.js} +1 -1
  57. package/dist/web/server/assets/{_id-BeKhPKw3.js → _id-BnqodC1c2.js} +7 -3
  58. package/dist/web/server/assets/{_id-DvlDkk04.js → _id-CeyHEsCZ.js} +1 -1
  59. package/dist/web/server/assets/{_id-BYKpT2Tu.js → _id-DFHB9JFQ.js} +1 -1
  60. package/dist/web/server/assets/{_id-DYU6uIBx.js → _id-DOnInzLb.js} +1 -1
  61. package/dist/web/server/assets/{_id-HMy7jM3P.js → _id-DrB9uR1b.js} +1 -1
  62. package/dist/web/server/assets/{_id-BAA9KJBU.js → _id-DtIYuJJX.js} +1 -1
  63. package/dist/web/server/assets/_id-DwZXhLlL.js +779 -0
  64. package/dist/web/server/assets/_id-wyjrf0JG.js +17 -0
  65. package/dist/web/server/assets/{_tanstack-start-manifest_v-Duhf0z7H.js → _tanstack-start-manifest_v-D7gKv6m6.js} +97 -70
  66. package/dist/web/server/assets/{activity-9VP6QDTH.js → activity-0VUkStOu.js} +1 -1
  67. package/dist/web/server/assets/{activity-BWv1goK6.js → activity-5fWKPDxj.js} +2 -2
  68. package/dist/web/server/assets/{activity-LjpblbDL.js → activity-C88qrNqv.js} +1 -1
  69. package/dist/web/server/assets/{agents-DjyQk94u.js → agents-C86K6HvS.js} +1 -1
  70. package/dist/web/server/assets/{agents-BJAv919x.js → agents-CSXLaM2W.js} +1 -1
  71. package/dist/web/server/assets/{approvals-BYi84gwl.js → approvals-C3MysI6l.js} +1 -1
  72. package/dist/web/server/assets/{approvals-7JOoBchn.js → approvals-DTdrltyk.js} +1 -1
  73. package/dist/web/server/assets/{approvals-Bz123liE.js → approvals-DXoN-T57.js} +15 -1
  74. package/dist/web/server/assets/{attention-UhqPK_Ro.js → attention-DLeLCKah.js} +1 -1
  75. package/dist/web/server/assets/{auth-7BHTH-KS.js → auth-CDZp9aEk.js} +1 -1
  76. package/dist/web/server/assets/{config-BMiajTZP.js → config-BVTHvljR.js} +1 -1
  77. package/dist/web/server/assets/{daemon-client-CI5NHwNC.js → daemon-client-xWyYKAcx.js} +59 -0
  78. package/dist/web/server/assets/{inbox-Dv55rGYq.js → inbox-PQTrjtOw.js} +1 -1
  79. package/dist/web/server/assets/{learning-C2upa1CE.js → learning-K0cmDsZR.js} +1 -1
  80. package/dist/web/server/assets/{login-BNj3U6ok.js → login-B_-9L8TU.js} +7 -2
  81. package/dist/web/server/assets/{login-Be8eP4Jp.js → login-rDox7PRD.js} +5 -2
  82. package/dist/web/server/assets/{mcp-BvnvlVFd.js → mcp-Rtraochg.js} +1 -1
  83. package/dist/web/server/assets/{members-DiYtr-zm.js → members-CD3GiTfF.js} +1 -1
  84. package/dist/web/server/assets/{members-DHYTVgwb.js → members-cc5SeEaW.js} +2 -2
  85. package/dist/web/server/assets/{members-BP3UTqu1.js → members-grAKFWgv.js} +1 -1
  86. package/dist/web/server/assets/{memory-CkXUgf5s.js → memory-C5i_GxlY.js} +2 -2
  87. package/dist/web/server/assets/{memory-DTFEmfF3.js → memory-CVqnyUaM.js} +1 -1
  88. package/dist/web/server/assets/{memory-BqV-Afy1.js → memory-egFpBD1g.js} +1 -1
  89. package/dist/web/server/assets/{policy-Bvvav8fh.js → policy-Dgjb0_gK.js} +2 -2
  90. package/dist/web/server/assets/{policy-BddK4xom.js → policy-bLKwvnja.js} +1 -1
  91. package/dist/web/server/assets/{policy-18fdTFO4.js → policy-ooSBgiDS.js} +1 -1
  92. package/dist/web/server/assets/results-CfNsFncJ.js +173 -0
  93. package/dist/web/server/assets/results-DXdYtHaq.js +12 -0
  94. package/dist/web/server/assets/results-N-kP4iFT.js +12 -0
  95. package/dist/web/server/assets/{router-CY_pCgP1.js → router-B6g_s7W3.js} +60 -43
  96. package/dist/web/server/assets/{routes-COtkyZG1.js → routes-BqSaZvlu.js} +3 -3
  97. package/dist/web/server/assets/{routes-BgHisAxH.js → routes-Dsh8F_7i.js} +2 -2
  98. package/dist/web/server/assets/{routes-DAU2g7Uz.js → routes-pcRy_Sf8.js} +1 -1
  99. package/dist/web/server/assets/{services-DozuJtzX.js → services-DlZA8fRL.js} +1 -1
  100. package/dist/web/server/assets/{skills-DfGSJTCB.js → skills-i2duvgW-.js} +1 -1
  101. package/dist/web/server/assets/{teams-be05ci17.js → teams-6RYIj1Xm.js} +1 -1
  102. package/dist/web/server/assets/{teams-DPnAX4wD.js → teams-B1AI3NfN.js} +1 -1
  103. package/dist/web/server/assets/{telegram-1AWL6lFw.js → telegram-C4q0YTVn.js} +1 -1
  104. package/dist/web/server/assets/{telegram-Dj4Wwhd6.js → telegram-CoNeOgqZ.js} +465 -1
  105. package/dist/web/server/assets/{telegram-DbOFpTFm.js → telegram-Zd1rIZxg.js} +1 -1
  106. package/dist/web/server/assets/{tokens-DjM8GsgS.js → tokens-RFquA2Bx.js} +1 -1
  107. package/dist/web/server/assets/{triggers-Nezfw-Bd.js → triggers-DVD-iE-N.js} +1 -1
  108. package/dist/web/server/server.js +31 -27
  109. package/dist/worker.js +1765 -710
  110. package/dist/worker.js.map +1 -1
  111. package/package.json +3 -3
  112. package/dist/web/client/assets/TeamTabs-DIRiKcqx.js +0 -1
  113. package/dist/web/client/assets/_id-Cx7o4Zmf.js +0 -1
  114. package/dist/web/client/assets/_id-DIiVVxBl.js +0 -1
  115. package/dist/web/client/assets/chevron-right-VWrk_dTX.js +0 -1
  116. package/dist/web/client/assets/login-CCMPXiny.js +0 -1
  117. package/dist/web/client/assets/routes-g3yUOhCb.js +0 -1
  118. package/dist/web/client/assets/styles-B5vcgXln.css +0 -2
  119. package/dist/web/client/assets/telegram-CJG_DFdI.js +0 -1
  120. package/dist/web/client/assets/wire-constants-zZ7Wjb9C.js +0 -74
  121. package/dist/web/server/assets/ChatPane-CgSe7tsy.js +0 -1429
  122. package/dist/web/server/assets/_id-ndxFHx0t.js +0 -381
@@ -1,381 +0,0 @@
1
- import { t as Route } from "./_id-BAA9KJBU.js";
2
- import { a as StatusBadge, i as SectionCard, r as PageShell } from "./Page-Bz-ydB8j.js";
3
- import { t as Button } from "./Button-Dsnw22OF.js";
4
- import { t as TeamTabs } from "./TeamTabs-Co3n2exj.js";
5
- import { t as UnsavedChangesGuard } from "./UnsavedChangesGuard-CiStXyBI.js";
6
- import { useEffect, useState } from "react";
7
- import { useRouter } from "@tanstack/react-router";
8
- import { jsx, jsxs } from "react/jsx-runtime";
9
- //#region src/routes/teams/$id/index.tsx?tsr-split=component
10
- function TeamDetailPage() {
11
- const { team, members, profileGroups } = Route.useLoaderData();
12
- const router = useRouter();
13
- const [userMd, setUserMd] = useState(team.userMd);
14
- const [busy, setBusy] = useState(false);
15
- const [err, setErr] = useState(null);
16
- const [savedAt, setSavedAt] = useState(null);
17
- const [topicDirty, setTopicDirty] = useState(false);
18
- const contextDirty = userMd !== team.userMd || topicDirty;
19
- async function save() {
20
- setBusy(true);
21
- setErr(null);
22
- try {
23
- const res = await fetch(`/api/teams/${encodeURIComponent(team.id)}/user-md`, {
24
- method: "PUT",
25
- headers: { "content-type": "application/json" },
26
- body: JSON.stringify({ userMd })
27
- });
28
- if (!res.ok) {
29
- const e = await res.json().catch(() => ({}));
30
- throw new Error(e.error ?? `${res.status} ${res.statusText}`);
31
- }
32
- setSavedAt(Date.now());
33
- await router.invalidate();
34
- } catch (e) {
35
- setErr(e.message);
36
- } finally {
37
- setBusy(false);
38
- }
39
- }
40
- return /* @__PURE__ */ jsxs(PageShell, { children: [
41
- /* @__PURE__ */ jsx(UnsavedChangesGuard, {
42
- when: contextDirty,
43
- subject: "Team context"
44
- }),
45
- /* @__PURE__ */ jsxs("h1", {
46
- className: "font-serif text-3xl text-foreground",
47
- children: [
48
- team.name,
49
- " ",
50
- /* @__PURE__ */ jsxs("span", {
51
- className: "text-muted-foreground text-base",
52
- children: [
53
- "(",
54
- team.id,
55
- ")"
56
- ]
57
- })
58
- ]
59
- }),
60
- /* @__PURE__ */ jsxs("p", {
61
- className: "text-muted-foreground text-sm mb-6 mt-1",
62
- children: [
63
- /* @__PURE__ */ jsx("code", {
64
- className: "font-mono",
65
- children: team.path
66
- }),
67
- " · ",
68
- members.length,
69
- " ",
70
- "member",
71
- members.length === 1 ? "" : "s",
72
- " ·",
73
- " ",
74
- /* @__PURE__ */ jsx("a", {
75
- href: `/teams/${encodeURIComponent(team.id)}/memory`,
76
- className: "text-primary underline",
77
- children: "shared memory →"
78
- })
79
- ]
80
- }),
81
- /* @__PURE__ */ jsx(TeamTabs, { teamId: team.id }),
82
- /* @__PURE__ */ jsxs("section", {
83
- className: "rounded-lg border bg-card p-5 mb-6",
84
- children: [
85
- /* @__PURE__ */ jsx("h3", {
86
- className: "font-serif text-xl mb-1",
87
- children: "USER.md"
88
- }),
89
- /* @__PURE__ */ jsx("p", {
90
- className: "text-muted-foreground text-sm mb-3",
91
- children: "Read-only context about the human, injected into every member agent's system prompt. 12 KB cap. Agents cannot edit this file — only you can."
92
- }),
93
- /* @__PURE__ */ jsx("label", {
94
- htmlFor: "team-user-context",
95
- className: "sr-only",
96
- children: "USER.md Team context"
97
- }),
98
- /* @__PURE__ */ jsx("textarea", {
99
- id: "team-user-context",
100
- value: userMd,
101
- onChange: (e) => setUserMd(e.target.value),
102
- rows: 16,
103
- className: "w-full rounded-md border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-ring/30",
104
- placeholder: "What the agent should know about you in this team context…"
105
- }),
106
- /* @__PURE__ */ jsxs("div", {
107
- className: "flex items-center gap-3 mt-3",
108
- children: [
109
- /* @__PURE__ */ jsx(Button, {
110
- variant: "primary",
111
- onClick: save,
112
- disabled: busy || userMd === team.userMd,
113
- children: busy ? "saving…" : "save"
114
- }),
115
- /* @__PURE__ */ jsxs("span", {
116
- className: "text-xs text-muted-foreground",
117
- children: [userMd.length, " / 12000 chars"]
118
- }),
119
- savedAt && /* @__PURE__ */ jsx("span", {
120
- role: "status",
121
- className: "text-xs text-success",
122
- children: "Saved"
123
- }),
124
- err && /* @__PURE__ */ jsx("span", {
125
- role: "alert",
126
- className: "text-xs text-danger",
127
- children: err
128
- })
129
- ]
130
- })
131
- ]
132
- }),
133
- /* @__PURE__ */ jsx(TopicNameFormatCard, {
134
- team,
135
- sampleAgent: members[0]?.name ?? "researcher",
136
- onSaved: () => router.invalidate(),
137
- onDirtyChange: setTopicDirty
138
- }),
139
- members.length === 0 && /* @__PURE__ */ jsx(SpawnFromTemplateCard, {
140
- teamId: team.id,
141
- profileGroups,
142
- onSpawned: () => router.invalidate()
143
- }),
144
- /* @__PURE__ */ jsx(SectionCard, {
145
- title: "Roster",
146
- description: "Live Team membership has one canonical management view.",
147
- actions: /* @__PURE__ */ jsxs(StatusBadge, {
148
- variant: members.length > 0 ? "success" : "neutral",
149
- children: [
150
- members.length,
151
- " member",
152
- members.length === 1 ? "" : "s"
153
- ]
154
- }),
155
- children: /* @__PURE__ */ jsx("a", {
156
- href: `/teams/${encodeURIComponent(team.id)}/members`,
157
- className: "ghost-btn",
158
- children: "Manage Team members"
159
- })
160
- })
161
- ] });
162
- }
163
- function TopicNameFormatCard({ team, sampleAgent, onSaved, onDirtyChange }) {
164
- const [format, setFormat] = useState(team.telegramTopicNameFormat ?? "");
165
- const [busy, setBusy] = useState(false);
166
- const [err, setErr] = useState(null);
167
- const [savedAt, setSavedAt] = useState(null);
168
- const trimmed = format.trim();
169
- const preview = trimmed ? trimmed.replaceAll("{agent.name}", sampleAgent).replaceAll("{team.name}", team.name).replaceAll("{team.slug}", team.id) : team.id === "default" ? sampleAgent : `${team.id} › ${sampleAgent}`;
170
- const dirty = (team.telegramTopicNameFormat ?? "") !== format;
171
- useEffect(() => {
172
- onDirtyChange(dirty);
173
- return () => onDirtyChange(false);
174
- }, [dirty, onDirtyChange]);
175
- async function save(clear) {
176
- setBusy(true);
177
- setErr(null);
178
- try {
179
- const res = await fetch(`/api/teams/${encodeURIComponent(team.id)}/topic-format`, {
180
- method: "PUT",
181
- headers: { "content-type": "application/json" },
182
- body: JSON.stringify({ format: clear ? null : format })
183
- });
184
- if (!res.ok) {
185
- const e = await res.json().catch(() => ({}));
186
- throw new Error(e.error ?? `${res.status} ${res.statusText}`);
187
- }
188
- if (clear) setFormat("");
189
- setSavedAt(Date.now());
190
- onSaved();
191
- } catch (e) {
192
- setErr(e.message);
193
- } finally {
194
- setBusy(false);
195
- }
196
- }
197
- return /* @__PURE__ */ jsxs("section", {
198
- className: "rounded-lg border bg-card p-5 mb-6",
199
- children: [
200
- /* @__PURE__ */ jsx("h3", {
201
- className: "font-serif text-xl mb-1",
202
- children: "Telegram topic names"
203
- }),
204
- /* @__PURE__ */ jsxs("p", {
205
- className: "text-muted-foreground text-sm mb-3",
206
- children: [
207
- "Template for this team's Telegram forum-topic titles. Leave empty for built-in naming. Tokens: ",
208
- /* @__PURE__ */ jsx("code", {
209
- className: "font-mono",
210
- children: "{agent.name}"
211
- }),
212
- " ",
213
- /* @__PURE__ */ jsx("code", {
214
- className: "font-mono",
215
- children: "{team.name}"
216
- }),
217
- " ",
218
- /* @__PURE__ */ jsx("code", {
219
- className: "font-mono",
220
- children: "{team.slug}"
221
- }),
222
- " — must include",
223
- " ",
224
- /* @__PURE__ */ jsx("code", {
225
- className: "font-mono",
226
- children: "{agent.name}"
227
- }),
228
- ". Saving renames existing topics that you haven't manually renamed in Telegram."
229
- ]
230
- }),
231
- /* @__PURE__ */ jsx("label", {
232
- htmlFor: "team-telegram-topic-format",
233
- className: "sr-only",
234
- children: "Telegram topic name format"
235
- }),
236
- /* @__PURE__ */ jsx("input", {
237
- id: "team-telegram-topic-format",
238
- value: format,
239
- onChange: (e) => setFormat(e.target.value),
240
- placeholder: "{team.name} / {agent.name}",
241
- className: "w-full rounded-md border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-ring/30"
242
- }),
243
- /* @__PURE__ */ jsxs("p", {
244
- className: "text-xs text-muted-foreground mt-2",
245
- children: ["preview: ", /* @__PURE__ */ jsx("span", {
246
- className: "font-mono text-foreground",
247
- children: preview
248
- })]
249
- }),
250
- /* @__PURE__ */ jsxs("div", {
251
- className: "flex items-center gap-3 mt-3",
252
- children: [
253
- /* @__PURE__ */ jsx(Button, {
254
- variant: "primary",
255
- onClick: () => save(false),
256
- disabled: busy || !dirty || trimmed.length === 0,
257
- children: busy ? "saving…" : "save"
258
- }),
259
- team.telegramTopicNameFormat && /* @__PURE__ */ jsx(Button, {
260
- variant: "ghost",
261
- onClick: () => save(true),
262
- disabled: busy,
263
- children: "clear"
264
- }),
265
- savedAt && /* @__PURE__ */ jsx("span", {
266
- role: "status",
267
- className: "text-xs text-success",
268
- children: "Saved"
269
- }),
270
- err && /* @__PURE__ */ jsx("span", {
271
- role: "alert",
272
- className: "text-xs text-danger",
273
- children: err
274
- })
275
- ]
276
- })
277
- ]
278
- });
279
- }
280
- function SpawnFromTemplateCard({ teamId, profileGroups, onSpawned }) {
281
- const eligible = profileGroups.filter((g) => g.slotCount > 0 && !g.deletedAt);
282
- const [selected, setSelected] = useState(eligible[0]?.id ?? "");
283
- const [busy, setBusy] = useState(false);
284
- const [err, setErr] = useState(null);
285
- async function spawn() {
286
- if (!selected) return;
287
- setBusy(true);
288
- setErr(null);
289
- try {
290
- const template = eligible.find((item) => item.id === selected);
291
- if (!template) throw new Error("Team template is unavailable.");
292
- const policyResponse = await fetch(`/api/teams/${encodeURIComponent(teamId)}/policy`);
293
- if (!policyResponse.ok) throw new Error("The current Team policy is unavailable.");
294
- const current = await policyResponse.json();
295
- const res = await fetch(`/api/team-templates/${encodeURIComponent(selected)}/spawn`, {
296
- method: "POST",
297
- headers: { "content-type": "application/json" },
298
- body: JSON.stringify({
299
- templateExpectedRevision: template.currentRevision,
300
- teamId,
301
- teamExpectedRevision: current.teamPolicy.revision,
302
- mode: "initialize"
303
- })
304
- });
305
- if (!res.ok) {
306
- const e = await res.json().catch(() => ({}));
307
- throw new Error(e.error ?? `${res.status} ${res.statusText}`);
308
- }
309
- onSpawned();
310
- } catch (e) {
311
- setErr(e.message);
312
- } finally {
313
- setBusy(false);
314
- }
315
- }
316
- return /* @__PURE__ */ jsxs("section", {
317
- className: "rounded-lg border bg-card p-5 mb-6",
318
- children: [
319
- /* @__PURE__ */ jsx("h3", {
320
- className: "font-serif text-xl mb-1",
321
- children: "spawn a team into this team"
322
- }),
323
- /* @__PURE__ */ jsx("p", {
324
- className: "text-muted-foreground text-sm mb-3",
325
- children: "This Team is empty. Pick a canonical Team template to initialize its roster and policy at the current reviewed Team and Team revisions."
326
- }),
327
- eligible.length === 0 ? /* @__PURE__ */ jsxs("p", {
328
- className: "text-muted-foreground text-sm",
329
- children: [
330
- "No Team templates with slots yet. Build one on",
331
- " ",
332
- /* @__PURE__ */ jsx("a", {
333
- href: "/templates/teams",
334
- className: "text-primary underline",
335
- children: "Team templates"
336
- }),
337
- " ",
338
- "first."
339
- ]
340
- }) : /* @__PURE__ */ jsxs("div", {
341
- className: "flex flex-wrap items-end gap-3",
342
- children: [
343
- /* @__PURE__ */ jsxs("label", {
344
- className: "m-0 flex min-w-0 flex-1 flex-col gap-1 text-sm text-foreground",
345
- children: ["Team template", /* @__PURE__ */ jsx("select", {
346
- value: selected,
347
- onChange: (e) => setSelected(e.target.value),
348
- className: "min-w-0 rounded-md border bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring/30",
349
- children: eligible.map((g) => /* @__PURE__ */ jsxs("option", {
350
- value: g.id,
351
- children: [
352
- g.name,
353
- " (",
354
- g.slotCount,
355
- " slot",
356
- g.slotCount === 1 ? "" : "s",
357
- ", r",
358
- g.currentRevision,
359
- ")"
360
- ]
361
- }, g.id))
362
- })]
363
- }),
364
- /* @__PURE__ */ jsx(Button, {
365
- variant: "primary",
366
- onClick: spawn,
367
- disabled: busy || !selected,
368
- children: busy ? "spawning…" : "spawn team"
369
- }),
370
- err && /* @__PURE__ */ jsx("span", {
371
- role: "alert",
372
- className: "basis-full text-xs text-danger",
373
- children: err
374
- })
375
- ]
376
- })
377
- ]
378
- });
379
- }
380
- //#endregion
381
- export { TeamDetailPage as component };