@moxxy/plugin-provider-admin 0.41.3 → 0.42.1
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/package.json +7 -7
- package/src/configure.test.ts +4 -2
- package/src/index.test.ts +5 -3
- package/src/key-name.test.ts +2 -1
- package/src/store.test.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moxxy/plugin-provider-admin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.1",
|
|
4
4
|
"description": "Model-callable provider admin: provider_add / provider_list / provider_remove / provider_test. Persists user-registered providers to ~/.moxxy/providers.json and hot-registers them in the live session by wrapping the OpenAI-compatible client with a vendor baseURL.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"moxxy",
|
|
@@ -47,16 +47,16 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"openai": "^
|
|
50
|
+
"openai": "^7.27.0",
|
|
51
51
|
"zod": "^3.25.76",
|
|
52
|
-
"@moxxy/config": "0.
|
|
53
|
-
"@moxxy/
|
|
54
|
-
"@moxxy/
|
|
52
|
+
"@moxxy/config": "0.42.1",
|
|
53
|
+
"@moxxy/plugin-provider-openai": "0.42.1",
|
|
54
|
+
"@moxxy/sdk": "0.42.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@types/node": "^22.
|
|
57
|
+
"@types/node": "^22.20.5",
|
|
58
58
|
"typescript": "^6.0.3",
|
|
59
|
-
"vitest": "^
|
|
59
|
+
"vitest": "^5.0.3",
|
|
60
60
|
"@moxxy/tsconfig": "0.0.0",
|
|
61
61
|
"@moxxy/vitest-preset": "0.0.0"
|
|
62
62
|
},
|
package/src/configure.test.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { posixFileModes } from '@moxxy/vitest-preset/platform';
|
|
2
3
|
import { promises as fs } from 'node:fs';
|
|
3
4
|
import * as os from 'node:os';
|
|
4
5
|
import * as path from 'node:path';
|
|
@@ -6,6 +7,7 @@ import { MoxxyError, type ProviderDef } from '@moxxy/sdk';
|
|
|
6
7
|
import { buildProviderAdminPluginWithApi, type ProviderRegistryLike } from './index.js';
|
|
7
8
|
import { readProvidersConfig, upsertStoredProvider } from './store.js';
|
|
8
9
|
import type { StoredProvider } from './types.js';
|
|
10
|
+
import { removeDir } from '@moxxy/vitest-preset/fs';
|
|
9
11
|
|
|
10
12
|
class FakeRegistry implements ProviderRegistryLike {
|
|
11
13
|
defs = new Map<string, ProviderDef>();
|
|
@@ -47,7 +49,7 @@ beforeEach(async () => {
|
|
|
47
49
|
});
|
|
48
50
|
|
|
49
51
|
afterEach(async () => {
|
|
50
|
-
await
|
|
52
|
+
await removeDir(tmpDir);
|
|
51
53
|
});
|
|
52
54
|
|
|
53
55
|
function build(reg: ProviderRegistryLike = registry) {
|
|
@@ -125,7 +127,7 @@ describe('buildProviderAdminPluginWithApi.configure', () => {
|
|
|
125
127
|
expect(stored.defaultModel).toBe('glm-4.5-air');
|
|
126
128
|
});
|
|
127
129
|
|
|
128
|
-
it('rolls back the live def to the prior registration when the disk write fails', async () => {
|
|
130
|
+
it.skipIf(!posixFileModes)('rolls back the live def to the prior registration when the disk write fails', async () => {
|
|
129
131
|
// The entry is readable on disk AND already live in the registry (owned by
|
|
130
132
|
// the plugin via onInit), but the write target is made unwritable so
|
|
131
133
|
// upsertStoredProvider rejects after the live replace() — driving the
|
package/src/index.test.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { posixFileModes } from '@moxxy/vitest-preset/platform';
|
|
2
3
|
import { promises as fs } from 'node:fs';
|
|
3
4
|
import * as os from 'node:os';
|
|
4
5
|
import * as path from 'node:path';
|
|
5
6
|
import type { ProviderDef, ToolContext, ToolDef } from '@moxxy/sdk';
|
|
6
7
|
import { buildProviderAdminPlugin, buildProviderAdminPluginWithApi, type ProviderRegistryLike } from './index.js';
|
|
7
8
|
import { readProvidersConfig } from './store.js';
|
|
9
|
+
import { removeDir } from '@moxxy/vitest-preset/fs';
|
|
8
10
|
|
|
9
11
|
// Stub ONLY the network probe; buildProviderDef stays real. Lets the
|
|
10
12
|
// provider_test tests assert what key the validator received without ever
|
|
@@ -63,7 +65,7 @@ beforeEach(async () => {
|
|
|
63
65
|
});
|
|
64
66
|
|
|
65
67
|
afterEach(async () => {
|
|
66
|
-
await
|
|
68
|
+
await removeDir(tmpDir);
|
|
67
69
|
});
|
|
68
70
|
|
|
69
71
|
function call(name: string, input: Record<string, unknown>): Promise<unknown> {
|
|
@@ -182,7 +184,7 @@ describe('provider_add', () => {
|
|
|
182
184
|
expect(withBuiltin.defs.get('openai')).toBe(builtinDef);
|
|
183
185
|
});
|
|
184
186
|
|
|
185
|
-
it('restores the prior def (not deletes it) when the disk write fails on a replace', async () => {
|
|
187
|
+
it.skipIf(!posixFileModes)('restores the prior def (not deletes it) when the disk write fails on a replace', async () => {
|
|
186
188
|
// Seed a 'zai' entry on disk + run onInit so the PLUGIN owns the live def (a
|
|
187
189
|
// def WE registered, not an external built-in). A later provider_add of the
|
|
188
190
|
// same slug is a genuine replace; if the disk write fails the prior owned
|
|
@@ -213,7 +215,7 @@ describe('provider_add', () => {
|
|
|
213
215
|
expect(reg.defs.get('zai')).toBe(priorDef);
|
|
214
216
|
});
|
|
215
217
|
|
|
216
|
-
it('unregisters a brand-new provider when the disk write fails (no phantom)', async () => {
|
|
218
|
+
it.skipIf(!posixFileModes)('unregisters a brand-new provider when the disk write fails (no phantom)', async () => {
|
|
217
219
|
// Fresh slug (not owned, not in registry) → register + write. Make the dir
|
|
218
220
|
// read-only so the write fails; the phantom registration must be rolled back.
|
|
219
221
|
const reg = new FakeRegistry();
|
package/src/key-name.test.ts
CHANGED
|
@@ -5,6 +5,7 @@ import * as path from 'node:path';
|
|
|
5
5
|
import { providerApiKeyName, storedProviderApiKeyName } from './key-name.js';
|
|
6
6
|
import { upsertStoredProvider } from './store.js';
|
|
7
7
|
import type { StoredProvider } from './types.js';
|
|
8
|
+
import { removeDir } from '@moxxy/vitest-preset/fs';
|
|
8
9
|
|
|
9
10
|
describe('providerApiKeyName', () => {
|
|
10
11
|
it('upper-snakes the slug and appends _API_KEY', () => {
|
|
@@ -33,7 +34,7 @@ describe('storedProviderApiKeyName', () => {
|
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
afterEach(async () => {
|
|
36
|
-
await
|
|
37
|
+
await removeDir(tmpDir);
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
const entry = (over: Partial<StoredProvider> = {}): StoredProvider => ({
|
package/src/store.test.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
upsertStoredProvider,
|
|
9
9
|
} from './store.js';
|
|
10
10
|
import type { StoredProvider } from './types.js';
|
|
11
|
+
import { removeDir } from '@moxxy/vitest-preset/fs';
|
|
11
12
|
|
|
12
13
|
const sampleEntry: StoredProvider = {
|
|
13
14
|
kind: 'openai-compat',
|
|
@@ -27,7 +28,7 @@ beforeEach(async () => {
|
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
afterEach(async () => {
|
|
30
|
-
await
|
|
31
|
+
await removeDir(tmpDir);
|
|
31
32
|
});
|
|
32
33
|
|
|
33
34
|
describe('stored-provider tree store (plugins.provider.items)', () => {
|