Skip to content

Commit 8715be7

Browse files
author
HEXA_E
committed
test: add changeset and tests for Z.ai GLM provider
1 parent 5b501a1 commit 8715be7

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

.changeset/add-zai-glm-provider.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@open-codesign/shared": minor
3+
"@open-codesign/providers": patch
4+
---
5+
6+
Add Z.ai (GLM Coding Plan) as a built-in provider with support for GLM-5.1, GLM-5-Turbo, GLM-4.7, and GLM-4.5-Air models via the Anthropic-compatible API endpoint.

packages/shared/src/config.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,3 +499,46 @@ describe('provider capability helpers', () => {
499499
expect(caps.modelDiscoveryMode).toBe('manual');
500500
});
501501
});
502+
503+
describe('zai builtin provider', () => {
504+
it('has a well-formed zai entry in BUILTIN_PROVIDERS', () => {
505+
const zai = BUILTIN_PROVIDERS.zai;
506+
expect(zai).toBeDefined();
507+
expect(zai.id).toBe('zai');
508+
expect(zai.name).toBe('Z.ai (GLM Coding Plan)');
509+
expect(zai.builtin).toBe(true);
510+
expect(zai.wire).toBe('anthropic');
511+
expect(zai.baseUrl).toBe('https://api.z.ai/api/anthropic');
512+
expect(zai.defaultModel).toBe('glm-5.1');
513+
expect(zai.modelsHint).toEqual(['glm-5.1', 'glm-5-turbo', 'glm-4.7', 'glm-4.5-air']);
514+
expect(zai.requiresApiKey).toBe(true);
515+
});
516+
517+
it('zai capabilities are set for static-hint discovery with reasoning', () => {
518+
const caps = resolveProviderCapabilities('zai', BUILTIN_PROVIDERS.zai);
519+
expect(caps.supportsKeyless).toBe(false);
520+
expect(caps.supportsModelsEndpoint).toBe(false);
521+
expect(caps.supportsReasoning).toBe(true);
522+
expect(caps.modelDiscoveryMode).toBe('static-hint');
523+
});
524+
525+
it('zai is included in SUPPORTED_ONBOARDING_PROVIDERS', () => {
526+
expect(SUPPORTED_ONBOARDING_PROVIDERS).toContain('zai');
527+
});
528+
529+
it('detects z.ai anthropic URL as anthropic wire', () => {
530+
expect(detectWireFromBaseUrl('https://api.z.ai/api/anthropic')).toBe('anthropic');
531+
});
532+
533+
it('accepts zai as active provider in v3 config', () => {
534+
const parsed = ConfigV3Schema.parse({
535+
version: 3,
536+
activeProvider: 'zai',
537+
activeModel: 'glm-5.1',
538+
secrets: { zai: { ciphertext: 'plain:sk-test', mask: 'sk-***test' } },
539+
providers: { zai: BUILTIN_PROVIDERS.zai },
540+
});
541+
expect(parsed.activeProvider).toBe('zai');
542+
expect(parsed.activeModel).toBe('glm-5.1');
543+
});
544+
});

0 commit comments

Comments
 (0)