@kelpie/ui 0.17.0 → 0.18.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/resources/ai.d.ts +5 -0
- package/dist/api/resources/ai.d.ts.map +1 -1
- package/dist/api/resources/ai.js +9 -1
- package/dist/api/resources/ai.js.map +1 -1
- package/dist/api/resources/forms.d.ts +8 -0
- package/dist/api/resources/forms.d.ts.map +1 -1
- package/dist/api/resources/forms.js +39 -0
- package/dist/api/resources/forms.js.map +1 -1
- package/dist/api/resources/personIntake.d.ts +12 -0
- package/dist/api/resources/personIntake.d.ts.map +1 -0
- package/dist/api/resources/personIntake.js +54 -0
- package/dist/api/resources/personIntake.js.map +1 -0
- package/dist/app/KelpieApp.js +2 -2
- package/dist/app/KelpieApp.js.map +1 -1
- package/dist/components/AgentTasks.js +2 -2
- package/dist/components/AgentTasks.js.map +1 -1
- package/dist/components/PersonIntakeDialog.d.ts +19 -0
- package/dist/components/PersonIntakeDialog.d.ts.map +1 -0
- package/dist/components/PersonIntakeDialog.js +87 -0
- package/dist/components/PersonIntakeDialog.js.map +1 -0
- package/dist/components/Shell.js +1 -1
- package/dist/components/Shell.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/modules/PersonIntakeWizard.d.ts +3 -0
- package/dist/modules/PersonIntakeWizard.d.ts.map +1 -0
- package/dist/modules/PersonIntakeWizard.js +223 -0
- package/dist/modules/PersonIntakeWizard.js.map +1 -0
- package/dist/modules/ai.d.ts +4 -3
- package/dist/modules/ai.d.ts.map +1 -1
- package/dist/modules/ai.js +10 -6
- package/dist/modules/ai.js.map +1 -1
- package/dist/modules/aiRunner.d.ts.map +1 -1
- package/dist/modules/aiRunner.js +7 -5
- package/dist/modules/aiRunner.js.map +1 -1
- package/dist/modules/personIntakeSelection.d.ts +7 -0
- package/dist/modules/personIntakeSelection.d.ts.map +1 -0
- package/dist/modules/personIntakeSelection.js +21 -0
- package/dist/modules/personIntakeSelection.js.map +1 -0
- package/dist/pages/FormsPage.js +4 -4
- package/dist/pages/FormsPage.js.map +1 -1
- package/dist/pages/PeoplePage.d.ts.map +1 -1
- package/dist/pages/PeoplePage.js +7 -1
- package/dist/pages/PeoplePage.js.map +1 -1
- package/dist/pages/admin/AiAdminPage.d.ts +2 -0
- package/dist/pages/admin/AiAdminPage.d.ts.map +1 -0
- package/dist/pages/admin/AiAdminPage.js +19 -0
- package/dist/pages/admin/AiAdminPage.js.map +1 -0
- package/dist/pages/admin/AiPage.d.ts +4 -1
- package/dist/pages/admin/AiPage.d.ts.map +1 -1
- package/dist/pages/admin/AiPage.js +77 -15
- package/dist/pages/admin/AiPage.js.map +1 -1
- package/dist/pages/admin/McpPanel.d.ts +3 -0
- package/dist/pages/admin/McpPanel.d.ts.map +1 -0
- package/dist/pages/admin/McpPanel.js +123 -0
- package/dist/pages/admin/McpPanel.js.map +1 -0
- package/dist/pages/admin/PrivacyPage.js +19 -3
- package/dist/pages/admin/PrivacyPage.js.map +1 -1
- package/dist/pages/forms/EmbedPanel.js +5 -2
- package/dist/pages/forms/EmbedPanel.js.map +1 -1
- package/dist/pages/forms/FieldsEditor.d.ts.map +1 -1
- package/dist/pages/forms/FieldsEditor.js +90 -8
- package/dist/pages/forms/FieldsEditor.js.map +1 -1
- package/dist/pages/forms/FormSettings.d.ts.map +1 -1
- package/dist/pages/forms/FormSettings.js +73 -6
- package/dist/pages/forms/FormSettings.js.map +1 -1
- package/dist/pages/forms/SubmissionDetail.d.ts.map +1 -1
- package/dist/pages/forms/SubmissionDetail.js +2 -1
- package/dist/pages/forms/SubmissionDetail.js.map +1 -1
- package/dist/pages/forms/SubmissionsTable.d.ts.map +1 -1
- package/dist/pages/forms/SubmissionsTable.js +2 -1
- package/dist/pages/forms/SubmissionsTable.js.map +1 -1
- package/dist/pages/forms/fieldList.d.ts +2 -2
- package/dist/pages/forms/fieldList.d.ts.map +1 -1
- package/dist/pages/forms/fieldList.js +38 -10
- package/dist/pages/forms/fieldList.js.map +1 -1
- package/dist/pages/forms/template.d.ts.map +1 -1
- package/dist/pages/forms/template.js +13 -0
- package/dist/pages/forms/template.js.map +1 -1
- package/dist/registry/context.d.ts +5 -1
- package/dist/registry/context.d.ts.map +1 -1
- package/dist/registry/context.js +8 -0
- package/dist/registry/context.js.map +1 -1
- package/dist/registry/contributions.d.ts +32 -1
- package/dist/registry/contributions.d.ts.map +1 -1
- package/dist/registry/registry.d.ts +8 -1
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +13 -0
- package/dist/registry/registry.js.map +1 -1
- package/package.json +2 -2
- package/src/api/resources/ai.ts +11 -1
- package/src/api/resources/forms.ts +56 -0
- package/src/api/resources/personIntake.ts +95 -0
- package/src/app/KelpieApp.tsx +4 -2
- package/src/components/AgentTasks.tsx +2 -2
- package/src/components/PersonIntakeDialog.tsx +226 -0
- package/src/components/Shell.tsx +1 -1
- package/src/index.ts +7 -1
- package/src/modules/PersonIntakeWizard.tsx +633 -0
- package/src/modules/ai.tsx +10 -6
- package/src/modules/aiRunner.ts +8 -5
- package/src/modules/personIntakeSelection.ts +24 -0
- package/src/pages/FormsPage.tsx +4 -4
- package/src/pages/PeoplePage.tsx +21 -5
- package/src/pages/admin/AiAdminPage.tsx +52 -0
- package/src/pages/admin/AiPage.tsx +136 -32
- package/src/pages/admin/{McpPage.tsx → McpPanel.tsx} +4 -6
- package/src/pages/admin/PrivacyPage.tsx +42 -0
- package/src/pages/forms/EmbedPanel.tsx +5 -1
- package/src/pages/forms/FieldsEditor.tsx +204 -15
- package/src/pages/forms/FormSettings.tsx +156 -9
- package/src/pages/forms/SubmissionDetail.tsx +2 -1
- package/src/pages/forms/SubmissionsTable.tsx +2 -1
- package/src/pages/forms/fieldList.ts +39 -10
- package/src/pages/forms/template.ts +13 -0
- package/src/registry/context.ts +13 -0
- package/src/registry/contributions.ts +34 -1
- package/src/registry/registry.ts +30 -0
package/src/modules/aiRunner.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AI_SERVICE_LABELS } from '@kelpie/schemas'
|
|
2
|
+
|
|
1
3
|
import { ApiError } from '../api/client.ts'
|
|
2
4
|
import { useAiRunForAgentRun, useAiSettings } from '../api/resources/ai.ts'
|
|
3
5
|
import { useAgents } from '../api/resources/agentTasks.ts'
|
|
@@ -25,20 +27,21 @@ function useAvailability(options: { readonly enabled: boolean }): AgentRunnerAva
|
|
|
25
27
|
if (settings.error !== null) {
|
|
26
28
|
// The runtime answers 403 or 404 when the module is switched off.
|
|
27
29
|
return settings.error instanceof ApiError && (settings.error.status === 403 || settings.error.status === 404)
|
|
28
|
-
? { status: 'unavailable', reason: '
|
|
29
|
-
: { status: 'unavailable', reason: '
|
|
30
|
+
? { status: 'unavailable', reason: 'AI is switched off for this workspace.' }
|
|
31
|
+
: { status: 'unavailable', reason: 'AI settings could not be read.' }
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
const record = settings.record
|
|
35
|
+
const label = record === undefined ? 'AI' : AI_SERVICE_LABELS[record.service]
|
|
33
36
|
|
|
34
37
|
if (record === undefined || !record.enabled) {
|
|
35
|
-
return { status: 'unavailable', reason:
|
|
38
|
+
return { status: 'unavailable', reason: `${label} is not enabled. An admin can enable it under Admin → AI.` }
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
if (!record.configured) {
|
|
39
42
|
return {
|
|
40
43
|
status: 'unavailable',
|
|
41
|
-
reason:
|
|
44
|
+
reason: `${label} has no provider key. An admin can add one under Admin → AI.`,
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
|
|
@@ -47,7 +50,7 @@ function useAvailability(options: { readonly enabled: boolean }): AgentRunnerAva
|
|
|
47
50
|
if (agent === undefined) {
|
|
48
51
|
return {
|
|
49
52
|
status: 'unavailable',
|
|
50
|
-
reason:
|
|
53
|
+
reason: `The ${label} agent is missing. An admin can save Admin → AI again to restore it.`,
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { personIntakeDependencies } from '@kelpie/schemas'
|
|
2
|
+
import type { PersonIntakeItem } from '@kelpie/schemas'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The items that can be written given what is ticked: an item whose
|
|
6
|
+
* dependency is unticked, or cannot be written, drops out too.
|
|
7
|
+
*/
|
|
8
|
+
export function effectiveSelection(items: readonly PersonIntakeItem[], ticked: ReadonlySet<string>): ReadonlySet<string> {
|
|
9
|
+
const keys = new Set(items.map((item) => item.key))
|
|
10
|
+
const effective = new Set([...ticked].filter((key) => keys.has(key)))
|
|
11
|
+
let changed = true
|
|
12
|
+
|
|
13
|
+
while (changed) {
|
|
14
|
+
changed = false
|
|
15
|
+
for (const item of items) {
|
|
16
|
+
if (effective.has(item.key) && personIntakeDependencies(item).some((key) => !effective.has(key))) {
|
|
17
|
+
effective.delete(item.key)
|
|
18
|
+
changed = true
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return effective
|
|
24
|
+
}
|
package/src/pages/FormsPage.tsx
CHANGED
|
@@ -136,11 +136,11 @@ export function FormsPage(): React.JSX.Element {
|
|
|
136
136
|
),
|
|
137
137
|
},
|
|
138
138
|
{
|
|
139
|
-
key: '
|
|
140
|
-
header: '
|
|
141
|
-
getSortValue: (form) => form.
|
|
139
|
+
key: 'slug',
|
|
140
|
+
header: 'Slug',
|
|
141
|
+
getSortValue: (form) => form.slug,
|
|
142
142
|
render: (form) => (
|
|
143
|
-
<span className="font-mono text-[12px] text-ink-muted">{form.
|
|
143
|
+
<span className="font-mono text-[12px] text-ink-muted">{form.slug}</span>
|
|
144
144
|
),
|
|
145
145
|
},
|
|
146
146
|
{
|
package/src/pages/PeoplePage.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import { Chip } from '../components/Chip.tsx'
|
|
|
9
9
|
import { SocialNetworkIcon } from '../components/SocialNetworkIcon.tsx'
|
|
10
10
|
import { ColumnPicker } from '../components/ColumnPicker.tsx'
|
|
11
11
|
import { DataTable } from '../components/DataTable.tsx'
|
|
12
|
+
import { AddFromNotesButton, PersonIntakeDialog } from '../components/PersonIntakeDialog.tsx'
|
|
12
13
|
import type { Column } from '../components/DataTable.tsx'
|
|
13
14
|
import { FilterBar, PageHeader } from '../components/PageHeader.tsx'
|
|
14
15
|
import { Paginator } from '../components/Paginator.tsx'
|
|
@@ -59,6 +60,7 @@ export function PeoplePage(): React.JSX.Element {
|
|
|
59
60
|
})
|
|
60
61
|
const directory = usePeopleDirectory(people.records.map((person) => person.id))
|
|
61
62
|
const createPerson = useCreatePerson()
|
|
63
|
+
const [intakeOpen, setIntakeOpen] = useState(false)
|
|
62
64
|
|
|
63
65
|
async function addPerson(): Promise<void> {
|
|
64
66
|
// The same defaults the API applies, so a person created here and one
|
|
@@ -242,13 +244,27 @@ export function PeoplePage(): React.JSX.Element {
|
|
|
242
244
|
}}
|
|
243
245
|
addLabel="Add person"
|
|
244
246
|
actions={
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
<>
|
|
248
|
+
<ColumnPicker
|
|
249
|
+
options={pickerOptions}
|
|
250
|
+
visibleKeys={listView.visibleKeys}
|
|
251
|
+
onChange={listView.setVisibleKeys}
|
|
252
|
+
/>
|
|
253
|
+
<AddFromNotesButton
|
|
254
|
+
onClick={() => {
|
|
255
|
+
setIntakeOpen(true)
|
|
256
|
+
}}
|
|
257
|
+
/>
|
|
258
|
+
</>
|
|
250
259
|
}
|
|
251
260
|
/>
|
|
261
|
+
{intakeOpen && (
|
|
262
|
+
<PersonIntakeDialog
|
|
263
|
+
onClose={() => {
|
|
264
|
+
setIntakeOpen(false)
|
|
265
|
+
}}
|
|
266
|
+
/>
|
|
267
|
+
)}
|
|
252
268
|
<FilterBar
|
|
253
269
|
value={term}
|
|
254
270
|
onChange={setTerm}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import { useSearchParams } from 'react-router'
|
|
3
|
+
|
|
4
|
+
import { PageHeader } from '../../components/PageHeader.tsx'
|
|
5
|
+
import { RecordTabs } from '../../components/RecordTabs.tsx'
|
|
6
|
+
import { useAdminTabs } from '../../registry/context.ts'
|
|
7
|
+
import { inSlotOrder } from '../../registry/registry.ts'
|
|
8
|
+
import { McpPanel } from './McpPanel.tsx'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Admin → AI at `/admin/ai`: how agents reach this workspace.
|
|
12
|
+
*
|
|
13
|
+
* Core owns the page and its MCP tab, so every install has both. The optional
|
|
14
|
+
* `ai` module adds Kelpie AI's Settings and Run log tabs through `adminTab`,
|
|
15
|
+
* ordered before MCP. Without that module the page is MCP alone.
|
|
16
|
+
*
|
|
17
|
+
* The open tab is `?tab=`, so a link can open one; `/admin/mcp` redirects to
|
|
18
|
+
* `?tab=mcp`. With no `tab`, or one no module provides, the first tab opens.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
interface PageTab {
|
|
22
|
+
readonly id: string
|
|
23
|
+
readonly label: string
|
|
24
|
+
readonly order?: number
|
|
25
|
+
readonly render: () => ReactNode
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const MCP_TAB: PageTab = { id: 'mcp', label: 'MCP', order: 300, render: () => <McpPanel /> }
|
|
29
|
+
|
|
30
|
+
export function AiAdminPage(): React.JSX.Element {
|
|
31
|
+
const moduleTabs = useAdminTabs('ai')
|
|
32
|
+
const tabs = inSlotOrder<PageTab>([...moduleTabs, MCP_TAB])
|
|
33
|
+
const [searchParams, setSearchParams] = useSearchParams()
|
|
34
|
+
const requested = searchParams.get('tab')
|
|
35
|
+
const active = tabs.find((tab) => tab.id === requested) ?? tabs[0] ?? MCP_TAB
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className="animate-slide-in mx-auto max-w-4xl space-y-6">
|
|
39
|
+
<PageHeader title="AI" description="Connect agents to this workspace, and run agent tasks." />
|
|
40
|
+
<RecordTabs
|
|
41
|
+
tabs={tabs.map((tab) => ({ id: tab.id, label: tab.label }))}
|
|
42
|
+
active={active.id}
|
|
43
|
+
onChange={(id) => {
|
|
44
|
+
setSearchParams({ tab: id }, { replace: true })
|
|
45
|
+
}}
|
|
46
|
+
ariaLabel="AI sections"
|
|
47
|
+
>
|
|
48
|
+
{active.render()}
|
|
49
|
+
</RecordTabs>
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import { AI_DEFAULT_MODELS, AI_PROVIDER_LABELS, AI_PROVIDERS } from '@kelpie/schemas'
|
|
2
|
-
import type { AiProvider, AiRun, AiSettings, AiSettingsInput } from '@kelpie/schemas'
|
|
1
|
+
import { AI_DEFAULT_MODELS, AI_PROVIDER_LABELS, AI_PROVIDERS, AI_SERVICE_LABELS } from '@kelpie/schemas'
|
|
2
|
+
import type { AgentTaskTargetType, AiProvider, AiRun, AiSettings, AiSettingsInput } from '@kelpie/schemas'
|
|
3
3
|
import { useState } from 'react'
|
|
4
4
|
import type { FormEvent } from 'react'
|
|
5
|
+
import { Link } from 'react-router'
|
|
5
6
|
|
|
6
7
|
import { useTimezone } from '../../api/resources/account.ts'
|
|
7
|
-
import { useAiRuns, useAiSettings, useDisableAi, useSaveAiSettings } from '../../api/resources/ai.ts'
|
|
8
|
+
import { useAiRuns, useAiServiceLabel, useAiSettings, useDisableAi, useSaveAiSettings } from '../../api/resources/ai.ts'
|
|
8
9
|
import { Chip } from '../../components/Chip.tsx'
|
|
9
10
|
import type { ChipTone } from '../../components/Chip.tsx'
|
|
10
|
-
import {
|
|
11
|
+
import { LinkedText } from '../../components/LinkedText.tsx'
|
|
12
|
+
import { Paginator } from '../../components/Paginator.tsx'
|
|
11
13
|
import { ErrorPanel, LoadingPanel } from '../../components/QueryState.tsx'
|
|
12
14
|
import { formatRelativeTime } from '../../lib/dates.ts'
|
|
15
|
+
import { targetHref } from '../../lib/recordLinks.ts'
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
|
-
* The
|
|
18
|
+
* The optional `ai` module's two tabs on Admin → AI, the core page at
|
|
19
|
+
* `/admin/ai` (`AiAdminPage`), beside core's MCP tab.
|
|
16
20
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
21
|
+
* Settings for Kelpie AI in this workspace, and its run log. Both read the
|
|
22
|
+
* same `/v1/ai/*` endpoints an agent would use.
|
|
19
23
|
*
|
|
20
24
|
* What the settings part shows depends on the module's key mode. In
|
|
21
25
|
* `workspace` mode an admin picks a provider, pastes their own API key, and
|
|
@@ -37,6 +41,21 @@ const OPERATION_TONES: Readonly<Record<string, ChipTone>> = {
|
|
|
37
41
|
skipped: 'neutral',
|
|
38
42
|
}
|
|
39
43
|
|
|
44
|
+
/** A `workspace` target is not shown: every run is in this workspace. */
|
|
45
|
+
const TARGET_TYPE_LABELS: Readonly<Record<Exclude<AgentTaskTargetType, 'workspace'>, string>> = {
|
|
46
|
+
person: 'Person',
|
|
47
|
+
company: 'Company',
|
|
48
|
+
deal: 'Deal',
|
|
49
|
+
opportunity: 'Opportunity',
|
|
50
|
+
partnership: 'Partnership',
|
|
51
|
+
raise: 'Raise',
|
|
52
|
+
enquiry: 'Enquiry',
|
|
53
|
+
event: 'Event',
|
|
54
|
+
candidate: 'Candidate',
|
|
55
|
+
role: 'Role',
|
|
56
|
+
handbook: 'Handbook page',
|
|
57
|
+
}
|
|
58
|
+
|
|
40
59
|
const inputClass =
|
|
41
60
|
'w-full max-w-md rounded-md border border-border bg-surface px-3 py-2 text-[13px] outline-none focus:border-accent focus:ring-2 focus:ring-accent/20'
|
|
42
61
|
const primaryButtonClass =
|
|
@@ -218,22 +237,64 @@ function DeploymentKeyControls({ settings }: { readonly settings: AiSettings }):
|
|
|
218
237
|
)
|
|
219
238
|
}
|
|
220
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Whether Add from notes may search the web. Saves on change: it is one
|
|
242
|
+
* switch, and the provider and key are untouched, so either key mode sends it.
|
|
243
|
+
*/
|
|
244
|
+
function WebSearchToggle({ settings }: { readonly settings: AiSettings }): React.JSX.Element {
|
|
245
|
+
const save = useSaveAiSettings()
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<div className="mt-4 space-y-2 border-t border-border pt-4">
|
|
249
|
+
<label className="flex items-start gap-2 text-[13px] text-ink">
|
|
250
|
+
<input
|
|
251
|
+
type="checkbox"
|
|
252
|
+
className="mt-0.5"
|
|
253
|
+
checked={settings.webSearch}
|
|
254
|
+
disabled={save.isPending}
|
|
255
|
+
onChange={(event) => {
|
|
256
|
+
save.run({ webSearch: event.target.checked })
|
|
257
|
+
}}
|
|
258
|
+
/>
|
|
259
|
+
<span>
|
|
260
|
+
<span className="font-medium">Web search</span>
|
|
261
|
+
<span className="block text-[12px] text-ink-muted">
|
|
262
|
+
Add from notes on People may use the provider's web search to research a person. Agent-task runs never
|
|
263
|
+
search. Turn this off to work from pasted notes and the CRM only.
|
|
264
|
+
</span>
|
|
265
|
+
</span>
|
|
266
|
+
</label>
|
|
267
|
+
{save.error !== null && <ErrorPanel error={save.error} />}
|
|
268
|
+
</div>
|
|
269
|
+
)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Kelpie AI is a hosted service: its provider and model are its own, so the
|
|
274
|
+
* panel names the service and leaves them out. A custom provider is the
|
|
275
|
+
* workspace's own, so the panel shows which one and which model.
|
|
276
|
+
*/
|
|
221
277
|
function SettingsPanel({ settings }: { readonly settings: AiSettings }): React.JSX.Element {
|
|
222
278
|
const disable = useDisableAi()
|
|
279
|
+
const label = AI_SERVICE_LABELS[settings.service]
|
|
280
|
+
const isHosted = settings.service === 'kelpie_ai'
|
|
223
281
|
|
|
224
282
|
return (
|
|
225
283
|
<section className="rounded-md border border-border p-5">
|
|
226
284
|
<div className="flex flex-wrap items-center gap-2">
|
|
227
|
-
<h2 className="text-[15px] font-semibold text-ink">
|
|
285
|
+
<h2 className="text-[15px] font-semibold text-ink">{label}</h2>
|
|
228
286
|
<Chip tone={settings.enabled ? 'success' : 'neutral'}>{settings.enabled ? 'Enabled' : 'Not enabled'}</Chip>
|
|
229
287
|
</div>
|
|
230
288
|
<p className="mt-2 max-w-2xl text-[13px] leading-relaxed text-ink-muted">
|
|
231
|
-
|
|
232
|
-
|
|
289
|
+
{isHosted
|
|
290
|
+
? 'Kelpie AI runs agent tasks for you: enrichment, summaries, follow-ups and notes.'
|
|
291
|
+
: 'Run agent tasks on your own OpenAI or Anthropic key: enrichment, summaries, follow-ups and notes.'}{' '}
|
|
292
|
+
Kelpie reads the record and its neighbours, asks the model for a reply, and applies that reply through the
|
|
293
|
+
same tools any agent uses.
|
|
233
294
|
</p>
|
|
234
295
|
|
|
235
296
|
<dl className="mt-4 grid max-w-md grid-cols-2 gap-y-2 text-[13px]">
|
|
236
|
-
{settings.provider !== null && (
|
|
297
|
+
{!isHosted && settings.provider !== null && (
|
|
237
298
|
<>
|
|
238
299
|
<dt className="text-ink-muted">Provider</dt>
|
|
239
300
|
<dd className="text-ink">{AI_PROVIDER_LABELS[settings.provider]}</dd>
|
|
@@ -258,6 +319,8 @@ function SettingsPanel({ settings }: { readonly settings: AiSettings }): React.J
|
|
|
258
319
|
<DeploymentKeyControls settings={settings} />
|
|
259
320
|
)}
|
|
260
321
|
|
|
322
|
+
{settings.enabled && settings.configured && <WebSearchToggle settings={settings} />}
|
|
323
|
+
|
|
261
324
|
{settings.enabled && (
|
|
262
325
|
<div className="mt-4 space-y-2 border-t border-border pt-4">
|
|
263
326
|
{disable.error !== null && <ErrorPanel error={disable.error} />}
|
|
@@ -272,7 +335,7 @@ function SettingsPanel({ settings }: { readonly settings: AiSettings }): React.J
|
|
|
272
335
|
{disable.isPending ? 'Disabling…' : 'Disable AI'}
|
|
273
336
|
</button>
|
|
274
337
|
<p className="text-[12px] text-ink-muted">
|
|
275
|
-
Disabling removes
|
|
338
|
+
Disabling removes {label} from the Run menu
|
|
276
339
|
{settings.keySource === 'workspace' ? ' and deletes the stored key' : ''}. The run log is kept.
|
|
277
340
|
</p>
|
|
278
341
|
</div>
|
|
@@ -281,8 +344,50 @@ function SettingsPanel({ settings }: { readonly settings: AiSettings }): React.J
|
|
|
281
344
|
)
|
|
282
345
|
}
|
|
283
346
|
|
|
347
|
+
/** `22012 in · 1576 out`, or null when the run recorded no token counts. */
|
|
348
|
+
function tokens(run: AiRun): string | null {
|
|
349
|
+
return run.inputTokens === null || run.outputTokens === null
|
|
350
|
+
? null
|
|
351
|
+
: `${String(run.inputTokens)} in · ${String(run.outputTokens)} out`
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* `Company · Acme`, with the name linked to the record's page, as an Activity
|
|
356
|
+
* row names its record. Nothing for a `workspace` target. The type alone when
|
|
357
|
+
* the record has no name, because it has since been deleted.
|
|
358
|
+
*/
|
|
359
|
+
function RunTarget({ run }: { readonly run: AiRun }): React.JSX.Element | null {
|
|
360
|
+
if (run.targetType === 'workspace') {
|
|
361
|
+
return null
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const href = targetHref(run.targetType === 'handbook' ? 'handbook_page' : run.targetType, run.targetId)
|
|
365
|
+
|
|
366
|
+
return (
|
|
367
|
+
<span className="text-[12px] text-ink-muted">
|
|
368
|
+
{TARGET_TYPE_LABELS[run.targetType]}
|
|
369
|
+
{run.targetName !== null && (
|
|
370
|
+
<>
|
|
371
|
+
{' · '}
|
|
372
|
+
{href === undefined ? (
|
|
373
|
+
run.targetName
|
|
374
|
+
) : (
|
|
375
|
+
<Link to={href} title={run.targetId} className="hover:text-accent hover:underline">
|
|
376
|
+
{run.targetName}
|
|
377
|
+
</Link>
|
|
378
|
+
)}
|
|
379
|
+
</>
|
|
380
|
+
)}
|
|
381
|
+
</span>
|
|
382
|
+
)
|
|
383
|
+
}
|
|
384
|
+
|
|
284
385
|
function RunLog(): React.JSX.Element {
|
|
285
|
-
const
|
|
386
|
+
const list = useAiRuns()
|
|
387
|
+
const serviceLabel = useAiServiceLabel()
|
|
388
|
+
// Kelpie AI's model is the hosted service's own, as on the Settings tab.
|
|
389
|
+
const showModel = useAiSettings().record?.service !== 'kelpie_ai'
|
|
390
|
+
const { records: runs, isLoading, error } = list
|
|
286
391
|
const timezone = useTimezone()
|
|
287
392
|
|
|
288
393
|
return (
|
|
@@ -292,7 +397,7 @@ function RunLog(): React.JSX.Element {
|
|
|
292
397
|
{error !== null && <ErrorPanel error={error} />}
|
|
293
398
|
{!isLoading && error === null && runs.length === 0 && (
|
|
294
399
|
<p className="mt-2 text-[13px] text-ink-muted">
|
|
295
|
-
No runs yet. Start one from the Agent menu on any record page and pick <em>
|
|
400
|
+
No runs yet. Start one from the Agent menu on any record page and pick <em>{serviceLabel}</em>.
|
|
296
401
|
</p>
|
|
297
402
|
)}
|
|
298
403
|
{runs.length > 0 && (
|
|
@@ -302,30 +407,24 @@ function RunLog(): React.JSX.Element {
|
|
|
302
407
|
<div className="flex flex-wrap items-center gap-2">
|
|
303
408
|
<Chip tone={STATUS_TONES[run.status]}>{run.status}</Chip>
|
|
304
409
|
<span className="text-[13px] font-medium text-ink">{run.taskId}</span>
|
|
305
|
-
<
|
|
306
|
-
{run.targetType} · {run.targetId}
|
|
307
|
-
</span>
|
|
410
|
+
<RunTarget run={run} />
|
|
308
411
|
<span className="ml-auto text-[12px] text-ink-faint">{formatRelativeTime(run.createdAt, timezone)}</span>
|
|
309
412
|
</div>
|
|
310
413
|
<p className="mt-1 text-[12px] text-ink-muted">
|
|
311
|
-
<span className="font-mono">{run.model}</span>
|
|
312
|
-
{run
|
|
313
|
-
|
|
314
|
-
: ''}
|
|
414
|
+
{showModel && <span className="font-mono">{run.model}</span>}
|
|
415
|
+
{showModel && tokens(run) !== null && ' · '}
|
|
416
|
+
{tokens(run)}
|
|
315
417
|
</p>
|
|
316
418
|
{run.failureReason !== null && <p className="mt-2 text-[12px] text-danger">{run.failureReason}</p>}
|
|
317
|
-
{run.output !== null && (
|
|
318
|
-
<pre className="mt-2 max-h-64 overflow-auto whitespace-pre-wrap rounded bg-surface-raised p-2 text-[12px] text-ink">
|
|
319
|
-
{run.output}
|
|
320
|
-
</pre>
|
|
321
|
-
)}
|
|
322
419
|
{run.operations !== null && run.operations.length > 0 && (
|
|
323
420
|
<ul className="mt-2 flex flex-col gap-1">
|
|
324
421
|
{run.operations.map((operation, index) => (
|
|
325
422
|
<li key={`${run.id}-op-${String(index)}`} className="flex flex-wrap items-center gap-2 text-[12px]">
|
|
326
423
|
<Chip tone={OPERATION_TONES[operation.status] ?? 'neutral'}>{operation.status}</Chip>
|
|
327
424
|
<span className="font-medium text-ink">{operation.kind}</span>
|
|
328
|
-
<span className="text-ink-muted">
|
|
425
|
+
<span className="text-ink-muted">
|
|
426
|
+
<LinkedText text={operation.detail} references={operation.references} />
|
|
427
|
+
</span>
|
|
329
428
|
</li>
|
|
330
429
|
))}
|
|
331
430
|
</ul>
|
|
@@ -334,20 +433,25 @@ function RunLog(): React.JSX.Element {
|
|
|
334
433
|
))}
|
|
335
434
|
</ul>
|
|
336
435
|
)}
|
|
436
|
+
{runs.length > 0 && <Paginator list={list} />}
|
|
337
437
|
</section>
|
|
338
438
|
)
|
|
339
439
|
}
|
|
340
440
|
|
|
341
|
-
|
|
441
|
+
/** The Settings tab the `ai` module adds to Admin → AI. */
|
|
442
|
+
export function AiSettingsTab(): React.JSX.Element {
|
|
342
443
|
const { record: settings, isLoading, error } = useAiSettings()
|
|
343
444
|
|
|
344
445
|
return (
|
|
345
|
-
|
|
346
|
-
<PageHeader title="AI" description="Run agent tasks with your own model provider." />
|
|
446
|
+
<>
|
|
347
447
|
{isLoading && <LoadingPanel label="Loading AI settings…" />}
|
|
348
448
|
{error !== null && <ErrorPanel error={error} />}
|
|
349
449
|
{settings !== undefined && <SettingsPanel settings={settings} />}
|
|
350
|
-
|
|
351
|
-
</div>
|
|
450
|
+
</>
|
|
352
451
|
)
|
|
353
452
|
}
|
|
453
|
+
|
|
454
|
+
/** The Run log tab the `ai` module adds to Admin → AI. */
|
|
455
|
+
export function AiRunLogTab(): React.JSX.Element {
|
|
456
|
+
return <RunLog />
|
|
457
|
+
}
|
|
@@ -12,14 +12,13 @@ import {
|
|
|
12
12
|
useDeleteAgent,
|
|
13
13
|
} from '../../api/resources/agentTasks.ts'
|
|
14
14
|
import { useMcpTools } from '../../api/resources/mcpTools.ts'
|
|
15
|
-
import { PageHeader } from '../../components/PageHeader.tsx'
|
|
16
15
|
import { ErrorPanel, LoadingPanel } from '../../components/QueryState.tsx'
|
|
17
16
|
import { CopyButton } from '../../components/CopyButton.tsx'
|
|
18
17
|
import { formatRelativeTime } from '../../lib/dates.ts'
|
|
19
18
|
import { mcpClientConfig, mcpEndpoint } from '../../lib/mcpConfig.ts'
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
|
-
* How an agent connects to this workspace.
|
|
21
|
+
* How an agent connects to this workspace: the MCP tab on Admin → AI.
|
|
23
22
|
*
|
|
24
23
|
* Everything on the page is derived rather than written down. The endpoint comes
|
|
25
24
|
* from the origin the browser reached the app on, the same way a form's embed URL
|
|
@@ -50,14 +49,13 @@ function matches(tool: McpTool, term: string): boolean {
|
|
|
50
49
|
)
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
/** The MCP tab on Admin → AI. Core, so every install has it. */
|
|
53
|
+
export function McpPanel(): React.JSX.Element {
|
|
54
54
|
const endpoint = mcpEndpoint()
|
|
55
55
|
const config = mcpClientConfig(endpoint, 'kp_live_…')
|
|
56
56
|
|
|
57
57
|
return (
|
|
58
|
-
<div className="
|
|
59
|
-
<PageHeader title="MCP" description="Connect agents to this workspace over Streamable HTTP." />
|
|
60
|
-
|
|
58
|
+
<div className="space-y-6">
|
|
61
59
|
<section className="rounded-md border border-border p-5">
|
|
62
60
|
<h2 className="text-[15px] font-semibold text-ink">How agents use Kelpie</h2>
|
|
63
61
|
<p className="mt-2 max-w-2xl text-[13px] leading-relaxed text-ink-muted">
|
|
@@ -58,12 +58,15 @@ function PurposesAdmin(): React.JSX.Element {
|
|
|
58
58
|
slug: 'contact',
|
|
59
59
|
label: 'Contact',
|
|
60
60
|
description: 'Being contacted by the workspace about our work together.',
|
|
61
|
+
statement:
|
|
62
|
+
'I consent to {{workspace}} contacting me and retaining my information for the purpose of handling my enquiry.',
|
|
61
63
|
defaultStatus: 'unknown',
|
|
62
64
|
})
|
|
63
65
|
await create.runAsync({
|
|
64
66
|
slug: 'marketing',
|
|
65
67
|
label: 'Marketing',
|
|
66
68
|
description: 'Marketing communications — newsletters, product updates, and campaigns.',
|
|
69
|
+
statement: 'I consent to {{workspace}} retaining my information for marketing purposes.',
|
|
67
70
|
defaultStatus: 'unknown',
|
|
68
71
|
})
|
|
69
72
|
} catch {
|
|
@@ -165,6 +168,7 @@ function AddPurposeForm({ onDone }: AddPurposeFormProps): React.JSX.Element {
|
|
|
165
168
|
const [slug, setSlug] = useState('')
|
|
166
169
|
const [slugEdited, setSlugEdited] = useState(false)
|
|
167
170
|
const [description, setDescription] = useState('')
|
|
171
|
+
const [statement, setStatement] = useState('')
|
|
168
172
|
const [defaultStatus, setDefaultStatus] = useState<ConsentPurposeStatus>('unknown')
|
|
169
173
|
|
|
170
174
|
const derivedSlug = useMemo(
|
|
@@ -183,6 +187,7 @@ function AddPurposeForm({ onDone }: AddPurposeFormProps): React.JSX.Element {
|
|
|
183
187
|
slug: derivedSlug,
|
|
184
188
|
label: trimmedLabel,
|
|
185
189
|
description: description.trim(),
|
|
190
|
+
statement: statement.trim(),
|
|
186
191
|
defaultStatus,
|
|
187
192
|
})
|
|
188
193
|
.then(() => {
|
|
@@ -190,6 +195,7 @@ function AddPurposeForm({ onDone }: AddPurposeFormProps): React.JSX.Element {
|
|
|
190
195
|
setSlug('')
|
|
191
196
|
setSlugEdited(false)
|
|
192
197
|
setDescription('')
|
|
198
|
+
setStatement('')
|
|
193
199
|
setDefaultStatus('unknown')
|
|
194
200
|
onDone()
|
|
195
201
|
})
|
|
@@ -252,6 +258,7 @@ function AddPurposeForm({ onDone }: AddPurposeFormProps): React.JSX.Element {
|
|
|
252
258
|
}}
|
|
253
259
|
/>
|
|
254
260
|
</Field>
|
|
261
|
+
<StatementField value={statement} onChange={setStatement} />
|
|
255
262
|
|
|
256
263
|
{create.error !== null && <ErrorPanel error={create.error} />}
|
|
257
264
|
|
|
@@ -277,6 +284,32 @@ function AddPurposeForm({ onDone }: AddPurposeFormProps): React.JSX.Element {
|
|
|
277
284
|
)
|
|
278
285
|
}
|
|
279
286
|
|
|
287
|
+
/**
|
|
288
|
+
* The consent statement a form shows beside this purpose's checkbox. The
|
|
289
|
+
* Person record keeps showing the label.
|
|
290
|
+
*/
|
|
291
|
+
function StatementField({
|
|
292
|
+
value,
|
|
293
|
+
onChange,
|
|
294
|
+
}: {
|
|
295
|
+
readonly value: string
|
|
296
|
+
readonly onChange: (value: string) => void
|
|
297
|
+
}): React.JSX.Element {
|
|
298
|
+
return (
|
|
299
|
+
<Field label="Consent statement (shown on forms instead of the label; {{workspace}} becomes the workspace name)">
|
|
300
|
+
<textarea
|
|
301
|
+
className="min-h-[60px] w-full rounded-md border border-border bg-transparent px-2 py-1 text-[13px] outline-none focus:border-accent"
|
|
302
|
+
value={value}
|
|
303
|
+
maxLength={1000}
|
|
304
|
+
placeholder="I consent to {{workspace}} …"
|
|
305
|
+
onChange={(event) => {
|
|
306
|
+
onChange(event.target.value)
|
|
307
|
+
}}
|
|
308
|
+
/>
|
|
309
|
+
</Field>
|
|
310
|
+
)
|
|
311
|
+
}
|
|
312
|
+
|
|
280
313
|
interface PurposeRowProps {
|
|
281
314
|
readonly purpose: ConsentPurpose
|
|
282
315
|
}
|
|
@@ -287,6 +320,7 @@ function PurposeRow({ purpose }: PurposeRowProps): React.JSX.Element {
|
|
|
287
320
|
const [editing, setEditing] = useState(false)
|
|
288
321
|
const [label, setLabel] = useState(purpose.label)
|
|
289
322
|
const [description, setDescription] = useState(purpose.description)
|
|
323
|
+
const [statement, setStatement] = useState(purpose.statement)
|
|
290
324
|
const [defaultStatus, setDefaultStatus] = useState<ConsentPurposeStatus>(purpose.defaultStatus)
|
|
291
325
|
const [confirmingDelete, setConfirmingDelete] = useState(false)
|
|
292
326
|
|
|
@@ -298,6 +332,7 @@ function PurposeRow({ purpose }: PurposeRowProps): React.JSX.Element {
|
|
|
298
332
|
changes: {
|
|
299
333
|
label: label.trim(),
|
|
300
334
|
description: description.trim(),
|
|
335
|
+
statement: statement.trim(),
|
|
301
336
|
defaultStatus,
|
|
302
337
|
},
|
|
303
338
|
})
|
|
@@ -325,6 +360,12 @@ function PurposeRow({ purpose }: PurposeRowProps): React.JSX.Element {
|
|
|
325
360
|
{purpose.description.length > 0 && (
|
|
326
361
|
<p className="mt-1 text-[12px] text-ink-muted">{purpose.description}</p>
|
|
327
362
|
)}
|
|
363
|
+
{purpose.statement.length > 0 && (
|
|
364
|
+
<p className="mt-1 text-[12px] text-ink">
|
|
365
|
+
<span className="text-ink-faint">On forms: </span>
|
|
366
|
+
{purpose.statement}
|
|
367
|
+
</p>
|
|
368
|
+
)}
|
|
328
369
|
</div>
|
|
329
370
|
<div className="flex shrink-0 gap-2">
|
|
330
371
|
<button
|
|
@@ -384,6 +425,7 @@ function PurposeRow({ purpose }: PurposeRowProps): React.JSX.Element {
|
|
|
384
425
|
}}
|
|
385
426
|
/>
|
|
386
427
|
</Field>
|
|
428
|
+
<StatementField value={statement} onChange={setStatement} />
|
|
387
429
|
{update.error !== null && <ErrorPanel error={update.error} />}
|
|
388
430
|
<div className="flex justify-end">
|
|
389
431
|
<button
|
|
@@ -160,10 +160,14 @@ function EmbedPreviewModal({
|
|
|
160
160
|
return
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
// The same check the pasted snippet makes: only the embed page may resize it.
|
|
164
|
+
const embedOrigin = new URL(url, window.location.href).origin
|
|
165
|
+
|
|
163
166
|
function onMessage(event: MessageEvent): void {
|
|
164
167
|
const data = event.data as { kelpie?: string; formId?: string; height?: number } | null
|
|
165
168
|
|
|
166
169
|
if (
|
|
170
|
+
event.origin !== embedOrigin ||
|
|
167
171
|
data === null ||
|
|
168
172
|
typeof data !== 'object' ||
|
|
169
173
|
data.kelpie !== 'height' ||
|
|
@@ -182,7 +186,7 @@ function EmbedPreviewModal({
|
|
|
182
186
|
return () => {
|
|
183
187
|
window.removeEventListener('message', onMessage)
|
|
184
188
|
}
|
|
185
|
-
}, [formId, mode])
|
|
189
|
+
}, [formId, mode, url])
|
|
186
190
|
|
|
187
191
|
useEffect(() => {
|
|
188
192
|
function onKeyDown(event: KeyboardEvent): void {
|