@adecore/agent-contracts 0.37.1 → 0.37.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/model.d.ts +14 -0
- package/dist/model.js +17 -0
- package/package.json +2 -2
- package/src/index.ts +6 -0
- package/src/model.ts +31 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { KNOWN_AGENT_KINDS, type KnownAgentKind, AGENT_KIND_MAX_LENGTH, AgentKin
|
|
|
2
2
|
export { ChatIdSchema, type ChatId, ChatContextBreakdownSchema, type ChatContextBreakdown, ChatUsageSchema, type ChatUsage, CHAT_ATTACHMENTS_MAX_BYTES, CHAT_ATTACHMENT_MAX_BYTES, CHAT_ATTACHMENTS_MAX_COUNT, attachmentBytes, attachmentImageMime, ChatAttachmentUploadSchema, type ChatAttachmentUpload, ChatAttachmentUploadsSchema, ChatAttachmentSchema, type ChatAttachment, ChatUiChoiceOriginSchema, type ChatUiChoiceOrigin, ChatUiAnswerSchema, type ChatUiAnswer, ChatQuoteSourceSchema, type ChatQuoteSource, ChatQueuedMessageSchema, type ChatQueuedMessage, ChatBackgroundTaskSchema, type ChatBackgroundTask, ChatTurnLimitSchema, type ChatTurnLimit, ChatGoalStatusSchema, type ChatGoalStatus, ChatGoalSchema, type ChatGoal, ChatQuestionSchema, type ChatQuestion, ChatRequestKindSchema, type ChatRequestKind, CHAT_REQUEST_LIMITS, ChatRequestApprovalSchema, type ChatRequestApproval, ChatRequestSummarySchema, type ChatRequestSummary, ChatInfoSchema, type ChatInfo, ChatSkillSourceSchema, type ChatSkillSource, ChatSkillSchema, type ChatSkill, SkillsListPayloadSchema, type SkillsListPayload, SkillsListResultSchema, type SkillsListResult, ChatUserItemSchema, ChatUiQueryReadingSchema, type ChatUiQueryReading, ChatUiLinkReadingSchema, type ChatUiLinkReading, ChatUiPlaceReadingSchema, type ChatUiPlaceReading, ChatUiQueryStateSchema, type ChatUiQueryState, ChatAssistantItemSchema, ChatThinkingItemSchema, ChatToolStateSchema, type ChatToolState, ChatToolProgressSchema, type ChatToolProgress, ChatFileChangeSchema, type ChatFileChange, ChatSubagentStatusSchema, type ChatSubagentStatus, ChatWorkflowPhaseSchema, type ChatWorkflowPhase, ChatWorkflowAgentSchema, type ChatWorkflowAgent, ChatWorkflowSchema, type ChatWorkflow, workflowAgentRef, workflowAgentIdOf, ChatToolItemSchema, ChatSubagentUsageSchema, type ChatSubagentUsage, HOST_TASK_ORIGIN, ChatSubagentItemSchema, ChatApprovalDecisionSchema, type ChatApprovalDecision, ChatApprovalItemSchema, ChatQuestionItemSchema, ChatCheckpointFileSchema, type ChatCheckpointFile, ChatCheckpointDiffSchema, type ChatCheckpointDiff, ChatTurnItemSchema, notResumedNote, abortedByMachine, ENDED_NOTE_PREFIX, abortedByEnd, activeSubagents, WAITING_NOTE_PREFIX, ChatNoteItemSchema, ChatCompactionItemSchema, ChatItemSchema, type ChatItem, type ChatUserItem, type ChatAssistantItem, type ChatThinkingItem, type ChatToolItem, type ChatSubagentItem, type ChatApprovalItem, type ChatQuestionItem, type ChatTurnItem, type ChatNoteItem, type ChatCompactionItem, ChatEventSchema, type ChatEvent, ChatEventEnvelopeSchema, type ChatEventEnvelope, ChatCreatePayloadSchema, type ChatCreatePayload, ChatConfigurePayloadSchema, type ChatConfigurePayload, ChatPreferencesPayloadSchema, type ChatPreferencesPayload, ChatTargetPayloadSchema, type ChatTargetPayload, ChatClearPayloadSchema, type ChatClearPayload, ChatCancelPayloadSchema, type ChatCancelPayload, ChatAttachPayloadSchema, ChatHistoryPayloadSchema, ChatHistoryPageSchema, ChatHistoryResultSchema, type ChatHistoryResult, ChatSubagentPayloadSchema, type ChatSubagentPayload, ChatStopSubagentPayloadSchema, type ChatStopSubagentPayload, ChatGoalActionSchema, type ChatGoalAction, ChatGoalPayloadSchema, type ChatGoalPayload, ChatStopTaskPayloadSchema, type ChatStopTaskPayload, ChatSubagentPageSchema, ChatSubagentSourceSchema, type ChatSubagentSource, ChatSubagentResultSchema, type ChatSubagentResult, ChatStatusEventSchema, type ChatStatusEvent, ChatSubagentChangedEventSchema, type ChatSubagentChangedEvent, CHAT_BOOKMARK_LIMITS, ChatBookmarkSchema, type ChatBookmark, ChatBookmarksSchema, ChatAddBookmarkPayloadSchema, type ChatAddBookmarkPayload, ChatRenameBookmarkPayloadSchema, type ChatRenameBookmarkPayload, ChatRemoveBookmarkPayloadSchema, type ChatRemoveBookmarkPayload, ChatBookmarksResultSchema, type ChatBookmarksResult, ChatBookmarksEventSchema, type ChatBookmarksEvent, ChatRemoveVisualPayloadSchema, type ChatRemoveVisualPayload, ChatVisualsResultSchema, type ChatVisualsResult, ChatVisualsEventSchema, type ChatVisualsEvent, ChatAttachResultSchema, type ChatAttachResult, ChatDeliverySchema, type ChatDelivery, ChatSendPayloadSchema, type ChatSendPayload, ChatSendResultSchema, type ChatSendResult, ChatUiChoicePayloadSchema, type ChatUiChoicePayload, ChatUiQueryPayloadSchema, type ChatUiQueryPayload, ChatUiLinkPayloadSchema, type ChatUiLinkPayload, ChatQueuePayloadSchema, type ChatQueuePayload, ChatUnqueueResultSchema, type ChatUnqueueResult, ChatApprovePayloadSchema, type ChatApprovePayload, ChatDismissPayloadSchema, type ChatDismissPayload, ChatAnswerPayloadSchema, type ChatAnswerPayload, ChatTurnDiffPayloadSchema, type ChatTurnDiffPayload, ChatTurnDiffResultSchema, type ChatTurnDiffResult, CHAT_FORK_TITLE_MAX, ChatForkPayloadSchema, type ChatForkPayload, ChatForkResultSchema, type ChatForkResult, ChatContinueOnPayloadSchema, type ChatContinueOnPayload, ChatContinueOnResultSchema, type ChatContinueOnResult, ChatSummarizePayloadSchema, type ChatSummarizePayload, ChatSummarizeResultSchema, type ChatSummarizeResult, ChatForkInfoPayloadSchema, type ChatForkInfoPayload, ChatForkInfoResultSchema, type ChatForkInfoResult, ChatListResultSchema, type ChatListResult, GeneratedImageInputSchema, type GeneratedImageInput, generatedImageAttachment } from './chat.ts';
|
|
3
3
|
export { ErrorSchema, type WireError, RequestSchema, type Request, ReplyOkSchema, type ReplyOk, ReplyErrorSchema, type ReplyError, ReplySchema, type Reply, EventSchema, type Event, ServerFrameSchema, type ServerFrame, type ParseResult, parseRequest, parseServerFrame } from './envelope.ts';
|
|
4
4
|
export { SessionIdSchema, type SessionId } from './ids.ts';
|
|
5
|
-
export { ModelOptionChoiceSchema, type ModelOptionChoice, ModelOptionDescriptorSchema, type ModelOptionDescriptor, ModelInfoSchema, type ModelInfo, ModelSelectionSchema, type ModelSelection, ModelCatalogProfileSchema, type ModelCatalogProfile, ModelCatalogEntrySchema, type ModelCatalogEntry, ModelCatalogDataSchema, type ModelCatalogData, RuntimeModeSchema, type RuntimeMode, ProviderCapabilitiesSchema, type ProviderCapabilities, ProviderPlatformSchema, type ProviderPlatform, ProviderSignInSchema, type ProviderSignIn, ProviderInstallSchema, type ProviderInstall, ProviderInfoSchema, type ProviderInfo, ProviderListResultSchema, type ProviderListResult, resumeCommandFor } from './model.ts';
|
|
5
|
+
export { ModelOptionChoiceSchema, type ModelOptionChoice, ModelOptionDescriptorSchema, type ModelOptionDescriptor, ModelInfoSchema, type ModelInfo, ModelSelectionSchema, type ModelSelection, ModelCatalogProfileSchema, type ModelCatalogProfile, ModelCatalogEntrySchema, type ModelCatalogEntry, ModelCatalogDataSchema, type ModelCatalogData, RuntimeModeSchema, type RuntimeMode, ProviderCapabilitiesSchema, type ProviderCapabilities, ProviderPlatformSchema, type ProviderPlatform, ProviderSignInSchema, type ProviderSignIn, ProviderInstallSchema, type ProviderInstall, ProviderInfoSchema, type ProviderInfo, FRONTIER_PROVIDER_KINDS, API_PROVIDER_KINDS, type ProviderPickerGroup, type ProviderPickerGroups, providerGroupOf, pickerGroupsOf, ProviderListResultSchema, type ProviderListResult, resumeCommandFor } from './model.ts';
|
|
6
6
|
export type { FramePort } from './port.ts';
|
|
7
7
|
export { EmptySchema, AGENT_REQUEST_SCHEMAS, AGENT_EVENT_SCHEMAS, type AgentRequestType, type AgentEventType } from './protocol.ts';
|
|
8
8
|
export { ProviderAccountIdSchema, type ProviderAccountId, ProviderAccountVariableSchema, type ProviderAccountVariable, ProviderAccountSchema, type ProviderAccount, ProviderAccountStateSchema, type ProviderAccountState, ProviderAccountStatusSchema, type ProviderAccountStatus, ProviderAccountMapSchema, type ProviderAccountMap, ProviderAccountsSchema, type ProviderAccounts, ProviderAccountsSavePayloadSchema, type ProviderAccountsSavePayload, ProviderAccountCreatePayloadSchema, type ProviderAccountCreatePayload, ProviderAccountCreateResultSchema, type ProviderAccountCreateResult, ProviderAccountWatchLoginPayloadSchema, type ProviderAccountWatchLoginPayload } from './provider-accounts.ts';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { KNOWN_AGENT_KINDS, AGENT_KIND_MAX_LENGTH, AgentKindSchema, isKnownAgent
|
|
|
3
3
|
export { ChatIdSchema, ChatContextBreakdownSchema, ChatUsageSchema, CHAT_ATTACHMENTS_MAX_BYTES, CHAT_ATTACHMENT_MAX_BYTES, CHAT_ATTACHMENTS_MAX_COUNT, attachmentBytes, attachmentImageMime, ChatAttachmentUploadSchema, ChatAttachmentUploadsSchema, ChatAttachmentSchema, ChatUiChoiceOriginSchema, ChatUiAnswerSchema, ChatQuoteSourceSchema, ChatQueuedMessageSchema, ChatBackgroundTaskSchema, ChatTurnLimitSchema, ChatGoalStatusSchema, ChatGoalSchema, ChatQuestionSchema, ChatRequestKindSchema, CHAT_REQUEST_LIMITS, ChatRequestApprovalSchema, ChatRequestSummarySchema, ChatInfoSchema, ChatSkillSourceSchema, ChatSkillSchema, SkillsListPayloadSchema, SkillsListResultSchema, ChatUserItemSchema, ChatUiQueryReadingSchema, ChatUiLinkReadingSchema, ChatUiPlaceReadingSchema, ChatUiQueryStateSchema, ChatAssistantItemSchema, ChatThinkingItemSchema, ChatToolStateSchema, ChatToolProgressSchema, ChatFileChangeSchema, ChatSubagentStatusSchema, ChatWorkflowPhaseSchema, ChatWorkflowAgentSchema, ChatWorkflowSchema, workflowAgentRef, workflowAgentIdOf, ChatToolItemSchema, ChatSubagentUsageSchema, HOST_TASK_ORIGIN, ChatSubagentItemSchema, ChatApprovalDecisionSchema, ChatApprovalItemSchema, ChatQuestionItemSchema, ChatCheckpointFileSchema, ChatCheckpointDiffSchema, ChatTurnItemSchema, notResumedNote, abortedByMachine, ENDED_NOTE_PREFIX, abortedByEnd, activeSubagents, WAITING_NOTE_PREFIX, ChatNoteItemSchema, ChatCompactionItemSchema, ChatItemSchema, ChatEventSchema, ChatEventEnvelopeSchema, ChatCreatePayloadSchema, ChatConfigurePayloadSchema, ChatPreferencesPayloadSchema, ChatTargetPayloadSchema, ChatClearPayloadSchema, ChatCancelPayloadSchema, ChatAttachPayloadSchema, ChatHistoryPayloadSchema, ChatHistoryPageSchema, ChatHistoryResultSchema, ChatSubagentPayloadSchema, ChatStopSubagentPayloadSchema, ChatGoalActionSchema, ChatGoalPayloadSchema, ChatStopTaskPayloadSchema, ChatSubagentPageSchema, ChatSubagentSourceSchema, ChatSubagentResultSchema, ChatStatusEventSchema, ChatSubagentChangedEventSchema, CHAT_BOOKMARK_LIMITS, ChatBookmarkSchema, ChatBookmarksSchema, ChatAddBookmarkPayloadSchema, ChatRenameBookmarkPayloadSchema, ChatRemoveBookmarkPayloadSchema, ChatBookmarksResultSchema, ChatBookmarksEventSchema, ChatRemoveVisualPayloadSchema, ChatVisualsResultSchema, ChatVisualsEventSchema, ChatAttachResultSchema, ChatDeliverySchema, ChatSendPayloadSchema, ChatSendResultSchema, ChatUiChoicePayloadSchema, ChatUiQueryPayloadSchema, ChatUiLinkPayloadSchema, ChatQueuePayloadSchema, ChatUnqueueResultSchema, ChatApprovePayloadSchema, ChatDismissPayloadSchema, ChatAnswerPayloadSchema, ChatTurnDiffPayloadSchema, ChatTurnDiffResultSchema, CHAT_FORK_TITLE_MAX, ChatForkPayloadSchema, ChatForkResultSchema, ChatContinueOnPayloadSchema, ChatContinueOnResultSchema, ChatSummarizePayloadSchema, ChatSummarizeResultSchema, ChatForkInfoPayloadSchema, ChatForkInfoResultSchema, ChatListResultSchema, GeneratedImageInputSchema, generatedImageAttachment } from './chat.js';
|
|
4
4
|
export { ErrorSchema, RequestSchema, ReplyOkSchema, ReplyErrorSchema, ReplySchema, EventSchema, ServerFrameSchema, parseRequest, parseServerFrame } from './envelope.js';
|
|
5
5
|
export { SessionIdSchema } from './ids.js';
|
|
6
|
-
export { ModelOptionChoiceSchema, ModelOptionDescriptorSchema, ModelInfoSchema, ModelSelectionSchema, ModelCatalogProfileSchema, ModelCatalogEntrySchema, ModelCatalogDataSchema, RuntimeModeSchema, ProviderCapabilitiesSchema, ProviderPlatformSchema, ProviderSignInSchema, ProviderInstallSchema, ProviderInfoSchema, ProviderListResultSchema, resumeCommandFor } from './model.js';
|
|
6
|
+
export { ModelOptionChoiceSchema, ModelOptionDescriptorSchema, ModelInfoSchema, ModelSelectionSchema, ModelCatalogProfileSchema, ModelCatalogEntrySchema, ModelCatalogDataSchema, RuntimeModeSchema, ProviderCapabilitiesSchema, ProviderPlatformSchema, ProviderSignInSchema, ProviderInstallSchema, ProviderInfoSchema, FRONTIER_PROVIDER_KINDS, API_PROVIDER_KINDS, providerGroupOf, pickerGroupsOf, ProviderListResultSchema, resumeCommandFor } from './model.js';
|
|
7
7
|
export { EmptySchema, AGENT_REQUEST_SCHEMAS, AGENT_EVENT_SCHEMAS } from './protocol.js';
|
|
8
8
|
export { ProviderAccountIdSchema, ProviderAccountVariableSchema, ProviderAccountSchema, ProviderAccountStateSchema, ProviderAccountStatusSchema, ProviderAccountMapSchema, ProviderAccountsSchema, ProviderAccountsSavePayloadSchema, ProviderAccountCreatePayloadSchema, ProviderAccountCreateResultSchema, ProviderAccountWatchLoginPayloadSchema } from './provider-accounts.js';
|
|
9
9
|
export { isRecord } from './record.js';
|
package/dist/model.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { type AgentKind } from './agent.ts';
|
|
2
3
|
export declare const ModelOptionChoiceSchema: z.ZodObject<{
|
|
3
4
|
id: z.ZodString;
|
|
4
5
|
label: z.ZodString;
|
|
@@ -282,6 +283,19 @@ export declare const ProviderInfoSchema: z.ZodObject<{
|
|
|
282
283
|
}, z.core.$strip>>;
|
|
283
284
|
}, z.core.$strip>;
|
|
284
285
|
export type ProviderInfo = z.infer<typeof ProviderInfoSchema>;
|
|
286
|
+
export declare const FRONTIER_PROVIDER_KINDS: ReadonlySet<AgentKind>;
|
|
287
|
+
export declare const API_PROVIDER_KINDS: ReadonlySet<AgentKind>;
|
|
288
|
+
export type ProviderPickerGroup = 'frontier' | 'others' | 'api';
|
|
289
|
+
export interface ProviderPickerGroups<T> {
|
|
290
|
+
frontier: T[];
|
|
291
|
+
others: T[];
|
|
292
|
+
api: T[];
|
|
293
|
+
}
|
|
294
|
+
export declare function providerGroupOf(kind: AgentKind): ProviderPickerGroup;
|
|
295
|
+
export declare function pickerGroupsOf<T extends {
|
|
296
|
+
kind: AgentKind;
|
|
297
|
+
name: string;
|
|
298
|
+
}>(providers: readonly T[]): ProviderPickerGroups<T>;
|
|
285
299
|
export declare const ProviderListResultSchema: z.ZodObject<{
|
|
286
300
|
providers: z.ZodArray<z.ZodObject<{
|
|
287
301
|
kind: z.ZodString;
|
package/dist/model.js
CHANGED
|
@@ -148,6 +148,23 @@ export const ProviderInfoSchema = z.object({
|
|
|
148
148
|
// Absent from a host that knows no way to install this CLI, and from one older than this field.
|
|
149
149
|
install: ProviderInstallSchema.optional()
|
|
150
150
|
});
|
|
151
|
+
// The CLIs of the labs that train their own frontier models; a picker lists them before every other provider.
|
|
152
|
+
export const FRONTIER_PROVIDER_KINDS = new Set(['claude', 'codex']);
|
|
153
|
+
// Providers billed per key rather than a CLI's own sign-in; a picker lists them last. Named, since an agent of
|
|
154
|
+
// the ACP registry has no terminal either.
|
|
155
|
+
export const API_PROVIDER_KINDS = new Set(['anthropic-claude-api', 'nanogpt']);
|
|
156
|
+
export function providerGroupOf(kind) {
|
|
157
|
+
return FRONTIER_PROVIDER_KINDS.has(kind) ? 'frontier' : API_PROVIDER_KINDS.has(kind) ? 'api' : 'others';
|
|
158
|
+
}
|
|
159
|
+
let nameCollator = null;
|
|
160
|
+
/* The providers in the three groups of a picker, each by name. Names are proper names, so the runtime locale sorts them. */
|
|
161
|
+
export function pickerGroupsOf(providers) {
|
|
162
|
+
nameCollator ??= new Intl.Collator(undefined, { sensitivity: 'base' });
|
|
163
|
+
const collator = nameCollator;
|
|
164
|
+
const sorted = [...providers].sort((a, b) => collator.compare(a.name, b.name));
|
|
165
|
+
const inGroup = (group) => sorted.filter((provider) => providerGroupOf(provider.kind) === group);
|
|
166
|
+
return { frontier: inGroup('frontier'), others: inGroup('others'), api: inGroup('api') };
|
|
167
|
+
}
|
|
151
168
|
export const ProviderListResultSchema = z.object({
|
|
152
169
|
providers: z.array(ProviderInfoSchema)
|
|
153
170
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agent-contracts",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.2",
|
|
4
4
|
"description": "Schemas and port contracts for agent chats, provider accounts, models and usage.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"test": "bun --conditions=source test"
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@adecore/intelligent-ui": "0.37.
|
|
89
|
+
"@adecore/intelligent-ui": "0.37.2",
|
|
90
90
|
"zod": "^4.6.5"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -302,6 +302,12 @@ export {
|
|
|
302
302
|
type ProviderInstall,
|
|
303
303
|
ProviderInfoSchema,
|
|
304
304
|
type ProviderInfo,
|
|
305
|
+
FRONTIER_PROVIDER_KINDS,
|
|
306
|
+
API_PROVIDER_KINDS,
|
|
307
|
+
type ProviderPickerGroup,
|
|
308
|
+
type ProviderPickerGroups,
|
|
309
|
+
providerGroupOf,
|
|
310
|
+
pickerGroupsOf,
|
|
305
311
|
ProviderListResultSchema,
|
|
306
312
|
type ProviderListResult,
|
|
307
313
|
resumeCommandFor
|
package/src/model.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { AgentKindSchema } from './agent.ts';
|
|
2
|
+
import { AgentKindSchema, type AgentKind } from './agent.ts';
|
|
3
3
|
|
|
4
4
|
// Options a model exposes (effort, context window, thinking). Generic descriptors instead of
|
|
5
5
|
// per-provider enums: a new model is a catalog entry, not a code change.
|
|
@@ -178,6 +178,36 @@ export const ProviderInfoSchema = z.object({
|
|
|
178
178
|
});
|
|
179
179
|
export type ProviderInfo = z.infer<typeof ProviderInfoSchema>;
|
|
180
180
|
|
|
181
|
+
// The CLIs of the labs that train their own frontier models; a picker lists them before every other provider.
|
|
182
|
+
export const FRONTIER_PROVIDER_KINDS: ReadonlySet<AgentKind> = new Set(['claude', 'codex']);
|
|
183
|
+
|
|
184
|
+
// Providers billed per key rather than a CLI's own sign-in; a picker lists them last. Named, since an agent of
|
|
185
|
+
// the ACP registry has no terminal either.
|
|
186
|
+
export const API_PROVIDER_KINDS: ReadonlySet<AgentKind> = new Set(['anthropic-claude-api', 'nanogpt']);
|
|
187
|
+
|
|
188
|
+
export type ProviderPickerGroup = 'frontier' | 'others' | 'api';
|
|
189
|
+
|
|
190
|
+
export interface ProviderPickerGroups<T> {
|
|
191
|
+
frontier: T[];
|
|
192
|
+
others: T[];
|
|
193
|
+
api: T[];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function providerGroupOf(kind: AgentKind): ProviderPickerGroup {
|
|
197
|
+
return FRONTIER_PROVIDER_KINDS.has(kind) ? 'frontier' : API_PROVIDER_KINDS.has(kind) ? 'api' : 'others';
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
let nameCollator: Intl.Collator | null = null;
|
|
201
|
+
|
|
202
|
+
/* The providers in the three groups of a picker, each by name. Names are proper names, so the runtime locale sorts them. */
|
|
203
|
+
export function pickerGroupsOf<T extends { kind: AgentKind; name: string }>(providers: readonly T[]): ProviderPickerGroups<T> {
|
|
204
|
+
nameCollator ??= new Intl.Collator(undefined, { sensitivity: 'base' });
|
|
205
|
+
const collator = nameCollator;
|
|
206
|
+
const sorted = [...providers].sort((a, b) => collator.compare(a.name, b.name));
|
|
207
|
+
const inGroup = (group: ProviderPickerGroup): T[] => sorted.filter((provider) => providerGroupOf(provider.kind) === group);
|
|
208
|
+
return { frontier: inGroup('frontier'), others: inGroup('others'), api: inGroup('api') };
|
|
209
|
+
}
|
|
210
|
+
|
|
181
211
|
export const ProviderListResultSchema = z.object({
|
|
182
212
|
providers: z.array(ProviderInfoSchema)
|
|
183
213
|
});
|