@kelpie/ui 0.21.0 → 0.23.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 (254) hide show
  1. package/dist/api/resource.d.ts +12 -0
  2. package/dist/api/resource.d.ts.map +1 -1
  3. package/dist/api/resource.js +11 -0
  4. package/dist/api/resource.js.map +1 -1
  5. package/dist/api/resources/decisions.d.ts +31 -0
  6. package/dist/api/resources/decisions.d.ts.map +1 -1
  7. package/dist/api/resources/decisions.js +51 -1
  8. package/dist/api/resources/decisions.js.map +1 -1
  9. package/dist/api/resources/forms.d.ts +21 -7
  10. package/dist/api/resources/forms.d.ts.map +1 -1
  11. package/dist/api/resources/forms.js +39 -1
  12. package/dist/api/resources/forms.js.map +1 -1
  13. package/dist/api/resources/oauth.d.ts +2 -0
  14. package/dist/api/resources/oauth.d.ts.map +1 -1
  15. package/dist/api/resources/oauth.js +13 -1
  16. package/dist/api/resources/oauth.js.map +1 -1
  17. package/dist/api/resources/personIntake.d.ts +15 -3
  18. package/dist/api/resources/personIntake.d.ts.map +1 -1
  19. package/dist/api/resources/personIntake.js +38 -9
  20. package/dist/api/resources/personIntake.js.map +1 -1
  21. package/dist/api/resources/session.d.ts.map +1 -1
  22. package/dist/api/resources/session.js +4 -0
  23. package/dist/api/resources/session.js.map +1 -1
  24. package/dist/api/resources/tags.d.ts +20 -0
  25. package/dist/api/resources/tags.d.ts.map +1 -0
  26. package/dist/api/resources/tags.js +52 -0
  27. package/dist/api/resources/tags.js.map +1 -0
  28. package/dist/app/KelpieApp.d.ts.map +1 -1
  29. package/dist/app/KelpieApp.js +2 -1
  30. package/dist/app/KelpieApp.js.map +1 -1
  31. package/dist/components/AddRecordPanel.d.ts +35 -0
  32. package/dist/components/AddRecordPanel.d.ts.map +1 -0
  33. package/dist/components/AddRecordPanel.js +35 -0
  34. package/dist/components/AddRecordPanel.js.map +1 -0
  35. package/dist/components/AiDrawer.d.ts.map +1 -1
  36. package/dist/components/AiDrawer.js +29 -6
  37. package/dist/components/AiDrawer.js.map +1 -1
  38. package/dist/components/ApiKeysPanel.d.ts.map +1 -1
  39. package/dist/components/ApiKeysPanel.js +101 -44
  40. package/dist/components/ApiKeysPanel.js.map +1 -1
  41. package/dist/components/Chip.d.ts +5 -1
  42. package/dist/components/Chip.d.ts.map +1 -1
  43. package/dist/components/Chip.js +8 -2
  44. package/dist/components/Chip.js.map +1 -1
  45. package/dist/components/CustomFieldsPanel.d.ts.map +1 -1
  46. package/dist/components/CustomFieldsPanel.js +5 -2
  47. package/dist/components/CustomFieldsPanel.js.map +1 -1
  48. package/dist/components/DecisionProvenance.d.ts +27 -0
  49. package/dist/components/DecisionProvenance.d.ts.map +1 -0
  50. package/dist/components/DecisionProvenance.js +53 -0
  51. package/dist/components/DecisionProvenance.js.map +1 -0
  52. package/dist/components/DecisionsPanel.d.ts +3 -0
  53. package/dist/components/DecisionsPanel.d.ts.map +1 -1
  54. package/dist/components/DecisionsPanel.js +9 -5
  55. package/dist/components/DecisionsPanel.js.map +1 -1
  56. package/dist/components/MarkdownView.d.ts.map +1 -1
  57. package/dist/components/MarkdownView.js +18 -2
  58. package/dist/components/MarkdownView.js.map +1 -1
  59. package/dist/components/NotesPanel.d.ts.map +1 -1
  60. package/dist/components/NotesPanel.js +7 -3
  61. package/dist/components/NotesPanel.js.map +1 -1
  62. package/dist/components/OriginLabel.d.ts +5 -0
  63. package/dist/components/OriginLabel.d.ts.map +1 -0
  64. package/dist/components/OriginLabel.js +22 -0
  65. package/dist/components/OriginLabel.js.map +1 -0
  66. package/dist/components/Shell.d.ts.map +1 -1
  67. package/dist/components/Shell.js +17 -5
  68. package/dist/components/Shell.js.map +1 -1
  69. package/dist/components/TagInput.d.ts +29 -0
  70. package/dist/components/TagInput.d.ts.map +1 -0
  71. package/dist/components/TagInput.js +139 -0
  72. package/dist/components/TagInput.js.map +1 -0
  73. package/dist/components/aiDrawerState.d.ts +12 -0
  74. package/dist/components/aiDrawerState.d.ts.map +1 -1
  75. package/dist/components/aiDrawerState.js.map +1 -1
  76. package/dist/components/personIntakeTask.d.ts +15 -0
  77. package/dist/components/personIntakeTask.d.ts.map +1 -1
  78. package/dist/components/personIntakeTask.js +42 -0
  79. package/dist/components/personIntakeTask.js.map +1 -1
  80. package/dist/lib/personIntakeRunStorage.d.ts +15 -0
  81. package/dist/lib/personIntakeRunStorage.d.ts.map +1 -0
  82. package/dist/lib/personIntakeRunStorage.js +88 -0
  83. package/dist/lib/personIntakeRunStorage.js.map +1 -0
  84. package/dist/modules/PersonIntakeWizard.d.ts +1 -1
  85. package/dist/modules/PersonIntakeWizard.d.ts.map +1 -1
  86. package/dist/modules/PersonIntakeWizard.js +243 -29
  87. package/dist/modules/PersonIntakeWizard.js.map +1 -1
  88. package/dist/modules/ai.d.ts +1 -1
  89. package/dist/modules/ai.js +1 -1
  90. package/dist/pages/CompaniesPage.d.ts.map +1 -1
  91. package/dist/pages/CompaniesPage.js +13 -6
  92. package/dist/pages/CompaniesPage.js.map +1 -1
  93. package/dist/pages/CompanyDetail.d.ts.map +1 -1
  94. package/dist/pages/CompanyDetail.js +4 -3
  95. package/dist/pages/CompanyDetail.js.map +1 -1
  96. package/dist/pages/DealDetail.d.ts.map +1 -1
  97. package/dist/pages/DealDetail.js +4 -3
  98. package/dist/pages/DealDetail.js.map +1 -1
  99. package/dist/pages/DealsPage.d.ts.map +1 -1
  100. package/dist/pages/DealsPage.js +16 -8
  101. package/dist/pages/DealsPage.js.map +1 -1
  102. package/dist/pages/DecisionsPage.d.ts.map +1 -1
  103. package/dist/pages/DecisionsPage.js +7 -3
  104. package/dist/pages/DecisionsPage.js.map +1 -1
  105. package/dist/pages/EnquiriesPage.d.ts.map +1 -1
  106. package/dist/pages/EnquiriesPage.js +14 -6
  107. package/dist/pages/EnquiriesPage.js.map +1 -1
  108. package/dist/pages/EnquiryDetail.js +4 -4
  109. package/dist/pages/EnquiryDetail.js.map +1 -1
  110. package/dist/pages/EventDetail.js +4 -4
  111. package/dist/pages/EventDetail.js.map +1 -1
  112. package/dist/pages/FundraisingPage.d.ts.map +1 -1
  113. package/dist/pages/FundraisingPage.js +16 -11
  114. package/dist/pages/FundraisingPage.js.map +1 -1
  115. package/dist/pages/OpportunitiesPage.d.ts.map +1 -1
  116. package/dist/pages/OpportunitiesPage.js +14 -6
  117. package/dist/pages/OpportunitiesPage.js.map +1 -1
  118. package/dist/pages/OpportunityDetail.js +4 -4
  119. package/dist/pages/OpportunityDetail.js.map +1 -1
  120. package/dist/pages/PartnershipDetail.js +4 -4
  121. package/dist/pages/PartnershipDetail.js.map +1 -1
  122. package/dist/pages/PartnershipsPage.d.ts.map +1 -1
  123. package/dist/pages/PartnershipsPage.js +16 -11
  124. package/dist/pages/PartnershipsPage.js.map +1 -1
  125. package/dist/pages/PeoplePage.d.ts.map +1 -1
  126. package/dist/pages/PeoplePage.js +13 -8
  127. package/dist/pages/PeoplePage.js.map +1 -1
  128. package/dist/pages/PersonDetail.js +7 -7
  129. package/dist/pages/PersonDetail.js.map +1 -1
  130. package/dist/pages/RaiseDetail.js +4 -4
  131. package/dist/pages/RaiseDetail.js.map +1 -1
  132. package/dist/pages/SearchPage.d.ts.map +1 -1
  133. package/dist/pages/SearchPage.js +2 -1
  134. package/dist/pages/SearchPage.js.map +1 -1
  135. package/dist/pages/account/ConnectedAppsPage.d.ts +0 -5
  136. package/dist/pages/account/ConnectedAppsPage.d.ts.map +1 -1
  137. package/dist/pages/account/ConnectedAppsPage.js +38 -6
  138. package/dist/pages/account/ConnectedAppsPage.js.map +1 -1
  139. package/dist/pages/admin/AgentsPanel.d.ts +10 -0
  140. package/dist/pages/admin/AgentsPanel.d.ts.map +1 -0
  141. package/dist/pages/admin/AgentsPanel.js +81 -0
  142. package/dist/pages/admin/AgentsPanel.js.map +1 -0
  143. package/dist/pages/admin/AiAdminPage.d.ts.map +1 -1
  144. package/dist/pages/admin/AiAdminPage.js +9 -6
  145. package/dist/pages/admin/AiAdminPage.js.map +1 -1
  146. package/dist/pages/admin/AiPage.js +1 -1
  147. package/dist/pages/admin/TeamPage.d.ts.map +1 -1
  148. package/dist/pages/admin/TeamPage.js +16 -3
  149. package/dist/pages/admin/TeamPage.js.map +1 -1
  150. package/dist/pages/ai/AiAccessPage.d.ts +11 -0
  151. package/dist/pages/ai/AiAccessPage.d.ts.map +1 -0
  152. package/dist/pages/ai/AiAccessPage.js +16 -0
  153. package/dist/pages/ai/AiAccessPage.js.map +1 -0
  154. package/dist/pages/ai/McpPanel.d.ts +7 -0
  155. package/dist/pages/ai/McpPanel.d.ts.map +1 -0
  156. package/dist/pages/ai/McpPanel.js +86 -0
  157. package/dist/pages/ai/McpPanel.js.map +1 -0
  158. package/dist/pages/auth/nextPath.d.ts +6 -0
  159. package/dist/pages/auth/nextPath.d.ts.map +1 -1
  160. package/dist/pages/auth/nextPath.js +16 -1
  161. package/dist/pages/auth/nextPath.js.map +1 -1
  162. package/dist/pages/dashboard/sections.d.ts.map +1 -1
  163. package/dist/pages/dashboard/sections.js +4 -2
  164. package/dist/pages/dashboard/sections.js.map +1 -1
  165. package/dist/pages/forms/EmbedPanel.js +1 -1
  166. package/dist/pages/forms/EmbedPanel.js.map +1 -1
  167. package/dist/pages/forms/FieldsEditor.d.ts.map +1 -1
  168. package/dist/pages/forms/FieldsEditor.js +6 -7
  169. package/dist/pages/forms/FieldsEditor.js.map +1 -1
  170. package/dist/pages/forms/FormActions.d.ts.map +1 -1
  171. package/dist/pages/forms/FormActions.js +4 -11
  172. package/dist/pages/forms/FormActions.js.map +1 -1
  173. package/dist/pages/forms/FormEmails.d.ts.map +1 -1
  174. package/dist/pages/forms/FormEmails.js +6 -1
  175. package/dist/pages/forms/FormEmails.js.map +1 -1
  176. package/dist/pages/forms/FormSettings.d.ts.map +1 -1
  177. package/dist/pages/forms/FormSettings.js +6 -2
  178. package/dist/pages/forms/FormSettings.js.map +1 -1
  179. package/dist/pages/forms/SubmissionDetail.d.ts.map +1 -1
  180. package/dist/pages/forms/SubmissionDetail.js +26 -6
  181. package/dist/pages/forms/SubmissionDetail.js.map +1 -1
  182. package/dist/pages/forms/SubmissionsTable.d.ts.map +1 -1
  183. package/dist/pages/forms/SubmissionsTable.js +81 -6
  184. package/dist/pages/forms/SubmissionsTable.js.map +1 -1
  185. package/dist/pages/forms/fieldList.d.ts +13 -5
  186. package/dist/pages/forms/fieldList.d.ts.map +1 -1
  187. package/dist/pages/forms/fieldList.js +12 -4
  188. package/dist/pages/forms/fieldList.js.map +1 -1
  189. package/dist/pages/oauth/ConsentPage.d.ts.map +1 -1
  190. package/dist/pages/oauth/ConsentPage.js +132 -15
  191. package/dist/pages/oauth/ConsentPage.js.map +1 -1
  192. package/dist/registry/contributions.d.ts +1 -1
  193. package/package.json +3 -3
  194. package/src/api/resource.ts +16 -0
  195. package/src/api/resources/decisions.ts +81 -1
  196. package/src/api/resources/forms.ts +68 -7
  197. package/src/api/resources/oauth.ts +15 -1
  198. package/src/api/resources/personIntake.ts +54 -13
  199. package/src/api/resources/session.ts +4 -0
  200. package/src/api/resources/tags.ts +71 -0
  201. package/src/app/KelpieApp.tsx +4 -2
  202. package/src/components/AddRecordPanel.tsx +143 -0
  203. package/src/components/AiDrawer.tsx +34 -7
  204. package/src/components/ApiKeysPanel.tsx +193 -75
  205. package/src/components/Chip.tsx +32 -1
  206. package/src/components/CustomFieldsPanel.tsx +15 -5
  207. package/src/components/DecisionProvenance.tsx +95 -0
  208. package/src/components/DecisionsPanel.tsx +30 -2
  209. package/src/components/MarkdownView.tsx +45 -11
  210. package/src/components/NotesPanel.tsx +15 -6
  211. package/src/components/OriginLabel.tsx +26 -0
  212. package/src/components/Shell.tsx +30 -6
  213. package/src/components/TagInput.tsx +285 -0
  214. package/src/components/aiDrawerState.ts +12 -0
  215. package/src/components/personIntakeTask.tsx +48 -0
  216. package/src/lib/personIntakeRunStorage.ts +97 -0
  217. package/src/modules/PersonIntakeWizard.tsx +391 -30
  218. package/src/modules/ai.tsx +1 -1
  219. package/src/pages/CompaniesPage.tsx +22 -5
  220. package/src/pages/CompanyDetail.tsx +6 -17
  221. package/src/pages/DealDetail.tsx +6 -17
  222. package/src/pages/DealsPage.tsx +25 -8
  223. package/src/pages/DecisionsPage.tsx +28 -1
  224. package/src/pages/EnquiriesPage.tsx +23 -5
  225. package/src/pages/EnquiryDetail.tsx +6 -18
  226. package/src/pages/EventDetail.tsx +6 -18
  227. package/src/pages/FundraisingPage.tsx +25 -11
  228. package/src/pages/OpportunitiesPage.tsx +23 -5
  229. package/src/pages/OpportunityDetail.tsx +6 -18
  230. package/src/pages/PartnershipDetail.tsx +6 -18
  231. package/src/pages/PartnershipsPage.tsx +25 -11
  232. package/src/pages/PeoplePage.tsx +22 -7
  233. package/src/pages/PersonDetail.tsx +11 -21
  234. package/src/pages/RaiseDetail.tsx +6 -18
  235. package/src/pages/SearchPage.tsx +3 -0
  236. package/src/pages/account/ConnectedAppsPage.tsx +97 -14
  237. package/src/pages/admin/{McpPanel.tsx → AgentsPanel.tsx} +11 -168
  238. package/src/pages/admin/AiAdminPage.tsx +16 -11
  239. package/src/pages/admin/AiPage.tsx +1 -1
  240. package/src/pages/admin/TeamPage.tsx +33 -0
  241. package/src/pages/ai/AiAccessPage.tsx +23 -0
  242. package/src/pages/ai/McpPanel.tsx +261 -0
  243. package/src/pages/auth/nextPath.ts +18 -1
  244. package/src/pages/dashboard/sections.tsx +4 -0
  245. package/src/pages/forms/EmbedPanel.tsx +3 -2
  246. package/src/pages/forms/FieldsEditor.tsx +6 -7
  247. package/src/pages/forms/FormActions.tsx +18 -20
  248. package/src/pages/forms/FormEmails.tsx +11 -2
  249. package/src/pages/forms/FormSettings.tsx +5 -0
  250. package/src/pages/forms/SubmissionDetail.tsx +47 -9
  251. package/src/pages/forms/SubmissionsTable.tsx +180 -5
  252. package/src/pages/forms/fieldList.ts +21 -7
  253. package/src/pages/oauth/ConsentPage.tsx +271 -33
  254. package/src/registry/contributions.ts +1 -1
