-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
2,068 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
export default { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
extensionsToTreatAsEsm: ['.ts'], | ||
moduleNameMapper: { | ||
'^(\\.{1,2}/.*)\\.js$': '$1', | ||
}, | ||
transform: { | ||
'^.+\\.tsx?$': [ | ||
'ts-jest', | ||
{ | ||
useESM: true, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Client, IAgentRuntime } from "@elizaos/core"; | ||
import { describe, it, expect } from '@jest/globals'; | ||
|
||
// Helper function to identify client types | ||
function determineClientType(client: Client): string { | ||
// Check if client has a direct type identifier | ||
if ('type' in client) { | ||
return (client as any).type; | ||
} | ||
|
||
// Check constructor name | ||
const constructorName = client.constructor?.name; | ||
if (constructorName && !constructorName.includes('Object')) { | ||
return constructorName.toLowerCase().replace('client', ''); | ||
} | ||
|
||
// Fallback: Generate a unique identifier | ||
return `client_${Date.now()}`; | ||
} | ||
|
||
// Mock client implementations for testing | ||
class MockNamedClient implements Client { | ||
type = "named-client"; | ||
async start(_runtime?: IAgentRuntime) { return this; } | ||
async stop(_runtime?: IAgentRuntime) { } | ||
} | ||
|
||
class MockConstructorClient implements Client { | ||
async start(_runtime?: IAgentRuntime) { return this; } | ||
async stop(_runtime?: IAgentRuntime) { } | ||
} | ||
|
||
const mockPlainClient: Client = { | ||
async start(_runtime?: IAgentRuntime) { return {}; }, | ||
async stop(_runtime?: IAgentRuntime) { } | ||
}; | ||
|
||
describe("Client Type Identification", () => { | ||
it("should identify client type from type property", () => { | ||
const client = new MockNamedClient(); | ||
expect(determineClientType(client)).toBe("named-client"); | ||
}); | ||
|
||
it("should identify client type from constructor name", () => { | ||
const client = new MockConstructorClient(); | ||
expect(determineClientType(client)).toBe("mockconstructor"); | ||
}); | ||
|
||
it("should generate fallback identifier for plain objects", () => { | ||
const result = determineClientType(mockPlainClient); | ||
expect(result).toMatch(/^client_\d+$/); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ | |
"module": "ESNext", | ||
"moduleResolution": "Bundler", | ||
"types": [ | ||
"node" | ||
"node", | ||
"jest" | ||
] | ||
}, | ||
"ts-node": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
{ | ||
"compilerOptions": { | ||
"incremental": true, | ||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", | ||
"target": "ES2020", | ||
"useDefineForClassFields": true, | ||
"lib": ["ES2020", "DOM", "DOM.Iterable"], | ||
"lib": [ | ||
"ES2020", | ||
"DOM", | ||
"DOM.Iterable" | ||
], | ||
"module": "ESNext", | ||
"skipLibCheck": true, | ||
|
||
/* Bundler mode */ | ||
"moduleResolution": "Bundler", | ||
"allowImportingTsExtensions": true, | ||
"isolatedModules": true, | ||
"moduleDetection": "force", | ||
"noEmit": true, | ||
"jsx": "react-jsx", | ||
|
||
/* Linting */ | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noUncheckedSideEffectImports": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["./src/*"] | ||
"@/*": [ | ||
"./src/*" | ||
] | ||
} | ||
}, | ||
"include": ["src"] | ||
} | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
{ | ||
"compilerOptions": { | ||
"incremental": true, | ||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", | ||
"target": "ES2022", | ||
"lib": ["ES2023"], | ||
"lib": [ | ||
"ES2023" | ||
], | ||
"module": "ESNext", | ||
"skipLibCheck": true, | ||
|
||
/* Bundler mode */ | ||
"moduleResolution": "Bundler", | ||
"allowImportingTsExtensions": true, | ||
"isolatedModules": true, | ||
"moduleDetection": "force", | ||
"noEmit": true, | ||
|
||
/* Linting */ | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noUncheckedSideEffectImports": true | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"include": ["vite.config.ts"] | ||
} | ||
"include": [ | ||
"vite.config.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.