Skip to content

Commit af342e6

Browse files
committed
Merge branch 'dev' into feat/planner-mode
2 parents 09891c9 + f46cf71 commit af342e6

File tree

12 files changed

+371
-152
lines changed

12 files changed

+371
-152
lines changed

packages/core/CHANGELOG

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to the SmythOS CORE Runtime Engine will be documented in thi
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [v1.5.50]
9+
10+
### Features
11+
12+
- Added support for OpenAI Responses API
13+
- Added support for GPT-5 family models with reasoning capabilities .
14+
- MCP Client component : support for Streamable HTTP transport
15+
816
## [v1.5.31]
917

1018
### LLM & Model Support:

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@smythos/sre",
3-
"version": "1.5.46",
3+
"version": "1.5.60",
44
"description": "Smyth Runtime Environment",
55
"author": "Alaa-eddine KADDOURI",
66
"license": "MIT",

packages/core/src/Components/APICall/APICall.class.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export class APICall extends Component {
5959
consumerSecret: Joi.string().allow('').label('Consumer Secret'),
6060
oauth1CallbackURL: Joi.string().allow('').label('OAuth1 Callback URL'),
6161
authenticate: Joi.string().allow('').label('Authenticate'),
62+
oauth_con_id: Joi.string().allow('').label('OAuth Connection ID'),
6263
});
6364
constructor() {
6465
super();
@@ -113,10 +114,14 @@ export class APICall extends Component {
113114
let Headers: any = {};
114115
let _error: any = undefined;
115116
try {
116-
if (config?.data?.oauthService && config?.data?.oauthService !== 'None') {
117-
const rootUrl = new URL(reqConfig.url).origin;
117+
// To support both old and new OAuth configuration, we check for both oauth_con_id and oauthService.
118+
logger.debug('checking oauth config', config?.data?.oauth_con_id, config?.data?.oauthService);
119+
if (
120+
(config?.data?.oauth_con_id !== undefined && config?.data?.oauth_con_id !== '' && config?.data?.oauth_con_id !== 'None') ||
121+
(config?.data?.oauthService !== '' && config.data.oauthService !== 'None')
122+
) {
118123
const additionalParams = extractAdditionalParamsForOAuth1(reqConfig);
119-
const oauthHeaders = await generateOAuthHeaders(agent, config, reqConfig, logger, additionalParams, rootUrl);
124+
const oauthHeaders = await generateOAuthHeaders(agent, config, reqConfig, logger, additionalParams);
120125
//reqConfig.headers = { ...reqConfig.headers, ...oauthHeaders };
121126
reqConfig.headers = reqConfig.headers.concat({ ...oauthHeaders });
122127
}

packages/core/src/Components/APICall/AccessTokenManager.ts

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,35 @@ class AccessTokenManager {
1919
private secondaryToken: string; // refreshToken || tokenSecret
2020
private tokenUrl: string; // tokenURL to refresh accessToken
2121
private expires_in: any;
22-
private data: any; // value of key(keyId) in teamSettings that needs to be updated if required
23-
private keyId: any; // key of object in teamSettings
22+
private tokensData: any; // Full tokens data object
23+
private keyId: any; // key of object in teamSettings
2424
private logger: any; // Use to log console in debugger
2525
private agent: Agent;
26+
private isNewStructure: boolean;
2627
constructor(
2728
clientId: string,
2829
clientSecret: string,
2930
secondaryToken: string,
3031
tokenUrl: string,
3132
expires_in: any,
3233
primaryToken: string,
33-
data: any,
34+
tokensData: any,
3435
keyId: any,
3536
logger: any,
3637
agent: Agent,
38+
isNewStructure: boolean = false,
3739
) {
3840
this.clientId = clientId;
3941
this.clientSecret = clientSecret;
4042
this.primaryToken = primaryToken;
4143
this.secondaryToken = secondaryToken;
4244
this.tokenUrl = tokenUrl;
4345
this.expires_in = expires_in;
44-
this.data = data;
46+
this.tokensData = tokensData;
4547
this.keyId = keyId;
4648
this.logger = logger;
4749
this.agent = agent;
50+
this.isNewStructure = isNewStructure;
4851
}
4952

5053
async getAccessToken(): Promise<string> {
@@ -105,19 +108,52 @@ class AccessTokenManager {
105108
this.logger.debug('Access token refreshed successfully.');
106109
const expiresInMilliseconds: number = response?.data?.expires_in ? response?.data?.expires_in * 1000 : response?.data?.expires_in;
107110
const expirationTimestamp: number = expiresInMilliseconds ? new Date().getTime() + expiresInMilliseconds : expiresInMilliseconds;
108-
this.data.primary = newAccessToken;
109-
this.data.expires_in = expirationTimestamp ? expirationTimestamp?.toString() : expirationTimestamp;
110-
//const oauthTeamSettings = new OauthTeamSettings();
111-
//const save: any = await oauthTeamSettings.update({ keyId: this.keyId, data: this.data });
112111

113-
const save: any = await managedVault.user(AccessCandidate.agent(this.agent.id)).set(this.keyId, JSON.stringify(this.data));
112+
// Maintain the same structure format when saving
113+
let updatedData;
114+
if (this.isNewStructure) {
115+
// Maintain new structure format
116+
updatedData = {
117+
...this.tokensData,
118+
auth_data: {
119+
...(this.tokensData?.auth_data ?? {}),
120+
primary: newAccessToken,
121+
// Persist rotated refresh_token when provided; fall back to existing
122+
secondary: (response?.data?.refresh_token ?? this.secondaryToken),
123+
// Use nullish check so 0 is preserved
124+
expires_in: (expirationTimestamp ?? undefined) !== undefined ? String(expirationTimestamp) : undefined
125+
}
126+
};
127+
} else {
128+
// Maintain old structure format
129+
updatedData = {
130+
...this.tokensData,
131+
primary: newAccessToken,
132+
expires_in: (expirationTimestamp ?? undefined) !== undefined ? String(expirationTimestamp) : undefined
133+
};
134+
// Persist rotated refresh_token when provided; otherwise keep existing
135+
updatedData.secondary = (response?.data?.refresh_token ?? this.secondaryToken);
136+
}
137+
138+
const save: any = await managedVault.user(AccessCandidate.agent(this.agent.id)).set(this.keyId, JSON.stringify(updatedData));
114139
if (save && save.status === 200) {
115140
console.log('Access token value is updated successfully.');
116141
this.logger.debug('Access token value is updated successfully.');
117142
} else {
118143
console.log('Warning: new access token value is not updated.');
119144
this.logger.debug('Warning: new access token value is not updated.');
120145
}
146+
147+
// Update internal tokensData reference
148+
this.tokensData = updatedData;
149+
this.primaryToken = newAccessToken;
150+
// Update in-memory refresh token in case the provider rotated it
151+
this.secondaryToken = (response?.data?.refresh_token ?? this.secondaryToken);
152+
// Preserve 0 and avoid dropping undefined
153+
this.expires_in =
154+
(expirationTimestamp ?? undefined) !== undefined
155+
? String(expirationTimestamp)
156+
: undefined;
121157
return newAccessToken;
122158
} catch (error) {
123159
console.error('Failed to refresh access token:', error);

0 commit comments

Comments
 (0)