Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
6bd6027
Added base interfaces for indexed data sources outside DataSources
SommerEngineering Oct 1, 2026
5ddb331
Improved the embedding service to look data sources up in one place
SommerEngineering Oct 1, 2026
0f65079
Improved index checks to read the data source row instead of the full…
SommerEngineering Oct 1, 2026
e20b571
Improved the embedding service to prepare each indexing run in one sh…
SommerEngineering Oct 1, 2026
db829c6
Improved indexing to embed any kind of document through one shared core
SommerEngineering Oct 1, 2026
7bea64e
Improved indexing to track the progress and failures of documents in …
SommerEngineering Oct 1, 2026
9956df7
Improved follow-up indexing runs to keep the reason they were request…
SommerEngineering Oct 1, 2026
16d581a
Improved indexing to cut text into chunks in one place shared by ever…
SommerEngineering Oct 1, 2026
c47a4f8
Improved indexing to let one indexer per kind of data source read its…
SommerEngineering Oct 1, 2026
78fb003
Improved indexing to let each indexer track changes to its own data s…
SommerEngineering Oct 1, 2026
47dc02e
Improved embedding status to count documents instead of files
SommerEngineering Oct 1, 2026
a80a2c7
Fixed IDE warnings in the indexing code and its tests
SommerEngineering Oct 1, 2026
bce731f
Added guidance for agents on how to add indexed data sources
SommerEngineering Oct 1, 2026
6cb19c2
Added point id filters to vector searches
SommerEngineering Oct 1, 2026
55a8001
Added the index tables for mailboxes
SommerEngineering Oct 1, 2026
60568d3
Added index store methods to sync mails, folders and their locations
SommerEngineering Oct 1, 2026
e398fed
Added index store methods for the sync and sign-in state of mailboxes
SommerEngineering Oct 1, 2026
a8ae117
Added index store queries to search, count and summarize mails
SommerEngineering Oct 1, 2026
ba4228e
Added mailbox settings with a confidence level enforced at runtime
SommerEngineering Oct 1, 2026
c85f4c5
Added an IMAP connector for mailboxes based on MailKit
SommerEngineering Oct 1, 2026
957c5d7
Added IMAP templates for well-known mail providers
SommerEngineering Oct 1, 2026
04bb543
Added a folder picker for mailboxes
SommerEngineering Oct 1, 2026
50f8d71
Added a dialog to add and edit mailboxes
SommerEngineering Oct 1, 2026
159ef1d
Added mailboxes to the data source table and menu
SommerEngineering Oct 1, 2026
c897c50
Changed the mailbox preview to the prototype stage
SommerEngineering Oct 1, 2026
a44eaba
Fixed stale validation errors in the data source dialogs
SommerEngineering Oct 1, 2026
24ea5ce
Added the text extraction for mails
SommerEngineering Oct 2, 2026
64fd91a
Added reading mails from IMAP folders
SommerEngineering Oct 2, 2026
3c4d7ae
Added the sync plan for mailbox folders
SommerEngineering Oct 2, 2026
480fd28
Added syncing mailboxes into the local index
SommerEngineering Oct 2, 2026
1ad9863
Added sync slices and a guard against mass removals for mailboxes
SommerEngineering Oct 2, 2026
33e42e4
Added indexing the text of attached documents in mailboxes
SommerEngineering Oct 2, 2026
86ce203
Added syncing mailboxes every 16 minutes
SommerEngineering Oct 2, 2026
7975c6b
Improved the wording of the embeddings page for mailboxes
SommerEngineering Oct 2, 2026
5cc6ccc
Added the sign-in and removal decisions for mailboxes to the embeddin…
SommerEngineering Oct 2, 2026
c3caa37
Added deleting the indexes of mailboxes which are no longer configured
SommerEngineering Oct 2, 2026
efb028c
Updated the translations for mailboxes
SommerEngineering Oct 2, 2026
851fd9b
Improved the wording of the embedding choice in data source dialogs
SommerEngineering Oct 2, 2026
59783a4
Fixed a stale token limit error when opening the expert settings of d…
SommerEngineering Oct 2, 2026
abcca84
Added an explanation of the provider choice to the mailbox dialog
SommerEngineering Oct 2, 2026
12f8860
Improved fetching mail attachments in pieces and raised their size li…
SommerEngineering Oct 2, 2026
05f83d9
Improved the information page to count indexed files and mails separa…
SommerEngineering Oct 2, 2026
1c4bb03
Removed a redundant argument from the mail attachment tests
SommerEngineering Oct 2, 2026
3eb0ccf
Added an outbound data restriction that chats keep after reading mail…
SommerEngineering Oct 2, 2026
4670f7f
Added a check that keeps tools from sending mail content beyond what …
SommerEngineering Oct 2, 2026
fffba25
Added tracking of the web addresses users and tools gave to a chat
SommerEngineering Oct 2, 2026
4db912d
Added tests for web addresses of internal services without TLS
SommerEngineering Oct 2, 2026
b276fd7
Improved Read Web Page to keep to the outbound data restriction of a …
SommerEngineering Oct 2, 2026
6d04eaa
Updated I18N
SommerEngineering Oct 2, 2026
7bf1f58
Improved Read Web Page to enforce the free address choice instead of …
SommerEngineering Oct 2, 2026
e18ea98
Updated I18N
SommerEngineering Oct 2, 2026
b47bcfd
Removed the instructions to the AI from a refusal text of Read Web Page
SommerEngineering Oct 2, 2026
51ed737
Fixed the token count to leave out tools a mailbox keeps from a chat
SommerEngineering Oct 2, 2026
58ff8d4
Extracted the search of a local index so mailboxes can use it
SommerEngineering Oct 2, 2026
21d568c
Updated I18N
SommerEngineering Oct 2, 2026
b851ec7
Added a service which searches, counts and reads the mails of a mailbox
SommerEngineering Oct 2, 2026
8e1047b
Added the conditions by which the mail tools narrow down mails
SommerEngineering Oct 2, 2026
e64954e
Added a way for tools to stay hidden while their preview is switched off
SommerEngineering Oct 2, 2026
d2740ed
Added a tool which lets the AI search the mailboxes
SommerEngineering Oct 2, 2026
40466e0
Updated I18N
SommerEngineering Oct 2, 2026
817f7dc
Added a tool which lets the AI read the mails it found
SommerEngineering Oct 2, 2026
6f25b92
Updated I18N
SommerEngineering Oct 2, 2026
a8975a1
Added a tool which lets the AI count the mails in the mailboxes
SommerEngineering Oct 2, 2026
319276b
Improved the sources list to show mails as text instead of links whic…
SommerEngineering Oct 2, 2026
91d90bc
Improved mailbox syncing to go by the clock and to retry unreachable …
SommerEngineering Oct 3, 2026
d9f01d1
Added tool collections, which share one confidence level and one swit…
SommerEngineering Oct 3, 2026
37fd630
Changed tool selections and settings to show a tool collection as one…
SommerEngineering Oct 3, 2026
d92a6be
Changed the tool settings and their export to cover all tools of a co…
SommerEngineering Oct 3, 2026
04b1c9a
Added documentation of tool collections for administrators and develo…
SommerEngineering Oct 3, 2026
50dbdeb
Updated I18N
SommerEngineering Oct 3, 2026
8f27113
Added enterprise settings to block adding mailboxes and to require a …
SommerEngineering Oct 3, 2026
eace685
Added mail servers which configuration plugins offer for new mailboxes
SommerEngineering Oct 3, 2026
65ffc43
Added the mail servers of the organization to the mailbox dialog
SommerEngineering Oct 3, 2026
2a942ba
Added an enterprise setting to allow mailboxes only on the mail serve…
SommerEngineering Oct 3, 2026
8853a4a
Changed the mailbox dialog to offer only the mail servers of the orga…
SommerEngineering Oct 3, 2026
3eacdae
Fixed warnings about a hidden field and needless null checks
SommerEngineering Oct 3, 2026
ec88c09
Updated I18N
SommerEngineering Oct 3, 2026
e4b091c
Added documentation of the mail tools, tool availability, and outboun…
SommerEngineering Oct 3, 2026
ffcf470
Updated changelog
SommerEngineering Oct 3, 2026
d96772a
Fixed renaming an ERI data source leaving its secret behind under the…
SommerEngineering Oct 3, 2026
061b555
Fixed the provider selection of the mailbox dialog showing the buildi…
SommerEngineering Oct 4, 2026
d421234
Added the logos of public mail providers to the mailbox dialog
SommerEngineering Oct 4, 2026
8863708
Improved the mailbox dialog to follow changes of the organization whi…
SommerEngineering Oct 4, 2026
42ce497
Improved the mailbox dialog to tuck away server settings which AI Stu…
SommerEngineering Oct 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
55 changes: 54 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,15 @@ When adding configuration plugin capabilities:
When adding, changing, or removing model-driven tools, keep these parts in sync:
- `app/MindWork AI Studio/Tools/ToolCallingSystem/ToolCallingImplementations/` for the `IToolImplementation` class, which states its own `ToolDefinition` through `GetDefinition()`, written with `ToolSettingsSchemaBuilder` for its settings and `ToolParameterSchemaBuilder` for the arguments the model passes. There are no tool definition files; a tool arriving from elsewhere brings an `IToolDefinitionSource` instead.
- `app/MindWork AI Studio/Program.cs` for DI registration of the implementation. Registering it as an `IToolImplementation` is enough, because `CodeToolDefinitionSource` collects the definitions of all of them.
- `app/MindWork AI Studio/Tools/ToolCallingSystem/ToolSelectionRules.cs` when the shared tool-call limits change. A tool's own minimum provider confidence belongs in its definition, not here.
- An `IToolCollection` next to the tools, registered in `Program.cs`, when tools only make sense together. Selections, `DataTools.DisabledToolIds`, and the minimum provider confidence name tool collections; a tool outside a declared collection forms one under its own ID, and the ID of a tool inside one stands for its whole collection. Normalize a selection with `ToolRegistry.NormalizeSelection`, and expand it into tools with `ToolRegistry.ExpandSelection` only where the view of the model counts.
- `app/MindWork AI Studio/Tools/ToolCallingSystem/ToolSelectionRules.cs` when the shared tool-call limits change. A tool's own minimum provider confidence belongs in its definition, or in the definition of its collection, not here.
- `app/MindWork AI Studio/Tools/ToolCallingSystem/ToolSettingsOptionSources.cs` when a tool setting offers a fixed choice the app maintains, such as languages. Prefer this over spelling the values out in the settings schema; it keeps the list in one place and gives the user translated names.
- `app/MindWork AI Studio/Plugins/configuration/plugin.lua` to document each setting's field name, meaning, and data type. Tool settings need no code to be centrally manageable: an organization addresses them by `"<toolId>.<fieldName>"` in `DataTools.LockedToolSettings` or `DataTools.DefaultToolSettings`.