@@ -11,6 +11,7 @@ import {
11
11
  useSendInvite,
12
12
  } from '../../api/resources/invites.ts'
13
13
  import { useSession } from '../../api/resources/session.ts'
14
+ import { Chip } from '../../components/Chip.tsx'
14
15
  import { PageHeader } from '../../components/PageHeader.tsx'
15
16
  import { ErrorPanel, LoadingPanel } from '../../components/QueryState.tsx'
16
17
  import { initialsOf } from '../../lib/names.ts'
@@ -194,6 +195,9 @@ function InviteRow({
194
195
  >
195
196
  {invite.status === 'pending' ? `Pending until ${formatDate(invite.expiresAt)}` : 'Expired'}
196
197
  </span>
198
+ {invite.emailFailedAt !== null && (
199
+ <EmailNotDelivered failedAt={invite.emailFailedAt} reason={invite.emailFailure} />
200
+ )}
197
201
  </td>
198
202
  <td className="px-4 py-3 text-right">
199
203
  <div className="flex flex-wrap justify-end gap-3">
@@ -220,6 +224,35 @@ function InviteRow({
220
224
  )
221
225
  }
222
226
 
227
+ /**
228
+ * Says that the invitation email did not arrive, and why. The person who was
229
+ * invited has no link, so the invitation stays pending until an admin sends
230
+ * it again or revokes it. The Resend button is in the same row.
231
+ *
232
+ * The reason is the mail server's own answer. It is shown as text, not only
233
+ * as a tooltip, so a touch screen shows it too. `break-words` and the
234
+ * maximum width keep a long answer from making the table wider.
235
+ */
236
+ function EmailNotDelivered({
237
+ failedAt,
238
+ reason,
239
+ }: {
240
+ readonly failedAt: Date
241
+ readonly reason: string | null
242
+ }): React.JSX.Element {
243
+ return (
244
+ <div className="mt-1.5 max-w-[320px] min-w-[160px]">
245
+ <Chip tone="danger">Email not delivered</Chip>
246
+ <p className="mt-1 text-[11px] break-words text-ink-muted">
247
+ {reason === null || reason === '' ? 'The mail server gave no reason.' : reason}
248
+ </p>
249
+ <p className="mt-0.5 text-[11px] text-ink-faint">
250
+ Failed {formatDate(failedAt)}. Resend it, or revoke it and invite the correct address.
251
+ </p>
252
+ </div>
253
+ )
254
+ }
255
+
223
256
  function MemberTable({
224
257
  members,
225
258
  isAdmin,
@@ -0,0 +1,23 @@
1
+ import { PageHeader } from '../../components/PageHeader.tsx'
2
+ import { McpPanel } from './McpPanel.tsx'
3
+
4
+ /**
5
+ * AI at `/ai`: how a member's agent reaches this workspace.
6
+ *
7
+ * Outside Admin, so every member can open it. Any member can use MCP with a
8
+ * personal key or OAuth sign-in, and this page is where they find the address.
9
+ * Settings for AI stay under Admin → AI.
10
+ *
11
+ * No tab strip while MCP is the only content. Add one with the second tab.
12
+ */
13
+ export function AiAccessPage(): React.JSX.Element {
14
+ return (
15
+ <div className="animate-slide-in mx-auto max-w-4xl">
16
+ <PageHeader
17
+ title="Connect your agent"
18
+ description="Give Claude, Cursor, or another MCP client access to this workspace."
19
+ />
20
+ <McpPanel />
21
+ </div>
22
+ )
23
+ }
@@ -0,0 +1,261 @@
1
+ import type { McpTool } from '@kelpie/schemas'
2
+ import { useMemo, useState } from 'react'
3
+ import { Link } from 'react-router'
4
+
5
+ import { useMcpTools } from '../../api/resources/mcpTools.ts'
6
+ import { useSession } from '../../api/resources/session.ts'
7
+ import { ErrorPanel, LoadingPanel } from '../../components/QueryState.tsx'
8
+ import { CopyButton } from '../../components/CopyButton.tsx'
9
+ import { mcpClientConfig, mcpEndpoint } from '../../lib/mcpConfig.ts'
10
+
11
+ /**
12
+ * How an agent connects to this workspace: the content of the AI page.
13
+ *
14
+ * Every member sees it. It is how to reach MCP, not a setting, and any member
15
+ * can connect a client with a personal key or OAuth sign-in.
16
+ *
17
+ * Everything on the page is derived rather than written down. The endpoint comes
18
+ * from the origin the browser reached the app on, the same way a form's embed URL
19
+ * does, so it is right for a self-hosted install on any hostname. The tool list
20
+ * comes from `/v1/mcp/tools`, which reads the registry the endpoint itself
21
+ * dispatches against: a module that adds a resource shows up here without anyone
22
+ * editing this file.
23
+ *
24
+ * Registered agents and their run log are configuration, and are on the Agents
25
+ * tab of Admin → AI.
26
+ */
27
+
28
+ /**
29
+ * Matches a tool on its name or its description, so "csv" finds the import and
30
+ * export tools and "pinned" finds the note list that filters on it.
31
+ */
32
+ function matches(tool: McpTool, term: string): boolean {
33
+ const needle = term.trim().toLowerCase()
34
+
35
+ if (needle.length === 0) {
36
+ return true
37
+ }
38
+
39
+ return (
40
+ tool.name.toLowerCase().includes(needle) ||
41
+ tool.description.toLowerCase().includes(needle)
42
+ )
43
+ }
44
+
45
+ type ConnectMethod = 'sign-in' | 'api-key'
46
+
47
+ const CONNECT_METHODS: readonly { readonly id: ConnectMethod; readonly label: string }[] = [
48
+ { id: 'sign-in', label: 'Sign in' },
49
+ { id: 'api-key', label: 'API key' },
50
+ ]
51
+
52
+ function methodClass(selected: boolean): string {
53
+ return [
54
+ 'rounded-md border px-2.5 py-1 text-[12px] font-medium transition',
55
+ selected
56
+ ? 'border-accent bg-accent text-accent-fg'
57
+ : 'border-border text-ink-muted hover:border-border-strong hover:text-ink',
58
+ ].join(' ')
59
+ }
60
+
61
+ const STEP_HEADING = 'text-[13px] font-semibold text-ink'
62
+ const STEP_TEXT = 'mt-1 max-w-2xl text-[13px] leading-relaxed text-ink-muted'
63
+
64
+ /**
65
+ * The AI page's content, as three steps in the order a member does them: copy
66
+ * the address, connect, check. The tool list and the rules are closed below,
67
+ * because a member reads them after the agent is connected, if at all.
68
+ */
69
+ export function McpPanel(): React.JSX.Element {
70
+ const endpoint = mcpEndpoint()
71
+ // A member cannot open Admin, so only an admin gets the workspace keys link.
72
+ const { session } = useSession()
73
+ const isAdmin = session?.role === 'owner' || session?.role === 'admin'
74
+ const config = mcpClientConfig(endpoint, 'kp_user_…')
75
+ const [method, setMethod] = useState<ConnectMethod>('sign-in')
76
+
77
+ return (
78
+ <div className="space-y-4">
79
+ <section className="rounded-md border border-border p-5">
80
+ <div className="flex items-center justify-between gap-3">
81
+ <h2 className={STEP_HEADING}>1. Copy the address</h2>
82
+ <CopyButton value={endpoint} label="Copy the address" />
83
+ </div>
84
+ <code className="mt-3 block rounded-md border border-border bg-surface px-3 py-2.5 font-mono text-[13px] break-all text-ink">
85
+ {endpoint}
86
+ </code>
87
+ </section>
88
+
89
+ <section className="rounded-md border border-border p-5">
90
+ <div className="flex flex-wrap items-center justify-between gap-3">
91
+ <h2 className={STEP_HEADING}>2. Connect</h2>
92
+ <div className="flex gap-1.5" role="group" aria-label="How to connect">
93
+ {CONNECT_METHODS.map((option) => (
94
+ <button
95
+ key={option.id}
96
+ type="button"
97
+ aria-pressed={method === option.id}
98
+ onClick={() => {
99
+ setMethod(option.id)
100
+ }}
101
+ className={methodClass(method === option.id)}
102
+ >
103
+ {option.label}
104
+ </button>
105
+ ))}
106
+ </div>
107
+ </div>
108
+
109
+ {method === 'sign-in' ? (
110
+ <>
111
+ <p className={STEP_TEXT}>
112
+ Use this if your client can sign in to an MCP server. A Claude.ai connector is one
113
+ example.
114
+ </p>
115
+ <ol className="mt-3 list-decimal space-y-1.5 pl-5 text-[13px] text-ink">
116
+ <li>Add a new MCP server in your client, and paste the address.</li>
117
+ <li>A Kelpie page opens. Select one or more workspaces and approve the access.</li>
118
+ </ol>
119
+ <p className="mt-3 text-[12px] text-ink-muted">
120
+ You can disconnect a client at any time under{' '}
121
+ <Link to="/account/connected-apps" className="text-accent hover:underline">
122
+ Connected apps
123
+ </Link>
124
+ .
125
+ </p>
126
+ </>
127
+ ) : (
128
+ <>
129
+ <p className={STEP_TEXT}>
130
+ Use this if your client reads a config file. Claude Code and Cursor are examples.
131
+ </p>
132
+ <ol className="mt-3 list-decimal space-y-1.5 pl-5 text-[13px] text-ink">
133
+ <li>
134
+ Create a personal key under{' '}
135
+ <Link to="/account/api-keys" className="text-accent hover:underline">
136
+ API keys
137
+ </Link>
138
+ . Kelpie shows the key one time, so copy it then.
139
+ </li>
140
+ <li>
141
+ Paste this config into your client, and put your key in the place of{' '}
142
+ <code className="font-mono text-[12px]">kp_user_…</code>.
143
+ </li>
144
+ </ol>
145
+ <div className="mt-3 flex justify-end">
146
+ <CopyButton value={config} label="Copy the client config" />
147
+ </div>
148
+ <pre className="bg-code-bg text-code-fg mt-2 overflow-x-auto rounded-md border border-border p-4 font-mono text-[12px] leading-relaxed">
149
+ {config}
150
+ </pre>
151
+ {isAdmin && (
152
+ <p className="mt-3 text-[12px] text-ink-muted">
153
+ For an agent that your team shares, use a workspace key from{' '}
154
+ <Link to="/admin/api-keys" className="text-accent hover:underline">
155
+ Admin → API keys
156
+ </Link>
157
+ .
158
+ </p>
159
+ )}
160
+ </>
161
+ )}
162
+ </section>
163
+
164
+ <section className="rounded-md border border-border p-5">
165
+ <h2 className={STEP_HEADING}>3. Check that it works</h2>
166
+ <p className={STEP_TEXT}>
167
+ Ask your agent: <span className="text-ink">“List the people in my CRM.”</span> If it
168
+ shows your people, the connection works.
169
+ </p>
170
+ </section>
171
+
172
+ <ToolCatalog />
173
+
174
+ <details className="rounded-md border border-border px-5 py-3">
175
+ <summary className="cursor-pointer text-[13px] font-semibold text-ink">Good to know</summary>
176
+ <ul className="mt-3 max-w-2xl list-disc space-y-1.5 pb-2 pl-5 text-[13px] text-ink-muted">
177
+ <li>
178
+ A key is for one workspace. With sign-in, you select the workspaces, and your agent sees
179
+ only those. If you select more than one, the agent must name the workspace on each
180
+ action.
181
+ </li>
182
+ <li>
183
+ Your agent reads and writes the same records that you see in the app. A tool follows
184
+ the same rules as the app, and refuses what the app refuses.
185
+ </li>
186
+ <li>
187
+ The address does not open in a browser. It answers only an MCP client that has a key or
188
+ a sign-in.
189
+ </li>
190
+ <li>The connection type is MCP over Streamable HTTP, if your client asks for it.</li>
191
+ </ul>
192
+ </details>
193
+ </div>
194
+ )
195
+ }
196
+
197
+ /**
198
+ * What this deployment actually registered, read from the endpoint's own registry.
199
+ *
200
+ * Closed until a member opens it: the list is long, and it is reference, not a
201
+ * step. A flat list rather than a grouped one. Tool names are resource-then-verb, so
202
+ * sorting by name already puts a resource's five together, and every rule for
203
+ * grouping them turned out to be a lexical guess that read `webhooks_rotate_secret`
204
+ * as a resource called `webhooks_rotate`.
205
+ */
206
+ function ToolCatalog(): React.JSX.Element {
207
+ const { records, isLoading, error } = useMcpTools()
208
+ const [term, setTerm] = useState('')
209
+ const shown = useMemo(
210
+ () => [...records].filter((tool) => matches(tool, term)).sort((left, right) => left.name.localeCompare(right.name)),
211
+ [records, term],
212
+ )
213
+
214
+ return (
215
+ <details className="rounded-md border border-border px-5 py-3">
216
+ <summary className="cursor-pointer text-[13px] font-semibold text-ink">
217
+ What your agent can do
218
+ {!isLoading && error === null && (
219
+ <span className="ml-2 font-normal text-ink-muted">{String(records.length)} tools</span>
220
+ )}
221
+ </summary>
222
+ <div className="mt-3 flex flex-wrap items-center justify-between gap-3">
223
+ <p className="max-w-2xl text-[12px] text-ink-muted">
224
+ {isLoading
225
+ ? 'Reading what this deployment exposes.'
226
+ : 'Each tool does one operation of the app, such as list people or create a note.'}
227
+ </p>
228
+ {records.length > 0 && (
229
+ <input
230
+ type="search"
231
+ value={term}
232
+ onChange={(event) => {
233
+ setTerm(event.target.value)
234
+ }}
235
+ placeholder="Filter tools"
236
+ aria-label="Filter tools"
237
+ className="rounded-md border border-border bg-surface px-2.5 py-1 text-[12px] text-ink outline-none focus:border-border-strong"
238
+ />
239
+ )}
240
+ </div>
241
+
242
+ {error !== null && <div className="mt-4">{<ErrorPanel error={error} />}</div>}
243
+ {isLoading && <LoadingPanel label="Loading tools…" />}
244
+
245
+ {records.length > 0 && shown.length === 0 && (
246
+ <p className="mt-4 text-[12px] text-ink-faint">No tool matches “{term}”.</p>
247
+ )}
248
+
249
+ {shown.length > 0 && (
250
+ <ul className="mt-4 divide-y divide-border rounded-md border border-border">
251
+ {shown.map((tool) => (
252
+ <li key={tool.name} className="px-3 py-2.5">
253
+ <code className="font-mono text-[12px] text-accent">{tool.name}</code>
254
+ <p className="mt-0.5 text-[12px] leading-relaxed text-ink-muted">{tool.description}</p>
255
+ </li>
256
+ ))}
257
+ </ul>
258
+ )}
259
+ </details>
260
+ )
261
+ }
@@ -8,10 +8,27 @@
8
8
  * rely on what it means.
9
9
  */
10
10
 
11
+ /**
12
+ * A backslash, or a control character: U+0000 to U+001F and U+007F, which
13
+ * are the ASCII ones, and U+0080 to U+009F, which the same Unicode class
14
+ * holds. Neither has a place in a path this app makes.
15
+ */
16
+ const REFUSED_CHARACTERS = /[\\\p{Cc}]/u
17
+
11
18
  /**
12
19
  * Only a path within this app. An absolute URL in `?next=` would turn a
13
20
  * sign-in page into an open redirect.
21
+ *
22
+ * `//host` is another site, so the second character must not be a slash. A
23
+ * browser also reads `\` as `/`, and it removes a tab or a line break from a
24
+ * URL before it reads it. So `/\host` and `/<tab>/host` are another site too,
25
+ * and a value with a backslash or a control character anywhere is refused.
26
+ * The result may go to `window.location`, which applies those browser rules.
14
27
  */
15
28
  export function safeNext(value: string | null): string {
16
- return value !== null && value.startsWith('/') && !value.startsWith('//') ? value : '/dashboard'
29
+ if (value === null || !value.startsWith('/') || value.startsWith('//') || REFUSED_CHARACTERS.test(value)) {
30
+ return '/dashboard'
31
+ }
32
+
33
+ return value
17
34
  }
@@ -11,7 +11,9 @@ import { Link } from 'react-router'
11
11
  import { ActivityAction } from '../../components/ActivityAction.tsx'
12
12
  import { Chip } from '../../components/Chip.tsx'
13
13
  import { LinkedText } from '../../components/LinkedText.tsx'
14
+ import { DecisionProvenance } from '../../components/DecisionProvenance.tsx'
14
15
  import { MarkdownView } from '../../components/MarkdownView.tsx'
16
+ import { OriginLabel } from '../../components/OriginLabel.tsx'
15
17
  import { SectionHeader } from '../../components/SectionHeader.tsx'
16
18
  import { formatDate, formatRelativeTime } from '../../lib/dates.ts'
17
19
  import { targetHref } from '../../lib/recordLinks.ts'
@@ -251,6 +253,7 @@ export function NotesList({
251
253
  <span>{note.authorId === null ? 'System' : (nameById.get(note.authorId) ?? 'Unknown')}</span>
252
254
  <span>·</span>
253
255
  <span>{formatRelativeTime(note.createdAt, timezone, now)}</span>
256
+ <OriginLabel origin={note.origin} />
254
257
  </div>
255
258
  </li>
256
259
  ))}
@@ -300,6 +303,7 @@ export function DecisionsList({
300
303
  <span>
301
304
  {decision.ownerId === null ? '—' : (nameById.get(decision.ownerId) ?? 'Unknown')}
302
305
  </span>
306
+ <DecisionProvenance origin={decision.origin} confirmedAt={decision.confirmedAt} />
303
307
  </div>
304
308
  </li>
305
309
  ))}
@@ -288,15 +288,16 @@ function AiPromptModal({
288
288
  title={`AI prompt · ${label}`}
289
289
  description="Paste this into an AI coding assistant to add the form to your site."
290
290
  actions={<CopyButton value={prompt} label={`Copy the ${label} AI prompt`} />}
291
- bodyClassName="p-4"
291
+ bodyClassName="flex flex-col p-4"
292
292
  onClose={onClose}
293
293
  >
294
+ {/* The textarea shrinks to the dialog and is the only scroll area. */}
294
295
  <textarea
295
296
  readOnly
296
297
  value={prompt}
297
298
  rows={prompt.split('\n').length + 1}
298
299
  aria-label={`${label} AI prompt`}
299
- className="w-full resize-y rounded-md border border-border bg-surface px-3 py-2 font-mono text-[11px] text-ink outline-none"
300
+ className="min-h-0 w-full flex-1 resize-none rounded-md border border-border bg-surface px-3 py-2 font-mono text-[11px] text-ink outline-none"
300
301
  />
301
302
  </ModalFrame>
302
303
  )
@@ -51,14 +51,13 @@ import type { EditableField } from './fieldList.ts'
51
51
  * drags it up and down; "Add field" offers ready-made fields to append.
52
52
  *
53
53
  * Explicitly saved rather than saved per keystroke, unlike the inline editing
54
- * everywhere else in the app. A write replaces the whole list, so an
55
- * auto-committing builder would send one full rewrite per character typed into a
56
- * label, and every one of them would reissue every field id. The draft lives
57
- * here until somebody presses Save.
54
+ * everywhere else in the app. A write carries the whole list, so an
55
+ * auto-committing builder would send one full list per character typed into a
56
+ * label. The draft lives here until somebody presses Save.
58
57
  *
59
58
  * A field id is a stored id for a saved field and a local one for a field just
60
- * added; neither is sent. The server assigns ids and positions from the array's
61
- * order on every write.
59
+ * added. A save sends the stored ids, so a saved field keeps its id through any
60
+ * edit; a local id is not sent, and the server gives that field its id.
62
61
  */
63
62
 
64
63
  let localFieldCount = 0
@@ -137,7 +136,7 @@ export function FieldsEditor({ form }: FieldsEditorProps): React.JSX.Element {
137
136
  }
138
137
 
139
138
  function save(): void {
140
- updateFields.run({ id: form.id, fields: toFieldInputs(fields) })
139
+ updateFields.run({ id: form.id, fields: toFieldInputs(form, fields) })
141
140
  }
142
141
 
143
142
  return (
@@ -1,5 +1,11 @@
1
1
  import { FORM_ATTACH_TARGET_TYPES, PLAN_ITEM_TARGET_TYPE_LABELS } from '@kelpie/schemas'
2
- import type { Form, FormAttachTarget, FormAttachTargetType, PipelineKind } from '@kelpie/schemas'
2
+ import type {
3
+ Form,
4
+ FormAttachTarget,
5
+ FormAttachTargetType,
6
+ PipelineKind,
7
+ TagTargetType,
8
+ } from '@kelpie/schemas'
3
9
  import { useMemo, useState } from 'react'
4
10
 
5
11
  import { useDeals } from '../../api/resources/deals.ts'
@@ -12,10 +18,9 @@ import { useOpportunities } from '../../api/resources/opportunities.ts'
12
18
  import { usePartnerships } from '../../api/resources/partnerships.ts'
13
19
  import { usePipelineStages } from '../../api/resources/pipelineStages.ts'
14
20
  import { useRaises } from '../../api/resources/raises.ts'
15
- import { Chip } from '../../components/Chip.tsx'
16
21
  import { ErrorPanel } from '../../components/QueryState.tsx'
17
22
  import { SectionHeader } from '../../components/SectionHeader.tsx'
18
- import { toTags } from '../fields.ts'
23
+ import { TagInput } from '../../components/TagInput.tsx'
19
24
  import { FormEmails } from './FormEmails.tsx'
20
25
 
21
26
  /**
@@ -119,12 +124,14 @@ export function FormActions({ form }: FormActionsProps): React.JSX.Element {
119
124
  <TagsBlock
120
125
  title="Tag the person"
121
126
  hint="Merged into the submitter's tags. Never removes a tag someone set by hand."
127
+ targetType="person"
122
128
  value={form.personTags}
123
129
  onChange={(next) => patch({ personTags: next })}
124
130
  />
125
131
  <TagsBlock
126
132
  title="Tag the company"
127
133
  hint="Merged into the resolved company's tags. Skipped when no company is resolved."
134
+ targetType="company"
128
135
  value={form.companyTags}
129
136
  onChange={(next) => patch({ companyTags: next })}
130
137
  />
@@ -278,35 +285,26 @@ function TriggerBlock(props: TriggerBlockProps): React.JSX.Element {
278
285
  function TagsBlock({
279
286
  title,
280
287
  hint,
288
+ targetType,
281
289
  value,
282
290
  onChange,
283
291
  }: {
284
292
  readonly title: string
285
293
  readonly hint: string
294
+ readonly targetType: TagTargetType
286
295
  readonly value: readonly string[]
287
296
  readonly onChange: (next: readonly string[]) => void
288
297
  }): React.JSX.Element {
289
298
  return (
290
299
  <div className="space-y-2 rounded-md border border-border p-4">
291
300
  <div className="text-[13px] font-medium text-ink">{title}</div>
292
- <input
293
- className={inputClass}
294
- defaultValue={value.join(', ')}
295
- onBlur={(event) => {
296
- const next = toTags(event.target.value)
297
- const changed =
298
- next.length !== value.length || next.some((tag, index) => tag !== value[index])
299
-
300
- if (changed) {
301
- onChange(next)
302
- }
303
- }}
301
+ <TagInput
302
+ value={value}
303
+ onChange={onChange}
304
+ targetType={targetType}
305
+ size="md"
306
+ label={title}
304
307
  />
305
- <div className="flex flex-wrap gap-1">
306
- {value.map((tag) => (
307
- <Chip key={tag}>{tag}</Chip>
308
- ))}
309
- </div>
310
308
  <p className="text-[11px] text-ink-faint">{hint}</p>
311
309
  </div>
312
310
  )
@@ -101,7 +101,15 @@ export function FormEmails({ form }: FormEmailsProps): React.JSX.Element {
101
101
  <input
102
102
  type="checkbox"
103
103
  checked={form.autoReply}
104
- onChange={(event) => onChange({ autoReply: event.target.checked })}
104
+ // The server refuses an auto-reply on a form without the spam
105
+ // check, so turning one on turns the other on in the same save.
106
+ onChange={(event) =>
107
+ onChange(
108
+ event.target.checked
109
+ ? { autoReply: true, requireSpamCheck: true }
110
+ : { autoReply: false },
111
+ )
112
+ }
105
113
  />
106
114
  Send an auto-reply
107
115
  </label>
@@ -109,7 +117,8 @@ export function FormEmails({ form }: FormEmailsProps): React.JSX.Element {
109
117
  Sent to the email address the visitor typed. Use it to confirm the request only, not
110
118
  for marketing. It cannot include the visitor&apos;s answers: anybody can type any
111
119
  address into a public form, so it contains only text you wrote. One auto-reply per
112
- address per day for each form.
120
+ address per day for each form. An auto-reply needs the spam check, so turning this
121
+ on also turns on &ldquo;Require the spam check&rdquo; on the Settings tab.
113
122
  </p>
114
123
 
115
124
  <ReplyToPicker
@@ -96,6 +96,9 @@ export function FormSettings({ form }: FormSettingsProps): React.JSX.Element {
96
96
  <input
97
97
  type="checkbox"
98
98
  checked={form.requireSpamCheck}
99
+ // The server refuses an auto-reply without the check, so the check
100
+ // cannot be turned off while the auto-reply is on.
101
+ disabled={form.autoReply && form.requireSpamCheck}
99
102
  onChange={(event) => {
100
103
  patch({ requireSpamCheck: event.target.checked })
101
104
  }}
@@ -107,6 +110,8 @@ export function FormSettings({ form }: FormSettingsProps): React.JSX.Element {
107
110
  can release it from the Submissions tab. Your embeds pass the check by themselves.
108
111
  If a site posts JSON to this form from its own markup, it must get a token first:
109
112
  see the Embed tab.
113
+ {form.autoReply &&
114
+ ' The auto-reply needs this check. To turn the check off, first turn the auto-reply off on the Actions tab.'}
110
115
  </Hint>
111
116
  </div>
112
117