diff --git a/.changeset/37907-knowledge-turso-test-connection.md b/.changeset/37907-knowledge-turso-test-connection.md new file mode 100644 index 00000000000..abad65b5cbd --- /dev/null +++ b/.changeset/37907-knowledge-turso-test-connection.md @@ -0,0 +1,27 @@ +--- +'@objectstack/knowledge-turso': patch +'@objectstack/service-settings': patch +'@objectstack/service-knowledge': patch +--- + +fix(knowledge-turso)!: the Knowledge page's "Test connection" comes with the Turso fields it checks — a page without them has no such action + +Clause-②: yes (narrowing) — the public surface grows by four exports of `@objectstack/knowledge-turso` (listed below); narrowed: where `@objectstack/knowledge-turso` does not contribute its Turso group (the store is `@objectstack/knowledge-pgvector`, on PostgreSQL, or the store is mounted with a `url` or `client` of its own), the Knowledge page has no "Test connection" action and `POST /api/settings/knowledge/test` answers `400 SETTINGS_ACTION_FAILED` (no handler registered), as every undeclared action does, where it answered the Turso form check with `200`; where the store reads its URL from settings, the action is on the page, beside the two fields, and answers as before. `@objectstack/service-settings` no longer exports `knowledgeTestActionHandler`; `@objectstack/knowledge-turso` does +Metadata-protocol: none +Skills-docs: none — no skill under `skills/**` teaches the Knowledge page's test action or `knowledgeTestActionHandler`. + + + +**BREAKING** for three readers: + +- A script or client that posts to `POST /api/settings/knowledge/test` on a deployment where the Turso fields are not on the page now gets `400 SETTINGS_ACTION_FAILED`. The check it answered there read fields nothing on that deployment reads, and opened no connection. Stop calling it there. +- Code that imports `knowledgeTestActionHandler` from `@objectstack/service-settings`: import it from `@objectstack/knowledge-turso` instead (`import { knowledgeTestActionHandler } from '@objectstack/knowledge-turso'`). Same check, same answers. `@objectstack/knowledge-turso` depends on the native libSQL client (`@libsql/client`); importing the handler loads nothing native, but installing the package installs that dependency. +- A host that registers its own `knowledge` settings page declaring `turso_url`, `turso_auth_token` and the `test` action: `KnowledgeTursoPlugin` leaves that page as written and registers no handler for it, so its `test` button now answers `400 SETTINGS_ACTION_FAILED`. Register the handler yourself after registering the page: `settings.registerAction('knowledge', 'test', knowledgeTestActionHandler)`, with `knowledgeTestActionHandler` imported from `@objectstack/knowledge-turso`. + +The `test` action left `@objectstack/service-settings`' `knowledge` manifest, and `@objectstack/service-knowledge` no longer registers its handler. `KnowledgeTursoPlugin` declares it as the last entry of the Turso group, after `turso_auth_token`, and registers `knowledgeTestActionHandler` with it, only where it contributes the group. The action's label moved with it, in all eleven locales: out of `@objectstack/service-settings`' bundles, into `knowledgeTursoSettingsTranslations`. + +New exports of `@objectstack/knowledge-turso`: `knowledgeTestActionHandler`, `KNOWLEDGE_TURSO_TEST_ACTION`, and the types `KnowledgeTursoActionInput` and `KnowledgeTursoActionResult`. + +`KnowledgeTursoPlugin` now warns once, at `init()`, when it reads its URL from settings but the Knowledge page cannot carry `turso_url` and `turso_auth_token` (no settings service, no `knowledge` page, or a host page that declares one of the group's ids without both keys): nothing can be saved there, and the store opens its default file, which the line names. + +The Turso group's description no longer says that a cloud deployment with a database per organization reuses that organization's database for a blank URL (no deployment does: a blank URL opens `knowledge.db` in the data directory), and no longer says the fields are not read on PostgreSQL (the group is never on the page there). It says instead that a blank URL uses `knowledge.db` in the data directory, in all eleven locales. diff --git a/content/docs/ai/knowledge-rag.mdx b/content/docs/ai/knowledge-rag.mdx index 3cbdf5258a6..ec63729ead3 100644 --- a/content/docs/ai/knowledge-rag.mdx +++ b/content/docs/ai/knowledge-rag.mdx @@ -36,7 +36,7 @@ Which store is mounted depends on the platform database: - **The embedder** comes from Settings → AI & Embedder ([below](#configuring-the-embedder-from-settings)). - **Another libSQL store** for the `turso` case: save its URL as `turso_url` (and `turso_auth_token` for a managed `libsql://` database) in Settings → Knowledge, then restart. A `file:` URL saved there must name a file inside that same data directory, and a URL carrying a NUL byte or another control character, written out or percent-encoded (`%00`), is refused, as is a token carrying one (a pasted line break counts); either way the store answers `SERVICE_UNAVAILABLE` saying why, and the boot goes on. - **Where the file is**: `os start --home` and `OS_HOME` move it with the default database, so on a container put `OS_HOME` on a volume and the index survives a redeploy. A database named by URL (`OS_DATABASE_URL`) does not move it. -- **Settings → Knowledge** holds only what the service and its store read: `turso_url` and `turso_auth_token`, which `@objectstack/knowledge-turso` adds to the page where it is the store and reads them (on PostgreSQL the page shows neither), and `chunk_target`, the longest passage the splitter cuts. The page names no adapter: a source's store is the one its own `adapter` names, and `os knowledge status` reports it per source. Every search re-checks each hit as the asking user, and no setting turns that off. +- **Settings → Knowledge** holds only what the service and its store read: `turso_url` and `turso_auth_token`, which `@objectstack/knowledge-turso` adds to the page where it is the store and reads them, with the "Test connection" check of those two fields (on PostgreSQL the page shows none of the three), and `chunk_target`, the longest passage the splitter cuts. The page names no adapter: a source's store is the one its own `adapter` names, and `os knowledge status` reports it per source. Every search re-checks each hit as the asking user, and no setting turns that off. A PostgreSQL deployment that saved the two Turso keys before the group left the page keeps their rows; the settings service never deletes a stored row. To tidy it up, delete the `knowledge` rows named `turso_url` and `turso_auth_token`, and the `sys_secret` row the `turso_auth_token` row's handle names: without the store no API door clears that key, and the row is a decryptable copy of the token. Nothing requires it. - **More than one replica** on MySQL, MongoDB or a remote libSQL database: each replica keeps its own local `knowledge.db` and indexes only the record writes that replica itself handles, so replicas answer from indexes that differ. Give them one store: save a shared `libsql://` URL in `turso_url`, or run on PostgreSQL, where the vectors live in the one database. - **An install without the libSQL client**: `@objectstack/knowledge-turso` is an optional dependency of the CLI, because its client is a native module. Where it could not be installed the server warns at boot that the store was not mounted, and sources naming `turso` answer `SERVICE_UNAVAILABLE`. - **Without a source or the token** nothing is mounted: no knowledge service, no store and no Knowledge settings page. `knowledge-memory` is never mounted for you. diff --git a/packages/plugins/knowledge-turso/src/__tests__/plugin.test.ts b/packages/plugins/knowledge-turso/src/__tests__/plugin.test.ts index ac599acb64a..f96e8f16db3 100644 --- a/packages/plugins/knowledge-turso/src/__tests__/plugin.test.ts +++ b/packages/plugins/knowledge-turso/src/__tests__/plugin.test.ts @@ -296,11 +296,17 @@ describe('resolveSettingsStoreUrl', () => { * A settings service answering saved `knowledge` values as `SettingsService.get` * resolves them — and, as the real one does, only once its data engine is * bound: until `bound` is set a saved value reads as the manifest default. + * It serves a `knowledge` page the plugin's init() contributes the Turso group + * to, as the knowledge service's page is on a real boot. */ function settingsOf(saved: Record, failure?: Error) { + let page = { namespace: 'knowledge', specifiers: [] as Array<{ key?: string; id?: string }> }; const settings = { bound: false, reads: 0, + getManifest: () => page, + registerManifest: (m: typeof page) => { page = m; }, + registerAction: () => undefined, get: async (namespace: string, key: string) => { settings.reads += 1; if (failure) throw failure; diff --git a/packages/plugins/knowledge-turso/src/__tests__/settings-contribution.test.ts b/packages/plugins/knowledge-turso/src/__tests__/settings-contribution.test.ts index 325ab9ee08d..3ec53c78f5b 100644 --- a/packages/plugins/knowledge-turso/src/__tests__/settings-contribution.test.ts +++ b/packages/plugins/knowledge-turso/src/__tests__/settings-contribution.test.ts @@ -36,7 +36,7 @@ import { LiteKernel } from '@objectstack/core'; import type { Plugin, PluginContext } from '@objectstack/core'; import type { IHttpRequest, IHttpResponse, IHttpServer, RouteHandler } from '@objectstack/spec/contracts'; import { KNOWLEDGE_SERVICE } from '@objectstack/spec/contracts'; -import { KnowledgeServicePlugin } from '@objectstack/service-knowledge'; +import { KnowledgeServicePlugin, type KnowledgeServicePluginOptions } from '@objectstack/service-knowledge'; import { SettingsServicePlugin, registerSettingsRoutes, @@ -46,11 +46,25 @@ import { import { KnowledgeTursoPlugin, dataDirectoryOf, + knowledgeTestActionHandler, knowledgeTursoSettingsSpecifiers, knowledgeTursoSettingsTranslations, } from '../index.js'; -const TURSO_IDS = ['turso', 'turso_url', 'turso_auth_token']; +/** The group, its two fields and the action that checks them, in page order. */ +const TURSO_IDS = ['turso', 'turso_url', 'turso_auth_token', 'test']; + +/** + * `POST /api/settings/knowledge/` beside the same post to an action + * no page declares: the answer "as for an undeclared action" is judged by that + * control's envelope, never by its message text. + */ +async function postBesideUndeclared(http: MockHttp, actionId: string, body: unknown) { + const route = 'POST /api/settings/:namespace/:actionId'; + const answer = await call(http, route, { namespace: 'knowledge', actionId }, body); + const control = await call(http, route, { namespace: 'knowledge', actionId: 'never_declared' }, body); + return { answer, control }; +} const dirs: string[] = []; afterAll(() => { @@ -92,7 +106,7 @@ class SavesStoreUrl implements Plugin { type Mount = 'no-turso' | 'turso-from-settings' | 'turso-own-url'; -async function boot(mount: Mount, extra: Plugin[] = []) { +async function boot(mount: Mount, extra: Plugin[] = [], knowledgeOptions: KnowledgeServicePluginOptions = {}) { const root = mkdtempSync(join(tmpdir(), 'knowledge-turso-settings-')); dirs.push(root); const i18n = new RecordingI18nPlugin(); @@ -103,7 +117,7 @@ async function boot(mount: Mount, extra: Plugin[] = []) { // service, whose init() registers the page this plugin adds to. if (mount === 'turso-from-settings') kernel.use(new KnowledgeTursoPlugin({ urlFromSettings: true, projectRoot: root, env: {} })); if (mount === 'turso-own-url') kernel.use(new KnowledgeTursoPlugin({ url: ':memory:', urlFromSettings: true, projectRoot: root, env: {} })); - kernel.use(new KnowledgeServicePlugin({ enableEventSync: false, buildAtBoot: false })); + kernel.use(new KnowledgeServicePlugin({ enableEventSync: false, buildAtBoot: false, ...knowledgeOptions })); kernel.use(new SettingsServicePlugin({ env: {}, registerRoutes: false })); for (const p of extra) kernel.use(p); await kernel.bootstrap(); @@ -172,6 +186,17 @@ describe('the Knowledge page without knowledge-turso (the store is pgvector)', a } }); + it('has no Test connection: the action door answers as for an undeclared action', async () => { + const specs = settings.getManifest('knowledge').specifiers as Array<{ type: string }>; + expect(specs.filter((s) => s.type === 'action_button')).toEqual([]); + const { answer, control } = await postBesideUndeclared(http, 'test', { values: { turso_url: 'file:./sent.db' } }); + expect(answer.status).toBe(400); + expect(answer.body?.error?.code).toBe('SETTINGS_ACTION_FAILED'); + expect([control.status, control.body?.error?.code]).toEqual([answer.status, answer.body?.error?.code]); + // Not the Turso check's answer: it would name the URL it was sent. + expect(JSON.stringify(answer.body)).not.toContain('file:./sent.db'); + }); + it('loads no Turso copy into the i18n service', () => { expect(loadedTursoCopy(i18n.loaded)).toEqual([]); // Non-vacuity: the settings bundle itself was loaded into the same recorder. @@ -184,13 +209,23 @@ describe('the Knowledge page with knowledge-turso reading its URL from settings' dirs.push(probe); const { settings, http, i18n } = await boot('turso-from-settings'); - it('carries the Turso group and its two fields, in front of the page, as declared', () => { + it('carries the Turso group, its two fields and their Test connection, in front of the page, as declared', () => { const ids = idsOf(settings); - expect(ids.slice(0, 3)).toEqual(TURSO_IDS); + expect(ids.slice(0, TURSO_IDS.length)).toEqual(TURSO_IDS); expect(ids).toContain('chunk_target'); - expect(settings.getManifest('knowledge').specifiers.slice(0, 3)).toEqual(knowledgeTursoSettingsSpecifiers); - // The page's own action is still answered after the re-registration. - expect(ids).toContain('test'); + expect(settings.getManifest('knowledge').specifiers.slice(0, TURSO_IDS.length)).toEqual(knowledgeTursoSettingsSpecifiers); + expect(knowledgeTursoSettingsSpecifiers.find((s) => s.id === 'test')).toMatchObject({ + type: 'action_button', + handler: { kind: 'http', method: 'POST', url: '/api/settings/knowledge/test' }, + }); + }); + + it('answers Test connection with the Turso check, where an undeclared action is refused', async () => { + const { answer, control } = await postBesideUndeclared(http, 'test', { values: { turso_url: 'file:./sent.db' } }); + expect(control.status).toBe(400); + expect(answer.status).toBe(200); + expect(answer.body?.data?.ok).toBe(true); + expect(String(answer.body?.data?.message)).toContain('file:./sent.db'); }); it('saves a PUT of turso_url, and keeps the auth token a secret', async () => { @@ -235,13 +270,40 @@ describe('the Knowledge page with knowledge-turso reading its URL from settings' }); }); +/** + * `embedderSettings: false` on the knowledge service keeps the embedder + * section off the `ai` page; the Knowledge page this store adds to is not + * that section, so its group and its Test connection are offered as before. + */ +describe('knowledge-turso beside a knowledge service mounted with embedderSettings: false', async () => { + const { settings, http } = await boot('turso-from-settings', [], { embedderSettings: false }); + const asBefore = await boot('turso-from-settings'); + + it('carries the Turso group, its two fields and their Test connection, as with the default mount', () => { + expect(idsOf(settings).slice(0, TURSO_IDS.length)).toEqual(TURSO_IDS); + expect(settings.getManifest('knowledge')).toEqual(asBefore.settings.getManifest('knowledge')); + }); + + it('answers Test connection with the Turso check, where an undeclared action is refused', async () => { + const { answer, control } = await postBesideUndeclared(http, 'test', { values: { turso_url: 'file:./sent.db' } }); + expect(control.status).toBe(400); + expect(answer.status).toBe(200); + expect(answer.body?.data?.ok).toBe(true); + // The Turso check's own answer: it names the URL it was sent. + expect(String(answer.body?.data?.message)).toContain('file:./sent.db'); + }); +}); + describe('knowledge-turso given a url of its own', async () => { - const { settings } = await boot('turso-own-url'); + const { settings, http } = await boot('turso-own-url'); - it('reads no setting, so the page carries no Turso field', () => { + it('reads no setting, so the page carries no Turso field and no Test connection', async () => { const ids = idsOf(settings); expect(ids).toContain('chunk_target'); for (const id of TURSO_IDS) expect(ids, id).not.toContain(id); + const { answer, control } = await postBesideUndeclared(http, 'test', {}); + expect(answer.status).toBe(400); + expect([control.status, control.body?.error?.code]).toEqual([answer.status, answer.body?.error?.code]); }); }); @@ -266,6 +328,7 @@ describe('the Turso group\'s copy moved with its fields', () => { expect(copy.keys[f.key!].label, `${locale} ${f.key}`).toBeTruthy(); expect(copy.keys[f.key!].help, `${locale} ${f.key}`).toBeTruthy(); } + expect(copy.actions.test.label, `${locale} test`).toBeTruthy(); } }); @@ -276,6 +339,157 @@ describe('the Turso group\'s copy moved with its fields', () => { expect(page.groups, locale).not.toHaveProperty('turso'); expect(page.keys, locale).not.toHaveProperty('turso_url'); expect(page.keys, locale).not.toHaveProperty('turso_auth_token'); + expect(page.actions ?? {}, locale).not.toHaveProperty('test'); + } + }); + + // The group is on the page only where the store reads it, which is never on + // PostgreSQL, and no deployment reuses an organization's own database for a + // blank URL (a blank URL opens knowledge.db in the data directory). So the + // description names PostgreSQL once (when the group is used), says what + // blank means, and carries neither the PostgreSQL clause nor the cloud one. + it('describes the group as it is read: PostgreSQL named once, blank is knowledge.db, no cloud fallback', () => { + const fallback = String(knowledgeTursoSettingsSpecifiers.find((s) => s.type === 'group')!.description); + const descriptions: Array<[string, string]> = [ + ['fallback', fallback], + ...locales.map((l) => [l, (knowledgeTursoSettingsTranslations[l]!.settings.knowledge.groups.turso.description)] as [string, string]), + ]; + expect(descriptions).toHaveLength(12); + for (const [where, text] of descriptions) { + expect(text.split('PostgreSQL').length - 1, where).toBe(1); + expect(text, where).toContain('knowledge.db'); } + expect(fallback).not.toMatch(/organi[sz]ation|cloud|not read/i); + expect(fallback).toContain('Leave blank to use knowledge.db in the data directory.'); + }); +}); + +describe('knowledgeTestActionHandler — the Turso form check', () => { + it('accepts no URL (the plugin defaults to its own file)', async () => { + const r = await knowledgeTestActionHandler({ values: {} }); + expect(r.ok).toBe(true); + expect(r.severity).toBe('info'); + // The plugin opens a file of its own, never the platform's database. + expect(r.message).toMatch(/knowledge\.db/); + expect(r.message).not.toMatch(/reuse the tenant/); + }); + + it('accepts a local file URL', async () => { + expect((await knowledgeTestActionHandler({ values: { turso_url: 'file:./knowledge.db' } })).ok).toBe(true); + }); + + it('rejects a managed Turso URL without an auth token, and accepts it with one', async () => { + const without = await knowledgeTestActionHandler({ values: { turso_url: 'libsql://x.turso.io' } }); + expect(without.ok).toBe(false); + expect(without.severity).toBe('error'); + const withToken = await knowledgeTestActionHandler({ values: { turso_url: 'libsql://x.turso.io', turso_auth_token: 't' } }); + expect(withToken.ok).toBe(true); + }); + + it('names the package that reads the URL and how it is registered, not an outside origin', async () => { + const message = String((await knowledgeTestActionHandler({ values: { turso_url: 'file:./knowledge.db' } })).message); + expect(message).toContain('@objectstack/knowledge-turso'); + expect(message).toMatch(/registered beside the knowledge service/); + expect(message).not.toMatch(/ObjectOS Cloud monorepo|does not ship|to exercise live calls/); + }); + + it('every green answer says no connection was attempted', async () => { + const forms: Array<[string, Record]> = [ + ['no URL', {}], + ['local file', { turso_url: 'file:./knowledge.db' }], + ['managed', { turso_url: 'libsql://x.turso.io', turso_auth_token: 't' }], + ]; + for (const [label, values] of forms) { + const r = await knowledgeTestActionHandler({ values }); + expect(r.ok, label).toBe(true); + expect(String(r.message), label).toMatch(/no connection was attempted/); + } + }); + + it('reads no adapter: a stale one in the values or the payload changes nothing', async () => { + const fields = { turso_url: 'libsql://x.turso.io', turso_auth_token: 't' }; + const baseline = await knowledgeTestActionHandler({ values: fields }); + expect(baseline.ok).toBe(true); + for (const adapter of ['memory', 'turso', 'ragflow', 'pgvector']) { + expect(await knowledgeTestActionHandler({ values: { ...fields, adapter } }), adapter).toEqual(baseline); + expect(await knowledgeTestActionHandler({ values: fields, payload: { values: { adapter } } }), adapter).toEqual(baseline); + } + // Non-vacuity: the fields it does read change the answer. + expect((await knowledgeTestActionHandler({ values: { turso_url: 'libsql://x.turso.io' } })).ok).toBe(false); + }); + + it('prefers payload.values over persisted values', async () => { + const r = await knowledgeTestActionHandler({ + values: { turso_url: 'libsql://x.turso.io' }, + payload: { values: { turso_url: 'file:foo.db' } }, + }); + expect(r.ok).toBe(true); + expect(r.message).toMatch(/file:foo\.db/); + }); +}); + +/** + * A store that reads its URL from settings, on a composition where the page + * cannot carry the two keys: the read finds nothing saved and the store opens + * its default file. That is said once, at init(). + */ +describe('KnowledgeTursoPlugin — a store-from-settings whose page cannot carry the Turso keys', () => { + const NOT_ON_PAGE = /does not carry turso_url and turso_auth_token/; + + function ctxWith(settings: unknown) { + const warns: string[] = []; + const ctx = { + getService: (name: string) => { + if (name === 'settings' && settings !== undefined) return settings; + throw new Error(`no service ${name}`); + }, + hook: () => undefined, + logger: { info: () => undefined, warn: (m: string) => warns.push(m), debug: () => undefined, error: () => undefined }, + } as unknown as PluginContext; + return { ctx, warns }; + } + + function pageOf(specifiers: unknown[]) { + let page = { namespace: 'knowledge', specifiers }; + const actions: string[] = []; + return { + actions, + getManifest: () => page, + registerManifest: (m: typeof page) => { page = m; }, + registerAction: (_ns: string, id: string) => { actions.push(id); }, + }; + } + + const plugin = () => new KnowledgeTursoPlugin({ urlFromSettings: true, projectRoot: '/srv/app', env: {} }); + + it('warns once with no settings service, naming the default file', async () => { + const { ctx, warns } = ctxWith(undefined); + await plugin().init(ctx); + const hits = warns.filter((m) => NOT_ON_PAGE.test(m)); + expect(hits).toHaveLength(1); + expect(hits[0]).toContain('knowledge.db'); + }); + + it('warns once for a host page that declares a Turso group id without the keys', async () => { + const page = pageOf([{ type: 'action_button', id: 'test', label: 'Host test' }]); + const { ctx, warns } = ctxWith(page); + await plugin().init(ctx); + expect(warns.filter((m) => NOT_ON_PAGE.test(m))).toHaveLength(1); + // The host's page and its own handler are left as written. + expect(page.actions).toEqual([]); + }); + + it('says nothing where it contributes the group, and registers the check with it', async () => { + const page = pageOf([{ type: 'number', key: 'chunk_target', label: 'Chunk' }]); + const { ctx, warns } = ctxWith(page); + await plugin().init(ctx); + expect(warns.filter((m) => NOT_ON_PAGE.test(m))).toEqual([]); + expect(page.actions).toEqual(['test']); + }); + + it('says nothing for a store given a url of its own: it reads no setting', async () => { + const { ctx, warns } = ctxWith(undefined); + await new KnowledgeTursoPlugin({ url: ':memory:', urlFromSettings: true, projectRoot: '/srv/app', env: {} }).init(ctx); + expect(warns.filter((m) => NOT_ON_PAGE.test(m))).toEqual([]); }); }); diff --git a/packages/plugins/knowledge-turso/src/index.ts b/packages/plugins/knowledge-turso/src/index.ts index 8bc16c8610a..48e6c7e2c44 100644 --- a/packages/plugins/knowledge-turso/src/index.ts +++ b/packages/plugins/knowledge-turso/src/index.ts @@ -19,9 +19,13 @@ export { } from './plugin.js'; export { KNOWLEDGE_SETTINGS_NAMESPACE, + KNOWLEDGE_TURSO_TEST_ACTION, contributeKnowledgeTursoSettings, + knowledgeTestActionHandler, knowledgeTursoSettingsSpecifiers, knowledgeTursoSettingsTranslations, withKnowledgeTursoSection, + type KnowledgeTursoActionInput, + type KnowledgeTursoActionResult, } from './settings-contribution.js'; export { GENERATION_TABLE, SAFE_SOURCE_ID, generationTable, legacyTable } from './sql.js'; diff --git a/packages/plugins/knowledge-turso/src/plugin.ts b/packages/plugins/knowledge-turso/src/plugin.ts index c6fefe25ea4..4251d59e9b1 100644 --- a/packages/plugins/knowledge-turso/src/plugin.ts +++ b/packages/plugins/knowledge-turso/src/plugin.ts @@ -428,7 +428,17 @@ export class KnowledgeTursoPlugin implements Plugin { // The two settings this store reads join the Knowledge page here, and only // here: a deployment that does not mount this store, or mounts it with a // `url` or `client` of its own, reads neither, so its page offers neither. - contributeKnowledgeTursoSettings(ctx); + // Where they cannot join it, the read below finds nothing saved and the + // store opens its default file, which would otherwise go unsaid. + if (!contributeKnowledgeTursoSettings(ctx)) { + ctx.logger.warn?.( + 'KnowledgeTursoPlugin: the store reads its URL from the Knowledge settings, but that page does not ' + + 'carry turso_url and turso_auth_token (no settings service, no knowledge page, or a knowledge page ' + + 'that declares one of the Turso group\'s ids without both keys), so nothing can be saved there and ' + + `the store opens its default file (${defaultStoreUrl(this.opts.projectRoot, this.opts.stateDir)}). Mount the knowledge service ` + + 'and the settings service, or pass the plugin a `url`.', + ); + } ctx.hook('kernel:bootstrapped', async () => { await this.openFromSettings(ctx); }); diff --git a/packages/plugins/knowledge-turso/src/settings-contribution.ts b/packages/plugins/knowledge-turso/src/settings-contribution.ts index 9d769bbd9d5..cc7c0c18e1e 100644 --- a/packages/plugins/knowledge-turso/src/settings-contribution.ts +++ b/packages/plugins/knowledge-turso/src/settings-contribution.ts @@ -27,6 +27,12 @@ * `400 UNKNOWN_KEY`, the answer every undeclared key gets; mounted again, the * store reads it as before. * + * The group's "Test connection" action and its handler + * ({@link knowledgeTestActionHandler}) come with it: the check reads the two + * fields and nothing else, so a page without them has no button, and + * `POST /api/settings/knowledge/test` there answers as every undeclared + * action does (`400 SETTINGS_ACTION_FAILED`, no handler registered). + * * The group's copy moved here with it, in every locale the settings bundle * ships ({@link knowledgeTursoSettingsTranslations}), and is loaded into the * i18n service at `kernel:ready`, when the settings service loads its own. @@ -38,9 +44,12 @@ import type { SettingsManifest } from '@objectstack/spec/system'; /** The settings namespace this group joins: the Knowledge page. */ export const KNOWLEDGE_SETTINGS_NAMESPACE = 'knowledge'; +/** The id of the group's "Test connection" action (`POST /api/settings/knowledge/test`). */ +export const KNOWLEDGE_TURSO_TEST_ACTION = 'test'; + /** - * The Turso group and its two fields, in the order the page showed them, ahead - * of the page's other groups. + * The Turso group, its two fields and the "Test connection" action that + * checks them, ahead of the page's other groups. */ export const knowledgeTursoSettingsSpecifiers: SettingsManifest['specifiers'] = [ // ── Turso / libSQL ──────────────────────────────────────────── @@ -49,15 +58,18 @@ export const knowledgeTursoSettingsSpecifiers: SettingsManifest['specifiers'] = { type: 'group', id: 'turso', label: 'Turso / libSQL', required: false, description: 'Used only when the platform database is not PostgreSQL: the knowledge store is then a Turso database, ' + - 'by default a file of its own. On PostgreSQL the store lives in the platform database and these fields are not read. ' + - 'Works against managed Turso (libsql://…), local file (file:./knowledge.db), ' + - 'or in-memory (:memory:). In a cloud deployment with a database per organization, leave blank to ' + - 'reuse that organization\'s own database connection.' }, + 'by default a file of its own. Works against managed Turso (libsql://…), local file (file:./knowledge.db), ' + + 'or in-memory (:memory:). Leave blank to use knowledge.db in the data directory.' }, { type: 'text', key: 'turso_url', label: 'Connection URL', required: false, description: 'Examples: libsql://your-tenant.turso.io · file:./.objectstack/data/knowledge.db · :memory:' }, { type: 'password', key: 'turso_auth_token', label: 'Auth token', required: false, encrypted: true, description: 'Only required for managed Turso URLs. Leave blank for local file / :memory:.' }, + // The check of the two fields above, beside them: a page without them has + // no button, and its action door answers as for any undeclared action. + { type: 'action_button', id: KNOWLEDGE_TURSO_TEST_ACTION, label: 'Test connection', + required: false, icon: 'Plug', + handler: { kind: 'http', method: 'POST', url: `/api/settings/${KNOWLEDGE_SETTINGS_NAMESPACE}/${KNOWLEDGE_TURSO_TEST_ACTION}` } }, ]; /** @@ -80,6 +92,7 @@ interface TursoGroupCopy { turso_url: { label: string; help: string }; turso_auth_token: { label: string; help: string }; }; + actions: { test: { label: string } }; }; }; } @@ -88,8 +101,17 @@ function copy( group: { title: string; description: string }, url: { label: string; help: string }, token: { label: string; help: string }, + test: { label: string }, ): TursoGroupCopy { - return { settings: { knowledge: { groups: { turso: group }, keys: { turso_url: url, turso_auth_token: token } } } }; + return { + settings: { + knowledge: { + groups: { turso: group }, + keys: { turso_url: url, turso_auth_token: token }, + actions: { test }, + }, + }, + }; } const URL_EXAMPLES = 'libsql://your-tenant.turso.io · file:./.objectstack/data/knowledge.db · :memory:'; @@ -102,76 +124,175 @@ const URL_EXAMPLES = 'libsql://your-tenant.turso.io · file:./.objectstack/data/ export const knowledgeTursoSettingsTranslations: Readonly> = { en: copy( { title: 'Turso / libSQL', - description: 'Used only when the platform database is not PostgreSQL; on PostgreSQL the knowledge store lives in the platform database and these fields are not read. Works against managed Turso, local file, or in-memory.' }, + description: 'Used only when the platform database is not PostgreSQL. Works against managed Turso, local file, or in-memory. Leave blank to use knowledge.db in the data directory.' }, { label: 'Connection URL', help: `Examples: ${URL_EXAMPLES}` }, { label: 'Auth token', help: 'Only required for managed Turso URLs.' }, + { label: 'Test connection' }, ), 'zh-CN': copy( { title: 'Turso / libSQL', - description: '仅在平台数据库不是 PostgreSQL 时使用;平台数据库为 PostgreSQL 时,知识存储位于平台数据库中,不读取这些字段。支持托管 Turso、本地文件、内存三种模式。' }, + description: '仅在平台数据库不是 PostgreSQL 时使用。支持托管 Turso、本地文件、内存三种模式。留空则使用数据目录中的 knowledge.db。' }, { label: '连接 URL', help: `示例:${URL_EXAMPLES}` }, { label: 'Auth Token', help: '仅托管 Turso URL 需要。' }, + { label: '测试连接' }, ), 'ja-JP': copy( { title: 'Turso / libSQL', - description: 'プラットフォームのデータベースが PostgreSQL でない場合にのみ使用されます。PostgreSQL の場合、ナレッジストアはプラットフォームのデータベース内にあり、これらの項目は読み取られません。マネージド Turso、ローカルファイル、インメモリのいずれでも動作します。' }, + description: 'プラットフォームのデータベースが PostgreSQL でない場合にのみ使用されます。マネージド Turso、ローカルファイル、インメモリのいずれでも動作します。空欄の場合は、データディレクトリ内の knowledge.db を使用します。' }, { label: '接続 URL', help: `例: ${URL_EXAMPLES}` }, { label: '認証トークン', help: 'マネージド Turso URL の場合のみ必要です。' }, + { label: '接続テスト' }, ), 'es-ES': copy( { title: 'Turso / libSQL', - description: 'Solo se usa cuando la base de datos de la plataforma no es PostgreSQL; con PostgreSQL, el almacén de conocimiento está en la base de datos de la plataforma y estos campos no se leen. Funciona con Turso gestionado, archivo local o en memoria.' }, + description: 'Solo se usa cuando la base de datos de la plataforma no es PostgreSQL. Funciona con Turso gestionado, archivo local o en memoria. Déjelo en blanco para usar knowledge.db en el directorio de datos.' }, { label: 'URL de conexión', help: `Ejemplos: ${URL_EXAMPLES}` }, { label: 'Token de autenticación', help: 'Solo se requiere para URLs de Turso gestionado.' }, + { label: 'Probar conexión' }, ), 'zh-Hant': copy( { title: 'Turso / libSQL', - description: '僅在平台資料庫不是 PostgreSQL 時使用;平台資料庫為 PostgreSQL 時,知識儲存位於平台資料庫中,不會讀取這些欄位。可搭配託管 Turso、本機檔案或記憶體使用。' }, + description: '僅在平台資料庫不是 PostgreSQL 時使用。可搭配託管 Turso、本機檔案或記憶體使用。留空則使用資料目錄中的 knowledge.db。' }, { label: '連線 URL', help: `範例:${URL_EXAMPLES}` }, { label: '驗證權杖', help: '僅託管 Turso URL 需要。' }, + { label: '測試連線' }, ), ar: copy( { title: 'Turso / libSQL', - description: 'يُستخدم فقط عندما لا تكون قاعدة بيانات المنصة PostgreSQL؛ مع PostgreSQL يكون مخزن المعرفة داخل قاعدة بيانات المنصة ولا تُقرأ هذه الحقول. يعمل مع Turso المُدار أو ملف محلي أو في الذاكرة.' }, + description: 'يُستخدم فقط عندما لا تكون قاعدة بيانات المنصة PostgreSQL. يعمل مع Turso المُدار أو ملف محلي أو في الذاكرة. اتركه فارغًا لاستخدام knowledge.db في دليل البيانات.' }, { label: 'عنوان URL للاتصال', help: `أمثلة: ${URL_EXAMPLES}` }, { label: 'رمز المصادقة', help: 'مطلوب فقط لعناوين Turso المُدارة.' }, + { label: 'اختبار الاتصال' }, ), fr: copy( { title: 'Turso / libSQL', - description: 'Utilisé uniquement lorsque la base de données de la plateforme n’est pas PostgreSQL ; sous PostgreSQL, le magasin de connaissances se trouve dans la base de données de la plateforme et ces champs ne sont pas lus. Fonctionne avec Turso géré, un fichier local ou en mémoire.' }, + description: 'Utilisé uniquement lorsque la base de données de la plateforme n’est pas PostgreSQL. Fonctionne avec Turso géré, un fichier local ou en mémoire. Laissez vide pour utiliser knowledge.db dans le répertoire de données.' }, { label: 'URL de connexion', help: `Exemples : ${URL_EXAMPLES}` }, { label: 'Jeton d’authentification', help: 'Nécessaire uniquement pour les URL Turso gérées.' }, + { label: 'Tester la connexion' }, ), 'pt-BR': copy( { title: 'Turso / libSQL', - description: 'Usado apenas quando o banco de dados da plataforma não é PostgreSQL; no PostgreSQL, o repositório de conhecimento fica no banco de dados da plataforma e estes campos não são lidos. Funciona com Turso gerenciado, arquivo local ou em memória.' }, + description: 'Usado apenas quando o banco de dados da plataforma não é PostgreSQL. Funciona com Turso gerenciado, arquivo local ou em memória. Deixe em branco para usar knowledge.db no diretório de dados.' }, { label: 'URL de conexão', help: `Exemplos: ${URL_EXAMPLES}` }, { label: 'Token de autenticação', help: 'Necessário apenas para URLs do Turso gerenciado.' }, + { label: 'Testar conexão' }, ), ru: copy( { title: 'Turso / libSQL', - description: 'Используется, только если база данных платформы — не PostgreSQL; на PostgreSQL хранилище знаний находится в базе данных платформы, и эти поля не читаются. Работает с управляемым Turso, локальным файлом или в памяти.' }, + description: 'Используется, только если база данных платформы — не PostgreSQL. Работает с управляемым Turso, локальным файлом или в памяти. Оставьте пустым, чтобы использовать knowledge.db в каталоге данных.' }, { label: 'URL подключения', help: `Примеры: ${URL_EXAMPLES}` }, { label: 'Токен авторизации', help: 'Нужен только для URL управляемого Turso.' }, + { label: 'Проверить подключение' }, ), de: copy( { title: 'Turso / libSQL', - description: 'Wird nur verwendet, wenn die Plattformdatenbank nicht PostgreSQL ist; unter PostgreSQL liegt der Wissensspeicher in der Plattformdatenbank, und diese Felder werden nicht gelesen. Funktioniert mit verwaltetem Turso, lokaler Datei oder im Arbeitsspeicher.' }, + description: 'Wird nur verwendet, wenn die Plattformdatenbank nicht PostgreSQL ist. Funktioniert mit verwaltetem Turso, lokaler Datei oder im Arbeitsspeicher. Leer lassen, um knowledge.db im Datenverzeichnis zu verwenden.' }, { label: 'Verbindungs-URL', help: `Beispiele: ${URL_EXAMPLES}` }, { label: 'Auth-Token', help: 'Nur für verwaltete Turso-URLs erforderlich.' }, + { label: 'Verbindung testen' }, ), ko: copy( { title: 'Turso / libSQL', - description: '플랫폼 데이터베이스가 PostgreSQL이 아닐 때만 사용됩니다. PostgreSQL에서는 지식 저장소가 플랫폼 데이터베이스 안에 있으며 이 필드는 읽히지 않습니다. 관리형 Turso, 로컬 파일, 인메모리 모두에서 동작합니다.' }, + description: '플랫폼 데이터베이스가 PostgreSQL이 아닐 때만 사용됩니다. 관리형 Turso, 로컬 파일, 인메모리 모두에서 동작합니다. 비워 두면 데이터 디렉터리의 knowledge.db를 사용합니다.' }, { label: '연결 URL', help: `예: ${URL_EXAMPLES}` }, { label: '인증 토큰', help: '관리형 Turso URL에만 필요합니다.' }, + { label: '연결 테스트' }, ), }; +/** + * What a settings action handler is handed and answers, as this contribution + * uses it (`SettingsActionHandler` in `@objectstack/service-settings`, which + * this package does not depend on at runtime). + */ +export interface KnowledgeTursoActionInput { + /** The namespace's stored values, one per key its page declares. */ + values: Record; + /** The request body: the form's unsaved values, bare or under `values`. */ + payload?: unknown; +} + +/** The answer the action door serves (`200` when `ok`, else `400 SETTINGS_ACTION_FAILED`). */ +export interface KnowledgeTursoActionResult { + ok: boolean; + severity: 'info' | 'warning' | 'error'; + message: string; +} + +/** + * The sentence every answer carries, so a green "Test connection" is never + * read as a connection that succeeded. + */ +const FORM_CHECK_ONLY = 'This checks the form only — no connection was attempted.'; + +/** + * Handler for `knowledge/test` ("Test connection"), registered with the group + * it checks ({@link contributeKnowledgeTursoSettings}): a page without the two + * fields has no button, and no handler. + * + * It checks the libSQL fields for completeness only — a Turso auth token + * beside a managed `libsql://` URL — and opens NO connection. It reads + * `turso_url` and `turso_auth_token` and nothing else: the page names no + * adapter, so a payload or a stored row still carrying `adapter` (a value + * saved before `@objectstack/service-settings`' manifest version 4) is not + * read, and neither is any other key the page does not declare. So every + * answer says no connection was attempted. + */ +export async function knowledgeTestActionHandler({ + values, + payload, +}: KnowledgeTursoActionInput): Promise { + const merged: Record = { ...values, ...extractOverrides(payload) }; + + const url = merged.turso_url; + if (!url) { + return { + ok: true, + severity: 'info', + message: + 'No Turso URL configured — where the knowledge store is @objectstack/knowledge-turso (a platform ' + + 'database other than PostgreSQL), it uses its own file, knowledge.db under .objectstack/data/, never ' + + 'the platform database. ' + + FORM_CHECK_ONLY, + }; + } + const u = String(url); + if (u.startsWith('libsql://') && !merged.turso_auth_token) { + return { + ok: false, + severity: 'error', + message: 'Managed Turso URL requires an auth token.', + }; + } + return { + ok: true, + severity: 'info', + message: + `Turso URL configured (${u}). ${FORM_CHECK_ONLY} It is read at startup by the ` + + '@objectstack/knowledge-turso plugin registered beside the knowledge service, which is the store a ' + + 'platform database other than PostgreSQL gets.', + }; +} + +function extractOverrides(payload: unknown): Record { + if (!payload || typeof payload !== 'object') return {}; + const p = payload as Record; + if (p.values && typeof p.values === 'object' && p.values !== null) { + return p.values as Record; + } + return p; +} + /** The settings service as this contribution uses it. */ interface SettingsRegistry { getManifest(namespace: string): SettingsManifest; registerManifest(manifest: SettingsManifest): void; + registerAction( + namespace: string, + actionId: string, + handler: (input: KnowledgeTursoActionInput) => Promise, + ): void; } /** The i18n service as this contribution uses it. */ @@ -180,14 +301,16 @@ interface TranslationSink { } /** - * Add the Turso group to the composition's Knowledge page, and its copy to the - * i18n service at `kernel:ready`. Called from `KnowledgeTursoPlugin.init()` - * when the plugin reads its URL from settings. + * Add the Turso group, with its "Test connection" action and that action's + * handler, to the composition's Knowledge page, and its copy to the i18n + * service at `kernel:ready`. Called from `KnowledgeTursoPlugin.init()` when + * the plugin reads its URL from settings. * - * Answers whether the page carries the group after the call. No settings - * service, or no `knowledge` page (the knowledge service is not mounted, and - * the plugin's start() says so), contributes nothing; a page that already - * declares the keys is left as it is. + * Answers whether the page carries both Turso keys after the call. No + * settings service, or no `knowledge` page (the knowledge service is not + * mounted), contributes nothing; a page that already declares any of the + * group's ids is left as it is, handler included, and answers whether it + * declares both keys itself. */ export function contributeKnowledgeTursoSettings(ctx: PluginContext): boolean { let settings: Partial | undefined; @@ -196,7 +319,13 @@ export function contributeKnowledgeTursoSettings(ctx: PluginContext): boolean { } catch { return false; } - if (typeof settings?.getManifest !== 'function' || typeof settings.registerManifest !== 'function') return false; + if ( + typeof settings?.getManifest !== 'function' || + typeof settings.registerManifest !== 'function' || + typeof settings.registerAction !== 'function' + ) { + return false; + } let page: SettingsManifest; try { page = settings.getManifest(KNOWLEDGE_SETTINGS_NAMESPACE); @@ -204,7 +333,14 @@ export function contributeKnowledgeTursoSettings(ctx: PluginContext): boolean { return false; } const composed = withKnowledgeTursoSection(page); - if (composed !== page) settings.registerManifest(composed); + if (composed !== page) { + settings.registerManifest(composed); + // After the manifest: `registerAction` refuses a namespace not registered, + // and the re-registration keeps the namespace's other handlers. + settings.registerAction(KNOWLEDGE_SETTINGS_NAMESPACE, KNOWLEDGE_TURSO_TEST_ACTION, knowledgeTestActionHandler); + } + const keys = new Set(composed.specifiers.map((s) => s.key)); + if (!keys.has('turso_url') || !keys.has('turso_auth_token')) return false; ctx.hook('kernel:ready', async () => { let i18n: Partial | undefined; diff --git a/packages/services/service-knowledge/src/__tests__/knowledge-settings-contribution.test.ts b/packages/services/service-knowledge/src/__tests__/knowledge-settings-contribution.test.ts index 816bb8fffec..619ed43468e 100644 --- a/packages/services/service-knowledge/src/__tests__/knowledge-settings-contribution.test.ts +++ b/packages/services/service-knowledge/src/__tests__/knowledge-settings-contribution.test.ts @@ -38,7 +38,6 @@ import { registerSettingsRoutes, aiEmbedderSettingsSpecifiers, aiTestEmbedderActionHandler, - knowledgeTestActionHandler, type CryptoAdapter, type SettingsService, } from '@objectstack/service-settings'; @@ -119,13 +118,19 @@ describe('#33933 — knowledge settings are contributed by the mounted knowledge for (const key of [...EMBEDDER_KEYS, 'embedder', 'test_embedder']) expect(bareKeys, key).not.toContain(key); }); - it('both test buttons reach their handlers when the service is mounted', async () => { + it('the embedder test reaches its handler when the service is mounted; the Turso check is not the service\'s', async () => { // "Reached" is judged by the handler's own answer for the same inputs, // never by message text: the no-handler answer is a different result. - const knowledgeValues = await namespaceValues(mounted.settings, 'knowledge'); - expect(await mounted.settings.runAction('knowledge', 'test', {})).toEqual( - await knowledgeTestActionHandler({ namespace: 'knowledge', actionId: 'test', values: knowledgeValues, payload: {}, ctx: {} }), - ); + // "Test connection" checks the Turso fields, and `@objectstack/knowledge-turso` + // contributes it with them; without that store the page has no such action. + const knowledgeIds = (mounted.settings.getManifest('knowledge').specifiers as Array<{ key?: string; id?: string }>) + .map((x) => x.key ?? x.id); + expect(knowledgeIds).toContain('chunk_target'); + expect(knowledgeIds).not.toContain('test'); + const unanswered = await mounted.settings.runAction('knowledge', 'never_declared', {}); + const turso = await mounted.settings.runAction('knowledge', 'test', {}); + expect({ ok: turso.ok, severity: turso.severity }).toEqual({ ok: unanswered.ok, severity: unanswered.severity }); + expect(turso.ok).toBe(false); const aiValues = await namespaceValues(mounted.settings, 'ai'); const embedder = await mounted.settings.runAction('ai', 'test_embedder', {}); expect(embedder).toEqual( @@ -173,13 +178,17 @@ describe('embedderSettings: false keeps the embedder section off the ai page', a expect(await mounted.settings.runAction('ai', 'test_embedder', {})).not.toEqual(offAnswer); }); - it('the knowledge page, its test button and its Setup entry are offered as before', async () => { + it('the knowledge page, its actions and its Setup entry are offered as before', async () => { expect(off.settings.listManifests().map((m) => m.namespace)).toContain('knowledge'); expect(off.settings.getManifest('knowledge')).toEqual(mounted.settings.getManifest('knowledge')); - const knowledgeValues = await namespaceValues(off.settings, 'knowledge'); - expect(await off.settings.runAction('knowledge', 'test', {})).toEqual( - await knowledgeTestActionHandler({ namespace: 'knowledge', actionId: 'test', values: knowledgeValues, payload: {}, ctx: {} }), - ); + // Test connection is not this service's: `@objectstack/knowledge-turso` + // contributes it with the Turso fields, and pins it beside this option. + // Here `knowledge/test` answers as on the default mount, which answers it + // as an undeclared action (judged by that control, never by message text). + const offTest = await off.settings.runAction('knowledge', 'test', {}); + expect(offTest).toEqual(await mounted.settings.runAction('knowledge', 'test', {})); + const undeclared = await off.settings.runAction('knowledge', 'never_declared', {}); + expect({ ok: offTest.ok, severity: offTest.severity }).toEqual({ ok: undeclared.ok, severity: undeclared.severity }); expect(knowledgeEntries(off.registered)).toHaveLength(1); }); @@ -241,14 +250,16 @@ describe('[#24769] the two buttons the knowledge service contributes, at the HTT expect(answer.body?.data?.message).toContain('text-embedding-3-small'); }); - it('POST /api/settings/knowledge/test is answered by the Turso form check (200, not 400)', async () => { - // The Turso fields alone: the check reads no `adapter` since #37104. - const answer = await post(http, 'knowledge', 'test', { - values: { turso_url: 'file:./knowledge.db' }, - }); - expect(answer.status).toBe(200); - expect(answer.body?.data?.ok).toBe(true); - expect(answer.body?.data?.message).toContain('file:./knowledge.db'); + it('POST /api/settings/knowledge/test answers as an undeclared action: the Turso check comes with its store', async () => { + // `@objectstack/knowledge-turso` declares the action and registers its + // handler where it contributes the Turso fields, and pins that case. + const body = { values: { turso_url: 'file:./knowledge.db' } }; + const answer = await post(http, 'knowledge', 'test', body); + const control = await post(http, 'knowledge', 'never_declared', body); + expect(answer.status).toBe(400); + expect(answer.body?.error?.code).toBe('SETTINGS_ACTION_FAILED'); + expect([control.status, control.body?.error?.code]).toEqual([answer.status, answer.body?.error?.code]); + expect(JSON.stringify(answer.body)).not.toContain('file:./knowledge.db'); }); }); diff --git a/packages/services/service-knowledge/src/knowledge-settings-contribution.ts b/packages/services/service-knowledge/src/knowledge-settings-contribution.ts index 304a72a736d..b7980d2c08e 100644 --- a/packages/services/service-knowledge/src/knowledge-settings-contribution.ts +++ b/packages/services/service-knowledge/src/knowledge-settings-contribution.ts @@ -24,7 +24,6 @@ import type { PluginContext } from '@objectstack/core'; import { knowledgeSettingsManifest, - knowledgeTestActionHandler, aiSettingsManifest, withAiEmbedderSection, aiEmbedderSettingsSpecifiers, @@ -134,7 +133,8 @@ export function contributeKnowledgeSettings( if (!settings || typeof settings.registerManifest !== 'function') return offered; settings.registerManifest(knowledgeSettingsManifest); - settings.registerAction('knowledge', 'test', knowledgeTestActionHandler); + // No `test` action here: "Test connection" checks the Turso fields, and + // `@objectstack/knowledge-turso` registers it with them, where it reads them. if (service) { settings.registerAction('knowledge', KNOWLEDGE_REBUILD_ACTION, knowledgeRebuildActionHandler(service)); settings.registerAction('knowledge', KNOWLEDGE_INDEX_STATUS_ACTION, knowledgeIndexStatusActionHandler(service)); diff --git a/packages/services/service-settings/src/index.ts b/packages/services/service-settings/src/index.ts index ec5b5424a7a..5fd28005f4e 100644 --- a/packages/services/service-settings/src/index.ts +++ b/packages/services/service-settings/src/index.ts @@ -184,7 +184,6 @@ export { // What `@objectstack/service-knowledge` contributes when it is mounted — // never registered by default (`builtinSettingsManifests`). knowledgeSettingsManifest, - knowledgeTestActionHandler, aiSettingsManifest, aiEmbedderSettingsSpecifiers, withAiEmbedderSection, diff --git a/packages/services/service-settings/src/knowledge-settings-retired-keys.pin.test.ts b/packages/services/service-settings/src/knowledge-settings-retired-keys.pin.test.ts index 295d984280e..0aef7f3c27f 100644 --- a/packages/services/service-settings/src/knowledge-settings-retired-keys.pin.test.ts +++ b/packages/services/service-settings/src/knowledge-settings-retired-keys.pin.test.ts @@ -18,7 +18,8 @@ * the stored retired rows (an encrypted one with a dangling secret handle * included) neither fail the read nor appear in it, and a stored * `enforce_rls = false` shows no toggle and is reported nowhere; - * - "Test connection" never answers from the stored `adapter`; + * - the page has no "Test connection" (it checks the Turso fields, and + * arrives with them), so its door answers as for any undeclared action; * - saving a declared key works beside them, and leaves them stored; * - a write naming a retired key is refused `400 UNKNOWN_KEY`, and refused * WHOLE: no other key in that body is saved. @@ -39,7 +40,7 @@ import { describe, it, expect } from 'vitest'; import { bootSettingsDoor } from './__tests__/settings-door.testkit.js'; import type { SettingsManifest } from '@objectstack/spec/system'; -import { knowledgeSettingsManifest, knowledgeTestActionHandler } from './manifests/knowledge.manifest.js'; +import { knowledgeSettingsManifest } from './manifests/knowledge.manifest.js'; const RETIRED_KEYS = [ 'adapter', @@ -56,7 +57,6 @@ const TURSO_KEYS = ['turso_url', 'turso_auth_token'] as const; async function bootWithRetiredRows() { const door = await bootSettingsDoor(knowledgeSettingsManifest); - door.svc.registerAction('knowledge', 'test', knowledgeTestActionHandler); // Every value as an earlier version stored it, `enforce_rls = false` among // them, beside two declared keys holding saved values of their own. door.seed({ id: 'ps_adapter', namespace: 'knowledge', key: 'adapter', value: 'ragflow' }); @@ -98,18 +98,18 @@ describe('#37104 — the Knowledge page with stored values for its retired keys' expect(JSON.stringify(page.body?.data ?? {})).not.toMatch(/enforce_rls|Enforce RLS/); }); - it('"Test connection" answers from the Turso fields it is sent, never from the stored adapter', async () => { + it('has no "Test connection": its door answers as for an action the page never declared', async () => { const { request } = await bootWithRetiredRows(); - const answer = await request( - 'POST /api/settings/:namespace/:actionId', - { namespace: 'knowledge', actionId: 'test' }, - { values: { turso_url: 'file:./sent.db' } }, - ); - // Before version 4 a stored `adapter = ragflow` answered "Unknown adapter". - expect(answer.status).toBe(200); - expect(answer.body?.data?.ok).toBe(true); - expect(String(answer.body?.data?.message)).toContain('file:./sent.db'); - expect(String(answer.body?.data?.message)).not.toMatch(/Unknown adapter|ragflow/i); + const post = (actionId: string) => + request('POST /api/settings/:namespace/:actionId', { namespace: 'knowledge', actionId }, { values: { turso_url: 'file:./sent.db' } }); + const answer = await post('test'); + const control = await post('never_declared'); + expect(answer.status).toBe(400); + expect(answer.body?.error?.code).toBe('SETTINGS_ACTION_FAILED'); + expect([control.status, control.body?.error?.code]).toEqual([answer.status, answer.body?.error?.code]); + expect(answer.body?.error?.details).toMatchObject({ ok: false, severity: 'error' }); + // Never the Turso check's answer, and never one read from the stored `adapter`. + expect(JSON.stringify(answer.body)).not.toMatch(/sent\.db|ragflow/i); }); it('saving a declared key works beside the retired rows, and leaves them stored', async () => { @@ -181,6 +181,9 @@ describe('version 5 — the Turso fields where knowledge-turso is not mounted, a it('once the store contributes the group again, the same stored turso_url is served, and saves', async () => { const { svc, request, save, stored } = await bootWithRetiredRows(); + svc.registerAction('knowledge', 'probe', async ({ values }) => ({ + ok: true, severity: 'info', message: `turso_url is ${String(values.turso_url)}`, + })); svc.registerManifest(withTursoSection(knowledgeSettingsManifest)); const page = await request('GET /api/settings/:namespace', { namespace: 'knowledge' }); expect(page.status).toBe(200); @@ -189,8 +192,9 @@ describe('version 5 — the Turso fields where knowledge-turso is not mounted, a const write = await save({ turso_url: 'file:./other.db' }); expect(write.status).toBe(200); expect(stored('turso_url')).toMatchObject({ value: 'file:./other.db' }); - // And the page's test action is still answered: re-registering a page keeps its handlers. - const answer = await request('POST /api/settings/:namespace/:actionId', { namespace: 'knowledge', actionId: 'test' }, {}); + // And an action registered before the re-registration is still answered: + // re-registering a page keeps its handlers. + const answer = await request('POST /api/settings/:namespace/:actionId', { namespace: 'knowledge', actionId: 'probe' }, {}); expect(answer.status).toBe(200); expect(String(answer.body?.data?.message)).toContain('file:./other.db'); }); diff --git a/packages/services/service-settings/src/manifests/index.ts b/packages/services/service-settings/src/manifests/index.ts index 34f83724f91..669105a5ff2 100644 --- a/packages/services/service-settings/src/manifests/index.ts +++ b/packages/services/service-settings/src/manifests/index.ts @@ -39,7 +39,7 @@ export { type AiModelRuleHost, type AiSettingReader, } from './ai-models.js'; -export { knowledgeSettingsManifest, knowledgeTestActionHandler } from './knowledge.manifest.js'; +export { knowledgeSettingsManifest } from './knowledge.manifest.js'; export { localizationSettingsManifest } from './localization.manifest.js'; export { companySettingsManifest } from './company.manifest.js'; diff --git a/packages/services/service-settings/src/manifests/knowledge.manifest.test.ts b/packages/services/service-settings/src/manifests/knowledge.manifest.test.ts index 17507e56f24..a733c01d956 100644 --- a/packages/services/service-settings/src/manifests/knowledge.manifest.test.ts +++ b/packages/services/service-settings/src/manifests/knowledge.manifest.test.ts @@ -2,10 +2,7 @@ import { describe, it, expect } from 'vitest'; import { SettingsManifestSchema } from '@objectstack/spec/system'; -import { - knowledgeSettingsManifest, - knowledgeTestActionHandler, -} from './knowledge.manifest.js'; +import { knowledgeSettingsManifest } from './knowledge.manifest.js'; describe('knowledgeSettingsManifest', () => { it('parses against SettingsManifestSchema', () => { @@ -47,21 +44,18 @@ describe('knowledgeSettingsManifest', () => { it('gates nothing on the retired adapter: no specifier declares a visibility predicate', () => { const specs = knowledgeSettingsManifest.specifiers as any[]; // Non-vacuity: the specifiers are there to inspect. - expect(specs.length).toBeGreaterThanOrEqual(3); + expect(specs.length).toBeGreaterThanOrEqual(2); for (const s of specs) expect(s.visible, s.key ?? s.id).toBeUndefined(); expect(JSON.stringify(knowledgeSettingsManifest)).not.toContain('data.adapter'); }); - it('exposes a test action wired to /api/settings/knowledge/test', () => { - const f = (knowledgeSettingsManifest.specifiers as any[]).find( - (s) => s.type === 'action_button' && s.id === 'test', - ); - expect(f).toBeDefined(); - expect(f.handler).toEqual({ - kind: 'http', - method: 'POST', - url: '/api/settings/knowledge/test', - }); + // "Test connection" checks the Turso fields alone, so it left this page with + // them: `@objectstack/knowledge-turso` declares it and registers its handler + // where it contributes the group, and pins both cases. + it('declares no action: the Turso check is contributed with the Turso fields', () => { + const specs = knowledgeSettingsManifest.specifiers as any[]; + expect(specs.filter((s) => s.type === 'action_button')).toEqual([]); + expect(JSON.stringify(knowledgeSettingsManifest)).not.toContain('/api/settings/knowledge/test'); }); }); @@ -80,103 +74,6 @@ describe('knowledgeSettingsManifest — no banner outlives the key it warned abo }); }); -describe('knowledgeTestActionHandler', () => { - it('accepts no URL (the plugin defaults to its own file)', async () => { - const r = await knowledgeTestActionHandler({ values: {} } as any); - expect(r.ok).toBe(true); - expect(r.severity).toBe('info'); - // The plugin opens a file of its own, never the platform's database (#37107). - expect(r.message).toMatch(/knowledge\.db/); - expect(r.message).not.toMatch(/reuse the tenant/); - }); - - it('accepts a local file URL', async () => { - const r = await knowledgeTestActionHandler({ - values: { turso_url: 'file:./knowledge.db' }, - } as any); - expect(r.ok).toBe(true); - }); - - it('rejects managed turso URL without auth token', async () => { - const r = await knowledgeTestActionHandler({ - values: { turso_url: 'libsql://x.turso.io' }, - } as any); - expect(r.ok).toBe(false); - expect(r.severity).toBe('error'); - }); - - it('accepts managed turso URL with auth token', async () => { - const r = await knowledgeTestActionHandler({ - values: { turso_url: 'libsql://x.turso.io', turso_auth_token: 't' }, - } as any); - expect(r.ok).toBe(true); - }); - - // The turso adapter's plugin package is built in this repo since #37107. The - // live-call hint names the package and how a deployment registers it, and no - // longer says it ships elsewhere. Pinned as a property, not as a literal, so - // the wording can be improved without the guard going stale. - it('turso live-call hint names the package and how it is registered, not an outside origin', async () => { - const r = await knowledgeTestActionHandler({ - values: { turso_url: 'file:./knowledge.db' }, - } as any); - expect(r.ok).toBe(true); - const message = String(r.message); - expect(message).toContain('@objectstack/knowledge-turso'); - expect(message).toMatch(/registered beside the knowledge service/); - expect(message).not.toMatch(/ObjectOS Cloud monorepo|does not ship/); - // the un-followable form this card retired: named, with no origin stated - expect(message).not.toMatch(/Mount @objectstack\/knowledge-turso to exercise live calls/); - }); - - // #24769 — "Test connection" is answered (the handler is in the plugin's - // default map), and what it answers is a form check: no package in this repo - // registers `knowledge/test`, so nothing replaces it with a live probe. Every - // green answer must say no connection was attempted, and none may promise - // that mounting a package makes this button live — no package does. - it('every green answer says no connection was attempted', async () => { - const forms: Array<[string, Record]> = [ - ['no URL', {}], - ['local file', { turso_url: 'file:./knowledge.db' }], - ['managed', { turso_url: 'libsql://x.turso.io', turso_auth_token: 't' }], - ]; - for (const [label, values] of forms) { - const r = await knowledgeTestActionHandler({ values } as any); - expect(r.ok, label).toBe(true); - const message = String(r.message); - expect(message, label).toMatch(/no connection was attempted/); - expect(message, label).not.toMatch(/to exercise live calls/); - } - }); - - // `adapter` is retired (#37104): a value saved before, or a stale form still - // sending one, is not read. The answer is the one the same Turso fields get - // with no adapter at all — never "Unknown adapter", never the in-memory - // warning the retired `memory` option answered. - it('reads no adapter: a stale one in the values or the payload changes nothing', async () => { - const fields = { turso_url: 'libsql://x.turso.io', turso_auth_token: 't' }; - const baseline = await knowledgeTestActionHandler({ values: fields } as any); - expect(baseline.ok).toBe(true); - for (const adapter of ['memory', 'turso', 'ragflow', 'pgvector']) { - const fromValues = await knowledgeTestActionHandler({ values: { ...fields, adapter } } as any); - const fromPayload = await knowledgeTestActionHandler({ values: fields, payload: { values: { adapter } } } as any); - expect(fromValues, adapter).toEqual(baseline); - expect(fromPayload, adapter).toEqual(baseline); - } - // Non-vacuity: the fields it does read change the answer. - expect((await knowledgeTestActionHandler({ values: { turso_url: 'libsql://x.turso.io' } } as any)).ok).toBe(false); - }); - - it('prefers payload.values over persisted values', async () => { - const r = await knowledgeTestActionHandler({ - values: { turso_url: 'libsql://x.turso.io' }, - payload: { values: { turso_url: 'file:foo.db' } }, - } as any); - expect(r.ok).toBe(true); - expect(r.message).toMatch(/file:foo\.db/); - }); -}); - describe('aiTestEmbedderActionHandler', () => { it('returns warning when embedder is disabled', async () => { const handler = await import('./ai.manifest.js').then((m) => m.aiTestEmbedderActionHandler); diff --git a/packages/services/service-settings/src/manifests/knowledge.manifest.ts b/packages/services/service-settings/src/manifests/knowledge.manifest.ts index c0511560059..3e33b0a381f 100644 --- a/packages/services/service-settings/src/manifests/knowledge.manifest.ts +++ b/packages/services/service-settings/src/manifests/knowledge.manifest.ts @@ -1,7 +1,6 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. import type { SettingsManifest } from '@objectstack/spec/system'; -import type { SettingsActionHandler } from '../settings-service.types.js'; /** * Knowledge — the settings the knowledge service and its store read. The @@ -14,7 +13,10 @@ import type { SettingsActionHandler } from '../settings-service.types.js'; * not declared here: its one reader, `@objectstack/knowledge-turso`, adds it * to this page when it reads them (`contributeKnowledgeTursoSettings`), so a * deployment whose store is `@objectstack/knowledge-pgvector` shows no Turso - * fields. + * fields. The "Test connection" action that checks those two fields, and its + * handler, come with them: a page without them has no such action, and + * `POST /api/settings/knowledge/test` there answers as every undeclared action + * does (no handler registered). * * - `chunk_target` — the knowledge service's splitter (#37098), read through * `KnowledgeServicePlugin` each time it splits: the longest passage, in @@ -71,11 +73,6 @@ const manifest = { { type: 'number', key: 'chunk_target', label: 'Target chunk size (chars)', required: false, default: 800, min: 64, max: 8192, description: "Longest passage, in characters, when the knowledge service splits a document. A size set on a knowledge source itself wins; the embedding model's input limit can lower it." }, - - // ── Probe ───────────────────────────────────────────────────── - { type: 'action_button', id: 'test', label: 'Test connection', - required: false, icon: 'Plug', - handler: { kind: 'http', method: 'POST', url: '/api/settings/knowledge/test' } }, ], }; @@ -86,72 +83,3 @@ const manifest = { * Knowledge page (#33933). */ export const knowledgeSettingsManifest = manifest as unknown as SettingsManifest; - -/** - * The sentence every answer carries, so a green "Test connection" is never - * read as a connection that succeeded. - */ -const FORM_CHECK_ONLY = 'This checks the form only — no connection was attempted.'; - -/** - * Handler for `knowledge/test` ("Test connection"), registered by - * `@objectstack/service-knowledge` with the manifest it contributes (#33933). - * - * It checks the libSQL fields for completeness only — a Turso auth token - * beside a managed `libsql://` URL — and opens NO connection. It reads - * `turso_url` and `turso_auth_token` and nothing else: the page names no - * adapter (#37104), so a payload or a stored row still carrying `adapter` - * (a value saved before this version) is not read, and neither is any other - * key the page no longer declares. The two fields are on the page only where - * `@objectstack/knowledge-turso` contributes them; elsewhere `values` carries - * neither, and the check answers from what the payload sends. - * - * Nothing in this repository replaces it with a live probe: - * `@objectstack/service-knowledge` registers exactly this handler, and no - * adapter package registers `knowledge/test` (a plugin that did would call - * `SettingsService.registerAction`, which replaces this handler). So every - * answer says no connection was attempted, and none names a package whose - * mounting would make this check live — none does. - */ -export const knowledgeTestActionHandler: SettingsActionHandler = async ({ values, payload }) => { - const overrides = extractOverrides(payload); - const merged: Record = { ...values, ...overrides }; - - const url = merged.turso_url; - if (!url) { - return { - ok: true, - severity: 'info', - message: - 'No Turso URL configured — where the knowledge store is @objectstack/knowledge-turso (a platform ' + - 'database other than PostgreSQL), it uses its own file, knowledge.db under .objectstack/data/, never ' + - 'the platform database. ' + - FORM_CHECK_ONLY, - }; - } - const u = String(url); - if (u.startsWith('libsql://') && !merged.turso_auth_token) { - return { - ok: false, - severity: 'error', - message: 'Managed Turso URL requires an auth token.', - }; - } - return { - ok: true, - severity: 'info', - message: - `Turso URL configured (${u}). ${FORM_CHECK_ONLY} It is read at startup by the ` + - '@objectstack/knowledge-turso plugin registered beside the knowledge service, which is the store a ' + - 'platform database other than PostgreSQL gets.', - }; -}; - -function extractOverrides(payload: unknown): Record { - if (!payload || typeof payload !== 'object') return {}; - const p = payload as Record; - if (p.values && typeof p.values === 'object' && p.values !== null) { - return p.values as Record; - } - return p; -} diff --git a/packages/services/service-settings/src/settings-default-action-handlers.pin.test.ts b/packages/services/service-settings/src/settings-default-action-handlers.pin.test.ts index ffdca15b142..99fcdac140a 100644 --- a/packages/services/service-settings/src/settings-default-action-handlers.pin.test.ts +++ b/packages/services/service-settings/src/settings-default-action-handlers.pin.test.ts @@ -112,9 +112,10 @@ describe('[#24769] the default composition answers every declared settings actio expect(declared).toEqual( expect.arrayContaining(['ai/test', 'ai/reset', 'mail/test', 'sms/test', 'storage/test']), ); - // #33933: `ai/test_embedder` and `knowledge/test` arrive with the knowledge - // service, which registers their handlers; its suite drives both at the - // HTTP door (`knowledge-settings-contribution.test.ts`). + // #33933: `ai/test_embedder` arrives with the knowledge service, which + // registers its handler (`knowledge-settings-contribution.test.ts` drives + // it at the HTTP door); `knowledge/test` arrives with the Turso fields it + // checks, from `@objectstack/knowledge-turso`, which pins both its cases. expect(declared).not.toContain('ai/test_embedder'); expect(declared).not.toContain('knowledge/test'); }); diff --git a/packages/services/service-settings/src/translations/ar.ts b/packages/services/service-settings/src/translations/ar.ts index 3a1a6417993..17c49cf22aa 100644 --- a/packages/services/service-settings/src/translations/ar.ts +++ b/packages/services/service-settings/src/translations/ar.ts @@ -690,9 +690,6 @@ export const ar: PlatformTranslationData = { help: 'أقصى طول للمقطع بالأحرف عند تقسيم خدمة المعرفة لمستند. تكون الأولوية للحجم المحدد في مصدر المعرفة نفسه، وقد يخفضه حد الإدخال الخاص بنموذج التضمين.', }, }, - actions: { - test: { label: 'اختبار الاتصال' }, - }, }, lifecycle: { title: 'دورة حياة البيانات', diff --git a/packages/services/service-settings/src/translations/de.ts b/packages/services/service-settings/src/translations/de.ts index 554a4bf6679..3905f42b820 100644 --- a/packages/services/service-settings/src/translations/de.ts +++ b/packages/services/service-settings/src/translations/de.ts @@ -726,9 +726,6 @@ export const de: PlatformTranslationData = { help: 'Längste Passage in Zeichen, wenn der Wissensdienst ein Dokument aufteilt. Eine an der Wissensquelle selbst gesetzte Größe hat Vorrang; das Eingabelimit des Embedding-Modells kann den Wert senken.', }, }, - actions: { - test: { label: 'Verbindung testen' }, - }, }, lifecycle: { title: 'Datenlebenszyklus', diff --git a/packages/services/service-settings/src/translations/en.ts b/packages/services/service-settings/src/translations/en.ts index 2849e26888e..8ca871f49a5 100644 --- a/packages/services/service-settings/src/translations/en.ts +++ b/packages/services/service-settings/src/translations/en.ts @@ -425,9 +425,6 @@ export const en: PlatformTranslationData = { chunk_target: { label: 'Target chunk size (chars)', help: 'Longest passage, in characters, when the knowledge service splits a document. A size set on a knowledge source itself wins; the embedding model\'s input limit can lower it.' }, }, - actions: { - test: { label: 'Test connection' }, - }, }, }, }; diff --git a/packages/services/service-settings/src/translations/es-ES.ts b/packages/services/service-settings/src/translations/es-ES.ts index c68a4174949..a98cdbc2e3c 100644 --- a/packages/services/service-settings/src/translations/es-ES.ts +++ b/packages/services/service-settings/src/translations/es-ES.ts @@ -591,9 +591,6 @@ export const esES: PlatformTranslationData = { chunk_target: { label: 'Tamaño objetivo de fragmento (caracteres)', help: 'Longitud máxima de un pasaje, en caracteres, cuando el servicio de conocimiento divide un documento. Un tamaño fijado en la propia fuente tiene prioridad; el límite de entrada del modelo de embeddings puede reducirlo.' }, }, - actions: { - test: { label: 'Probar conexión' }, - }, }, lifecycle: { diff --git a/packages/services/service-settings/src/translations/fr.ts b/packages/services/service-settings/src/translations/fr.ts index 39b4feb6efa..dbf8e408224 100644 --- a/packages/services/service-settings/src/translations/fr.ts +++ b/packages/services/service-settings/src/translations/fr.ts @@ -735,9 +735,6 @@ export const fr: PlatformTranslationData = { help: 'Longueur maximale d’un passage, en caractères, lorsque le service de connaissances découpe un document. Une taille fixée sur la source elle-même l’emporte ; la limite d’entrée du modèle d’embedding peut l’abaisser.', }, }, - actions: { - test: { label: 'Tester la connexion' }, - }, }, lifecycle: { title: 'Cycle de vie des données', diff --git a/packages/services/service-settings/src/translations/ja-JP.ts b/packages/services/service-settings/src/translations/ja-JP.ts index 3e2b9deff31..e8012e885b7 100644 --- a/packages/services/service-settings/src/translations/ja-JP.ts +++ b/packages/services/service-settings/src/translations/ja-JP.ts @@ -590,9 +590,6 @@ export const jaJP: PlatformTranslationData = { chunk_target: { label: '目標チャンクサイズ(文字数)', help: 'ナレッジサービスがドキュメントを分割するときの、パッセージ 1 件あたりの最大文字数。ナレッジソース自身に設定したサイズが優先され、埋め込みモデルの入力上限によって小さくなることがあります。' }, }, - actions: { - test: { label: '接続テスト' }, - }, }, lifecycle: { diff --git a/packages/services/service-settings/src/translations/ko.ts b/packages/services/service-settings/src/translations/ko.ts index 6570d1d66fa..d365b2c6e09 100644 --- a/packages/services/service-settings/src/translations/ko.ts +++ b/packages/services/service-settings/src/translations/ko.ts @@ -563,9 +563,6 @@ export const ko: PlatformTranslationData = { keys: { chunk_target: { label: '목표 청크 크기(자)', help: '지식 서비스가 문서를 나눌 때 구절 하나의 최대 문자 수입니다. 지식 소스 자체에 설정한 크기가 우선하며, 임베딩 모델의 입력 한도에 따라 더 작아질 수 있습니다.' }, }, - actions: { - test: { label: '연결 테스트' }, - }, }, lifecycle: { title: '데이터 수명 주기', diff --git a/packages/services/service-settings/src/translations/pt-BR.ts b/packages/services/service-settings/src/translations/pt-BR.ts index 6631a458f0f..d95ce7d7e63 100644 --- a/packages/services/service-settings/src/translations/pt-BR.ts +++ b/packages/services/service-settings/src/translations/pt-BR.ts @@ -722,9 +722,6 @@ export const ptBR: PlatformTranslationData = { help: 'Tamanho máximo de um trecho, em caracteres, quando o serviço de conhecimento divide um documento. Um tamanho definido na própria fonte tem prioridade; o limite de entrada do modelo de embeddings pode reduzi-lo.', }, }, - actions: { - test: { label: 'Testar conexão' }, - }, }, lifecycle: { title: 'Ciclo de vida dos dados', diff --git a/packages/services/service-settings/src/translations/ru.ts b/packages/services/service-settings/src/translations/ru.ts index 03154ad52f9..2162eea0c76 100644 --- a/packages/services/service-settings/src/translations/ru.ts +++ b/packages/services/service-settings/src/translations/ru.ts @@ -735,9 +735,6 @@ export const ru: PlatformTranslationData = { help: 'Наибольшая длина фрагмента в символах, когда служба знаний разбивает документ. Размер, заданный в самом источнике знаний, имеет приоритет; лимит ввода модели эмбеддингов может его уменьшить.', }, }, - actions: { - test: { label: 'Проверить подключение' }, - }, }, lifecycle: { title: 'Жизненный цикл данных', diff --git a/packages/services/service-settings/src/translations/zh-CN.ts b/packages/services/service-settings/src/translations/zh-CN.ts index 5ca9b1463cc..f2bbcb2e616 100644 --- a/packages/services/service-settings/src/translations/zh-CN.ts +++ b/packages/services/service-settings/src/translations/zh-CN.ts @@ -620,9 +620,6 @@ export const zhCN: PlatformTranslationData = { keys: { chunk_target: { label: '目标 chunk 大小(字符)', help: '知识服务切分文档时每个片段的最大字符数。知识源自身设置的大小优先;嵌入模型的输入上限可能将其调低。' }, }, - actions: { - test: { label: '测试连接' }, - }, }, lifecycle: { diff --git a/packages/services/service-settings/src/translations/zh-Hant.ts b/packages/services/service-settings/src/translations/zh-Hant.ts index 2ab77bb3000..fc2a4a352eb 100644 --- a/packages/services/service-settings/src/translations/zh-Hant.ts +++ b/packages/services/service-settings/src/translations/zh-Hant.ts @@ -505,9 +505,6 @@ export const zhHant: PlatformTranslationData = { keys: { chunk_target: { label: '目標區塊大小(字元)', help: '知識服務切分文件時每個片段的最大字元數。知識來源自身設定的大小優先;嵌入模型的輸入上限可能將其調低。' }, }, - actions: { - test: { label: '測試連線' }, - }, }, lifecycle: { title: '資料生命週期',