Tool implementations must treat model-provided arguments as untrusted input. Validate settings and arguments, protect secrets with `SensitiveTraceArgumentNames`, use `ToolExecutionBlockedException` for intentional policy blocks, and check provider confidence before returning sensitive data to the model.

A tool which belongs to a preview feature returns false from `IToolImplementation.IsAvailable` while the preview is switched off; the registry then leaves it out of every list, every request, and the token count, so no component has to check that preview for the tool. Every tool declares in `IToolImplementation.OutboundData` where its arguments go: a chat which read from a mailbox keeps the tools whose data goes further than the mailbox allows from being offered and from running, see `ToolSelectionRules.IsOutboundDataAllowed`. A tool which brings content of a mailbox into the chat raises `ToolExecutionResult.RequiredOutboundDataRestriction`, next to `RequiredProviderConfidence` and `RequiredDataSecurity`. "Searching Mailboxes" in `documentation/Tools.md` explains the mail tools.

A tool which offers itself from the context of a chat instead of being selected, such as `semantic_search`, sets `Activation = ToolActivation.CONTEXT` and tailors its function to each request in `ResolveFunctionAsync`. Code which decides something on behalf of a request — whether the classic RAG process steps back, say — asks `ToolRegistry.GetOfferBlockReasonAsync` or `ToolRegistry.GetEffectiveRetrievalModeAsync` with the provider settings of the request (`IProvider.CreateSettingsProvider`), never a check of its own: two answers which drift apart leave a chat searching nothing or twice.

