Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ public ActionType(string value)

public static readonly ActionType ResourceWatchChanged = new ActionType("resourceWatch/changed");

public static readonly ActionType SearchQueryChanged = new ActionType("search/queryChanged");

public static readonly ActionType SearchResultsChanged = new ActionType("search/resultsChanged");

public static readonly ActionType SearchLifecycleChanged = new ActionType("search/lifecycleChanged");

public static readonly ActionType AutomationCreateRequested = new ActionType("automation/createRequested");

public static readonly ActionType AutomationUpdateRequested = new ActionType("automation/updateRequested");
Expand Down Expand Up @@ -2548,6 +2554,76 @@ public sealed record ResourceWatchChangedAction
public JsonElement Changes { get; init; }
}

/// <summary>Replaces the search's query and restarts the search.
///
/// Keeps {@link SearchState.results} and sets {@link SearchState.lifecycle} to
/// {@link SearchLifecycleStatus.Pending | pending}. The old results stay
/// visible until the host replaces them, so the client does not flash an empty
/// list.
///
/// After the host applies this action, it stops the previous search and drops
/// any of its results that it has not dispatched yet. The host MUST then
/// dispatch {@link SearchResultsChangedAction | `search/resultsChanged`} with
/// `replace: true` before any other search action. The replacement can keep
/// old results that still match the new query, and can be empty. If the new
/// query is not valid,
/// for example because it contains an invalid regular expression, the host
/// replaces the results with an empty list and then changes the lifecycle to
/// {@link SearchLifecycleStatus.Failed | failed}.
///
/// Stability: 1.0 - Early development.</summary>
public sealed record SearchQueryChangedAction
{
public ActionType Type { get; init; } = ActionType.SearchQueryChanged;

/// <summary>The new query.</summary>
public required SearchQuery Query { get; init; }
}

/// <summary>Adds results to {@link SearchState.results}, or replaces them.
///
/// By default, the reducer appends `results`. Set `replace` to `true` to
/// replace every result instead; if {@link SearchState.lifecycle} is
/// {@link SearchLifecycleStatus.Pending | pending}, a replacement also changes
/// it to {@link SearchLifecycleStatus.Running | running}.
///
/// The host MUST dispatch a replacement first after a
/// {@link SearchQueryChangedAction | `search/queryChanged`}. It MAY also
/// replace the results at other times, for example to re-rank them, to remove
/// duplicates, or to update a completed search when a watched file changes.
/// The host MUST NOT dispatch an empty `results` list unless `replace` is
/// `true`.
///
/// Stability: 1.0 - Early development.</summary>
public sealed record SearchResultsChangedAction
{
public ActionType Type { get; init; } = ActionType.SearchResultsChanged;

/// <summary>The results to append, in the order the host found them, or the replacement results.</summary>
public required List<SearchResult> Results { get; init; }

/// <summary>When `true`, replaces every result instead of appending.</summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? Replace { get; init; }
}

/// <summary>Replaces {@link SearchState.lifecycle}.
///
/// The host dispatches this to complete or fail a search, or to move a
/// completed search back to {@link SearchLifecycleStatus.Running | running} when it
/// searches again, for example after a watched file changes. The host MUST NOT
/// change the lifecycle to {@link SearchLifecycleStatus.Pending | pending}; only
/// {@link SearchQueryChangedAction | `search/queryChanged`} does that.
///
/// Stability: 1.0 - Early development.</summary>
public sealed record SearchLifecycleChangedAction
{
public ActionType Type { get; init; } = ActionType.SearchLifecycleChanged;

/// <summary>The new lifecycle.</summary>
public required SearchLifecycleState Lifecycle { get; init; }
}

/// <summary>Upsert an {@link Annotation} in the annotations channel — adds a new
/// annotation, or replaces an existing one identified by
/// {@link Annotation.id}.
Expand Down Expand Up @@ -2996,6 +3072,9 @@ public StateActionConverter()
["terminal/commandExecuted"] = typeof(TerminalCommandExecutedAction),
["terminal/commandFinished"] = typeof(TerminalCommandFinishedAction),
["resourceWatch/changed"] = typeof(ResourceWatchChangedAction),
["search/queryChanged"] = typeof(SearchQueryChangedAction),
["search/resultsChanged"] = typeof(SearchResultsChangedAction),
["search/lifecycleChanged"] = typeof(SearchLifecycleChangedAction),
["annotations/set"] = typeof(AnnotationsSetAction),
["annotations/removed"] = typeof(AnnotationsRemovedAction),
["annotations/entrySet"] = typeof(AnnotationsEntrySetAction),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,13 @@ public sealed record InitializeResult
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public TcpConnectionsCapability? TcpConnections { get; init; }

/// <summary>Present when the host supports `createSearch`, which searches files,
/// sessions, and chats and streams the results on an `ahp-search:` channel.
///
/// Stability: 1.0 - Early development.</summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public SearchCapability? Search { get; init; }

/// <summary>Present when chats in one session may be backed by different agent
/// providers (see {@link CreateChatParams.provider} and
/// {@link ChatState.provider}).
Expand Down Expand Up @@ -1872,6 +1879,42 @@ public sealed record CreateResourceWatchResult
public required string Channel { get; init; }
}

