feat: add pluggable workflow orchestrator controls
This commit is contained in:
@@ -90,6 +90,88 @@ test('admin memory-v2 config routes expose config and runtime state', async () =
|
||||
}
|
||||
});
|
||||
|
||||
test('admin orchestrator routes expose a versioned plug-in control plane', async () => {
|
||||
const updates = [];
|
||||
const state = {
|
||||
config: {
|
||||
mode: 'off',
|
||||
primaryEngine: 'langgraph',
|
||||
fallbackEngine: 'native',
|
||||
serviceUrl: '',
|
||||
requestTimeoutMs: 5000,
|
||||
rolloutPercent: 0,
|
||||
userAllowlist: [],
|
||||
workflowAllowlist: ['code-run-v1'],
|
||||
fallbackToNative: true,
|
||||
requireHealthy: true,
|
||||
},
|
||||
configVersion: 1,
|
||||
runtime: { effective: false, reason: 'mode_off' },
|
||||
engines: [{ id: 'native', configured: true }, { id: 'langgraph', configured: false }],
|
||||
};
|
||||
const router = createAdminApi({
|
||||
jsonBody: express.json(),
|
||||
getToken() {
|
||||
return 'token-admin';
|
||||
},
|
||||
userAuth: {
|
||||
async getMe() {
|
||||
return { id: 'admin-1', role: 'admin' };
|
||||
},
|
||||
},
|
||||
llmProviderService: null,
|
||||
memoryV2ConfigService: null,
|
||||
orchestratorConfigService: {
|
||||
async getAdminConfig() {
|
||||
return state;
|
||||
},
|
||||
async updateAdminConfig(config, context) {
|
||||
updates.push({ config, context });
|
||||
return { ...state, config: { ...state.config, ...config }, configVersion: 2 };
|
||||
},
|
||||
async getRuntimeState() {
|
||||
return { ...state, source: 'admin-db' };
|
||||
},
|
||||
},
|
||||
plazaPosts: null,
|
||||
plazaOps: null,
|
||||
wechatAdmin: null,
|
||||
subscriptionService: null,
|
||||
});
|
||||
|
||||
const server = await startTestServer(router);
|
||||
try {
|
||||
const configResponse = await fetch(`${server.baseUrl}/admin-api/orchestrator/config`, {
|
||||
headers: { cookie: 'h5_user_session=token-admin' },
|
||||
});
|
||||
assert.equal(configResponse.status, 200);
|
||||
assert.equal((await configResponse.json()).config.mode, 'off');
|
||||
|
||||
const updateResponse = await fetch(`${server.baseUrl}/admin-api/orchestrator/config`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
cookie: 'h5_user_session=token-admin',
|
||||
},
|
||||
body: JSON.stringify({ config: { mode: 'shadow', serviceUrl: 'http://127.0.0.1:8093' } }),
|
||||
});
|
||||
assert.equal(updateResponse.status, 200);
|
||||
assert.equal((await updateResponse.json()).configVersion, 2);
|
||||
assert.deepEqual(updates, [{
|
||||
config: { mode: 'shadow', serviceUrl: 'http://127.0.0.1:8093' },
|
||||
context: { updatedBy: 'admin-1' },
|
||||
}]);
|
||||
|
||||
const runtimeResponse = await fetch(`${server.baseUrl}/admin-api/orchestrator/runtime`, {
|
||||
headers: { cookie: 'h5_user_session=token-admin' },
|
||||
});
|
||||
assert.equal(runtimeResponse.status, 200);
|
||||
assert.equal((await runtimeResponse.json()).source, 'admin-db');
|
||||
} finally {
|
||||
await server.close();
|
||||
}
|
||||
});
|
||||
|
||||
test('admin system disclosure policy routes version config through the injected control-plane service', async () => {
|
||||
const updates = [];
|
||||
const config = {
|
||||
|
||||
Reference in New Issue
Block a user