Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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 @@ -131,4 +131,4 @@ void testOnDidChangeFeatureFlagsWithEmptyFeatureFlags() {
verify(mockFeatureFlags).setByokEnabled(true);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public class CopilotEventConstants {
*/
private static final String TOPIC_MCP = TOPIC_BASE + "MCP/";

/**
* Topic for quota events.
*/
private static final String TOPIC_QUOTA = TOPIC_BASE + "QUOTA/";

/**
* Topic for Next Edit Suggestion (NES) events.
*/
Expand Down Expand Up @@ -161,6 +166,11 @@ public class CopilotEventConstants {
*/
public static final String TOPIC_RATE_LIMIT_WARNING = TOPIC_CHAT + "RATE_LIMIT_WARNING";

/**
* Event when a quota warning notification is received from the language server.
*/
public static final String TOPIC_QUOTA_WARNING = TOPIC_QUOTA + "WARNING";

/**
* Event when custom prompts, skills, agents, or instructions change on the language server. Clients should re-fetch
* conversation templates on receipt.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import com.microsoft.copilot.eclipse.core.lsp.protocol.codingagent.CodingAgentMessageRequestParams;
import com.microsoft.copilot.eclipse.core.lsp.protocol.codingagent.CodingAgentMessageResult;
import com.microsoft.copilot.eclipse.core.lsp.protocol.policy.DidChangePolicyParams;
import com.microsoft.copilot.eclipse.core.lsp.protocol.quota.QuotaWarningParams;
import com.microsoft.copilot.eclipse.core.utils.FileUtils;
import com.microsoft.copilot.eclipse.core.utils.PlatformUtils;

Expand Down Expand Up @@ -353,6 +354,17 @@ public CompletableFuture<CodingAgentMessageResult> onCodingAgentMessage(CodingAg
return CompletableFuture.completedFuture(result);
}

/**
* Notify when a quota warning is received from the language server.
*/
@JsonNotification("copilot/quotaWarning")
Comment thread
jdneo marked this conversation as resolved.
public void onQuotaWarning(QuotaWarningParams params) {
CopilotCore.LOGGER.info("Quota warning received: " + params);
if (eventBroker != null) {
eventBroker.post(CopilotEventConstants.TOPIC_QUOTA_WARNING, params);
}
}

/**
* Reads the contents and stats of a file given its URI.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
import java.util.Objects;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.eclipse.lsp4j.jsonrpc.validation.NonNull;

/**
* Result of a chat creation.
*/
public class ChatCreateResult {
@NonNull
Comment thread
ethanyhou marked this conversation as resolved.
private String conversationId;
@NonNull
private String turnId;
private String agentSlug;
private String modelName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ public String getErrorReason() {
return error != null ? error.getReason() : null;
}

/**
* Returns the BYOK model-provider name from the error payload, when present.
*
* @return the name of the BYOK model provider that produced the error, or {@code null} for built-in models.
*/
public String getErrorModelProviderName() {
return error != null ? error.getModelProviderName() : null;
}

public List<AgentRound> getAgentRounds() {
return editAgentRounds;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
import java.util.Objects;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.eclipse.lsp4j.jsonrpc.validation.NonNull;

/**
* Result of a chat turn.
*/
public class ChatTurnResult {
@NonNull
Comment thread
ethanyhou marked this conversation as resolved.
private String conversationId;
@NonNull
private String turnId;
private String agentSlug;
private String modelName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class ConversationError {
private String reason;
private boolean responseIsIncomplete;
private boolean responseIsFiltered;
private String modelProviderName;

public void setMessage(String message) {
this.message = message;
Expand All @@ -40,6 +41,10 @@ public void setResponseIsFiltered(boolean responseIsFiltered) {
this.responseIsFiltered = responseIsFiltered;
}

public void setModelProviderName(String modelProviderName) {
this.modelProviderName = modelProviderName;
}

public String getMessage() {
return message;
}
Expand All @@ -60,9 +65,17 @@ public boolean getResponseIsFiltered() {
return responseIsFiltered;
}

/**
* The name of the model provider that produced the error, when the failing request was routed to a custom
* Bring-Your-Own-Key (BYOK) model. {@code null} or blank for built-in Copilot models.
*/
public String getModelProviderName() {
return modelProviderName;
}

@Override
public int hashCode() {
return Objects.hash(message, code, reason, responseIsIncomplete, responseIsFiltered);
return Objects.hash(message, code, reason, responseIsIncomplete, responseIsFiltered, modelProviderName);
}

@Override
Expand All @@ -75,7 +88,8 @@ public boolean equals(Object o) {
}
ConversationError that = (ConversationError) o;
return Objects.equals(message, that.message) && code == that.code && Objects.equals(reason, that.reason)
&& responseIsIncomplete == that.responseIsIncomplete && responseIsFiltered == that.responseIsFiltered;
&& responseIsIncomplete == that.responseIsIncomplete && responseIsFiltered == that.responseIsFiltered
&& Objects.equals(modelProviderName, that.modelProviderName);
}

@Override
Expand All @@ -86,6 +100,7 @@ public String toString() {
builder.append("reason", reason);
builder.append("responseIsIncomplete", responseIsIncomplete);
builder.append("responseIsFiltered", responseIsFiltered);
builder.append("modelProviderName", modelProviderName);
return builder.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

package com.microsoft.copilot.eclipse.core.lsp.protocol.quota;

import com.google.gson.annotations.SerializedName;

/**
* Parameters for the {@code copilot/quotaWarning} notification, sent by the language server when
* the user crosses a quota usage threshold or starts consuming overages.
*
* @param title warning title (e.g. "Copilot Quota Usage Alert")
* @param message human-readable warning message
* @param severity severity level, either {@code "warning"} or {@code "info"}
* @param chat current chat quota snapshot, when available
* @param completions current completions quota snapshot, when available
* @param premiumInteractions current premium interactions quota snapshot, when available
* @param copilotPlan the user's Copilot plan
*/
public record QuotaWarningParams(String title, String message, String severity, QuotaSnapshotParams chat,
Comment thread
ethanyhou marked this conversation as resolved.
QuotaSnapshotParams completions,
@SerializedName("premium_interactions") QuotaSnapshotParams premiumInteractions, String copilotPlan) {
}
Comment thread
ethanyhou marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ private void applyConversationError(ReplyData reply, ConversationError error) {
ErrorData errorData = new ErrorData();
errorData.setMessage(error.getMessage());
errorData.setCode(error.getCode());
errorData.setModelProviderName(error.getModelProviderName());
ErrorMessageData em = new ErrorMessageData();
em.setError(errorData);
reply.getErrorMessages().add(em);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ public String toString() {
public static class ErrorData {
private String message;
private int code;
private String modelProviderName;
private Map<String, Object> data;

public String getMessage() {
Expand All @@ -458,6 +459,18 @@ public void setCode(int code) {
this.code = code;
}

/**
* The BYOK model provider responsible for the error, or {@code null} when the failing model was a
* built-in Copilot model.
*/
public String getModelProviderName() {
return modelProviderName;
}

public void setModelProviderName(String modelProviderName) {
this.modelProviderName = modelProviderName;
}

public Map<String, Object> getData() {
return data;
}
Expand All @@ -468,7 +481,7 @@ public void setData(Map<String, Object> data) {

@Override
public int hashCode() {
return Objects.hash(code, data, message);
return Objects.hash(code, data, message, modelProviderName);
}

@Override
Expand All @@ -483,14 +496,16 @@ public boolean equals(Object obj) {
return false;
}
ErrorData other = (ErrorData) obj;
return code == other.code && Objects.equals(data, other.data) && Objects.equals(message, other.message);
return code == other.code && Objects.equals(data, other.data) && Objects.equals(message, other.message)
&& Objects.equals(modelProviderName, other.modelProviderName);
}

@Override
public String toString() {
ToStringBuilder builder = new ToStringBuilder(this);
builder.append("message", message);
builder.append("code", code);
builder.append("modelProviderName", modelProviderName);
builder.append("data", data);
return builder.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ void testMessagesInitialization() {
assertNotNull(Messages.menu_signToGitHub);
assertNotNull(Messages.menu_signOutOfGitHub);
}
}
}
1 change: 1 addition & 0 deletions com.microsoft.copilot.eclipse.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Require-Bundle: com.microsoft.copilot.eclipse.core;bundle-version="0.15.0",
org.eclipse.ui;bundle-version="3.205.0",
org.eclipse.ui.navigator;bundle-version="3.12.200",
org.eclipse.jface.text;bundle-version="3.24.200",
org.eclipse.jface.notifications;bundle-version="0.7.0",
Comment thread
ethanyhou marked this conversation as resolved.
Outdated
Comment thread
ethanyhou marked this conversation as resolved.
Outdated
org.eclipse.core.runtime;bundle-version="[3.30.0,4.0.0)",
org.eclipse.core.expressions,
org.eclipse.jdt.annotation;resolution:=optional,
Expand Down
Loading
Loading