Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/**
* Mirror of the Copilot extension's `FilterReason` (see
* `extensions/copilot/src/platform/networking/common/openai.ts`).
*/
export
const
enum
{
=
'hate'
,
=
'self_harm'
,
=
'sexual'
,
=
'violence'
,
=
'snippy'
,
=
'prompt'
}
/**
* Raw error payload forwarded from an agent host harness. This is the
* serialized `ChatFetchError` from the Copilot extension. Because it crosses
* the extension/core boundary as untyped JSON inside `_meta`, every field is
* optional and consumers type-cast based on `type`.
*/
export
interface
IChatFetchErrorPayload
{
readonly
:
|
string
;
readonly
?
:
string
;
readonly
?
:
string
;
readonly
?
:
string
;
readonly
?
:
string
|
undefined
;
readonly
?
:
|
string
;
readonly
?
:
number
;
readonly
?
:
string
;
readonly
?
:
boolean
;
readonly
?
:
{
?
:
string
;
?
:
string
}
;
}
/**
* The full forwarded chat error payload, including the user-context fields that
* the extension would normally read from the Copilot token. This is the value
* placed at `_meta.chatError` by the harnesses.
*/
export
interface
IForwardedChatError
{
readonly
:
;
readonly
?
:
string
;
readonly
?
:
boolean
;
readonly
?
:
string
;
}
const
RATE_LIMIT_LEARN_MORE_URL
=
'https://aka.ms/github-copilot-rate-limit-error'
;
const
FILTERED_DOCS_URL
=
'https://aka.ms/copilot-chat-filtered-docs'
;
const
GITHUB_SUPPORT_URL
=
'https://support.github.com/contact'
;
/**
* Localized "canceled" message. Mirrors the extension's `CanceledMessage`,
* which is intentionally not localized there; we localize it in core.
*/
const
:
=
{
:
localize
(
'chatError.canceled'
,
"Canceled"
)
}
;
/**
* Converts a number of seconds into a human readable, localized string like
* "6 hours 50 minutes". Based on the Copilot extension's
* `secondsToHumanReadableTime` (`extensions/copilot/src/util/common/time.ts`),
* but the unit fragments are externalized so they translate in non-English
* locales.
*/
function
secondsToHumanReadableTime
(
:
number
)
:
string
{
if
(
<
90
)
{
return
localize
(
'chatError.duration.seconds'
,
"{0} seconds"
,
)
;
}
const
=
.
floor
(
/
60
)
;
if
(
<=
5400
)
{
return
localize
(
'chatError.duration.minutes'
,
"{0} minutes"
,
)
;
}
const
=
.
floor
(
/
60
)
;
const
=
%
60
;
if
(
>
0
)
{
return
localize
(
'chatError.duration.hoursMinutes'
,
"{0} hours {1} minutes"
,
,
)
;
}
return
localize
(
'chatError.duration.hours'
,
"{0} hours"
,
)
;
}
function
getRateLimitMessage
(
:
,
:
string
|
undefined
)
:
string
{
const
=
.
?
secondsToHumanReadableTime
(
.
)
:
localize
(
'chatError.aMoment'
,
"a moment"
)
;
const
=
.
?.
;
if
(
?.
startsWith
(
'agent_mode_limit_exceeded'
)
)
{
// Rate limited in agent mode
return
localize
(
{
:
'chatError.rateLimit.agentMode'
,
:
[
`{Locked=']({'}`
]
}
,
"Sorry, you have exceeded the agent mode rate limit. Please switch to ask mode and try again in {0}. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
if
(
?.
startsWith
(
'model_overloaded'
)
||
?.
startsWith
(
'upstream_provider_rate_limit'
)
)
{
if
(
.
)
{
return
localize
(
{
:
'chatError.rateLimit.overloadedAuto'
,
:
[
`{Locked=']({'}`
]
}
,
"Sorry, the upstream model provider is currently experiencing high demand. Please try again in {0}. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
return
localize
(
{
:
'chatError.rateLimit.overloaded'
,
:
[
`{Locked=']({'}`
]
}
,
"Sorry, the upstream model provider is currently experiencing high demand. Please try again in {0} or consider switching to Auto. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
if
(
?.
startsWith
(
'user_global_rate_limited'
)
)
{
if
(
===
'free'
||
===
'individual'
||
===
'individual_pro'
||
===
'edu'
)
{
return
localize
(
{
:
'chatError.rateLimit.sessionUpgrade'
,
:
[
`{Locked=']({'}`
]
}
,
"You've hit your session rate limit. Please upgrade your plan or wait {0} for your limit to reset. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
return
localize
(
{
:
'chatError.rateLimit.session'
,
:
[
`{Locked=']({'}`
]
}
,
"You've hit your session rate limit. Please wait {0} for your limit to reset. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
if
(
?.
startsWith
(
'user_weekly_rate_limited'
)
)
{
if
(
.
)
{
const
=
new
Date
(
.
now
(
)
+
.
*
1000
)
;
const
=
.
toLocaleString
(
undefined
,
{
:
'numeric'
,
:
'long'
,
:
'numeric'
,
:
'numeric'
,
:
'2-digit'
}
)
;
if
(
.
)
{
return
localize
(
{
:
'chatError.rateLimit.weeklyDateAuto'
,
:
[
`{Locked=']({'}`
]
}
,
"You've reached your weekly rate limit. Please wait for your limit to reset on {0}. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
return
localize
(
{
:
'chatError.rateLimit.weeklyDate'
,
:
[
`{Locked=']({'}`
]
}
,
"You've reached your weekly rate limit. Please switch to the Auto model to continue working or wait for your limit to reset on {0}. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
if
(
.
)
{
return
localize
(
{
:
'chatError.rateLimit.weeklyAuto'
,
:
[
`{Locked=']({'}`
]
}
,
"You've reached your weekly rate limit. Please wait {0} for your limit to reset. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
return
localize
(
{
:
'chatError.rateLimit.weekly'
,
:
[
`{Locked=']({'}`
]
}
,
"You've reached your weekly rate limit. Please switch to the Auto model to continue working or wait {0} for your limit to reset. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
if
(
?.
startsWith
(
'user_model_rate_limited'
)
)
{
if
(
.
)
{
return
localize
(
{
:
'chatError.rateLimit.modelAuto'
,
:
[
`{Locked=']({'}`
]
}
,
"You've hit the rate limit for this model. Please try again in {0}. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
return
localize
(
{
:
'chatError.rateLimit.model'
,
:
[
`{Locked=']({'}`
]
}
,
"You've hit the rate limit for this model. Please try switching to Auto or try again in {0}. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
if
(
?.
startsWith
(
'integration_rate_limited'
)
)
{
return
localize
(
{
:
'chatError.rateLimit.integration'
,
:
[
`{Locked=']({'}`
]
}
,
"Sorry, GitHub Copilot Chat is currently experiencing high demand. Please try again in {0}. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
if
(
.
?.
&&
.
?.
)
{
if
(
.
)
{
return
localize
(
{
:
'chatError.rateLimit.serverAuto'
,
:
[
`{Locked=']({'}`
]
}
,
"Sorry, you have been rate-limited. Please wait {0} before trying again. [Learn More]({1})\n\nServer Error: {2}\nError Code: {3}"
,
,
RATE_LIMIT_LEARN_MORE_URL
,
.
.
,
.
.
)
;
}
return
localize
(
{
:
'chatError.rateLimit.server'
,
:
[
`{Locked=']({'}`
]
}
,
"Sorry, you have been rate-limited. Please wait {0} before trying again or consider switching to Auto. [Learn More]({1})\n\nServer Error: {2}\nError Code: {3}"
,
,
RATE_LIMIT_LEARN_MORE_URL
,
.
.
,
.
.
)
;
}
if
(
.
)
{
return
localize
(
{
:
'chatError.rateLimit.genericAuto'
,
:
[
`{Locked=']({'}`
]
}
,
"Sorry, your request was rate-limited. Please wait {0} before trying again. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
return
localize
(
{
:
'chatError.rateLimit.generic'
,
:
[
`{Locked=']({'}`
]
}
,
"Sorry, your request was rate-limited. Please wait {0} before trying again or consider switching to Auto. [Learn More]({1})"
,
,
RATE_LIMIT_LEARN_MORE_URL
)
;
}
export
function
getQuotaMessageForPlan
(
:
string
|
undefined
,
?
:
boolean
,
?
:
string
)
:
string
{
const
=
?
new
Date
(
)
.
toLocaleString
(
undefined
,
{
:
'numeric'
,
:
'long'
,
:
'numeric'
,
:
'numeric'
,
:
'2-digit'
}
)
:
undefined
;
if
(
)
{
switch
(
)
{
case
'free'
:
return
?
localize
(
'chatError.quota.ubb.freeDate'
,
"You've reached your monthly credit limit. Upgrade to Copilot Pro or wait until your credits reset on {0}."
,
)
:
localize
(
'chatError.quota.ubb.free'
,
"You've reached your monthly credit limit. Upgrade to Copilot Pro or wait for your credits to reset."
)
;
case
'individual'
:
return
?
localize
(
'chatError.quota.ubb.individualDate'
,
"You've reached your monthly credit limit. Please enable additional paid credits, upgrade to Copilot Pro+, or wait until your credits reset on {0}."
,
)
:
localize
(
'chatError.quota.ubb.individual'
,
"You've reached your monthly credit limit. Please enable additional paid credits, upgrade to Copilot Pro+, or wait for your credits to reset."
)
;
case
'edu'
:
return
?
localize
(
'chatError.quota.ubb.eduDate'
,
"You've reached your monthly credit limit. Please enable additional paid credits, upgrade to Copilot Pro, or wait until your credits reset on {0}."
,
)
:
localize
(
'chatError.quota.ubb.edu'
,
"You've reached your monthly credit limit. Please enable additional paid credits, upgrade to Copilot Pro, or wait for your credits to reset."
)
;
case
'individual_pro'
:
case
'individual_max'
:
return
?
localize
(
'chatError.quota.ubb.proDate'
,
"You've reached your monthly credit limit. Please enable additional paid credits or wait until your credits reset on {0}."
,
)
:
localize
(
'chatError.quota.ubb.pro'
,
"You've reached your monthly credit limit. Please enable additional paid credits or wait for your credits to reset."
)
;
case
'business'
:
case
'enterprise'
:
return
?
localize
(
'chatError.quota.ubb.businessDate'
,
"You've reached your credit limit. To continue working, please contact your organization's Copilot admin or wait until your credits reset on {0}."
,
)
:
localize
(
'chatError.quota.ubb.business'
,
"You've reached your credit limit. To continue working, please contact your organization's Copilot admin or wait for your credits to reset."
)
;
default
:
return
?
localize
(
'chatError.quota.ubb.defaultDate'
,
"You've reached your credit limit. For additional paid credits, please reach out to your organization's Copilot admin or wait until your credits reset on {0}."
,
)
:
localize
(
'chatError.quota.ubb.default'
,
"You've reached your credit limit. For additional paid credits, please reach out to your organization's Copilot admin or wait for your credits to reset."
)
;
}
}
switch
(
)
{
case
'free'
:
return
localize
(
'chatError.quota.free'
,
"You've reached your monthly chat messages quota. Upgrade to Copilot Pro or wait for your allowance to renew."
)
;
case
'individual'
:
return
localize
(
'chatError.quota.individual'
,
"You've exhausted your premium model quota. Please enable additional paid premium requests, upgrade to Copilot Pro+, or wait for your allowance to renew."
)
;
case
'edu'
:
return
localize
(
'chatError.quota.edu'
,
"You've exhausted your premium model quota. Please enable additional paid premium requests, upgrade to Copilot Pro, or wait for your allowance to renew."
)
;
case
'individual_pro'
:
case
'individual_max'
:
return
localize
(
'chatError.quota.pro'
,
"You've exhausted your premium model quota. Please enable additional paid premium requests or wait for your allowance to renew."
)
;
case
'business'
:
case
'enterprise'
:
return
localize
(
'chatError.quota.business'
,
"You've exhausted your credits. To continue working, please contact your organization's Copilot admin or wait for your allowance to renew."
)
;
default
:
return
localize
(
'chatError.quota.default'
,
"You've exhausted your premium model quota. For additional paid premium requests, please reach out to your organization's Copilot admin or wait for your allowance to renew."
)
;
}
}
function
getQuotaHitMessage
(
:
,
:
string
|
undefined
,
?
:
boolean
,
?
:
string
)
:
string
{
let
=
.
?.
;
if
(
===
'free_quota_exceeded'
)
{
=
'quota_exceeded'
;
// Remap this to the generic quota code so we get per plan handling
}
if
(
===
'quota_exceeded'
)
{
return
getQuotaMessageForPlan
(
,
,
)
;
}
else
if
(
===
'overage_limit_reached'
)
{
return
localize
(
{
:
'chatError.quota.overage'
,
:
[
`{Locked=']({'}`
]
}
,
"You cannot accrue additional premium requests at this time. Please contact [GitHub Support]({0}) to continue using Copilot."
,
GITHUB_SUPPORT_URL
)
;
}
else
if
(
===
'additional_spend_limit_reached'
)
{
return
localize
(
'chatError.quota.additionalSpend'
,
"You've reached your additional usage limit for your plan. Upgrade your plan to keep going."
"Sorry, the response was filtered by the Responsible AI Service. Please rephrase your prompt and try again. [Learn more]({0})."
,
FILTERED_DOCS_URL
)
;
}
return
localize
(
'chatError.filtered.default'
,
"Sorry, the response was filtered by the Responsible AI Service. Please rephrase your prompt and try again."
)
;
}
}
/**
* Builds the user-facing {@link IChatResponseErrorDetails} from a forwarded raw
* chat fetch error. This is the core analog of the Copilot extension's
* `getErrorDetailsFromChatFetchError`. Unlike the extension, core has no
* access to the GitHub outage status, so the outage note is never appended
* (assume no outage).
*/
export
function
getChatErrorDetailsFromFetchError
(
:
,
:
string
|
undefined
,
?
:
boolean
,
?
:
string
)
:
{
return
{
:
.
,
...
getChatErrorDetailsInner
(
,
,
,
)
}
;
}
function
getChatErrorDetailsInner
(
:
,
:
string
|
undefined
,
?
:
boolean
,
?
:
string
)
:
{
const
=
.
??
''
;
const
=
.
??
''
;
switch
(
.
)
{
case
.
:
return
{
:
localize
(
'chatError.offTopic'
,
"Sorry, but I can only assist with programming related questions."
"Sorry, there was a network error. Please try again later. Request id: {0}\n\nReason: {1}"
,
,
)
}
;
case
.
:
case
.
:
return
{
:
getFilteredMessage
(
.
??
''
)
,
:
true
,
:
.
,
}
;
case
.
:
return
{
:
localize
(
'chatError.somethingWrong'
,
"Sorry, something went wrong."
)
}
;
case
.
:
return
{
:
}
;
case
.
:
return
{
:
localize
(
'chatError.length'
,
"Sorry, the response hit the length limit. Please rephrase your prompt."
)
}
;
case
.
:
return
{
:
localize
(
'chatError.notFound'
,
"Sorry, the resource was not found."
)
}
;
case
.
:
return
{
:
localize
(
'chatError.unknown'
,
"Sorry, no response was returned."
)
}
;
case
.
:
return
{
:
localize
(
'chatError.extensionBlocked'
,
"Sorry, something went wrong."
)
}
;
case
.
:
// should be unreachable, retried within the endpoint
return
{
:
localize
(
'chatError.invalidStatefulMarker'
,
"Your chat session state is invalid, please start a new chat."
)
}
;
default
:
return
{
:
||
localize
(
'chatError.somethingWrong'
,
"Sorry, something went wrong."
)
}
;
}
}
/**
* Type guard for the forwarded chat error payload placed at `_meta.chatError`
* by the agent host harnesses.
*/
function
isForwardedChatError
(
:
unknown
)
:
is
{
return
!
!
&&
typeof
===
'object'
&&
'fetchError'
in
&&
!
!
(
as
)
.
&&
typeof
(
as
)
.
===
'object'
&&
typeof
(
as
)
.
.
===
'string'
;
}
/**
* Extracts and formats {@link IChatResponseErrorDetails} from the `_meta`
* forwarded by an agent host harness, if present. Returns `undefined` when no
* forwarded chat error is found so callers can fall back to their existing
* error handling.
*
* The agent host does not know the signed-in user's plan, so callers in core
* pass an {@link IChatErrorContext} (resolved from `IChatEntitlementService`)
* whose fields take precedence over the values forwarded in `_meta`.
*/
export
function
getChatErrorDetailsFromMeta
(
:
|
undefined
,
?
:
)
:
|
undefined
{
const
=
?.
;
const
=
?.
;
if
(
!
isForwardedChatError
(
)
)
{
return
undefined
;
}
return
getChatErrorDetailsFromFetchError
(
.
,
?.
??
.
,
?.
??
.
,
?.
??
.
,
)
;
}
/**
* User-context overrides for {@link getChatErrorDetailsFromMeta}. When a field
* is set it takes precedence over the value forwarded by the agent host. Core
* resolves these from `IChatEntitlementService`.
*/
export
interface
IChatErrorContext
{
readonly
?
:
string
;
readonly
?
:
boolean
;
readonly
?
:
string
;
}
/**
* Maps a core {@link ChatEntitlement} to the Copilot plan string understood by
* the quota/rate-limit message helpers (mirrors the Copilot extension's
* `CopilotToken.copilotPlan` values).
*/