Skip to content

Commit 202b3b4

Browse files
committed
hotfix for sre context in debug mode
1 parent 273ea57 commit 202b3b4

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

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.56",
3+
"version": "1.5.57",
44
"description": "Smyth Runtime Environment",
55
"author": "Alaa-eddine KADDOURI",
66
"license": "MIT",

packages/core/src/Core/SmythRuntime.class.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Logger } from '../helpers/Log.helper';
55
import { ConnectorService } from './ConnectorsService';
66
import { SystemEvents } from './SystemEvents';
77
import { findSmythPath } from '../helpers/Sysconfig.helper';
8+
import pkg from '../../package.json';
89

910
const logger = Logger('SRE');
1011

@@ -18,6 +19,10 @@ export class SmythRuntime {
1819
private _readyPromise: Promise<boolean>;
1920
private _readyResolve: (value: boolean) => void;
2021

22+
public get version() {
23+
return pkg.version;
24+
}
25+
2126
private defaultConfig: SREConfig = {
2227
Vault: {
2328
Connector: 'JSONFileVault',
@@ -88,6 +93,7 @@ export class SmythRuntime {
8893
private _initialized = false;
8994

9095
public init(_config?: SREConfig): SmythRuntime {
96+
logger.info(`SRE v${this.version} initializing...`);
9197
if (!_config || JSON.stringify(_config) === '{}') {
9298
this._smythDir = findSmythPath();
9399
logger.info('.smyth directory found in:', this._smythDir);

packages/core/src/subsystems/MemoryManager/RuntimeContext.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,9 @@ export class RuntimeContext extends EventEmitter {
122122
}
123123
}
124124

125-
if (this.runtime.debug) {
126-
await this._cacheConnector
127-
.requester(AccessCandidate.agent(this.runtime.agent.id))
128-
.set(this.ctxFile, JSON.stringify(ctxData), null, null, 1 * 60 * 60); //expires in 1 hour
129-
}
125+
await this._cacheConnector
126+
.requester(AccessCandidate.agent(this.runtime.agent.id))
127+
.set(this.ctxFile, JSON.stringify(ctxData), null, null, 1 * 60 * 60); //expires in 1 hour
130128
} else {
131129
ctxData = JSON.parse(data);
132130
if (!ctxData.step) ctxData.step = 0;
@@ -143,7 +141,7 @@ export class RuntimeContext extends EventEmitter {
143141
return this._readyPromise;
144142
}
145143
private async sync() {
146-
if (!this.ctxFile || this.runtime.debug) return;
144+
if (!this.ctxFile) return;
147145

148146
this.emit('syncing');
149147

@@ -162,11 +160,14 @@ export class RuntimeContext extends EventEmitter {
162160
this.ctxFile = null;
163161
}
164162
} else {
163+
//TODO : Do we need to cache the context if not in debug mode ?
164+
165165
const data = this.serialize();
166166
//if (data) fs.writeFileSync(this.ctxFile, JSON.stringify(data, null, 2));
167167
if (data) {
168168
let serializedData = JSON.stringify(data);
169169
console.debug('Agent Context Size', this.ctxFile, serializedData.length, AccessCandidate.agent(this.runtime.agent.id));
170+
170171
await this._cacheConnector
171172
.requester(AccessCandidate.agent(this.runtime.agent.id))
172173
.set(this.ctxFile, serializedData, null, null, 3 * 60 * 60); //expires in 3 hours max

0 commit comments

Comments
 (0)