## Model Capabilities
Expand Down Expand Up @@ -221,6 +224,56 @@ RAG is available as a beta preview feature. Architecture:
- **Index database** - SQLite, holding the file fingerprints and the chunk texts for full-text search; see "Databases" below
- **File processing** - Extracts text from PDF, DOCX, XLSX via Rust runtime

### Indexed data sources

Everything AI Studio embeds itself runs through one pipeline in `app/MindWork AI Studio/Tools/Services/Indexing/`,
driven by `DataSourceEmbeddingService`, which queues the runs, prepares each one and owns the statuses. A new
kind of data source plugs into this pipeline instead of building its own.

The parts:
- **`IIndexedDataSource`** (`Settings/`) - what indexing needs to know about a data source: confidence level,
embedding provider and chunk settings. `IDataSourceBase` is what every data source has. Implement
`IDataSource` on top only when classic RAG, Semantic Search and the agents should see the data source. A data
source kept in a list of its own implements `IIndexedDataSource` alone, and the compiler keeps it out of
`DataSources`.
- **`IIndexedSourceIndexer`** - one per kind of data source. `Supports` claims the data sources, `ProcessAsync`
finds and reads the documents of one run, and `TrackChanges` / `StopTracking` notice changes on their own.
`FileSourceIndexer` is the reference: a file system watcher per data source, fingerprints over path, size and
write time.
- **`IndexedRunContext`** - one prepared run: both stores, the embedding provider, the manifest and the
collection. `IndexDocumentAsync` embeds and stores one document; the cleanup methods remove what a failed
attempt left behind.
- **`EmbeddingDocument`** - one document: its key, its index row, its display name, and how to read its chunks.
- **`DocumentRunProgress`** - counts the documents, records indexed and failed ones in the stores, publishes the
status and completes the run.
- **`TextChunker`** - cuts text into chunks the embedding provider accepts. Pick one of its strategies; do not
write a chunker of your own.

