@crossworks/client-types 0.300.46 → 0.300.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossworks/client-types",
3
- "version": "0.300.46",
3
+ "version": "0.300.48",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -0,0 +1,307 @@
1
+ /**
2
+ * The hand kind lists (arch plan A10 #12), RECORDED as they stood on main
3
+ * v0.300.46, before they were derived from the kind registry (./kinds).
4
+ *
5
+ * Record, move, compare: the first commit of A10 #12 proved RECORDED
6
+ * against the literals in the source (git show 12b4564ec); now each list is
7
+ * a filter over a registry field (./kind-lists), and this proves the derived
8
+ * list equals RECORDED with CHANGES applied, CHANGES naming every cell that
9
+ * moved. A list the code only asks membership of is compared as a set; a
10
+ * list whose order means something (TYPE_RANK) is compared in order.
11
+ */
12
+ import { describe, expect, it } from 'vitest';
13
+ import {
14
+ ACCEPTED_KINDS,
15
+ CONTEXT_REF_KINDS,
16
+ CORPUS_MAP_KINDS,
17
+ DOCUMENT_TITLE_KINDS,
18
+ EMBEDDING_KINDS,
19
+ EXPORT_FORMAT_BY_KIND,
20
+ EXTRACT_KINDS,
21
+ LINK_SERVE_KINDS,
22
+ MENTION_TARGET_KINDS,
23
+ NODE_TYPE_BY_CONTEXT_REF,
24
+ PEER_PICK_EXCLUDED_KINDS,
25
+ SEARCH_TOOL_KINDS,
26
+ acceptedRank,
27
+ forAcceptedKind,
28
+ isAcceptedKind,
29
+ } from './kind-lists';
30
+ import { ITEM_KINDS, ITEM_KIND_NAMES } from './kinds';
31
+ import { MEMBER_ITEM_KINDS } from './member-kinds';
32
+
33
+ /** The hand lists on main v0.300.46, by name (file, then the list). */
34
+ export const RECORDED = {
35
+ // server/api/src/agent/extract/gates.ts: the extractor's default allowlist.
36
+ DEFAULT_EXTRACT_TYPES: [
37
+ 'note',
38
+ 'page',
39
+ 'table',
40
+ 'file',
41
+ 'email',
42
+ 'email_thread',
43
+ 'secret',
44
+ 'task',
45
+ 'event',
46
+ 'contact',
47
+ 'documentation',
48
+ 'journal',
49
+ 'location',
50
+ 'formula',
51
+ 'draw',
52
+ ],
53
+ // server/web/lib/integrity/landed.ts: the integrity view's kinds.
54
+ LANDED_TYPES: [
55
+ 'note',
56
+ 'page',
57
+ 'task',
58
+ 'event',
59
+ 'contact',
60
+ 'secret',
61
+ 'file',
62
+ 'email',
63
+ 'table',
64
+ 'journal',
65
+ 'formula',
66
+ 'draw',
67
+ ],
68
+ // packages/runtime/src/agent/conversation.ts: the corpus map's kinds.
69
+ CORPUS_MAP_TYPES: ['page', 'table', 'file', 'note', 'task', 'app'],
70
+ // packages/db/src/context-ref-resolve.ts: the kinds a context ref names.
71
+ CONTEXT_KINDS: [
72
+ 'file',
73
+ 'folder',
74
+ 'page',
75
+ 'note',
76
+ 'table',
77
+ 'journal',
78
+ 'task',
79
+ 'event',
80
+ 'app',
81
+ 'draw',
82
+ 'formula',
83
+ 'email',
84
+ 'contact',
85
+ ],
86
+ // packages/db/src/context-ref-resolve.ts: context kind to node type.
87
+ NODE_TYPE_BY_KIND: {
88
+ file: 'file',
89
+ folder: 'branch',
90
+ page: 'page',
91
+ note: 'note',
92
+ table: 'table',
93
+ journal: 'journal',
94
+ task: 'task',
95
+ event: 'event',
96
+ app: 'app',
97
+ draw: 'draw',
98
+ formula: 'formula',
99
+ contact: 'contact',
100
+ },
101
+ // packages/content/src/embed-closure.ts: the kinds that embed items.
102
+ EMBEDDING_KINDS: ['page', 'draw', 'note'],
103
+ // server/web/lib/maintenance/refold-embeds.ts: KINDS and its Kind union.
104
+ REFOLD_KINDS: ['page', 'note', 'draw'],
105
+ // server/web/app/api/mentions/search/route.ts: what a mention may name.
106
+ MENTION_TARGETS: ['page', 'note', 'draw'],
107
+ // packages/content/src/link-serve.ts serveCandidates: the kinds whose
108
+ // link serves the items they name or embed (a folder serves its own).
109
+ LINK_SERVE_KINDS: ['page', 'note', 'task', 'event', 'draw'],
110
+ // packages/content/src/export-node.ts: EXPORTABLE_TYPES (and ExportKind).
111
+ EXPORTABLE_TYPES: { page: 'docx', note: 'docx', table: 'xlsx', draw: 'svg' },
112
+ // packages/content/src/login-notices.ts: which of a bundle's items names
113
+ // it. ORDERED: the index is the rank.
114
+ TYPE_RANK: ['page', 'note', 'table', 'draw', 'file'],
115
+ // The copied 5-case kind switches over an accepted item (case order).
116
+ SWITCH_MEMBER_ACCEPTED: ['page', 'note', 'table', 'draw', 'file'],
117
+ SWITCH_MEMBER_LIBRARY: ['page', 'note', 'table', 'draw', 'file'],
118
+ SWITCH_MEMBER_SNAPSHOTS: ['page', 'note', 'draw', 'table', 'file'],
119
+ SWITCH_SNAPSHOT_COPIES: ['page', 'note', 'table', 'draw', 'file'],
120
+ // packages/tools/src/builtins-search.ts: search_nodes' `type` enum.
121
+ SEARCH_NODES_TYPE_ENUM: [
122
+ 'branch',
123
+ 'email',
124
+ 'email_thread',
125
+ 'file',
126
+ 'note',
127
+ 'page',
128
+ 'sermon',
129
+ 'contact',
130
+ 'task',
131
+ 'event',
132
+ 'printer_project',
133
+ 'telegram_message',
134
+ 'documentation',
135
+ 'journal',
136
+ 'secret',
137
+ 'formula',
138
+ 'draw',
139
+ ],
140
+ // packages/mcp-core/src/mcp-defs.ts: the MCP `search` tool's `type` enum.
141
+ MCP_SEARCH_TYPE_ENUM: [
142
+ 'branch',
143
+ 'email',
144
+ 'email_thread',
145
+ 'file',
146
+ 'note',
147
+ 'page',
148
+ 'sermon',
149
+ 'contact',
150
+ 'secret',
151
+ 'task',
152
+ 'event',
153
+ 'printer_project',
154
+ 'telegram_message',
155
+ 'documentation',
156
+ 'journal',
157
+ 'formula',
158
+ 'draw',
159
+ ],
160
+ // server/web/app/api/peers/nodes/route.ts: the kinds the peer grant
161
+ // picker leaves out.
162
+ PEER_PICKER_EXCLUDED: ['branch', 'mantle_peer', 'secret'],
163
+ // packages/content/src/entity-names.ts: kinds whose title names a document.
164
+ DOCUMENT_NODE_TYPES: ['file', 'documentation', 'sermon'],
165
+ } as const;
166
+
167
+ /** Every cell that moved with A10 #12, by list. `add`/`remove`: a kind
168
+ * that came in or went out (a behaviour change, named); `order`: the same
169
+ * set in registry order (the code asks membership only, or the order is
170
+ * only how a schema prints). */
171
+ export const CHANGES = {
172
+ LANDED_TYPES: {
173
+ add: ['email_thread', 'documentation', 'location'],
174
+ why:
175
+ 'named fix: the three kinds the extractor reads that the integrity view ' +
176
+ 'could not see. Visibility only: the extract set is unchanged.',
177
+ },
178
+ SEARCH_NODES_TYPE_ENUM: {
179
+ order: true,
180
+ why: 'the same 17 kinds in registry order: the tool schema prints them so',
181
+ },
182
+ MCP_SEARCH_TYPE_ENUM: {
183
+ order: true,
184
+ why:
185
+ 'the same 17 kinds in registry order (`page` after `telegram_message`): ' +
186
+ 'the MCP tools/list snapshots (packages/mcp-core/src/__snapshots__) moved ' +
187
+ 'by that one line, and every connection hash with it',
188
+ },
189
+ } as const satisfies Partial<
190
+ Record<keyof typeof RECORDED, { add?: readonly string[]; order?: true; why: string }>
191
+ >;
192
+
193
+ const set = (xs: readonly string[]) => [...xs].sort();
194
+ const omit = <T extends Record<string, unknown>>(o: T, k: string) =>
195
+ Object.fromEntries(Object.entries(o).filter(([key]) => key !== k));
196
+
197
+ /** Each list as the code derives it now. */
198
+ function derived(): Record<keyof typeof RECORDED, unknown> {
199
+ const accepted = set(ACCEPTED_KINDS);
200
+ return {
201
+ DEFAULT_EXTRACT_TYPES: set(EXTRACT_KINDS),
202
+ LANDED_TYPES: set(EXTRACT_KINDS),
203
+ CORPUS_MAP_TYPES: set(CORPUS_MAP_KINDS),
204
+ CONTEXT_KINDS: set(CONTEXT_REF_KINDS),
205
+ NODE_TYPE_BY_KIND: omit(NODE_TYPE_BY_CONTEXT_REF, 'email'),
206
+ EMBEDDING_KINDS: set(EMBEDDING_KINDS),
207
+ REFOLD_KINDS: set(EMBEDDING_KINDS),
208
+ MENTION_TARGETS: set(MENTION_TARGET_KINDS),
209
+ LINK_SERVE_KINDS: set(LINK_SERVE_KINDS),
210
+ EXPORTABLE_TYPES: { ...EXPORT_FORMAT_BY_KIND },
211
+ TYPE_RANK: [...ACCEPTED_KINDS].sort((a, b) => acceptedRank(a) - acceptedRank(b)),
212
+ SWITCH_MEMBER_ACCEPTED: accepted,
213
+ SWITCH_MEMBER_LIBRARY: accepted,
214
+ SWITCH_MEMBER_SNAPSHOTS: accepted,
215
+ SWITCH_SNAPSHOT_COPIES: accepted,
216
+ SEARCH_NODES_TYPE_ENUM: set(SEARCH_TOOL_KINDS),
217
+ MCP_SEARCH_TYPE_ENUM: set(SEARCH_TOOL_KINDS),
218
+ PEER_PICKER_EXCLUDED: set(PEER_PICK_EXCLUDED_KINDS),
219
+ DOCUMENT_NODE_TYPES: set(DOCUMENT_TITLE_KINDS),
220
+ };
221
+ }
222
+
223
+ /** RECORDED with CHANGES applied, in the shape derived() gives. */
224
+ function expected(): Record<keyof typeof RECORDED, unknown> {
225
+ const out = {} as Record<keyof typeof RECORDED, unknown>;
226
+ for (const [name, value] of Object.entries(RECORDED) as [keyof typeof RECORDED, unknown][]) {
227
+ const change = (CHANGES as Partial<Record<string, { add?: readonly string[] }>>)[name];
228
+ if (Array.isArray(value)) {
229
+ const list = [...(value as string[]), ...(change?.add ?? [])];
230
+ out[name] = name === 'TYPE_RANK' ? list : set(list);
231
+ } else out[name] = value;
232
+ }
233
+ return out;
234
+ }
235
+
236
+ describe('the hand kind lists, derived from the registry', () => {
237
+ it('each derived list is RECORDED with CHANGES applied, and nothing else moved', () => {
238
+ expect(derived()).toEqual(expected());
239
+ });
240
+
241
+ it('CHANGES names only lists that moved', () => {
242
+ for (const name of Object.keys(CHANGES) as (keyof typeof CHANGES)[]) {
243
+ const was = RECORDED[name] as readonly string[];
244
+ const now = derived()[name] as readonly string[];
245
+ const moved = 'order' in CHANGES[name] ? true : set(was).join() !== set(now).join();
246
+ expect(moved, name).toBe(true);
247
+ }
248
+ });
249
+
250
+ it('the search enums keep their 17 kinds: searchable plus secret', () => {
251
+ expect(set(SEARCH_TOOL_KINDS)).toEqual(set(RECORDED.SEARCH_NODES_TYPE_ENUM));
252
+ expect(set(SEARCH_TOOL_KINDS)).toEqual(set(RECORDED.MCP_SEARCH_TYPE_ENUM));
253
+ const searchable = ITEM_KIND_NAMES.filter((t) => ITEM_KINDS[t].searchable);
254
+ expect(set(SEARCH_TOOL_KINDS)).toEqual(set([...searchable, 'secret']));
255
+ });
256
+
257
+ it('the extract set is not widened: LANDED_TYPES grew, DEFAULT_EXTRACT_TYPES did not', () => {
258
+ expect(set(EXTRACT_KINDS)).toEqual(set(RECORDED.DEFAULT_EXTRACT_TYPES));
259
+ });
260
+
261
+ it('the accepted kinds are the Library kinds (one list until library goes)', () => {
262
+ expect(set(ACCEPTED_KINDS)).toEqual(set(MEMBER_ITEM_KINDS));
263
+ });
264
+
265
+ it('every context ref kind names a kind (folder is a branch)', () => {
266
+ expect(NODE_TYPE_BY_CONTEXT_REF.folder).toBe('branch');
267
+ for (const [ref, t] of Object.entries(NODE_TYPE_BY_CONTEXT_REF)) {
268
+ if (ref !== 'folder') expect(t, ref).toBe(ref);
269
+ }
270
+ });
271
+ });
272
+
273
+ describe('forAcceptedKind', () => {
274
+ type Item = { type: 'page'; doc: string } | { type: 'note'; content: string };
275
+ const cases = {
276
+ page: (i: { type: string; doc?: string }) => `page:${i.doc}`,
277
+ note: (i: { type: string; content?: string }) => `note:${i.content}`,
278
+ table: () => 'table',
279
+ draw: () => 'draw',
280
+ file: () => 'file',
281
+ };
282
+
283
+ it('runs the case of the item kind', () => {
284
+ const page: Item = { type: 'page', doc: 'd' };
285
+ expect(forAcceptedKind(page, cases)).toBe('page:d');
286
+ expect(forAcceptedKind({ type: 'file' }, cases)).toBe('file');
287
+ });
288
+
289
+ it('answers null for a kind that is not accepted', () => {
290
+ expect(forAcceptedKind({ type: 'task' }, cases)).toBeNull();
291
+ expect(forAcceptedKind({ type: 'toString' }, cases)).toBeNull();
292
+ expect(isAcceptedKind('branch')).toBe(false);
293
+ expect(acceptedRank('task')).toBe(ACCEPTED_KINDS.length);
294
+ });
295
+
296
+ it('narrows a union item to the case kind', () => {
297
+ const note: Item = { type: 'note', content: 'c' };
298
+ const got = forAcceptedKind<Item, string>(note, {
299
+ page: (i) => i.doc,
300
+ note: (i) => i.content,
301
+ table: () => '',
302
+ draw: () => '',
303
+ file: () => '',
304
+ });
305
+ expect(got).toBe('c');
306
+ });
307
+ });
@@ -0,0 +1,121 @@
1
+ /**
2
+ * The kind lists that were written by hand across the repo (arch plan A10
3
+ * #12), each now a filter over one field of the kind registry (./kinds).
4
+ * Every list is in registry order (the Drizzle enum's) unless it says
5
+ * otherwise; the code asks each one for membership only.
6
+ *
7
+ * kind-lists.test.ts pins every list to its value on main v0.300.46 and
8
+ * names, cell by cell, the few that changed with the move.
9
+ *
10
+ * Pure and dependency free: the `@mantle/client-types/kind-lists` subpath.
11
+ */
12
+ import {
13
+ ITEM_KINDS,
14
+ ITEM_KIND_NAMES,
15
+ kindSpecOf,
16
+ kindsWhere,
17
+ type AcceptedKind,
18
+ type ContextRefKind,
19
+ type CorpusMapKind,
20
+ type EmbeddingKind,
21
+ type ExportKind,
22
+ type ExtractKind,
23
+ type ItemKind,
24
+ type KindExportFormat,
25
+ type LinkServeKind,
26
+ type MentionTargetKind,
27
+ type SearchToolKind,
28
+ } from './kinds';
29
+
30
+ /** The extractor's default allowlist (a worker's `target_types` replaces
31
+ * it), and the kinds the integrity view lists. */
32
+ export const EXTRACT_KINDS = kindsWhere<ExtractKind>((s) => s.extract);
33
+
34
+ /** The kinds the responder's corpus map lists by title. */
35
+ export const CORPUS_MAP_KINDS = kindsWhere<CorpusMapKind>((s) => s.corpusMap);
36
+
37
+ /** The kinds that embed other items (node_embeds). */
38
+ export const EMBEDDING_KINDS = kindsWhere<EmbeddingKind>((s) => s.embeds);
39
+
40
+ /** The kinds a mention chip may name. */
41
+ export const MENTION_TARGET_KINDS = kindsWhere<MentionTargetKind>((s) => s.mentionTarget);
42
+
43
+ /** The kinds whose public link may serve the items they name or embed. */
44
+ export const LINK_SERVE_KINDS = kindsWhere<LinkServeKind>((s) => s.linkServes);
45
+
46
+ /** The `type` values of the search tools (search_nodes, the MCP `search`). */
47
+ export const SEARCH_TOOL_KINDS = kindsWhere<SearchToolKind>((s) => s.searchTool);
48
+
49
+ /** The kinds the linked brain grant picker leaves out. */
50
+ export const PEER_PICK_EXCLUDED_KINDS = kindsWhere((s) => !s.peerPick);
51
+
52
+ /** The kinds whose title names a document, not a thing the user does. */
53
+ export const DOCUMENT_TITLE_KINDS = kindsWhere((s) => s.documentTitle);
54
+
55
+ // ── context refs ────────────────────────────────────────────────────────────
56
+
57
+ const contextRefs = ITEM_KIND_NAMES.flatMap((t) => {
58
+ const ref: string | false = ITEM_KINDS[t].contextRef;
59
+ return ref ? [[ref as ContextRefKind, t] as const] : [];
60
+ });
61
+
62
+ /** The kinds a context ref may name, in the client's vocabulary. */
63
+ export const CONTEXT_REF_KINDS = contextRefs.map(([ref]) => ref) as unknown as readonly [
64
+ ContextRefKind,
65
+ ...ContextRefKind[],
66
+ ];
67
+
68
+ /** A context ref kind's node type (`folder` is a `branch`). */
69
+ export const NODE_TYPE_BY_CONTEXT_REF = Object.fromEntries(contextRefs) as Readonly<
70
+ Record<ContextRefKind, ItemKind>
71
+ >;
72
+
73
+ // ── exports ─────────────────────────────────────────────────────────────────
74
+
75
+ /** The format each exportable kind downloads as by default. */
76
+ export const EXPORT_FORMAT_BY_KIND = Object.fromEntries(
77
+ ITEM_KIND_NAMES.flatMap((t) => {
78
+ const f: KindExportFormat | false = ITEM_KINDS[t].exportAs;
79
+ return f ? [[t, f] as const] : [];
80
+ }),
81
+ ) as Readonly<Record<ExportKind, KindExportFormat>>;
82
+
83
+ // ── accepted items ──────────────────────────────────────────────────────────
84
+
85
+ /** The kinds of an accepted item (a snapshot on accept, the Library, a copy). */
86
+ export const ACCEPTED_KINDS = kindsWhere<AcceptedKind>((s) => s.accepted !== false);
87
+
88
+ export function isAcceptedKind(v: unknown): v is AcceptedKind {
89
+ return typeof v === 'string' && (ACCEPTED_KINDS as readonly string[]).includes(v);
90
+ }
91
+
92
+ /** Which of a bundle's items names it: the lowest rank; a kind that is not
93
+ * accepted ranks after every accepted one. */
94
+ export function acceptedRank(type: string): number {
95
+ const a = kindSpecOf(type)?.accepted;
96
+ return a ? a.rank : ACCEPTED_KINDS.length;
97
+ }
98
+
99
+ /** `T` narrowed to kind `K` when `T` is a union over `type`, else `T`. */
100
+ type OfKind<T, K> = [Extract<T, { type: K }>] extends [never] ? T : Extract<T, { type: K }>;
101
+
102
+ /** One case per accepted kind: a kind that turns `accepted` on fails to
103
+ * compile at every call until it has its case. */
104
+ export type AcceptedCases<T extends { type: string }, R> = {
105
+ readonly [K in AcceptedKind]: (item: OfKind<T, K>) => R;
106
+ };
107
+
108
+ /**
109
+ * The ONE switch over an accepted item's kind (it was copied four times:
110
+ * member-accepted.ts, member-library.ts, member-snapshots.ts and
111
+ * server/web/lib/snapshot-copies.ts). Runs the case of `item.type`, or
112
+ * answers null for a kind that is not accepted.
113
+ */
114
+ export function forAcceptedKind<T extends { type: string }, R>(
115
+ item: T,
116
+ cases: AcceptedCases<T, R>,
117
+ ): R | null {
118
+ if (!isAcceptedKind(item.type)) return null;
119
+ const run = cases[item.type] as (item: T) => R;
120
+ return run(item);
121
+ }
package/src/kinds.ts CHANGED
@@ -13,7 +13,11 @@
13
13
  * - TEAM_PRIVATE_CORPUS_TYPES and TEAM_NEVER_TYPES
