discourse-ai/lib/personas/tools
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
..
create_artifact.rb FEATURE: persistent key-value storage for AI Artifacts (#1417) 2025-06-11 06:59:46 +10:00
create_image.rb FEATURE: forum researcher persona for deep research (#1313) 2025-05-14 12:36:16 +10:00
custom.rb FEATURE: allow tools to amend personas (#1250) 2025-04-09 15:48:25 +10:00
dall_e.rb FEATURE: add OpenAI image generation and editing capabilities (#1293) 2025-04-29 17:38:54 +10:00
db_schema.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
discourse_meta_search.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
edit_image.rb FEATURE: forum researcher persona for deep research (#1313) 2025-05-14 12:36:16 +10:00
github_file_content.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
github_pull_request_diff.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
github_search_code.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
github_search_files.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
google.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
image.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
javascript_evaluator.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
list_categories.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
list_tags.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
option.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
random_picker.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
read.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
read_artifact.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
researcher.rb FEATURE: allow access to assigns from forum researcher (#1412) 2025-06-06 16:59:00 +10:00
search.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
search_settings.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
setting_context.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
summarize.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
time.rb REFACTOR: Move personas into its own module. (#1233) 2025-03-31 14:42:33 -03:00
tool.rb FEATURE: forum researcher persona for deep research (#1313) 2025-05-14 12:36:16 +10:00
update_artifact.rb FEATURE: forum researcher persona for deep research (#1313) 2025-05-14 12:36:16 +10:00
web_browser.rb FIX: handle unexpected errors when browsing web (#1314) 2025-05-06 18:12:26 +10:00