To add a kind of data source:
1. Write its indexer in `Tools/Services/Indexing/` and create it in `DataSourceEmbeddingService.CreateIndexers`,
which hands every indexer the same `TextChunker`.
2. Gate it in `IsSupportedIndexedSource`, behind a preview feature of its own while it is new.
3. When the data source is not kept in `DataSources`, add its list to `GetConfiguredIndexedSources`. Every lookup
by id and every pass over all data sources goes through it: the startup hash check,
`QueueAllInternalDataSourcesAsync` and `RefreshWatchers`.
4. Keep whatever the kind has to remember beyond its documents in tables of its own in the index store, added
by an EF Core migration (see "Databases").
5. Report every status through `DocumentRunProgress`, so all rows of the embedding page behave alike.

Rules which are easy to break:
- **A document key is not a path.** Only files use their full path as the key. Never pass a key through the
`Path` APIs: on Windows, `Path.GetFullPath` reads a key like `mail:…` as a file with an alternate data stream.
- **Ids and signature are pinned.** The formats in `IndexedDocumentIds` and the embedding signature
(`DataSourceEmbeddingService.BuildEmbeddingSignature`) are fixed by tests, because every stored chunk and every
index depends on them. When the metadata stored next to a chunk changes, raise `CHUNK_METADATA_VERSION`
deliberately: that rebuilds every index.
- **Every content path goes through the prompt injection filter.** Files pass the sanitizer of the runtime while
their text is extracted; a new kind of data source needs its own pass through `PromptInjectionGuardService`.
- **The service decides when, the indexer decides how.** Whether changes are tracked at all depends on the
automatic refresh setting and the startup hash check, and only the embedding service decides that.
- **Moving a `TB()` text into another class gives it a new I18N key**, so its translation is made anew during
the next localization run.

## Databases

