@agent-native/toolkit 0.198.8 → 0.199.0-nightly-20261001064935
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/app/agentkit/react/components.d.ts.map +1 -1
- package/dist/app/agentkit/react/components.js +142 -56
- package/dist/app/agentkit/react/components.js.map +1 -1
- package/dist/app/chat/AgentKitAssistantChat.d.ts.map +1 -1
- package/dist/app/chat/AgentKitAssistantChat.js +34 -27
- package/dist/app/chat/AgentKitAssistantChat.js.map +1 -1
- package/dist/app/chat/AgentPanel.d.ts +2 -1
- package/dist/app/chat/AgentPanel.d.ts.map +1 -1
- package/dist/app/chat/AgentPanel.js +7 -4
- package/dist/app/chat/AgentPanel.js.map +1 -1
- package/dist/app/chat/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/app/chat/MultiTabAssistantChat.js +21 -4
- package/dist/app/chat/MultiTabAssistantChat.js.map +1 -1
- package/dist/app/chat/chat/run-recovery.d.ts +2 -1
- package/dist/app/chat/chat/run-recovery.d.ts.map +1 -1
- package/dist/app/chat/chat/run-recovery.js +13 -9
- package/dist/app/chat/chat/run-recovery.js.map +1 -1
- package/dist/app/i18n/catalogs/ar-SA.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/ar-SA.js +24 -2
- package/dist/app/i18n/catalogs/ar-SA.js.map +1 -1
- package/dist/app/i18n/catalogs/de-DE.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/de-DE.js +24 -2
- package/dist/app/i18n/catalogs/de-DE.js.map +1 -1
- package/dist/app/i18n/catalogs/en-US.d.ts +24 -2
- package/dist/app/i18n/catalogs/en-US.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/en-US.js +24 -2
- package/dist/app/i18n/catalogs/en-US.js.map +1 -1
- package/dist/app/i18n/catalogs/es-ES.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/es-ES.js +24 -2
- package/dist/app/i18n/catalogs/es-ES.js.map +1 -1
- package/dist/app/i18n/catalogs/fr-FR.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/fr-FR.js +24 -2
- package/dist/app/i18n/catalogs/fr-FR.js.map +1 -1
- package/dist/app/i18n/catalogs/hi-IN.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/hi-IN.js +24 -2
- package/dist/app/i18n/catalogs/hi-IN.js.map +1 -1
- package/dist/app/i18n/catalogs/ja-JP.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/ja-JP.js +24 -2
- package/dist/app/i18n/catalogs/ja-JP.js.map +1 -1
- package/dist/app/i18n/catalogs/ko-KR.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/ko-KR.js +24 -2
- package/dist/app/i18n/catalogs/ko-KR.js.map +1 -1
- package/dist/app/i18n/catalogs/pt-BR.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/pt-BR.js +24 -2
- package/dist/app/i18n/catalogs/pt-BR.js.map +1 -1
- package/dist/app/i18n/catalogs/zh-CN.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/zh-CN.js +24 -2
- package/dist/app/i18n/catalogs/zh-CN.js.map +1 -1
- package/dist/app/i18n/catalogs/zh-TW.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/zh-TW.js +24 -2
- package/dist/app/i18n/catalogs/zh-TW.js.map +1 -1
- package/dist/app/labs/LabsSettings.d.ts.map +1 -1
- package/dist/app/labs/LabsSettings.js +10 -2
- package/dist/app/labs/LabsSettings.js.map +1 -1
- package/dist/app/org/OrgSwitcher.d.ts.map +1 -1
- package/dist/app/org/OrgSwitcher.js +51 -9
- package/dist/app/org/OrgSwitcher.js.map +1 -1
- package/dist/app/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/app/settings/SettingsPanel.js +4 -145
- package/dist/app/settings/SettingsPanel.js.map +1 -1
- package/dist/app/settings/SettingsTabsPage.d.ts.map +1 -1
- package/dist/app/settings/SettingsTabsPage.js +27 -16
- package/dist/app/settings/SettingsTabsPage.js.map +1 -1
- package/dist/app/settings/model/ChatGPTSubscriptionRow.d.ts +24 -2
- package/dist/app/settings/model/ChatGPTSubscriptionRow.d.ts.map +1 -1
- package/dist/app/settings/model/ChatGPTSubscriptionRow.js +97 -26
- package/dist/app/settings/model/ChatGPTSubscriptionRow.js.map +1 -1
- package/dist/app/settings/model/ModelSettingsPage.d.ts.map +1 -1
- package/dist/app/settings/model/ModelSettingsPage.js +73 -22
- package/dist/app/settings/model/ModelSettingsPage.js.map +1 -1
- package/dist/app/settings/model/model-page-state.d.ts +12 -2
- package/dist/app/settings/model/model-page-state.d.ts.map +1 -1
- package/dist/app/settings/model/model-page-state.js +14 -1
- package/dist/app/settings/model/model-page-state.js.map +1 -1
- package/dist/app/settings/shell/bridge.d.ts +1 -1
- package/dist/app/settings/shell/bridge.d.ts.map +1 -1
- package/dist/app/settings/shell/bridge.js +1 -4
- package/dist/app/settings/shell/bridge.js.map +1 -1
- package/dist/app/settings/usage/UsagePage.d.ts.map +1 -1
- package/dist/app/settings/usage/UsagePage.js +3 -2
- package/dist/app/settings/usage/UsagePage.js.map +1 -1
- package/dist/composer/TiptapComposer.d.ts +1 -0
- package/dist/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/composer/TiptapComposer.js +10 -4
- package/dist/composer/TiptapComposer.js.map +1 -1
- package/dist/composer/runtime-adapters.d.ts +1 -0
- package/dist/composer/runtime-adapters.d.ts.map +1 -1
- package/dist/composer/runtime-adapters.js.map +1 -1
- package/package.json +4 -4
- package/src/app/agentkit/react/components.tsx +295 -98
- package/src/app/agentkit/react/lifecycle.spec.tsx +758 -17
- package/src/app/chat/AgentKitAssistantChat.spec.tsx +116 -7
- package/src/app/chat/AgentKitAssistantChat.tsx +100 -45
- package/src/app/chat/AgentPanel.header.spec.ts +9 -0
- package/src/app/chat/AgentPanel.tsx +10 -1
- package/src/app/chat/MultiTabAssistantChat.spec.tsx +115 -1
- package/src/app/chat/MultiTabAssistantChat.tsx +24 -4
- package/src/app/chat/chat/run-recovery.spec.tsx +31 -0
- package/src/app/chat/chat/run-recovery.tsx +22 -5
- package/src/app/i18n/catalogs/ar-SA.ts +31 -2
- package/src/app/i18n/catalogs/de-DE.ts +33 -2
- package/src/app/i18n/catalogs/en-US.ts +33 -2
- package/src/app/i18n/catalogs/es-ES.ts +34 -2
- package/src/app/i18n/catalogs/fr-FR.ts +33 -2
- package/src/app/i18n/catalogs/hi-IN.ts +34 -2
- package/src/app/i18n/catalogs/ja-JP.ts +31 -2
- package/src/app/i18n/catalogs/ko-KR.ts +31 -2
- package/src/app/i18n/catalogs/pt-BR.ts +33 -2
- package/src/app/i18n/catalogs/zh-CN.ts +32 -2
- package/src/app/i18n/catalogs/zh-TW.ts +32 -2
- package/src/app/labs/LabsSettings.tsx +13 -3
- package/src/app/org/OrgSwitcher.spec.tsx +75 -0
- package/src/app/org/OrgSwitcher.tsx +104 -34
- package/src/app/settings/SettingsPanel.connections.spec.tsx +25 -5
- package/src/app/settings/SettingsPanel.tsx +3 -286
- package/src/app/settings/SettingsTabsPage.spec.tsx +110 -17
- package/src/app/settings/SettingsTabsPage.tsx +36 -20
- package/src/app/settings/model/ChatGPTSubscriptionRow.tsx +316 -60
- package/src/app/settings/model/ModelSettingsPage.spec.tsx +599 -20
- package/src/app/settings/model/ModelSettingsPage.tsx +114 -25
- package/src/app/settings/model/model-page-state.spec.ts +46 -0
- package/src/app/settings/model/model-page-state.ts +27 -2
- package/src/app/settings/shell/bridge.spec.ts +3 -13
- package/src/app/settings/shell/bridge.ts +2 -5
- package/src/app/settings/shell/pages/app-group-pages.spec.tsx +50 -2
- package/src/app/settings/usage/UsagePage.spec.tsx +25 -1
- package/src/app/settings/usage/UsagePage.tsx +21 -1
- package/src/composer/PromptComposer.context.spec.tsx +22 -3
- package/src/composer/TiptapComposer.tsx +13 -4
- package/src/composer/runtime-adapters.tsx +1 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderKeyPolicyStatus } from "@agent-native/core/agent/actions/manage-provider-key-policy";
|
|
2
|
-
import {
|
|
2
|
+
import { CHATGPT_SUBSCRIPTION_ENGINE_NAME } from "@agent-native/core/agent/chatgpt-subscription-contract";
|
|
3
3
|
import {
|
|
4
4
|
setAgentEngineDefaultModel,
|
|
5
5
|
type AgentEngineKeyScope,
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
getAgentProviderOption,
|
|
14
14
|
type AgentProviderId,
|
|
15
15
|
} from "@agent-native/core/client/agent-provider-catalog";
|
|
16
|
+
import type { ChatModelEngineEntry } from "@agent-native/core/client/chat-model-groups";
|
|
16
17
|
import { callAction, useActionQuery } from "@agent-native/core/client/hooks";
|
|
17
18
|
import { useFormatters, useT } from "@agent-native/core/client/i18n";
|
|
18
19
|
import { useLabState } from "@agent-native/core/client/labs/use-lab";
|
|
@@ -61,6 +62,7 @@ import {
|
|
|
61
62
|
parseDefaultModelValue,
|
|
62
63
|
providerForEngine,
|
|
63
64
|
providerRows,
|
|
65
|
+
type ChatGPTModelCatalog,
|
|
64
66
|
type ModelProvidersListing,
|
|
65
67
|
type ProviderKeyRow,
|
|
66
68
|
type ProviderModelsRead,
|
|
@@ -76,6 +78,7 @@ const MAX_ITERATIONS_LABEL = "agentChat.settingsShell.search.maxIterations";
|
|
|
76
78
|
const BUILDER_LABEL = "Builder.io";
|
|
77
79
|
const CHATGPT_LABEL = "ChatGPT";
|
|
78
80
|
const POLICY_QUERY_KEY = ["action", "manage-provider-key-policy", {}] as const;
|
|
81
|
+
const ENGINES_QUERY_KEY = ["action", "manage-agent-engine", { action: "list" }];
|
|
79
82
|
const LOOP_QUERY_KEY = [
|
|
80
83
|
"action",
|
|
81
84
|
"manage-agent-loop-settings",
|
|
@@ -86,12 +89,65 @@ type DialogState =
|
|
|
86
89
|
| { mode: "add" }
|
|
87
90
|
| { mode: "manage"; provider: AgentProviderId; scope: AgentEngineKeyScope };
|
|
88
91
|
|
|
92
|
+
type ChatGPTSubscriptionStatusRead = {
|
|
93
|
+
connected: boolean;
|
|
94
|
+
activeAccountId: string | null;
|
|
95
|
+
};
|
|
96
|
+
|
|
89
97
|
/** `get-provider-models`, kept apart so a failed read never reads as "no models". */
|
|
90
98
|
type ModelsReadState =
|
|
91
99
|
| { status: "loading" }
|
|
92
100
|
| { status: "error"; retry: () => void }
|
|
93
101
|
| { status: "ready"; data: ProviderModelsRead };
|
|
94
102
|
|
|
103
|
+
/** The signed-in ChatGPT account's model list for the personal default. */
|
|
104
|
+
type ChatGPTModelsState =
|
|
105
|
+
| { status: "off" }
|
|
106
|
+
| { status: "loading" }
|
|
107
|
+
| { status: "error"; retry: () => void }
|
|
108
|
+
| { status: "ready"; catalog: ChatGPTModelCatalog };
|
|
109
|
+
|
|
110
|
+
function useChatGPTModels(
|
|
111
|
+
personalDefault: boolean,
|
|
112
|
+
connected: boolean,
|
|
113
|
+
accountId: string | null,
|
|
114
|
+
statusError: boolean,
|
|
115
|
+
retryStatus: () => void,
|
|
116
|
+
): ChatGPTModelsState {
|
|
117
|
+
const query = useQuery({
|
|
118
|
+
queryKey: [...ENGINES_QUERY_KEY, accountId],
|
|
119
|
+
enabled: personalDefault && connected && accountId !== null && !statusError,
|
|
120
|
+
queryFn: () =>
|
|
121
|
+
callAction<{ engines?: ChatModelEngineEntry[] }>(
|
|
122
|
+
"manage-agent-engine" as never,
|
|
123
|
+
{ action: "list" } as never,
|
|
124
|
+
),
|
|
125
|
+
select: (result): ChatGPTModelCatalog => {
|
|
126
|
+
const entry = result.engines?.find(
|
|
127
|
+
(engine) => engine.name === CHATGPT_SUBSCRIPTION_ENGINE_NAME,
|
|
128
|
+
);
|
|
129
|
+
// A catalog the server couldn't read is an error, not an empty list.
|
|
130
|
+
if (!entry || entry.configuredError) {
|
|
131
|
+
throw new Error(entry?.configuredError ?? "No ChatGPT model list.");
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
label: CHATGPT_LABEL,
|
|
135
|
+
models: [...(entry.supportedModels ?? [])],
|
|
136
|
+
displayNames: { ...entry.modelDisplayNames },
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
if (!personalDefault) return { status: "off" };
|
|
141
|
+
if (statusError) return { status: "error", retry: retryStatus };
|
|
142
|
+
if (!connected) return { status: "off" };
|
|
143
|
+
if (!accountId) return { status: "loading" };
|
|
144
|
+
if (query.data) return { status: "ready", catalog: query.data };
|
|
145
|
+
if (query.isError) {
|
|
146
|
+
return { status: "error", retry: () => void query.refetch() };
|
|
147
|
+
}
|
|
148
|
+
return { status: "loading" };
|
|
149
|
+
}
|
|
150
|
+
|
|
95
151
|
/**
|
|
96
152
|
* Settings › Agent › Model: Organization providers, Personal providers, and
|
|
97
153
|
* Organization settings (spec §5.6). Every control writes through an action
|
|
@@ -114,6 +170,30 @@ export default function ModelSettingsPage(_props: SettingsPageProps) {
|
|
|
114
170
|
const [dialog, setDialog] = useState<DialogState | null>(null);
|
|
115
171
|
const [removing, setRemoving] = useState<ProviderKeyRow | null>(null);
|
|
116
172
|
|
|
173
|
+
const chatgptLab = useLabState("chatgpt-subscription");
|
|
174
|
+
const chatgptStatus = useActionQuery<ChatGPTSubscriptionStatusRead>(
|
|
175
|
+
"get-chatgpt-subscription-status" as never,
|
|
176
|
+
undefined,
|
|
177
|
+
{ enabled: chatgptLab.enabled },
|
|
178
|
+
);
|
|
179
|
+
// A failed read leaves status unknown, even when React Query has old data.
|
|
180
|
+
const chatgptConnected = !chatgptLab.enabled
|
|
181
|
+
? false
|
|
182
|
+
: chatgptStatus.isError
|
|
183
|
+
? null
|
|
184
|
+
: (chatgptStatus.data?.connected ?? null);
|
|
185
|
+
const chatgptAccountId =
|
|
186
|
+
!chatgptLab.enabled || chatgptStatus.isError
|
|
187
|
+
? null
|
|
188
|
+
: (chatgptStatus.data?.activeAccountId ?? null);
|
|
189
|
+
const chatgptModels = useChatGPTModels(
|
|
190
|
+
listing.data?.hasOrganization === false,
|
|
191
|
+
chatgptLab.enabled && chatgptConnected === true,
|
|
192
|
+
chatgptAccountId,
|
|
193
|
+
chatgptLab.enabled && chatgptStatus.isError,
|
|
194
|
+
() => void chatgptStatus.refetch(),
|
|
195
|
+
);
|
|
196
|
+
|
|
117
197
|
const canAdd = listing.data
|
|
118
198
|
? addableProviders(listing.data).length > 0
|
|
119
199
|
: false;
|
|
@@ -122,6 +202,7 @@ export default function ModelSettingsPage(_props: SettingsPageProps) {
|
|
|
122
202
|
listing.data,
|
|
123
203
|
providerRows(listing.data, models.data),
|
|
124
204
|
builder,
|
|
205
|
+
chatgptConnected,
|
|
125
206
|
)
|
|
126
207
|
: false;
|
|
127
208
|
// The empty state carries the page's actions, so the header stays empty
|
|
@@ -206,6 +287,7 @@ export default function ModelSettingsPage(_props: SettingsPageProps) {
|
|
|
206
287
|
<OrganizationSettingsGroup
|
|
207
288
|
listing={data}
|
|
208
289
|
models={modelsRead}
|
|
290
|
+
chatgpt={chatgptModels}
|
|
209
291
|
builder={builder}
|
|
210
292
|
hasProvider={!needsProvider}
|
|
211
293
|
/>
|
|
@@ -252,18 +334,20 @@ function AddProviderButton({
|
|
|
252
334
|
}
|
|
253
335
|
|
|
254
336
|
/**
|
|
255
|
-
* Whether the agent has a provider to answer with: a connected
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
337
|
+
* Whether the agent has a provider to answer with: a connected ChatGPT plan
|
|
338
|
+
* (the viewer's own, and not an API key, so personal key restrictions don't
|
|
339
|
+
* apply), a connected Builder.io or an organization key, or for members (while
|
|
340
|
+
* personal API keys aren't restricted) and people without an organization, one
|
|
341
|
+
* of their own. Unknown Builder.io or ChatGPT status (`null`) counts as a
|
|
342
|
+
* provider, so the empty state never flashes before the status read answers.
|
|
260
343
|
*/
|
|
261
344
|
function hasAnyProvider(
|
|
262
345
|
listing: ModelProvidersListing,
|
|
263
346
|
rows: { org: ProviderKeyRow[]; personal: ProviderKeyRow[] },
|
|
264
347
|
builder: BuilderConnectFlow,
|
|
348
|
+
chatgptConnected: boolean | null,
|
|
265
349
|
): boolean {
|
|
266
|
-
if (!builder.hasFetchedStatus) return true;
|
|
350
|
+
if (chatgptConnected !== false || !builder.hasFetchedStatus) return true;
|
|
267
351
|
if (!listing.hasOrganization) {
|
|
268
352
|
return builder.configured || rows.personal.length > 0;
|
|
269
353
|
}
|
|
@@ -373,7 +457,6 @@ function PersonalProvidersGroup({
|
|
|
373
457
|
onRemove: (row: ProviderKeyRow) => void;
|
|
374
458
|
}) {
|
|
375
459
|
const t = useT();
|
|
376
|
-
const chatgptLab = useLabState(CHATGPT_SUBSCRIPTION_LAB_KEY);
|
|
377
460
|
const restricted = listing.personalKeysRestricted;
|
|
378
461
|
const personalGrant = builder.grants?.personal;
|
|
379
462
|
// Owners and admins connect Builder.io for the organization (open question
|
|
@@ -383,11 +466,7 @@ function PersonalProvidersGroup({
|
|
|
383
466
|
(listing.hasOrganization
|
|
384
467
|
? !listing.canManageOrg && (!!personalGrant || !restricted)
|
|
385
468
|
: true);
|
|
386
|
-
const
|
|
387
|
-
const hasRows = showBuilder || rows.length > 0 || showChatgpt;
|
|
388
|
-
|
|
389
|
-
// The no-provider empty state already says what a restricted member can do.
|
|
390
|
-
if (!hasRows && (!restricted || hideBuilder)) return null;
|
|
469
|
+
const hasProviderRows = showBuilder || rows.length > 0;
|
|
391
470
|
return (
|
|
392
471
|
<div>
|
|
393
472
|
<SettingsGroup
|
|
@@ -416,12 +495,12 @@ function PersonalProvidersGroup({
|
|
|
416
495
|
onRemove={() => onRemove(row)}
|
|
417
496
|
/>
|
|
418
497
|
))}
|
|
419
|
-
|
|
420
|
-
{!
|
|
498
|
+
<ChatGPTSubscriptionRow />
|
|
499
|
+
{!hasProviderRows && restricted ? (
|
|
421
500
|
<SettingsEmpty icon={IconLock} title={t(`${K}restricted`)} />
|
|
422
501
|
) : null}
|
|
423
502
|
</SettingsGroup>
|
|
424
|
-
{restricted &&
|
|
503
|
+
{restricted && hasProviderRows ? (
|
|
425
504
|
<p className="mt-2 px-1 text-xs leading-5 text-muted-foreground">
|
|
426
505
|
{t(`${K}restricted`)}
|
|
427
506
|
</p>
|
|
@@ -642,11 +721,13 @@ function KeyProviderRow({
|
|
|
642
721
|
function OrganizationSettingsGroup({
|
|
643
722
|
listing,
|
|
644
723
|
models,
|
|
724
|
+
chatgpt,
|
|
645
725
|
builder,
|
|
646
726
|
hasProvider,
|
|
647
727
|
}: {
|
|
648
728
|
listing: ModelProvidersListing;
|
|
649
729
|
models: ModelsReadState;
|
|
730
|
+
chatgpt: ChatGPTModelsState;
|
|
650
731
|
builder: BuilderConnectFlow;
|
|
651
732
|
hasProvider: boolean;
|
|
652
733
|
}) {
|
|
@@ -661,6 +742,7 @@ function OrganizationSettingsGroup({
|
|
|
661
742
|
<DefaultModelRow
|
|
662
743
|
listing={listing}
|
|
663
744
|
models={models}
|
|
745
|
+
chatgpt={chatgpt}
|
|
664
746
|
builder={builder}
|
|
665
747
|
hasProvider={hasProvider}
|
|
666
748
|
/>
|
|
@@ -673,11 +755,13 @@ function OrganizationSettingsGroup({
|
|
|
673
755
|
function DefaultModelRow({
|
|
674
756
|
listing,
|
|
675
757
|
models: modelsRead,
|
|
758
|
+
chatgpt,
|
|
676
759
|
builder,
|
|
677
760
|
hasProvider,
|
|
678
761
|
}: {
|
|
679
762
|
listing: ModelProvidersListing;
|
|
680
763
|
models: ModelsReadState;
|
|
764
|
+
chatgpt: ChatGPTModelsState;
|
|
681
765
|
builder: BuilderConnectFlow;
|
|
682
766
|
hasProvider: boolean;
|
|
683
767
|
}) {
|
|
@@ -698,6 +782,7 @@ function DefaultModelRow({
|
|
|
698
782
|
models,
|
|
699
783
|
builderConnected,
|
|
700
784
|
builderLabel: BUILDER_LABEL,
|
|
785
|
+
chatgpt: chatgpt.status === "ready" ? chatgpt.catalog : undefined,
|
|
701
786
|
});
|
|
702
787
|
const stored = listing.defaultModel
|
|
703
788
|
? {
|
|
@@ -766,6 +851,12 @@ function DefaultModelRow({
|
|
|
766
851
|
|
|
767
852
|
// Until a provider is added there is nothing to choose; the row says so.
|
|
768
853
|
const waitingForProvider = !hasProvider;
|
|
854
|
+
const retryRead =
|
|
855
|
+
modelsRead.status === "error"
|
|
856
|
+
? modelsRead.retry
|
|
857
|
+
: chatgpt.status === "error"
|
|
858
|
+
? chatgpt.retry
|
|
859
|
+
: null;
|
|
769
860
|
|
|
770
861
|
return (
|
|
771
862
|
<SettingsRow
|
|
@@ -777,7 +868,7 @@ function DefaultModelRow({
|
|
|
777
868
|
: t(`${K}defaultModelDescription`)
|
|
778
869
|
}
|
|
779
870
|
control={
|
|
780
|
-
modelsRead.status === "loading" ? (
|
|
871
|
+
modelsRead.status === "loading" || chatgpt.status === "loading" ? (
|
|
781
872
|
<Skeleton
|
|
782
873
|
className="h-8 w-64 max-w-full"
|
|
783
874
|
data-default-model-loading=""
|
|
@@ -820,7 +911,10 @@ function DefaultModelRow({
|
|
|
820
911
|
key={model}
|
|
821
912
|
value={defaultModelValue(group.engine, model)}
|
|
822
913
|
>
|
|
823
|
-
{t(`${K}modelOption`, {
|
|
914
|
+
{t(`${K}modelOption`, {
|
|
915
|
+
model: group.modelDisplayNames?.[model] ?? model,
|
|
916
|
+
provider: group.label,
|
|
917
|
+
})}
|
|
824
918
|
</SelectItem>
|
|
825
919
|
))}
|
|
826
920
|
</SelectGroup>
|
|
@@ -837,15 +931,10 @@ function DefaultModelRow({
|
|
|
837
931
|
{error}
|
|
838
932
|
</p>
|
|
839
933
|
) : null}
|
|
840
|
-
{
|
|
934
|
+
{retryRead ? (
|
|
841
935
|
<div role="alert" className="flex flex-wrap items-center gap-3 text-sm">
|
|
842
936
|
<p className="text-destructive">{t(`${K}settingLoadFailed`)}</p>
|
|
843
|
-
<Button
|
|
844
|
-
type="button"
|
|
845
|
-
variant="outline"
|
|
846
|
-
size="sm"
|
|
847
|
-
onClick={modelsRead.retry}
|
|
848
|
-
>
|
|
937
|
+
<Button type="button" variant="outline" size="sm" onClick={retryRead}>
|
|
849
938
|
{t("agentChat.common.retry")}
|
|
850
939
|
</Button>
|
|
851
940
|
</div>
|
|
@@ -218,6 +218,52 @@ describe("model page state", () => {
|
|
|
218
218
|
]);
|
|
219
219
|
});
|
|
220
220
|
|
|
221
|
+
it("offers connected ChatGPT models only for a personal default", () => {
|
|
222
|
+
const chatgpt = {
|
|
223
|
+
label: "ChatGPT",
|
|
224
|
+
models: ["gpt-5.5"],
|
|
225
|
+
displayNames: { "gpt-5.5": "GPT-5.5" },
|
|
226
|
+
};
|
|
227
|
+
const organizationGroups = defaultModelGroups({
|
|
228
|
+
listing: listing(),
|
|
229
|
+
models,
|
|
230
|
+
builderConnected: false,
|
|
231
|
+
builderLabel: "Builder.io",
|
|
232
|
+
chatgpt,
|
|
233
|
+
});
|
|
234
|
+
expect(
|
|
235
|
+
organizationGroups.some(
|
|
236
|
+
(group) => group.engine === "chatgpt-subscription",
|
|
237
|
+
),
|
|
238
|
+
).toBe(false);
|
|
239
|
+
|
|
240
|
+
const personalGroups = defaultModelGroups({
|
|
241
|
+
listing: listing({ hasOrganization: false }),
|
|
242
|
+
models: { providers: [] },
|
|
243
|
+
builderConnected: false,
|
|
244
|
+
builderLabel: "Builder.io",
|
|
245
|
+
chatgpt,
|
|
246
|
+
});
|
|
247
|
+
expect(personalGroups).toEqual([
|
|
248
|
+
{
|
|
249
|
+
engine: "chatgpt-subscription",
|
|
250
|
+
provider: "chatgpt",
|
|
251
|
+
label: "ChatGPT",
|
|
252
|
+
models: ["gpt-5.5"],
|
|
253
|
+
modelDisplayNames: { "gpt-5.5": "GPT-5.5" },
|
|
254
|
+
},
|
|
255
|
+
]);
|
|
256
|
+
expect(
|
|
257
|
+
defaultModelGroups({
|
|
258
|
+
listing: listing(),
|
|
259
|
+
models,
|
|
260
|
+
builderConnected: false,
|
|
261
|
+
builderLabel: "Builder.io",
|
|
262
|
+
chatgpt: { ...chatgpt, models: [] },
|
|
263
|
+
}).some((group) => group.engine === "chatgpt-subscription"),
|
|
264
|
+
).toBe(false);
|
|
265
|
+
});
|
|
266
|
+
|
|
221
267
|
it("uses personal keys for the default of someone without an organization", () => {
|
|
222
268
|
const groups = defaultModelGroups({
|
|
223
269
|
listing: listing({ hasOrganization: false }),
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
ModelProviderKeyScope,
|
|
11
11
|
ModelProvidersListing,
|
|
12
12
|
} from "@agent-native/core/agent/actions/list-model-providers";
|
|
13
|
+
import { CHATGPT_SUBSCRIPTION_ENGINE_NAME } from "@agent-native/core/agent/chatgpt-subscription-contract";
|
|
13
14
|
import {
|
|
14
15
|
AGENT_PROVIDER_CATALOG,
|
|
15
16
|
getAgentProviderOption,
|
|
@@ -206,9 +207,18 @@ export function providerForEngine(
|
|
|
206
207
|
|
|
207
208
|
export interface DefaultModelGroup {
|
|
208
209
|
engine: string;
|
|
209
|
-
provider: AgentProviderId | "builder";
|
|
210
|
+
provider: AgentProviderId | "builder" | "chatgpt";
|
|
210
211
|
label: string;
|
|
211
212
|
models: string[];
|
|
213
|
+
/** Names to show instead of the model ids, where the provider has them. */
|
|
214
|
+
modelDisplayNames?: Record<string, string>;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** The models the signed-in ChatGPT account may use, from the engine list. */
|
|
218
|
+
export interface ChatGPTModelCatalog {
|
|
219
|
+
label: string;
|
|
220
|
+
models: string[];
|
|
221
|
+
displayNames: Record<string, string>;
|
|
212
222
|
}
|
|
213
223
|
|
|
214
224
|
/**
|
|
@@ -216,13 +226,15 @@ export interface DefaultModelGroup {
|
|
|
216
226
|
* so only organization providers are listed (Builder.io first when the
|
|
217
227
|
* organization is connected), each with its organization-checked models. A
|
|
218
228
|
* rejected key offers nothing until it's replaced. Without an organization
|
|
219
|
-
* the default is the user's own, so their personal keys fill it instead.
|
|
229
|
+
* the default is the user's own, so their personal keys fill it instead. A
|
|
230
|
+
* connected ChatGPT plan is offered only for that personal default.
|
|
220
231
|
*/
|
|
221
232
|
export function defaultModelGroups(input: {
|
|
222
233
|
listing: ModelProvidersListing;
|
|
223
234
|
models: ProviderModelsRead | undefined;
|
|
224
235
|
builderConnected: boolean;
|
|
225
236
|
builderLabel: string;
|
|
237
|
+
chatgpt?: ChatGPTModelCatalog | undefined;
|
|
226
238
|
}): DefaultModelGroup[] {
|
|
227
239
|
const { listing, models } = input;
|
|
228
240
|
const scope: ModelProviderKeyScope = listing.hasOrganization ? "org" : "user";
|
|
@@ -250,6 +262,19 @@ export function defaultModelGroups(input: {
|
|
|
250
262
|
models: checked,
|
|
251
263
|
});
|
|
252
264
|
}
|
|
265
|
+
if (
|
|
266
|
+
!listing.hasOrganization &&
|
|
267
|
+
input.chatgpt &&
|
|
268
|
+
input.chatgpt.models.length > 0
|
|
269
|
+
) {
|
|
270
|
+
groups.push({
|
|
271
|
+
engine: CHATGPT_SUBSCRIPTION_ENGINE_NAME,
|
|
272
|
+
provider: "chatgpt",
|
|
273
|
+
label: input.chatgpt.label,
|
|
274
|
+
models: input.chatgpt.models,
|
|
275
|
+
modelDisplayNames: input.chatgpt.displayNames,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
253
278
|
return groups;
|
|
254
279
|
}
|
|
255
280
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CHATGPT_SUBSCRIPTION_LAB } from "@agent-native/core/labs/core-labs";
|
|
2
1
|
import { createElement } from "react";
|
|
3
2
|
import { describe, expect, it } from "vitest";
|
|
4
3
|
|
|
@@ -106,14 +105,11 @@ describe("settings shell bridge", () => {
|
|
|
106
105
|
expect(bridge.appAreas.map((area) => area.id)).toEqual(["recordings"]);
|
|
107
106
|
});
|
|
108
107
|
|
|
109
|
-
it("
|
|
108
|
+
it("keeps app-provided labs", () => {
|
|
110
109
|
const bridge = createSettingsBridge({
|
|
111
110
|
labs: [{ key: "clips.meetings", displayName: "Meetings" }],
|
|
112
111
|
});
|
|
113
|
-
expect(bridge.labs.map((lab) => lab.key)).toEqual([
|
|
114
|
-
CHATGPT_SUBSCRIPTION_LAB.key,
|
|
115
|
-
"clips.meetings",
|
|
116
|
-
]);
|
|
112
|
+
expect(bridge.labs.map((lab) => lab.key)).toEqual(["clips.meetings"]);
|
|
117
113
|
});
|
|
118
114
|
|
|
119
115
|
it("finds a legacy tab by the first id that exists", () => {
|
|
@@ -277,13 +273,7 @@ describe("settings shell bridge", () => {
|
|
|
277
273
|
]);
|
|
278
274
|
expect(
|
|
279
275
|
entries.get("labs")?.map((entry) => [entry.id, entry.anchor]),
|
|
280
|
-
).toEqual([
|
|
281
|
-
[
|
|
282
|
-
`lab:${CHATGPT_SUBSCRIPTION_LAB.key}`,
|
|
283
|
-
`lab-${CHATGPT_SUBSCRIPTION_LAB.key}`,
|
|
284
|
-
],
|
|
285
|
-
["lab:clips.meetings", "lab-clips.meetings"],
|
|
286
|
-
]);
|
|
276
|
+
).toEqual([["lab:clips.meetings", "lab-clips.meetings"]]);
|
|
287
277
|
});
|
|
288
278
|
});
|
|
289
279
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CHATGPT_SUBSCRIPTION_LAB } from "@agent-native/core/labs/core-labs";
|
|
2
1
|
import type { LabDefinition } from "@agent-native/core/labs/registry";
|
|
3
2
|
import { IconSettings } from "@tabler/icons-react";
|
|
4
3
|
import { Children, isValidElement, type ReactNode } from "react";
|
|
@@ -56,7 +55,7 @@ export interface SettingsBridge {
|
|
|
56
55
|
/** `null` outside the shell, which always names the app group. */
|
|
57
56
|
appName: string | null;
|
|
58
57
|
mcpAbout: string | null;
|
|
59
|
-
/**
|
|
58
|
+
/** Labs contributed by the app. */
|
|
60
59
|
labs: readonly LabDefinition[];
|
|
61
60
|
labsLabel?: string;
|
|
62
61
|
labsIntro?: string;
|
|
@@ -95,9 +94,7 @@ export function createSettingsBridge(
|
|
|
95
94
|
input.whatsNewMarkdown ?? changelogMarkdownFrom(input.whatsNew) ?? null,
|
|
96
95
|
appName: input.appName?.trim() || null,
|
|
97
96
|
mcpAbout: input.mcpAbout?.trim() || null,
|
|
98
|
-
labs
|
|
99
|
-
? labs
|
|
100
|
-
: [CHATGPT_SUBSCRIPTION_LAB, ...labs],
|
|
97
|
+
labs,
|
|
101
98
|
labsLabel: input.labsLabel,
|
|
102
99
|
labsIntro: input.labsIntro,
|
|
103
100
|
tabs,
|
|
@@ -390,11 +390,11 @@ describe("app group pages", () => {
|
|
|
390
390
|
);
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
-
it("groups
|
|
393
|
+
it("groups app labs under the app's name with the footnote", async () => {
|
|
394
394
|
await renderPage(LabsSettingsPage, { input: { labs } });
|
|
395
395
|
const title = container.querySelector("#labs h2");
|
|
396
396
|
expect(title?.textContent).toBe("Clips");
|
|
397
|
-
expect(container.textContent).toContain("ChatGPT subscription");
|
|
397
|
+
expect(container.textContent).not.toContain("ChatGPT subscription");
|
|
398
398
|
expect(container.textContent).toContain(
|
|
399
399
|
"These new, unstable features may have bugs.",
|
|
400
400
|
);
|
|
@@ -442,6 +442,54 @@ describe("app group pages", () => {
|
|
|
442
442
|
expect(switchFor("Voice dictation")?.disabled).toBe(false);
|
|
443
443
|
});
|
|
444
444
|
|
|
445
|
+
it("refreshes the model catalog after a ChatGPT lab change succeeds", async () => {
|
|
446
|
+
labsActions.query.data = {
|
|
447
|
+
"chatgpt-subscription": {
|
|
448
|
+
enabled: false,
|
|
449
|
+
source: "default",
|
|
450
|
+
mixed: false,
|
|
451
|
+
},
|
|
452
|
+
};
|
|
453
|
+
const modelConfigChanged = vi.fn();
|
|
454
|
+
window.addEventListener(
|
|
455
|
+
"agent-engine:configured-changed",
|
|
456
|
+
modelConfigChanged,
|
|
457
|
+
);
|
|
458
|
+
try {
|
|
459
|
+
await renderPage(LabsSettingsPage, {
|
|
460
|
+
input: {
|
|
461
|
+
labs: [
|
|
462
|
+
{
|
|
463
|
+
key: "chatgpt-subscription",
|
|
464
|
+
displayName: "ChatGPT plan access",
|
|
465
|
+
},
|
|
466
|
+
],
|
|
467
|
+
},
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
const toggle = switchFor("ChatGPT plan access");
|
|
471
|
+
expect(toggle?.getAttribute("aria-checked")).toBe("false");
|
|
472
|
+
|
|
473
|
+
for (const [index, enabled] of [true, false].entries()) {
|
|
474
|
+
act(() => toggle?.click());
|
|
475
|
+
const [variables, options] =
|
|
476
|
+
labsActions.mutate.mock.calls[index] ?? [];
|
|
477
|
+
expect(variables).toEqual({ key: "chatgpt-subscription", enabled });
|
|
478
|
+
expect(modelConfigChanged).toHaveBeenCalledTimes(index);
|
|
479
|
+
act(() => {
|
|
480
|
+
(options as { onSuccess?: () => void } | undefined)?.onSuccess?.();
|
|
481
|
+
});
|
|
482
|
+
expect(modelConfigChanged).toHaveBeenCalledTimes(index + 1);
|
|
483
|
+
expect(toggle?.getAttribute("aria-checked")).toBe(String(enabled));
|
|
484
|
+
}
|
|
485
|
+
} finally {
|
|
486
|
+
window.removeEventListener(
|
|
487
|
+
"agent-engine:configured-changed",
|
|
488
|
+
modelConfigChanged,
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
|
|
445
493
|
it("offers explicit choices for inherited mixed settings", async () => {
|
|
446
494
|
labsActions.query.data = {
|
|
447
495
|
"clips.meetings": {
|
|
@@ -12,6 +12,7 @@ const state = vi.hoisted(() => ({
|
|
|
12
12
|
metrics: undefined as unknown,
|
|
13
13
|
creditUsage: null as unknown,
|
|
14
14
|
alerts: [] as unknown[],
|
|
15
|
+
chatgpt: undefined as unknown,
|
|
15
16
|
calls: [] as Array<{ name: string; params: unknown }>,
|
|
16
17
|
mutations: [] as Array<{ name: string; input: unknown }>,
|
|
17
18
|
}));
|
|
@@ -41,7 +42,12 @@ vi.mock("@agent-native/core/client/hooks", () => ({
|
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
return {
|
|
44
|
-
data:
|
|
45
|
+
data:
|
|
46
|
+
name === "get-usage-alerts"
|
|
47
|
+
? state.alerts
|
|
48
|
+
: name === "get-chatgpt-subscription-status"
|
|
49
|
+
? state.chatgpt
|
|
50
|
+
: undefined,
|
|
45
51
|
isError: false,
|
|
46
52
|
isLoading: false,
|
|
47
53
|
isFetching: false,
|
|
@@ -184,6 +190,7 @@ beforeEach(() => {
|
|
|
184
190
|
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
|
|
185
191
|
state.calls = [];
|
|
186
192
|
state.alerts = [];
|
|
193
|
+
state.chatgpt = undefined;
|
|
187
194
|
state.creditUsage = null;
|
|
188
195
|
state.mutations = [];
|
|
189
196
|
container = document.createElement("div");
|
|
@@ -198,6 +205,23 @@ afterEach(() => {
|
|
|
198
205
|
});
|
|
199
206
|
|
|
200
207
|
describe("UsagePage", () => {
|
|
208
|
+
it("links to ChatGPT plan usage beside the filters only while a plan is connected", () => {
|
|
209
|
+
state.metrics = metrics();
|
|
210
|
+
render(member);
|
|
211
|
+
expect(container.textContent).not.toContain("ChatGPT plan usage");
|
|
212
|
+
act(() => root?.unmount());
|
|
213
|
+
|
|
214
|
+
state.chatgpt = { connected: true };
|
|
215
|
+
render(member);
|
|
216
|
+
const link = container.querySelector<HTMLAnchorElement>(
|
|
217
|
+
'a[href="https://chatgpt.com/settings/usage"]',
|
|
218
|
+
);
|
|
219
|
+
expect(link?.textContent).toBe("ChatGPT plan usage");
|
|
220
|
+
expect(
|
|
221
|
+
link?.closest("div")?.querySelector('[role="combobox"]'),
|
|
222
|
+
).not.toBeNull();
|
|
223
|
+
});
|
|
224
|
+
|
|
201
225
|
it("shows a member only their own usage across all apps, in dollars", () => {
|
|
202
226
|
state.metrics = metrics();
|
|
203
227
|
render(member);
|
|
@@ -27,7 +27,12 @@ import {
|
|
|
27
27
|
ToggleGroupItem,
|
|
28
28
|
} from "@agent-native/toolkit/ui/toggle-group";
|
|
29
29
|
import { cn } from "@agent-native/toolkit/utils";
|
|
30
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
IconChartBar,
|
|
32
|
+
IconChartLine,
|
|
33
|
+
IconExternalLink,
|
|
34
|
+
IconTool,
|
|
35
|
+
} from "@tabler/icons-react";
|
|
31
36
|
import { keepPreviousData } from "@tanstack/react-query";
|
|
32
37
|
import { useCallback, useMemo, useState, type ReactNode } from "react";
|
|
33
38
|
|
|
@@ -225,6 +230,9 @@ export function UsagePage({ context }: { context: SettingsPageContext }) {
|
|
|
225
230
|
{ sinceDays, scope, app },
|
|
226
231
|
{ placeholderData: keepPreviousData },
|
|
227
232
|
);
|
|
233
|
+
const chatGPTStatus = useActionQuery<{ connected: boolean }>(
|
|
234
|
+
"get-chatgpt-subscription-status" as never,
|
|
235
|
+
);
|
|
228
236
|
const data = query.data;
|
|
229
237
|
const canViewOrganization =
|
|
230
238
|
data?.access.canViewWorkspace ?? mayViewOrganization;
|
|
@@ -487,6 +495,18 @@ export function UsagePage({ context }: { context: SettingsPageContext }) {
|
|
|
487
495
|
</SelectContent>
|
|
488
496
|
</Select>
|
|
489
497
|
) : null}
|
|
498
|
+
{chatGPTStatus.data?.connected ? (
|
|
499
|
+
<Button asChild variant="ghost" size="sm" className="ml-auto">
|
|
500
|
+
<a
|
|
501
|
+
href="https://chatgpt.com/settings/usage"
|
|
502
|
+
target="_blank"
|
|
503
|
+
rel="noreferrer"
|
|
504
|
+
>
|
|
505
|
+
{t("agentChat.settings.usage.chatgptPlanUsage")}
|
|
506
|
+
<IconExternalLink aria-hidden />
|
|
507
|
+
</a>
|
|
508
|
+
</Button>
|
|
509
|
+
) : null}
|
|
490
510
|
</div>
|
|
491
511
|
);
|
|
492
512
|
|