Skip to content
Draft
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 @@ -125,6 +125,16 @@ public override void Write(Utf8JsonWriter writer, ChatMoveDestinationKind value,
=> writer.WriteStringValue(value.Value);
}

/// <summary>The searchable side of a completed turn.</summary>
[JsonConverter(typeof(WireEnumConverter<ChatTurnMatchKind>))]
public enum ChatTurnMatchKind
{
[WireValue("request")]
Request,
[WireValue("response")]
Response,
}

/// <summary>Native filesystem path grammar used by a host environment.</summary>
[JsonConverter(typeof(WireEnumConverter<PathStyle>))]
public enum PathStyle
Expand Down Expand Up @@ -1922,6 +1932,68 @@ public sealed record ReadChatTurnsResult
public string? PreviousCursor { get; init; }
}

/// <summary>A match locator, not a snippet, text offset, or response-part identifier.</summary>
public sealed record ChatTurnMatch
{
public required string TurnId { get; init; }

public ChatTurnMatchKind Kind { get; init; }

/// <summary>Zero-based index of this nonempty match in forward text order on this
/// side of the turn, for the same query and flags.</summary>
public long Occurrence { get; init; }
}

/// <summary>Searches visible request and response text in retained completed turns.
/// Returns match locators newest first, independently of the subscription.
/// Requires `ChatState.historyBrowsing.search`.</summary>
public sealed record SearchChatTurnsParams
{
/// <summary>Chat URI.</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>Maximum matches in the page; defaults to 100. The host may return fewer.</summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public long? Limit { get; init; }

/// <summary>Opaque cursor for the same chat, query and effective flags; omit to start at the newest turn.</summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Cursor { get; init; }

/// <summary>Nonempty literal text, or a pattern when `isRegex` is true.</summary>
public required string Query { get; init; }

/// <summary>Case-sensitive matching; defaults to false.</summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? MatchCase { get; init; }

/// <summary>Require whole-word matches; defaults to false.</summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? WholeWord { get; init; }

/// <summary>Treat the query as a regular expression; defaults to false.</summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? IsRegex { get; init; }
}

/// <summary>One page of match locators, which may end within a turn or side.</summary>
public sealed record SearchChatTurnsResult
{
/// <summary>Resume after the last result or scanned position. A bounded scan may
/// return no matches with an advancing cursor; only absence means done.</summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? NextCursor { get; init; }

/// <summary>Match locators in reverse transcript order.</summary>
public required List<ChatTurnMatch> Items { get; init; }
}