Local RAG runs on two databases, addressed through `DatabaseRole`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,13 @@ private static ReadOnlySpan<char> ExtractJson(ReadOnlySpan<char> input)
/// </summary>
/// <remarks>
/// The description is the one the tool gives a model, which is exactly what the assistant's
/// model would read. A tool this installation does not know is listed by its ID alone: the
/// plugin still asks for it, and a name nobody can resolve is itself worth seeing.
/// model would read. A collection is listed by its tools for the same reason. A tool this
/// installation does not know is listed by its ID alone: the plugin still asks for it, and a
/// name nobody can resolve is itself worth seeing.
/// </remarks>
private string FormatRequestedTools(PluginAssistants plugin)
{
var toolIds = ToolSelectionRules.NormalizeSelection(plugin.AssistantToolIds ?? plugin.ChatLaunchConfiguration?.ToolIds ?? []);
var toolIds = toolRegistry.ExpandSelection(plugin.AssistantToolIds ?? plugin.ChatLaunchConfiguration?.ToolIds ?? []);
if (toolIds.Count == 0)
return "None. This plugin does not request any tools.";

Expand Down
3 changes: 2 additions & 1 deletion app/MindWork AI Studio/Assistants/AssistantBase.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using AIStudio.Chat
@using AIStudio.Settings.DataModel
@inherits AssistantLowerBase
@typeparam TSettings

Expand Down Expand Up @@ -180,7 +181,7 @@
@* No selection where the assistant's own rules already name the tools: *@
@if (this.SettingsManager.AreToolsEnabled() && this.AssistantManagedToolIds is null && this.SettingsManager.IsToolSelectionVisible(this.Component))
{
<ToolSelection Component="@this.Component" LLMProvider="@this.ProviderSettings" SelectedToolIds="@this.SelectedToolIds" SelectedToolIdsChanged="@this.SelectedToolIdsChanged" Disabled="@this.IsProcessing" />
<ToolSelection Component="@this.Component" LLMProvider="@this.ProviderSettings" RequiredOutboundDataRestriction="@(this.ChatThread?.RequiredOutboundDataRestriction ?? OutboundDataRequirement.NONE)" SelectedToolIds="@this.SelectedToolIds" SelectedToolIdsChanged="@this.SelectedToolIdsChanged" Disabled="@this.IsProcessing" />
}

<MudSpacer />
Expand Down
21 changes: 12 additions & 9 deletions app/MindWork AI Studio/Assistants/AssistantBase.razor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using AIStudio.Chat;
using AIStudio.Provider;
using AIStudio.Settings;
using AIStudio.Settings.DataModel;
using AIStudio.Dialogs.Settings;
using AIStudio.Tools.AIJobs;
using AIStudio.Tools.AssistantSessions;
Expand Down Expand Up @@ -197,7 +198,7 @@ protected override async Task OnInitializedAsync()
this.ProviderSettings = this.SettingsManager.GetPreselectedProvider(this.Component);
this.CurrentProfile = this.SettingsManager.GetPreselectedProfile(this.Component);
this.CurrentChatTemplate = this.SettingsManager.GetPreselectedChatTemplate(this.Component);
this.SelectedToolIds = this.SettingsManager.GetDefaultToolIds(this.Component);
this.SelectedToolIds = this.ToolRegistry.GetDefaultToolIds(this.Component);
await this.OnDefaultsAppliedAsync();
this.assistantSessionKey = new(this.Component, this.AssistantSessionInstanceId);
await this.AttachAssistantSessionIfAvailable();
Expand Down Expand Up @@ -408,7 +409,7 @@ protected virtual void ResetProviderAndProfileSelection()
this.ProviderSettings = this.SettingsManager.GetPreselectedProvider(this.Component);
this.CurrentProfile = this.SettingsManager.GetPreselectedProfile(this.Component);
this.CurrentChatTemplate = this.SettingsManager.GetPreselectedChatTemplate(this.Component);
this.SelectedToolIds = this.SettingsManager.GetDefaultToolIds(this.Component);
this.SelectedToolIds = this.ToolRegistry.GetDefaultToolIds(this.Component);
}

