opencode-morphllm 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitleaks.toml +6 -0
- package/.husky/pre-commit +3 -1
- package/.prettierignore +1 -0
- package/.prettierrc +1 -1
- package/README.md +21 -2
- package/bun.lock +23 -0
- package/bunfig.toml +4 -0
- package/dist/index.js +13 -14
- package/dist/morph/mcps.js +15 -0
- package/dist/morph/mcps.test.d.ts +1 -0
- package/dist/morph/mcps.test.js +39 -0
- package/dist/morph/router.d.ts +22 -0
- package/dist/morph/router.js +65 -0
- package/dist/morph/router.test.d.ts +1 -0
- package/dist/morph/router.test.js +239 -0
- package/dist/shared/config.d.ts +29 -0
- package/dist/shared/config.js +80 -0
- package/dist/shared/config.test.d.ts +1 -0
- package/dist/shared/config.test.js +201 -0
- package/dist/shared/opencode-config-dir.d.ts +18 -8
- package/dist/shared/opencode-config-dir.js +93 -47
- package/dist/shared/opencode-config-dir.test.d.ts +1 -0
- package/dist/shared/opencode-config-dir.test.js +310 -0
- package/package.json +3 -2
- package/src/index.ts +3 -4
- package/src/morph/mcps.test.ts +51 -0
- package/src/{mcps.ts → morph/mcps.ts} +1 -1
- package/src/morph/router.test.ts +267 -0
- package/src/{router.ts → morph/router.ts} +29 -3
- package/src/shared/config.test.ts +257 -0
- package/src/{config.ts → shared/config.ts} +30 -6
- package/src/shared/opencode-config-dir.test.ts +404 -0
- package/src/shared/opencode-config-dir.ts +90 -11
- package/dist/config.d.ts +0 -20
- package/dist/config.js +0 -71
- package/dist/mcps.js +0 -15
- package/dist/router.d.ts +0 -27
- package/dist/router.js +0 -51
- /package/dist/{mcps.d.ts → morph/mcps.d.ts} +0 -0
package/dist/router.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { MorphClient } from '@morphllm/morphsdk';
|
|
2
|
-
import {
|
|
3
|
-
API_KEY,
|
|
4
|
-
MORPH_MODEL_EASY,
|
|
5
|
-
MORPH_MODEL_MEDIUM,
|
|
6
|
-
MORPH_MODEL_HARD,
|
|
7
|
-
MORPH_MODEL_DEFAULT,
|
|
8
|
-
} from './config';
|
|
9
|
-
const morph = new MorphClient({ apiKey: API_KEY });
|
|
10
|
-
function parseModel(s) {
|
|
11
|
-
if (!s) return { providerID: '', modelID: '' };
|
|
12
|
-
const [providerID = '', modelID = ''] = s.split('/');
|
|
13
|
-
return { providerID, modelID };
|
|
14
|
-
}
|
|
15
|
-
function pickModelForDifficulty(difficulty) {
|
|
16
|
-
const key = String(difficulty).toLowerCase();
|
|
17
|
-
switch (key) {
|
|
18
|
-
case 'easy':
|
|
19
|
-
return parseModel(MORPH_MODEL_EASY);
|
|
20
|
-
case 'medium':
|
|
21
|
-
return parseModel(MORPH_MODEL_MEDIUM);
|
|
22
|
-
case 'hard':
|
|
23
|
-
return parseModel(MORPH_MODEL_HARD);
|
|
24
|
-
default:
|
|
25
|
-
return parseModel(MORPH_MODEL_DEFAULT);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export function createModelRouterHook() {
|
|
29
|
-
return {
|
|
30
|
-
'chat.message': async (input, output) => {
|
|
31
|
-
input.model = input.model ?? { providerID: '', modelID: '' };
|
|
32
|
-
const promptText = extractPromptText(output.parts);
|
|
33
|
-
const classifier =
|
|
34
|
-
input.classify ?? ((args) => morph.routers.raw.classify(args));
|
|
35
|
-
const classification = await classifier({
|
|
36
|
-
input: promptText,
|
|
37
|
-
});
|
|
38
|
-
const chosen = pickModelForDifficulty(classification?.difficulty);
|
|
39
|
-
const finalProviderID = chosen.providerID || input.model.providerID;
|
|
40
|
-
const finalModelID = chosen.modelID || input.model.modelID;
|
|
41
|
-
input.model.providerID = finalProviderID;
|
|
42
|
-
input.model.modelID = finalModelID;
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export function extractPromptText(parts) {
|
|
47
|
-
return parts
|
|
48
|
-
.filter((p) => p.type === 'text')
|
|
49
|
-
.map((p) => p.text || '')
|
|
50
|
-
.join(' ');
|
|
51
|
-
}
|
|
File without changes
|