@f5-sales-demo/xcsh 21.6.4 → 21.7.0
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/package.json +8 -8
- package/src/config/auto-config.ts +9 -3
- package/src/config/model-registry.ts +10 -4
- package/src/config/model-resolver.ts +18 -6
- package/src/extensibility/extensions/types.ts +5 -1
- package/src/internal-urls/build-info.generated.ts +8 -8
- package/src/modes/acp/acp-agent.ts +3 -1
- package/src/modes/components/auth-link-presenter.ts +10 -0
- package/src/modes/components/context-add-wizard.ts +4 -31
- package/src/modes/components/model-selector.ts +107 -123
- package/src/modes/controllers/selector-controller.ts +52 -7
- package/src/services/xcsh-context.ts +29 -106
- package/src/session/agent-session.ts +1 -1
- package/src/session/session-manager.ts +4 -4
- package/src/thinking.ts +22 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@f5-sales-demo/xcsh",
|
|
4
|
-
"version": "21.
|
|
4
|
+
"version": "21.7.0",
|
|
5
5
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
6
6
|
"homepage": "https://github.com/f5-sales-demo/xcsh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@agentclientprotocol/sdk": "1.3.0",
|
|
64
|
-
"@f5-sales-demo/pi-agent-core": "21.
|
|
65
|
-
"@f5-sales-demo/pi-ai": "21.
|
|
66
|
-
"@f5-sales-demo/pi-natives": "21.
|
|
67
|
-
"@f5-sales-demo/pi-resource-management": "21.
|
|
68
|
-
"@f5-sales-demo/pi-tui": "21.
|
|
69
|
-
"@f5-sales-demo/pi-utils": "21.
|
|
70
|
-
"@f5-sales-demo/xcsh-stats": "21.
|
|
64
|
+
"@f5-sales-demo/pi-agent-core": "21.7.0",
|
|
65
|
+
"@f5-sales-demo/pi-ai": "21.7.0",
|
|
66
|
+
"@f5-sales-demo/pi-natives": "21.7.0",
|
|
67
|
+
"@f5-sales-demo/pi-resource-management": "21.7.0",
|
|
68
|
+
"@f5-sales-demo/pi-tui": "21.7.0",
|
|
69
|
+
"@f5-sales-demo/pi-utils": "21.7.0",
|
|
70
|
+
"@f5-sales-demo/xcsh-stats": "21.7.0",
|
|
71
71
|
"@mozilla/readability": "^0.6",
|
|
72
72
|
"@sinclair/typebox": "^0.34",
|
|
73
73
|
"@xterm/headless": "^6.0",
|
|
@@ -20,7 +20,7 @@ import { hardenAgentConfigFileSync, writeAgentConfigFileSync } from "./agent-con
|
|
|
20
20
|
import { DEFAULT_MODEL_ROLE } from "./settings-schema";
|
|
21
21
|
|
|
22
22
|
/** Current config schema version. Bump when the generated format changes. */
|
|
23
|
-
export const CURRENT_CONFIG_VERSION =
|
|
23
|
+
export const CURRENT_CONFIG_VERSION = 5;
|
|
24
24
|
const LITELLM_CONFIG_DIR_MODE = 0o700;
|
|
25
25
|
const LITELLM_MODELS_FILE_MODE = 0o600;
|
|
26
26
|
|
|
@@ -86,8 +86,14 @@ export function generateModelsYml(baseUrl: string, options?: GenerateModelsYmlOp
|
|
|
86
86
|
" - image",
|
|
87
87
|
" thinking:",
|
|
88
88
|
" mode: effort",
|
|
89
|
-
"
|
|
90
|
-
"
|
|
89
|
+
" defaultLevel: medium",
|
|
90
|
+
" supportedLevels:",
|
|
91
|
+
" - { effort: none, description: No reasoning }",
|
|
92
|
+
" - { effort: low, description: Light reasoning }",
|
|
93
|
+
" - { effort: medium, description: Balanced reasoning }",
|
|
94
|
+
" - { effort: high, description: Deep reasoning }",
|
|
95
|
+
" - { effort: xhigh, description: Very deep reasoning }",
|
|
96
|
+
" - { effort: max, description: Maximum reasoning }",
|
|
91
97
|
" contextWindow: 1050000",
|
|
92
98
|
" maxTokens: 128000",
|
|
93
99
|
" compat:",
|
|
@@ -169,11 +169,13 @@ const OpenAICompatSchema = Type.Object({
|
|
|
169
169
|
});
|
|
170
170
|
|
|
171
171
|
const EffortSchema = Type.Union([
|
|
172
|
+
Type.Literal("none"),
|
|
172
173
|
Type.Literal("minimal"),
|
|
173
174
|
Type.Literal("low"),
|
|
174
175
|
Type.Literal("medium"),
|
|
175
176
|
Type.Literal("high"),
|
|
176
177
|
Type.Literal("xhigh"),
|
|
178
|
+
Type.Literal("max"),
|
|
177
179
|
]);
|
|
178
180
|
|
|
179
181
|
const ThinkingControlModeSchema = Type.Union([
|
|
@@ -185,10 +187,14 @@ const ThinkingControlModeSchema = Type.Union([
|
|
|
185
187
|
]);
|
|
186
188
|
|
|
187
189
|
const ModelThinkingSchema = Type.Object({
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
190
|
+
supportedLevels: Type.Array(
|
|
191
|
+
Type.Object({
|
|
192
|
+
effort: EffortSchema,
|
|
193
|
+
description: Type.String({ minLength: 1 }),
|
|
194
|
+
}),
|
|
195
|
+
{ minItems: 1 },
|
|
196
|
+
),
|
|
197
|
+
defaultLevel: EffortSchema,
|
|
192
198
|
mode: ThinkingControlModeSchema,
|
|
193
199
|
});
|
|
194
200
|
|
|
@@ -601,11 +601,23 @@ export function resolveModelRoleValue(
|
|
|
601
601
|
modelRegistry: options?.modelRegistry,
|
|
602
602
|
});
|
|
603
603
|
if (resolved.model) {
|
|
604
|
+
let thinkingLevel = resolved.thinkingLevel;
|
|
605
|
+
if (resolved.explicitThinkingLevel) {
|
|
606
|
+
try {
|
|
607
|
+
thinkingLevel =
|
|
608
|
+
resolveThinkingLevelForModel(resolved.model, resolved.thinkingLevel) ?? resolved.thinkingLevel;
|
|
609
|
+
} catch (error) {
|
|
610
|
+
return {
|
|
611
|
+
model: resolved.model,
|
|
612
|
+
thinkingLevel: undefined,
|
|
613
|
+
explicitThinkingLevel: true,
|
|
614
|
+
warning: error instanceof Error ? error.message : String(error),
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
}
|
|
604
618
|
return {
|
|
605
619
|
model: resolved.model,
|
|
606
|
-
thinkingLevel
|
|
607
|
-
? (resolveThinkingLevelForModel(resolved.model, resolved.thinkingLevel) ?? resolved.thinkingLevel)
|
|
608
|
-
: resolved.thinkingLevel,
|
|
620
|
+
thinkingLevel,
|
|
609
621
|
explicitThinkingLevel: resolved.explicitThinkingLevel,
|
|
610
622
|
warning: resolved.warning,
|
|
611
623
|
};
|
|
@@ -695,18 +707,18 @@ export function resolveModelOverride(
|
|
|
695
707
|
modelPatterns: string[],
|
|
696
708
|
modelRegistry: ModelLookupRegistry,
|
|
697
709
|
settings?: Settings,
|
|
698
|
-
): { model?: Model<Api>; thinkingLevel?: ThinkingLevel; explicitThinkingLevel: boolean } {
|
|
710
|
+
): { model?: Model<Api>; thinkingLevel?: ThinkingLevel; explicitThinkingLevel: boolean; warning?: string } {
|
|
699
711
|
if (modelPatterns.length === 0) return { explicitThinkingLevel: false };
|
|
700
712
|
const availableModels = modelRegistry.getAvailable();
|
|
701
713
|
const matchPreferences = { usageOrder: settings?.getStorage()?.getModelUsageOrder() };
|
|
702
714
|
for (const pattern of modelPatterns) {
|
|
703
|
-
const { model, thinkingLevel, explicitThinkingLevel } = resolveModelRoleValue(pattern, availableModels, {
|
|
715
|
+
const { model, thinkingLevel, explicitThinkingLevel, warning } = resolveModelRoleValue(pattern, availableModels, {
|
|
704
716
|
settings,
|
|
705
717
|
matchPreferences,
|
|
706
718
|
modelRegistry,
|
|
707
719
|
});
|
|
708
720
|
if (model) {
|
|
709
|
-
return { model, thinkingLevel, explicitThinkingLevel };
|
|
721
|
+
return { model, thinkingLevel, explicitThinkingLevel, warning };
|
|
710
722
|
}
|
|
711
723
|
}
|
|
712
724
|
return { explicitThinkingLevel: false };
|
|
@@ -1183,7 +1183,11 @@ export interface ExtensionAPI {
|
|
|
1183
1183
|
* id: "claude-sonnet-4@20250514",
|
|
1184
1184
|
* name: "Claude Sonnet 4 (Vertex)",
|
|
1185
1185
|
* reasoning: true,
|
|
1186
|
-
* thinking: { mode: "anthropic-adaptive",
|
|
1186
|
+
* thinking: { mode: "anthropic-adaptive", defaultLevel: "medium", supportedLevels: [
|
|
1187
|
+
* { effort: "low", description: "Light reasoning" },
|
|
1188
|
+
* { effort: "medium", description: "Balanced reasoning" },
|
|
1189
|
+
* { effort: "high", description: "Deep reasoning" },
|
|
1190
|
+
* ] },
|
|
1187
1191
|
* input: ["text", "image"],
|
|
1188
1192
|
* cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
1189
1193
|
* contextWindow: 200000,
|
|
@@ -17,17 +17,17 @@ export interface BuildInfo {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const BUILD_INFO: BuildInfo = {
|
|
20
|
-
"version": "21.
|
|
21
|
-
"commit": "
|
|
22
|
-
"shortCommit": "
|
|
20
|
+
"version": "21.7.0",
|
|
21
|
+
"commit": "95f2f0d47bef5b8bd74e99e1f1656babc0115c99",
|
|
22
|
+
"shortCommit": "95f2f0d",
|
|
23
23
|
"branch": "main",
|
|
24
|
-
"tag": "v21.
|
|
25
|
-
"commitDate": "2026-09-
|
|
26
|
-
"buildDate": "2026-09-
|
|
24
|
+
"tag": "v21.7.0",
|
|
25
|
+
"commitDate": "2026-09-02T21:22:58+00:00",
|
|
26
|
+
"buildDate": "2026-09-02T21:59:57.287Z",
|
|
27
27
|
"dirty": true,
|
|
28
28
|
"prNumber": "",
|
|
29
29
|
"repoUrl": "https://github.com/f5-sales-demo/xcsh",
|
|
30
30
|
"repoSlug": "f5-sales-demo/xcsh",
|
|
31
|
-
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/
|
|
32
|
-
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.
|
|
31
|
+
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/95f2f0d47bef5b8bd74e99e1f1656babc0115c99",
|
|
32
|
+
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.7.0"
|
|
33
33
|
};
|
|
@@ -674,7 +674,9 @@ export class AcpAgent implements Agent {
|
|
|
674
674
|
|
|
675
675
|
#buildThinkingOptions(session: AgentSession): Array<{ value: string; name: string; description?: string }> {
|
|
676
676
|
return [
|
|
677
|
-
...(session.model?.thinking?.
|
|
677
|
+
...(session.model?.thinking?.supportedLevels.some(level => level.effort === "none")
|
|
678
|
+
? [{ value: THINKING_OFF, name: "Off" }]
|
|
679
|
+
: []),
|
|
678
680
|
...session.getAvailableThinkingLevels().map(level => ({
|
|
679
681
|
value: level,
|
|
680
682
|
name: level,
|
|
@@ -34,3 +34,13 @@ export function presentAuthLink(
|
|
|
34
34
|
// Clipboard access is best-effort; the OSC 8 link remains available.
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
/** Render device verification details so they remain usable without hyperlink or clipboard support. */
|
|
39
|
+
export function presentDeviceCode(container: AuthLinkContainer, url: string, userCode: string): void {
|
|
40
|
+
const hyperlink = `\x1b]8;;${url}\x07${url}\x1b]8;;\x07`;
|
|
41
|
+
container.addChild(new Text(theme.fg("accent", hyperlink), 1, 0));
|
|
42
|
+
container.addChild(new Text(theme.fg("warning", `One-time code: ${theme.bold(userCode)}`), 1, 0));
|
|
43
|
+
container.addChild(
|
|
44
|
+
new Text(theme.fg("dim", "Press c at the prompt to copy; the code remains readable above."), 1, 0),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Container, Input, matchesKey, Spacer, Text, TruncatedText } from "@f5-sales-demo/pi-tui";
|
|
2
|
+
import { normalizeXcshApiUrlInput, normalizeXcshCredentialInput } from "@f5-sales-demo/pi-utils/xcsh-auth";
|
|
2
3
|
import type { TokenValidationResult, XCSHContext } from "../../services/xcsh-context";
|
|
3
4
|
import {
|
|
4
5
|
deriveTenantFromUrl,
|
|
5
6
|
isSensitiveEnvKey,
|
|
6
|
-
normalizeApiUrl,
|
|
7
7
|
XCSH_API_TOKEN,
|
|
8
8
|
XCSH_API_URL,
|
|
9
9
|
XCSH_CONSOLE_PASSWORD,
|
|
@@ -27,40 +27,13 @@ type WizardCredentialKey =
|
|
|
27
27
|
* tokens that contain or end with `=`.
|
|
28
28
|
*/
|
|
29
29
|
export function normalizeWizardCredential(value: string, expectedKey: WizardCredentialKey): string | null {
|
|
30
|
-
|
|
31
|
-
const trimmed = value.trim();
|
|
32
|
-
if (!trimmed) return "";
|
|
33
|
-
const assignment = trimmed.match(/^(?:#\s*)?(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
|
|
34
|
-
const isShellAssignment =
|
|
35
|
-
assignment !== null &&
|
|
36
|
-
(assignment[1] === expectedKey || assignment[1].startsWith("XCSH_") || /^(?:#\s*)?(?:export\s+)/.test(trimmed));
|
|
37
|
-
if (assignment && isShellAssignment) {
|
|
38
|
-
if (assignment[1] !== expectedKey) return null;
|
|
39
|
-
return unwrapWholeValueQuotes(assignment[2].trim());
|
|
40
|
-
}
|
|
41
|
-
if (trimmed === expectedKey || trimmed === `export ${expectedKey}` || trimmed === `#${expectedKey}`) return null;
|
|
42
|
-
// A shell-style assignment for another field must not silently become a token.
|
|
43
|
-
if (/^(?:#\s*)?(?:export\s+)?XCSH_[A-Za-z0-9_]*\s*=/.test(trimmed)) return null;
|
|
44
|
-
return unwrapWholeValueQuotes(trimmed);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function unwrapWholeValueQuotes(value: string): string | null {
|
|
48
|
-
if (value.startsWith('"') || value.endsWith('"') || value.startsWith("'") || value.endsWith("'")) {
|
|
49
|
-
if (!(value.length >= 2 && value[0] === value.at(-1))) return null;
|
|
50
|
-
}
|
|
51
|
-
if (
|
|
52
|
-
value.length >= 2 &&
|
|
53
|
-
((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'")))
|
|
54
|
-
) {
|
|
55
|
-
return value.slice(1, -1);
|
|
56
|
-
}
|
|
57
|
-
return value;
|
|
30
|
+
return normalizeXcshCredentialInput(value, expectedKey);
|
|
58
31
|
}
|
|
59
32
|
|
|
60
33
|
export function normalizeWizardUrl(value: string): string | null {
|
|
61
|
-
const normalized =
|
|
34
|
+
const normalized = normalizeXcshApiUrlInput(value);
|
|
62
35
|
if (normalized === null || validateWizardUrl(normalized)) return null;
|
|
63
|
-
return
|
|
36
|
+
return normalized;
|
|
64
37
|
}
|
|
65
38
|
|
|
66
39
|
export function validateWizardUrl(url: string): string | null {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ThinkingLevel } from "@f5-sales-demo/pi-agent-core";
|
|
2
|
-
import {
|
|
2
|
+
import { getSupportedReasoningEfforts, type Model, modelsAreEqual, ReasoningEffort } from "@f5-sales-demo/pi-ai";
|
|
3
3
|
import {
|
|
4
4
|
Container,
|
|
5
5
|
getKeybindings,
|
|
@@ -73,21 +73,33 @@ export interface DefaultPickerModelPresentation {
|
|
|
73
73
|
selector: string;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
/** Collapse subscription tiers only in the ordinary picker; explicit --models scopes keep raw access. */
|
|
76
|
+
/** Present every service selector exactly; access tiers are not interchangeable aliases. */
|
|
79
77
|
export function presentModelsForDefaultPicker(
|
|
80
78
|
models: readonly Model[],
|
|
81
|
-
|
|
79
|
+
_explicitlyScoped = false,
|
|
82
80
|
): DefaultPickerModelPresentation[] {
|
|
83
|
-
return models
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
return models
|
|
82
|
+
.filter(model => model.visibility !== "hide")
|
|
83
|
+
.map(model => {
|
|
84
|
+
const selector = `${model.provider}/${model.id}`;
|
|
85
|
+
return { model, displaySelector: selector, selector };
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function getModelSearchText(item: DefaultPickerModelPresentation): string {
|
|
90
|
+
const { model, selector } = item;
|
|
91
|
+
return [model.provider, model.publisher, model.family, model.tier, model.name, model.description, selector]
|
|
92
|
+
.filter(Boolean)
|
|
93
|
+
.join(" ");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function getProviderDisplayName(provider: string): string {
|
|
97
|
+
if (provider === "openai-codex") return "ChatGPT Subscription";
|
|
98
|
+
if (provider === "openai") return "OpenAI API Key";
|
|
99
|
+
return provider
|
|
100
|
+
.split("-")
|
|
101
|
+
.map(part => part.charAt(0).toUpperCase() + part.slice(1))
|
|
102
|
+
.join(" ");
|
|
91
103
|
}
|
|
92
104
|
|
|
93
105
|
interface RoleAssignment {
|
|
@@ -102,8 +114,8 @@ interface MenuRoleAction {
|
|
|
102
114
|
role: string; // now accepts custom role strings
|
|
103
115
|
}
|
|
104
116
|
|
|
105
|
-
const
|
|
106
|
-
const
|
|
117
|
+
const QUICK_TAB = "QUICK";
|
|
118
|
+
const ALL_TAB = "ALL MODELS";
|
|
107
119
|
|
|
108
120
|
/**
|
|
109
121
|
* Component that renders a model selector with provider tabs and context menu.
|
|
@@ -132,11 +144,12 @@ export class ModelSelectorComponent extends Container {
|
|
|
132
144
|
#tui: TUI;
|
|
133
145
|
#scopedModels: ReadonlyArray<ScopedModelItem>;
|
|
134
146
|
#temporaryOnly: boolean;
|
|
147
|
+
#currentModel: Model | undefined;
|
|
135
148
|
|
|
136
149
|
#menuRoleActions: MenuRoleAction[] = [];
|
|
137
150
|
|
|
138
151
|
// Tab state
|
|
139
|
-
#providers: string[] = [ALL_TAB];
|
|
152
|
+
#providers: string[] = [QUICK_TAB, ALL_TAB];
|
|
140
153
|
#activeTabIndex: number = 0;
|
|
141
154
|
|
|
142
155
|
// Context menu state
|
|
@@ -164,6 +177,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
164
177
|
this.#onSelectCallback = onSelect;
|
|
165
178
|
this.#onCancelCallback = onCancel;
|
|
166
179
|
this.#temporaryOnly = options?.temporaryOnly ?? false;
|
|
180
|
+
this.#currentModel = _currentModel;
|
|
167
181
|
const initialSearchInput = options?.initialSearchInput;
|
|
168
182
|
|
|
169
183
|
// Initialize menu role actions (built-in + custom from settings)
|
|
@@ -228,7 +242,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
228
242
|
if (currentQuery) {
|
|
229
243
|
this.#filterModels(currentQuery);
|
|
230
244
|
} else {
|
|
231
|
-
this.#
|
|
245
|
+
this.#applyTabFilter();
|
|
232
246
|
}
|
|
233
247
|
// Request re-render after models are loaded
|
|
234
248
|
this.#tui.requestRender();
|
|
@@ -258,6 +272,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
258
272
|
matchPreferences,
|
|
259
273
|
modelRegistry: this.#modelRegistry,
|
|
260
274
|
});
|
|
275
|
+
if (resolved.warning) this.#errorMessage = resolved.warning;
|
|
261
276
|
if (resolved.model) {
|
|
262
277
|
this.#roles[role] = {
|
|
263
278
|
model: resolved.model,
|
|
@@ -400,7 +415,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
400
415
|
const loadError = this.#modelRegistry.getError();
|
|
401
416
|
if (loadError) {
|
|
402
417
|
this.#errorMessage = loadError;
|
|
403
|
-
} else {
|
|
418
|
+
} else if (!this.#errorMessage) {
|
|
404
419
|
this.#errorMessage = undefined;
|
|
405
420
|
}
|
|
406
421
|
|
|
@@ -424,92 +439,21 @@ export class ModelSelectorComponent extends Container {
|
|
|
424
439
|
}
|
|
425
440
|
}
|
|
426
441
|
|
|
427
|
-
const canonicalRecords = this.#modelRegistry.getCanonicalModels({
|
|
428
|
-
availableOnly: this.#scopedModels.length === 0,
|
|
429
|
-
candidates: models.map(item => item.model),
|
|
430
|
-
});
|
|
431
|
-
const canonicalModels = canonicalRecords
|
|
432
|
-
.map(record => {
|
|
433
|
-
const selectedModel = this.#modelRegistry.resolveCanonicalModel(record.id, {
|
|
434
|
-
availableOnly: this.#scopedModels.length === 0,
|
|
435
|
-
candidates: models.map(item => item.model),
|
|
436
|
-
});
|
|
437
|
-
if (!selectedModel) return undefined;
|
|
438
|
-
const searchText = [
|
|
439
|
-
record.id,
|
|
440
|
-
record.name,
|
|
441
|
-
selectedModel.provider,
|
|
442
|
-
selectedModel.id,
|
|
443
|
-
selectedModel.name,
|
|
444
|
-
...record.variants.flatMap(variant => [variant.selector, variant.model.name]),
|
|
445
|
-
].join(" ");
|
|
446
|
-
return {
|
|
447
|
-
kind: "canonical" as const,
|
|
448
|
-
id: record.id,
|
|
449
|
-
model: selectedModel,
|
|
450
|
-
selector: record.id,
|
|
451
|
-
variantCount: record.variants.length,
|
|
452
|
-
searchText,
|
|
453
|
-
normalizedSearchText: normalizeSearchText(searchText),
|
|
454
|
-
compactSearchText: compactSearchText(searchText),
|
|
455
|
-
};
|
|
456
|
-
})
|
|
457
|
-
.filter((item): item is CanonicalModelItem => item !== undefined)
|
|
458
|
-
.filter(
|
|
459
|
-
item =>
|
|
460
|
-
this.#scopedModels.length > 0 ||
|
|
461
|
-
item.model.provider !== "openai-codex" ||
|
|
462
|
-
!OPENAI_CODEX_GPT56_TIERS.has(item.model.id),
|
|
463
|
-
);
|
|
464
|
-
if (this.#scopedModels.length === 0) {
|
|
465
|
-
const friendly = models.find(item => item.provider === "openai-codex" && item.id === "gpt-5.6");
|
|
466
|
-
if (friendly) {
|
|
467
|
-
canonicalModels.push({
|
|
468
|
-
kind: "canonical",
|
|
469
|
-
id: "openai-codex/gpt-5.6",
|
|
470
|
-
model: friendly.model,
|
|
471
|
-
selector: friendly.selector,
|
|
472
|
-
variantCount: 1,
|
|
473
|
-
searchText: "openai-codex/gpt-5.6 GPT-5.6 Sol",
|
|
474
|
-
normalizedSearchText: normalizeSearchText("openai-codex/gpt-5.6 GPT-5.6 Sol"),
|
|
475
|
-
compactSearchText: compactSearchText("openai-codex/gpt-5.6 GPT-5.6 Sol"),
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
442
|
this.#sortModels(models);
|
|
481
|
-
this.#sortCanonicalModels(canonicalModels);
|
|
482
443
|
|
|
483
444
|
this.#allModels = models;
|
|
484
445
|
this.#filteredModels = models;
|
|
485
|
-
this.#canonicalModels =
|
|
486
|
-
this.#filteredCanonicalModels =
|
|
446
|
+
this.#canonicalModels = [];
|
|
447
|
+
this.#filteredCanonicalModels = [];
|
|
487
448
|
this.#selectedIndex = Math.min(this.#selectedIndex, Math.max(0, models.length - 1));
|
|
488
449
|
}
|
|
489
450
|
|
|
490
451
|
#buildProviderTabs(): void {
|
|
491
|
-
|
|
492
|
-
for (const item of this.#allModels) {
|
|
493
|
-
providerSet.add(item.provider.toUpperCase());
|
|
494
|
-
}
|
|
495
|
-
for (const provider of this.#modelRegistry.getDiscoverableProviders()) {
|
|
496
|
-
providerSet.add(provider.toUpperCase());
|
|
497
|
-
}
|
|
498
|
-
const sortedProviders = Array.from(providerSet).sort();
|
|
499
|
-
this.#providers = [ALL_TAB, CANONICAL_TAB, ...sortedProviders];
|
|
452
|
+
this.#providers = [QUICK_TAB, ALL_TAB];
|
|
500
453
|
}
|
|
501
454
|
|
|
502
455
|
async #refreshSelectedProvider(): Promise<void> {
|
|
503
|
-
|
|
504
|
-
if (this.#scopedModels.length > 0 || activeProvider === ALL_TAB || activeProvider === CANONICAL_TAB) {
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
await this.#modelRegistry.refreshProvider(activeProvider.toLowerCase());
|
|
508
|
-
await this.#loadModels();
|
|
509
|
-
this.#buildProviderTabs();
|
|
510
|
-
this.#updateTabBar();
|
|
511
|
-
this.#applyTabFilter();
|
|
512
|
-
this.#tui.requestRender();
|
|
456
|
+
return;
|
|
513
457
|
}
|
|
514
458
|
|
|
515
459
|
#updateTabBar(): void {
|
|
@@ -536,27 +480,43 @@ export class ModelSelectorComponent extends Container {
|
|
|
536
480
|
}
|
|
537
481
|
|
|
538
482
|
#isCanonicalTab(): boolean {
|
|
539
|
-
return
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
#getQuickModels(): ModelItem[] {
|
|
487
|
+
const wanted = new Set<string>();
|
|
488
|
+
if (this.#currentModel) wanted.add(`${this.#currentModel.provider}/${this.#currentModel.id}`);
|
|
489
|
+
for (const assigned of Object.values(this.#roles)) {
|
|
490
|
+
if (assigned) wanted.add(`${assigned.model.provider}/${assigned.model.id}`);
|
|
491
|
+
}
|
|
492
|
+
for (const selector of (this.#settings.getStorage()?.getModelUsageOrder() ?? []).slice(0, 5))
|
|
493
|
+
wanted.add(selector);
|
|
494
|
+
const recommended = new Map<string, ModelItem>();
|
|
495
|
+
for (const item of this.#allModels) {
|
|
496
|
+
const previous = recommended.get(item.provider);
|
|
497
|
+
if (!previous || (item.model.priority ?? Infinity) < (previous.model.priority ?? Infinity)) {
|
|
498
|
+
recommended.set(item.provider, item);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
for (const item of recommended.values()) wanted.add(item.selector);
|
|
502
|
+
return this.#allModels.filter(item => wanted.has(item.selector));
|
|
540
503
|
}
|
|
541
504
|
|
|
542
505
|
#filterModels(query: string): void {
|
|
543
506
|
const activeProvider = this.#getActiveProvider();
|
|
544
|
-
const isCanonicalTab =
|
|
507
|
+
const isCanonicalTab = false;
|
|
545
508
|
|
|
546
509
|
// Start with all models or filter by provider/canonical view
|
|
547
|
-
let baseModels = this.#allModels;
|
|
510
|
+
let baseModels = activeProvider === QUICK_TAB ? this.#getQuickModels() : this.#allModels;
|
|
548
511
|
const baseCanonicalModels = this.#canonicalModels;
|
|
549
|
-
if (!isCanonicalTab && activeProvider !== ALL_TAB) {
|
|
550
|
-
baseModels = this.#allModels.filter(m => m.provider.toUpperCase() === activeProvider);
|
|
551
|
-
}
|
|
552
512
|
|
|
553
513
|
// Apply fuzzy filter if query is present
|
|
554
514
|
if (query.trim()) {
|
|
555
515
|
// If user is searching from a provider tab, auto-switch to ALL to show global provider results.
|
|
556
516
|
if (activeProvider !== ALL_TAB && !isCanonicalTab) {
|
|
557
|
-
this.#activeTabIndex =
|
|
558
|
-
if (this.#tabBar && this.#tabBar.getActiveIndex() !==
|
|
559
|
-
this.#tabBar.setActiveIndex(
|
|
517
|
+
this.#activeTabIndex = 1;
|
|
518
|
+
if (this.#tabBar && this.#tabBar.getActiveIndex() !== 1) {
|
|
519
|
+
this.#tabBar.setActiveIndex(1);
|
|
560
520
|
return;
|
|
561
521
|
}
|
|
562
522
|
this.#updateTabBar();
|
|
@@ -586,10 +546,8 @@ export class ModelSelectorComponent extends Container {
|
|
|
586
546
|
this.#sortCanonicalModels(fuzzyMatches);
|
|
587
547
|
this.#filteredCanonicalModels = fuzzyMatches;
|
|
588
548
|
} else {
|
|
589
|
-
const fuzzyMatches = fuzzyFilter(
|
|
590
|
-
|
|
591
|
-
query,
|
|
592
|
-
({ id, model, provider, selector }) => `${selector} ${id} ${provider} ${model.name}`,
|
|
549
|
+
const fuzzyMatches = fuzzyFilter(baseModels, query, ({ model, selector }) =>
|
|
550
|
+
getModelSearchText({ model, selector, displaySelector: selector }),
|
|
593
551
|
);
|
|
594
552
|
this.#sortModels(fuzzyMatches);
|
|
595
553
|
this.#filteredModels = fuzzyMatches;
|
|
@@ -623,7 +581,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
623
581
|
|
|
624
582
|
#getProviderEmptyStateMessage(): string | undefined {
|
|
625
583
|
const activeProvider = this.#getActiveProvider();
|
|
626
|
-
if (activeProvider === ALL_TAB || activeProvider ===
|
|
584
|
+
if (activeProvider === ALL_TAB || activeProvider === QUICK_TAB || this.#searchInput.getValue().trim()) {
|
|
627
585
|
return undefined;
|
|
628
586
|
}
|
|
629
587
|
const state = this.#modelRegistry.getProviderDiscoveryState(activeProvider.toLowerCase());
|
|
@@ -663,11 +621,22 @@ export class ModelSelectorComponent extends Container {
|
|
|
663
621
|
const showProvider = activeProvider === ALL_TAB;
|
|
664
622
|
|
|
665
623
|
// Show visible slice of filtered models
|
|
624
|
+
let previousGroup: string | undefined;
|
|
666
625
|
for (let i = startIndex; i < endIndex; i++) {
|
|
667
626
|
const item = visibleItems[i];
|
|
668
627
|
if (!item) continue;
|
|
669
628
|
const canonicalItem = isCanonicalTab ? (item as CanonicalModelItem) : undefined;
|
|
670
629
|
const providerItem = isCanonicalTab ? undefined : (item as ModelItem);
|
|
630
|
+
const group = showProvider
|
|
631
|
+
? [getProviderDisplayName(providerItem?.provider ?? ""), item.model.publisher, item.model.family]
|
|
632
|
+
.filter(Boolean)
|
|
633
|
+
.join(" › ")
|
|
634
|
+
: undefined;
|
|
635
|
+
if (group && group !== previousGroup) {
|
|
636
|
+
if (previousGroup) this.#listContainer.addChild(new Spacer(1));
|
|
637
|
+
this.#listContainer.addChild(new Text(theme.fg("muted", ` ${group}`), 0, 0));
|
|
638
|
+
previousGroup = group;
|
|
639
|
+
}
|
|
671
640
|
|
|
672
641
|
const isSelected = i === this.#selectedIndex;
|
|
673
642
|
|
|
@@ -701,8 +670,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
701
670
|
const backing = theme.fg("dim", ` -> ${item.model.provider}/${item.model.id}`);
|
|
702
671
|
line = `${prefix}${theme.fg("accent", item.id)}${variants}${backing}${badgeText}`;
|
|
703
672
|
} else if (showProvider) {
|
|
704
|
-
|
|
705
|
-
line = `${prefix}${providerPrefix}${theme.fg("accent", providerItem?.id ?? item.id)}${badgeText}`;
|
|
673
|
+
line = `${prefix}${theme.fg("accent", item.model.name)} ${theme.fg("dim", `[${item.selector}]`)}${badgeText}`;
|
|
706
674
|
} else {
|
|
707
675
|
line = `${prefix}${theme.fg("accent", item.id)}${badgeText}`;
|
|
708
676
|
}
|
|
@@ -713,8 +681,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
713
681
|
const backing = theme.fg("dim", ` -> ${item.model.provider}/${item.model.id}`);
|
|
714
682
|
line = `${prefix}${item.id}${variants}${backing}${badgeText}`;
|
|
715
683
|
} else if (showProvider) {
|
|
716
|
-
|
|
717
|
-
line = `${prefix}${providerPrefix}${providerItem?.id ?? item.id}${badgeText}`;
|
|
684
|
+
line = `${prefix}${item.model.name} ${theme.fg("dim", `[${item.selector}]`)}${badgeText}`;
|
|
718
685
|
} else {
|
|
719
686
|
line = `${prefix}${item.id}${badgeText}`;
|
|
720
687
|
}
|
|
@@ -755,8 +722,9 @@ export class ModelSelectorComponent extends Container {
|
|
|
755
722
|
#getThinkingLevelsForModel(model: Model): ReadonlyArray<ThinkingLevel> {
|
|
756
723
|
return [
|
|
757
724
|
ThinkingLevel.Inherit,
|
|
758
|
-
...(model.
|
|
759
|
-
|
|
725
|
+
...getSupportedReasoningEfforts(model).map(level =>
|
|
726
|
+
level === ReasoningEffort.None ? ThinkingLevel.Off : (level as ThinkingLevel),
|
|
727
|
+
),
|
|
760
728
|
];
|
|
761
729
|
}
|
|
762
730
|
|
|
@@ -787,6 +755,16 @@ export class ModelSelectorComponent extends Container {
|
|
|
787
755
|
this.#updateMenu();
|
|
788
756
|
}
|
|
789
757
|
|
|
758
|
+
#openThinkingMenu(role: string): void {
|
|
759
|
+
const selected = this.#getSelectedItem();
|
|
760
|
+
if (!selected) return;
|
|
761
|
+
this.#isMenuOpen = true;
|
|
762
|
+
this.#menuStep = "thinking";
|
|
763
|
+
this.#menuSelectedRole = role;
|
|
764
|
+
this.#menuSelectedIndex = this.#getThinkingPreselectIndex(role, selected.model);
|
|
765
|
+
this.#updateMenu();
|
|
766
|
+
}
|
|
767
|
+
|
|
790
768
|
#closeMenu(): void {
|
|
791
769
|
this.#isMenuOpen = false;
|
|
792
770
|
this.#menuStep = "role";
|
|
@@ -806,7 +784,12 @@ export class ModelSelectorComponent extends Container {
|
|
|
806
784
|
? thinkingOptions.map((thinkingLevel, index) => {
|
|
807
785
|
const prefix = index === this.#menuSelectedIndex ? ` ${theme.nav.cursor} ` : " ";
|
|
808
786
|
const label = getThinkingLevelMetadata(thinkingLevel).label;
|
|
809
|
-
|
|
787
|
+
const effort = thinkingLevel === ThinkingLevel.Off ? ReasoningEffort.None : thinkingLevel;
|
|
788
|
+
const description =
|
|
789
|
+
thinkingLevel === ThinkingLevel.Inherit
|
|
790
|
+
? "Use the provider default"
|
|
791
|
+
: selectedItem.model.thinking?.supportedLevels.find(level => level.effort === effort)?.description;
|
|
792
|
+
return `${prefix}${label}${description ? ` — ${description}` : ""}`;
|
|
810
793
|
})
|
|
811
794
|
: this.#menuRoleActions.map((action, index) => {
|
|
812
795
|
const prefix = index === this.#menuSelectedIndex ? ` ${theme.nav.cursor} ` : " ";
|
|
@@ -882,20 +865,21 @@ export class ModelSelectorComponent extends Container {
|
|
|
882
865
|
return;
|
|
883
866
|
}
|
|
884
867
|
|
|
885
|
-
// Enter
|
|
868
|
+
// Enter selects the model and opens its exact reasoning picker.
|
|
886
869
|
if (matchesKey(keyData, "enter") || matchesKey(keyData, "return") || keyData === "\n") {
|
|
887
870
|
const selectedItem = this.#getSelectedItem();
|
|
888
871
|
if (selectedItem) {
|
|
889
|
-
|
|
890
|
-
// In temporary mode, skip menu and select directly
|
|
891
|
-
this.#handleSelect(selectedItem, null);
|
|
892
|
-
} else {
|
|
893
|
-
this.#openMenu();
|
|
894
|
-
}
|
|
872
|
+
this.#openThinkingMenu(this.#temporaryOnly ? "default" : "default");
|
|
895
873
|
}
|
|
896
874
|
return;
|
|
897
875
|
}
|
|
898
876
|
|
|
877
|
+
// Role assignment is deliberately secondary.
|
|
878
|
+
if (keyData.toLowerCase() === "r" && !this.#temporaryOnly) {
|
|
879
|
+
this.#openMenu();
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
|
|
899
883
|
// Escape or Ctrl+C - close selector
|
|
900
884
|
if (getKeybindings().matches(keyData, "tui.select.cancel")) {
|
|
901
885
|
this.#onCancelCallback();
|
|
@@ -943,7 +927,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
943
927
|
const thinkingOptions = this.#getThinkingLevelsForModel(selectedItem.model);
|
|
944
928
|
const thinkingLevel = thinkingOptions[this.#menuSelectedIndex];
|
|
945
929
|
if (!thinkingLevel) return;
|
|
946
|
-
this.#handleSelect(selectedItem, this.#menuSelectedRole, thinkingLevel);
|
|
930
|
+
this.#handleSelect(selectedItem, this.#temporaryOnly ? null : this.#menuSelectedRole, thinkingLevel);
|
|
947
931
|
this.#closeMenu();
|
|
948
932
|
return;
|
|
949
933
|
}
|
|
@@ -965,7 +949,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
965
949
|
#handleSelect(item: ModelItem | CanonicalModelItem, role: string | null, thinkingLevel?: ThinkingLevel): void {
|
|
966
950
|
// For temporary role, don't save to settings - just notify caller
|
|
967
951
|
if (role === null) {
|
|
968
|
-
this.#onSelectCallback(item.model, null,
|
|
952
|
+
this.#onSelectCallback(item.model, null, thinkingLevel, item.selector);
|
|
969
953
|
return;
|
|
970
954
|
}
|
|
971
955
|
|
|
@@ -3,10 +3,10 @@ import * as path from "node:path";
|
|
|
3
3
|
import { ThinkingLevel } from "@f5-sales-demo/pi-agent-core";
|
|
4
4
|
import {
|
|
5
5
|
getOAuthProviders,
|
|
6
|
+
getOpenAICodexLoginMethods,
|
|
6
7
|
loginLiteLLM,
|
|
7
8
|
type OAuthPrompt,
|
|
8
9
|
type OAuthProvider,
|
|
9
|
-
resolveOpenAICodexLoginMethod,
|
|
10
10
|
} from "@f5-sales-demo/pi-ai";
|
|
11
11
|
import type { Component } from "@f5-sales-demo/pi-tui";
|
|
12
12
|
import { Loader, Spacer, Text } from "@f5-sales-demo/pi-tui";
|
|
@@ -45,10 +45,11 @@ import type { InteractiveModeContext } from "../../modes/types";
|
|
|
45
45
|
import { type SessionInfo, SessionManager } from "../../session/session-manager";
|
|
46
46
|
import { FileSessionStorage } from "../../session/session-storage";
|
|
47
47
|
import { isSearchProviderPreference, setPreferredImageProvider, setPreferredSearchProvider } from "../../tools";
|
|
48
|
+
import { copyToClipboard } from "../../utils/clipboard";
|
|
48
49
|
import { setSessionTerminalTitle } from "../../utils/title-generator";
|
|
49
50
|
import { AgentDashboard } from "../components/agent-dashboard";
|
|
50
51
|
import { AssistantMessageComponent } from "../components/assistant-message";
|
|
51
|
-
import { presentAuthLink } from "../components/auth-link-presenter";
|
|
52
|
+
import { presentAuthLink, presentDeviceCode } from "../components/auth-link-presenter";
|
|
52
53
|
import { ExtensionDashboard } from "../components/extensions";
|
|
53
54
|
import { GutterBlock } from "../components/gutter-block";
|
|
54
55
|
import { HistorySearchComponent } from "../components/history-search";
|
|
@@ -465,7 +466,7 @@ export class SelectorController {
|
|
|
465
466
|
try {
|
|
466
467
|
if (role === null) {
|
|
467
468
|
// Temporary: update agent state but don't persist to settings
|
|
468
|
-
await this.ctx.session.setModelTemporary(model);
|
|
469
|
+
await this.ctx.session.setModelTemporary(model, thinkingLevel);
|
|
469
470
|
this.ctx.statusLine.invalidate();
|
|
470
471
|
this.ctx.updateEditorBorderColor();
|
|
471
472
|
this.ctx.showStatus(`Temporary model: ${selector ?? model.id}`);
|
|
@@ -483,7 +484,7 @@ export class SelectorController {
|
|
|
483
484
|
this.ctx.statusLine.invalidate();
|
|
484
485
|
this.ctx.updateEditorBorderColor();
|
|
485
486
|
this.ctx.showStatus(`Default model: ${selector ?? model.id}`);
|
|
486
|
-
|
|
487
|
+
done();
|
|
487
488
|
} else {
|
|
488
489
|
// Other roles (smol, slow): just update settings, not current model
|
|
489
490
|
this.ctx.settings.setModelRole(
|
|
@@ -1236,15 +1237,28 @@ export class SelectorController {
|
|
|
1236
1237
|
return this.#handleVllmLogin();
|
|
1237
1238
|
}
|
|
1238
1239
|
|
|
1240
|
+
let openAICodexMethod: "browser" | "device" | undefined;
|
|
1241
|
+
if (providerId === "openai-codex") {
|
|
1242
|
+
openAICodexMethod = await this.#selectOpenAICodexLoginMethod();
|
|
1243
|
+
if (!openAICodexMethod) {
|
|
1244
|
+
this.ctx.showStatus("ChatGPT login cancelled.");
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1239
1248
|
this.ctx.showStatus(`Logging in to ${providerId}…`);
|
|
1240
1249
|
const manualInput = this.ctx.oauthManualInput;
|
|
1241
1250
|
const useManualInput =
|
|
1242
1251
|
CALLBACK_SERVER_PROVIDERS.has(providerId as OAuthProvider) || providerId === "openai-codex";
|
|
1243
|
-
const shouldOpenBrowser = providerId !== "openai-codex" ||
|
|
1252
|
+
const shouldOpenBrowser = providerId !== "openai-codex" || openAICodexMethod === "browser";
|
|
1244
1253
|
const loginCallbacks = {
|
|
1245
|
-
|
|
1254
|
+
method: openAICodexMethod,
|
|
1255
|
+
onAuth: (info: { url: string; instructions?: string; kind?: "browser" | "device"; userCode?: string }) => {
|
|
1246
1256
|
this.ctx.chatContainer.addChild(new Spacer(1));
|
|
1247
|
-
|
|
1257
|
+
if (info.kind === "device" && info.userCode) {
|
|
1258
|
+
presentDeviceCode(this.ctx.chatContainer, info.url, info.userCode);
|
|
1259
|
+
} else {
|
|
1260
|
+
presentAuthLink(this.ctx.chatContainer, info.url);
|
|
1261
|
+
}
|
|
1248
1262
|
if (info.instructions) {
|
|
1249
1263
|
this.ctx.chatContainer.addChild(new Spacer(1));
|
|
1250
1264
|
this.ctx.chatContainer.addChild(new Text(theme.fg("warning", info.instructions), 1, 0));
|
|
@@ -1273,6 +1287,12 @@ export class SelectorController {
|
|
|
1273
1287
|
codeInput.onSubmit = () => {
|
|
1274
1288
|
const code = codeInput.getValue();
|
|
1275
1289
|
closeInput();
|
|
1290
|
+
if (prompt.copyText && /^(?:c|copy)$/i.test(code.trim())) {
|
|
1291
|
+
void copyToClipboard(prompt.copyText).catch(() => undefined);
|
|
1292
|
+
this.ctx.showStatus("One-time code copied when terminal clipboard support is available.");
|
|
1293
|
+
resolve("");
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1276
1296
|
resolve(code);
|
|
1277
1297
|
};
|
|
1278
1298
|
codeInput.onEscape = () => {
|
|
@@ -1350,6 +1370,31 @@ export class SelectorController {
|
|
|
1350
1370
|
}
|
|
1351
1371
|
}
|
|
1352
1372
|
|
|
1373
|
+
#selectOpenAICodexLoginMethod(): Promise<"browser" | "device" | undefined> {
|
|
1374
|
+
const ordered = getOpenAICodexLoginMethods();
|
|
1375
|
+
const labels = ordered.map(method =>
|
|
1376
|
+
method === "browser" ? "Browser Login — local PKCE callback" : "Device Code — SSH/headless friendly",
|
|
1377
|
+
);
|
|
1378
|
+
return new Promise(resolve => {
|
|
1379
|
+
this.showSelector(done => {
|
|
1380
|
+
const selector = new HookSelectorComponent(
|
|
1381
|
+
"ChatGPT subscription sign-in method",
|
|
1382
|
+
labels,
|
|
1383
|
+
label => {
|
|
1384
|
+
done();
|
|
1385
|
+
resolve(label.startsWith("Browser") ? "browser" : "device");
|
|
1386
|
+
},
|
|
1387
|
+
() => {
|
|
1388
|
+
done();
|
|
1389
|
+
resolve(undefined);
|
|
1390
|
+
},
|
|
1391
|
+
{ helpText: "ChatGPT subscription OAuth is separate from usage-based OpenAI API-key access." },
|
|
1392
|
+
);
|
|
1393
|
+
return { component: selector, focus: selector };
|
|
1394
|
+
});
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1353
1398
|
/** Corporate Vertex uses isolated standalone OAuth, never consumer Google credentials or ambient ADC. */
|
|
1354
1399
|
async #handleVertexLogin(): Promise<void> {
|
|
1355
1400
|
const runtime = defaultVertexLoginRuntime;
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
RESERVED_CONTEXT_NAMES,
|
|
8
8
|
xcshContextPaths,
|
|
9
9
|
} from "@f5-sales-demo/pi-utils";
|
|
10
|
+
import { validateXcshApiCredentials, type XcshAuthValidationFailure } from "@f5-sales-demo/pi-utils/xcsh-auth";
|
|
10
11
|
import { Settings } from "../config/settings";
|
|
11
12
|
import { SECRET_ENV_PATTERNS } from "../secrets/index";
|
|
12
13
|
import { XCSHApiClient } from "./xcsh-api-client";
|
|
@@ -73,15 +74,7 @@ export interface XCSHContext {
|
|
|
73
74
|
export type AuthStatus = "connected" | "auth_error" | "offline" | "unknown";
|
|
74
75
|
|
|
75
76
|
/** Safe, actionable classification of a failed token validation request. */
|
|
76
|
-
export type ValidationFailureReason =
|
|
77
|
-
| "unauthorized"
|
|
78
|
-
| "forbidden"
|
|
79
|
-
| "redirect"
|
|
80
|
-
| "non_json"
|
|
81
|
-
| "rate_limited"
|
|
82
|
-
| "server"
|
|
83
|
-
| "timeout"
|
|
84
|
-
| "network";
|
|
77
|
+
export type ValidationFailureReason = XcshAuthValidationFailure;
|
|
85
78
|
|
|
86
79
|
export interface TokenValidationResult {
|
|
87
80
|
status: AuthStatus;
|
|
@@ -1020,104 +1013,34 @@ export class ContextService {
|
|
|
1020
1013
|
(options?.apiUrl !== undefined && options.apiUrl !== activeUrl) ||
|
|
1021
1014
|
(options?.apiToken !== undefined && options.apiToken !== activeToken);
|
|
1022
1015
|
|
|
1023
|
-
const url = `${normalizeApiUrl(effectiveUrl)}/api/web/namespaces`;
|
|
1024
|
-
const timeout = options?.timeoutMs ?? 3000;
|
|
1025
1016
|
const checkedAt = Date.now();
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
status: "offline",
|
|
1054
|
-
latencyMs,
|
|
1055
|
-
httpStatus: response.status || undefined,
|
|
1056
|
-
failureReason: "redirect",
|
|
1057
|
-
errorClass: "url_not_found",
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
if (response.status === 200) {
|
|
1061
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
1062
|
-
if (!contentType.includes("application/json")) {
|
|
1063
|
-
if (!adHoc) this.#authStatus = "offline";
|
|
1064
|
-
return recordResult({
|
|
1065
|
-
status: "offline",
|
|
1066
|
-
latencyMs,
|
|
1067
|
-
httpStatus: response.status,
|
|
1068
|
-
failureReason: "non_json",
|
|
1069
|
-
errorClass: "url_not_found",
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
|
-
try {
|
|
1073
|
-
await response.clone().json();
|
|
1074
|
-
} catch {
|
|
1075
|
-
if (!adHoc) this.#authStatus = "offline";
|
|
1076
|
-
return recordResult({
|
|
1077
|
-
status: "offline",
|
|
1078
|
-
latencyMs,
|
|
1079
|
-
httpStatus: response.status,
|
|
1080
|
-
failureReason: "non_json",
|
|
1081
|
-
errorClass: "url_not_found",
|
|
1082
|
-
});
|
|
1083
|
-
}
|
|
1084
|
-
if (!adHoc) this.#authStatus = "connected";
|
|
1085
|
-
return recordResult({ status: "connected", latencyMs, httpStatus: response.status });
|
|
1086
|
-
}
|
|
1087
|
-
if (response.status === 401 || response.status === 403) {
|
|
1088
|
-
if (!adHoc) this.#authStatus = "auth_error";
|
|
1089
|
-
return recordResult({
|
|
1090
|
-
status: "auth_error",
|
|
1091
|
-
latencyMs,
|
|
1092
|
-
httpStatus: response.status,
|
|
1093
|
-
failureReason: response.status === 401 ? "unauthorized" : "forbidden",
|
|
1094
|
-
errorClass: "credential",
|
|
1095
|
-
});
|
|
1096
|
-
}
|
|
1097
|
-
// 5xx, 429, etc. — server reachable but unhealthy; treat as offline so startup retry fires
|
|
1098
|
-
if (!adHoc) this.#authStatus = "offline";
|
|
1099
|
-
return recordResult({
|
|
1100
|
-
status: "offline",
|
|
1101
|
-
latencyMs,
|
|
1102
|
-
httpStatus: response.status,
|
|
1103
|
-
failureReason: response.status === 429 ? "rate_limited" : response.status >= 500 ? "server" : "network",
|
|
1104
|
-
errorClass: "network",
|
|
1105
|
-
});
|
|
1106
|
-
} catch (error) {
|
|
1107
|
-
const latencyMs = Math.round(performance.now() - start);
|
|
1108
|
-
const isTimeout = error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError");
|
|
1109
|
-
if (!adHoc) {
|
|
1110
|
-
this.#lastAuthLatencyMs = Date.now() - checkedAt;
|
|
1111
|
-
this.#lastAuthCheckedAt = checkedAt;
|
|
1112
|
-
this.#authStatus = "offline";
|
|
1113
|
-
}
|
|
1114
|
-
return recordResult({
|
|
1115
|
-
status: "offline",
|
|
1116
|
-
latencyMs,
|
|
1117
|
-
failureReason: isTimeout ? "timeout" : "network",
|
|
1118
|
-
errorClass: "network",
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
1017
|
+
const shared = await validateXcshApiCredentials({
|
|
1018
|
+
apiUrl: effectiveUrl,
|
|
1019
|
+
apiToken: effectiveToken,
|
|
1020
|
+
timeoutMs: options?.timeoutMs,
|
|
1021
|
+
fetch,
|
|
1022
|
+
});
|
|
1023
|
+
const errorClass: TokenValidationResult["errorClass"] =
|
|
1024
|
+
shared.failureReason === "unauthorized" || shared.failureReason === "forbidden"
|
|
1025
|
+
? "credential"
|
|
1026
|
+
: shared.failureReason === "redirect" || shared.failureReason === "non_json"
|
|
1027
|
+
? "url_not_found"
|
|
1028
|
+
: shared.failureReason
|
|
1029
|
+
? "network"
|
|
1030
|
+
: undefined;
|
|
1031
|
+
const result: TokenValidationResult = { ...shared, ...(errorClass ? { errorClass } : {}) };
|
|
1032
|
+
if (!adHoc) {
|
|
1033
|
+
this.#lastAuthLatencyMs = shared.latencyMs;
|
|
1034
|
+
this.#lastAuthCheckedAt = checkedAt;
|
|
1035
|
+
this.#authStatus = shared.status;
|
|
1036
|
+
}
|
|
1037
|
+
logger.debug("XCSH token validation", {
|
|
1038
|
+
status: result.status,
|
|
1039
|
+
httpStatus: result.httpStatus,
|
|
1040
|
+
latencyMs: result.latencyMs,
|
|
1041
|
+
failureReason: result.failureReason,
|
|
1042
|
+
});
|
|
1043
|
+
return result;
|
|
1121
1044
|
}
|
|
1122
1045
|
|
|
1123
1046
|
/**
|
|
@@ -4511,7 +4511,7 @@ export class AgentSession {
|
|
|
4511
4511
|
if (!this.model?.reasoning) return undefined;
|
|
4512
4512
|
|
|
4513
4513
|
const levels = [
|
|
4514
|
-
...(this.model.thinking?.
|
|
4514
|
+
...(this.model.thinking?.supportedLevels.some(level => level.effort === "none") ? [ThinkingLevel.Off] : []),
|
|
4515
4515
|
...this.getAvailableThinkingLevels(),
|
|
4516
4516
|
];
|
|
4517
4517
|
const currentLevel = this.thinkingLevel === ThinkingLevel.Inherit ? ThinkingLevel.Off : this.thinkingLevel;
|
|
@@ -539,7 +539,7 @@ export function buildSessionContext(
|
|
|
539
539
|
// Explicitly null - return no messages (navigated to before first entry)
|
|
540
540
|
return {
|
|
541
541
|
messages: [],
|
|
542
|
-
thinkingLevel:
|
|
542
|
+
thinkingLevel: undefined,
|
|
543
543
|
serviceTier: undefined,
|
|
544
544
|
models: {},
|
|
545
545
|
injectedTtsrRules: [],
|
|
@@ -562,7 +562,7 @@ export function buildSessionContext(
|
|
|
562
562
|
if (!leaf) {
|
|
563
563
|
return {
|
|
564
564
|
messages: [],
|
|
565
|
-
thinkingLevel:
|
|
565
|
+
thinkingLevel: undefined,
|
|
566
566
|
serviceTier: undefined,
|
|
567
567
|
models: {},
|
|
568
568
|
injectedTtsrRules: [],
|
|
@@ -584,7 +584,7 @@ export function buildSessionContext(
|
|
|
584
584
|
}
|
|
585
585
|
|
|
586
586
|
// Extract settings and find compaction
|
|
587
|
-
let thinkingLevel: string | undefined
|
|
587
|
+
let thinkingLevel: string | undefined;
|
|
588
588
|
let serviceTier: ServiceTier | undefined;
|
|
589
589
|
const models: Record<string, string> = {};
|
|
590
590
|
let activeContextName: string | undefined;
|
|
@@ -600,7 +600,7 @@ export function buildSessionContext(
|
|
|
600
600
|
|
|
601
601
|
for (const entry of path) {
|
|
602
602
|
if (entry.type === "thinking_level_change") {
|
|
603
|
-
thinkingLevel = entry.thinkingLevel ??
|
|
603
|
+
thinkingLevel = entry.thinkingLevel ?? undefined;
|
|
604
604
|
} else if (entry.type === "model_change") {
|
|
605
605
|
// New format: { model: "provider/id", role?: string }
|
|
606
606
|
if (entry.model) {
|
package/src/thinking.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { type ResolvedThinkingLevel, ThinkingLevel } from "@f5-sales-demo/pi-agent-core";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
clampThinkingLevelForModel,
|
|
4
|
+
type Effort,
|
|
5
|
+
getSupportedReasoningEfforts,
|
|
6
|
+
type Model,
|
|
7
|
+
ReasoningEffort,
|
|
8
|
+
THINKING_EFFORTS,
|
|
9
|
+
} from "@f5-sales-demo/pi-ai";
|
|
3
10
|
|
|
4
11
|
/**
|
|
5
12
|
* Metadata used to render thinking selector values in the coding-agent UI.
|
|
@@ -69,9 +76,12 @@ export function getThinkingLevelMetadata(level: ThinkingLevel): ThinkingLevelMet
|
|
|
69
76
|
* Converts an agent-local selector into the effort sent to providers.
|
|
70
77
|
*/
|
|
71
78
|
export function toReasoningEffort(level: ThinkingLevel | undefined): Effort | undefined {
|
|
72
|
-
if (level === undefined || level === ThinkingLevel.
|
|
79
|
+
if (level === undefined || level === ThinkingLevel.Inherit) {
|
|
73
80
|
return undefined;
|
|
74
81
|
}
|
|
82
|
+
// Agent's legacy transport type predates an explicit `none`; the catalog
|
|
83
|
+
// guard below ensures this value only reaches a service that advertises it.
|
|
84
|
+
if (level === ThinkingLevel.Off) return ReasoningEffort.None as Effort;
|
|
75
85
|
return level;
|
|
76
86
|
}
|
|
77
87
|
|
|
@@ -81,15 +91,22 @@ export function toReasoningEffort(level: ThinkingLevel | undefined): Effort | un
|
|
|
81
91
|
export function resolveThinkingLevelForModel(
|
|
82
92
|
model: Model | undefined,
|
|
83
93
|
level: ThinkingLevel | undefined,
|
|
94
|
+
options: { strictUnsupported?: boolean } = { strictUnsupported: true },
|
|
84
95
|
): ResolvedThinkingLevel | undefined {
|
|
85
96
|
if (level === undefined || level === ThinkingLevel.Inherit) {
|
|
86
|
-
return
|
|
97
|
+
return undefined;
|
|
87
98
|
}
|
|
88
99
|
if (level === ThinkingLevel.Off) {
|
|
89
|
-
if (model
|
|
100
|
+
if (model && !getSupportedReasoningEfforts(model).includes(ReasoningEffort.None)) {
|
|
101
|
+
if (options.strictUnsupported === false) return undefined;
|
|
90
102
|
throw new Error(`Cannot disable thinking for ${model.provider}/${model.id}`);
|
|
91
103
|
}
|
|
92
104
|
return ThinkingLevel.Off;
|
|
93
105
|
}
|
|
94
|
-
|
|
106
|
+
try {
|
|
107
|
+
return clampThinkingLevelForModel(model, level);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
if (options.strictUnsupported === false) return undefined;
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
95
112
|
}
|