Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .changeset/37309-knowledge-source-studio-form.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@objectstack/spec': patch
'@objectstack/platform-objects': patch
'@object-ui/app-shell': patch
---

feat(studio): create and edit a knowledge source (`knowledge_source`) in Studio — a form for the type, with field pickers scoped to the source's own object

Clause-②: yes (widening) — one new public export, `knowledgeSourceForm` from `@objectstack/spec/ai`, and `/meta/types` now serves a form for `knowledge_source`; no key is added to what a source may hold
Metadata-protocol: none

ADR-0161 K4, clause 2 (runtime authoring). A knowledge source can now be created and edited in Studio like a skill or a context pack: Studio's metadata editor lays it out with the new `knowledgeSourceForm` (`@objectstack/spec/ai`, registered in `METADATA_FORM_REGISTRY` as `knowledge_source`), and a Save goes through the metadata API, where the two save-time guards (the `manage_knowledge_sources` capability, and source admission as the author) refuse what they refuse today. The knowledge service picks the published source up with no restart, and `search_knowledge` answers from it.

- **Basics.** `name`, `label`, `description`, `aiExposed`, and `adapter` as optional free text: blank means the deployment's store (pgvector on PostgreSQL, turso otherwise, else the only store mounted).
- **Records.** The object is picked from the object catalog; `source.content` (in order) and `source.metadataFields` are field pickers over that object's fields. `source.where` is the JSON editor and takes an ObjectQL filter, for example `{"status": {"$ne": "done"}}`. `source.split` takes the strategy (`whole`, `recursive`, `markdown`), `maxChars` and `minChars`.
- **Egress and cost.** Beside `content` the form says that a build costs money: the first build sends the text of every listed field of every matching record to your embedding provider, which bills for it, and keeps it in an index; a rebuild after a change of embedding model or split sends all of it again. Beside `adapter` it says that the `memory` store re-embeds the whole source on every boot. Content fields are named one by one: there is no wildcard.
- **Refresh.** `refresh.onRecordChange`.
- No control is offered for a key the type does not carry (`embedding`, `vectorStore`, `adapterConfig`, `refresh.cron`, a `'*'` member).
- **Field pickers follow the object the form declares.** Studio's metadata editor bound its field pickers to an object found at a fixed set of item paths (`interfaceConfig.source`, `data.object`, `object`, `objectName`); it now also reads the path the type's form declares on its picker rows (`dependsOn`, under the composites the row sits in), which is how a knowledge source's pickers offer the fields of `source.object`. Types the fixed set already served are bound as before.
- **Translations.** The form's section and help strings are in the Setup bundles (`@objectstack/platform-objects`), translated for zh-CN, ja-JP and es-ES; in the other locales the select choices are translated and the rest carries the English text until it is translated, as for every metadata form.
Original file line number Diff line number Diff line change
Expand Up @@ -3494,6 +3494,98 @@ export const arMetadataForms: NonNullable<TranslationData['metadataForms']> = {
}
},
knowledge_source: {
label: "مصدر معرفة"
label: "مصدر معرفة",
sections: {
basics: {
label: "Basics",
description: "The source's identity, whether agents may search it, and the store that holds its index."
},
records: {
label: "Records",
description: "Which records of which object are indexed, and which of their fields. Each field picker offers the fields of the object chosen here."
},
refresh: {
label: "Refresh",
description: "How the index follows the records."
}
},
fields: {
name: {
label: "Name",
helpText: "Unique identifier (snake_case). search_knowledge lists the source by it, and its sourceIds argument names the source by it."
},
label: {
label: "Label",
helpText: "Display name, shown in the sources list of a search_knowledge answer."
},
description: {
label: "Description",
helpText: "What the source holds, shown beside its name in the sources list of a search_knowledge answer."
},
aiExposed: {
label: "Searchable by AI agents",
helpText: "Whether search_knowledge may search this source for AI agents. On by default."
},
adapter: {
label: "Store",
helpText: "The store that holds the index, by its adapter id (pgvector, turso, memory). Leave it blank for the deployment's store: pgvector on PostgreSQL, turso otherwise, else the only store mounted. A store this deployment does not mount is refused at save. The memory store keeps nothing across a restart, so every boot builds its index again and sends the whole source to the embedding provider."
},
source: {
label: "Source",
helpText: "What the source indexes: the records of one object."
},
"source.kind": {
label: "Kind",
helpText: "What the source indexes. A source indexes the records of one object.",
options: {
object: "سجلات كائن"
}
},
"source.object": {
label: "Object",
helpText: "The object whose records are indexed. Each matching record becomes one document."
},
"source.content": {
label: "Content fields",
helpText: "The fields whose text is indexed, in order. Each field is named: there is no wildcard. Embedding is egress, and a build costs money: the first build reads every record the filter matches and sends the text of each listed field to your embedding provider, which bills for it, and that text is kept in an index outside the record store. A rebuild after you change the embedding model or the split sends all of it again. A field added to the object later is not indexed until you add it here. Credential and internal fields are never indexed, even when listed."
},
"source.metadataFields": {
label: "Filter fields",
helpText: "Fields kept beside each passage, so a search can filter on them (for example a status or an owner). Each one must be a field you may query."
},
"source.where": {
label: "Records to index",
helpText: "An ObjectQL filter on the object, for example {\"status\": {\"$ne\": \"done\"}}. Only the records it matches are indexed. Blank: every record."
},
"source.split": {
label: "Passages",
helpText: "How each document is cut into passages. Blank: recursive, with the settings page's chunk size (800 characters unless changed)."
},
"source.split.strategy": {
label: "Strategy",
helpText: "Whole: one passage per document. Recursive: cut at blank lines, then line breaks, then sentence ends. Markdown: one passage per heading, carrying its heading path.",
options: {
whole: "المستند كاملاً",
recursive: "تكراري",
markdown: "أقسام Markdown"
}
},
"source.split.maxChars": {
label: "Longest passage",
helpText: "In characters. Wins over the settings page's chunk size; the embedding model's input limit can lower it. Not read by Whole document."
},
"source.split.minChars": {
label: "Shortest passage",
helpText: "Adjacent pieces shorter than this are merged, up to this length (default 200). Recursive and Markdown only."
},
refresh: {
label: "Refresh",
helpText: "How the index is kept in step with the records."
},
"refresh.onRecordChange": {
label: "Sync on record changes",
helpText: "Keep the index in step as records are created, changed and deleted (on by default). Off: an external indexer keeps the index, and the platform neither syncs nor builds it."
}
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,46 @@ export const arGeneratedSourceHashes: Readonly<Record<string, string>> = {
"metadataForms.email_template.fields.variables.helpText": "27197774c2cda633",
"metadataForms.field.fields.inlineEdit.helpText": "1ce60e4c6d5fc0e1",
"metadataForms.field.fields.inlineEdit.label": "f29ea014320f588e",
"metadataForms.knowledge_source.fields.adapter.helpText": "9529330956105d79",
"metadataForms.knowledge_source.fields.adapter.label": "da213009390baa11",
"metadataForms.knowledge_source.fields.aiExposed.helpText": "308cc1b601e6601c",
"metadataForms.knowledge_source.fields.aiExposed.label": "61da7af3c7a42d23",
"metadataForms.knowledge_source.fields.description.helpText": "6117bd9062dbb3d3",
"metadataForms.knowledge_source.fields.description.label": "779a4342c8eb6707",
"metadataForms.knowledge_source.fields.label.helpText": "0108489eabde9658",
"metadataForms.knowledge_source.fields.label.label": "c680364257b11569",
"metadataForms.knowledge_source.fields.name.helpText": "e825b21f14b83cfa",
"metadataForms.knowledge_source.fields.name.label": "5274417ff1ccaf01",
"metadataForms.knowledge_source.fields.refresh.helpText": "3dc3007498cbdddc",
"metadataForms.knowledge_source.fields.refresh.label": "1b63ae2e002930a6",
"metadataForms.knowledge_source.fields.refresh.onRecordChange.helpText": "ef6f113e883733b7",
"metadataForms.knowledge_source.fields.refresh.onRecordChange.label": "53a3285b7bcfb91f",
"metadataForms.knowledge_source.fields.source.content.helpText": "a58391e05d69ffe7",
"metadataForms.knowledge_source.fields.source.content.label": "fb33868fefbf74b3",
"metadataForms.knowledge_source.fields.source.helpText": "0b648dbc7af2f85c",
"metadataForms.knowledge_source.fields.source.kind.helpText": "98e903260393800d",
"metadataForms.knowledge_source.fields.source.kind.label": "3acd2ee4b0e7f2cf",
"metadataForms.knowledge_source.fields.source.label": "8fe786e8e29c8cec",
"metadataForms.knowledge_source.fields.source.metadataFields.helpText": "8f41aea242f1a77e",
"metadataForms.knowledge_source.fields.source.metadataFields.label": "de294fc128e44483",
"metadataForms.knowledge_source.fields.source.object.helpText": "37a6686deb6e5201",
"metadataForms.knowledge_source.fields.source.object.label": "d0c49032d95ebb36",
"metadataForms.knowledge_source.fields.source.split.helpText": "a51a59132d112116",
"metadataForms.knowledge_source.fields.source.split.label": "3a77c4c884b1d4a4",
"metadataForms.knowledge_source.fields.source.split.maxChars.helpText": "d7254716c7258828",
"metadataForms.knowledge_source.fields.source.split.maxChars.label": "780596d178bbdef6",
"metadataForms.knowledge_source.fields.source.split.minChars.helpText": "c570045548551b8b",
"metadataForms.knowledge_source.fields.source.split.minChars.label": "f8a2b05e9c16afda",
"metadataForms.knowledge_source.fields.source.split.strategy.helpText": "f3ff47d9386b7956",
"metadataForms.knowledge_source.fields.source.split.strategy.label": "785c1dd353da380b",
"metadataForms.knowledge_source.fields.source.where.helpText": "45098881521ffbd5",
"metadataForms.knowledge_source.fields.source.where.label": "cae99e947da34116",
"metadataForms.knowledge_source.sections.basics.description": "c232f620677bab66",
"metadataForms.knowledge_source.sections.basics.label": "55562f900da68c5d",
"metadataForms.knowledge_source.sections.records.description": "929da5e97dc7eda2",
"metadataForms.knowledge_source.sections.records.label": "9e5814dbd123f1c1",
"metadataForms.knowledge_source.sections.refresh.description": "79311cb3f9e55b89",
"metadataForms.knowledge_source.sections.refresh.label": "1b63ae2e002930a6",
"metadataForms.permission.fields.fields.helpText": "887a0bae04a950e2",
"metadataForms.permission.fields.objects.helpText": "e2512cfb3b501aae",
"metadataForms.permission.fields.tabPermissions.helpText": "8942e2aebe59897c",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -821,16 +821,19 @@ describe('#19403 round 7 — the population, DERIVED from the registry and a sha
// #37143), so it is a panel type now.
// 15 → 16: `form` joined bare (ADR-0159 card ②, #37086).
// 16 / 18 → 17 / 18: `knowledge_source` arrives bare (#37304).
expect(BARE_TYPES.length).toBe(17);
expect(PANEL_TYPES.length).toBe(18);
// 17 / 18 → 16 / 19: `knowledge_source` gained its form (ADR-0161 K4
// clause 2, #37309), so it is a panel type now.
expect(BARE_TYPES.length).toBe(16);
expect(PANEL_TYPES.length).toBe(19);
expect(BARE_TYPES.length + PANEL_TYPES.length).toBe(REGISTRY_TYPES.length);
for (const type of ['seed', 'mapping', 'api', 'doc', 'book', 'capability', 'picklist', 'sharing_rule', 'queue', 'assignment_rule', 'object_extension']) {
expect(BARE_TYPES, `${type} is bare`).toContain(type);
}
for (const type of AUTHORED_BARE_TYPES) expect(BARE_TYPES, `${type} is bare`).toContain(type);
// 28 leaves: seventeen labels, and a description on the eleven that carry one.
expect(BARE_LEAVES.length).toBe(28);
expect(BARE_LEAVES.filter((l) => l.prop === 'label').length).toBe(17);
// 27 leaves: sixteen labels, and a description on the eleven that carry one
// (`knowledge_source`, label only, left the class with its form, #37309).
expect(BARE_LEAVES.length).toBe(27);
expect(BARE_LEAVES.filter((l) => l.prop === 'label').length).toBe(16);
expect(BARE_LEAVES.filter((l) => l.prop === 'description').length).toBe(11);
expect(BARE_LEAVES.every((l) => ['label', 'description'].includes(l.prop))).toBe(true);
});
Expand Down Expand Up @@ -912,13 +915,13 @@ describe('#19403 round 7 — the population, DERIVED from the registry and a sha
expect(flagged.length).toBe(BARE_LEAVES.length);
});

it('⭐ this class is now DONE — zero of its 28 leaves echoes in all three locales', () => {
it('⭐ this class is now DONE — zero of its 27 leaves echoes in all three locales', () => {
const echoing = BARE_LEAVES.filter((l) =>
TRANSLATED_LOCALES.every(([, forms]) => forms[l.type]?.[l.prop] === l.en),
);
expect(echoing.map((l) => `${l.type}.${l.prop}`)).toEqual([]);
// Lit — and it really walked the class, which a zero alone would not show.
expect(BARE_LEAVES.length).toBe(28);
expect(BARE_LEAVES.length).toBe(27);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3494,6 +3494,98 @@ export const deMetadataForms: NonNullable<TranslationData['metadataForms']> = {
}
},
knowledge_source: {
label: "Wissensquelle"
label: "Wissensquelle",
sections: {
basics: {
label: "Basics",
description: "The source's identity, whether agents may search it, and the store that holds its index."
},
records: {
label: "Records",
description: "Which records of which object are indexed, and which of their fields. Each field picker offers the fields of the object chosen here."
},
refresh: {
label: "Refresh",
description: "How the index follows the records."
}
},
fields: {
name: {
label: "Name",
helpText: "Unique identifier (snake_case). search_knowledge lists the source by it, and its sourceIds argument names the source by it."
},
label: {
label: "Label",
helpText: "Display name, shown in the sources list of a search_knowledge answer."
},
description: {
label: "Description",
helpText: "What the source holds, shown beside its name in the sources list of a search_knowledge answer."
},
aiExposed: {
label: "Searchable by AI agents",
helpText: "Whether search_knowledge may search this source for AI agents. On by default."
},
adapter: {
label: "Store",
helpText: "The store that holds the index, by its adapter id (pgvector, turso, memory). Leave it blank for the deployment's store: pgvector on PostgreSQL, turso otherwise, else the only store mounted. A store this deployment does not mount is refused at save. The memory store keeps nothing across a restart, so every boot builds its index again and sends the whole source to the embedding provider."
},
source: {
label: "Source",
helpText: "What the source indexes: the records of one object."
},
"source.kind": {
label: "Kind",
helpText: "What the source indexes. A source indexes the records of one object.",
options: {
object: "Datensätze eines Objekts"
}
},
"source.object": {
label: "Object",
helpText: "The object whose records are indexed. Each matching record becomes one document."
},
"source.content": {
label: "Content fields",
helpText: "The fields whose text is indexed, in order. Each field is named: there is no wildcard. Embedding is egress, and a build costs money: the first build reads every record the filter matches and sends the text of each listed field to your embedding provider, which bills for it, and that text is kept in an index outside the record store. A rebuild after you change the embedding model or the split sends all of it again. A field added to the object later is not indexed until you add it here. Credential and internal fields are never indexed, even when listed."
},
"source.metadataFields": {
label: "Filter fields",
helpText: "Fields kept beside each passage, so a search can filter on them (for example a status or an owner). Each one must be a field you may query."
},
"source.where": {
label: "Records to index",
helpText: "An ObjectQL filter on the object, for example {\"status\": {\"$ne\": \"done\"}}. Only the records it matches are indexed. Blank: every record."
},
"source.split": {
label: "Passages",
helpText: "How each document is cut into passages. Blank: recursive, with the settings page's chunk size (800 characters unless changed)."
},
"source.split.strategy": {
label: "Strategy",
helpText: "Whole: one passage per document. Recursive: cut at blank lines, then line breaks, then sentence ends. Markdown: one passage per heading, carrying its heading path.",
options: {
whole: "Ganzes Dokument",
recursive: "Rekursiv",
markdown: "Markdown-Abschnitte"
}
},
"source.split.maxChars": {
label: "Longest passage",
helpText: "In characters. Wins over the settings page's chunk size; the embedding model's input limit can lower it. Not read by Whole document."
},
"source.split.minChars": {
label: "Shortest passage",
helpText: "Adjacent pieces shorter than this are merged, up to this length (default 200). Recursive and Markdown only."
},
refresh: {
label: "Refresh",
helpText: "How the index is kept in step with the records."
},
"refresh.onRecordChange": {
label: "Sync on record changes",
helpText: "Keep the index in step as records are created, changed and deleted (on by default). Off: an external indexer keeps the index, and the platform neither syncs nor builds it."
}
}
}
};
Loading
Loading