/// <summary>Stop receiving updates for a channel.</summary>
public sealed record UnsubscribeParams
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ namespace Microsoft.AgentHostProtocol;
[JsonSerializable(typeof(ChatDraftChangedAction))]
[JsonSerializable(typeof(ChatErrorAction))]
[JsonSerializable(typeof(ChatHistoryBrowsingCapability))]
[JsonSerializable(typeof(ChatHistorySearchCapability))]
[JsonSerializable(typeof(ChatInputAnswer))]
[JsonSerializable(typeof(ChatInputAnswerChangedAction))]
[JsonSerializable(typeof(ChatInputAnswered))]
Expand Down Expand Up @@ -199,6 +200,8 @@ namespace Microsoft.AgentHostProtocol;
[JsonSerializable(typeof(ChatTurnCancelledAction))]
[JsonSerializable(typeof(ChatTurnCompleteAction))]
[JsonSerializable(typeof(ChatTurnIndexEntry))]
[JsonSerializable(typeof(ChatTurnMatch))]
[JsonSerializable(typeof(ChatTurnMatchKind))]
[JsonSerializable(typeof(ChatTurnResumeAction))]
[JsonSerializable(typeof(ChatTurnsLoadedAction))]
[JsonSerializable(typeof(ChatTurnStartedAction))]
Expand Down Expand Up @@ -369,6 +372,8 @@ namespace Microsoft.AgentHostProtocol;
[JsonSerializable(typeof(RuleCustomization))]
[JsonSerializable(typeof(RunAutomationParams))]
[JsonSerializable(typeof(RunAutomationResult))]
[JsonSerializable(typeof(SearchChatTurnsParams))]
[JsonSerializable(typeof(SearchChatTurnsResult))]
[JsonSerializable(typeof(SessionActiveClient))]
[JsonSerializable(typeof(SessionActiveClientRemovedAction))]
[JsonSerializable(typeof(SessionActiveClientSetAction))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2175,6 +2175,14 @@ public sealed record MultipleChatsCapability

/// <summary>Presence advertises `listChatTurns` and `readChatTurns` for this chat.</summary>
public sealed record ChatHistoryBrowsingCapability
{
/// <summary>Presence advertises host-side search; omit for browsing-only chats.</summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChatHistorySearchCapability? Search { get; init; }
}

/// <summary>Presence advertises `searchChatTurns`. Open a result with `readChatTurns`.</summary>
public sealed record ChatHistorySearchCapability
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ private static (object decoded, string reencoded) DecodeAndReencode(string type,
return Wrap(Ser.Deserialize<ReadChatTurnsParams>(inputJson));
case "ReadChatTurnsResult":
return Wrap(Ser.Deserialize<ReadChatTurnsResult>(inputJson));
case "SearchChatTurnsParams":
return Wrap(Ser.Deserialize<SearchChatTurnsParams>(inputJson));
case "SearchChatTurnsResult":
return Wrap(Ser.Deserialize<SearchChatTurnsResult>(inputJson));
case "Snapshot":
return Wrap(Ser.Deserialize<Snapshot>(inputJson));
case "SubscribeParams":
Expand Down
55 changes: 55 additions & 0 deletions clients/go/ahptypes/commands.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ const (
ChatMoveDestinationKindNewSession ChatMoveDestinationKind = "newSession"
)

// The searchable side of a completed turn.
type ChatTurnMatchKind string

const (
ChatTurnMatchKindRequest ChatTurnMatchKind = "request"
ChatTurnMatchKindResponse ChatTurnMatchKind = "response"
)

// Native filesystem path grammar used by a host environment.
type PathStyle string

Expand Down Expand Up @@ -1377,6 +1385,53 @@ type ReadChatTurnsResult struct {
PreviousCursor *string `json:"previousCursor,omitempty"`
}

// A match locator, not a snippet, text offset, or response-part identifier.
type ChatTurnMatch struct {
TurnId string `json:"turnId"`
Kind ChatTurnMatchKind `json:"kind"`
// Zero-based index of this nonempty match in forward text order on this
// side of the turn, for the same query and flags.
Occurrence int64 `json:"occurrence"`
}

// Searches visible request and response text in retained completed turns.
// Returns match locators newest first, independently of the subscription.
// Requires `ChatState.historyBrowsing.search`.
type SearchChatTurnsParams struct {
// Channel URI this command targets.
Channel URI `json:"channel"`
// Optional JSON-serializable metadata associated with this request.
// Receivers MUST ignore keys they do not understand.
Meta map[string]json.RawMessage `json:"_meta,omitempty"`
// Maximum number of entries to return in this page. The server SHOULD respect
// this bound but MAY return fewer entries and MAY impose its own upper cap.
// Omit to let the server choose the page size.
Limit *int64 `json:"limit,omitempty"`
// Opaque pagination cursor from a previous {@link PaginatedResult.nextCursor}.
// Omit to fetch the first page. Cursors are server-defined and MUST be treated
// as opaque — do not parse, modify, or persist them across connections. An
// unrecognised cursor SHOULD be rejected with an `InvalidParams` error.
Cursor *string `json:"cursor,omitempty"`
// Nonempty literal text, or a pattern when `isRegex` is true.
Query string `json:"query"`
// Case-sensitive matching; defaults to false.
MatchCase *bool `json:"matchCase,omitempty"`
// Require whole-word matches; defaults to false.
WholeWord *bool `json:"wholeWord,omitempty"`
// Treat the query as a regular expression; defaults to false.
IsRegex *bool `json:"isRegex,omitempty"`
}

// One page of match locators, which may end within a turn or side.
type SearchChatTurnsResult struct {
// Opaque cursor for the next page. Present when more entries exist beyond the
// returned page; absent signals the end of the collection. Pass it back as
// {@link PaginatedParams.cursor} to fetch the following page.
NextCursor *string `json:"nextCursor,omitempty"`
// Match locators in reverse transcript order.
Items []ChatTurnMatch `json:"items"`
}

// Stop receiving updates for a channel.
type UnsubscribeParams struct {
// Channel URI to unsubscribe from
Expand Down
8 changes: 8 additions & 0 deletions clients/go/ahptypes/roundtrip_fixture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,14 @@ func decodeAndReencode(t *testing.T, name, typ, inputJSON string) string {
var v ReadChatTurnsResult
dec(&v)
return enc(&v)
case "SearchChatTurnsParams":
var v SearchChatTurnsParams
dec(&v)
return enc(&v)
case "SearchChatTurnsResult":
var v SearchChatTurnsResult
dec(&v)
return enc(&v)
case "ChatSource":
var v ChatSource
dec(&v)
Expand Down
6 changes: 6 additions & 0 deletions clients/go/ahptypes/state.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,12 @@ type MultipleChatsCapability struct {

// Presence advertises `listChatTurns` and `readChatTurns` for this chat.
type ChatHistoryBrowsingCapability struct {
// Presence advertises host-side search; omit for browsing-only chats.
Search *ChatHistorySearchCapability `json:"search,omitempty"`
}

// Presence advertises `searchChatTurns`. Open a result with `readChatTurns`.
type ChatHistorySearchCapability struct {
}

// Options for the {@link AgentCapabilities.multipleWorkingDirectories} capability.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ internal object ChatMoveDestinationKindSerializer : KSerializer<ChatMoveDestinat
ChatMoveDestinationKind(decoder.decodeString())
}

/**
* The searchable side of a completed turn.
*/
@Serializable
enum class ChatTurnMatchKind {
@SerialName("request")
REQUEST,
@SerialName("response")
RESPONSE
}

/**
* Native filesystem path grammar used by a host environment.
*/
Expand Down Expand Up @@ -1666,6 +1677,74 @@ data class ReadChatTurnsResult(
val previousCursor: String? = null
)

@Serializable
data class ChatTurnMatch(
val turnId: String,
val kind: ChatTurnMatchKind,
/**
* Zero-based index of this nonempty match in forward text order on this
* side of the turn, for the same query and flags.
*/
val occurrence: Long
)

@Serializable
data class SearchChatTurnsParams(
/**
* Channel URI this command targets.
*/
val channel: String,
/**
* Optional JSON-serializable metadata associated with this request.
* Receivers MUST ignore keys they do not understand.
*/
@SerialName("_meta")
val meta: Map<String, JsonElement>? = null,
/**
* Maximum number of entries to return in this page. The server SHOULD respect
* this bound but MAY return fewer entries and MAY impose its own upper cap.
* Omit to let the server choose the page size.
*/
val limit: Long? = null,
/**
* Opaque pagination cursor from a previous {@link PaginatedResult.nextCursor}.
* Omit to fetch the first page. Cursors are server-defined and MUST be treated
* as opaque — do not parse, modify, or persist them across connections. An
* unrecognised cursor SHOULD be rejected with an `InvalidParams` error.
*/
val cursor: String? = null,
/**
* Nonempty literal text, or a pattern when `isRegex` is true.
*/
val query: String,
/**
* Case-sensitive matching; defaults to false.
*/
val matchCase: Boolean? = null,
/**
* Require whole-word matches; defaults to false.
*/
val wholeWord: Boolean? = null,
/**
* Treat the query as a regular expression; defaults to false.
*/
val isRegex: Boolean? = null
)

@Serializable
data class SearchChatTurnsResult(
/**
* Opaque cursor for the next page. Present when more entries exist beyond the
* returned page; absent signals the end of the collection. Pass it back as
* {@link PaginatedParams.cursor} to fetch the following page.
*/
val nextCursor: String? = null,
/**
* Match locators in reverse transcript order.
*/
val items: List<ChatTurnMatch>
)

@Serializable
data class UnsubscribeParams(
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ object AhpCommands {
fun readChatTurns(id: Long, params: ReadChatTurnsParams): JsonRpcRequest<ReadChatTurnsParams> =
JsonRpcRequest(id = id, method = "readChatTurns", params = params)

fun searchChatTurns(id: Long, params: SearchChatTurnsParams): JsonRpcRequest<SearchChatTurnsParams> =
JsonRpcRequest(id = id, method = "searchChatTurns", params = params)

fun authenticate(id: Long, params: AuthenticateParams): JsonRpcRequest<AuthenticateParams> =
JsonRpcRequest(id = id, method = "authenticate", params = params)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,15 @@ data class MultipleChatsCapability(
)

@Serializable
class ChatHistoryBrowsingCapability
data class ChatHistoryBrowsingCapability(
/**
* Presence advertises host-side search; omit for browsing-only chats.
*/
val search: ChatHistorySearchCapability? = null
)

@Serializable
class ChatHistorySearchCapability

@Serializable
data class MultipleWorkingDirectoriesCapability(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import com.microsoft.agenthostprotocol.generated.ListChatTurnsParams
import com.microsoft.agenthostprotocol.generated.ListChatTurnsResult
import com.microsoft.agenthostprotocol.generated.ReadChatTurnsParams
import com.microsoft.agenthostprotocol.generated.ReadChatTurnsResult
import com.microsoft.agenthostprotocol.generated.SearchChatTurnsParams
import com.microsoft.agenthostprotocol.generated.SearchChatTurnsResult
import com.microsoft.agenthostprotocol.generated.Customization
import com.microsoft.agenthostprotocol.generated.Implementation
import com.microsoft.agenthostprotocol.generated.InitializeResult
Expand Down Expand Up @@ -276,6 +278,8 @@ class RoundTripCorpusTest {
"ListChatTurnsResult" -> rt(ListChatTurnsResult.serializer())
"ReadChatTurnsParams" -> rt(ReadChatTurnsParams.serializer())
"ReadChatTurnsResult" -> rt(ReadChatTurnsResult.serializer())
"SearchChatTurnsParams" -> rt(SearchChatTurnsParams.serializer())
"SearchChatTurnsResult" -> rt(SearchChatTurnsResult.serializer())
"ChatSource" -> rt(ChatSource.serializer())
"Snapshot" -> rt(Snapshot.serializer())
"SubscribeParams" -> rt(SubscribeParams.serializer())
Expand Down
Loading