@peer-agent/protocol 0.0.12 → 0.0.13
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 -0
- package/dist/index.js +1 -0
- package/dist/model-menu.d.ts +20 -0
- package/dist/model-menu.js +25 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { SelectionRange, SelectionReference, SelectionDraft, SelectionOrigin, SelectionChildSession, SelectionChildSummary, SelectionChildrenPage, SelectionChildRead } from './selection-reference.ts';
|
|
2
|
+
export { buildModelMenuGroups, modelMenuChannelName, type ModelMenuRow } from './model-menu.ts';
|
|
2
3
|
export type LocalAccessLevel = 'ask_before_local' | 'session_local' | 'restricted_local' | 'full_local';
|
|
3
4
|
export type { ConversationLifetimeUsage, ProviderRequestUsage, RuntimeTurnUsage, UsageAmounts, UsageScope, } from './usage-accounting.ts';
|
|
4
5
|
export type CapabilityRiskLevel = 'L0_inert' | 'L1_local_read' | 'L2_local_write' | 'L3_external_write' | 'L4_privileged' | 'L5_destructive';
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Presentation-only model menu projection shared by local clients. No sorting or deduplication. */
|
|
2
|
+
export declare function modelMenuChannelName(name: string | undefined, model: string, authMethod: string | undefined, isZh: boolean): string;
|
|
3
|
+
export interface ModelMenuRow {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly groupId?: string;
|
|
6
|
+
readonly groupLabel: string;
|
|
7
|
+
readonly model: string;
|
|
8
|
+
readonly modelLabel?: string;
|
|
9
|
+
readonly available: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function buildModelMenuGroups(rows: readonly ModelMenuRow[], hideDisabled?: boolean): {
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
items: {
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
}[];
|
|
20
|
+
}[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Presentation-only model menu projection shared by local clients. No sorting or deduplication. */
|
|
2
|
+
export function modelMenuChannelName(name, model, authMethod, isZh) {
|
|
3
|
+
const trimmed = name?.trim();
|
|
4
|
+
if (authMethod === 'oauth_chatgpt' && (!trimmed || trimmed === 'ChatGPT 订阅' || trimmed === 'ChatGPT Subscription')) {
|
|
5
|
+
return isZh ? 'ChatGPT 订阅' : 'ChatGPT Subscription';
|
|
6
|
+
}
|
|
7
|
+
return trimmed || model;
|
|
8
|
+
}
|
|
9
|
+
export function buildModelMenuGroups(rows, hideDisabled = false) {
|
|
10
|
+
const groups = new Map();
|
|
11
|
+
for (const row of rows) {
|
|
12
|
+
const key = row.groupId || row.id;
|
|
13
|
+
let group = groups.get(key);
|
|
14
|
+
if (!group) {
|
|
15
|
+
group = { id: key, label: row.groupLabel, items: [] };
|
|
16
|
+
groups.set(key, group);
|
|
17
|
+
}
|
|
18
|
+
if (!hideDisabled || row.available) {
|
|
19
|
+
group.items.push({ id: row.id, label: row.modelLabel || row.model, disabled: !row.available });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return [...groups.values()]
|
|
23
|
+
.filter((group) => !hideDisabled || group.items.length > 0)
|
|
24
|
+
.map((group) => ({ ...group, disabled: group.items.every((item) => item.disabled) }));
|
|
25
|
+
}
|