/// <summary>
Expand All @@ -431,18 +432,20 @@ protected virtual void ResetProviderAndProfileSelection()
/// always has the last word: a tool asking for more confidence than the selected provider has
/// never reaches the model, no matter who put it on the list. That filter belongs here rather
/// than into the stored selection, because a provider with too little confidence must not cost
/// the user a tool for good.
/// the user a tool for good. The same goes for a tool which a mailbox the thread read from
/// keeps back.
/// </remarks>
protected HashSet<string> GetRunnableToolIds()
/// <param name="outboundDataRestriction">Where the thread the tools run in may still send data, see ChatThread.RequiredOutboundDataRestriction.</param>
protected HashSet<string> GetRunnableToolIds(OutboundDataRestriction outboundDataRestriction)
{
if (this.AssistantManagedToolIds is not null)
return this.ToolRegistry.FilterToolIdsForProvider(this.ProviderSettings, this.AssistantManagedToolIds);
return this.ToolRegistry.FilterToolIdsForProvider(this.ProviderSettings, this.AssistantManagedToolIds, outboundDataRestriction);

// What the user cannot see, the assistant does not use:
if (!this.SettingsManager.IsToolSelectionVisible(this.Component))
return [];

return this.ToolRegistry.FilterToolIdsForProvider(this.ProviderSettings, this.SelectedToolIds);
return this.ToolRegistry.FilterToolIdsForProvider(this.ProviderSettings, this.SelectedToolIds, outboundDataRestriction);
}

/// <summary>
Expand All @@ -454,7 +457,7 @@ protected HashSet<string> GetRunnableToolIds()
/// </remarks>
protected Task SelectedToolIdsChanged(HashSet<string> updatedToolIds)
{
this.SelectedToolIds = ToolSelectionRules.NormalizeSelection(updatedToolIds);
this.SelectedToolIds = this.ToolRegistry.NormalizeSelection(updatedToolIds);
return Task.CompletedTask;
}

Expand Down Expand Up @@ -518,7 +521,7 @@ protected async Task<string> AddAIResponseAsync(DateTimeOffset time, bool hideCo
this.ChatThread.SelectedProvider = this.ProviderSettings.Id;
this.ChatThread.RuntimeComponent = this.Component;
this.ChatThread.SelectedToolIds = [..this.SelectedToolIds];
this.ChatThread.RuntimeSelectedToolIds = this.GetRunnableToolIds();
this.ChatThread.RuntimeSelectedToolIds = this.GetRunnableToolIds(this.ChatThread.RequiredOutboundDataRestriction.Restriction);
this.ChatThread.RuntimeToolsAreAssistantManaged = this.AssistantManagedToolIds is not null;
}

