@kelpie/ui 0.22.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.
- package/dist/api/resource.d.ts +12 -0
- package/dist/api/resource.d.ts.map +1 -1
- package/dist/api/resource.js +11 -0
- package/dist/api/resource.js.map +1 -1
- package/dist/api/resources/decisions.d.ts +31 -0
- package/dist/api/resources/decisions.d.ts.map +1 -1
- package/dist/api/resources/decisions.js +51 -1
- package/dist/api/resources/decisions.js.map +1 -1
- package/dist/api/resources/oauth.d.ts +2 -0
- package/dist/api/resources/oauth.d.ts.map +1 -1
- package/dist/api/resources/oauth.js +13 -1
- package/dist/api/resources/oauth.js.map +1 -1
- package/dist/api/resources/personIntake.d.ts +15 -3
- package/dist/api/resources/personIntake.d.ts.map +1 -1
- package/dist/api/resources/personIntake.js +38 -9
- package/dist/api/resources/personIntake.js.map +1 -1
- package/dist/api/resources/session.d.ts.map +1 -1
- package/dist/api/resources/session.js +4 -0
- package/dist/api/resources/session.js.map +1 -1
- package/dist/app/KelpieApp.d.ts.map +1 -1
- package/dist/app/KelpieApp.js +2 -1
- package/dist/app/KelpieApp.js.map +1 -1
- package/dist/components/AddRecordPanel.d.ts +35 -0
- package/dist/components/AddRecordPanel.d.ts.map +1 -0
- package/dist/components/AddRecordPanel.js +35 -0
- package/dist/components/AddRecordPanel.js.map +1 -0
- package/dist/components/AiDrawer.d.ts.map +1 -1
- package/dist/components/AiDrawer.js +29 -6
- package/dist/components/AiDrawer.js.map +1 -1
- package/dist/components/ApiKeysPanel.d.ts.map +1 -1
- package/dist/components/ApiKeysPanel.js +101 -44
- package/dist/components/ApiKeysPanel.js.map +1 -1
- package/dist/components/CustomFieldsPanel.d.ts.map +1 -1
- package/dist/components/CustomFieldsPanel.js +5 -2
- package/dist/components/CustomFieldsPanel.js.map +1 -1
- package/dist/components/DecisionProvenance.d.ts +27 -0
- package/dist/components/DecisionProvenance.d.ts.map +1 -0
- package/dist/components/DecisionProvenance.js +53 -0
- package/dist/components/DecisionProvenance.js.map +1 -0
- package/dist/components/DecisionsPanel.d.ts +3 -0
- package/dist/components/DecisionsPanel.d.ts.map +1 -1
- package/dist/components/DecisionsPanel.js +9 -5
- package/dist/components/DecisionsPanel.js.map +1 -1
- package/dist/components/MarkdownView.d.ts.map +1 -1
- package/dist/components/MarkdownView.js +18 -2
- package/dist/components/MarkdownView.js.map +1 -1
- package/dist/components/NotesPanel.d.ts.map +1 -1
- package/dist/components/NotesPanel.js +7 -3
- package/dist/components/NotesPanel.js.map +1 -1
- package/dist/components/OriginLabel.d.ts +5 -0
- package/dist/components/OriginLabel.d.ts.map +1 -0
- package/dist/components/OriginLabel.js +22 -0
- package/dist/components/OriginLabel.js.map +1 -0
- package/dist/components/Shell.d.ts.map +1 -1
- package/dist/components/Shell.js +17 -5
- package/dist/components/Shell.js.map +1 -1
- package/dist/components/aiDrawerState.d.ts +12 -0
- package/dist/components/aiDrawerState.d.ts.map +1 -1
- package/dist/components/aiDrawerState.js.map +1 -1
- package/dist/components/personIntakeTask.d.ts +15 -0
- package/dist/components/personIntakeTask.d.ts.map +1 -1
- package/dist/components/personIntakeTask.js +42 -0
- package/dist/components/personIntakeTask.js.map +1 -1
- package/dist/lib/personIntakeRunStorage.d.ts +15 -0
- package/dist/lib/personIntakeRunStorage.d.ts.map +1 -0
- package/dist/lib/personIntakeRunStorage.js +88 -0
- package/dist/lib/personIntakeRunStorage.js.map +1 -0
- package/dist/modules/PersonIntakeWizard.d.ts +1 -1
- package/dist/modules/PersonIntakeWizard.d.ts.map +1 -1
- package/dist/modules/PersonIntakeWizard.js +243 -29
- package/dist/modules/PersonIntakeWizard.js.map +1 -1
- package/dist/modules/ai.d.ts +1 -1
- package/dist/modules/ai.js +1 -1
- package/dist/pages/CompaniesPage.d.ts.map +1 -1
- package/dist/pages/CompaniesPage.js +13 -6
- package/dist/pages/CompaniesPage.js.map +1 -1
- package/dist/pages/DealsPage.d.ts.map +1 -1
- package/dist/pages/DealsPage.js +16 -8
- package/dist/pages/DealsPage.js.map +1 -1
- package/dist/pages/DecisionsPage.d.ts.map +1 -1
- package/dist/pages/DecisionsPage.js +7 -3
- package/dist/pages/DecisionsPage.js.map +1 -1
- package/dist/pages/EnquiriesPage.d.ts.map +1 -1
- package/dist/pages/EnquiriesPage.js +14 -6
- package/dist/pages/EnquiriesPage.js.map +1 -1
- package/dist/pages/FundraisingPage.d.ts.map +1 -1
- package/dist/pages/FundraisingPage.js +16 -11
- package/dist/pages/FundraisingPage.js.map +1 -1
- package/dist/pages/OpportunitiesPage.d.ts.map +1 -1
- package/dist/pages/OpportunitiesPage.js +14 -6
- package/dist/pages/OpportunitiesPage.js.map +1 -1
- package/dist/pages/PartnershipsPage.d.ts.map +1 -1
- package/dist/pages/PartnershipsPage.js +16 -11
- package/dist/pages/PartnershipsPage.js.map +1 -1
- package/dist/pages/PeoplePage.d.ts.map +1 -1
- package/dist/pages/PeoplePage.js +13 -8
- package/dist/pages/PeoplePage.js.map +1 -1
- package/dist/pages/PersonDetail.js +2 -2
- package/dist/pages/PersonDetail.js.map +1 -1
- package/dist/pages/SearchPage.d.ts.map +1 -1
- package/dist/pages/SearchPage.js +2 -1
- package/dist/pages/SearchPage.js.map +1 -1
- package/dist/pages/account/ConnectedAppsPage.d.ts +0 -5
- package/dist/pages/account/ConnectedAppsPage.d.ts.map +1 -1
- package/dist/pages/account/ConnectedAppsPage.js +38 -6
- package/dist/pages/account/ConnectedAppsPage.js.map +1 -1
- package/dist/pages/admin/AgentsPanel.d.ts +10 -0
- package/dist/pages/admin/AgentsPanel.d.ts.map +1 -0
- package/dist/pages/admin/AgentsPanel.js +81 -0
- package/dist/pages/admin/AgentsPanel.js.map +1 -0
- package/dist/pages/admin/AiAdminPage.d.ts.map +1 -1
- package/dist/pages/admin/AiAdminPage.js +9 -6
- package/dist/pages/admin/AiAdminPage.js.map +1 -1
- package/dist/pages/admin/AiPage.js +1 -1
- package/dist/pages/admin/TeamPage.d.ts.map +1 -1
- package/dist/pages/admin/TeamPage.js +16 -3
- package/dist/pages/admin/TeamPage.js.map +1 -1
- package/dist/pages/ai/AiAccessPage.d.ts +11 -0
- package/dist/pages/ai/AiAccessPage.d.ts.map +1 -0
- package/dist/pages/ai/AiAccessPage.js +16 -0
- package/dist/pages/ai/AiAccessPage.js.map +1 -0
- package/dist/pages/ai/McpPanel.d.ts +7 -0
- package/dist/pages/ai/McpPanel.d.ts.map +1 -0
- package/dist/pages/ai/McpPanel.js +86 -0
- package/dist/pages/ai/McpPanel.js.map +1 -0
- package/dist/pages/auth/nextPath.d.ts +6 -0
- package/dist/pages/auth/nextPath.d.ts.map +1 -1
- package/dist/pages/auth/nextPath.js +16 -1
- package/dist/pages/auth/nextPath.js.map +1 -1
- package/dist/pages/dashboard/sections.d.ts.map +1 -1
- package/dist/pages/dashboard/sections.js +4 -2
- package/dist/pages/dashboard/sections.js.map +1 -1
- package/dist/pages/forms/EmbedPanel.js +1 -1
- package/dist/pages/forms/EmbedPanel.js.map +1 -1
- package/dist/pages/forms/FormEmails.d.ts.map +1 -1
- package/dist/pages/forms/FormEmails.js +6 -1
- package/dist/pages/forms/FormEmails.js.map +1 -1
- package/dist/pages/forms/FormSettings.d.ts.map +1 -1
- package/dist/pages/forms/FormSettings.js +6 -2
- package/dist/pages/forms/FormSettings.js.map +1 -1
- package/dist/pages/forms/SubmissionDetail.js +15 -3
- package/dist/pages/forms/SubmissionDetail.js.map +1 -1
- package/dist/pages/forms/SubmissionsTable.js +5 -2
- package/dist/pages/forms/SubmissionsTable.js.map +1 -1
- package/dist/pages/oauth/ConsentPage.d.ts.map +1 -1
- package/dist/pages/oauth/ConsentPage.js +132 -15
- package/dist/pages/oauth/ConsentPage.js.map +1 -1
- package/dist/registry/contributions.d.ts +1 -1
- package/package.json +3 -3
- package/src/api/resource.ts +16 -0
- package/src/api/resources/decisions.ts +81 -1
- package/src/api/resources/oauth.ts +15 -1
- package/src/api/resources/personIntake.ts +54 -13
- package/src/api/resources/session.ts +4 -0
- package/src/app/KelpieApp.tsx +4 -2
- package/src/components/AddRecordPanel.tsx +143 -0
- package/src/components/AiDrawer.tsx +34 -7
- package/src/components/ApiKeysPanel.tsx +193 -75
- package/src/components/CustomFieldsPanel.tsx +15 -5
- package/src/components/DecisionProvenance.tsx +95 -0
- package/src/components/DecisionsPanel.tsx +30 -2
- package/src/components/MarkdownView.tsx +45 -11
- package/src/components/NotesPanel.tsx +15 -6
- package/src/components/OriginLabel.tsx +26 -0
- package/src/components/Shell.tsx +30 -6
- package/src/components/aiDrawerState.ts +12 -0
- package/src/components/personIntakeTask.tsx +48 -0
- package/src/lib/personIntakeRunStorage.ts +97 -0
- package/src/modules/PersonIntakeWizard.tsx +391 -30
- package/src/modules/ai.tsx +1 -1
- package/src/pages/CompaniesPage.tsx +22 -5
- package/src/pages/DealsPage.tsx +25 -8
- package/src/pages/DecisionsPage.tsx +28 -1
- package/src/pages/EnquiriesPage.tsx +23 -5
- package/src/pages/FundraisingPage.tsx +25 -11
- package/src/pages/OpportunitiesPage.tsx +23 -5
- package/src/pages/PartnershipsPage.tsx +25 -11
- package/src/pages/PeoplePage.tsx +22 -7
- package/src/pages/PersonDetail.tsx +4 -2
- package/src/pages/SearchPage.tsx +3 -0
- package/src/pages/account/ConnectedAppsPage.tsx +97 -14
- package/src/pages/admin/{McpPanel.tsx → AgentsPanel.tsx} +11 -168
- package/src/pages/admin/AiAdminPage.tsx +16 -11
- package/src/pages/admin/AiPage.tsx +1 -1
- package/src/pages/admin/TeamPage.tsx +33 -0
- package/src/pages/ai/AiAccessPage.tsx +23 -0
- package/src/pages/ai/McpPanel.tsx +261 -0
- package/src/pages/auth/nextPath.ts +18 -1
- package/src/pages/dashboard/sections.tsx +4 -0
- package/src/pages/forms/EmbedPanel.tsx +3 -2
- package/src/pages/forms/FormEmails.tsx +11 -2
- package/src/pages/forms/FormSettings.tsx +5 -0
- package/src/pages/forms/SubmissionDetail.tsx +23 -4
- package/src/pages/forms/SubmissionsTable.tsx +9 -1
- package/src/pages/oauth/ConsentPage.tsx +271 -33
- package/src/registry/contributions.ts +1 -1
|
@@ -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
|
-
|
|
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-
|
|
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
|
)
|
|
@@ -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
|
-
|
|
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'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 “Require the spam check” 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
|
|
|
@@ -218,6 +218,9 @@ function SubmissionDetailView({
|
|
|
218
218
|
{entry.detail.length > 0 && (
|
|
219
219
|
<p className="mt-1 text-[12px] text-ink-muted">{entry.detail}</p>
|
|
220
220
|
)}
|
|
221
|
+
{entry.status === 'refused' && (
|
|
222
|
+
<p className="mt-1 text-[12px] text-danger">{REFUSED_EMAIL_NOTE}</p>
|
|
223
|
+
)}
|
|
221
224
|
</li>
|
|
222
225
|
))}
|
|
223
226
|
</ul>
|
|
@@ -307,15 +310,31 @@ function RecordRow({
|
|
|
307
310
|
)
|
|
308
311
|
}
|
|
309
312
|
|
|
313
|
+
/** Under a `refused` entry: the mail server's answer is final. */
|
|
314
|
+
const REFUSED_EMAIL_NOTE = 'The mail server refused this email. Kelpie does not send it again.'
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* An `error` and a `refused` are both failures, so both are red. A `refused`
|
|
318
|
+
* also has a solid background: no retry follows it, and it must not look like
|
|
319
|
+
* an error that can clear.
|
|
320
|
+
*/
|
|
321
|
+
const ACTION_STATUS_CLASSES: Readonly<Record<FormSubmissionActionEntry['status'], string>> = {
|
|
322
|
+
ok: 'text-success',
|
|
323
|
+
skipped: 'text-ink-faint',
|
|
324
|
+
error: 'text-danger',
|
|
325
|
+
refused: 'rounded bg-danger px-1.5 py-0.5 text-danger-fg',
|
|
326
|
+
}
|
|
327
|
+
|
|
310
328
|
function ActionStatus({
|
|
311
329
|
status,
|
|
312
330
|
}: {
|
|
313
331
|
readonly status: FormSubmissionActionEntry['status']
|
|
314
332
|
}): React.JSX.Element {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
333
|
+
return (
|
|
334
|
+
<span className={`text-[11px] font-medium uppercase ${ACTION_STATUS_CLASSES[status]}`}>
|
|
335
|
+
{status}
|
|
336
|
+
</span>
|
|
337
|
+
)
|
|
319
338
|
}
|
|
320
339
|
|
|
321
340
|
function displayAnswer(field: FormField, answer: string | undefined): string | null {
|
|
@@ -442,8 +442,11 @@ function ActionLogChip({
|
|
|
442
442
|
}
|
|
443
443
|
|
|
444
444
|
const errors = entries.filter((entry) => entry.status === 'error').length
|
|
445
|
+
// An email the mail server refused for good. Counted apart from the errors:
|
|
446
|
+
// an error on an email can clear on a retry, and a refusal cannot.
|
|
447
|
+
const refused = entries.filter((entry) => entry.status === 'refused').length
|
|
445
448
|
const skipped = entries.filter((entry) => entry.status === 'skipped').length
|
|
446
|
-
const ok = entries.length - errors - skipped
|
|
449
|
+
const ok = entries.length - errors - refused - skipped
|
|
447
450
|
const detail = entries
|
|
448
451
|
.map((entry) => `${entry.action}: ${entry.status}${entry.detail.length > 0 ? ` — ${entry.detail}` : ''}`)
|
|
449
452
|
.join('\n')
|
|
@@ -453,6 +456,11 @@ function ActionLogChip({
|
|
|
453
456
|
{ok > 0 && <span className="text-success">✓{ok}</span>}
|
|
454
457
|
{skipped > 0 && <span className="text-ink-faint">−{skipped}</span>}
|
|
455
458
|
{errors > 0 && <span className="text-danger">!{errors}</span>}
|
|
459
|
+
{refused > 0 && (
|
|
460
|
+
<span className="rounded bg-danger px-1 text-danger-fg" aria-label={`${String(refused)} refused`}>
|
|
461
|
+
✕{refused}
|
|
462
|
+
</span>
|
|
463
|
+
)}
|
|
456
464
|
</span>
|
|
457
465
|
)
|
|
458
466
|
}
|