Repository navigation
feat(tabularis): add declarative AI assistant kind preset #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,292 @@ | ||
| { | ||
| "key": "ai-assistant", | ||
| "label": "AI assistants", | ||
| "labelTranslations": { | ||
| "it": "Assistenti AI" | ||
| }, | ||
| "description": "Declarative AI providers for Tabularis. No plugin code is executed.", | ||
| "publicPageEnabled": true, | ||
| "publicPageCopy": { | ||
| "hero": "Choose your AI assistant", | ||
| "intro": "Use the providers built into Tabularis, or install additional providers such as Gemini. Credentials and settings stay in the application; external packages can be updated independently." | ||
| }, | ||
| "extensionsSchema": { | ||
| "ai_assistant": { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": true, | ||
| "properties": { | ||
| "api_version": { | ||
| "type": "integer", | ||
| "const": 1 | ||
| }, | ||
| "authentication": { | ||
| "type": "string", | ||
| "enum": ["api-key", "none"] | ||
| }, | ||
| "api_key_env": { | ||
| "type": "string", | ||
| "pattern": "^[A-Z_][A-Z0-9_]*$", | ||
| "maxLength": 100 | ||
| }, | ||
| "default_models": { | ||
| "type": "array", | ||
| "maxItems": 1000, | ||
| "items": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| } | ||
| }, | ||
| "optional_api_key": { | ||
| "type": "boolean" | ||
| }, | ||
| "api_key_header": { | ||
| "type": "string", | ||
| "maxLength": 100 | ||
| }, | ||
| "api_key_prefix": { | ||
| "type": "string", | ||
| "maxLength": 100 | ||
| }, | ||
| "direct": { | ||
| "type": "boolean" | ||
| }, | ||
| "generate": { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": ["requests", "response"], | ||
| "properties": { | ||
| "requests": { | ||
| "type": "array", | ||
| "minItems": 1, | ||
| "maxItems": 4, | ||
| "items": { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": ["url"], | ||
| "properties": { | ||
| "url": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| }, | ||
| "append_path": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| }, | ||
| "headers": { | ||
| "type": "object", | ||
| "maxProperties": 16, | ||
| "additionalProperties": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| } | ||
| }, | ||
| "body": { | ||
| "type": "object" | ||
| }, | ||
| "authenticated": { | ||
| "type": "boolean" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "response": { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": ["path"], | ||
| "properties": { | ||
| "path": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| }, | ||
| "select": { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": ["path"], | ||
| "properties": { | ||
| "path": { | ||
| "type": "string", | ||
| "maxLength": 256 | ||
| }, | ||
| "equals": {}, | ||
| "contains": {}, | ||
| "starts_with": { | ||
| "type": "string", | ||
| "maxLength": 256 | ||
| }, | ||
| "missing_matches": { | ||
| "type": "boolean" | ||
| }, | ||
| "prefixes": { | ||
| "type": "array", | ||
| "maxItems": 16, | ||
| "items": { | ||
| "type": "string", | ||
| "maxLength": 100 | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "value_path": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "models": { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": ["sources"], | ||
| "properties": { | ||
| "sources": { | ||
| "type": "array", | ||
| "maxItems": 8, | ||
| "items": { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": ["request", "items_path", "id_path"], | ||
| "properties": { | ||
| "request": { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": ["url"], | ||
| "properties": { | ||
| "url": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| }, | ||
| "append_path": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| }, | ||
| "headers": { | ||
| "type": "object", | ||
| "maxProperties": 16, | ||
| "additionalProperties": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| } | ||
| }, | ||
| "body": { | ||
| "type": "object" | ||
| }, | ||
| "authenticated": { | ||
| "type": "boolean" | ||
| } | ||
| } | ||
| }, | ||
| "items_path": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| }, | ||
| "id_path": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| }, | ||
| "filters": { | ||
| "type": "array", | ||
| "maxItems": 16, | ||
| "items": { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": ["path"], | ||
| "properties": { | ||
| "path": { | ||
| "type": "string", | ||
| "maxLength": 256 | ||
| }, | ||
| "equals": {}, | ||
| "contains": {}, | ||
| "starts_with": { | ||
| "type": "string", | ||
| "maxLength": 256 | ||
| }, | ||
| "missing_matches": { | ||
| "type": "boolean" | ||
| }, | ||
| "prefixes": { | ||
| "type": "array", | ||
| "maxItems": 16, | ||
| "items": { | ||
| "type": "string", | ||
| "maxLength": 100 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "cache_seconds": { | ||
| "type": "integer", | ||
| "minimum": 0, | ||
| "maximum": 86400 | ||
| }, | ||
| "fallback": { | ||
| "type": "boolean" | ||
| } | ||
| } | ||
| }, | ||
| "auto_select_priority": { | ||
| "type": "integer", | ||
| "minimum": 0, | ||
| "maximum": 1000 | ||
| }, | ||
| "require_explicit_model": { | ||
| "type": "boolean", | ||
| "default": false, | ||
| "description": "Require a saved or explicitly selected model instead of choosing the first discovered model." | ||
| } | ||
| }, | ||
| "allOf": [ | ||
| { | ||
| "required": ["api_version", "authentication", "generate", "models"] | ||
| } | ||
| ] | ||
| }, | ||
| "settings": { | ||
| "type": "array", | ||
| "maxItems": 32, | ||
| "items": { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": ["key", "label", "type"], | ||
| "properties": { | ||
| "key": { | ||
| "type": "string", | ||
| "pattern": "^[a-z][a-z0-9_]*$" | ||
| }, | ||
| "label": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| }, | ||
| "description": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| }, | ||
| "type": { | ||
| "type": "string", | ||
| "enum": ["string", "number", "boolean", "select"] | ||
| }, | ||
| "default": {}, | ||
| "required": { | ||
| "type": "boolean" | ||
| }, | ||
| "options": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string", | ||
| "maxLength": 2048 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "customExample": { | ||
| "json": "{\n \"id\": \"gemini\",\n \"name\": \"Google Gemini\",\n \"version\": \"1.0.1\",\n \"kind\": \"ai-assistant\",\n \"description\": \"Google Gemini assistant using the native generateContent API.\",\n \"ai_assistant\": {\n \"api_version\": 1,\n \"authentication\": \"api-key\",\n \"api_key_env\": \"GEMINI_API_KEY\",\n \"api_key_header\": \"x-goog-api-key\",\n \"api_key_prefix\": \"\",\n \"default_models\": [\n \"models/gemini-flash-latest\"\n ],\n \"generate\": {\n \"requests\": [\n {\n \"url\": \"https://generativelanguage.googleapis.com/v1beta/{{model}}:generateContent\",\n \"body\": {\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"{{system_prompt}}\"\n }\n ]\n },\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"{{prompt}}\"\n }\n ]\n }\n ]\n }\n }\n ],\n \"response\": {\n \"path\": \"/candidates/0/content/parts\",\n \"select\": {\n \"path\": \"/thought\",\n \"equals\": false,\n \"missing_matches\": true\n },\n \"value_path\": \"/text\"\n }\n },\n \"models\": {\n \"sources\": [\n {\n \"request\": {\n \"url\": \"https://generativelanguage.googleapis.com/v1beta/models\"\n },\n \"items_path\": \"/models\",\n \"id_path\": \"/name\",\n \"filters\": [\n {\n \"path\": \"/supportedGenerationMethods\",\n \"contains\": \"generateContent\"\n }\n ]\n }\n ],\n \"cache_seconds\": 86400\n }\n },\n \"settings\": [],\n \"license\": \"Apache-2.0\",\n \"icon\": \"https://raw.githubusercontent.com/TabularisDB/tabularis-gemini-plugin/main/icon.svg\"\n}" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { describe, expect, it } from 'bun:test' | ||
| import { buildSchema, ManifestSchema, validateManifest, type ExtensionsDelta } from '../src/index' | ||
| import preset from '../../../deploy/tabularis/ai-assistant-kind.json' | ||
|
|
||
| const schema = buildSchema({ | ||
| coreSchema: ManifestSchema as never, | ||
| kindOverrides: { 'ai-assistant': preset.extensionsSchema as ExtensionsDelta }, | ||
| kind: 'ai-assistant', | ||
| }) | ||
|
|
||
| describe('Tabularis AI assistant kind preset', () => { | ||
| it('accepts the native Gemini example with a stable id and display name', () => { | ||
| const manifest = JSON.parse(preset.customExample.json) as Record<string, unknown> | ||
| expect(validateManifest(manifest, schema).ok).toBe(true) | ||
| expect(manifest.id).toBe('gemini') | ||
| expect((manifest.ai_assistant as Record<string, unknown>).api_key_header).toBe('x-goog-api-key') | ||
| }) | ||
|
|
||
| it('requires the provider contract and excludes executable extension fields', () => { | ||
| const manifest = JSON.parse(preset.customExample.json) as Record<string, unknown> | ||
| for (const key of ['executable', 'interpreter', 'ui_extensions']) { | ||
| expect(validateManifest({ ...manifest, [key]: 'forbidden' }, schema).ok).toBe(false) | ||
| } | ||
| const missing = { ...manifest } | ||
| delete missing.ai_assistant | ||
| expect(validateManifest(missing, schema).ok).toBe(false) | ||
| const contract = manifest.ai_assistant as Record<string, unknown> | ||
| const incomplete = { ...contract } | ||
| delete incomplete.generate | ||
| expect(validateManifest({ ...manifest, ai_assistant: incomplete }, schema).ok).toBe(false) | ||
| }) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.