Skip to content

Commit f55c22b

Browse files
committed
chore: fix lint findings
1 parent 9c82ab1 commit f55c22b

27 files changed

Lines changed: 4398 additions & 4325 deletions

codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ comment:
3030
require_base: no
3131
require_head: yes
3232

33+
34+

docs/RELEASING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,5 @@ Fix tests locally before releasing. Do not skip tests.
153153

154154

155155

156+
157+

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default tseslint.config(
1414
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
1515
'@typescript-eslint/no-empty-function': 'off',
1616
'@typescript-eslint/ban-ts-comment': 'off',
17+
'@typescript-eslint/no-unused-expressions': 'off',
1718
'no-console': 'off',
1819
},
1920
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"clean": "rimraf dist tsconfig.build.tsbuildinfo",
2222
"build": "npm run clean && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && node scripts/fix-esm-imports.mjs",
2323
"typecheck": "tsc --noEmit",
24-
"lint": "eslint \"src/**/*.{ts,js}\"",
24+
"lint": "node scripts/strip-nbsp.mjs && eslint \"src/**/*.{ts,js}\"",
2525
"test": "vitest run",
2626
"dev:test": "vitest",
2727
"docs:clean": "rimraf docs/api ../../docs-generated/library ../../docs-generated/api",

scripts/strip-nbsp.mjs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
6+
const SRC_DIR = path.join(ROOT, 'src');
7+
const TARGET_EXTS = new Set(['.ts', '.tsx', '.js', '.jsx']);
8+
const isWindows = process.platform === 'win32';
9+
10+
function normalizePath(p) {
11+
return isWindows && p.startsWith('/') ? p.slice(1) : p;
12+
}
13+
14+
function walk(dir, acc) {
15+
const entries = fs.readdirSync(dir, { withFileTypes: true });
16+
for (const entry of entries) {
17+
if (entry.name === 'node_modules' || entry.name === 'dist') continue;
18+
const full = path.join(dir, entry.name);
19+
if (entry.isDirectory()) {
20+
walk(full, acc);
21+
} else if (TARGET_EXTS.has(path.extname(entry.name))) {
22+
acc.push(full);
23+
}
24+
}
25+
return acc;
26+
}
27+
28+
const files = walk(SRC_DIR, []);
29+
let changed = 0;
30+
let stripped = 0;
31+
32+
for (const file of files) {
33+
const raw = fs.readFileSync(file, 'utf8');
34+
const cleaned = raw
35+
// Normalize NBSP and other exotic spaces to regular space
36+
.replace(/[\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000]/g, ' ')
37+
// Remove zero-width chars if any snuck in
38+
.replace(/[\u200b\u200c\u200d\ufeff]/g, '');
39+
40+
if (cleaned !== raw) {
41+
fs.writeFileSync(file, cleaned, 'utf8');
42+
changed += 1;
43+
stripped += (raw.length - cleaned.length);
44+
}
45+
}
46+
47+
console.log(`strip-nbsp: cleaned ${changed} files, removed ${stripped} chars`);
48+
49+