Expand Down Expand Up @@ -1014,7 +1017,7 @@ private void ImportAssistantSessionState(IReadOnlyDictionary<string, IAssistantS
reader.Restore(RESULTING_CONTENT_BLOCK_STATE_KEY, value => this.ResultingContentBlock = value);
reader.Restore(INPUT_ISSUES_STATE_KEY, value => this.InputIssues = value);
reader.Restore(IS_PROCESSING_STATE_KEY, value => this.IsProcessing = value);
reader.Restore(SELECTED_TOOL_IDS_STATE_KEY, value => this.SelectedToolIds = ToolSelectionRules.NormalizeSelection(value));
reader.Restore(SELECTED_TOOL_IDS_STATE_KEY, value => this.SelectedToolIds = this.ToolRegistry.NormalizeSelection(value));
this.RestoreCustomAssistantSessionState(reader);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using AIStudio.Chat;
using AIStudio.Provider;
using AIStudio.Settings;
using AIStudio.Settings.DataModel;
using AIStudio.Tools.ToolCallingSystem;

namespace AIStudio.Assistants.BatchProcessing;
Expand Down Expand Up @@ -110,7 +111,9 @@ private static string BuildUserPrompt(string fileName, string fileContent)
Name = this.Title,
Blocks = [],
RuntimeComponent = this.Component,
RuntimeSelectedToolIds = this.GetRunnableToolIds(),

// A thread of its own, which has read no mailbox yet:
RuntimeSelectedToolIds = this.GetRunnableToolIds(OutboundDataRestriction.UNRESTRICTED),

// Always true here, unlike in the assistant base: a batch run takes its tools from the
// selected policy or from its own field, never from the tool selection in the footer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using AIStudio.Tools.PluginSystem.Assistants;
using AIStudio.Tools.PluginSystem.Assistants.DataModel;
using AIStudio.Tools.Services;
using AIStudio.Tools.ToolCallingSystem;
using Microsoft.AspNetCore.Components;
using DialogOptions = AIStudio.Dialogs.DialogOptions;

Expand Down Expand Up @@ -326,7 +325,7 @@ protected override void RestoreCustomAssistantSessionState(AssistantSessionState
state.Restore(LAUNCHER_PROFILE_ID_STATE_KEY, value => this.launcherProfileId = value);
state.Restore(LAUNCHER_CHAT_TEMPLATE_ID_STATE_KEY, value => this.launcherChatTemplateId = value);
state.Restore(LAUNCHER_DATA_SOURCE_IDS_STATE_KEY, value => this.launcherDataSourceIds = value);
state.Restore(LAUNCHER_TOOL_IDS_STATE_KEY, value => this.launcherToolIds = ToolSelectionRules.NormalizeSelection(value));
state.Restore(LAUNCHER_TOOL_IDS_STATE_KEY, value => this.launcherToolIds = this.ToolRegistry.NormalizeSelection(value));
state.Restore(SELECTED_ASSISTANT_COMPONENTS_STATE_KEY, value => this.selectedAssistantComponents = value);
state.Restore(SELECTED_OUTPUT_LANGUAGE_STATE_KEY, value => this.selectedOutputLanguage = value);
state.Restore(CUSTOM_OUTPUT_LANGUAGE_STATE_KEY, value => this.customOutputLanguage = value);
Expand Down Expand Up @@ -542,7 +541,7 @@ private string GetSelectedAssistantComponentTypes()
return null;

var dataSourceIds = this.launcherDataSourceIds.Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
var toolIds = ToolSelectionRules.NormalizeSelection(this.launcherToolIds).ToArray();
var toolIds = this.ToolRegistry.NormalizeSelection(this.launcherToolIds).ToArray();
return new(
this.launcherWorkspaceName.Trim(),
NullIfEmpty(this.launcherProviderId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using AIStudio.Tools.PluginSystem.Assistants;
using AIStudio.Tools.PluginSystem.Assistants.DataModel;
using AIStudio.Tools.Services;
using AIStudio.Tools.ToolCallingSystem;
using Lua;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.WebUtilities;
Expand Down Expand Up @@ -171,7 +170,7 @@ protected override void OnInitialized()
this.systemPrompt = pluginAssistant.SystemPrompt;
this.submitText = pluginAssistant.SubmitText;
this.allowProfiles = pluginAssistant.AllowProfiles;
this.assistantToolIds = ReadPluginToolIds(pluginAssistant);
this.assistantToolIds = this.ReadPluginToolIds(pluginAssistant);
this.showFooterProfileSelection = !pluginAssistant.HasEmbeddedProfileSelection;
this.pluginPath = pluginAssistant.PluginPath;
var pluginHash = pluginAssistant.ComputeAuditHash();
Expand Down Expand Up @@ -366,7 +365,7 @@ private void ApplyUpdatedAssistantPlugin(PluginAssistants updatedPlugin)
this.systemPrompt = updatedPlugin.SystemPrompt;
this.submitText = updatedPlugin.SubmitText;
this.allowProfiles = updatedPlugin.AllowProfiles;
this.assistantToolIds = ReadPluginToolIds(updatedPlugin);
this.assistantToolIds = this.ReadPluginToolIds(updatedPlugin);
this.showFooterProfileSelection = !updatedPlugin.HasEmbeddedProfileSelection;
this.pluginPath = updatedPlugin.PluginPath;
var pluginHash = updatedPlugin.ComputeAuditHash();
Expand All @@ -391,7 +390,7 @@ private void ApplyUpdatedAssistantPlugin(PluginAssistants updatedPlugin)
/// a plugin installed later, and dropping it here would silently turn a plugin that names tools
/// into one that lets the user choose.
/// </remarks>
private static HashSet<string>? ReadPluginToolIds(PluginAssistants plugin) => plugin.AssistantToolIds is { } toolIds ? ToolSelectionRules.NormalizeSelection(toolIds) : null;
private HashSet<string>? ReadPluginToolIds(PluginAssistants plugin) => plugin.AssistantToolIds is { } toolIds ? this.ToolRegistry.NormalizeSelection(toolIds) : null;

private string ResolveImageSource(AssistantImage image)
{
Expand Down
Loading
Loading