@kelpie/ui 0.17.0 → 0.19.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/AiDrawer.d.ts +13 -0
- package/dist/components/AiDrawer.d.ts.map +1 -0
- package/dist/components/AiDrawer.js +165 -0
- package/dist/components/AiDrawer.js.map +1 -0
- package/dist/components/ApiKeysPanel.js +1 -1
- package/dist/components/DataTable.js +1 -1
- package/dist/components/KanbanBoard.d.ts +5 -1
- package/dist/components/KanbanBoard.d.ts.map +1 -1
- package/dist/components/KanbanBoard.js +37 -2
- package/dist/components/KanbanBoard.js.map +1 -1
- package/dist/components/NotesPanel.js +2 -2
- package/dist/components/NotesPanel.js.map +1 -1
- package/dist/components/PageHeader.js +1 -1
- package/dist/components/PageHeader.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/PersonIntakePanel.d.ts +21 -0
- package/dist/components/PersonIntakePanel.d.ts.map +1 -0
- package/dist/components/PersonIntakePanel.js +76 -0
- package/dist/components/PersonIntakePanel.js.map +1 -0
- package/dist/components/SegmentedControl.js +2 -2
- package/dist/components/SegmentedControl.js.map +1 -1
- package/dist/components/Shell.d.ts.map +1 -1
- package/dist/components/Shell.js +40 -4
- package/dist/components/Shell.js.map +1 -1
- package/dist/components/WorkspaceSwitcher.d.ts.map +1 -1
- package/dist/components/WorkspaceSwitcher.js +10 -2
- package/dist/components/WorkspaceSwitcher.js.map +1 -1
- package/dist/components/aiDrawerState.d.ts +45 -0
- package/dist/components/aiDrawerState.d.ts.map +1 -0
- package/dist/components/aiDrawerState.js +14 -0
- package/dist/components/aiDrawerState.js.map +1 -0
- package/dist/components/personIntakeTask.d.ts +5 -0
- package/dist/components/personIntakeTask.d.ts.map +1 -0
- package/dist/components/personIntakeTask.js +13 -0
- package/dist/components/personIntakeTask.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/mediaQuery.d.ts +9 -0
- package/dist/lib/mediaQuery.d.ts.map +1 -0
- package/dist/lib/mediaQuery.js +24 -0
- package/dist/lib/mediaQuery.js.map +1 -0
- package/dist/modules/PersonIntakeWizard.d.ts +3 -0
- package/dist/modules/PersonIntakeWizard.d.ts.map +1 -0
- package/dist/modules/PersonIntakeWizard.js +227 -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/FormDetail.d.ts.map +1 -1
- package/dist/pages/FormDetail.js +7 -7
- package/dist/pages/FormDetail.js.map +1 -1
- package/dist/pages/FormsPage.js +4 -4
- package/dist/pages/FormsPage.js.map +1 -1
- package/dist/pages/ListDetail.d.ts.map +1 -1
- package/dist/pages/ListDetail.js +2 -2
- package/dist/pages/ListDetail.js.map +1 -1
- package/dist/pages/PeoplePage.d.ts.map +1 -1
- package/dist/pages/PeoplePage.js +9 -1
- package/dist/pages/PeoplePage.js.map +1 -1
- package/dist/pages/RoleDetail.d.ts.map +1 -1
- package/dist/pages/RoleDetail.js +3 -3
- package/dist/pages/RoleDetail.js.map +1 -1
- package/dist/pages/account/ConnectedAppsPage.js +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/DataPage.js +2 -2
- 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/AddFieldMenu.js +2 -2
- package/dist/pages/forms/AddFieldMenu.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/pages/handbook/HandbookPage.js +4 -4
- package/dist/pages/handbook/HandbookPage.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 +37 -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/AiDrawer.tsx +272 -0
- package/src/components/ApiKeysPanel.tsx +1 -1
- package/src/components/DataTable.tsx +1 -1
- package/src/components/KanbanBoard.tsx +119 -2
- package/src/components/NotesPanel.tsx +7 -4
- package/src/components/PageHeader.tsx +1 -1
- package/src/components/PersonIntakePanel.tsx +193 -0
- package/src/components/SegmentedControl.tsx +2 -2
- package/src/components/Shell.tsx +99 -13
- package/src/components/WorkspaceSwitcher.tsx +13 -2
- package/src/components/aiDrawerState.ts +61 -0
- package/src/components/personIntakeTask.tsx +14 -0
- package/src/index.ts +12 -1
- package/src/lib/mediaQuery.ts +32 -0
- package/src/modules/PersonIntakeWizard.tsx +638 -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/FormDetail.tsx +18 -14
- package/src/pages/FormsPage.tsx +4 -4
- package/src/pages/ListDetail.tsx +5 -3
- package/src/pages/PeoplePage.tsx +18 -5
- package/src/pages/RoleDetail.tsx +10 -5
- package/src/pages/account/ConnectedAppsPage.tsx +1 -1
- package/src/pages/admin/AiAdminPage.tsx +52 -0
- package/src/pages/admin/AiPage.tsx +136 -32
- package/src/pages/admin/DataPage.tsx +2 -2
- package/src/pages/admin/{McpPage.tsx → McpPanel.tsx} +4 -6
- package/src/pages/admin/PrivacyPage.tsx +42 -0
- package/src/pages/forms/AddFieldMenu.tsx +2 -2
- 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/pages/handbook/HandbookPage.tsx +5 -5
- package/src/registry/context.ts +13 -0
- package/src/registry/contributions.ts +39 -1
- package/src/registry/registry.ts +30 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formFieldDisplayLabel } from '@kelpie/schemas'
|
|
1
2
|
import type { Form, FormSubmission, FormSubmissionActionEntry } from '@kelpie/schemas'
|
|
2
3
|
import { useMemo } from 'react'
|
|
3
4
|
import { Link, useNavigate } from 'react-router'
|
|
@@ -251,7 +252,7 @@ function summarise(form: Form, submission: FormSubmission): string {
|
|
|
251
252
|
? (field.options.find((option) => option.key === answer)?.value ?? answer)
|
|
252
253
|
: answer
|
|
253
254
|
|
|
254
|
-
return `${field
|
|
255
|
+
return `${formFieldDisplayLabel(field)}: ${shown}`
|
|
255
256
|
})
|
|
256
257
|
.filter((part): part is string => part !== undefined)
|
|
257
258
|
.slice(0, 2)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FORM_FIELD_TYPES,
|
|
3
|
+
FORM_LIST_TARGET,
|
|
3
4
|
isCompatibleFormFieldType,
|
|
4
5
|
isKnownMapTarget,
|
|
5
6
|
isRepeatableMapTarget,
|
|
@@ -35,7 +36,13 @@ export interface EditableField extends FormFieldInput {
|
|
|
35
36
|
readonly id: string
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
/** The type picker's text. Each type shows as its own name, except `list`. */
|
|
40
|
+
const FIELD_TYPE_LABELS: Partial<Record<FormFieldType, string>> = { list: 'add to list' }
|
|
41
|
+
|
|
42
|
+
export const FIELD_TYPE_OPTIONS = FORM_FIELD_TYPES.map((type) => ({
|
|
43
|
+
value: type,
|
|
44
|
+
label: FIELD_TYPE_LABELS[type] ?? type,
|
|
45
|
+
}))
|
|
39
46
|
|
|
40
47
|
export interface FindProblemsOptions {
|
|
41
48
|
readonly customFieldDefinitions?: readonly CustomFieldDefinitionRef[]
|
|
@@ -54,6 +61,8 @@ export function toEditableFields(form: Form): EditableField[] {
|
|
|
54
61
|
statement: field.statement,
|
|
55
62
|
consentPurposeIds: [...field.consentPurposeIds],
|
|
56
63
|
consentPurposeLabels: { ...field.consentPurposeLabels },
|
|
64
|
+
listIds: [...field.listIds],
|
|
65
|
+
listLabels: { ...field.listLabels },
|
|
57
66
|
}))
|
|
58
67
|
}
|
|
59
68
|
|
|
@@ -96,9 +105,9 @@ export function editField(
|
|
|
96
105
|
return fields.map((field) => {
|
|
97
106
|
if (field.id !== id) {
|
|
98
107
|
// Only one field may carry a CRM target, so taking one releases it
|
|
99
|
-
// wherever it was. `submission
|
|
100
|
-
// that may repeat — consent's uniqueness is per purpose, not
|
|
101
|
-
// target, and is enforced when the purpose is picked.
|
|
108
|
+
// wherever it was. `submission`, `person.consent` and `lists` are the
|
|
109
|
+
// targets that may repeat — consent's uniqueness is per purpose, not
|
|
110
|
+
// per target, and is enforced when the purpose is picked.
|
|
102
111
|
return change.mapTo !== undefined &&
|
|
103
112
|
!isRepeatableMapTarget(change.mapTo) &&
|
|
104
113
|
field.mapTo === change.mapTo
|
|
@@ -106,19 +115,32 @@ export function editField(
|
|
|
106
115
|
: field
|
|
107
116
|
}
|
|
108
117
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// A consent or notice field must map to person.consent; anything else
|
|
112
|
-
// clears any lingering purpose list.
|
|
118
|
+
let next: EditableField = { ...field, ...change }
|
|
113
119
|
const isConsentLike = next.type === 'consent' || next.type === 'notice'
|
|
120
|
+
const isList = next.type === 'list'
|
|
121
|
+
|
|
122
|
+
// Only a consent or notice field carries purposes, and only a list field
|
|
123
|
+
// carries lists. A field that changes type drops the ones it left behind.
|
|
124
|
+
if (!isConsentLike && (next.consentPurposeIds ?? []).length > 0) {
|
|
125
|
+
next = { ...next, consentPurposeIds: [], consentPurposeLabels: {} }
|
|
126
|
+
}
|
|
127
|
+
if (!isList && (next.listIds ?? []).length > 0) {
|
|
128
|
+
next = { ...next, listIds: [], listLabels: {} }
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// A list field maps to `lists`, and a consent or notice field to
|
|
132
|
+
// person.consent. Each of those targets takes only its own types.
|
|
133
|
+
if (isList && next.mapTo !== FORM_LIST_TARGET) {
|
|
134
|
+
return { ...withoutOptions(next), mapTo: FORM_LIST_TARGET }
|
|
135
|
+
}
|
|
114
136
|
if (isConsentLike && next.mapTo !== PERSON_CONSENT_TARGET) {
|
|
115
137
|
return { ...withoutOptions(next), mapTo: PERSON_CONSENT_TARGET }
|
|
116
138
|
}
|
|
117
139
|
if (next.mapTo === PERSON_CONSENT_TARGET && !isConsentLike) {
|
|
118
140
|
return { ...withoutOptions(next), type: 'consent' }
|
|
119
141
|
}
|
|
120
|
-
if (
|
|
121
|
-
return
|
|
142
|
+
if (next.mapTo === FORM_LIST_TARGET && !isList) {
|
|
143
|
+
return { ...withoutOptions(next), type: 'list' }
|
|
122
144
|
}
|
|
123
145
|
|
|
124
146
|
if (next.type !== 'select') {
|
|
@@ -242,6 +264,13 @@ export function findProblems(
|
|
|
242
264
|
}
|
|
243
265
|
}
|
|
244
266
|
}
|
|
267
|
+
} else if (field.mapTo === FORM_LIST_TARGET) {
|
|
268
|
+
const lists = field.listIds ?? []
|
|
269
|
+
if (lists.length === 0) {
|
|
270
|
+
byField.set(field.id, 'Pick at least one list this field offers.')
|
|
271
|
+
} else if (new Set(lists).size !== lists.length) {
|
|
272
|
+
byField.set(field.id, 'This field lists a list twice.')
|
|
273
|
+
}
|
|
245
274
|
} else if (!isRepeatableMapTarget(field.mapTo)) {
|
|
246
275
|
if (seen.has(field.mapTo)) {
|
|
247
276
|
byField.set(field.id, `Another field already maps to ${field.mapTo}.`)
|
|
@@ -130,6 +130,19 @@ export const SUBMISSION_FIELD_PRESETS: readonly SubmissionFieldPreset[] = [
|
|
|
130
130
|
consentPurposeLabels: {},
|
|
131
131
|
},
|
|
132
132
|
},
|
|
133
|
+
{
|
|
134
|
+
menuLabel: 'Add to list',
|
|
135
|
+
field: {
|
|
136
|
+
label: 'Add to list',
|
|
137
|
+
type: 'list',
|
|
138
|
+
required: false,
|
|
139
|
+
mapTo: 'lists',
|
|
140
|
+
placeholder: null,
|
|
141
|
+
statement: null,
|
|
142
|
+
listIds: [],
|
|
143
|
+
listLabels: {},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
133
146
|
{
|
|
134
147
|
menuLabel: 'Notice',
|
|
135
148
|
field: {
|
|
@@ -173,8 +173,8 @@ export function HandbookLayout(): React.JSX.Element {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
return (
|
|
176
|
-
<div className="animate-fade-in flex min-h-[calc(100vh-8rem)] gap-0 overflow-hidden rounded-md border border-border">
|
|
177
|
-
<aside className="flex w-
|
|
176
|
+
<div className="animate-fade-in flex min-h-[calc(100vh-8rem)] flex-col gap-0 overflow-hidden rounded-md border border-border lg:flex-row">
|
|
177
|
+
<aside className="flex w-full shrink-0 flex-col border-b border-border bg-surface lg:w-[260px] lg:border-r lg:border-b-0">
|
|
178
178
|
<div className="flex items-center justify-between gap-2 border-b border-border px-3 py-3">
|
|
179
179
|
<div>
|
|
180
180
|
<div className="text-[13px] font-semibold text-ink">Handbook</div>
|
|
@@ -191,7 +191,7 @@ export function HandbookLayout(): React.JSX.Element {
|
|
|
191
191
|
New
|
|
192
192
|
</button>
|
|
193
193
|
</div>
|
|
194
|
-
<nav className="flex-1 overflow-y-auto p-2">
|
|
194
|
+
<nav className="max-h-64 flex-1 overflow-y-auto p-2 lg:max-h-none">
|
|
195
195
|
<DndContext
|
|
196
196
|
sensors={sensors}
|
|
197
197
|
collisionDetection={closestCenter}
|
|
@@ -404,7 +404,7 @@ function HandbookEditor({
|
|
|
404
404
|
return (
|
|
405
405
|
<div className="flex h-full flex-col">
|
|
406
406
|
<div className="flex flex-wrap items-start justify-between gap-3 border-b border-border px-5 py-3">
|
|
407
|
-
<div className="min-w-
|
|
407
|
+
<div className="min-w-[12rem] flex-1">
|
|
408
408
|
{editing ? (
|
|
409
409
|
<input
|
|
410
410
|
value={title}
|
|
@@ -422,7 +422,7 @@ function HandbookEditor({
|
|
|
422
422
|
{authorName === undefined ? '' : ` · ${authorName}`}
|
|
423
423
|
</div>
|
|
424
424
|
</div>
|
|
425
|
-
<div className="flex
|
|
425
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
426
426
|
{editing ? (
|
|
427
427
|
<>
|
|
428
428
|
<button
|
package/src/registry/context.ts
CHANGED
|
@@ -2,12 +2,15 @@ import { createContext, useContext } from 'react'
|
|
|
2
2
|
import type { ComponentType } from 'react'
|
|
3
3
|
|
|
4
4
|
import type {
|
|
5
|
+
AdminTab,
|
|
5
6
|
AgentRunner,
|
|
6
7
|
AuthMethod,
|
|
7
8
|
DashboardCard,
|
|
9
|
+
ExtensibleAdminPage,
|
|
8
10
|
ExtensibleRecordType,
|
|
9
11
|
NavItem,
|
|
10
12
|
NavSlot,
|
|
13
|
+
PersonIntakeProvider,
|
|
11
14
|
RecordSidebarCard,
|
|
12
15
|
RecordTab,
|
|
13
16
|
RouteContribution,
|
|
@@ -51,6 +54,11 @@ export function useRecordSidebarCards(objectType: ExtensibleRecordType): readonl
|
|
|
51
54
|
return useUiExtensions().recordSidebarCards(objectType)
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
/** Module tabs for an admin page, in order. The page merges its own tabs in. */
|
|
58
|
+
export function useAdminTabs(page: ExtensibleAdminPage): readonly AdminTab[] {
|
|
59
|
+
return useUiExtensions().adminTabs(page)
|
|
60
|
+
}
|
|
61
|
+
|
|
54
62
|
export function useDashboardCards(): readonly DashboardCard[] {
|
|
55
63
|
return useUiExtensions().dashboardCards()
|
|
56
64
|
}
|
|
@@ -65,6 +73,11 @@ export function useAgentRunner(): AgentRunner | undefined {
|
|
|
65
73
|
return useUiExtensions().agentRunner()
|
|
66
74
|
}
|
|
67
75
|
|
|
76
|
+
/** The wizard behind People's Add from notes, when a module provides one. */
|
|
77
|
+
export function usePersonIntakeProvider(): PersonIntakeProvider | undefined {
|
|
78
|
+
return useUiExtensions().personIntake()
|
|
79
|
+
}
|
|
80
|
+
|
|
68
81
|
/**
|
|
69
82
|
* The component to render for an overridable: a module's replacement, or core's
|
|
70
83
|
* own. Core calls this instead of rendering its component directly.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtensibleRecordType } from '@kelpie/schemas'
|
|
2
|
-
import type { ReactNode } from 'react'
|
|
2
|
+
import type { ComponentType, ReactNode } from 'react'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* What a UI module may add to the shell.
|
|
@@ -82,6 +82,20 @@ export interface RecordTab {
|
|
|
82
82
|
readonly render: (context: RecordContext) => ReactNode
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* An admin page whose tabs modules may add to. `ai` is Admin → AI: core owns
|
|
87
|
+
* the page and its MCP tab, and the optional `ai` module adds Kelpie AI's
|
|
88
|
+
* settings and run log.
|
|
89
|
+
*/
|
|
90
|
+
export type ExtensibleAdminPage = 'ai'
|
|
91
|
+
|
|
92
|
+
export interface AdminTab {
|
|
93
|
+
readonly id: string
|
|
94
|
+
readonly label: string
|
|
95
|
+
readonly order?: number
|
|
96
|
+
readonly render: () => ReactNode
|
|
97
|
+
}
|
|
98
|
+
|
|
85
99
|
export interface RecordSidebarCard {
|
|
86
100
|
readonly id: string
|
|
87
101
|
readonly order?: number
|
|
@@ -124,3 +138,27 @@ export interface AgentRunner {
|
|
|
124
138
|
/** Progress for the core agent run `agentRunId`. `undefined` polls nothing. */
|
|
125
139
|
readonly useProgress: (agentRunId: string | undefined) => AgentRunnerProgress | undefined
|
|
126
140
|
}
|
|
141
|
+
|
|
142
|
+
export interface PersonIntakeWizardProps {
|
|
143
|
+
/** Ends the intake and closes the AI drawer it sits in. */
|
|
144
|
+
readonly onClose: () => void
|
|
145
|
+
/**
|
|
146
|
+
* Called when a model request starts or ends, so the drawer's header button
|
|
147
|
+
* can show that the task is working while the drawer is hidden.
|
|
148
|
+
*/
|
|
149
|
+
readonly onPendingChange?: (pending: boolean) => void
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The model-driven wizard behind People's **Add from notes**.
|
|
154
|
+
*
|
|
155
|
+
* Core owns the button and the AI drawer panel, and with no provider (or one
|
|
156
|
+
* that is not ready) the panel offers a copy-prompt for the user's own agent. A
|
|
157
|
+
* provider replaces that with a wizard that identifies, researches and
|
|
158
|
+
* creates. `useAvailability` is a hook, with the runner's shape and rules.
|
|
159
|
+
*/
|
|
160
|
+
export interface PersonIntakeProvider {
|
|
161
|
+
readonly id: string
|
|
162
|
+
readonly useAvailability: (options: { readonly enabled: boolean }) => AgentRunnerAvailability
|
|
163
|
+
readonly Wizard: ComponentType<PersonIntakeWizardProps>
|
|
164
|
+
}
|
package/src/registry/registry.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { ComponentType } from 'react'
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
|
+
AdminTab,
|
|
4
5
|
AgentRunner,
|
|
5
6
|
AuthMethod,
|
|
7
|
+
PersonIntakeProvider,
|
|
6
8
|
DashboardCard,
|
|
9
|
+
ExtensibleAdminPage,
|
|
7
10
|
ExtensibleRecordType,
|
|
8
11
|
NavItem,
|
|
9
12
|
NavSlot,
|
|
@@ -32,11 +35,15 @@ export interface UiModuleContext {
|
|
|
32
35
|
route(route: RouteContribution): void
|
|
33
36
|
recordTab(objectType: ExtensibleRecordType, tab: RecordTab): void
|
|
34
37
|
recordSidebarCard(objectType: ExtensibleRecordType, card: RecordSidebarCard): void
|
|
38
|
+
/** A tab on an admin page core owns, beside core's own tabs. */
|
|
39
|
+
adminTab(page: ExtensibleAdminPage, tab: AdminTab): void
|
|
35
40
|
dashboardCard(card: DashboardCard): void
|
|
36
41
|
/** Another way to sign in, rendered beside the password form on `/login` and `/signup`. */
|
|
37
42
|
authMethod(method: AuthMethod): void
|
|
38
43
|
/** The agent the Agent menu's Run button dispatches to. One per assembly. */
|
|
39
44
|
agentRunner(runner: AgentRunner): void
|
|
45
|
+
/** The wizard behind People's Add from notes. One per assembly. */
|
|
46
|
+
personIntake(provider: PersonIntakeProvider): void
|
|
40
47
|
/** Replaces a core component. Prefer a slot. */
|
|
41
48
|
override<Props>(token: Overridable<Props>, component: ComponentType<Props>): void
|
|
42
49
|
}
|
|
@@ -52,10 +59,13 @@ export interface UiExtensions {
|
|
|
52
59
|
routes(): readonly RouteContribution[]
|
|
53
60
|
recordTabs(objectType: ExtensibleRecordType): readonly RecordTab[]
|
|
54
61
|
recordSidebarCards(objectType: ExtensibleRecordType): readonly RecordSidebarCard[]
|
|
62
|
+
adminTabs(page: ExtensibleAdminPage): readonly AdminTab[]
|
|
55
63
|
dashboardCards(): readonly DashboardCard[]
|
|
56
64
|
authMethods(): readonly AuthMethod[]
|
|
57
65
|
/** The registered runner, or `undefined` when no module provides one. */
|
|
58
66
|
agentRunner(): AgentRunner | undefined
|
|
67
|
+
/** The registered intake wizard, or `undefined` when no module provides one. */
|
|
68
|
+
personIntake(): PersonIntakeProvider | undefined
|
|
59
69
|
componentFor<Props>(token: Overridable<Props>): ComponentType<Props>
|
|
60
70
|
}
|
|
61
71
|
|
|
@@ -75,10 +85,12 @@ export function inSlotOrder<T extends { readonly order?: number }>(items: readon
|
|
|
75
85
|
|
|
76
86
|
interface Accumulator {
|
|
77
87
|
agentRunner?: AgentRunner
|
|
88
|
+
personIntake?: PersonIntakeProvider
|
|
78
89
|
readonly nav: Map<NavSlot, NavItem[]>
|
|
79
90
|
readonly routes: RouteContribution[]
|
|
80
91
|
readonly recordTabs: Map<ExtensibleRecordType, RecordTab[]>
|
|
81
92
|
readonly recordSidebarCards: Map<ExtensibleRecordType, RecordSidebarCard[]>
|
|
93
|
+
readonly adminTabs: Map<ExtensibleAdminPage, AdminTab[]>
|
|
82
94
|
readonly dashboardCards: DashboardCard[]
|
|
83
95
|
readonly authMethods: AuthMethod[]
|
|
84
96
|
readonly overrides: OverrideStore
|
|
@@ -140,6 +152,11 @@ function createModuleContext(
|
|
|
140
152
|
pushInto(accumulator.recordSidebarCards, objectType, card)
|
|
141
153
|
},
|
|
142
154
|
|
|
155
|
+
adminTab(page, tab) {
|
|
156
|
+
claim(taken, module.id, `admin.tabs.${page}`, tab.id)
|
|
157
|
+
pushInto(accumulator.adminTabs, page, tab)
|
|
158
|
+
},
|
|
159
|
+
|
|
143
160
|
dashboardCard(card) {
|
|
144
161
|
claim(taken, module.id, 'dashboard.cards', card.id)
|
|
145
162
|
accumulator.dashboardCards.push(card)
|
|
@@ -161,6 +178,16 @@ function createModuleContext(
|
|
|
161
178
|
accumulator.agentRunner = runner
|
|
162
179
|
},
|
|
163
180
|
|
|
181
|
+
personIntake(provider) {
|
|
182
|
+
if (accumulator.personIntake !== undefined) {
|
|
183
|
+
throw new UiModuleError(
|
|
184
|
+
`module "${module.id}" contributes person intake "${provider.id}", but "${accumulator.personIntake.id}" is already registered`,
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
accumulator.personIntake = provider
|
|
189
|
+
},
|
|
190
|
+
|
|
164
191
|
override(token, component) {
|
|
165
192
|
if (accumulator.overrides.has(token.key)) {
|
|
166
193
|
throw new UiModuleError(
|
|
@@ -184,6 +211,7 @@ export function registerUiModules(modules: readonly UiModule[]): UiExtensions {
|
|
|
184
211
|
routes: [],
|
|
185
212
|
recordTabs: new Map(),
|
|
186
213
|
recordSidebarCards: new Map(),
|
|
214
|
+
adminTabs: new Map(),
|
|
187
215
|
dashboardCards: [],
|
|
188
216
|
authMethods: [],
|
|
189
217
|
overrides: createOverrideStore(),
|
|
@@ -206,9 +234,11 @@ export function registerUiModules(modules: readonly UiModule[]): UiExtensions {
|
|
|
206
234
|
recordTabs: (objectType) => inSlotOrder(accumulator.recordTabs.get(objectType) ?? []),
|
|
207
235
|
recordSidebarCards: (objectType) =>
|
|
208
236
|
inSlotOrder(accumulator.recordSidebarCards.get(objectType) ?? []),
|
|
237
|
+
adminTabs: (page) => inSlotOrder(accumulator.adminTabs.get(page) ?? []),
|
|
209
238
|
dashboardCards: () => inSlotOrder(accumulator.dashboardCards),
|
|
210
239
|
authMethods: () => inSlotOrder(accumulator.authMethods),
|
|
211
240
|
agentRunner: () => accumulator.agentRunner,
|
|
241
|
+
personIntake: () => accumulator.personIntake,
|
|
212
242
|
componentFor: (token) => accumulator.overrides.get(token),
|
|
213
243
|
}
|
|
214
244
|
}
|