@f5-sales-demo/xcsh 21.21.1 → 21.21.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/CHANGELOG.md +3 -0
- package/package.json +8 -8
- package/src/config/model-registry.ts +1 -1
- package/src/extensibility/extensions/types.ts +1 -1
- package/src/internal-urls/build-info.generated.ts +8 -8
- package/src/mcp/manager.ts +47 -27
- package/src/mcp/oauth-flow.ts +15 -4
- package/src/web/search/providers/gemini.ts +31 -64
package/CHANGELOG.md
CHANGED
|
@@ -48,6 +48,9 @@
|
|
|
48
48
|
|
|
49
49
|
### Fixed
|
|
50
50
|
|
|
51
|
+
- Routed MCP and Gemini web-search OAuth refreshes through the shared durable refresh coordinator,
|
|
52
|
+
including proactive refresh and forced retry after authentication failures
|
|
53
|
+
([#3796](https://github.com/f5-sales-demo/xcsh/issues/3796)).
|
|
51
54
|
- Kept `/login` honest after live validation by reporting reachable keyless vLLM services as
|
|
52
55
|
`keyless configured` and unreachable keyless services as `unreachable`
|
|
53
56
|
([#3783](https://github.com/f5-sales-demo/xcsh/issues/3783)).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@f5-sales-demo/xcsh",
|
|
4
|
-
"version": "21.21.
|
|
4
|
+
"version": "21.21.2",
|
|
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",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@agentclientprotocol/sdk": "1.3.0",
|
|
65
|
-
"@f5-sales-demo/pi-agent-core": "21.21.
|
|
66
|
-
"@f5-sales-demo/pi-ai": "21.21.
|
|
67
|
-
"@f5-sales-demo/pi-natives": "21.21.
|
|
68
|
-
"@f5-sales-demo/pi-resource-management": "21.21.
|
|
69
|
-
"@f5-sales-demo/pi-tui": "21.21.
|
|
70
|
-
"@f5-sales-demo/pi-utils": "21.21.
|
|
71
|
-
"@f5-sales-demo/xcsh-stats": "21.21.
|
|
65
|
+
"@f5-sales-demo/pi-agent-core": "21.21.2",
|
|
66
|
+
"@f5-sales-demo/pi-ai": "21.21.2",
|
|
67
|
+
"@f5-sales-demo/pi-natives": "21.21.2",
|
|
68
|
+
"@f5-sales-demo/pi-resource-management": "21.21.2",
|
|
69
|
+
"@f5-sales-demo/pi-tui": "21.21.2",
|
|
70
|
+
"@f5-sales-demo/pi-utils": "21.21.2",
|
|
71
|
+
"@f5-sales-demo/xcsh-stats": "21.21.2",
|
|
72
72
|
"@mozilla/readability": "^0.6",
|
|
73
73
|
"@sinclair/typebox": "^0.34",
|
|
74
74
|
"@xterm/headless": "^6.0",
|
|
@@ -2569,7 +2569,7 @@ export interface ProviderConfigInput {
|
|
|
2569
2569
|
oauth?: {
|
|
2570
2570
|
name: string;
|
|
2571
2571
|
login(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials | string>;
|
|
2572
|
-
refreshToken?(credentials: OAuthCredentials): Promise<OAuthCredentials>;
|
|
2572
|
+
refreshToken?(credentials: OAuthCredentials, signal: AbortSignal): Promise<OAuthCredentials>;
|
|
2573
2573
|
getApiKey?(credentials: OAuthCredentials): string;
|
|
2574
2574
|
modifyModels?(models: Model<Api>[], credentials: OAuthCredentials): Model<Api>[];
|
|
2575
2575
|
};
|
|
@@ -1245,7 +1245,7 @@ export interface ProviderConfig {
|
|
|
1245
1245
|
/** Run the provider login flow and return credentials (or a plain API key) to persist. */
|
|
1246
1246
|
login(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials | string>;
|
|
1247
1247
|
/** Refresh expired credentials. */
|
|
1248
|
-
refreshToken?(credentials: OAuthCredentials): Promise<OAuthCredentials>;
|
|
1248
|
+
refreshToken?(credentials: OAuthCredentials, signal: AbortSignal): Promise<OAuthCredentials>;
|
|
1249
1249
|
/** Convert credentials to an API key string for requests. */
|
|
1250
1250
|
getApiKey?(credentials: OAuthCredentials): string;
|
|
1251
1251
|
/** Optional model rewrite hook for credential-aware routing (e.g., enterprise URLs). */
|
|
@@ -17,17 +17,17 @@ export interface BuildInfo {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const BUILD_INFO: BuildInfo = {
|
|
20
|
-
"version": "21.21.
|
|
21
|
-
"commit": "
|
|
22
|
-
"shortCommit": "
|
|
20
|
+
"version": "21.21.2",
|
|
21
|
+
"commit": "543254c7b2d3468a5af620a1905064da069837eb",
|
|
22
|
+
"shortCommit": "543254c",
|
|
23
23
|
"branch": "main",
|
|
24
|
-
"tag": "v21.21.
|
|
25
|
-
"commitDate": "2026-09-
|
|
26
|
-
"buildDate": "2026-09-
|
|
24
|
+
"tag": "v21.21.2",
|
|
25
|
+
"commitDate": "2026-09-09T14:40:15+00:00",
|
|
26
|
+
"buildDate": "2026-09-09T15:51:38.046Z",
|
|
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.21.
|
|
31
|
+
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/543254c7b2d3468a5af620a1905064da069837eb",
|
|
32
|
+
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.21.2"
|
|
33
33
|
};
|
package/src/mcp/manager.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
import * as url from "node:url";
|
|
9
|
+
import { isDefinitiveOAuthFailure } from "@f5-sales-demo/pi-ai";
|
|
9
10
|
import { logger } from "@f5-sales-demo/pi-utils";
|
|
10
11
|
import type { TSchema } from "@sinclair/typebox";
|
|
11
12
|
import type { SourceMeta } from "../capability/types";
|
|
@@ -593,8 +594,8 @@ export class MCPManager {
|
|
|
593
594
|
/**
|
|
594
595
|
* Resolve auth and shell-command substitutions in config before connecting.
|
|
595
596
|
*/
|
|
596
|
-
async prepareConfig(config: MCPServerConfig): Promise<MCPServerConfig> {
|
|
597
|
-
return this.#resolveAuthConfig(config);
|
|
597
|
+
async prepareConfig(config: MCPServerConfig, forceRefresh = false): Promise<MCPServerConfig> {
|
|
598
|
+
return this.#resolveAuthConfig(config, forceRefresh);
|
|
598
599
|
}
|
|
599
600
|
|
|
600
601
|
/**
|
|
@@ -1071,15 +1072,32 @@ export class MCPManager {
|
|
|
1071
1072
|
forceRefresh || (credential.expires && Date.now() >= credential.expires - REFRESH_BUFFER_MS);
|
|
1072
1073
|
if (shouldRefresh && credential.refresh && auth.tokenUrl) {
|
|
1073
1074
|
try {
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
credential.
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1075
|
+
const row = this.#authStorage
|
|
1076
|
+
.listStoredCredentials(credentialId)
|
|
1077
|
+
.find(entry => entry.credential.type === "oauth");
|
|
1078
|
+
if (row?.credential.type === "oauth") {
|
|
1079
|
+
const outcome = await this.#authStorage.refreshStoredOAuthCredential(credentialId, {
|
|
1080
|
+
credentialId: row.id,
|
|
1081
|
+
observedCredential: credential,
|
|
1082
|
+
credentialFromRow: current => current,
|
|
1083
|
+
forceRefresh,
|
|
1084
|
+
refreshSkewMs: REFRESH_BUFFER_MS,
|
|
1085
|
+
canRefresh: current => Boolean(current.refresh && auth.tokenUrl),
|
|
1086
|
+
refresh: (current, signal) =>
|
|
1087
|
+
refreshMCPOAuthToken(
|
|
1088
|
+
auth.tokenUrl!,
|
|
1089
|
+
current.refresh,
|
|
1090
|
+
auth.clientId,
|
|
1091
|
+
auth.clientSecret,
|
|
1092
|
+
signal,
|
|
1093
|
+
),
|
|
1094
|
+
isDefinitiveFailure: isDefinitiveOAuthFailure,
|
|
1095
|
+
disabledCause: error =>
|
|
1096
|
+
`oauth refresh failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
1097
|
+
keepCredentialOnRefreshFailure: true,
|
|
1098
|
+
});
|
|
1099
|
+
credential = outcome.credential;
|
|
1100
|
+
}
|
|
1083
1101
|
} catch (refreshError) {
|
|
1084
1102
|
logger.warn("MCP OAuth refresh failed, using existing token", {
|
|
1085
1103
|
credentialId,
|
|
@@ -1088,22 +1106,24 @@ export class MCPManager {
|
|
|
1088
1106
|
}
|
|
1089
1107
|
}
|
|
1090
1108
|
|
|
1091
|
-
if (
|
|
1092
|
-
resolved
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1109
|
+
if (credential) {
|
|
1110
|
+
if (resolved.type === "http" || resolved.type === "sse") {
|
|
1111
|
+
resolved = {
|
|
1112
|
+
...resolved,
|
|
1113
|
+
headers: {
|
|
1114
|
+
...resolved.headers,
|
|
1115
|
+
Authorization: `Bearer ${credential.access}`,
|
|
1116
|
+
},
|
|
1117
|
+
};
|
|
1118
|
+
} else {
|
|
1119
|
+
resolved = {
|
|
1120
|
+
...resolved,
|
|
1121
|
+
env: {
|
|
1122
|
+
...resolved.env,
|
|
1123
|
+
OAUTH_ACCESS_TOKEN: credential.access,
|
|
1124
|
+
},
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1107
1127
|
}
|
|
1108
1128
|
}
|
|
1109
1129
|
} catch (error) {
|
package/src/mcp/oauth-flow.ts
CHANGED
|
@@ -352,8 +352,9 @@ export class MCPOAuthFlow extends OAuthCallbackFlow {
|
|
|
352
352
|
export async function refreshMCPOAuthToken(
|
|
353
353
|
tokenUrl: string,
|
|
354
354
|
refreshToken: string,
|
|
355
|
-
clientId
|
|
356
|
-
clientSecret
|
|
355
|
+
clientId: string | undefined,
|
|
356
|
+
clientSecret: string | undefined,
|
|
357
|
+
signal: AbortSignal,
|
|
357
358
|
): Promise<OAuthCredentials> {
|
|
358
359
|
const params = new URLSearchParams({
|
|
359
360
|
grant_type: "refresh_token",
|
|
@@ -366,11 +367,21 @@ export async function refreshMCPOAuthToken(
|
|
|
366
367
|
method: "POST",
|
|
367
368
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
368
369
|
body: params.toString(),
|
|
370
|
+
signal,
|
|
369
371
|
});
|
|
370
372
|
|
|
371
373
|
if (!response.ok) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
+
let payload: unknown;
|
|
375
|
+
try {
|
|
376
|
+
payload = await response.json();
|
|
377
|
+
} catch {
|
|
378
|
+
payload = undefined;
|
|
379
|
+
}
|
|
380
|
+
const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : undefined;
|
|
381
|
+
const rawCode = (record as { error?: unknown } | undefined)?.error;
|
|
382
|
+
const code =
|
|
383
|
+
typeof rawCode === "string" && /^[a-z][a-z0-9_.-]{0,63}$/i.test(rawCode.trim()) ? rawCode.trim() : undefined;
|
|
384
|
+
throw new Error(`MCP OAuth refresh failed (HTTP ${response.status}${code ? `; error=${code}` : ""})`);
|
|
374
385
|
}
|
|
375
386
|
|
|
376
387
|
const data = (await response.json()) as {
|
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import {
|
|
9
9
|
ANTIGRAVITY_SYSTEM_INSTRUCTION,
|
|
10
|
+
AuthStorage,
|
|
10
11
|
extractRetryDelay,
|
|
11
12
|
getAntigravityHeaders,
|
|
12
13
|
getGeminiCliHeaders,
|
|
13
|
-
|
|
14
|
+
isDefinitiveOAuthFailure,
|
|
15
|
+
refreshOAuthToken,
|
|
14
16
|
} from "@f5-sales-demo/pi-ai";
|
|
15
17
|
import { getAgentDbPath } from "@f5-sales-demo/pi-utils";
|
|
16
|
-
import { AgentStorage } from "../../../session/agent-storage";
|
|
17
18
|
import type { SearchCitation, SearchResponse, SearchSource } from "../../../web/search/types";
|
|
18
19
|
import { SearchProviderError } from "../../../web/search/types";
|
|
19
20
|
import type { SearchParams } from "./base";
|
|
@@ -55,23 +56,12 @@ export function buildGeminiRequestTools(params: GeminiToolParams): Array<Record<
|
|
|
55
56
|
return tools;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
/** OAuth credential stored in agent.db */
|
|
59
|
-
interface GeminiOAuthCredential {
|
|
60
|
-
type: "oauth";
|
|
61
|
-
access: string;
|
|
62
|
-
refresh?: string;
|
|
63
|
-
expires: number;
|
|
64
|
-
projectId?: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
59
|
/** Auth info for Gemini API requests */
|
|
68
60
|
interface GeminiAuth {
|
|
69
61
|
accessToken: string;
|
|
70
62
|
refreshToken?: string;
|
|
71
63
|
projectId: string;
|
|
72
64
|
isAntigravity: boolean;
|
|
73
|
-
storage: AgentStorage;
|
|
74
|
-
credentialId: number;
|
|
75
65
|
}
|
|
76
66
|
|
|
77
67
|
/**
|
|
@@ -80,72 +70,49 @@ interface GeminiAuth {
|
|
|
80
70
|
* @returns OAuth credential with access token and project ID, or null if none found
|
|
81
71
|
*/
|
|
82
72
|
export async function findGeminiAuth(): Promise<GeminiAuth | null> {
|
|
83
|
-
const expiryBuffer = 5 * 60 * 1000; // 5 minutes
|
|
84
|
-
const now = Date.now();
|
|
85
|
-
|
|
86
73
|
// Try providers in deterministic order: gemini-cli first, then antigravity
|
|
87
74
|
const providers = ["google-gemini-cli", "google-antigravity"] as const;
|
|
75
|
+
let storage: AuthStorage | undefined;
|
|
88
76
|
|
|
89
77
|
try {
|
|
90
|
-
|
|
78
|
+
storage = await AuthStorage.create(getAgentDbPath());
|
|
91
79
|
|
|
92
80
|
for (const provider of providers) {
|
|
93
|
-
const records = storage.
|
|
81
|
+
const records = storage.listStoredCredentials(provider);
|
|
94
82
|
|
|
95
83
|
for (const record of records) {
|
|
96
84
|
const credential = record.credential;
|
|
97
85
|
if (credential.type !== "oauth") continue;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
accessToken: refreshed.access,
|
|
122
|
-
refreshToken: refreshed.refresh ?? oauthCred.refresh,
|
|
123
|
-
projectId,
|
|
124
|
-
isAntigravity: provider === "google-antigravity",
|
|
125
|
-
storage,
|
|
126
|
-
credentialId: record.id,
|
|
127
|
-
};
|
|
128
|
-
} catch {
|
|
129
|
-
// Refresh failed, skip this credential
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
// No refresh token or refresh failed
|
|
134
|
-
continue;
|
|
86
|
+
if (!credential.access || !credential.projectId) continue;
|
|
87
|
+
try {
|
|
88
|
+
const outcome = await storage.refreshStoredOAuthCredential(provider, {
|
|
89
|
+
credentialId: record.id,
|
|
90
|
+
observedCredential: credential,
|
|
91
|
+
credentialFromRow: current => current,
|
|
92
|
+
refreshSkewMs: 5 * 60_000,
|
|
93
|
+
canRefresh: current => Boolean(current.refresh && current.projectId),
|
|
94
|
+
refresh: (current, signal) => refreshOAuthToken(provider, current, signal),
|
|
95
|
+
isDefinitiveFailure: isDefinitiveOAuthFailure,
|
|
96
|
+
disabledCause: error =>
|
|
97
|
+
`oauth refresh failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
98
|
+
});
|
|
99
|
+
const current = outcome.credential;
|
|
100
|
+
if (!current?.access || !current.projectId || outcome.reauthenticationRequired) continue;
|
|
101
|
+
return {
|
|
102
|
+
accessToken: current.access,
|
|
103
|
+
refreshToken: current.refresh,
|
|
104
|
+
projectId: current.projectId,
|
|
105
|
+
isAntigravity: provider === "google-antigravity",
|
|
106
|
+
};
|
|
107
|
+
} catch {
|
|
108
|
+
// Refresh failed; try the next credential.
|
|
135
109
|
}
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
accessToken: oauthCred.access,
|
|
139
|
-
refreshToken: oauthCred.refresh,
|
|
140
|
-
projectId,
|
|
141
|
-
isAntigravity: provider === "google-antigravity",
|
|
142
|
-
storage,
|
|
143
|
-
credentialId: record.id,
|
|
144
|
-
};
|
|
145
110
|
}
|
|
146
111
|
}
|
|
147
112
|
} catch {
|
|
148
113
|
return null;
|
|
114
|
+
} finally {
|
|
115
|
+
storage?.close();
|
|
149
116
|
}
|
|
150
117
|
|
|
151
118
|
return null;
|