discourse-ai/spec/models
Sam fdf0ff8a25
FEATURE: persistent key-value storage for AI Artifacts (#1417)
Introduces a persistent, user-scoped key-value storage system for
AI Artifacts, enabling them to be stateful and interactive. This
transforms artifacts from static content into mini-applications that can
save user input, preferences, and other data.

The core components of this feature are:

1.  **Model and API**:
    - A new `AiArtifactKeyValue` model and corresponding database table to
      store data associated with a user and an artifact.
    - A new `ArtifactKeyValuesController` provides a RESTful API for
      CRUD operations (`index`, `set`, `destroy`) on the key-value data.
    - Permissions are enforced: users can only modify their own data but
      can view public data from other users.

2.  **Secure JavaScript Bridge**:
    - A `postMessage` communication bridge is established between the
      sandboxed artifact `iframe` and the parent Discourse window.
    - A JavaScript API is exposed to the artifact as `window.discourseArtifact`
      with async methods: `get(key)`, `set(key, value, options)`,
      `delete(key)`, and `index(filter)`.
    - The parent window handles these requests, makes authenticated calls to the
      new controller, and returns the results to the iframe. This ensures
      security by keeping untrusted JS isolated.

3.  **AI Tool Integration**:
    - The `create_artifact` tool is updated with a `requires_storage`
      boolean parameter.
    - If an artifact requires storage, its metadata is flagged, and the
      system prompt for the code-generating AI is augmented with detailed
      documentation for the new storage API.

4.  **Configuration**:
    - Adds hidden site settings `ai_artifact_kv_value_max_length` and
      `ai_artifact_max_keys_per_user_per_artifact` for throttling.

This also includes a minor fix to use `jsonb_set` when updating
artifact metadata, ensuring other metadata fields are preserved.
2025-06-11 06:59:46 +10:00
..
ai_artifact_key_value_spec.rb FEATURE: persistent key-value storage for AI Artifacts (#1417) 2025-06-11 06:59:46 +10:00
ai_persona_multisite_spec.rb FIX: system persona state leaking between sites (#1304) 2025-05-01 13:24:53 +10:00
ai_persona_spec.rb FEATURE: Examples support for personas. (#1334) 2025-05-13 10:06:16 -03:00
ai_tool_spec.rb DEV: improve tool infra, improve forum researcher prompts, improve logging (#1391) 2025-06-03 15:17:55 +10:00
inferred_concept_spec.rb FEATURE: add inferred concepts system (#1330) 2025-06-02 14:29:20 -03:00
llm_model_spec.rb DEV: Prefer ENV key for seeded models (#893) 2024-11-05 06:19:13 -08:00
llm_quota_spec.rb FEATURE: llm quotas (#1047) 2025-01-14 15:54:09 +11:00
llm_quota_usage_spec.rb FEATURE: llm quotas (#1047) 2025-01-14 15:54:09 +11:00
model_accuracy_spec.rb DEV: Update linting (#423) 2024-01-13 00:28:06 +01:00
rag_document_fragment_spec.rb DEV: Robust check for embeddings enabled (#1116) 2025-02-06 12:18:55 -03:00
reviewable_ai_chat_message_spec.rb DEV: Fix new Rubocop offenses 2024-03-06 15:23:29 +01:00
reviewable_ai_post_spec.rb DEV: Fix new Rubocop offenses 2024-03-06 15:23:29 +01:00
shared_ai_conversation_spec.rb FEATURE: persistent key-value storage for AI Artifacts (#1417) 2025-06-11 06:59:46 +10:00
user_option_spec.rb FEATURE: Add ability to disable search discoveries (#1177) 2025-03-10 14:17:58 -07:00