Skip to content

Commit 8afba95

Browse files
committed
fix(lint): prefer-const for organizationIdForMemory and currentToolForges
1 parent 4438215 commit 8afba95

21 files changed

Lines changed: 1635 additions & 117 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
**TypeScript runtime for autonomous AI agents — multimodal RAG, cognitive memory, streaming guardrails, voice pipeline, and emergent multi-agent orchestration.**
1010

1111
[![npm version](https://img.shields.io/npm/v/@framers/agentos?style=flat-square&logo=npm&color=cb3837)](https://www.npmjs.com/package/@framers/agentos)
12-
[![CI](https://img.shields.io/github/actions/workflow/status/framersai/agentos/ci.yml?style=flat-square&logo=github&label=CI)](https://github.com/framersai/agentos/actions)
12+
[![CI](https://img.shields.io/github/actions/workflow/status/framersai/agentos/ci.yml?branch=master&style=flat-square&logo=github&label=CI)](https://github.com/framersai/agentos/actions/workflows/ci.yml)
1313
[![codecov](https://codecov.io/gh/framersai/agentos/graph/badge.svg)](https://codecov.io/gh/framersai/agentos)
1414
[![TypeScript](https://img.shields.io/badge/TypeScript-5.4+-3178c6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
1515
[![License](https://img.shields.io/badge/License-Apache_2.0-blue?style=flat-square)](https://opensource.org/licenses/Apache-2.0)

docs/memory/CLIENT_SIDE_STORAGE.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ const storage = await createAgentOSStorage({ platform: 'auto' });
268268
const agentos = new AgentOS();
269269
await agentos.initialize({
270270
storageAdapter: storage.getAdapter(), // 🆕 Client-side
271-
prisma: mockPrisma, // Stub for compatibility (TODO: make optional)
271+
prisma: mockPrisma, // Compatibility stub while Prisma remains required
272272
// ...
273273
});
274274
```
275275

276-
**Note:** Currently, AgentOS still requires a Prisma instance. We're working on making it optional when `storageAdapter` is provided.
276+
**Note:** Client-side AgentOS initialization still expects a Prisma-compatible object even when `storageAdapter` is provided, so keep the stub in place for now.
277277

278278
---
279279

@@ -376,4 +376,3 @@ const storage = new IndexedDbAdapter({
376376
---
377377

378378
**TL;DR:** Use `createAgentOSStorage({ platform: 'auto' })` and AgentOS works offline everywhere. IndexedDB for web, better-sqlite3 for desktop, capacitor for mobile.
379-

src/api/runtime/TurnExecutionPipeline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ export class TurnExecutionPipeline {
237237
// -------------------------------------------------------------------
238238
// Phase 3: Stream context registration
239239
// -------------------------------------------------------------------
240-
let organizationIdForMemory: string | undefined;
240+
const organizationIdForMemory: string | undefined;
241241
const streamContext: PipelineStreamContext = {
242242
gmi,
243243
userId: input.userId,

src/api/types/AgentOSInput.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export interface ProcessingOptions {
122122
temperature?: number;
123123
topP?: number;
124124
maxTokens?: number;
125+
responseFormat?: { type: 'text' | 'json_object' | string };
125126
disableAdaptation?: boolean;
126127
debugMode?: boolean;
127128
forceNewConversation?: boolean;

src/core/utils/usage/UsageLedger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type UsageSummary = UsageBucket;
3434
/** Persistence adapter contract enabling storage engines. */
3535
export interface IUsageLedgerPersistence {
3636
save(bucket: UsageBucket): Promise<void>;
37-
loadAll(): Promise<UsageBucket[]>; // For bootstrapping (may be large; future pagination TBD)
37+
loadAll(): Promise<UsageBucket[]>; // For bootstrapping only; callers should avoid using this for routine large scans.
3838
}
3939

4040
/** Options for UsageLedger behavior. */

src/nlp/ai_utilities/StatisticalUtilityAI.ts

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ import {
2323
import * as natural from 'natural';
2424
import { GMIError, GMIErrorCode } from '@framers/agentos/core/utils/errors';
2525

26+
const NATURAL_STEMMER_LANGUAGE_KEYS: Record<string, string> = {
27+
De: 'de',
28+
Es: 'es',
29+
Fa: 'fa',
30+
Fr: 'fr',
31+
It: 'it',
32+
Nl: 'nl',
33+
No: 'no',
34+
Pt: 'pt',
35+
Ru: 'ru',
36+
Sv: 'sv',
37+
Uk: 'uk',
38+
};
39+
2640
// Default English stop words list (can be expanded or loaded from file)
2741
const DEFAULT_ENGLISH_STOP_WORDS = new Set([
2842
'i', 'me', 'my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you', 'your', 'yours', 'yourself', 'yourselves',
@@ -85,18 +99,45 @@ export class StatisticalUtilityAI implements IUtilityAI {
8599
// For sentiment analysis
86100
private sentimentAnalyzers: Map<string, natural.SentimentAnalyzer>; // language -> analyzer
87101

102+
private createStemmerRegistry(): Record<string, natural.Stemmer> {
103+
const registry: Record<string, natural.Stemmer> = {
104+
porter: natural.PorterStemmer,
105+
lancaster: natural.LancasterStemmer,
106+
};
107+
108+
const naturalWithVariants = natural as unknown as Record<string, unknown>;
109+
for (const [suffix, langCode] of Object.entries(NATURAL_STEMMER_LANGUAGE_KEYS)) {
110+
const porterVariant = naturalWithVariants[`PorterStemmer${suffix}`];
111+
if (porterVariant && typeof (porterVariant as natural.Stemmer).stem === 'function') {
112+
registry[`porter_${langCode}`] = porterVariant as natural.Stemmer;
113+
}
114+
}
115+
116+
const carryFrench = naturalWithVariants.CarryStemmerFr;
117+
if (carryFrench && typeof (carryFrench as natural.Stemmer).stem === 'function') {
118+
registry.carry_fr = carryFrench as natural.Stemmer;
119+
}
120+
121+
const stemmerId = naturalWithVariants.StemmerId;
122+
if (stemmerId && typeof (stemmerId as natural.Stemmer).stem === 'function') {
123+
registry.default_id = stemmerId as natural.Stemmer;
124+
}
125+
126+
const stemmerJa = naturalWithVariants.StemmerJa;
127+
if (stemmerJa && typeof (stemmerJa as natural.Stemmer).stem === 'function') {
128+
registry.default_ja = stemmerJa as natural.Stemmer;
129+
}
130+
131+
return registry;
132+
}
88133

89134
constructor(utilityId?: string) {
90135
this.utilityId = utilityId || `stat-utility-${uuidv4()}`;
91136
this.tokenizers = {
92137
word: new natural.WordTokenizer(),
93138
sentence: new natural.SentenceTokenizer(),
94139
};
95-
this.stemmers = {
96-
porter: natural.PorterStemmer, // Static access to stem method
97-
lancaster: natural.LancasterStemmer, // Static access
98-
// PorterStemmerRu, PorterStemmerEs, etc. can be added if 'natural' supports them or via external libraries
99-
};
140+
this.stemmers = this.createStemmerRegistry();
100141
this.stopWords = new Map<string, Set<string>>([['en', DEFAULT_ENGLISH_STOP_WORDS]]);
101142
this.classifiers = new Map();
102143
this.sentimentAnalyzers = new Map();
@@ -165,11 +206,12 @@ export class StatisticalUtilityAI implements IUtilityAI {
165206

166207
private getStemmer(algorithm?: string, language?: string): natural.Stemmer {
167208
const algo = (algorithm || 'porter').toLowerCase();
168-
// TODO: Add language-specific stemmers from 'natural' if they exist (e.g., PorterStemmerRu)
169-
// This requires checking the 'natural' library for available stemmers beyond the basic English ones.
170-
// For now, defaults to English Porter if language-specific is not found.
171-
if (language && language.toLowerCase() !== 'en' && this.stemmers[`${algo}_${language.toLowerCase()}`]) {
172-
return this.stemmers[`${algo}_${language.toLowerCase()}`];
209+
const langCode = language?.toLowerCase().split('-')[0];
210+
if (langCode && langCode !== 'en' && this.stemmers[`${algo}_${langCode}`]) {
211+
return this.stemmers[`${algo}_${langCode}`];
212+
}
213+
if (langCode && this.stemmers[`default_${langCode}`]) {
214+
return this.stemmers[`default_${langCode}`];
173215
}
174216
return this.stemmers[algo] || natural.PorterStemmer; // Fallback to Porter
175217
}
@@ -722,4 +764,3 @@ export class StatisticalUtilityAI implements IUtilityAI {
722764
console.log(`StatisticalUtilityAI (ID: ${this.utilityId}) shut down.`);
723765
}
724766
}
725-

src/nlp/ai_utilities/tests/StatisticalUtilityAI.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ describe('StatisticalUtilityAI', () => {
4646
expect(summary).toBe("Sentence one. Sentence two.");
4747
});
4848

49+
it('should use language-specific stemmers when available', async () => {
50+
const spanishStem = await statUtility.stemTokens(['corriendo'], {
51+
algorithm: 'porter',
52+
language: 'es',
53+
});
54+
const russianStem = await statUtility.stemTokens(['машины'], {
55+
algorithm: 'porter',
56+
language: 'ru',
57+
});
58+
59+
expect(spanishStem).toEqual(['corr']);
60+
expect(russianStem).toEqual(['машин']);
61+
});
62+
4963
it('checkHealth should report as healthy if initialized', async () => {
5064
const health = await statUtility.checkHealth();
5165
expect(health.isHealthy).toBe(true);
@@ -56,4 +70,4 @@ describe('StatisticalUtilityAI', () => {
5670
await expect(statUtility.shutdown?.()).resolves.toBeUndefined();
5771
// Add any assertions about state after shutdown if applicable
5872
});
59-
});
73+
});

0 commit comments

Comments
 (0)