/// <summary>Starts a search on the host.
///
/// The client chooses the channel URI and then subscribes to it to receive the
/// search's {@link SearchState} and its results. The client replaces the query
/// by dispatching {@link SearchQueryChangedAction | `search/queryChanged`},
/// and cancels the search by unsubscribing.
///
/// The client MUST NOT send this command unless `InitializeResult.search` is
/// present, and MUST NOT include a target whose kind is not listed in
/// {@link SearchCapability.targets}.
///
/// Stability: 1.0 - Early development.</summary>
public sealed record CreateSearchParams
{
/// <summary>The client-chosen URI for the new channel, for example `ahp-search:/&lt;uuid&gt;`.</summary>
public required string Channel { get; init; }

/// <summary>Optional JSON-serializable metadata associated with this request.
/// Receivers MUST ignore keys they do not understand.</summary>
[JsonPropertyName("_meta")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Dictionary<string, JsonElement>? Meta { get; init; }

/// <summary>What to search for and where.</summary>
public required SearchQuery Query { get; init; }
}

/// <summary>Result of the `createSearch` command.
///
/// An empty object on success.
///
/// Stability: 1.0 - Early development.</summary>
public sealed record CreateSearchResult
{
}

/// <summary>Requests that the host load older historical turns into a chat state.
///
/// The command result does not carry turns. Instead, before responding, the host
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ namespace Microsoft.AgentHostProtocol;
[JsonSerializable(typeof(ChatInteractivity))]
[JsonSerializable(typeof(ChatIsArchivedChangedAction))]
[JsonSerializable(typeof(ChatIsReadChangedAction))]
[JsonSerializable(typeof(ChatMessageSearchResult))]
[JsonSerializable(typeof(ChatMessagesSearchTarget))]
[JsonSerializable(typeof(ChatMovableChangedAction))]
[JsonSerializable(typeof(ChatMovedAction))]
[JsonSerializable(typeof(ChatMoveDestination))]
Expand Down Expand Up @@ -220,6 +222,8 @@ namespace Microsoft.AgentHostProtocol;
[JsonSerializable(typeof(CreateChatParams))]
[JsonSerializable(typeof(CreateResourceWatchParams))]
[JsonSerializable(typeof(CreateResourceWatchResult))]
[JsonSerializable(typeof(CreateSearchParams))]
[JsonSerializable(typeof(CreateSearchResult))]
[JsonSerializable(typeof(CreateSessionParams))]
[JsonSerializable(typeof(CreateTcpConnectionParams))]
[JsonSerializable(typeof(CreateTcpConnectionResult))]
Expand Down Expand Up @@ -259,6 +263,10 @@ namespace Microsoft.AgentHostProtocol;
[JsonSerializable(typeof(FileEditCollection))]
[JsonSerializable(typeof(FileEditDiffStats))]
[JsonSerializable(typeof(FileEditSide))]
[JsonSerializable(typeof(FileNameSearchResult))]
[JsonSerializable(typeof(FileNamesSearchTarget))]
[JsonSerializable(typeof(FileTextSearchResult))]
[JsonSerializable(typeof(FileTextSearchTarget))]
[JsonSerializable(typeof(ForkChatSource))]
[JsonSerializable(typeof(HookCustomization))]
[JsonSerializable(typeof(HostEnvironment))]
Expand Down Expand Up @@ -370,6 +378,25 @@ namespace Microsoft.AgentHostProtocol;
[JsonSerializable(typeof(RuleCustomization))]
[JsonSerializable(typeof(RunAutomationParams))]
[JsonSerializable(typeof(RunAutomationResult))]
[JsonSerializable(typeof(SearchCapability))]
[JsonSerializable(typeof(SearchCompletedLifecycleState))]
[JsonSerializable(typeof(SearchCompletionReason))]
[JsonSerializable(typeof(SearchFailedLifecycleState))]
[JsonSerializable(typeof(SearchHighlight))]
[JsonSerializable(typeof(SearchLifecycleChangedAction))]
[JsonSerializable(typeof(SearchLifecycleState))]
[JsonSerializable(typeof(SearchLifecycleStatus))]
[JsonSerializable(typeof(SearchMatch))]
[JsonSerializable(typeof(SearchPendingLifecycleState))]
[JsonSerializable(typeof(SearchQuery))]
[JsonSerializable(typeof(SearchQueryChangedAction))]
[JsonSerializable(typeof(SearchResult))]
[JsonSerializable(typeof(SearchResultKind))]
[JsonSerializable(typeof(SearchResultsChangedAction))]
[JsonSerializable(typeof(SearchRunningLifecycleState))]
[JsonSerializable(typeof(SearchState))]
[JsonSerializable(typeof(SearchTarget))]
[JsonSerializable(typeof(SearchTargetKind))]
[JsonSerializable(typeof(SessionActiveClient))]
[JsonSerializable(typeof(SessionActiveClientRemovedAction))]
[JsonSerializable(typeof(SessionActiveClientSetAction))]
Expand Down Expand Up @@ -419,7 +446,9 @@ namespace Microsoft.AgentHostProtocol;
[JsonSerializable(typeof(SessionReasoningAction))]
[JsonSerializable(typeof(SessionRemovedParams))]
[JsonSerializable(typeof(SessionResponsePartAction))]
[JsonSerializable(typeof(SessionSearchResult))]
[JsonSerializable(typeof(SessionServerToolsChangedAction))]
[JsonSerializable(typeof(SessionsSearchTarget))]
[JsonSerializable(typeof(SessionState))]
[JsonSerializable(typeof(SessionStatus))]
[JsonSerializable(typeof(SessionSummary))]
Expand Down
Loading
Loading