src/api/AgentOSOrchestrator.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ export class AgentOSOrchestrator {
811811
);
812812
}
813813
break;
814-
case GMIOutputChunkType.ERROR:
814+
case GMIOutputChunkType.ERROR: {
815815
const errDetails = gmiChunk.errorDetails || { message: gmiChunk.content };
816816
await this.pushErrorChunk(
817817
agentOSStreamId, personaId, gmiInstanceIdForChunks,
@@ -825,6 +825,7 @@ export class AgentOSOrchestrator {
825825
await this.dependencies.streamingManager.closeStream(agentOSStreamId, `GMI stream error: ${errDetails.message || String(gmiChunk.content)}`);
826826
}
827827
break;
828+
}
828829
case GMIOutputChunkType.FINAL_RESPONSE_MARKER:
829830
// This chunk signals the end of GMI's streaming.
830831
// The actual final content should have been accumulated or is in this chunk's content/metadata.
@@ -834,24 +835,24 @@ export class AgentOSOrchestrator {
834835
// For now, if GMI explicitly sends this, we ensure the stream is marked for closure.
835836
// The main _processTurnInternal loop will handle the comprehensive AgentOSFinalResponseChunk.
836837
if (gmiChunk.isFinal) { // This marker SHOULD imply isFinal=true
837-
if (this.config.enableConversationalPersistence && conversationContext) {
838-
await this.dependencies.conversationManager.saveConversation(conversationContext);
839-
}
840-
// This is a simplified final response based *only* on this marker chunk.
841-
// A more robust solution accumulates all data through the turn.
842-
await this.pushChunkToStream(
843-
agentOSStreamId, AgentOSResponseChunkType.FINAL_RESPONSE,
844-
gmiInstanceIdForChunks, personaId, true,
845-
{
846-
finalResponseText: typeof gmiChunk.content === 'string' ? gmiChunk.content : "Processing complete.",
847-
// other fields like usage, trace would need to be on the FINAL_RESPONSE_MARKER content
848-
// or aggregated throughout the turn.
849-
updatedConversationContext: conversationContext.toJSON(),
850-
activePersonaDetails: snapshotPersonaDetails(gmi.getPersona?.()),
851-
}
852-
);
853-
this.activeStreamContexts.delete(agentOSStreamId);
854-
await this.dependencies.streamingManager.closeStream(agentOSStreamId, "GMI processing complete (final marker).");
838+
if (this.config.enableConversationalPersistence && conversationContext) {
839+
await this.dependencies.conversationManager.saveConversation(conversationContext);
840+
}
841+
// This is a simplified final response based *only* on this marker chunk.
842+
// A more robust solution accumulates all data through the turn.
843+
await this.pushChunkToStream(
844+
agentOSStreamId, AgentOSResponseChunkType.FINAL_RESPONSE,
845+
gmiInstanceIdForChunks, personaId, true,
846+
{
847+
finalResponseText: typeof gmiChunk.content === 'string' ? gmiChunk.content : "Processing complete.",
848+
// other fields like usage, trace would need to be on the FINAL_RESPONSE_MARKER content
849+
// or aggregated throughout the turn.
850+
updatedConversationContext: conversationContext.toJSON(),
851+
activePersonaDetails: snapshotPersonaDetails(gmi.getPersona?.()),
852+
}
853+
);
854+
this.activeStreamContexts.delete(agentOSStreamId);
855+
await this.dependencies.streamingManager.closeStream(agentOSStreamId, "GMI processing complete (final marker).");
855856
}
856857
break;
857858
case GMIOutputChunkType.USAGE_UPDATE:

src/cognitive_substrate/GMI.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ export class GMI implements IGMI {
328328
case GMIInteractionType.MULTIMODAL_CONTENT:
329329
messageToAdd = { role: 'user', content: turnInput.content as any, name: turnInput.metadata?.userName || turnInput.userId };
330330
break;
331-
case GMIInteractionType.TOOL_RESPONSE:
331+
case GMIInteractionType.TOOL_RESPONSE: {
332332
const results = Array.isArray(turnInput.content) ? turnInput.content as ToolCallResult[] : [turnInput.content as ToolCallResult];
333333
results.forEach(result => {
334334
this.conversationHistory.push({
@@ -339,6 +339,7 @@ export class GMI implements IGMI {
339339
});
340340
});
341341
break;
342+
}
342343
case GMIInteractionType.SYSTEM_MESSAGE:
343344
messageToAdd = { role: 'system', content: turnInput.content as string };
344345
break;

src/core/agents/AgentPoolAgent.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ export class AgentPoolAgent extends AgentCore implements IAgent {
288288
return await this.handleDirectDelegation(userInput, conversationContext);
289289
case AgentPoolStrategy.EXPLORATORY_GENERATION:
290290
return await this.handleExploratoryGeneration(userInput, conversationContext);
291-
default:
291+
default: {
292292
const errorMsg = `AgentPoolAgent '${this.name}': Unhandled or unknown strategy '${this.poolConfig.strategy}'.`;
293293
console.error(errorMsg);
294294
// Use the inherited error handler to explain this to the user via LLM
@@ -297,6 +297,7 @@ export class AgentPoolAgent extends AgentCore implements IAgent {
297297
conversationContext,
298298
true // This is fatal for the turn
299299
);
300+
}
300301
}
301302
} catch (error: any) {
302303
const strategyErrorMsg = `Error executing strategy '${this.poolConfig.strategy}' in AgentPoolAgent '${this.name}': ${error.message}`;

src/core/audio/AdaptiveVAD.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@ export interface AdaptiveVADConfig {
8585
// spectralConfig?: { zcrThreshold?: number; fluxThreshold?: number; };
8686
}
8787

88-
// Declare emit and on methods more strongly for typed events
89-
export declare interface AdaptiveVAD {
90-
on<U extends keyof VADEmitterEvents>(event: U, listener: VADEmitterEvents[U]): this;
91-
emit<U extends keyof VADEmitterEvents>(event: U, ...args: Parameters<VADEmitterEvents[U]>): boolean;
92-
}
93-
9488
/**
9589
* AdaptiveVAD - Detects speech in audio frames, adapting to environmental noise.
9690
*/
@@ -117,6 +111,15 @@ export class AdaptiveVAD extends EventEmitter {
117111

118112
private energyHistory: number[] = []; // For smoothing
119113

114+
// Strongly typed event helpers
115+
public override on<U extends keyof VADEmitterEvents>(event: U, listener: VADEmitterEvents[U]): this {
116+
return super.on(event, listener);
117+
}
118+
119+
public override emit<U extends keyof VADEmitterEvents>(event: U, ...args: Parameters<VADEmitterEvents[U]>): boolean {
120+
return super.emit(event, ...args);
121+
}
122+
120123
/**
121124
* Creates a new AdaptiveVAD instance.
122125
* @param {AdaptiveVADConfig} config - VAD configuration options.

src/core/audio/AudioProcessor.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ export interface WebAudioProcessorEvents extends VADEmitterEvents {
7676
'raw_audio_frame': (frame: Float32Array, sampleRate: number) => void;
7777
}
7878

79-
export declare interface AudioProcessor {
80-
on<U extends keyof WebAudioProcessorEvents>(event: U, listener: WebAudioProcessorEvents[U]): this;
81-
emit<U extends keyof WebAudioProcessorEvents>(event: U, ...args: Parameters<WebAudioProcessorEvents[U]>): boolean;
82-
}
83-
8479
/**
8580
* AudioProcessor - Central client-side audio processing pipeline using Web Audio APIs.
8681
* Orchestrates EnvironmentalCalibrator (web-version) and AdaptiveVAD (logic-version).
@@ -105,6 +100,14 @@ export class AudioProcessor extends EventEmitter {
105100

106101
private internalState: AudioProcessorState;
107102

103+
public override on<U extends keyof WebAudioProcessorEvents>(event: U, listener: WebAudioProcessorEvents[U]): this {
104+
return super.on(event, listener);
105+
}
106+
107+
public override emit<U extends keyof WebAudioProcessorEvents>(event: U, ...args: Parameters<WebAudioProcessorEvents[U]>): boolean {
108+
return super.emit(event, ...args);
109+
}
110+
108111
constructor(
109112
config: WebAudioProcessorConfig = {},
110113
calibrationConfig: CalibrationConfig = {}, // For web-based EnvironmentalCalibrator

0 commit comments

Comments
 (0)