14
14
  * (@mantle/content-core/profile-projections), teamHidden;
15
15
  * - MEMBER_ITEM_KINDS and CLIENT_ITEM_KINDS (./member-kinds), library: kept
16
- * one pair release, then they go with the field.
16
+ * one pair release, then they go with the field;
17
+ * - the lists of ./kind-lists (A10 #12): extract, corpusMap, contextRef,
18
+ * embeds, mentionTarget, linkServes, exportAs, accepted, searchTool,
19
+ * peerPick, documentTitle. A literal list of kind names anywhere else is
20
+ * an arch count pinned at 0 (eslint-rules/arch-counts.mjs handKindLists).
17
21
  *
18
22
  * Each field holds the value the code had when the registry came in (A1).
19
23
  * Who may share or see a kind changes here only as a reviewed diff of the
@@ -78,8 +82,48 @@ export type KindSpec = {
78
82
  * CLIENT_ITEM_KINDS too when `client`. Kept one pair release (A1), then
79
83
  * removed with them. */
80
84
  readonly library: { readonly order: number; readonly client: boolean } | false;
85
+
86
+ // ── A10 #12: the hand kind lists, now fields (./kind-lists derives them).
87
+ // Each holds the value its list had on main v0.300.46 (kind-lists.test.ts
88
+ // RECORDED), except the changes that test names.
89
+
90
+ /** The extractor reads it by default (DEFAULT_EXTRACT_TYPES, a worker's
91
+ * `target_types` overrides), and the integrity view lists it
92
+ * (LANDED_TYPES). Turning this on for a kind that had it off extracts
93
+ * that kind's whole corpus: a cost decision, never a tidy-up. */
94
+ readonly extract: boolean;
95
+ /** Listed by title in the responder's corpus map (CORPUS_MAP_TYPES). */
96
+ readonly corpusMap: boolean;
97
+ /** The kind a context ref names it by (the client's vocabulary,
98
+ * CONTEXT_KINDS: a `branch` is a `folder`), or false. */
99
+ readonly contextRef: string | false;
100
+ /** Embeds other items (node_embeds edges: EMBEDDING_KINDS, the embed
101
+ * refold). */
102
+ readonly embeds: boolean;
103
+ /** A mention chip may name it (/api/mentions/search). */
104
+ readonly mentionTarget: boolean;
105
+ /** Its public link may serve the items it names or embeds
106
+ * (link-serve.ts; a folder serves its own items). */
107
+ readonly linkServes: boolean;
108
+ /** Downloads as this format by default (EXPORTABLE_TYPES), or false. */
109
+ readonly exportAs: KindExportFormat | false;
110
+ /** An accepted item: its snapshot is recorded on accept, read back,
111
+ * served in the Library and copied (forAcceptedKind). `rank`: which of a
112
+ * bundle's items names it, lowest first (login-notices.ts). */
113
+ readonly accepted: { readonly rank: number } | false;
114
+ /** A `type` value of the search tools (search_nodes, the MCP `search`).
115
+ * Wider than `searchable` by `secret`: an agent may filter its own
116
+ * secrets' metadata; the search screen offers no such filter. */
117
+ readonly searchTool: boolean;
118
+ /** Offered by the linked brain grant picker (/api/peers/nodes). */
119
+ readonly peerPick: boolean;
120
+ /** Its title names a document, not a thing the user does (entity-names). */
121
+ readonly documentTitle: boolean;
81
122
  };
82
123
 
124
+ /** The formats a kind downloads as by default. */
125
+ export type KindExportFormat = 'docx' | 'xlsx' | 'svg';
126
+
83
127
  const none = { content: null, v1: null } as const;
84
128
 
85
129
  export const ITEM_KINDS = {
@@ -93,6 +137,17 @@ export const ITEM_KINDS = {
93
137
  route: { content: '/api/files/folders', v1: null },
94
138
  teamHidden: false,
95
139
  library: false,
140
+ extract: false,
141
+ corpusMap: false,
142
+ contextRef: 'folder',
143
+ embeds: false,
144
+ mentionTarget: false,
145
+ linkServes: false,
146
+ exportAs: false,
147
+ accepted: false,
148
+ searchTool: true,
149
+ peerPick: false,
150
+ documentTitle: false,
96
151
  },
97
152
  email: {
98
153
  class: 'admin_only',
@@ -104,6 +159,17 @@ export const ITEM_KINDS = {
104
159
  route: { content: '/api/email/messages', v1: null },
105
160
  teamHidden: 'private-corpus',
106
161
  library: false,
162
+ extract: true,
163
+ corpusMap: false,
164
+ contextRef: 'email',
165
+ embeds: false,
166
+ mentionTarget: false,
167
+ linkServes: false,
168
+ exportAs: false,
169
+ accepted: false,
170
+ searchTool: true,
171
+ peerPick: true,
172
+ documentTitle: false,
107
173
  },
108
174
  email_thread: {
109
175
  class: 'admin_only',
@@ -115,6 +181,17 @@ export const ITEM_KINDS = {
115
181
  route: none,
116
182
  teamHidden: 'private-corpus',
117
183
  library: false,
184
+ extract: true,
185
+ corpusMap: false,
186
+ contextRef: false,
187
+ embeds: false,
188
+ mentionTarget: false,
189
+ linkServes: false,
190
+ exportAs: false,
191
+ accepted: false,
192
+ searchTool: true,
193
+ peerPick: true,
194
+ documentTitle: false,
118
195
  },
119
196
  file: {
120
197
  class: 'workspace',
@@ -133,6 +210,17 @@ export const ITEM_KINDS = {
133
210
  route: { content: '/api/files/files', v1: '/api/v1/files' },
134
211
  teamHidden: false,
135
212
  library: { order: 4, client: true },
213
+ extract: true,
214
+ corpusMap: true,
215
+ contextRef: 'file',
216
+ embeds: false,
217
+ mentionTarget: false,
218
+ linkServes: false,
219
+ exportAs: false,
220
+ accepted: { rank: 4 },
221
+ searchTool: true,
222
+ peerPick: true,
223
+ documentTitle: true,
136
224
  },
137
225
  note: {
138
226
  class: 'workspace',
@@ -151,6 +239,17 @@ export const ITEM_KINDS = {
151
239
  route: { content: '/api/notes', v1: '/api/v1/notes' },
152
240
  teamHidden: false,
153
241
  library: { order: 1, client: true },
242
+ extract: true,
243
+ corpusMap: true,
244
+ contextRef: 'note',
245
+ embeds: true,
246
+ mentionTarget: true,
247
+ linkServes: true,
248
+ exportAs: 'docx',
249
+ accepted: { rank: 1 },
250
+ searchTool: true,
251
+ peerPick: true,
252
+ documentTitle: false,
154
253
  },
155
254
  sermon: {
156
255
  class: 'admin_only',
@@ -162,6 +261,17 @@ export const ITEM_KINDS = {
162
261
  route: none,
163
262
  teamHidden: false,
164
263
  library: false,
264
+ extract: false,
265
+ corpusMap: false,
266
+ contextRef: false,
267
+ embeds: false,
268
+ mentionTarget: false,
269
+ linkServes: false,
270
+ exportAs: false,
271
+ accepted: false,
272
+ searchTool: true,
273
+ peerPick: true,
274
+ documentTitle: true,
165
275
  },
166
276
  contact: {
167
277
  class: 'admin_only',
@@ -180,6 +290,17 @@ export const ITEM_KINDS = {
180
290
  route: { content: '/api/contacts', v1: '/api/v1/contacts' },
181
291
  teamHidden: false,
182
292
  library: false,
293
+ extract: true,
294
+ corpusMap: false,
295
+ contextRef: 'contact',
296
+ embeds: false,
297
+ mentionTarget: false,
298
+ linkServes: false,
299
+ exportAs: false,
300
+ accepted: false,
301
+ searchTool: true,
302
+ peerPick: true,
303
+ documentTitle: false,
183
304
  },
184
305
  secret: {
185
306
  class: 'admin_only',
@@ -198,6 +319,17 @@ export const ITEM_KINDS = {
198
319
  route: { content: '/api/secrets', v1: null },
199
320
  teamHidden: 'never',
200
321
  library: false,
322
+ extract: true,
323
+ corpusMap: false,
324
+ contextRef: false,
325
+ embeds: false,
326
+ mentionTarget: false,
327
+ linkServes: false,
328
+ exportAs: false,
329
+ accepted: false,
330
+ searchTool: true,
331
+ peerPick: false,
332
+ documentTitle: false,
201
333
  },
202
334
  task: {
203
335
  class: 'workspace',
@@ -216,6 +348,17 @@ export const ITEM_KINDS = {
216
348
  route: { content: '/api/tasks', v1: '/api/v1/tasks' },
217
349
  teamHidden: false,
218
350
  library: false,
351
+ extract: true,
352
+ corpusMap: true,
353
+ contextRef: 'task',
354
+ embeds: false,
355
+ mentionTarget: false,
356
+ linkServes: true,
357
+ exportAs: false,
358
+ accepted: false,
359
+ searchTool: true,
360
+ peerPick: true,
361
+ documentTitle: false,
219
362
  },
220
363
  event: {
221
364
  class: 'workspace',
@@ -234,6 +377,17 @@ export const ITEM_KINDS = {
234
377
  route: { content: '/api/events', v1: '/api/v1/events' },
235
378
  teamHidden: false,
236
379
  library: false,
380
+ extract: true,
381
+ corpusMap: false,
382
+ contextRef: 'event',
383
+ embeds: false,
384
+ mentionTarget: false,
385
+ linkServes: true,
386
+ exportAs: false,
387
+ accepted: false,
388
+ searchTool: true,
389
+ peerPick: true,
390
+ documentTitle: false,
237
391
  },
238
392
  printer_project: {
239
393
  class: 'admin_only',
@@ -245,6 +399,17 @@ export const ITEM_KINDS = {
245
399
  route: none,
246
400
  teamHidden: false,
247
401
  library: false,
402
+ extract: false,
403
+ corpusMap: false,
404
+ contextRef: false,
405
+ embeds: false,
406
+ mentionTarget: false,
407
+ linkServes: false,
408
+ exportAs: false,
409
+ accepted: false,
410
+ searchTool: true,
411
+ peerPick: true,
412
+ documentTitle: false,
248
413
  },
249
414
  telegram_message: {
250
415
  class: 'conversation',
@@ -256,6 +421,17 @@ export const ITEM_KINDS = {
256
421
  route: none,
257
422
  teamHidden: 'never',
258
423
  library: false,
424
+ extract: false,
425
+ corpusMap: false,
426
+ contextRef: false,
427
+ embeds: false,
428
+ mentionTarget: false,
429
+ linkServes: false,
430
+ exportAs: false,
431
+ accepted: false,
432
+ searchTool: true,
433
+ peerPick: true,
434
+ documentTitle: false,
259
435
  },
260
436
  page: {
261
437
  class: 'workspace',
@@ -274,6 +450,17 @@ export const ITEM_KINDS = {
274
450
  route: { content: '/api/pages', v1: '/api/v1/pages' },
275
451
  teamHidden: false,
276
452
  library: { order: 0, client: true },
453
+ extract: true,
454
+ corpusMap: true,
455
+ contextRef: 'page',
456
+ embeds: true,
457
+ mentionTarget: true,
458
+ linkServes: true,
459
+ exportAs: 'docx',
460
+ accepted: { rank: 0 },
461
+ searchTool: true,
462
+ peerPick: true,
463
+ documentTitle: false,
277
464
  },
278
465
  table: {
279
466
  class: 'workspace',
@@ -292,6 +479,17 @@ export const ITEM_KINDS = {
292
479
  route: { content: '/api/tables', v1: '/api/v1/tables' },
293
480
  teamHidden: false,
294
481
  library: { order: 3, client: false },
482
+ extract: true,
483
+ corpusMap: true,
484
+ contextRef: 'table',
485
+ embeds: false,
486
+ mentionTarget: false,
487
+ linkServes: false,
488
+ exportAs: 'xlsx',
489
+ accepted: { rank: 2 },
490
+ searchTool: false,
491
+ peerPick: true,
492
+ documentTitle: false,
295
493
  },
296
494
  mantle_peer: {
297
495
  class: 'admin_only',
@@ -303,6 +501,17 @@ export const ITEM_KINDS = {
303
501
  route: none,
304
502
  teamHidden: 'never',
305
503
  library: false,
504
+ extract: false,
505
+ corpusMap: false,
506
+ contextRef: false,
507
+ embeds: false,
508
+ mentionTarget: false,
509
+ linkServes: false,
510
+ exportAs: false,
511
+ accepted: false,
512
+ searchTool: false,
513
+ peerPick: false,
514
+ documentTitle: false,
306
515
  },
307
516
  documentation: {
308
517
  class: 'admin_only',
@@ -314,6 +523,17 @@ export const ITEM_KINDS = {
314
523
  route: { content: '/api/docs/reader', v1: null },
315
524
  teamHidden: false,
316
525
  library: false,
526
+ extract: true,
527
+ corpusMap: false,
528
+ contextRef: false,
529
+ embeds: false,
530
+ mentionTarget: false,
531
+ linkServes: false,
532
+ exportAs: false,
533
+ accepted: false,
534
+ searchTool: true,
535
+ peerPick: true,
536
+ documentTitle: true,
317
537
  },
318
538
  journal: {
319
539
  class: 'admin_only',
@@ -325,6 +545,17 @@ export const ITEM_KINDS = {
325
545
  route: { content: '/api/journal', v1: '/api/v1/journal' },
326
546
  teamHidden: 'private-corpus',
327
547
  library: false,
548
+ extract: true,
549
+ corpusMap: false,
550
+ contextRef: 'journal',
551
+ embeds: false,
552
+ mentionTarget: false,
553
+ linkServes: false,
554
+ exportAs: false,
555
+ accepted: false,
556
+ searchTool: true,
557
+ peerPick: true,
558
+ documentTitle: false,
328
559
  },
329
560
  location: {
330
561
  class: 'admin_only',
@@ -336,6 +567,17 @@ export const ITEM_KINDS = {
336
567
  route: none,
337
568
  teamHidden: 'never',
338
569
  library: false,
570
+ extract: true,
571
+ corpusMap: false,
572
+ contextRef: false,
573
+ embeds: false,
574
+ mentionTarget: false,
575
+ linkServes: false,
576
+ exportAs: false,
577
+ accepted: false,
578
+ searchTool: false,
579
+ peerPick: true,
580
+ documentTitle: false,
339
581
  },
340
582
  app: {
341
583
  class: 'workspace',
@@ -354,6 +596,17 @@ export const ITEM_KINDS = {
354
596
  route: { content: '/api/apps', v1: null },
355
597
  teamHidden: false,
356
598
  library: false,
599
+ extract: false,
600
+ corpusMap: true,
601
+ contextRef: 'app',
602
+ embeds: false,
603
+ mentionTarget: false,
604
+ linkServes: false,
605
+ exportAs: false,
606
+ accepted: false,
607
+ searchTool: false,
608
+ peerPick: true,
609
+ documentTitle: false,
357
610
  },
358
611
  formula: {
359
612
  class: 'workspace',
@@ -372,6 +625,17 @@ export const ITEM_KINDS = {
372
625
  route: { content: '/api/formulas', v1: null },
373
626
  teamHidden: false,
374
627
  library: false,
628
+ extract: true,
629
+ corpusMap: false,
630
+ contextRef: 'formula',
631
+ embeds: false,
632
+ mentionTarget: false,
633
+ linkServes: false,
634
+ exportAs: false,
635
+ accepted: false,
636
+ searchTool: true,
637
+ peerPick: true,
638
+ documentTitle: false,
375
639
  },
376
640
  draw: {
377
641
  class: 'workspace',
@@ -390,6 +654,17 @@ export const ITEM_KINDS = {
390
654
  route: { content: '/api/draws', v1: null },
391
655
  teamHidden: false,
392
656
  library: { order: 2, client: false },
657
+ extract: true,
658
+ corpusMap: false,
659
+ contextRef: 'draw',
660
+ embeds: true,
661
+ mentionTarget: true,
662
+ linkServes: true,
663
+ exportAs: 'svg',
664
+ accepted: { rank: 3 },
665
+ searchTool: true,
666
+ peerPick: true,
667
+ documentTitle: false,
393
668
  },
394
669
  recall: {
395
670
  class: 'workspace',
@@ -411,6 +686,17 @@ export const ITEM_KINDS = {
411
686
  route: { content: '/api/recall/maps', v1: null },
412
687
  teamHidden: false,
413
688
  library: false,
689
+ extract: false,
690
+ corpusMap: false,
691
+ contextRef: false,
692
+ embeds: false,
693
+ mentionTarget: false,
694
+ linkServes: false,
695
+ exportAs: false,
696
+ accepted: false,
697
+ searchTool: false,
698
+ peerPick: true,
699
+ documentTitle: false,
414
700
  },
415
701
  } as const satisfies Record<string, KindSpec>;
416
702
 
@@ -455,6 +741,19 @@ export type PeerShareKind = KindsWhere<{ peerShare: true }>;
455
741
  export type SearchableKind = KindsWhere<{ searchable: true }>;
456
742
  export type MemberLibraryKind = KindsWhere<{ library: { order: number } }>;
457
743
  export type ClientLibraryKind = KindsWhere<{ library: { client: true } }>;
744
+ export type ExtractKind = KindsWhere<{ extract: true }>;
745
+ export type CorpusMapKind = KindsWhere<{ corpusMap: true }>;
746
+ export type EmbeddingKind = KindsWhere<{ embeds: true }>;
747
+ export type MentionTargetKind = KindsWhere<{ mentionTarget: true }>;
748
+ export type LinkServeKind = KindsWhere<{ linkServes: true }>;
749
+ export type ExportKind = KindsWhere<{ exportAs: KindExportFormat }>;
750
+ export type AcceptedKind = KindsWhere<{ accepted: { rank: number } }>;
751
+ export type SearchToolKind = KindsWhere<{ searchTool: true }>;
752
+
753
+ /** The context ref kinds the registry names (`folder`, `file`, ...). */
754
+ export type ContextRefKind = {
755
+ [K in ItemKind]: Kinds[K]['contextRef'] extends string ? Kinds[K]['contextRef'] : never;
756
+ }[ItemKind];
458
757
 
459
758
  /** The tree kinds the registry names (`files`, `notes`, ...). */
460
759
  export type RegistryTreeKind = {